Mercurial > octave-nkf
annotate src/pt-jit.h @ 14913:c7071907a641
Use symbol_record_ref instead of names in JIT
* src/pt-id.h (tree_identifier::symbol): New function.
* src/symtab.h (tree_identifier::symbol_record_ref::operator->):
Added const variant.
* src/pt-jit.h: Use symbol_record_ref
* src/pt-jit.cc: Use symbol_record_ref
author | Max Brister <max@2bass.com> |
---|---|
date | Fri, 18 May 2012 10:22:34 -0600 |
parents | 1e2196d0bea4 |
children | 1e5eafcb83f8 |
rev | line source |
---|---|
14899 | 1 /* |
2 | |
14901
516b4a15b775
doc: Copyright fix in pt-jit.h and pt-jit.cc
Max Brister <max@2bass.com>
parents:
14899
diff
changeset
|
3 Copyright (C) 2012 Max Brister <max@2bass.com> |
14899 | 4 |
5 This file is part of Octave. | |
6 | |
7 Octave is free software; you can redistribute it and/or modify it | |
8 under the terms of the GNU General Public License as published by the | |
9 Free Software Foundation; either version 3 of the License, or (at your | |
10 option) any later version. | |
11 | |
12 Octave is distributed in the hope that it will be useful, but WITHOUT | |
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
18 along with Octave; see the file COPYING. If not, see | |
19 <http://www.gnu.org/licenses/>. | |
20 | |
21 */ | |
22 | |
23 #if !defined (octave_tree_jit_h) | |
24 #define octave_tree_jit_h 1 | |
25 | |
14903 | 26 #include <list> |
14899 | 27 #include <map> |
14903 | 28 #include <set> |
14899 | 29 #include <stdexcept> |
30 #include <vector> | |
31 | |
14903 | 32 #include "Array.h" |
14906 | 33 #include "Range.h" |
14899 | 34 #include "pt-walk.h" |
14913
c7071907a641
Use symbol_record_ref instead of names in JIT
Max Brister <max@2bass.com>
parents:
14911
diff
changeset
|
35 #include "symtab.h" |
14899 | 36 |
14903 | 37 // -------------------- Current status -------------------- |
38 // Simple binary operations (+-*/) on octave_scalar's (doubles) are optimized. | |
39 // However, there is no warning emitted on divide by 0. For example, | |
40 // a = 5; | |
41 // b = a * 5 + a; | |
42 // | |
43 // For other types all binary operations are compiled but not optimized. For | |
44 // example, | |
45 // a = [1 2 3] | |
46 // b = a + a; | |
47 // will compile to do_binary_op (a, a). | |
14906 | 48 // |
49 // for loops with ranges compile. For example, | |
50 // for i=1:1000 | |
51 // result = i + 1; | |
52 // endfor | |
53 // Will compile. Nested for loops with constant bounds are also supported. | |
54 // | |
55 // TODO: | |
56 // 1. Cleanup | |
57 // 2. Support if statements | |
58 // 3. Support iteration over matricies | |
59 // 4. Check error state | |
60 // 5. ... | |
14903 | 61 // --------------------------------------------------------- |
14899 | 62 |
14903 | 63 |
64 // we don't want to include llvm headers here, as they require __STDC_LIMIT_MACROS | |
65 // and __STDC_CONSTANT_MACROS be defined in the entire compilation unit | |
14899 | 66 namespace llvm |
67 { | |
68 class Value; | |
69 class Module; | |
70 class FunctionPassManager; | |
14903 | 71 class PassManager; |
14899 | 72 class ExecutionEngine; |
73 class Function; | |
74 class BasicBlock; | |
75 class LLVMContext; | |
14903 | 76 class Type; |
77 class GenericValue; | |
14899 | 78 } |
79 | |
14903 | 80 class octave_base_value; |
81 class octave_value; | |
14899 | 82 class tree; |
83 | |
14906 | 84 // jit_range is compatable with the llvm range structure |
85 struct | |
86 jit_range | |
87 { | |
88 jit_range (void) {} | |
89 | |
90 jit_range (const Range& from) : base (from.base ()), limit (from.limit ()), | |
91 inc (from.inc ()), nelem (from.nelem ()) | |
92 {} | |
93 | |
94 operator Range () const | |
95 { | |
96 return Range (base, limit, inc); | |
97 } | |
98 | |
99 double base; | |
100 double limit; | |
101 double inc; | |
102 octave_idx_type nelem; | |
103 }; | |
14903 | 104 |
105 // Used to keep track of estimated (infered) types during JIT. This is a | |
106 // hierarchical type system which includes both concrete and abstract types. | |
107 // | |
108 // Current, we only support any and scalar types. If we can't figure out what | |
109 // type a variable is, we assign it the any type. This allows us to generate | |
110 // code even for the case of poor type inference. | |
111 class | |
112 jit_type | |
113 { | |
114 public: | |
115 jit_type (const std::string& n, bool fi, jit_type *mparent, llvm::Type *lt, | |
116 int tid) : | |
117 mname (n), finit (fi), p (mparent), llvm_type (lt), id (tid) | |
118 {} | |
119 | |
120 // a user readable type name | |
121 const std::string& name (void) const { return mname; } | |
122 | |
123 // do we need to initialize variables of this type, even if they are not | |
124 // input arguments? | |
125 bool force_init (void) const { return finit; } | |
126 | |
127 // a unique id for the type | |
128 int type_id (void) const { return id; } | |
129 | |
130 // An abstract base type, may be null | |
131 jit_type *parent (void) const { return p; } | |
132 | |
133 // convert to an llvm type | |
134 llvm::Type *to_llvm (void) const { return llvm_type; } | |
135 | |
136 // how this type gets passed as a function argument | |
137 llvm::Type *to_llvm_arg (void) const; | |
138 private: | |
139 std::string mname; | |
140 bool finit; | |
141 jit_type *p; | |
142 llvm::Type *llvm_type; | |
143 int id; | |
144 }; | |
145 | |
146 // Keeps track of overloads for a builtin function. Used for both type inference | |
147 // and code generation. | |
148 class | |
149 jit_function | |
150 { | |
151 public: | |
152 struct overload | |
153 { | |
154 overload (void) : function (0), can_error (true), result (0) {} | |
155 | |
156 overload (llvm::Function *f, bool e, jit_type *r, jit_type *arg0) : | |
157 function (f), can_error (e), result (r), arguments (1) | |
158 { | |
159 arguments[0] = arg0; | |
160 } | |
161 | |
162 overload (llvm::Function *f, bool e, jit_type *r, jit_type *arg0, | |
163 jit_type *arg1) : function (f), can_error (e), result (r), | |
164 arguments (2) | |
165 { | |
166 arguments[0] = arg0; | |
167 arguments[1] = arg1; | |
168 } | |
169 | |
170 llvm::Function *function; | |
171 bool can_error; | |
172 jit_type *result; | |
173 std::vector<jit_type*> arguments; | |
174 }; | |
175 | |
176 void add_overload (const overload& func) | |
177 { | |
178 add_overload (func, func.arguments); | |
179 } | |
180 | |
14906 | 181 void add_overload (llvm::Function *f, bool e, jit_type *r, jit_type *arg0) |
182 { | |
183 overload ol (f, e, r, arg0); | |
184 add_overload (ol); | |
185 } | |
186 | |
14903 | 187 void add_overload (llvm::Function *f, bool e, jit_type *r, jit_type *arg0, |
188 jit_type *arg1) | |
189 { | |
190 overload ol (f, e, r, arg0, arg1); | |
191 add_overload (ol); | |
192 } | |
193 | |
194 void add_overload (const overload& func, | |
195 const std::vector<jit_type*>& args); | |
196 | |
197 const overload& get_overload (const std::vector<jit_type *>& types) const; | |
198 | |
199 const overload& get_overload (jit_type *arg0) const | |
200 { | |
201 std::vector<jit_type *> types (1); | |
202 types[0] = arg0; | |
203 return get_overload (types); | |
204 } | |
205 | |
206 const overload& get_overload (jit_type *arg0, jit_type *arg1) const | |
207 { | |
208 std::vector<jit_type *> types (2); | |
209 types[0] = arg0; | |
210 types[1] = arg1; | |
211 return get_overload (types); | |
212 } | |
213 | |
214 jit_type *get_result (const std::vector<jit_type *>& types) const | |
215 { | |
216 const overload& temp = get_overload (types); | |
217 return temp.result; | |
218 } | |
219 | |
220 jit_type *get_result (jit_type *arg0, jit_type *arg1) const | |
221 { | |
222 const overload& temp = get_overload (arg0, arg1); | |
223 return temp.result; | |
224 } | |
225 private: | |
226 Array<octave_idx_type> to_idx (const std::vector<jit_type*>& types) const; | |
227 | |
228 std::vector<Array<overload> > overloads; | |
229 }; | |
230 | |
231 // Get information and manipulate jit types. | |
232 class | |
233 jit_typeinfo | |
234 { | |
235 public: | |
14906 | 236 jit_typeinfo (llvm::Module *m, llvm::ExecutionEngine *e); |
14903 | 237 |
238 jit_type *get_any (void) const { return any; } | |
239 | |
240 jit_type *get_scalar (void) const { return scalar; } | |
241 | |
14906 | 242 llvm::Type *get_scalar_llvm (void) const { return scalar->to_llvm (); } |
243 | |
244 jit_type *get_range (void) const { return range; } | |
245 | |
246 llvm::Type *get_range_llvm (void) const { return range->to_llvm (); } | |
247 | |
248 jit_type *get_bool (void) const { return boolean; } | |
249 | |
250 jit_type *get_index (void) const { return index; } | |
251 | |
252 llvm::Type *get_index_llvm (void) const { return index->to_llvm (); } | |
253 | |
14903 | 254 jit_type *type_of (const octave_value& ov) const; |
255 | |
256 const jit_function& binary_op (int op) const; | |
257 | |
258 const jit_function::overload& binary_op_overload (int op, jit_type *lhs, | |
259 jit_type *rhs) const | |
260 { | |
261 const jit_function& jf = binary_op (op); | |
262 return jf.get_overload (lhs, rhs); | |
263 } | |
264 | |
265 jit_type *binary_op_result (int op, jit_type *lhs, jit_type *rhs) const | |
266 { | |
267 const jit_function::overload& ol = binary_op_overload (op, lhs, rhs); | |
268 return ol.result; | |
269 } | |
270 | |
271 const jit_function::overload& assign_op (jit_type *lhs, jit_type *rhs) const; | |
272 | |
273 const jit_function::overload& print_value (jit_type *to_print) const; | |
274 | |
14906 | 275 const jit_function::overload& get_simple_for_check (jit_type *bounds) const |
276 { | |
277 return simple_for_check.get_overload (bounds, index); | |
278 } | |
279 | |
280 const jit_function::overload& get_simple_for_index (jit_type *bounds) const | |
281 { | |
282 return simple_for_index.get_overload (bounds, index); | |
283 } | |
284 | |
285 jit_type *get_simple_for_index_result (jit_type *bounds) const | |
286 { | |
287 const jit_function::overload& ol = get_simple_for_index (bounds); | |
288 return ol.result; | |
289 } | |
290 | |
14903 | 291 void to_generic (jit_type *type, llvm::GenericValue& gv); |
14911 | 292 |
14903 | 293 void to_generic (jit_type *type, llvm::GenericValue& gv, octave_value ov); |
294 | |
295 octave_value to_octave_value (jit_type *type, llvm::GenericValue& gv); | |
296 | |
14910
a8f1e08de8fc
Simplified llvm::GenericValue creation
Max Brister <max@2bass.com>
parents:
14909
diff
changeset
|
297 void reset_generic (void); |
14903 | 298 private: |
299 jit_type *new_type (const std::string& name, bool force_init, | |
300 jit_type *parent, llvm::Type *llvm_type); | |
301 | |
302 void add_print (jit_type *ty, void *call); | |
303 | |
304 void add_binary_op (jit_type *ty, int op, int llvm_op); | |
305 | |
306 llvm::Module *module; | |
307 llvm::ExecutionEngine *engine; | |
308 int next_id; | |
309 | |
310 llvm::Type *ov_t; | |
311 | |
312 std::vector<jit_type*> id_to_type; | |
313 jit_type *any; | |
314 jit_type *scalar; | |
14906 | 315 jit_type *range; |
316 jit_type *boolean; | |
317 jit_type *index; | |
14903 | 318 |
319 std::vector<jit_function> binary_ops; | |
320 jit_function assign_fn; | |
321 jit_function print_fn; | |
14906 | 322 jit_function simple_for_check; |
323 jit_function simple_for_incr; | |
324 jit_function simple_for_index; | |
14903 | 325 |
14910
a8f1e08de8fc
Simplified llvm::GenericValue creation
Max Brister <max@2bass.com>
parents:
14909
diff
changeset
|
326 std::list<double> scalar_out; |
a8f1e08de8fc
Simplified llvm::GenericValue creation
Max Brister <max@2bass.com>
parents:
14909
diff
changeset
|
327 std::list<octave_base_value *> ov_out; |
a8f1e08de8fc
Simplified llvm::GenericValue creation
Max Brister <max@2bass.com>
parents:
14909
diff
changeset
|
328 std::list<jit_range> range_out; |
14906 | 329 }; |
330 | |
331 class | |
332 jit_infer : public tree_walker | |
333 { | |
334 public: | |
14913
c7071907a641
Use symbol_record_ref instead of names in JIT
Max Brister <max@2bass.com>
parents:
14911
diff
changeset
|
335 // pair <argin, type> |
c7071907a641
Use symbol_record_ref instead of names in JIT
Max Brister <max@2bass.com>
parents:
14911
diff
changeset
|
336 typedef std::pair<bool, jit_type *> type_entry; |
c7071907a641
Use symbol_record_ref instead of names in JIT
Max Brister <max@2bass.com>
parents:
14911
diff
changeset
|
337 typedef std::map<symbol_table::symbol_record_ref, type_entry, |
c7071907a641
Use symbol_record_ref instead of names in JIT
Max Brister <max@2bass.com>
parents:
14911
diff
changeset
|
338 symbol_table::symbol_record_ref::comparator> type_map; |
c7071907a641
Use symbol_record_ref instead of names in JIT
Max Brister <max@2bass.com>
parents:
14911
diff
changeset
|
339 |
14906 | 340 jit_infer (jit_typeinfo *ti) : tinfo (ti), is_lvalue (false), |
341 rvalue_type (0) | |
342 {} | |
343 | |
344 const type_map& get_types () const { return types; } | |
345 | |
346 void infer (tree_simple_for_command& cmd, jit_type *bounds); | |
347 | |
348 void visit_anon_fcn_handle (tree_anon_fcn_handle&); | |
349 | |
350 void visit_argument_list (tree_argument_list&); | |
351 | |
352 void visit_binary_expression (tree_binary_expression&); | |
353 | |
354 void visit_break_command (tree_break_command&); | |
355 | |
356 void visit_colon_expression (tree_colon_expression&); | |
357 | |
358 void visit_continue_command (tree_continue_command&); | |
359 | |
360 void visit_global_command (tree_global_command&); | |
361 | |
362 void visit_persistent_command (tree_persistent_command&); | |
363 | |
364 void visit_decl_elt (tree_decl_elt&); | |
365 | |
366 void visit_decl_init_list (tree_decl_init_list&); | |
367 | |
368 void visit_simple_for_command (tree_simple_for_command&); | |
369 | |
370 void visit_complex_for_command (tree_complex_for_command&); | |
371 | |
372 void visit_octave_user_script (octave_user_script&); | |
373 | |
374 void visit_octave_user_function (octave_user_function&); | |
375 | |
376 void visit_octave_user_function_header (octave_user_function&); | |
377 | |
378 void visit_octave_user_function_trailer (octave_user_function&); | |
379 | |
380 void visit_function_def (tree_function_def&); | |
381 | |
382 void visit_identifier (tree_identifier&); | |
383 | |
384 void visit_if_clause (tree_if_clause&); | |
385 | |
386 void visit_if_command (tree_if_command&); | |
387 | |
388 void visit_if_command_list (tree_if_command_list&); | |
389 | |
390 void visit_index_expression (tree_index_expression&); | |
391 | |
392 void visit_matrix (tree_matrix&); | |
393 | |
394 void visit_cell (tree_cell&); | |
395 | |
396 void visit_multi_assignment (tree_multi_assignment&); | |
397 | |
398 void visit_no_op_command (tree_no_op_command&); | |
399 | |
400 void visit_constant (tree_constant&); | |
401 | |
402 void visit_fcn_handle (tree_fcn_handle&); | |
403 | |
404 void visit_parameter_list (tree_parameter_list&); | |
405 | |
406 void visit_postfix_expression (tree_postfix_expression&); | |
407 | |
408 void visit_prefix_expression (tree_prefix_expression&); | |
409 | |
410 void visit_return_command (tree_return_command&); | |
411 | |
412 void visit_return_list (tree_return_list&); | |
413 | |
414 void visit_simple_assignment (tree_simple_assignment&); | |
415 | |
416 void visit_statement (tree_statement&); | |
417 | |
418 void visit_statement_list (tree_statement_list&); | |
419 | |
420 void visit_switch_case (tree_switch_case&); | |
421 | |
422 void visit_switch_case_list (tree_switch_case_list&); | |
423 | |
424 void visit_switch_command (tree_switch_command&); | |
425 | |
426 void visit_try_catch_command (tree_try_catch_command&); | |
427 | |
428 void visit_unwind_protect_command (tree_unwind_protect_command&); | |
429 | |
430 void visit_while_command (tree_while_command&); | |
431 | |
432 void visit_do_until_command (tree_do_until_command&); | |
433 private: | |
434 void infer_simple_for (tree_simple_for_command& cmd, | |
435 jit_type *bounds); | |
436 | |
14913
c7071907a641
Use symbol_record_ref instead of names in JIT
Max Brister <max@2bass.com>
parents:
14911
diff
changeset
|
437 void handle_identifier (const symbol_table::symbol_record_ref& record); |
14906 | 438 |
439 jit_typeinfo *tinfo; | |
440 | |
441 bool is_lvalue; | |
442 jit_type *rvalue_type; | |
443 | |
444 type_map types; | |
445 | |
446 std::vector<jit_type *> type_stack; | |
447 }; | |
448 | |
449 class | |
450 jit_generator : public tree_walker | |
451 { | |
452 public: | |
14913
c7071907a641
Use symbol_record_ref instead of names in JIT
Max Brister <max@2bass.com>
parents:
14911
diff
changeset
|
453 typedef jit_infer::type_map type_map; |
c7071907a641
Use symbol_record_ref instead of names in JIT
Max Brister <max@2bass.com>
parents:
14911
diff
changeset
|
454 |
c7071907a641
Use symbol_record_ref instead of names in JIT
Max Brister <max@2bass.com>
parents:
14911
diff
changeset
|
455 jit_generator (jit_typeinfo *ti, llvm::Module *mod, tree_simple_for_command &cmd, |
c7071907a641
Use symbol_record_ref instead of names in JIT
Max Brister <max@2bass.com>
parents:
14911
diff
changeset
|
456 jit_type *bounds, const type_map& infered_types); |
14906 | 457 |
458 llvm::Function *get_function () const { return function; } | |
459 | |
460 void visit_anon_fcn_handle (tree_anon_fcn_handle&); | |
461 | |
462 void visit_argument_list (tree_argument_list&); | |
463 | |
464 void visit_binary_expression (tree_binary_expression&); | |
465 | |
466 void visit_break_command (tree_break_command&); | |
467 | |
468 void visit_colon_expression (tree_colon_expression&); | |
469 | |
470 void visit_continue_command (tree_continue_command&); | |
471 | |
472 void visit_global_command (tree_global_command&); | |
473 | |
474 void visit_persistent_command (tree_persistent_command&); | |
475 | |
476 void visit_decl_elt (tree_decl_elt&); | |
477 | |
478 void visit_decl_init_list (tree_decl_init_list&); | |
479 | |
480 void visit_simple_for_command (tree_simple_for_command&); | |
481 | |
482 void visit_complex_for_command (tree_complex_for_command&); | |
483 | |
484 void visit_octave_user_script (octave_user_script&); | |
485 | |
486 void visit_octave_user_function (octave_user_function&); | |
487 | |
488 void visit_octave_user_function_header (octave_user_function&); | |
489 | |
490 void visit_octave_user_function_trailer (octave_user_function&); | |
491 | |
492 void visit_function_def (tree_function_def&); | |
493 | |
494 void visit_identifier (tree_identifier&); | |
495 | |
496 void visit_if_clause (tree_if_clause&); | |
497 | |
498 void visit_if_command (tree_if_command&); | |
499 | |
500 void visit_if_command_list (tree_if_command_list&); | |
501 | |
502 void visit_index_expression (tree_index_expression&); | |
503 | |
504 void visit_matrix (tree_matrix&); | |
505 | |
506 void visit_cell (tree_cell&); | |
507 | |
508 void visit_multi_assignment (tree_multi_assignment&); | |
509 | |
510 void visit_no_op_command (tree_no_op_command&); | |
511 | |
512 void visit_constant (tree_constant&); | |
513 | |
514 void visit_fcn_handle (tree_fcn_handle&); | |
515 | |
516 void visit_parameter_list (tree_parameter_list&); | |
517 | |
518 void visit_postfix_expression (tree_postfix_expression&); | |
519 | |
520 void visit_prefix_expression (tree_prefix_expression&); | |
521 | |
522 void visit_return_command (tree_return_command&); | |
523 | |
524 void visit_return_list (tree_return_list&); | |
525 | |
526 void visit_simple_assignment (tree_simple_assignment&); | |
527 | |
528 void visit_statement (tree_statement&); | |
529 | |
530 void visit_statement_list (tree_statement_list&); | |
531 | |
532 void visit_switch_case (tree_switch_case&); | |
533 | |
534 void visit_switch_case_list (tree_switch_case_list&); | |
535 | |
536 void visit_switch_command (tree_switch_command&); | |
537 | |
538 void visit_try_catch_command (tree_try_catch_command&); | |
539 | |
540 void visit_unwind_protect_command (tree_unwind_protect_command&); | |
541 | |
542 void visit_while_command (tree_while_command&); | |
543 | |
544 void visit_do_until_command (tree_do_until_command&); | |
545 private: | |
546 typedef std::pair<jit_type *, llvm::Value *> value; | |
547 | |
548 void emit_simple_for (tree_simple_for_command& cmd, value over, | |
549 bool atleast_once); | |
550 | |
551 void emit_print (const std::string& name, const value& v); | |
552 | |
553 void push_value (jit_type *type, llvm::Value *v) | |
554 { | |
555 value_stack.push_back (value (type, v)); | |
556 } | |
557 | |
14913
c7071907a641
Use symbol_record_ref instead of names in JIT
Max Brister <max@2bass.com>
parents:
14911
diff
changeset
|
558 void initialize (const std::vector<std::string>& names, |
c7071907a641
Use symbol_record_ref instead of names in JIT
Max Brister <max@2bass.com>
parents:
14911
diff
changeset
|
559 const std::vector<bool>& argin, |
c7071907a641
Use symbol_record_ref instead of names in JIT
Max Brister <max@2bass.com>
parents:
14911
diff
changeset
|
560 const std::vector<jit_type *> types); |
c7071907a641
Use symbol_record_ref instead of names in JIT
Max Brister <max@2bass.com>
parents:
14911
diff
changeset
|
561 |
c7071907a641
Use symbol_record_ref instead of names in JIT
Max Brister <max@2bass.com>
parents:
14911
diff
changeset
|
562 void finalize (const std::vector<std::string>& names); |
c7071907a641
Use symbol_record_ref instead of names in JIT
Max Brister <max@2bass.com>
parents:
14911
diff
changeset
|
563 |
14906 | 564 jit_typeinfo *tinfo; |
14913
c7071907a641
Use symbol_record_ref instead of names in JIT
Max Brister <max@2bass.com>
parents:
14911
diff
changeset
|
565 llvm::Module *module; |
14906 | 566 llvm::Function *function; |
567 | |
568 bool is_lvalue; | |
569 std::map<std::string, value> variables; | |
570 std::vector<value> value_stack; | |
14903 | 571 }; |
572 | |
14899 | 573 class |
14903 | 574 tree_jit |
14899 | 575 { |
576 public: | |
577 tree_jit (void); | |
578 | |
579 ~tree_jit (void); | |
580 | |
14906 | 581 bool execute (tree_simple_for_command& cmd, const octave_value& bounds); |
14903 | 582 |
14906 | 583 jit_typeinfo *get_typeinfo (void) const { return tinfo; } |
14903 | 584 |
14906 | 585 llvm::ExecutionEngine *get_engine (void) const { return engine; } |
14903 | 586 |
14906 | 587 llvm::Module *get_module (void) const { return module; } |
14903 | 588 |
14906 | 589 void optimize (llvm::Function *fn); |
590 private: | |
591 bool initialize (void); | |
14899 | 592 |
593 llvm::LLVMContext &context; | |
594 llvm::Module *module; | |
14903 | 595 llvm::PassManager *module_pass_manager; |
14899 | 596 llvm::FunctionPassManager *pass_manager; |
597 llvm::ExecutionEngine *engine; | |
598 | |
14903 | 599 jit_typeinfo *tinfo; |
14906 | 600 }; |
14903 | 601 |
14906 | 602 class |
603 jit_info | |
604 { | |
605 public: | |
14913
c7071907a641
Use symbol_record_ref instead of names in JIT
Max Brister <max@2bass.com>
parents:
14911
diff
changeset
|
606 typedef jit_infer::type_map type_map; |
c7071907a641
Use symbol_record_ref instead of names in JIT
Max Brister <max@2bass.com>
parents:
14911
diff
changeset
|
607 |
14906 | 608 jit_info (tree_jit& tjit, tree_simple_for_command& cmd, jit_type *bounds); |
609 | |
610 bool execute (const octave_value& bounds) const; | |
611 | |
612 bool match (void) const; | |
613 private: | |
614 jit_typeinfo *tinfo; | |
615 llvm::ExecutionEngine *engine; | |
616 type_map types; | |
617 llvm::Function *function; | |
14913
c7071907a641
Use symbol_record_ref instead of names in JIT
Max Brister <max@2bass.com>
parents:
14911
diff
changeset
|
618 jit_type *bounds_t; |
14899 | 619 }; |
620 | |
621 #endif |