Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 427 lines (383 sloc) 13.737 kb
cfd7b4d added licensing information on the new files
Laurent Sansonetti authored
1 /*
2 * MacRuby compiler.
3 *
4 * This file is covered by the Ruby license. See COPYING for more details.
5 *
4aca101 @drernie Added 2010 Copyrights
drernie authored
6 * Copyright (C) 2008-2010, Apple Inc. All rights reserved.
cfd7b4d added licensing information on the new files
Laurent Sansonetti authored
7 */
8
cb65416 the great schism, part I
Laurent Sansonetti authored
9 #ifndef __COMPILER_H_
10 #define __COMPILER_H_
11
12 #if defined(__cplusplus)
13
14 // For the dispatcher.
9590d40 fixing and adding several missing ruby method features
Laurent Sansonetti authored
15 #define DISPATCH_VCALL 1 // no receiver, no argument
16 #define DISPATCH_FCALL 2 // no receiver, one or more arguments
17 #define DISPATCH_SUPER 3 // super call
18 #define DISPATCH_SELF_ATTRASGN 4 // self attribute assignment
19 #define SPLAT_ARG_FOLLOWS 0xdeadbeef
cb65416 the great schism, part I
Laurent Sansonetti authored
20
370e385 get rid of bad allocas, disable frame pointer elimination, simplified co...
Laurent Sansonetti authored
21 // For const lookup.
22 #define CONST_LOOKUP_LEXICAL 1
23 #define CONST_LOOKUP_DYNAMIC_CLASS 2
24
cb65416 the great schism, part I
Laurent Sansonetti authored
25 // For defined?
26 #define DEFINED_IVAR 1
27 #define DEFINED_GVAR 2
28 #define DEFINED_CVAR 3
29 #define DEFINED_CONST 4
30 #define DEFINED_LCONST 5
31 #define DEFINED_SUPER 6
32 #define DEFINED_METHOD 7
33
34 class RoxorCompiler {
35 public:
36 static llvm::Module *module;
37 static RoxorCompiler *shared;
38
cf73725 experimental debugger
Laurent Sansonetti authored
39 RoxorCompiler(bool debug_mode);
cb65416 the great schism, part I
Laurent Sansonetti authored
40 virtual ~RoxorCompiler(void) { }
41
0f14388 emit dwarf metadata at compilation time and use it to establish backtrac...
Laurent Sansonetti authored
42 void set_fname(const char *_fname);
3432fd1 a better exception-based implementation for return-from-block
Laurent Sansonetti authored
43
cb65416 the great schism, part I
Laurent Sansonetti authored
44 Value *compile_node(NODE *node);
45
46 virtual Function *compile_main_function(NODE *node);
47 Function *compile_read_attr(ID name);
48 Function *compile_write_attr(ID name);
9fab1ac fixed variadic functions/methods calls
Laurent Sansonetti authored
49 Function *compile_stub(const char *types, bool variadic, int min_argc,
50 bool is_objc);
485e435 Allow methods/blocks with 12+ arguments
Thibault Martin-Lagardette authored
51 Function *compile_long_arity_stub(int argc, bool is_block);
cb65416 the great schism, part I
Laurent Sansonetti authored
52 Function *compile_bs_struct_new(rb_vm_bs_boxed_t *bs_boxed);
53 Function *compile_bs_struct_writer(rb_vm_bs_boxed_t *bs_boxed,
54 int field);
55 Function *compile_ffi_function(void *stub, void *imp, int argc);
56 Function *compile_to_rval_convertor(const char *type);
57 Function *compile_to_ocval_convertor(const char *type);
c1c347f AOT compiler: now supporting objc stubs and super dispatch
Laurent Sansonetti authored
58 Function *compile_objc_stub(Function *ruby_func, IMP ruby_imp,
59 const rb_vm_arity_t &arity, const char *types);
208a965 a quick implementation for #define_method (not yet 100% complete)
Laurent Sansonetti authored
60 Function *compile_block_caller(rb_vm_block_t *block);
4b7c757 cleaning a bit public headers, added support for methods defined for the...
Laurent Sansonetti authored
61 Function *compile_mri_stub(void *imp, const int arity);
cb65416 the great schism, part I
Laurent Sansonetti authored
62
63 const Type *convert_type(const char *type);
64
c219e86 don't slow ivars used inside an eval string
Laurent Sansonetti authored
65 bool is_inside_eval(void) { return inside_eval; }
66 void set_inside_eval(bool flag) { inside_eval = flag; }
12a1d67 fixing bugs in instance_eval & friends + fixed some specs so that they p...
Laurent Sansonetti authored
67 bool is_dynamic_class(void) { return dynamic_class; }
68 void set_dynamic_class(bool flag) { dynamic_class = flag; }
c219e86 don't slow ivars used inside an eval string
Laurent Sansonetti authored
69
cb65416 the great schism, part I
Laurent Sansonetti authored
70 protected:
0f14388 emit dwarf metadata at compilation time and use it to establish backtrac...
Laurent Sansonetti authored
71 DIFactory *debug_info;
72 DICompileUnit debug_compile_unit;
73 DISubprogram debug_subprogram;
74
cf73725 experimental debugger
Laurent Sansonetti authored
75 bool debug_mode;
cb65416 the great schism, part I
Laurent Sansonetti authored
76 const char *fname;
c219e86 don't slow ivars used inside an eval string
Laurent Sansonetti authored
77 bool inside_eval;
cb65416 the great schism, part I
Laurent Sansonetti authored
78
79 std::map<ID, Value *> lvars;
80 std::vector<ID> dvars;
f61f2c7 @vincentisambart const pointers should be real constants
vincentisambart authored
81 std::map<ID, Value *> ivar_slots_cache;
cb65416 the great schism, part I
Laurent Sansonetti authored
82 std::map<std::string, GlobalVariable *> static_strings;
e379686 some work on unicode support (still in progress)
Laurent Sansonetti authored
83 std::map<CFHashCode, GlobalVariable *> static_ustrings;
cb65416 the great schism, part I
Laurent Sansonetti authored
84
85 #if ROXOR_COMPILER_DEBUG
86 int level;
87 # define DEBUG_LEVEL_INC() (level++)
88 # define DEBUG_LEVEL_DEC() (level--)
89 #else
90 # define DEBUG_LEVEL_INC()
91 # define DEBUG_LEVEL_DEC()
92 #endif
93
2541db3 added preliminary support for backtracing/symbolication
Laurent Sansonetti authored
94 unsigned int current_line;
cb65416 the great schism, part I
Laurent Sansonetti authored
95 BasicBlock *bb;
96 BasicBlock *entry_bb;
97 ID current_mid;
164ca93 fixed super within a method that has a splat argument
Laurent Sansonetti authored
98 rb_vm_arity_t current_arity;
cb65416 the great schism, part I
Laurent Sansonetti authored
99 bool current_instance_method;
100 ID self_id;
101 Value *current_self;
102 bool current_block;
1961daa better fix than last one
Laurent Sansonetti authored
103 bool current_block_chain;
cb65416 the great schism, part I
Laurent Sansonetti authored
104 Value *current_var_uses;
105 Value *running_block;
cc6f8a9 fixed a bug in super without argument, it should pass the method's &bloc...
Laurent Sansonetti authored
106 Value *current_block_arg;
cb65416 the great schism, part I
Laurent Sansonetti authored
107 BasicBlock *begin_bb;
63c77f8 @vincentisambart now rescues in rescues should work properly in most cases
vincentisambart authored
108 // block used in an invoke when an exception occurs
109 BasicBlock *rescue_invoke_bb;
110 // block to return to in a rescue if an exception is not handled
111 BasicBlock *rescue_rethrow_bb;
cb65416 the great schism, part I
Laurent Sansonetti authored
112 BasicBlock *ensure_bb;
113 bool current_rescue;
114 NODE *current_block_node;
115 Function *current_block_func;
116 GlobalVariable *current_opened_class;
12a1d67 fixing bugs in instance_eval & friends + fixed some specs so that they p...
Laurent Sansonetti authored
117 bool dynamic_class;
cb65416 the great schism, part I
Laurent Sansonetti authored
118 bool current_module;
119 BasicBlock *current_loop_begin_bb;
120 BasicBlock *current_loop_body_bb;
121 BasicBlock *current_loop_end_bb;
513ee74 @vincentisambart Fixed the return value of while/until loops
vincentisambart authored
122 PHINode *current_loop_exit_val;
3432fd1 a better exception-based implementation for return-from-block
Laurent Sansonetti authored
123 int return_from_block;
124 int return_from_block_ids;
5d7a33f @vincentisambart when there are multiple returns in an ensure,
vincentisambart authored
125 PHINode *ensure_pn;
13f5368 fixed a bunch of super-dispatch bugs
Laurent Sansonetti authored
126 bool block_declaration;
cb65416 the great schism, part I
Laurent Sansonetti authored
127
128 Function *dispatcherFunc;
38456a4 most fast ops in place
Laurent Sansonetti authored
129 Function *fastPlusFunc;
130 Function *fastMinusFunc;
131 Function *fastMultFunc;
132 Function *fastDivFunc;
133 Function *fastLtFunc;
134 Function *fastLeFunc;
135 Function *fastGtFunc;
136 Function *fastGeFunc;
944d624 optimize #== and #!= for non fixnum/float types
Laurent Sansonetti authored
137 Function *fastEqFunc;
138 Function *fastNeqFunc;
cb65416 the great schism, part I
Laurent Sansonetti authored
139 Function *fastEqqFunc;
140 Function *whenSplatFunc;
141 Function *prepareBlockFunc;
142 Function *pushBindingFunc;
143 Function *getBlockFunc;
144 Function *currentBlockObjectFunc;
145 Function *getConstFunc;
146 Function *setConstFunc;
147 Function *prepareMethodFunc;
148 Function *singletonClassFunc;
149 Function *defineClassFunc;
150 Function *prepareIvarSlotFunc;
151 Function *getIvarFunc;
152 Function *setIvarFunc;
153 Function *definedFunc;
154 Function *undefFunc;
155 Function *aliasFunc;
156 Function *valiasFunc;
157 Function *newHashFunc;
158 Function *toAFunc;
159 Function *toAryFunc;
160 Function *catArrayFunc;
161 Function *dupArrayFunc;
162 Function *newArrayFunc;
163 Function *newStructFunc;
164 Function *newOpaqueFunc;
ff75d60 added support for overwriting an ObjC method that accepts a pointer
Laurent Sansonetti authored
165 Function *newPointerFunc;
cb65416 the great schism, part I
Laurent Sansonetti authored
166 Function *getStructFieldsFunc;
167 Function *getOpaqueDataFunc;
168 Function *getPointerPtrFunc;
169 Function *checkArityFunc;
170 Function *setStructFunc;
171 Function *newRangeFunc;
172 Function *newRegexpFunc;
173 Function *strInternFunc;
174 Function *keepVarsFunc;
175 Function *masgnGetElemBeforeSplatFunc;
176 Function *masgnGetElemAfterSplatFunc;
177 Function *masgnGetSplatFunc;
178 Function *newStringFunc;
913687b fixed a bug in the way we compile literal strings
Laurent Sansonetti authored
179 Function *newString2Func;
180 Function *newString3Func;
cb65416 the great schism, part I
Laurent Sansonetti authored
181 Function *yieldFunc;
7da28cb make sure break makes yield return from its scope
Laurent Sansonetti authored
182 Function *getBrokenFunc;
208a965 a quick implementation for #define_method (not yet 100% complete)
Laurent Sansonetti authored
183 Function *blockEvalFunc;
cb65416 the great schism, part I
Laurent Sansonetti authored
184 Function *gvarSetFunc;
185 Function *gvarGetFunc;
186 Function *cvarSetFunc;
187 Function *cvarGetFunc;
188 Function *currentExceptionFunc;
189 Function *popExceptionFunc;
190 Function *getSpecialFunc;
191 Function *breakFunc;
6c5b476 a new implementation for return-from-block which uses an exception inste...
Laurent Sansonetti authored
192 Function *returnFromBlockFunc;
208c475 optimized returns from non-ensure-scoped and non-Proc blocks
Laurent Sansonetti authored
193 Function *returnedFromBlockFunc;
3432fd1 a better exception-based implementation for return-from-block
Laurent Sansonetti authored
194 Function *checkReturnFromBlockFunc;
208c475 optimized returns from non-ensure-scoped and non-Proc blocks
Laurent Sansonetti authored
195 Function *setHasEnsureFunc;
cb65416 the great schism, part I
Laurent Sansonetti authored
196 Function *longjmpFunc;
197 Function *setjmpFunc;
9590d40 fixing and adding several missing ruby method features
Laurent Sansonetti authored
198 Function *setScopeFunc;
199 Function *setCurrentClassFunc;
77f9768 implemented super from a block
Laurent Sansonetti authored
200 Function *getCacheFunc;
cf73725 experimental debugger
Laurent Sansonetti authored
201 Function *debugTrapFunc;
c437b62 - Adds the flip-flop operator (fixes #548)
Thibault Martin-Lagardette authored
202 Function *getFFStateFunc;
203 Function *setFFStateFunc;
ad56c99 when doing an assignment from thread X to thread Y's stack, defeat the t...
Laurent Sansonetti authored
204 Function *takeOwnershipFunc;
cb65416 the great schism, part I
Laurent Sansonetti authored
205
206 Constant *zeroVal;
207 Constant *oneVal;
208 Constant *twoVal;
01528a7 floating point arithmetic optimization: Float objects are now immediate ...
Laurent Sansonetti authored
209 Constant *threeVal;
cb65416 the great schism, part I
Laurent Sansonetti authored
210 Constant *nilVal;
211 Constant *trueVal;
212 Constant *falseVal;
213 Constant *undefVal;
214 Constant *splatArgFollowsVal;
9590d40 fixing and adding several missing ruby method features
Laurent Sansonetti authored
215 Constant *defaultScope;
216 Constant *publicScope;
bb0b28c moving to LLVM r82747
Laurent Sansonetti authored
217
218 const Type *VoidTy;
219 const Type *Int1Ty;
220 const Type *Int8Ty;
221 const Type *Int16Ty;
222 const Type *Int32Ty;
223 const Type *Int64Ty;
224 const Type *FloatTy;
225 const Type *DoubleTy;
cb65416 the great schism, part I
Laurent Sansonetti authored
226 const Type *RubyObjTy;
f61f2c7 @vincentisambart const pointers should be real constants
vincentisambart authored
227 const PointerType *RubyObjPtrTy;
228 const PointerType *RubyObjPtrPtrTy;
229 const PointerType *PtrTy;
230 const PointerType *PtrPtrTy;
cb65416 the great schism, part I
Laurent Sansonetti authored
231 const Type *IntTy;
f61f2c7 @vincentisambart const pointers should be real constants
vincentisambart authored
232 const PointerType *Int32PtrTy;
cb65416 the great schism, part I
Laurent Sansonetti authored
233
fa57162 follow LLVM ToT
Laurent Sansonetti authored
234 unsigned dbg_mdkind;
235
cb65416 the great schism, part I
Laurent Sansonetti authored
236 void compile_node_error(const char *msg, NODE *node);
237
f61f2c7 @vincentisambart const pointers should be real constants
vincentisambart authored
238 virtual Constant *
239 compile_const_pointer(void *ptr, const PointerType *type=NULL) {
85b7cc2 AOT compiler: ivar slots support
Laurent Sansonetti authored
240 if (type == NULL) {
241 type = PtrTy;
242 }
f61f2c7 @vincentisambart const pointers should be real constants
vincentisambart authored
243 if (ptr == NULL) {
244 return ConstantPointerNull::get(type);
245 }
246 else {
247 Constant *ptrint = ConstantInt::get(IntTy, (long)ptr);
248 return ConstantExpr::getIntToPtr(ptrint, type);
249 }
cb65416 the great schism, part I
Laurent Sansonetti authored
250 }
251
f61f2c7 @vincentisambart const pointers should be real constants
vincentisambart authored
252 Constant *
253 compile_const_pointer_to_pointer(void *ptr) {
254 return compile_const_pointer(ptr, PtrPtrTy);
cb65416 the great schism, part I
Laurent Sansonetti authored
255 }
256
c80c60a in the objc->ruby 32-bit stub convert ruby exceptions to objc
Laurent Sansonetti authored
257 Instruction *compile_protected_call(Value *imp,
cb65416 the great schism, part I
Laurent Sansonetti authored
258 std::vector<Value *> &params);
259 void compile_dispatch_arguments(NODE *args,
260 std::vector<Value *> &arguments, int *pargc);
261 Function::ArgumentListType::iterator compile_optional_arguments(
262 Function::ArgumentListType::iterator iter, NODE *node);
263 void compile_boolean_test(Value *condVal, BasicBlock *ifTrueBB,
264 BasicBlock *ifFalseBB);
265 void compile_when_arguments(NODE *args, Value *comparedToVal,
266 BasicBlock *thenBB);
267 void compile_single_when_argument(NODE *arg, Value *comparedToVal,
268 BasicBlock *thenBB);
12a1d67 fixing bugs in instance_eval & friends + fixed some specs so that they p...
Laurent Sansonetti authored
269 virtual void compile_prepare_method(Value *classVal, Value *sel,
270 bool singleton, Function *new_function, rb_vm_arity_t &arity,
9590d40 fixing and adding several missing ruby method features
Laurent Sansonetti authored
271 NODE *body);
cb65416 the great schism, part I
Laurent Sansonetti authored
272 Value *compile_dispatch_call(std::vector<Value *> &params);
273 Value *compile_when_splat(Value *comparedToVal, Value *splatVal);
944d624 optimize #== and #!= for non fixnum/float types
Laurent Sansonetti authored
274 Value *compile_fast_op_call(SEL sel, Value *selfVal, Value *comparedToVal);
cb65416 the great schism, part I
Laurent Sansonetti authored
275 Value *compile_attribute_assign(NODE *node, Value *extra_val);
2c54dbd AOT compiler: added support for blocks
Laurent Sansonetti authored
276 virtual Value *compile_prepare_block_args(Function *func, int *flags);
cc6f8a9 fixed a bug in super without argument, it should pass the method's &bloc...
Laurent Sansonetti authored
277 Value *compile_block_create(void);
278 Value *compile_block_get(Value *block_object);
cb65416 the great schism, part I
Laurent Sansonetti authored
279 Value *compile_binding(void);
280 Value *compile_optimized_dispatch_call(SEL sel, int argc,
281 std::vector<Value *> &params);
282 Value *compile_ivar_read(ID vid);
283 Value *compile_ivar_assignment(ID vid, Value *val);
284 Value *compile_cvar_assignment(ID vid, Value *val);
eeb7a10 added support for @@foo||=42, a lot of changes for a very stupid functio...
Laurent Sansonetti authored
285 Value *compile_cvar_get(ID vid, bool check);
42e4a2a AOT compiler: added support for global variables
Laurent Sansonetti authored
286 Value *compile_gvar_assignment(NODE *node, Value *val);
cb65416 the great schism, part I
Laurent Sansonetti authored
287 Value *compile_constant_declaration(NODE *node, Value *val);
288 Value *compile_multiple_assignment(NODE *node, Value *val);
289 void compile_multiple_assignment_element(NODE *node, Value *val);
290 Value *compile_current_class(void);
57d8085 AOT compiler: added support for NSObject and ID compilation
Laurent Sansonetti authored
291 virtual Value *compile_nsobject(void);
78b1e93 added support for AOT compilation of the rb_eStandardError constant
Laurent Sansonetti authored
292 virtual Value *compile_standarderror(void);
e037cf2 fix a const lookup bug inside Foo::Bar modules
Laurent Sansonetti authored
293 Value *compile_class_path(NODE *node, int *flags);
cb65416 the great schism, part I
Laurent Sansonetti authored
294 Value *compile_const(ID id, Value *outer);
295 Value *compile_singleton_class(Value *obj);
296 Value *compile_defined_expression(NODE *node);
297 Value *compile_dstr(NODE *node);
298 Value *compile_dvar_slot(ID name);
299 void compile_break_val(Value *val);
e8d79c7 @vincentisambart a return in an ensure should now work properly
vincentisambart authored
300 void compile_simple_return(Value *val);
208c475 optimized returns from non-ensure-scoped and non-Proc blocks
Laurent Sansonetti authored
301 Value *compile_set_has_ensure(Value *val);
3432fd1 a better exception-based implementation for return-from-block
Laurent Sansonetti authored
302 void compile_return_from_block(Value *val, int id);
303 void compile_return_from_block_handler(int id);
cb65416 the great schism, part I
Laurent Sansonetti authored
304 Value *compile_jump(NODE *node);
305 virtual Value *compile_mcache(SEL sel, bool super);
77f9768 implemented super from a block
Laurent Sansonetti authored
306 Value *compile_get_mcache(Value *sel, bool super);
cb65416 the great schism, part I
Laurent Sansonetti authored
307 virtual Value *compile_ccache(ID id);
f61f2c7 @vincentisambart const pointers should be real constants
vincentisambart authored
308 virtual Value *compile_sel(SEL sel, bool add_to_bb=true) {
309 return compile_const_pointer(sel, PtrTy);
cb65416 the great schism, part I
Laurent Sansonetti authored
310 }
57d8085 AOT compiler: added support for NSObject and ID compilation
Laurent Sansonetti authored
311 virtual Value *compile_id(ID id);
913687b fixed a bug in the way we compile literal strings
Laurent Sansonetti authored
312 GlobalVariable *compile_const_global_string(const char *str,
313 const size_t str_len);
314 GlobalVariable *compile_const_global_string(const char *str) {
315 return compile_const_global_string(str, strlen(str));
316 }
e379686 some work on unicode support (still in progress)
Laurent Sansonetti authored
317 GlobalVariable *compile_const_global_ustring(const UniChar *str,
318 const size_t str_len, CFHashCode hash);
319
2c54dbd AOT compiler: added support for blocks
Laurent Sansonetti authored
320 Value *compile_arity(rb_vm_arity_t &arity);
95f3b23 added support for AOT compilation of literal ranges
Laurent Sansonetti authored
321 Instruction *compile_range(Value *beg, Value *end, bool exclude_end,
14423f1 fixed AOT compilation of literal ranges (objects should be retained)
Laurent Sansonetti authored
322 bool retain=false, bool add_to_bb=true);
913687b fixed a bug in the way we compile literal strings
Laurent Sansonetti authored
323 Value *compile_literal(VALUE val);
907bd81 AOT compiler: added support for some immutable literals
Laurent Sansonetti authored
324 virtual Value *compile_immutable_literal(VALUE val);
42e4a2a AOT compiler: added support for global variables
Laurent Sansonetti authored
325 virtual Value *compile_global_entry(NODE *node);
cb65416 the great schism, part I
Laurent Sansonetti authored
326
9590d40 fixing and adding several missing ruby method features
Laurent Sansonetti authored
327 void compile_set_current_scope(Value *klass, Value *scope);
328 Value *compile_set_current_class(Value *klass);
329
3432fd1 a better exception-based implementation for return-from-block
Laurent Sansonetti authored
330 Value *compile_landing_pad_header(void);
331 Value *compile_landing_pad_header(const std::type_info &eh_type);
6c5b476 a new implementation for return-from-block which uses an exception inste...
Laurent Sansonetti authored
332 void compile_landing_pad_footer(bool pop_exception=true);
c80c60a in the objc->ruby 32-bit stub convert ruby exceptions to objc
Laurent Sansonetti authored
333 Value *compile_current_exception(void);
cb65416 the great schism, part I
Laurent Sansonetti authored
334 void compile_rethrow_exception(void);
23ef57e now properly popping exceptions from the VM stack when we unwind from a ...
Laurent Sansonetti authored
335 void compile_pop_exception(int pos=0);
cb65416 the great schism, part I
Laurent Sansonetti authored
336 Value *compile_lvar_slot(ID name);
337 bool compile_lvars(ID *tbl);
338 Value *compile_new_struct(Value *klass, std::vector<Value *> &fields);
339 Value *compile_new_opaque(Value *klass, Value *val);
ff75d60 added support for overwriting an ObjC method that accepts a pointer
Laurent Sansonetti authored
340 Value *compile_new_pointer(const char *type, Value *val);
cb65416 the great schism, part I
Laurent Sansonetti authored
341 void compile_get_struct_fields(Value *val, Value *buf,
342 rb_vm_bs_boxed_t *bs_boxed);
343 Value *compile_get_opaque_data(Value *val, rb_vm_bs_boxed_t *bs_boxed,
344 Value *slot);
345 Value *compile_get_cptr(Value *val, const char *type, Value *slot);
346 void compile_check_arity(Value *given, Value *requested);
347 void compile_set_struct(Value *rcv, int field, Value *val);
348
349 Value *compile_conversion_to_c(const char *type, Value *val,
350 Value *slot);
351 Value *compile_conversion_to_ruby(const char *type,
352 const Type *llvm_type, Value *val);
cf73725 experimental debugger
Laurent Sansonetti authored
353 void compile_debug_trap(void);
cb65416 the great schism, part I
Laurent Sansonetti authored
354
f61f2c7 @vincentisambart const pointers should be real constants
vincentisambart authored
355 Value *compile_slot_cache(ID id);
356 virtual Value *gen_slot_cache(ID id);
cb65416 the great schism, part I
Laurent Sansonetti authored
357 ICmpInst *is_value_a_fixnum(Value *val);
358 void compile_ivar_slots(Value *klass, BasicBlock::InstListType &list,
359 BasicBlock::InstListType::iterator iter);
360 bool unbox_ruby_constant(Value *val, VALUE *rval);
01528a7 floating point arithmetic optimization: Float objects are now immediate ...
Laurent Sansonetti authored
361 Value *optimized_immediate_op(SEL sel, Value *leftVal, Value *rightVal,
362 bool float_op, bool *is_predicate);
363 Value *compile_double_coercion(Value *val, Value *mask,
364 BasicBlock *fallback_bb, Function *f);
2a1240c @vincentisambart some refactoring
vincentisambart authored
365 void compile_keep_vars(BasicBlock *startBB, BasicBlock *mergeBB);
01528a7 floating point arithmetic optimization: Float objects are now immediate ...
Laurent Sansonetti authored
366
cb65416 the great schism, part I
Laurent Sansonetti authored
367 SEL mid_to_sel(ID mid, int arity);
4e1a3ba let's attach more metadata
Laurent Sansonetti authored
368
c437b62 - Adds the flip-flop operator (fixes #548)
Thibault Martin-Lagardette authored
369 Value *compile_get_ffstate(GlobalVariable *ffstate);
370 Value *compile_set_ffstate(Value *val, Value *expected, GlobalVariable *ffstate, BasicBlock *mergeBB, Function *f);
371 Value *compile_ff2(NODE *current_node);
372 Value *compile_ff3(NODE *current_node);
373
4e1a3ba let's attach more metadata
Laurent Sansonetti authored
374 void attach_current_line_metadata(Instruction *insn);
cb65416 the great schism, part I
Laurent Sansonetti authored
375 };
376
bb0b28c moving to LLVM r82747
Laurent Sansonetti authored
377 #define context (RoxorCompiler::module->getContext())
378
cb65416 the great schism, part I
Laurent Sansonetti authored
379 class RoxorAOTCompiler : public RoxorCompiler {
380 public:
3432fd1 a better exception-based implementation for return-from-block
Laurent Sansonetti authored
381 RoxorAOTCompiler(void);
cb65416 the great schism, part I
Laurent Sansonetti authored
382
383 Function *compile_main_function(NODE *node);
384
385 private:
386 std::map<SEL, GlobalVariable *> mcaches;
387 std::map<ID, GlobalVariable *> ccaches;
388 std::map<SEL, GlobalVariable *> sels;
57d8085 AOT compiler: added support for NSObject and ID compilation
Laurent Sansonetti authored
389 std::map<ID, GlobalVariable *> ids;
42e4a2a AOT compiler: added support for global variables
Laurent Sansonetti authored
390 std::map<ID, GlobalVariable *> global_entries;
85b7cc2 AOT compiler: ivar slots support
Laurent Sansonetti authored
391 std::vector<GlobalVariable *> ivar_slots;
907bd81 AOT compiler: added support for some immutable literals
Laurent Sansonetti authored
392 std::map<VALUE, GlobalVariable *> literals;
393
57d8085 AOT compiler: added support for NSObject and ID compilation
Laurent Sansonetti authored
394 GlobalVariable *cObject_gvar;
78b1e93 added support for AOT compilation of the rb_eStandardError constant
Laurent Sansonetti authored
395 GlobalVariable *cStandardError_gvar;
396 std::vector<GlobalVariable *> class_gvars;
cb65416 the great schism, part I
Laurent Sansonetti authored
397
398 Value *compile_mcache(SEL sel, bool super);
399 Value *compile_ccache(ID id);
f61f2c7 @vincentisambart const pointers should be real constants
vincentisambart authored
400 Value *compile_sel(SEL sel, bool add_to_bb=true);
12a1d67 fixing bugs in instance_eval & friends + fixed some specs so that they p...
Laurent Sansonetti authored
401 void compile_prepare_method(Value *classVal, Value *sel,
402 bool singleton, Function *new_function, rb_vm_arity_t &arity,
9590d40 fixing and adding several missing ruby method features
Laurent Sansonetti authored
403 NODE *body);
2c54dbd AOT compiler: added support for blocks
Laurent Sansonetti authored
404 Value *compile_prepare_block_args(Function *func, int *flags);
57d8085 AOT compiler: added support for NSObject and ID compilation
Laurent Sansonetti authored
405 Value *compile_nsobject(void);
78b1e93 added support for AOT compilation of the rb_eStandardError constant
Laurent Sansonetti authored
406 Value *compile_standarderror(void);
57d8085 AOT compiler: added support for NSObject and ID compilation
Laurent Sansonetti authored
407 Value *compile_id(ID id);
907bd81 AOT compiler: added support for some immutable literals
Laurent Sansonetti authored
408 Value *compile_immutable_literal(VALUE val);
42e4a2a AOT compiler: added support for global variables
Laurent Sansonetti authored
409 Value *compile_global_entry(NODE *node);
cb65416 the great schism, part I
Laurent Sansonetti authored
410
f61f2c7 @vincentisambart const pointers should be real constants
vincentisambart authored
411 Value *gen_slot_cache(ID id);
85b7cc2 AOT compiler: ivar slots support
Laurent Sansonetti authored
412
f61f2c7 @vincentisambart const pointers should be real constants
vincentisambart authored
413 Constant *
414 compile_const_pointer(void *ptr, const PointerType *type=NULL) {
cb65416 the great schism, part I
Laurent Sansonetti authored
415 if (ptr == NULL) {
f61f2c7 @vincentisambart const pointers should be real constants
vincentisambart authored
416 return RoxorCompiler::compile_const_pointer(ptr, type);
cb65416 the great schism, part I
Laurent Sansonetti authored
417 }
418 printf("compile_const_pointer() called with a non-NULL pointer " \
419 "on the AOT compiler - leaving the ship!\n");
420 abort();
421 }
422 };
423
424 #endif /* __cplusplus */
425
426 #endif /* __COMPILER_H_ */
Something went wrong with that request. Please try again.