Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

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