Mercurial > octave-nkf
comparison src/interp-core/jit-ir.h @ 15182:a7a56b436de2
Factor out jit_block_list and jit_factory from jit_convert
* jit-ir.cc (jit_factory, jit_block_list): New class.
(jit_block::maybe_split): Use jit_factory and jit_block_list instead of
jit_convert.
(jit_magic_end::context::context): Use jit_factory instead of jit_convert.
* jit-ir.h (jit_factory, jit_block_list): New class.
(jit_block::maybe_split): Use jit_block_list and jit_factory.
(jit_magic_end::context::context) Use jit_factory.
* pt-jit.cc (jit_convert): Use jit_factory and jit_block_list instead of
internal methods.
(jit_convert::append): Removed method.
(jit_convert::create_checked_impl): Merg in jit_convert::create_check.
(jit_convert::insert_before, jit_convert;:insert_after,
jit_convert::~jit_convert, jit_convert::append): Remove method.
(jit_convert_llvm::convert): Use jit_block_list.
* pt-jit.h (jit_convert::~jit_convert, jit_convert::append): Remove declaration.
(jit_convert::create, jit_convert::insert_before, jit_convert::insert_after,
jit_convert::track_value): Remove method.
(jit_convert_llvm::convert): Use jit_block_list.
author | Max Brister <max@2bass.com> |
---|---|
date | Wed, 15 Aug 2012 23:30:02 -0500 |
parents | d29f2583cf7b |
children | ed4f4fb78586 |
comparison
equal
deleted
inserted
replaced
15181:ed2b911a2fb3 | 15182:a7a56b436de2 |
---|---|
67 | 67 |
68 JIT_VISIT_IR_NOTEMPLATE | 68 JIT_VISIT_IR_NOTEMPLATE |
69 | 69 |
70 #undef JIT_METH | 70 #undef JIT_METH |
71 | 71 |
72 class jit_convert; | |
73 | |
74 // ABCs which aren't included in JIT_VISIT_IR_ALL | 72 // ABCs which aren't included in JIT_VISIT_IR_ALL |
75 class jit_instruction; | 73 class jit_instruction; |
76 class jit_terminator; | 74 class jit_terminator; |
77 | 75 |
78 template <typename T, jit_type *(*EXTRACT_T)(void), typename PASS_T = T, | 76 template <typename T, jit_type *(*EXTRACT_T)(void), typename PASS_T = T, |
89 typedef jit_const<jit_range, jit_typeinfo::get_range, const jit_range&> | 87 typedef jit_const<jit_range, jit_typeinfo::get_range, const jit_range&> |
90 jit_const_range; | 88 jit_const_range; |
91 | 89 |
92 class jit_ir_walker; | 90 class jit_ir_walker; |
93 class jit_use; | 91 class jit_use; |
92 | |
93 // Creates and tracks memory for jit_value and subclasses. | |
94 // Memory managment is simple, all values that are created live as long as the | |
95 // factory. | |
96 class | |
97 jit_factory | |
98 { | |
99 typedef std::list<jit_value *> value_list; | |
100 public: | |
101 ~jit_factory (void); | |
102 | |
103 const value_list& constants (void) const { return mconstants; } | |
104 | |
105 // this would be easier with variadic templates | |
106 template <typename T> | |
107 T *create (void) | |
108 { | |
109 T *ret = new T (); | |
110 track_value (ret); | |
111 return ret; | |
112 } | |
113 | |
114 #define DECL_ARG(n) const ARG ## n& arg ## n | |
115 #define JIT_CREATE(N) \ | |
116 template <typename T, OCT_MAKE_DECL_LIST (typename, ARG, N)> \ | |
117 T *create (OCT_MAKE_LIST (DECL_ARG, N)) \ | |
118 { \ | |
119 T *ret = new T (OCT_MAKE_ARG_LIST (arg, N)); \ | |
120 track_value (ret); \ | |
121 return ret; \ | |
122 } | |
123 | |
124 JIT_CREATE (1) | |
125 JIT_CREATE (2) | |
126 JIT_CREATE (3) | |
127 JIT_CREATE (4) | |
128 | |
129 #undef JIT_CREATE | |
130 private: | |
131 void track_value (jit_value *v); | |
132 | |
133 value_list all_values; | |
134 | |
135 value_list mconstants; | |
136 }; | |
137 | |
138 // A list of basic blocks (jit_block) which form some body of code. | |
139 // | |
140 // We do not directly inherit from std::list because we need to update the | |
141 // blocks stashed location in push_back and insert. | |
142 class | |
143 jit_block_list | |
144 { | |
145 public: | |
146 typedef std::list<jit_block *>::iterator iterator; | |
147 typedef std::list<jit_block *>::const_iterator const_iterator; | |
148 | |
149 jit_block *back (void) const { return mlist.back (); } | |
150 | |
151 iterator begin (void) { return mlist.begin (); } | |
152 | |
153 const_iterator begin (void) const { return mlist.begin (); } | |
154 | |
155 iterator end (void) { return mlist.end (); } | |
156 | |
157 const_iterator end (void) const { return mlist.end (); } | |
158 | |
159 iterator erase (iterator iter) { return mlist.erase (iter); } | |
160 | |
161 jit_block *front (void) const { return mlist.front (); } | |
162 | |
163 void insert_after (iterator iter, jit_block *ablock); | |
164 | |
165 void insert_after (jit_block *loc, jit_block *ablock); | |
166 | |
167 void insert_before (iterator iter, jit_block *ablock); | |
168 | |
169 void insert_before (jit_block *loc, jit_block *ablock); | |
170 | |
171 void push_back (jit_block *b); | |
172 private: | |
173 std::list<jit_block *> mlist; | |
174 }; | |
94 | 175 |
95 class | 176 class |
96 jit_value : public jit_internal_list<jit_value, jit_use> | 177 jit_value : public jit_internal_list<jit_value, jit_use> |
97 { | 178 { |
98 public: | 179 public: |
631 instr->print (os, indent + 1) << std::endl; | 712 instr->print (os, indent + 1) << std::endl; |
632 } | 713 } |
633 return os; | 714 return os; |
634 } | 715 } |
635 | 716 |
636 // ... | 717 jit_block *maybe_split (jit_factory& factory, jit_block_list& blocks, |
637 jit_block *maybe_split (jit_convert& convert, jit_block *asuccessor); | 718 jit_block *asuccessor); |
638 | 719 |
639 jit_block *maybe_split (jit_convert& convert, jit_block& asuccessor) | 720 jit_block *maybe_split (jit_factory& factory, jit_block_list& blocks, |
640 { | 721 jit_block& asuccessor) |
641 return maybe_split (convert, &asuccessor); | 722 { |
723 return maybe_split (factory, blocks, &asuccessor); | |
642 } | 724 } |
643 | 725 |
644 // print dominator infomration | 726 // print dominator infomration |
645 std::ostream& print_dom (std::ostream& os) const; | 727 std::ostream& print_dom (std::ostream& os) const; |
646 | 728 |
1160 { | 1242 { |
1161 public: | 1243 public: |
1162 context (void) : value (0), index (0), count (0) | 1244 context (void) : value (0), index (0), count (0) |
1163 {} | 1245 {} |
1164 | 1246 |
1165 context (jit_convert& convert, jit_value *avalue, size_t aindex, | 1247 context (jit_factory& factory, jit_value *avalue, size_t aindex, |
1166 size_t acount); | 1248 size_t acount); |
1167 | 1249 |
1168 jit_value *value; | 1250 jit_value *value; |
1169 jit_const_index *index; | 1251 jit_const_index *index; |
1170 jit_const_index *count; | 1252 jit_const_index *count; |