Mercurial > hg > octave-nkf
annotate libinterp/interp-core/jit-ir.cc @ 15602:f3e339aee38f
Fix block labeling in JIT debug output
* jit-ir.cc (jit_block_list::label): New function.
(jit_block::label, jit_block::print): Implementation moved to cc file.
* jit-ir.h (jit_block_list::label): New function delcaration.
(jit_block::label, jit_block::print): Implementation moved to cc file.
(jit_block::print): Make it clear when a block has not been labeled.
* pt-jit.cc (jit_inter::inter, jit_infer::construct_ssa,
jit_function_info::jit_function_info, jit_info::compile):
Use jit_block_list::label.
author | Max Brister <max@2bass.com> |
---|---|
date | Sun, 04 Nov 2012 20:09:23 -0700 |
parents | 4f1a4923a19e |
children | 44272909d926 |
rev | line source |
---|---|
15016 | 1 /* |
2 | |
3 Copyright (C) 2012 Max Brister <max@2bass.com> | |
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 // defines required by llvm | |
24 #define __STDC_LIMIT_MACROS | |
25 #define __STDC_CONSTANT_MACROS | |
26 | |
27 #ifdef HAVE_CONFIG_H | |
28 #include <config.h> | |
29 #endif | |
30 | |
31 #ifdef HAVE_LLVM | |
32 | |
33 #include "jit-ir.h" | |
34 | |
35 #include <llvm/BasicBlock.h> | |
36 #include <llvm/Instructions.h> | |
37 | |
38 #include "error.h" | |
15182
a7a56b436de2
Factor out jit_block_list and jit_factory from jit_convert
Max Brister <max@2bass.com>
parents:
15171
diff
changeset
|
39 |
a7a56b436de2
Factor out jit_block_list and jit_factory from jit_convert
Max Brister <max@2bass.com>
parents:
15171
diff
changeset
|
40 // -------------------- jit_factory -------------------- |
a7a56b436de2
Factor out jit_block_list and jit_factory from jit_convert
Max Brister <max@2bass.com>
parents:
15171
diff
changeset
|
41 jit_factory::~jit_factory (void) |
a7a56b436de2
Factor out jit_block_list and jit_factory from jit_convert
Max Brister <max@2bass.com>
parents:
15171
diff
changeset
|
42 { |
a7a56b436de2
Factor out jit_block_list and jit_factory from jit_convert
Max Brister <max@2bass.com>
parents:
15171
diff
changeset
|
43 for (value_list::iterator iter = all_values.begin (); |
a7a56b436de2
Factor out jit_block_list and jit_factory from jit_convert
Max Brister <max@2bass.com>
parents:
15171
diff
changeset
|
44 iter != all_values.end (); ++iter) |
a7a56b436de2
Factor out jit_block_list and jit_factory from jit_convert
Max Brister <max@2bass.com>
parents:
15171
diff
changeset
|
45 delete *iter; |
a7a56b436de2
Factor out jit_block_list and jit_factory from jit_convert
Max Brister <max@2bass.com>
parents:
15171
diff
changeset
|
46 } |
a7a56b436de2
Factor out jit_block_list and jit_factory from jit_convert
Max Brister <max@2bass.com>
parents:
15171
diff
changeset
|
47 |
a7a56b436de2
Factor out jit_block_list and jit_factory from jit_convert
Max Brister <max@2bass.com>
parents:
15171
diff
changeset
|
48 void |
a7a56b436de2
Factor out jit_block_list and jit_factory from jit_convert
Max Brister <max@2bass.com>
parents:
15171
diff
changeset
|
49 jit_factory::track_value (jit_value *value) |
a7a56b436de2
Factor out jit_block_list and jit_factory from jit_convert
Max Brister <max@2bass.com>
parents:
15171
diff
changeset
|
50 { |
a7a56b436de2
Factor out jit_block_list and jit_factory from jit_convert
Max Brister <max@2bass.com>
parents:
15171
diff
changeset
|
51 if (value->type ()) |
a7a56b436de2
Factor out jit_block_list and jit_factory from jit_convert
Max Brister <max@2bass.com>
parents:
15171
diff
changeset
|
52 mconstants.push_back (value); |
a7a56b436de2
Factor out jit_block_list and jit_factory from jit_convert
Max Brister <max@2bass.com>
parents:
15171
diff
changeset
|
53 all_values.push_back (value); |
a7a56b436de2
Factor out jit_block_list and jit_factory from jit_convert
Max Brister <max@2bass.com>
parents:
15171
diff
changeset
|
54 } |
a7a56b436de2
Factor out jit_block_list and jit_factory from jit_convert
Max Brister <max@2bass.com>
parents:
15171
diff
changeset
|
55 |
a7a56b436de2
Factor out jit_block_list and jit_factory from jit_convert
Max Brister <max@2bass.com>
parents:
15171
diff
changeset
|
56 // -------------------- jit_block_list -------------------- |
a7a56b436de2
Factor out jit_block_list and jit_factory from jit_convert
Max Brister <max@2bass.com>
parents:
15171
diff
changeset
|
57 void |
a7a56b436de2
Factor out jit_block_list and jit_factory from jit_convert
Max Brister <max@2bass.com>
parents:
15171
diff
changeset
|
58 jit_block_list::insert_after (iterator iter, jit_block *ablock) |
a7a56b436de2
Factor out jit_block_list and jit_factory from jit_convert
Max Brister <max@2bass.com>
parents:
15171
diff
changeset
|
59 { |
a7a56b436de2
Factor out jit_block_list and jit_factory from jit_convert
Max Brister <max@2bass.com>
parents:
15171
diff
changeset
|
60 ++iter; |
a7a56b436de2
Factor out jit_block_list and jit_factory from jit_convert
Max Brister <max@2bass.com>
parents:
15171
diff
changeset
|
61 insert_before (iter, ablock); |
a7a56b436de2
Factor out jit_block_list and jit_factory from jit_convert
Max Brister <max@2bass.com>
parents:
15171
diff
changeset
|
62 } |
a7a56b436de2
Factor out jit_block_list and jit_factory from jit_convert
Max Brister <max@2bass.com>
parents:
15171
diff
changeset
|
63 |
a7a56b436de2
Factor out jit_block_list and jit_factory from jit_convert
Max Brister <max@2bass.com>
parents:
15171
diff
changeset
|
64 void |
a7a56b436de2
Factor out jit_block_list and jit_factory from jit_convert
Max Brister <max@2bass.com>
parents:
15171
diff
changeset
|
65 jit_block_list::insert_after (jit_block *loc, jit_block *ablock) |
a7a56b436de2
Factor out jit_block_list and jit_factory from jit_convert
Max Brister <max@2bass.com>
parents:
15171
diff
changeset
|
66 { |
a7a56b436de2
Factor out jit_block_list and jit_factory from jit_convert
Max Brister <max@2bass.com>
parents:
15171
diff
changeset
|
67 insert_after (loc->location (), ablock); |
a7a56b436de2
Factor out jit_block_list and jit_factory from jit_convert
Max Brister <max@2bass.com>
parents:
15171
diff
changeset
|
68 } |
a7a56b436de2
Factor out jit_block_list and jit_factory from jit_convert
Max Brister <max@2bass.com>
parents:
15171
diff
changeset
|
69 |
a7a56b436de2
Factor out jit_block_list and jit_factory from jit_convert
Max Brister <max@2bass.com>
parents:
15171
diff
changeset
|
70 void |
a7a56b436de2
Factor out jit_block_list and jit_factory from jit_convert
Max Brister <max@2bass.com>
parents:
15171
diff
changeset
|
71 jit_block_list::insert_before (iterator iter, jit_block *ablock) |
a7a56b436de2
Factor out jit_block_list and jit_factory from jit_convert
Max Brister <max@2bass.com>
parents:
15171
diff
changeset
|
72 { |
a7a56b436de2
Factor out jit_block_list and jit_factory from jit_convert
Max Brister <max@2bass.com>
parents:
15171
diff
changeset
|
73 iter = mlist.insert (iter, ablock); |
a7a56b436de2
Factor out jit_block_list and jit_factory from jit_convert
Max Brister <max@2bass.com>
parents:
15171
diff
changeset
|
74 ablock->stash_location (iter); |
a7a56b436de2
Factor out jit_block_list and jit_factory from jit_convert
Max Brister <max@2bass.com>
parents:
15171
diff
changeset
|
75 } |
a7a56b436de2
Factor out jit_block_list and jit_factory from jit_convert
Max Brister <max@2bass.com>
parents:
15171
diff
changeset
|
76 |
a7a56b436de2
Factor out jit_block_list and jit_factory from jit_convert
Max Brister <max@2bass.com>
parents:
15171
diff
changeset
|
77 void |
a7a56b436de2
Factor out jit_block_list and jit_factory from jit_convert
Max Brister <max@2bass.com>
parents:
15171
diff
changeset
|
78 jit_block_list::insert_before (jit_block *loc, jit_block *ablock) |
a7a56b436de2
Factor out jit_block_list and jit_factory from jit_convert
Max Brister <max@2bass.com>
parents:
15171
diff
changeset
|
79 { |
a7a56b436de2
Factor out jit_block_list and jit_factory from jit_convert
Max Brister <max@2bass.com>
parents:
15171
diff
changeset
|
80 insert_before (loc->location (), ablock); |
a7a56b436de2
Factor out jit_block_list and jit_factory from jit_convert
Max Brister <max@2bass.com>
parents:
15171
diff
changeset
|
81 } |
a7a56b436de2
Factor out jit_block_list and jit_factory from jit_convert
Max Brister <max@2bass.com>
parents:
15171
diff
changeset
|
82 |
15602
f3e339aee38f
Fix block labeling in JIT debug output
Max Brister <max@2bass.com>
parents:
15259
diff
changeset
|
83 void |
f3e339aee38f
Fix block labeling in JIT debug output
Max Brister <max@2bass.com>
parents:
15259
diff
changeset
|
84 jit_block_list::label (void) |
f3e339aee38f
Fix block labeling in JIT debug output
Max Brister <max@2bass.com>
parents:
15259
diff
changeset
|
85 { |
f3e339aee38f
Fix block labeling in JIT debug output
Max Brister <max@2bass.com>
parents:
15259
diff
changeset
|
86 if (mlist.size ()) |
f3e339aee38f
Fix block labeling in JIT debug output
Max Brister <max@2bass.com>
parents:
15259
diff
changeset
|
87 { |
f3e339aee38f
Fix block labeling in JIT debug output
Max Brister <max@2bass.com>
parents:
15259
diff
changeset
|
88 jit_block *block = mlist.back (); |
f3e339aee38f
Fix block labeling in JIT debug output
Max Brister <max@2bass.com>
parents:
15259
diff
changeset
|
89 block->label (); |
f3e339aee38f
Fix block labeling in JIT debug output
Max Brister <max@2bass.com>
parents:
15259
diff
changeset
|
90 } |
f3e339aee38f
Fix block labeling in JIT debug output
Max Brister <max@2bass.com>
parents:
15259
diff
changeset
|
91 } |
f3e339aee38f
Fix block labeling in JIT debug output
Max Brister <max@2bass.com>
parents:
15259
diff
changeset
|
92 |
15191
ed4f4fb78586
Move type inference from jit_convert to jit_infer
Max Brister <max@2bass.com>
parents:
15182
diff
changeset
|
93 std::ostream& |
ed4f4fb78586
Move type inference from jit_convert to jit_infer
Max Brister <max@2bass.com>
parents:
15182
diff
changeset
|
94 jit_block_list::print (std::ostream& os, const std::string& header) const |
ed4f4fb78586
Move type inference from jit_convert to jit_infer
Max Brister <max@2bass.com>
parents:
15182
diff
changeset
|
95 { |
ed4f4fb78586
Move type inference from jit_convert to jit_infer
Max Brister <max@2bass.com>
parents:
15182
diff
changeset
|
96 os << "-------------------- " << header << " --------------------\n"; |
ed4f4fb78586
Move type inference from jit_convert to jit_infer
Max Brister <max@2bass.com>
parents:
15182
diff
changeset
|
97 return os << *this; |
ed4f4fb78586
Move type inference from jit_convert to jit_infer
Max Brister <max@2bass.com>
parents:
15182
diff
changeset
|
98 } |
ed4f4fb78586
Move type inference from jit_convert to jit_infer
Max Brister <max@2bass.com>
parents:
15182
diff
changeset
|
99 |
ed4f4fb78586
Move type inference from jit_convert to jit_infer
Max Brister <max@2bass.com>
parents:
15182
diff
changeset
|
100 std::ostream& |
ed4f4fb78586
Move type inference from jit_convert to jit_infer
Max Brister <max@2bass.com>
parents:
15182
diff
changeset
|
101 jit_block_list::print_dom (std::ostream& os) const |
ed4f4fb78586
Move type inference from jit_convert to jit_infer
Max Brister <max@2bass.com>
parents:
15182
diff
changeset
|
102 { |
ed4f4fb78586
Move type inference from jit_convert to jit_infer
Max Brister <max@2bass.com>
parents:
15182
diff
changeset
|
103 os << "-------------------- dom info --------------------\n"; |
ed4f4fb78586
Move type inference from jit_convert to jit_infer
Max Brister <max@2bass.com>
parents:
15182
diff
changeset
|
104 for (const_iterator iter = begin (); iter != end (); ++iter) |
ed4f4fb78586
Move type inference from jit_convert to jit_infer
Max Brister <max@2bass.com>
parents:
15182
diff
changeset
|
105 { |
ed4f4fb78586
Move type inference from jit_convert to jit_infer
Max Brister <max@2bass.com>
parents:
15182
diff
changeset
|
106 assert (*iter); |
ed4f4fb78586
Move type inference from jit_convert to jit_infer
Max Brister <max@2bass.com>
parents:
15182
diff
changeset
|
107 (*iter)->print_dom (os); |
ed4f4fb78586
Move type inference from jit_convert to jit_infer
Max Brister <max@2bass.com>
parents:
15182
diff
changeset
|
108 } |
ed4f4fb78586
Move type inference from jit_convert to jit_infer
Max Brister <max@2bass.com>
parents:
15182
diff
changeset
|
109 os << std::endl; |
15259
4f1a4923a19e
Add missing return value in JIT code.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15195
diff
changeset
|
110 |
4f1a4923a19e
Add missing return value in JIT code.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15195
diff
changeset
|
111 return os; |
15191
ed4f4fb78586
Move type inference from jit_convert to jit_infer
Max Brister <max@2bass.com>
parents:
15182
diff
changeset
|
112 } |
ed4f4fb78586
Move type inference from jit_convert to jit_infer
Max Brister <max@2bass.com>
parents:
15182
diff
changeset
|
113 |
15182
a7a56b436de2
Factor out jit_block_list and jit_factory from jit_convert
Max Brister <max@2bass.com>
parents:
15171
diff
changeset
|
114 void |
a7a56b436de2
Factor out jit_block_list and jit_factory from jit_convert
Max Brister <max@2bass.com>
parents:
15171
diff
changeset
|
115 jit_block_list::push_back (jit_block *b) |
a7a56b436de2
Factor out jit_block_list and jit_factory from jit_convert
Max Brister <max@2bass.com>
parents:
15171
diff
changeset
|
116 { |
a7a56b436de2
Factor out jit_block_list and jit_factory from jit_convert
Max Brister <max@2bass.com>
parents:
15171
diff
changeset
|
117 mlist.push_back (b); |
a7a56b436de2
Factor out jit_block_list and jit_factory from jit_convert
Max Brister <max@2bass.com>
parents:
15171
diff
changeset
|
118 iterator iter = mlist.end (); |
a7a56b436de2
Factor out jit_block_list and jit_factory from jit_convert
Max Brister <max@2bass.com>
parents:
15171
diff
changeset
|
119 b->stash_location (--iter); |
a7a56b436de2
Factor out jit_block_list and jit_factory from jit_convert
Max Brister <max@2bass.com>
parents:
15171
diff
changeset
|
120 } |
15016 | 121 |
15191
ed4f4fb78586
Move type inference from jit_convert to jit_infer
Max Brister <max@2bass.com>
parents:
15182
diff
changeset
|
122 std::ostream& |
ed4f4fb78586
Move type inference from jit_convert to jit_infer
Max Brister <max@2bass.com>
parents:
15182
diff
changeset
|
123 operator<<(std::ostream& os, const jit_block_list& blocks) |
ed4f4fb78586
Move type inference from jit_convert to jit_infer
Max Brister <max@2bass.com>
parents:
15182
diff
changeset
|
124 { |
ed4f4fb78586
Move type inference from jit_convert to jit_infer
Max Brister <max@2bass.com>
parents:
15182
diff
changeset
|
125 for (jit_block_list::const_iterator iter = blocks.begin (); |
ed4f4fb78586
Move type inference from jit_convert to jit_infer
Max Brister <max@2bass.com>
parents:
15182
diff
changeset
|
126 iter != blocks.end (); ++iter) |
ed4f4fb78586
Move type inference from jit_convert to jit_infer
Max Brister <max@2bass.com>
parents:
15182
diff
changeset
|
127 { |
ed4f4fb78586
Move type inference from jit_convert to jit_infer
Max Brister <max@2bass.com>
parents:
15182
diff
changeset
|
128 assert (*iter); |
ed4f4fb78586
Move type inference from jit_convert to jit_infer
Max Brister <max@2bass.com>
parents:
15182
diff
changeset
|
129 (*iter)->print (os, 0); |
ed4f4fb78586
Move type inference from jit_convert to jit_infer
Max Brister <max@2bass.com>
parents:
15182
diff
changeset
|
130 } |
ed4f4fb78586
Move type inference from jit_convert to jit_infer
Max Brister <max@2bass.com>
parents:
15182
diff
changeset
|
131 return os << std::endl; |
ed4f4fb78586
Move type inference from jit_convert to jit_infer
Max Brister <max@2bass.com>
parents:
15182
diff
changeset
|
132 } |
ed4f4fb78586
Move type inference from jit_convert to jit_infer
Max Brister <max@2bass.com>
parents:
15182
diff
changeset
|
133 |
15016 | 134 // -------------------- jit_use -------------------- |
135 jit_block * | |
136 jit_use::user_parent (void) const | |
137 { | |
138 return muser->parent (); | |
139 } | |
140 | |
141 // -------------------- jit_value -------------------- | |
142 jit_value::~jit_value (void) | |
143 {} | |
144 | |
145 jit_block * | |
146 jit_value::first_use_block (void) | |
147 { | |
148 jit_use *use = first_use (); | |
149 while (use) | |
150 { | |
151 if (! isa<jit_error_check> (use->user ())) | |
152 return use->user_parent (); | |
153 | |
154 use = use->next (); | |
155 } | |
156 | |
157 return 0; | |
158 } | |
159 | |
160 void | |
161 jit_value::replace_with (jit_value *value) | |
162 { | |
163 while (first_use ()) | |
164 { | |
165 jit_instruction *user = first_use ()->user (); | |
166 size_t idx = first_use ()->index (); | |
167 user->stash_argument (idx, value); | |
168 } | |
169 } | |
170 | |
171 #define JIT_METH(clname) \ | |
172 void \ | |
173 jit_ ## clname::accept (jit_ir_walker& walker) \ | |
174 { \ | |
175 walker.visit (*this); \ | |
176 } | |
177 | |
178 JIT_VISIT_IR_NOTEMPLATE | |
179 #undef JIT_METH | |
180 | |
181 std::ostream& | |
182 operator<< (std::ostream& os, const jit_value& value) | |
183 { | |
184 return value.short_print (os); | |
185 } | |
186 | |
187 std::ostream& | |
188 jit_print (std::ostream& os, jit_value *avalue) | |
189 { | |
190 if (avalue) | |
191 return avalue->print (os); | |
192 return os << "NULL"; | |
193 } | |
194 | |
195 // -------------------- jit_instruction -------------------- | |
196 void | |
197 jit_instruction::remove (void) | |
198 { | |
199 if (mparent) | |
200 mparent->remove (mlocation); | |
201 resize_arguments (0); | |
202 } | |
203 | |
204 llvm::BasicBlock * | |
205 jit_instruction::parent_llvm (void) const | |
206 { | |
207 return mparent->to_llvm (); | |
208 } | |
209 | |
210 std::ostream& | |
211 jit_instruction::short_print (std::ostream& os) const | |
212 { | |
213 if (type ()) | |
214 jit_print (os, type ()) << ": "; | |
215 return os << "#" << mid; | |
216 } | |
217 | |
218 void | |
219 jit_instruction::do_construct_ssa (size_t start, size_t end) | |
220 { | |
221 for (size_t i = start; i < end; ++i) | |
222 { | |
223 jit_value *arg = argument (i); | |
224 jit_variable *var = dynamic_cast<jit_variable *> (arg); | |
225 if (var && var->has_top ()) | |
226 stash_argument (i, var->top ()); | |
227 } | |
228 } | |
229 | |
230 // -------------------- jit_block -------------------- | |
231 void | |
232 jit_block::replace_with (jit_value *value) | |
233 { | |
234 assert (isa<jit_block> (value)); | |
235 jit_block *block = static_cast<jit_block *> (value); | |
236 | |
237 jit_value::replace_with (block); | |
238 | |
239 while (ILIST_T::first_use ()) | |
240 { | |
241 jit_phi_incomming *incomming = ILIST_T::first_use (); | |
242 incomming->stash_value (block); | |
243 } | |
244 } | |
245 | |
246 void | |
247 jit_block::replace_in_phi (jit_block *ablock, jit_block *with) | |
248 { | |
249 jit_phi_incomming *node = ILIST_T::first_use (); | |
250 while (node) | |
251 { | |
252 jit_phi_incomming *prev = node; | |
253 node = node->next (); | |
254 | |
255 if (prev->user_parent () == ablock) | |
256 prev->stash_value (with); | |
257 } | |
258 } | |
259 | |
260 jit_block * | |
261 jit_block::maybe_merge () | |
262 { | |
263 if (successor_count () == 1 && successor (0) != this | |
264 && (successor (0)->use_count () == 1 || instructions.size () == 1)) | |
265 { | |
266 jit_block *to_merge = successor (0); | |
267 merge (*to_merge); | |
268 return to_merge; | |
269 } | |
270 | |
271 return 0; | |
272 } | |
273 | |
274 void | |
275 jit_block::merge (jit_block& block) | |
276 { | |
277 // the merge block will contain a new terminator | |
278 jit_terminator *old_term = terminator (); | |
279 if (old_term) | |
280 old_term->remove (); | |
281 | |
282 bool was_empty = end () == begin (); | |
283 iterator merge_begin = end (); | |
284 if (! was_empty) | |
285 --merge_begin; | |
286 | |
287 instructions.splice (end (), block.instructions); | |
288 if (was_empty) | |
289 merge_begin = begin (); | |
290 else | |
291 ++merge_begin; | |
292 | |
293 // now merge_begin points to the start of the new instructions, we must | |
294 // update their parent information | |
295 for (iterator iter = merge_begin; iter != end (); ++iter) | |
296 { | |
297 jit_instruction *instr = *iter; | |
298 instr->stash_parent (this, iter); | |
299 } | |
300 | |
301 block.replace_with (this); | |
302 } | |
303 | |
304 jit_instruction * | |
305 jit_block::prepend (jit_instruction *instr) | |
306 { | |
307 instructions.push_front (instr); | |
308 instr->stash_parent (this, instructions.begin ()); | |
309 return instr; | |
310 } | |
311 | |
312 jit_instruction * | |
313 jit_block::prepend_after_phi (jit_instruction *instr) | |
314 { | |
315 // FIXME: Make this O(1) | |
316 for (iterator iter = begin (); iter != end (); ++iter) | |
317 { | |
318 jit_instruction *temp = *iter; | |
319 if (! isa<jit_phi> (temp)) | |
320 { | |
321 insert_before (iter, instr); | |
322 return instr; | |
323 } | |
324 } | |
325 | |
326 return append (instr); | |
327 } | |
328 | |
329 void | |
330 jit_block::internal_append (jit_instruction *instr) | |
331 { | |
332 instructions.push_back (instr); | |
333 instr->stash_parent (this, --instructions.end ()); | |
334 } | |
335 | |
336 jit_instruction * | |
337 jit_block::insert_before (iterator loc, jit_instruction *instr) | |
338 { | |
339 iterator iloc = instructions.insert (loc, instr); | |
340 instr->stash_parent (this, iloc); | |
341 return instr; | |
342 } | |
343 | |
344 jit_instruction * | |
345 jit_block::insert_after (iterator loc, jit_instruction *instr) | |
346 { | |
347 ++loc; | |
348 iterator iloc = instructions.insert (loc, instr); | |
349 instr->stash_parent (this, iloc); | |
350 return instr; | |
351 } | |
352 | |
353 jit_terminator * | |
354 jit_block::terminator (void) const | |
355 { | |
356 assert (this); | |
357 if (instructions.empty ()) | |
358 return 0; | |
359 | |
360 jit_instruction *last = instructions.back (); | |
361 return dynamic_cast<jit_terminator *> (last); | |
362 } | |
363 | |
364 bool | |
365 jit_block::branch_alive (jit_block *asucc) const | |
366 { | |
367 return terminator ()->alive (asucc); | |
368 } | |
369 | |
370 jit_block * | |
371 jit_block::successor (size_t i) const | |
372 { | |
373 jit_terminator *term = terminator (); | |
374 return term->successor (i); | |
375 } | |
376 | |
377 size_t | |
378 jit_block::successor_count (void) const | |
379 { | |
380 jit_terminator *term = terminator (); | |
381 return term ? term->successor_count () : 0; | |
382 } | |
383 | |
384 llvm::BasicBlock * | |
385 jit_block::to_llvm (void) const | |
386 { | |
387 return llvm::cast<llvm::BasicBlock> (llvm_value); | |
388 } | |
389 | |
390 std::ostream& | |
391 jit_block::print_dom (std::ostream& os) const | |
392 { | |
393 short_print (os); | |
394 os << ":\n"; | |
395 os << " mid: " << mid << std::endl; | |
396 os << " predecessors: "; | |
397 for (jit_use *use = first_use (); use; use = use->next ()) | |
398 os << *use->user_parent () << " "; | |
399 os << std::endl; | |
400 | |
401 os << " successors: "; | |
402 for (size_t i = 0; i < successor_count (); ++i) | |
403 os << *successor (i) << " "; | |
404 os << std::endl; | |
405 | |
406 os << " idom: "; | |
407 if (idom) | |
408 os << *idom; | |
409 else | |
410 os << "NULL"; | |
411 os << std::endl; | |
412 os << " df: "; | |
413 for (df_iterator iter = df_begin (); iter != df_end (); ++iter) | |
414 os << **iter << " "; | |
415 os << std::endl; | |
416 | |
417 os << " dom_succ: "; | |
418 for (size_t i = 0; i < dom_succ.size (); ++i) | |
419 os << *dom_succ[i] << " "; | |
420 | |
421 return os << std::endl; | |
422 } | |
423 | |
424 void | |
425 jit_block::compute_df (size_t avisit_count) | |
426 { | |
427 if (visited (avisit_count)) | |
428 return; | |
429 | |
430 if (use_count () >= 2) | |
431 { | |
432 for (jit_use *use = first_use (); use; use = use->next ()) | |
433 { | |
434 jit_block *runner = use->user_parent (); | |
435 while (runner != idom) | |
436 { | |
437 runner->mdf.insert (this); | |
438 runner = runner->idom; | |
439 } | |
440 } | |
441 } | |
442 | |
443 for (size_t i = 0; i < successor_count (); ++i) | |
444 successor (i)->compute_df (avisit_count); | |
445 } | |
446 | |
447 bool | |
448 jit_block::update_idom (size_t avisit_count) | |
449 { | |
450 if (visited (avisit_count) || ! use_count ()) | |
451 return false; | |
452 | |
453 bool changed = false; | |
454 for (jit_use *use = first_use (); use; use = use->next ()) | |
455 { | |
456 jit_block *pred = use->user_parent (); | |
457 changed = pred->update_idom (avisit_count) || changed; | |
458 } | |
459 | |
460 jit_use *use = first_use (); | |
461 jit_block *new_idom = use->user_parent (); | |
462 use = use->next (); | |
463 | |
464 for (; use; use = use->next ()) | |
465 { | |
466 jit_block *pred = use->user_parent (); | |
467 jit_block *pidom = pred->idom; | |
468 if (pidom) | |
469 new_idom = idom_intersect (pidom, new_idom); | |
470 } | |
471 | |
472 if (idom != new_idom) | |
473 { | |
474 idom = new_idom; | |
475 return true; | |
476 } | |
477 | |
478 return changed; | |
479 } | |
480 | |
481 void | |
15602
f3e339aee38f
Fix block labeling in JIT debug output
Max Brister <max@2bass.com>
parents:
15259
diff
changeset
|
482 jit_block::label (size_t avisit_count, size_t& number) |
f3e339aee38f
Fix block labeling in JIT debug output
Max Brister <max@2bass.com>
parents:
15259
diff
changeset
|
483 { |
f3e339aee38f
Fix block labeling in JIT debug output
Max Brister <max@2bass.com>
parents:
15259
diff
changeset
|
484 if (visited (avisit_count)) |
f3e339aee38f
Fix block labeling in JIT debug output
Max Brister <max@2bass.com>
parents:
15259
diff
changeset
|
485 return; |
f3e339aee38f
Fix block labeling in JIT debug output
Max Brister <max@2bass.com>
parents:
15259
diff
changeset
|
486 |
f3e339aee38f
Fix block labeling in JIT debug output
Max Brister <max@2bass.com>
parents:
15259
diff
changeset
|
487 for (jit_use *use = first_use (); use; use = use->next ()) |
f3e339aee38f
Fix block labeling in JIT debug output
Max Brister <max@2bass.com>
parents:
15259
diff
changeset
|
488 { |
f3e339aee38f
Fix block labeling in JIT debug output
Max Brister <max@2bass.com>
parents:
15259
diff
changeset
|
489 jit_block *pred = use->user_parent (); |
f3e339aee38f
Fix block labeling in JIT debug output
Max Brister <max@2bass.com>
parents:
15259
diff
changeset
|
490 pred->label (avisit_count, number); |
f3e339aee38f
Fix block labeling in JIT debug output
Max Brister <max@2bass.com>
parents:
15259
diff
changeset
|
491 } |
f3e339aee38f
Fix block labeling in JIT debug output
Max Brister <max@2bass.com>
parents:
15259
diff
changeset
|
492 |
f3e339aee38f
Fix block labeling in JIT debug output
Max Brister <max@2bass.com>
parents:
15259
diff
changeset
|
493 mid = number++; |
f3e339aee38f
Fix block labeling in JIT debug output
Max Brister <max@2bass.com>
parents:
15259
diff
changeset
|
494 } |
f3e339aee38f
Fix block labeling in JIT debug output
Max Brister <max@2bass.com>
parents:
15259
diff
changeset
|
495 |
f3e339aee38f
Fix block labeling in JIT debug output
Max Brister <max@2bass.com>
parents:
15259
diff
changeset
|
496 void |
15016 | 497 jit_block::pop_all (void) |
498 { | |
499 for (iterator iter = begin (); iter != end (); ++iter) | |
500 { | |
501 jit_instruction *instr = *iter; | |
502 instr->pop_variable (); | |
503 } | |
504 } | |
505 | |
15602
f3e339aee38f
Fix block labeling in JIT debug output
Max Brister <max@2bass.com>
parents:
15259
diff
changeset
|
506 std::ostream& |
f3e339aee38f
Fix block labeling in JIT debug output
Max Brister <max@2bass.com>
parents:
15259
diff
changeset
|
507 jit_block::print (std::ostream& os, size_t indent) const |
f3e339aee38f
Fix block labeling in JIT debug output
Max Brister <max@2bass.com>
parents:
15259
diff
changeset
|
508 { |
f3e339aee38f
Fix block labeling in JIT debug output
Max Brister <max@2bass.com>
parents:
15259
diff
changeset
|
509 print_indent (os, indent); |
f3e339aee38f
Fix block labeling in JIT debug output
Max Brister <max@2bass.com>
parents:
15259
diff
changeset
|
510 short_print (os) << ": %pred = "; |
f3e339aee38f
Fix block labeling in JIT debug output
Max Brister <max@2bass.com>
parents:
15259
diff
changeset
|
511 for (jit_use *use = first_use (); use; use = use->next ()) |
f3e339aee38f
Fix block labeling in JIT debug output
Max Brister <max@2bass.com>
parents:
15259
diff
changeset
|
512 { |
f3e339aee38f
Fix block labeling in JIT debug output
Max Brister <max@2bass.com>
parents:
15259
diff
changeset
|
513 jit_block *pred = use->user_parent (); |
f3e339aee38f
Fix block labeling in JIT debug output
Max Brister <max@2bass.com>
parents:
15259
diff
changeset
|
514 os << *pred; |
f3e339aee38f
Fix block labeling in JIT debug output
Max Brister <max@2bass.com>
parents:
15259
diff
changeset
|
515 if (use->next ()) |
f3e339aee38f
Fix block labeling in JIT debug output
Max Brister <max@2bass.com>
parents:
15259
diff
changeset
|
516 os << ", "; |
f3e339aee38f
Fix block labeling in JIT debug output
Max Brister <max@2bass.com>
parents:
15259
diff
changeset
|
517 } |
f3e339aee38f
Fix block labeling in JIT debug output
Max Brister <max@2bass.com>
parents:
15259
diff
changeset
|
518 os << std::endl; |
f3e339aee38f
Fix block labeling in JIT debug output
Max Brister <max@2bass.com>
parents:
15259
diff
changeset
|
519 |
f3e339aee38f
Fix block labeling in JIT debug output
Max Brister <max@2bass.com>
parents:
15259
diff
changeset
|
520 for (const_iterator iter = begin (); iter != end (); ++iter) |
f3e339aee38f
Fix block labeling in JIT debug output
Max Brister <max@2bass.com>
parents:
15259
diff
changeset
|
521 { |
f3e339aee38f
Fix block labeling in JIT debug output
Max Brister <max@2bass.com>
parents:
15259
diff
changeset
|
522 jit_instruction *instr = *iter; |
f3e339aee38f
Fix block labeling in JIT debug output
Max Brister <max@2bass.com>
parents:
15259
diff
changeset
|
523 instr->print (os, indent + 1) << std::endl; |
f3e339aee38f
Fix block labeling in JIT debug output
Max Brister <max@2bass.com>
parents:
15259
diff
changeset
|
524 } |
f3e339aee38f
Fix block labeling in JIT debug output
Max Brister <max@2bass.com>
parents:
15259
diff
changeset
|
525 return os; |
f3e339aee38f
Fix block labeling in JIT debug output
Max Brister <max@2bass.com>
parents:
15259
diff
changeset
|
526 } |
f3e339aee38f
Fix block labeling in JIT debug output
Max Brister <max@2bass.com>
parents:
15259
diff
changeset
|
527 |
15016 | 528 jit_block * |
15182
a7a56b436de2
Factor out jit_block_list and jit_factory from jit_convert
Max Brister <max@2bass.com>
parents:
15171
diff
changeset
|
529 jit_block::maybe_split (jit_factory& factory, jit_block_list& blocks, |
a7a56b436de2
Factor out jit_block_list and jit_factory from jit_convert
Max Brister <max@2bass.com>
parents:
15171
diff
changeset
|
530 jit_block *asuccessor) |
15016 | 531 { |
532 if (successor_count () > 1) | |
533 { | |
534 jit_terminator *term = terminator (); | |
535 size_t idx = term->successor_index (asuccessor); | |
15182
a7a56b436de2
Factor out jit_block_list and jit_factory from jit_convert
Max Brister <max@2bass.com>
parents:
15171
diff
changeset
|
536 jit_block *split = factory.create<jit_block> ("phi_split", mvisit_count); |
15016 | 537 |
15171
7a19e8275d41
Do not simplify the CFG during type inference
Max Brister <max@2bass.com>
parents:
15124
diff
changeset
|
538 // place after this to ensure define before use in the blocks list |
15182
a7a56b436de2
Factor out jit_block_list and jit_factory from jit_convert
Max Brister <max@2bass.com>
parents:
15171
diff
changeset
|
539 blocks.insert_after (this, split); |
15016 | 540 |
541 term->stash_argument (idx, split); | |
15182
a7a56b436de2
Factor out jit_block_list and jit_factory from jit_convert
Max Brister <max@2bass.com>
parents:
15171
diff
changeset
|
542 jit_branch *br = split->append (factory.create<jit_branch> (asuccessor)); |
15016 | 543 replace_in_phi (asuccessor, split); |
544 | |
545 if (alive ()) | |
546 { | |
547 split->mark_alive (); | |
548 br->infer (); | |
549 } | |
550 | |
551 return split; | |
552 } | |
553 | |
554 return this; | |
555 } | |
556 | |
557 void | |
558 jit_block::create_dom_tree (size_t avisit_count) | |
559 { | |
560 if (visited (avisit_count)) | |
561 return; | |
562 | |
563 if (idom != this) | |
564 idom->dom_succ.push_back (this); | |
565 | |
566 for (size_t i = 0; i < successor_count (); ++i) | |
567 successor (i)->create_dom_tree (avisit_count); | |
568 } | |
569 | |
570 jit_block * | |
571 jit_block::idom_intersect (jit_block *i, jit_block *j) | |
572 { | |
573 while (i && j && i != j) | |
574 { | |
575 while (i && i->id () > j->id ()) | |
576 i = i->idom; | |
577 | |
578 while (i && j && j->id () > i->id ()) | |
579 j = j->idom; | |
580 } | |
581 | |
582 return i ? i : j; | |
583 } | |
584 | |
585 // -------------------- jit_phi_incomming -------------------- | |
586 | |
587 jit_block * | |
588 jit_phi_incomming::user_parent (void) const | |
589 { return muser->parent (); } | |
590 | |
591 // -------------------- jit_phi -------------------- | |
592 bool | |
593 jit_phi::prune (void) | |
594 { | |
595 jit_block *p = parent (); | |
596 size_t new_idx = 0; | |
597 jit_value *unique = argument (1); | |
598 | |
599 for (size_t i = 0; i < argument_count (); ++i) | |
600 { | |
601 jit_block *inc = incomming (i); | |
602 if (inc->branch_alive (p)) | |
603 { | |
604 if (unique != argument (i)) | |
605 unique = 0; | |
606 | |
607 if (new_idx != i) | |
608 { | |
609 stash_argument (new_idx, argument (i)); | |
610 mincomming[new_idx].stash_value (inc); | |
611 } | |
612 | |
613 ++new_idx; | |
614 } | |
615 } | |
616 | |
617 if (new_idx != argument_count ()) | |
618 { | |
619 resize_arguments (new_idx); | |
620 mincomming.resize (new_idx); | |
621 } | |
622 | |
623 assert (argument_count () > 0); | |
624 if (unique) | |
625 { | |
626 replace_with (unique); | |
627 return true; | |
628 } | |
629 | |
630 return false; | |
631 } | |
632 | |
633 bool | |
634 jit_phi::infer (void) | |
635 { | |
636 jit_block *p = parent (); | |
637 if (! p->alive ()) | |
638 return false; | |
639 | |
640 jit_type *infered = 0; | |
641 for (size_t i = 0; i < argument_count (); ++i) | |
642 { | |
643 jit_block *inc = incomming (i); | |
644 if (inc->branch_alive (p)) | |
645 infered = jit_typeinfo::join (infered, argument_type (i)); | |
646 } | |
647 | |
648 if (infered != type ()) | |
649 { | |
650 stash_type (infered); | |
651 return true; | |
652 } | |
653 | |
654 return false; | |
655 } | |
656 | |
657 llvm::PHINode * | |
658 jit_phi::to_llvm (void) const | |
659 { | |
660 return llvm::cast<llvm::PHINode> (jit_value::to_llvm ()); | |
661 } | |
662 | |
663 // -------------------- jit_terminator -------------------- | |
664 size_t | |
665 jit_terminator::successor_index (const jit_block *asuccessor) const | |
666 { | |
667 size_t scount = successor_count (); | |
668 for (size_t i = 0; i < scount; ++i) | |
669 if (successor (i) == asuccessor) | |
670 return i; | |
671 | |
672 panic_impossible (); | |
673 } | |
674 | |
675 bool | |
676 jit_terminator::infer (void) | |
677 { | |
678 if (! parent ()->alive ()) | |
679 return false; | |
680 | |
681 bool changed = false; | |
682 for (size_t i = 0; i < malive.size (); ++i) | |
683 if (! malive[i] && check_alive (i)) | |
684 { | |
685 changed = true; | |
686 malive[i] = true; | |
687 successor (i)->mark_alive (); | |
688 } | |
689 | |
690 return changed; | |
691 } | |
692 | |
693 llvm::TerminatorInst * | |
694 jit_terminator::to_llvm (void) const | |
695 { | |
696 return llvm::cast<llvm::TerminatorInst> (jit_value::to_llvm ()); | |
697 } | |
698 | |
699 // -------------------- jit_call -------------------- | |
700 bool | |
701 jit_call::infer (void) | |
702 { | |
703 // FIXME: explain algorithm | |
704 for (size_t i = 0; i < argument_count (); ++i) | |
705 { | |
706 already_infered[i] = argument_type (i); | |
707 if (! already_infered[i]) | |
708 return false; | |
709 } | |
710 | |
711 jit_type *infered = moperation.result (already_infered); | |
712 if (! infered && use_count ()) | |
713 { | |
714 std::stringstream ss; | |
715 ss << "Missing overload in type inference for "; | |
716 print (ss, 0); | |
717 throw jit_fail_exception (ss.str ()); | |
718 } | |
719 | |
720 if (infered != type ()) | |
721 { | |
722 stash_type (infered); | |
723 return true; | |
724 } | |
725 | |
726 return false; | |
727 } | |
728 | |
15056
bc32288f4a42
Support the end keyword for one dimentional indexing in JIT.
Max Brister <max@2bass.com>
parents:
15016
diff
changeset
|
729 // -------------------- jit_magic_end -------------------- |
15182
a7a56b436de2
Factor out jit_block_list and jit_factory from jit_convert
Max Brister <max@2bass.com>
parents:
15171
diff
changeset
|
730 jit_magic_end::context::context (jit_factory& factory, jit_value *avalue, |
15102
d29f2583cf7b
Support end in multi indexing in JIT
Max Brister <max@2bass.com>
parents:
15096
diff
changeset
|
731 size_t aindex, size_t acount) |
15182
a7a56b436de2
Factor out jit_block_list and jit_factory from jit_convert
Max Brister <max@2bass.com>
parents:
15171
diff
changeset
|
732 : value (avalue), index (factory.create<jit_const_index> (aindex)), |
a7a56b436de2
Factor out jit_block_list and jit_factory from jit_convert
Max Brister <max@2bass.com>
parents:
15171
diff
changeset
|
733 count (factory.create<jit_const_index> (acount)) |
15102
d29f2583cf7b
Support end in multi indexing in JIT
Max Brister <max@2bass.com>
parents:
15096
diff
changeset
|
734 {} |
d29f2583cf7b
Support end in multi indexing in JIT
Max Brister <max@2bass.com>
parents:
15096
diff
changeset
|
735 |
15067 | 736 jit_magic_end::jit_magic_end (const std::vector<context>& full_context) |
15102
d29f2583cf7b
Support end in multi indexing in JIT
Max Brister <max@2bass.com>
parents:
15096
diff
changeset
|
737 : contexts (full_context) |
15067 | 738 { |
15102
d29f2583cf7b
Support end in multi indexing in JIT
Max Brister <max@2bass.com>
parents:
15096
diff
changeset
|
739 resize_arguments (contexts.size ()); |
15067 | 740 |
741 size_t i; | |
742 std::vector<context>::const_iterator iter; | |
15102
d29f2583cf7b
Support end in multi indexing in JIT
Max Brister <max@2bass.com>
parents:
15096
diff
changeset
|
743 for (iter = contexts.begin (), i = 0; iter != contexts.end (); ++iter, ++i) |
d29f2583cf7b
Support end in multi indexing in JIT
Max Brister <max@2bass.com>
parents:
15096
diff
changeset
|
744 stash_argument (i, iter->value); |
15067 | 745 } |
746 | |
15102
d29f2583cf7b
Support end in multi indexing in JIT
Max Brister <max@2bass.com>
parents:
15096
diff
changeset
|
747 jit_magic_end::context |
15056
bc32288f4a42
Support the end keyword for one dimentional indexing in JIT.
Max Brister <max@2bass.com>
parents:
15016
diff
changeset
|
748 jit_magic_end::resolve_context (void) const |
bc32288f4a42
Support the end keyword for one dimentional indexing in JIT.
Max Brister <max@2bass.com>
parents:
15016
diff
changeset
|
749 { |
15124
0464e3ceb85b
Skip functions when resolving end context in JIT
Max Brister <max@2bass.com>
parents:
15102
diff
changeset
|
750 size_t idx; |
0464e3ceb85b
Skip functions when resolving end context in JIT
Max Brister <max@2bass.com>
parents:
15102
diff
changeset
|
751 for (idx = 0; idx < contexts.size (); ++idx) |
0464e3ceb85b
Skip functions when resolving end context in JIT
Max Brister <max@2bass.com>
parents:
15102
diff
changeset
|
752 { |
0464e3ceb85b
Skip functions when resolving end context in JIT
Max Brister <max@2bass.com>
parents:
15102
diff
changeset
|
753 jit_type *ctx_type = contexts[idx].value->type (); |
0464e3ceb85b
Skip functions when resolving end context in JIT
Max Brister <max@2bass.com>
parents:
15102
diff
changeset
|
754 if (! ctx_type || ctx_type->skip_paren ()) |
0464e3ceb85b
Skip functions when resolving end context in JIT
Max Brister <max@2bass.com>
parents:
15102
diff
changeset
|
755 break; |
0464e3ceb85b
Skip functions when resolving end context in JIT
Max Brister <max@2bass.com>
parents:
15102
diff
changeset
|
756 } |
0464e3ceb85b
Skip functions when resolving end context in JIT
Max Brister <max@2bass.com>
parents:
15102
diff
changeset
|
757 |
0464e3ceb85b
Skip functions when resolving end context in JIT
Max Brister <max@2bass.com>
parents:
15102
diff
changeset
|
758 if (idx >= contexts.size ()) |
0464e3ceb85b
Skip functions when resolving end context in JIT
Max Brister <max@2bass.com>
parents:
15102
diff
changeset
|
759 idx = 0; |
0464e3ceb85b
Skip functions when resolving end context in JIT
Max Brister <max@2bass.com>
parents:
15102
diff
changeset
|
760 |
0464e3ceb85b
Skip functions when resolving end context in JIT
Max Brister <max@2bass.com>
parents:
15102
diff
changeset
|
761 context ret = contexts[idx]; |
0464e3ceb85b
Skip functions when resolving end context in JIT
Max Brister <max@2bass.com>
parents:
15102
diff
changeset
|
762 ret.value = argument (idx); |
15102
d29f2583cf7b
Support end in multi indexing in JIT
Max Brister <max@2bass.com>
parents:
15096
diff
changeset
|
763 return ret; |
15056
bc32288f4a42
Support the end keyword for one dimentional indexing in JIT.
Max Brister <max@2bass.com>
parents:
15016
diff
changeset
|
764 } |
bc32288f4a42
Support the end keyword for one dimentional indexing in JIT.
Max Brister <max@2bass.com>
parents:
15016
diff
changeset
|
765 |
bc32288f4a42
Support the end keyword for one dimentional indexing in JIT.
Max Brister <max@2bass.com>
parents:
15016
diff
changeset
|
766 bool |
bc32288f4a42
Support the end keyword for one dimentional indexing in JIT.
Max Brister <max@2bass.com>
parents:
15016
diff
changeset
|
767 jit_magic_end::infer (void) |
bc32288f4a42
Support the end keyword for one dimentional indexing in JIT.
Max Brister <max@2bass.com>
parents:
15016
diff
changeset
|
768 { |
bc32288f4a42
Support the end keyword for one dimentional indexing in JIT.
Max Brister <max@2bass.com>
parents:
15016
diff
changeset
|
769 jit_type *new_type = overload ().result (); |
bc32288f4a42
Support the end keyword for one dimentional indexing in JIT.
Max Brister <max@2bass.com>
parents:
15016
diff
changeset
|
770 if (new_type != type ()) |
bc32288f4a42
Support the end keyword for one dimentional indexing in JIT.
Max Brister <max@2bass.com>
parents:
15016
diff
changeset
|
771 { |
bc32288f4a42
Support the end keyword for one dimentional indexing in JIT.
Max Brister <max@2bass.com>
parents:
15016
diff
changeset
|
772 stash_type (new_type); |
bc32288f4a42
Support the end keyword for one dimentional indexing in JIT.
Max Brister <max@2bass.com>
parents:
15016
diff
changeset
|
773 return true; |
bc32288f4a42
Support the end keyword for one dimentional indexing in JIT.
Max Brister <max@2bass.com>
parents:
15016
diff
changeset
|
774 } |
bc32288f4a42
Support the end keyword for one dimentional indexing in JIT.
Max Brister <max@2bass.com>
parents:
15016
diff
changeset
|
775 |
bc32288f4a42
Support the end keyword for one dimentional indexing in JIT.
Max Brister <max@2bass.com>
parents:
15016
diff
changeset
|
776 return false; |
bc32288f4a42
Support the end keyword for one dimentional indexing in JIT.
Max Brister <max@2bass.com>
parents:
15016
diff
changeset
|
777 } |
bc32288f4a42
Support the end keyword for one dimentional indexing in JIT.
Max Brister <max@2bass.com>
parents:
15016
diff
changeset
|
778 |
15102
d29f2583cf7b
Support end in multi indexing in JIT
Max Brister <max@2bass.com>
parents:
15096
diff
changeset
|
779 std::ostream& |
d29f2583cf7b
Support end in multi indexing in JIT
Max Brister <max@2bass.com>
parents:
15096
diff
changeset
|
780 jit_magic_end::print (std::ostream& os, size_t indent) const |
d29f2583cf7b
Support end in multi indexing in JIT
Max Brister <max@2bass.com>
parents:
15096
diff
changeset
|
781 { |
d29f2583cf7b
Support end in multi indexing in JIT
Max Brister <max@2bass.com>
parents:
15096
diff
changeset
|
782 context ctx = resolve_context (); |
d29f2583cf7b
Support end in multi indexing in JIT
Max Brister <max@2bass.com>
parents:
15096
diff
changeset
|
783 short_print (print_indent (os, indent)) << " (" << *ctx.value << ", "; |
d29f2583cf7b
Support end in multi indexing in JIT
Max Brister <max@2bass.com>
parents:
15096
diff
changeset
|
784 return os << *ctx.index << ", " << *ctx.count << ")"; |
d29f2583cf7b
Support end in multi indexing in JIT
Max Brister <max@2bass.com>
parents:
15096
diff
changeset
|
785 } |
d29f2583cf7b
Support end in multi indexing in JIT
Max Brister <max@2bass.com>
parents:
15096
diff
changeset
|
786 |
d29f2583cf7b
Support end in multi indexing in JIT
Max Brister <max@2bass.com>
parents:
15096
diff
changeset
|
787 const jit_function& |
d29f2583cf7b
Support end in multi indexing in JIT
Max Brister <max@2bass.com>
parents:
15096
diff
changeset
|
788 jit_magic_end::overload () const |
d29f2583cf7b
Support end in multi indexing in JIT
Max Brister <max@2bass.com>
parents:
15096
diff
changeset
|
789 { |
d29f2583cf7b
Support end in multi indexing in JIT
Max Brister <max@2bass.com>
parents:
15096
diff
changeset
|
790 const context& ctx = resolve_context (); |
d29f2583cf7b
Support end in multi indexing in JIT
Max Brister <max@2bass.com>
parents:
15096
diff
changeset
|
791 return jit_typeinfo::end (ctx.value, ctx.index, ctx.count); |
d29f2583cf7b
Support end in multi indexing in JIT
Max Brister <max@2bass.com>
parents:
15096
diff
changeset
|
792 } |
d29f2583cf7b
Support end in multi indexing in JIT
Max Brister <max@2bass.com>
parents:
15096
diff
changeset
|
793 |
15016 | 794 #endif |