Mercurial > hg > graal-compiler
annotate src/share/vm/adlc/formssel.cpp @ 12364:651cc32247d7
Add Graal option for deferring write barriers of eden allocated objects
author | Christos Kotselidis <christos.kotselidis@oracle.com> |
---|---|
date | Fri, 11 Oct 2013 17:06:18 +0200 |
parents | 7fa25f5575c9 |
children | c9ccd7b85f20 |
rev | line source |
---|---|
0 | 1 /* |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6143
diff
changeset
|
2 * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. |
0 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1541
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1541
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1541
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
25 // FORMS.CPP - Definitions for ADL Parser Forms Classes | |
26 #include "adlc.hpp" | |
27 | |
28 //==============================Instructions=================================== | |
29 //------------------------------InstructForm----------------------------------- | |
30 InstructForm::InstructForm(const char *id, bool ideal_only) | |
31 : _ident(id), _ideal_only(ideal_only), | |
32 _localNames(cmpstr, hashstr, Form::arena), | |
2008 | 33 _effects(cmpstr, hashstr, Form::arena), |
4120
f03a3c8bd5e5
7077312: Provide a CALL effect for instruct declaration in the ad file
roland
parents:
3965
diff
changeset
|
34 _is_mach_constant(false), |
f03a3c8bd5e5
7077312: Provide a CALL effect for instruct declaration in the ad file
roland
parents:
3965
diff
changeset
|
35 _has_call(false) |
2008 | 36 { |
0 | 37 _ftype = Form::INS; |
38 | |
39 _matrule = NULL; | |
40 _insencode = NULL; | |
2008 | 41 _constant = NULL; |
0 | 42 _opcode = NULL; |
43 _size = NULL; | |
44 _attribs = NULL; | |
45 _predicate = NULL; | |
46 _exprule = NULL; | |
47 _rewrule = NULL; | |
48 _format = NULL; | |
49 _peephole = NULL; | |
50 _ins_pipe = NULL; | |
51 _uniq_idx = NULL; | |
52 _num_uniq = 0; | |
53 _cisc_spill_operand = Not_cisc_spillable;// Which operand may cisc-spill | |
54 _cisc_spill_alternate = NULL; // possible cisc replacement | |
55 _cisc_reg_mask_name = NULL; | |
56 _is_cisc_alternate = false; | |
57 _is_short_branch = false; | |
58 _short_branch_form = NULL; | |
59 _alignment = 1; | |
60 } | |
61 | |
62 InstructForm::InstructForm(const char *id, InstructForm *instr, MatchRule *rule) | |
63 : _ident(id), _ideal_only(false), | |
64 _localNames(instr->_localNames), | |
2008 | 65 _effects(instr->_effects), |
4120
f03a3c8bd5e5
7077312: Provide a CALL effect for instruct declaration in the ad file
roland
parents:
3965
diff
changeset
|
66 _is_mach_constant(false), |
f03a3c8bd5e5
7077312: Provide a CALL effect for instruct declaration in the ad file
roland
parents:
3965
diff
changeset
|
67 _has_call(false) |
2008 | 68 { |
0 | 69 _ftype = Form::INS; |
70 | |
71 _matrule = rule; | |
72 _insencode = instr->_insencode; | |
2008 | 73 _constant = instr->_constant; |
0 | 74 _opcode = instr->_opcode; |
75 _size = instr->_size; | |
76 _attribs = instr->_attribs; | |
77 _predicate = instr->_predicate; | |
78 _exprule = instr->_exprule; | |
79 _rewrule = instr->_rewrule; | |
80 _format = instr->_format; | |
81 _peephole = instr->_peephole; | |
82 _ins_pipe = instr->_ins_pipe; | |
83 _uniq_idx = instr->_uniq_idx; | |
84 _num_uniq = instr->_num_uniq; | |
85 _cisc_spill_operand = Not_cisc_spillable;// Which operand may cisc-spill | |
86 _cisc_spill_alternate = NULL; // possible cisc replacement | |
87 _cisc_reg_mask_name = NULL; | |
88 _is_cisc_alternate = false; | |
89 _is_short_branch = false; | |
90 _short_branch_form = NULL; | |
91 _alignment = 1; | |
92 // Copy parameters | |
93 const char *name; | |
94 instr->_parameters.reset(); | |
95 for (; (name = instr->_parameters.iter()) != NULL;) | |
96 _parameters.addName(name); | |
97 } | |
98 | |
99 InstructForm::~InstructForm() { | |
100 } | |
101 | |
102 InstructForm *InstructForm::is_instruction() const { | |
103 return (InstructForm*)this; | |
104 } | |
105 | |
106 bool InstructForm::ideal_only() const { | |
107 return _ideal_only; | |
108 } | |
109 | |
110 bool InstructForm::sets_result() const { | |
111 return (_matrule != NULL && _matrule->sets_result()); | |
112 } | |
113 | |
114 bool InstructForm::needs_projections() { | |
115 _components.reset(); | |
116 for( Component *comp; (comp = _components.iter()) != NULL; ) { | |
117 if (comp->isa(Component::KILL)) { | |
118 return true; | |
119 } | |
120 } | |
121 return false; | |
122 } | |
123 | |
124 | |
125 bool InstructForm::has_temps() { | |
126 if (_matrule) { | |
127 // Examine each component to see if it is a TEMP | |
128 _components.reset(); | |
129 // Skip the first component, if already handled as (SET dst (...)) | |
130 Component *comp = NULL; | |
131 if (sets_result()) comp = _components.iter(); | |
132 while ((comp = _components.iter()) != NULL) { | |
133 if (comp->isa(Component::TEMP)) { | |
134 return true; | |
135 } | |
136 } | |
137 } | |
138 | |
139 return false; | |
140 } | |
141 | |
142 uint InstructForm::num_defs_or_kills() { | |
143 uint defs_or_kills = 0; | |
144 | |
145 _components.reset(); | |
146 for( Component *comp; (comp = _components.iter()) != NULL; ) { | |
147 if( comp->isa(Component::DEF) || comp->isa(Component::KILL) ) { | |
148 ++defs_or_kills; | |
149 } | |
150 } | |
151 | |
152 return defs_or_kills; | |
153 } | |
154 | |
155 // This instruction has an expand rule? | |
156 bool InstructForm::expands() const { | |
157 return ( _exprule != NULL ); | |
158 } | |
159 | |
160 // This instruction has a peephole rule? | |
161 Peephole *InstructForm::peepholes() const { | |
162 return _peephole; | |
163 } | |
164 | |
165 // This instruction has a peephole rule? | |
166 void InstructForm::append_peephole(Peephole *peephole) { | |
167 if( _peephole == NULL ) { | |
168 _peephole = peephole; | |
169 } else { | |
170 _peephole->append_peephole(peephole); | |
171 } | |
172 } | |
173 | |
174 | |
175 // ideal opcode enumeration | |
176 const char *InstructForm::ideal_Opcode( FormDict &globalNames ) const { | |
177 if( !_matrule ) return "Node"; // Something weird | |
178 // Chain rules do not really have ideal Opcodes; use their source | |
179 // operand ideal Opcode instead. | |
180 if( is_simple_chain_rule(globalNames) ) { | |
181 const char *src = _matrule->_rChild->_opType; | |
182 OperandForm *src_op = globalNames[src]->is_operand(); | |
183 assert( src_op, "Not operand class of chain rule" ); | |
184 if( !src_op->_matrule ) return "Node"; | |
185 return src_op->_matrule->_opType; | |
186 } | |
187 // Operand chain rules do not really have ideal Opcodes | |
188 if( _matrule->is_chain_rule(globalNames) ) | |
189 return "Node"; | |
190 return strcmp(_matrule->_opType,"Set") | |
191 ? _matrule->_opType | |
192 : _matrule->_rChild->_opType; | |
193 } | |
194 | |
195 // Recursive check on all operands' match rules in my match rule | |
196 bool InstructForm::is_pinned(FormDict &globals) { | |
197 if ( ! _matrule) return false; | |
198 | |
199 int index = 0; | |
200 if (_matrule->find_type("Goto", index)) return true; | |
201 if (_matrule->find_type("If", index)) return true; | |
202 if (_matrule->find_type("CountedLoopEnd",index)) return true; | |
203 if (_matrule->find_type("Return", index)) return true; | |
204 if (_matrule->find_type("Rethrow", index)) return true; | |
205 if (_matrule->find_type("TailCall", index)) return true; | |
206 if (_matrule->find_type("TailJump", index)) return true; | |
207 if (_matrule->find_type("Halt", index)) return true; | |
208 if (_matrule->find_type("Jump", index)) return true; | |
209 | |
210 return is_parm(globals); | |
211 } | |
212 | |
213 // Recursive check on all operands' match rules in my match rule | |
214 bool InstructForm::is_projection(FormDict &globals) { | |
215 if ( ! _matrule) return false; | |
216 | |
217 int index = 0; | |
218 if (_matrule->find_type("Goto", index)) return true; | |
219 if (_matrule->find_type("Return", index)) return true; | |
220 if (_matrule->find_type("Rethrow", index)) return true; | |
221 if (_matrule->find_type("TailCall",index)) return true; | |
222 if (_matrule->find_type("TailJump",index)) return true; | |
223 if (_matrule->find_type("Halt", index)) return true; | |
224 | |
225 return false; | |
226 } | |
227 | |
228 // Recursive check on all operands' match rules in my match rule | |
229 bool InstructForm::is_parm(FormDict &globals) { | |
230 if ( ! _matrule) return false; | |
231 | |
232 int index = 0; | |
233 if (_matrule->find_type("Parm",index)) return true; | |
234 | |
235 return false; | |
236 } | |
237 | |
11002
7fa25f5575c9
8016157: During CTW: C2: assert(!def_outside->member(r)) failed: Use of external LRG overlaps the same LRG defined in this block
adlertz
parents:
10389
diff
changeset
|
238 bool InstructForm::is_ideal_negD() const { |
7fa25f5575c9
8016157: During CTW: C2: assert(!def_outside->member(r)) failed: Use of external LRG overlaps the same LRG defined in this block
adlertz
parents:
10389
diff
changeset
|
239 return (_matrule && _matrule->_rChild && strcmp(_matrule->_rChild->_opType, "NegD") == 0); |
7fa25f5575c9
8016157: During CTW: C2: assert(!def_outside->member(r)) failed: Use of external LRG overlaps the same LRG defined in this block
adlertz
parents:
10389
diff
changeset
|
240 } |
0 | 241 |
242 // Return 'true' if this instruction matches an ideal 'Copy*' node | |
243 int InstructForm::is_ideal_copy() const { | |
244 return _matrule ? _matrule->is_ideal_copy() : 0; | |
245 } | |
246 | |
247 // Return 'true' if this instruction is too complex to rematerialize. | |
248 int InstructForm::is_expensive() const { | |
249 // We can prove it is cheap if it has an empty encoding. | |
250 // This helps with platform-specific nops like ThreadLocal and RoundFloat. | |
251 if (is_empty_encoding()) | |
252 return 0; | |
253 | |
254 if (is_tls_instruction()) | |
255 return 1; | |
256 | |
257 if (_matrule == NULL) return 0; | |
258 | |
259 return _matrule->is_expensive(); | |
260 } | |
261 | |
262 // Has an empty encoding if _size is a constant zero or there | |
263 // are no ins_encode tokens. | |
264 int InstructForm::is_empty_encoding() const { | |
265 if (_insencode != NULL) { | |
266 _insencode->reset(); | |
267 if (_insencode->encode_class_iter() == NULL) { | |
268 return 1; | |
269 } | |
270 } | |
271 if (_size != NULL && strcmp(_size, "0") == 0) { | |
272 return 1; | |
273 } | |
274 return 0; | |
275 } | |
276 | |
277 int InstructForm::is_tls_instruction() const { | |
278 if (_ident != NULL && | |
279 ( ! strcmp( _ident,"tlsLoadP") || | |
280 ! strncmp(_ident,"tlsLoadP_",9)) ) { | |
281 return 1; | |
282 } | |
283 | |
284 if (_matrule != NULL && _insencode != NULL) { | |
285 const char* opType = _matrule->_opType; | |
286 if (strcmp(opType, "Set")==0) | |
287 opType = _matrule->_rChild->_opType; | |
288 if (strcmp(opType,"ThreadLocal")==0) { | |
289 fprintf(stderr, "Warning: ThreadLocal instruction %s should be named 'tlsLoadP_*'\n", | |
290 (_ident == NULL ? "NULL" : _ident)); | |
291 return 1; | |
292 } | |
293 } | |
294 | |
295 return 0; | |
296 } | |
297 | |
298 | |
299 // Return 'true' if this instruction matches an ideal 'If' node | |
300 bool InstructForm::is_ideal_if() const { | |
301 if( _matrule == NULL ) return false; | |
302 | |
303 return _matrule->is_ideal_if(); | |
304 } | |
305 | |
306 // Return 'true' if this instruction matches an ideal 'FastLock' node | |
307 bool InstructForm::is_ideal_fastlock() const { | |
308 if( _matrule == NULL ) return false; | |
309 | |
310 return _matrule->is_ideal_fastlock(); | |
311 } | |
312 | |
313 // Return 'true' if this instruction matches an ideal 'MemBarXXX' node | |
314 bool InstructForm::is_ideal_membar() const { | |
315 if( _matrule == NULL ) return false; | |
316 | |
317 return _matrule->is_ideal_membar(); | |
318 } | |
319 | |
320 // Return 'true' if this instruction matches an ideal 'LoadPC' node | |
321 bool InstructForm::is_ideal_loadPC() const { | |
322 if( _matrule == NULL ) return false; | |
323 | |
324 return _matrule->is_ideal_loadPC(); | |
325 } | |
326 | |
327 // Return 'true' if this instruction matches an ideal 'Box' node | |
328 bool InstructForm::is_ideal_box() const { | |
329 if( _matrule == NULL ) return false; | |
330 | |
331 return _matrule->is_ideal_box(); | |
332 } | |
333 | |
334 // Return 'true' if this instruction matches an ideal 'Goto' node | |
335 bool InstructForm::is_ideal_goto() const { | |
336 if( _matrule == NULL ) return false; | |
337 | |
338 return _matrule->is_ideal_goto(); | |
339 } | |
340 | |
341 // Return 'true' if this instruction matches an ideal 'Jump' node | |
342 bool InstructForm::is_ideal_jump() const { | |
343 if( _matrule == NULL ) return false; | |
344 | |
345 return _matrule->is_ideal_jump(); | |
346 } | |
347 | |
3853
11211f7cb5a0
7079317: Incorrect branch's destination block in PrintoOptoAssembly output
kvn
parents:
3851
diff
changeset
|
348 // Return 'true' if instruction matches ideal 'If' | 'Goto' | 'CountedLoopEnd' |
0 | 349 bool InstructForm::is_ideal_branch() const { |
350 if( _matrule == NULL ) return false; | |
351 | |
3853
11211f7cb5a0
7079317: Incorrect branch's destination block in PrintoOptoAssembly output
kvn
parents:
3851
diff
changeset
|
352 return _matrule->is_ideal_if() || _matrule->is_ideal_goto(); |
0 | 353 } |
354 | |
355 | |
356 // Return 'true' if this instruction matches an ideal 'Return' node | |
357 bool InstructForm::is_ideal_return() const { | |
358 if( _matrule == NULL ) return false; | |
359 | |
360 // Check MatchRule to see if the first entry is the ideal "Return" node | |
361 int index = 0; | |
362 if (_matrule->find_type("Return",index)) return true; | |
363 if (_matrule->find_type("Rethrow",index)) return true; | |
364 if (_matrule->find_type("TailCall",index)) return true; | |
365 if (_matrule->find_type("TailJump",index)) return true; | |
366 | |
367 return false; | |
368 } | |
369 | |
370 // Return 'true' if this instruction matches an ideal 'Halt' node | |
371 bool InstructForm::is_ideal_halt() const { | |
372 int index = 0; | |
373 return _matrule && _matrule->find_type("Halt",index); | |
374 } | |
375 | |
376 // Return 'true' if this instruction matches an ideal 'SafePoint' node | |
377 bool InstructForm::is_ideal_safepoint() const { | |
378 int index = 0; | |
379 return _matrule && _matrule->find_type("SafePoint",index); | |
380 } | |
381 | |
382 // Return 'true' if this instruction matches an ideal 'Nop' node | |
383 bool InstructForm::is_ideal_nop() const { | |
384 return _ident && _ident[0] == 'N' && _ident[1] == 'o' && _ident[2] == 'p' && _ident[3] == '_'; | |
385 } | |
386 | |
387 bool InstructForm::is_ideal_control() const { | |
388 if ( ! _matrule) return false; | |
389 | |
3853
11211f7cb5a0
7079317: Incorrect branch's destination block in PrintoOptoAssembly output
kvn
parents:
3851
diff
changeset
|
390 return is_ideal_return() || is_ideal_branch() || _matrule->is_ideal_jump() || is_ideal_halt(); |
0 | 391 } |
392 | |
393 // Return 'true' if this instruction matches an ideal 'Call' node | |
394 Form::CallType InstructForm::is_ideal_call() const { | |
395 if( _matrule == NULL ) return Form::invalid_type; | |
396 | |
397 // Check MatchRule to see if the first entry is the ideal "Call" node | |
398 int idx = 0; | |
399 if(_matrule->find_type("CallStaticJava",idx)) return Form::JAVA_STATIC; | |
400 idx = 0; | |
401 if(_matrule->find_type("Lock",idx)) return Form::JAVA_STATIC; | |
402 idx = 0; | |
403 if(_matrule->find_type("Unlock",idx)) return Form::JAVA_STATIC; | |
404 idx = 0; | |
405 if(_matrule->find_type("CallDynamicJava",idx)) return Form::JAVA_DYNAMIC; | |
406 idx = 0; | |
407 if(_matrule->find_type("CallRuntime",idx)) return Form::JAVA_RUNTIME; | |
408 idx = 0; | |
409 if(_matrule->find_type("CallLeaf",idx)) return Form::JAVA_LEAF; | |
410 idx = 0; | |
411 if(_matrule->find_type("CallLeafNoFP",idx)) return Form::JAVA_LEAF; | |
412 idx = 0; | |
413 | |
414 return Form::invalid_type; | |
415 } | |
416 | |
417 // Return 'true' if this instruction matches an ideal 'Load?' node | |
418 Form::DataType InstructForm::is_ideal_load() const { | |
419 if( _matrule == NULL ) return Form::none; | |
420 | |
421 return _matrule->is_ideal_load(); | |
422 } | |
423 | |
855
f9094a5e1c8a
6857159: local schedule failed with checkcast of Thread.currentThread()
never
parents:
681
diff
changeset
|
424 // Return 'true' if this instruction matches an ideal 'LoadKlass' node |
f9094a5e1c8a
6857159: local schedule failed with checkcast of Thread.currentThread()
never
parents:
681
diff
changeset
|
425 bool InstructForm::skip_antidep_check() const { |
f9094a5e1c8a
6857159: local schedule failed with checkcast of Thread.currentThread()
never
parents:
681
diff
changeset
|
426 if( _matrule == NULL ) return false; |
f9094a5e1c8a
6857159: local schedule failed with checkcast of Thread.currentThread()
never
parents:
681
diff
changeset
|
427 |
f9094a5e1c8a
6857159: local schedule failed with checkcast of Thread.currentThread()
never
parents:
681
diff
changeset
|
428 return _matrule->skip_antidep_check(); |
f9094a5e1c8a
6857159: local schedule failed with checkcast of Thread.currentThread()
never
parents:
681
diff
changeset
|
429 } |
f9094a5e1c8a
6857159: local schedule failed with checkcast of Thread.currentThread()
never
parents:
681
diff
changeset
|
430 |
0 | 431 // Return 'true' if this instruction matches an ideal 'Load?' node |
432 Form::DataType InstructForm::is_ideal_store() const { | |
433 if( _matrule == NULL ) return Form::none; | |
434 | |
435 return _matrule->is_ideal_store(); | |
436 } | |
437 | |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6143
diff
changeset
|
438 // Return 'true' if this instruction matches an ideal vector node |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6143
diff
changeset
|
439 bool InstructForm::is_vector() const { |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6143
diff
changeset
|
440 if( _matrule == NULL ) return false; |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6143
diff
changeset
|
441 |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6143
diff
changeset
|
442 return _matrule->is_vector(); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6143
diff
changeset
|
443 } |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6143
diff
changeset
|
444 |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6143
diff
changeset
|
445 |
0 | 446 // Return the input register that must match the output register |
447 // If this is not required, return 0 | |
448 uint InstructForm::two_address(FormDict &globals) { | |
449 uint matching_input = 0; | |
450 if(_components.count() == 0) return 0; | |
451 | |
452 _components.reset(); | |
453 Component *comp = _components.iter(); | |
454 // Check if there is a DEF | |
455 if( comp->isa(Component::DEF) ) { | |
456 // Check that this is a register | |
457 const char *def_type = comp->_type; | |
458 const Form *form = globals[def_type]; | |
459 OperandForm *op = form->is_operand(); | |
460 if( op ) { | |
461 if( op->constrained_reg_class() != NULL && | |
462 op->interface_type(globals) == Form::register_interface ) { | |
463 // Remember the local name for equality test later | |
464 const char *def_name = comp->_name; | |
465 // Check if a component has the same name and is a USE | |
466 do { | |
467 if( comp->isa(Component::USE) && strcmp(comp->_name,def_name)==0 ) { | |
468 return operand_position_format(def_name); | |
469 } | |
470 } while( (comp = _components.iter()) != NULL); | |
471 } | |
472 } | |
473 } | |
474 | |
475 return 0; | |
476 } | |
477 | |
478 | |
479 // when chaining a constant to an instruction, returns 'true' and sets opType | |
480 Form::DataType InstructForm::is_chain_of_constant(FormDict &globals) { | |
481 const char *dummy = NULL; | |
482 const char *dummy2 = NULL; | |
483 return is_chain_of_constant(globals, dummy, dummy2); | |
484 } | |
485 Form::DataType InstructForm::is_chain_of_constant(FormDict &globals, | |
486 const char * &opTypeParam) { | |
487 const char *result = NULL; | |
488 | |
489 return is_chain_of_constant(globals, opTypeParam, result); | |
490 } | |
491 | |
492 Form::DataType InstructForm::is_chain_of_constant(FormDict &globals, | |
493 const char * &opTypeParam, const char * &resultParam) { | |
494 Form::DataType data_type = Form::none; | |
495 if ( ! _matrule) return data_type; | |
496 | |
497 // !!!!! | |
498 // The source of the chain rule is 'position = 1' | |
499 uint position = 1; | |
500 const char *result = NULL; | |
501 const char *name = NULL; | |
502 const char *opType = NULL; | |
503 // Here base_operand is looking for an ideal type to be returned (opType). | |
504 if ( _matrule->is_chain_rule(globals) | |
505 && _matrule->base_operand(position, globals, result, name, opType) ) { | |
506 data_type = ideal_to_const_type(opType); | |
507 | |
508 // if it isn't an ideal constant type, just return | |
509 if ( data_type == Form::none ) return data_type; | |
510 | |
511 // Ideal constant types also adjust the opType parameter. | |
512 resultParam = result; | |
513 opTypeParam = opType; | |
514 return data_type; | |
515 } | |
516 | |
517 return data_type; | |
518 } | |
519 | |
520 // Check if a simple chain rule | |
521 bool InstructForm::is_simple_chain_rule(FormDict &globals) const { | |
522 if( _matrule && _matrule->sets_result() | |
523 && _matrule->_rChild->_lChild == NULL | |
524 && globals[_matrule->_rChild->_opType] | |
525 && globals[_matrule->_rChild->_opType]->is_opclass() ) { | |
526 return true; | |
527 } | |
528 return false; | |
529 } | |
530 | |
531 // check for structural rematerialization | |
532 bool InstructForm::rematerialize(FormDict &globals, RegisterForm *registers ) { | |
533 bool rematerialize = false; | |
534 | |
535 Form::DataType data_type = is_chain_of_constant(globals); | |
536 if( data_type != Form::none ) | |
537 rematerialize = true; | |
538 | |
11002
7fa25f5575c9
8016157: During CTW: C2: assert(!def_outside->member(r)) failed: Use of external LRG overlaps the same LRG defined in this block
adlertz
parents:
10389
diff
changeset
|
539 // Ugly: until a better fix is implemented, disable rematerialization for |
7fa25f5575c9
8016157: During CTW: C2: assert(!def_outside->member(r)) failed: Use of external LRG overlaps the same LRG defined in this block
adlertz
parents:
10389
diff
changeset
|
540 // negD nodes because they are proved to be problematic. |
7fa25f5575c9
8016157: During CTW: C2: assert(!def_outside->member(r)) failed: Use of external LRG overlaps the same LRG defined in this block
adlertz
parents:
10389
diff
changeset
|
541 if (is_ideal_negD()) { |
7fa25f5575c9
8016157: During CTW: C2: assert(!def_outside->member(r)) failed: Use of external LRG overlaps the same LRG defined in this block
adlertz
parents:
10389
diff
changeset
|
542 return false; |
7fa25f5575c9
8016157: During CTW: C2: assert(!def_outside->member(r)) failed: Use of external LRG overlaps the same LRG defined in this block
adlertz
parents:
10389
diff
changeset
|
543 } |
7fa25f5575c9
8016157: During CTW: C2: assert(!def_outside->member(r)) failed: Use of external LRG overlaps the same LRG defined in this block
adlertz
parents:
10389
diff
changeset
|
544 |
0 | 545 // Constants |
546 if( _components.count() == 1 && _components[0]->is(Component::USE_DEF) ) | |
547 rematerialize = true; | |
548 | |
549 // Pseudo-constants (values easily available to the runtime) | |
550 if (is_empty_encoding() && is_tls_instruction()) | |
551 rematerialize = true; | |
552 | |
553 // 1-input, 1-output, such as copies or increments. | |
554 if( _components.count() == 2 && | |
555 _components[0]->is(Component::DEF) && | |
556 _components[1]->isa(Component::USE) ) | |
557 rematerialize = true; | |
558 | |
559 // Check for an ideal 'Load?' and eliminate rematerialize option | |
560 if ( is_ideal_load() != Form::none || // Ideal load? Do not rematerialize | |
561 is_ideal_copy() != Form::none || // Ideal copy? Do not rematerialize | |
562 is_expensive() != Form::none) { // Expensive? Do not rematerialize | |
563 rematerialize = false; | |
564 } | |
565 | |
566 // Always rematerialize the flags. They are more expensive to save & | |
567 // restore than to recompute (and possibly spill the compare's inputs). | |
568 if( _components.count() >= 1 ) { | |
569 Component *c = _components[0]; | |
570 const Form *form = globals[c->_type]; | |
571 OperandForm *opform = form->is_operand(); | |
572 if( opform ) { | |
573 // Avoid the special stack_slots register classes | |
574 const char *rc_name = opform->constrained_reg_class(); | |
575 if( rc_name ) { | |
576 if( strcmp(rc_name,"stack_slots") ) { | |
577 // Check for ideal_type of RegFlags | |
578 const char *type = opform->ideal_type( globals, registers ); | |
6850 | 579 if( (type != NULL) && !strcmp(type, "RegFlags") ) |
0 | 580 rematerialize = true; |
581 } else | |
582 rematerialize = false; // Do not rematerialize things target stk | |
583 } | |
584 } | |
585 } | |
586 | |
587 return rematerialize; | |
588 } | |
589 | |
590 // loads from memory, so must check for anti-dependence | |
591 bool InstructForm::needs_anti_dependence_check(FormDict &globals) const { | |
855
f9094a5e1c8a
6857159: local schedule failed with checkcast of Thread.currentThread()
never
parents:
681
diff
changeset
|
592 if ( skip_antidep_check() ) return false; |
f9094a5e1c8a
6857159: local schedule failed with checkcast of Thread.currentThread()
never
parents:
681
diff
changeset
|
593 |
0 | 594 // Machine independent loads must be checked for anti-dependences |
595 if( is_ideal_load() != Form::none ) return true; | |
596 | |
597 // !!!!! !!!!! !!!!! | |
598 // TEMPORARY | |
599 // if( is_simple_chain_rule(globals) ) return false; | |
600 | |
681 | 601 // String.(compareTo/equals/indexOf) and Arrays.equals use many memorys edges, |
602 // but writes none | |
0 | 603 if( _matrule && _matrule->_rChild && |
681 | 604 ( strcmp(_matrule->_rChild->_opType,"StrComp" )==0 || |
605 strcmp(_matrule->_rChild->_opType,"StrEquals" )==0 || | |
606 strcmp(_matrule->_rChild->_opType,"StrIndexOf" )==0 || | |
607 strcmp(_matrule->_rChild->_opType,"AryEq" )==0 )) | |
0 | 608 return true; |
609 | |
610 // Check if instruction has a USE of a memory operand class, but no defs | |
611 bool USE_of_memory = false; | |
612 bool DEF_of_memory = false; | |
613 Component *comp = NULL; | |
614 ComponentList &components = (ComponentList &)_components; | |
615 | |
616 components.reset(); | |
617 while( (comp = components.iter()) != NULL ) { | |
618 const Form *form = globals[comp->_type]; | |
619 if( !form ) continue; | |
620 OpClassForm *op = form->is_opclass(); | |
621 if( !op ) continue; | |
622 if( form->interface_type(globals) == Form::memory_interface ) { | |
623 if( comp->isa(Component::USE) ) USE_of_memory = true; | |
624 if( comp->isa(Component::DEF) ) { | |
625 OperandForm *oper = form->is_operand(); | |
626 if( oper && oper->is_user_name_for_sReg() ) { | |
627 // Stack slots are unaliased memory handled by allocator | |
628 oper = oper; // debug stopping point !!!!! | |
629 } else { | |
630 DEF_of_memory = true; | |
631 } | |
632 } | |
633 } | |
634 } | |
635 return (USE_of_memory && !DEF_of_memory); | |
636 } | |
637 | |
638 | |
639 bool InstructForm::is_wide_memory_kill(FormDict &globals) const { | |
640 if( _matrule == NULL ) return false; | |
641 if( !_matrule->_opType ) return false; | |
642 | |
643 if( strcmp(_matrule->_opType,"MemBarRelease") == 0 ) return true; | |
644 if( strcmp(_matrule->_opType,"MemBarAcquire") == 0 ) return true; | |
3849
f1c12354c3f7
7074017: Introduce MemBarAcquireLock/MemBarReleaseLock nodes for monitor enter/exit code paths
roland
parents:
3842
diff
changeset
|
645 if( strcmp(_matrule->_opType,"MemBarReleaseLock") == 0 ) return true; |
f1c12354c3f7
7074017: Introduce MemBarAcquireLock/MemBarReleaseLock nodes for monitor enter/exit code paths
roland
parents:
3842
diff
changeset
|
646 if( strcmp(_matrule->_opType,"MemBarAcquireLock") == 0 ) return true; |
4763
1dc233a8c7fe
7121140: Allocation paths require explicit memory synchronization operations for RMO systems
roland
parents:
4120
diff
changeset
|
647 if( strcmp(_matrule->_opType,"MemBarStoreStore") == 0 ) return true; |
0 | 648 |
649 return false; | |
650 } | |
651 | |
652 int InstructForm::memory_operand(FormDict &globals) const { | |
653 // Machine independent loads must be checked for anti-dependences | |
654 // Check if instruction has a USE of a memory operand class, or a def. | |
655 int USE_of_memory = 0; | |
656 int DEF_of_memory = 0; | |
657 const char* last_memory_DEF = NULL; // to test DEF/USE pairing in asserts | |
658 Component *unique = NULL; | |
659 Component *comp = NULL; | |
660 ComponentList &components = (ComponentList &)_components; | |
661 | |
662 components.reset(); | |
663 while( (comp = components.iter()) != NULL ) { | |
664 const Form *form = globals[comp->_type]; | |
665 if( !form ) continue; | |
666 OpClassForm *op = form->is_opclass(); | |
667 if( !op ) continue; | |
668 if( op->stack_slots_only(globals) ) continue; | |
669 if( form->interface_type(globals) == Form::memory_interface ) { | |
670 if( comp->isa(Component::DEF) ) { | |
671 last_memory_DEF = comp->_name; | |
672 DEF_of_memory++; | |
673 unique = comp; | |
674 } else if( comp->isa(Component::USE) ) { | |
675 if( last_memory_DEF != NULL ) { | |
676 assert(0 == strcmp(last_memory_DEF, comp->_name), "every memory DEF is followed by a USE of the same name"); | |
677 last_memory_DEF = NULL; | |
678 } | |
679 USE_of_memory++; | |
680 if (DEF_of_memory == 0) // defs take precedence | |
681 unique = comp; | |
682 } else { | |
683 assert(last_memory_DEF == NULL, "unpaired memory DEF"); | |
684 } | |
685 } | |
686 } | |
687 assert(last_memory_DEF == NULL, "unpaired memory DEF"); | |
688 assert(USE_of_memory >= DEF_of_memory, "unpaired memory DEF"); | |
689 USE_of_memory -= DEF_of_memory; // treat paired DEF/USE as one occurrence | |
690 if( (USE_of_memory + DEF_of_memory) > 0 ) { | |
691 if( is_simple_chain_rule(globals) ) { | |
692 //fprintf(stderr, "Warning: chain rule is not really a memory user.\n"); | |
693 //((InstructForm*)this)->dump(); | |
694 // Preceding code prints nothing on sparc and these insns on intel: | |
695 // leaP8 leaP32 leaPIdxOff leaPIdxScale leaPIdxScaleOff leaP8 leaP32 | |
696 // leaPIdxOff leaPIdxScale leaPIdxScaleOff | |
697 return NO_MEMORY_OPERAND; | |
698 } | |
699 | |
700 if( DEF_of_memory == 1 ) { | |
701 assert(unique != NULL, ""); | |
702 if( USE_of_memory == 0 ) { | |
703 // unique def, no uses | |
704 } else { | |
705 // // unique def, some uses | |
706 // // must return bottom unless all uses match def | |
707 // unique = NULL; | |
708 } | |
709 } else if( DEF_of_memory > 0 ) { | |
710 // multiple defs, don't care about uses | |
711 unique = NULL; | |
712 } else if( USE_of_memory == 1) { | |
713 // unique use, no defs | |
714 assert(unique != NULL, ""); | |
715 } else if( USE_of_memory > 0 ) { | |
716 // multiple uses, no defs | |
717 unique = NULL; | |
718 } else { | |
719 assert(false, "bad case analysis"); | |
720 } | |
721 // process the unique DEF or USE, if there is one | |
722 if( unique == NULL ) { | |
723 return MANY_MEMORY_OPERANDS; | |
724 } else { | |
725 int pos = components.operand_position(unique->_name); | |
726 if( unique->isa(Component::DEF) ) { | |
727 pos += 1; // get corresponding USE from DEF | |
728 } | |
729 assert(pos >= 1, "I was just looking at it!"); | |
730 return pos; | |
731 } | |
732 } | |
733 | |
734 // missed the memory op?? | |
735 if( true ) { // %%% should not be necessary | |
736 if( is_ideal_store() != Form::none ) { | |
737 fprintf(stderr, "Warning: cannot find memory opnd in instr.\n"); | |
738 ((InstructForm*)this)->dump(); | |
739 // pretend it has multiple defs and uses | |
740 return MANY_MEMORY_OPERANDS; | |
741 } | |
742 if( is_ideal_load() != Form::none ) { | |
743 fprintf(stderr, "Warning: cannot find memory opnd in instr.\n"); | |
744 ((InstructForm*)this)->dump(); | |
745 // pretend it has multiple uses and no defs | |
746 return MANY_MEMORY_OPERANDS; | |
747 } | |
748 } | |
749 | |
750 return NO_MEMORY_OPERAND; | |
751 } | |
752 | |
753 | |
754 // This instruction captures the machine-independent bottom_type | |
755 // Expected use is for pointer vs oop determination for LoadP | |
1541
b5fdf39b9749
6953576: bottom_type for matched AddPNodes doesn't always agree with ideal
never
parents:
1396
diff
changeset
|
756 bool InstructForm::captures_bottom_type(FormDict &globals) const { |
0 | 757 if( _matrule && _matrule->_rChild && |
6848
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6823
diff
changeset
|
758 (!strcmp(_matrule->_rChild->_opType,"CastPP") || // new result type |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6823
diff
changeset
|
759 !strcmp(_matrule->_rChild->_opType,"CastX2P") || // new result type |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6823
diff
changeset
|
760 !strcmp(_matrule->_rChild->_opType,"DecodeN") || |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6823
diff
changeset
|
761 !strcmp(_matrule->_rChild->_opType,"EncodeP") || |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6823
diff
changeset
|
762 !strcmp(_matrule->_rChild->_opType,"DecodeNKlass") || |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6823
diff
changeset
|
763 !strcmp(_matrule->_rChild->_opType,"EncodePKlass") || |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6823
diff
changeset
|
764 !strcmp(_matrule->_rChild->_opType,"LoadN") || |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6823
diff
changeset
|
765 !strcmp(_matrule->_rChild->_opType,"LoadNKlass") || |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6823
diff
changeset
|
766 !strcmp(_matrule->_rChild->_opType,"CreateEx") || // type of exception |
8117
706c919d3b56
8007722: C2: "assert(tp->base() != Type::AnyPtr) failed: not a bare pointer" at machnode.cpp:376
roland
parents:
7637
diff
changeset
|
767 !strcmp(_matrule->_rChild->_opType,"CheckCastPP") || |
706c919d3b56
8007722: C2: "assert(tp->base() != Type::AnyPtr) failed: not a bare pointer" at machnode.cpp:376
roland
parents:
7637
diff
changeset
|
768 !strcmp(_matrule->_rChild->_opType,"GetAndSetP") || |
706c919d3b56
8007722: C2: "assert(tp->base() != Type::AnyPtr) failed: not a bare pointer" at machnode.cpp:376
roland
parents:
7637
diff
changeset
|
769 !strcmp(_matrule->_rChild->_opType,"GetAndSetN")) ) return true; |
0 | 770 else if ( is_ideal_load() == Form::idealP ) return true; |
771 else if ( is_ideal_store() != Form::none ) return true; | |
772 | |
1541
b5fdf39b9749
6953576: bottom_type for matched AddPNodes doesn't always agree with ideal
never
parents:
1396
diff
changeset
|
773 if (needs_base_oop_edge(globals)) return true; |
b5fdf39b9749
6953576: bottom_type for matched AddPNodes doesn't always agree with ideal
never
parents:
1396
diff
changeset
|
774 |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6143
diff
changeset
|
775 if (is_vector()) return true; |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6143
diff
changeset
|
776 if (is_mach_constant()) return true; |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6143
diff
changeset
|
777 |
0 | 778 return false; |
779 } | |
780 | |
781 | |
782 // Access instr_cost attribute or return NULL. | |
783 const char* InstructForm::cost() { | |
784 for (Attribute* cur = _attribs; cur != NULL; cur = (Attribute*)cur->_next) { | |
785 if( strcmp(cur->_ident,AttributeForm::_ins_cost) == 0 ) { | |
786 return cur->_val; | |
787 } | |
788 } | |
789 return NULL; | |
790 } | |
791 | |
792 // Return count of top-level operands. | |
793 uint InstructForm::num_opnds() { | |
794 int num_opnds = _components.num_operands(); | |
795 | |
796 // Need special handling for matching some ideal nodes | |
797 // i.e. Matching a return node | |
798 /* | |
799 if( _matrule ) { | |
800 if( strcmp(_matrule->_opType,"Return" )==0 || | |
801 strcmp(_matrule->_opType,"Halt" )==0 ) | |
802 return 3; | |
803 } | |
804 */ | |
805 return num_opnds; | |
806 } | |
807 | |
10389 | 808 const char* InstructForm::opnd_ident(int idx) { |
6850 | 809 return _components.at(idx)->_name; |
810 } | |
811 | |
10389 | 812 const char* InstructForm::unique_opnd_ident(uint idx) { |
6850 | 813 uint i; |
814 for (i = 1; i < num_opnds(); ++i) { | |
815 if (unique_opnds_idx(i) == idx) { | |
816 break; | |
817 } | |
818 } | |
819 return (_components.at(i) != NULL) ? _components.at(i)->_name : ""; | |
820 } | |
821 | |
0 | 822 // Return count of unmatched operands. |
823 uint InstructForm::num_post_match_opnds() { | |
824 uint num_post_match_opnds = _components.count(); | |
825 uint num_match_opnds = _components.match_count(); | |
826 num_post_match_opnds = num_post_match_opnds - num_match_opnds; | |
827 | |
828 return num_post_match_opnds; | |
829 } | |
830 | |
831 // Return the number of leaves below this complex operand | |
832 uint InstructForm::num_consts(FormDict &globals) const { | |
833 if ( ! _matrule) return 0; | |
834 | |
835 // This is a recursive invocation on all operands in the matchrule | |
836 return _matrule->num_consts(globals); | |
837 } | |
838 | |
839 // Constants in match rule with specified type | |
840 uint InstructForm::num_consts(FormDict &globals, Form::DataType type) const { | |
841 if ( ! _matrule) return 0; | |
842 | |
843 // This is a recursive invocation on all operands in the matchrule | |
844 return _matrule->num_consts(globals, type); | |
845 } | |
846 | |
847 | |
848 // Return the register class associated with 'leaf'. | |
849 const char *InstructForm::out_reg_class(FormDict &globals) { | |
850 assert( false, "InstructForm::out_reg_class(FormDict &globals); Not Implemented"); | |
851 | |
852 return NULL; | |
853 } | |
854 | |
855 | |
856 | |
857 // Lookup the starting position of inputs we are interested in wrt. ideal nodes | |
858 uint InstructForm::oper_input_base(FormDict &globals) { | |
859 if( !_matrule ) return 1; // Skip control for most nodes | |
860 | |
861 // Need special handling for matching some ideal nodes | |
862 // i.e. Matching a return node | |
863 if( strcmp(_matrule->_opType,"Return" )==0 || | |
864 strcmp(_matrule->_opType,"Rethrow" )==0 || | |
865 strcmp(_matrule->_opType,"TailCall" )==0 || | |
866 strcmp(_matrule->_opType,"TailJump" )==0 || | |
867 strcmp(_matrule->_opType,"SafePoint" )==0 || | |
868 strcmp(_matrule->_opType,"Halt" )==0 ) | |
869 return AdlcVMDeps::Parms; // Skip the machine-state edges | |
870 | |
871 if( _matrule->_rChild && | |
986
62001a362ce9
6827605: new String intrinsics may prevent EA scalar replacement
kvn
parents:
855
diff
changeset
|
872 ( strcmp(_matrule->_rChild->_opType,"AryEq" )==0 || |
62001a362ce9
6827605: new String intrinsics may prevent EA scalar replacement
kvn
parents:
855
diff
changeset
|
873 strcmp(_matrule->_rChild->_opType,"StrComp" )==0 || |
681 | 874 strcmp(_matrule->_rChild->_opType,"StrEquals" )==0 || |
7637
b30b3c2a0cf2
6896617: Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() on x86
kvn
parents:
6850
diff
changeset
|
875 strcmp(_matrule->_rChild->_opType,"StrIndexOf")==0 || |
b30b3c2a0cf2
6896617: Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() on x86
kvn
parents:
6850
diff
changeset
|
876 strcmp(_matrule->_rChild->_opType,"EncodeISOArray")==0)) { |
986
62001a362ce9
6827605: new String intrinsics may prevent EA scalar replacement
kvn
parents:
855
diff
changeset
|
877 // String.(compareTo/equals/indexOf) and Arrays.equals |
7637
b30b3c2a0cf2
6896617: Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() on x86
kvn
parents:
6850
diff
changeset
|
878 // and sun.nio.cs.iso8859_1$Encoder.EncodeISOArray |
986
62001a362ce9
6827605: new String intrinsics may prevent EA scalar replacement
kvn
parents:
855
diff
changeset
|
879 // take 1 control and 1 memory edges. |
62001a362ce9
6827605: new String intrinsics may prevent EA scalar replacement
kvn
parents:
855
diff
changeset
|
880 return 2; |
0 | 881 } |
882 | |
883 // Check for handling of 'Memory' input/edge in the ideal world. | |
884 // The AD file writer is shielded from knowledge of these edges. | |
885 int base = 1; // Skip control | |
886 base += _matrule->needs_ideal_memory_edge(globals); | |
887 | |
888 // Also skip the base-oop value for uses of derived oops. | |
889 // The AD file writer is shielded from knowledge of these edges. | |
890 base += needs_base_oop_edge(globals); | |
891 | |
892 return base; | |
893 } | |
894 | |
6850 | 895 // This function determines the order of the MachOper in _opnds[] |
896 // by writing the operand names into the _components list. | |
897 // | |
0 | 898 // Implementation does not modify state of internal structures |
899 void InstructForm::build_components() { | |
900 // Add top-level operands to the components | |
901 if (_matrule) _matrule->append_components(_localNames, _components); | |
902 | |
903 // Add parameters that "do not appear in match rule". | |
904 bool has_temp = false; | |
905 const char *name; | |
906 const char *kill_name = NULL; | |
907 for (_parameters.reset(); (name = _parameters.iter()) != NULL;) { | |
908 OperandForm *opForm = (OperandForm*)_localNames[name]; | |
909 | |
603
dbbe28fc66b5
6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents:
602
diff
changeset
|
910 Effect* e = NULL; |
dbbe28fc66b5
6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents:
602
diff
changeset
|
911 { |
dbbe28fc66b5
6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents:
602
diff
changeset
|
912 const Form* form = _effects[name]; |
dbbe28fc66b5
6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents:
602
diff
changeset
|
913 e = form ? form->is_effect() : NULL; |
dbbe28fc66b5
6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents:
602
diff
changeset
|
914 } |
dbbe28fc66b5
6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents:
602
diff
changeset
|
915 |
0 | 916 if (e != NULL) { |
917 has_temp |= e->is(Component::TEMP); | |
918 | |
919 // KILLs must be declared after any TEMPs because TEMPs are real | |
920 // uses so their operand numbering must directly follow the real | |
921 // inputs from the match rule. Fixing the numbering seems | |
922 // complex so simply enforce the restriction during parse. | |
923 if (kill_name != NULL && | |
924 e->isa(Component::TEMP) && !e->isa(Component::DEF)) { | |
925 OperandForm* kill = (OperandForm*)_localNames[kill_name]; | |
926 globalAD->syntax_err(_linenum, "%s: %s %s must be at the end of the argument list\n", | |
927 _ident, kill->_ident, kill_name); | |
602
ed6404fac86b
6810855: KILL vs. TEMP ordering restrictions are too strong
never
parents:
599
diff
changeset
|
928 } else if (e->isa(Component::KILL) && !e->isa(Component::USE)) { |
0 | 929 kill_name = name; |
930 } | |
931 } | |
932 | |
933 const Component *component = _components.search(name); | |
934 if ( component == NULL ) { | |
935 if (e) { | |
936 _components.insert(name, opForm->_ident, e->_use_def, false); | |
937 component = _components.search(name); | |
938 if (component->isa(Component::USE) && !component->isa(Component::TEMP) && _matrule) { | |
939 const Form *form = globalAD->globalNames()[component->_type]; | |
940 assert( form, "component type must be a defined form"); | |
941 OperandForm *op = form->is_operand(); | |
942 if (op->_interface && op->_interface->is_RegInterface()) { | |
943 globalAD->syntax_err(_linenum, "%s: illegal USE of non-input: %s %s\n", | |
944 _ident, opForm->_ident, name); | |
945 } | |
946 } | |
947 } else { | |
948 // This would be a nice warning but it triggers in a few places in a benign way | |
949 // if (_matrule != NULL && !expands()) { | |
950 // globalAD->syntax_err(_linenum, "%s: %s %s not mentioned in effect or match rule\n", | |
951 // _ident, opForm->_ident, name); | |
952 // } | |
953 _components.insert(name, opForm->_ident, Component::INVALID, false); | |
954 } | |
955 } | |
956 else if (e) { | |
957 // Component was found in the list | |
958 // Check if there is a new effect that requires an extra component. | |
959 // This happens when adding 'USE' to a component that is not yet one. | |
960 if ((!component->isa( Component::USE) && ((e->_use_def & Component::USE) != 0))) { | |
961 if (component->isa(Component::USE) && _matrule) { | |
962 const Form *form = globalAD->globalNames()[component->_type]; | |
963 assert( form, "component type must be a defined form"); | |
964 OperandForm *op = form->is_operand(); | |
965 if (op->_interface && op->_interface->is_RegInterface()) { | |
966 globalAD->syntax_err(_linenum, "%s: illegal USE of non-input: %s %s\n", | |
967 _ident, opForm->_ident, name); | |
968 } | |
969 } | |
970 _components.insert(name, opForm->_ident, e->_use_def, false); | |
971 } else { | |
972 Component *comp = (Component*)component; | |
973 comp->promote_use_def_info(e->_use_def); | |
974 } | |
975 // Component positions are zero based. | |
976 int pos = _components.operand_position(name); | |
977 assert( ! (component->isa(Component::DEF) && (pos >= 1)), | |
978 "Component::DEF can only occur in the first position"); | |
979 } | |
980 } | |
981 | |
982 // Resolving the interactions between expand rules and TEMPs would | |
983 // be complex so simply disallow it. | |
984 if (_matrule == NULL && has_temp) { | |
985 globalAD->syntax_err(_linenum, "%s: TEMPs without match rule isn't supported\n", _ident); | |
986 } | |
987 | |
988 return; | |
989 } | |
990 | |
991 // Return zero-based position in component list; -1 if not in list. | |
992 int InstructForm::operand_position(const char *name, int usedef) { | |
6850 | 993 return unique_opnds_idx(_components.operand_position(name, usedef, this)); |
0 | 994 } |
995 | |
996 int InstructForm::operand_position_format(const char *name) { | |
6850 | 997 return unique_opnds_idx(_components.operand_position_format(name, this)); |
0 | 998 } |
999 | |
1000 // Return zero-based position in component list; -1 if not in list. | |
1001 int InstructForm::label_position() { | |
1002 return unique_opnds_idx(_components.label_position()); | |
1003 } | |
1004 | |
1005 int InstructForm::method_position() { | |
1006 return unique_opnds_idx(_components.method_position()); | |
1007 } | |
1008 | |
1009 // Return number of relocation entries needed for this instruction. | |
1010 uint InstructForm::reloc(FormDict &globals) { | |
1011 uint reloc_entries = 0; | |
1012 // Check for "Call" nodes | |
1013 if ( is_ideal_call() ) ++reloc_entries; | |
1014 if ( is_ideal_return() ) ++reloc_entries; | |
1015 if ( is_ideal_safepoint() ) ++reloc_entries; | |
1016 | |
1017 | |
1018 // Check if operands MAYBE oop pointers, by checking for ConP elements | |
1019 // Proceed through the leaves of the match-tree and check for ConPs | |
1020 if ( _matrule != NULL ) { | |
1021 uint position = 0; | |
1022 const char *result = NULL; | |
1023 const char *name = NULL; | |
1024 const char *opType = NULL; | |
1025 while (_matrule->base_operand(position, globals, result, name, opType)) { | |
1026 if ( strcmp(opType,"ConP") == 0 ) { | |
1027 #ifdef SPARC | |
1028 reloc_entries += 2; // 1 for sethi + 1 for setlo | |
1029 #else | |
1030 ++reloc_entries; | |
1031 #endif | |
1032 } | |
1033 ++position; | |
1034 } | |
1035 } | |
1036 | |
1037 // Above is only a conservative estimate | |
1038 // because it did not check contents of operand classes. | |
1039 // !!!!! !!!!! | |
1040 // Add 1 to reloc info for each operand class in the component list. | |
1041 Component *comp; | |
1042 _components.reset(); | |
1043 while ( (comp = _components.iter()) != NULL ) { | |
1044 const Form *form = globals[comp->_type]; | |
1045 assert( form, "Did not find component's type in global names"); | |
1046 const OpClassForm *opc = form->is_opclass(); | |
1047 const OperandForm *oper = form->is_operand(); | |
1048 if ( opc && (oper == NULL) ) { | |
1049 ++reloc_entries; | |
1050 } else if ( oper ) { | |
1051 // floats and doubles loaded out of method's constant pool require reloc info | |
1052 Form::DataType type = oper->is_base_constant(globals); | |
1053 if ( (type == Form::idealF) || (type == Form::idealD) ) { | |
1054 ++reloc_entries; | |
1055 } | |
1056 } | |
1057 } | |
1058 | |
1059 // Float and Double constants may come from the CodeBuffer table | |
1060 // and require relocatable addresses for access | |
1061 // !!!!! | |
1062 // Check for any component being an immediate float or double. | |
1063 Form::DataType data_type = is_chain_of_constant(globals); | |
1064 if( data_type==idealD || data_type==idealF ) { | |
1065 #ifdef SPARC | |
1066 // sparc required more relocation entries for floating constants | |
1067 // (expires 9/98) | |
1068 reloc_entries += 6; | |
1069 #else | |
1070 reloc_entries++; | |
1071 #endif | |
1072 } | |
1073 | |
1074 return reloc_entries; | |
1075 } | |
1076 | |
1077 // Utility function defined in archDesc.cpp | |
1078 extern bool is_def(int usedef); | |
1079 | |
1080 // Return the result of reducing an instruction | |
1081 const char *InstructForm::reduce_result() { | |
1082 const char* result = "Universe"; // default | |
1083 _components.reset(); | |
1084 Component *comp = _components.iter(); | |
1085 if (comp != NULL && comp->isa(Component::DEF)) { | |
1086 result = comp->_type; | |
1087 // Override this if the rule is a store operation: | |
1088 if (_matrule && _matrule->_rChild && | |
1089 is_store_to_memory(_matrule->_rChild->_opType)) | |
1090 result = "Universe"; | |
1091 } | |
1092 return result; | |
1093 } | |
1094 | |
1095 // Return the name of the operand on the right hand side of the binary match | |
1096 // Return NULL if there is no right hand side | |
1097 const char *InstructForm::reduce_right(FormDict &globals) const { | |
1098 if( _matrule == NULL ) return NULL; | |
1099 return _matrule->reduce_right(globals); | |
1100 } | |
1101 | |
1102 // Similar for left | |
1103 const char *InstructForm::reduce_left(FormDict &globals) const { | |
1104 if( _matrule == NULL ) return NULL; | |
1105 return _matrule->reduce_left(globals); | |
1106 } | |
1107 | |
1108 | |
1109 // Base class for this instruction, MachNode except for calls | |
1541
b5fdf39b9749
6953576: bottom_type for matched AddPNodes doesn't always agree with ideal
never
parents:
1396
diff
changeset
|
1110 const char *InstructForm::mach_base_class(FormDict &globals) const { |
0 | 1111 if( is_ideal_call() == Form::JAVA_STATIC ) { |
1112 return "MachCallStaticJavaNode"; | |
1113 } | |
1114 else if( is_ideal_call() == Form::JAVA_DYNAMIC ) { | |
1115 return "MachCallDynamicJavaNode"; | |
1116 } | |
1117 else if( is_ideal_call() == Form::JAVA_RUNTIME ) { | |
1118 return "MachCallRuntimeNode"; | |
1119 } | |
1120 else if( is_ideal_call() == Form::JAVA_LEAF ) { | |
1121 return "MachCallLeafNode"; | |
1122 } | |
1123 else if (is_ideal_return()) { | |
1124 return "MachReturnNode"; | |
1125 } | |
1126 else if (is_ideal_halt()) { | |
1127 return "MachHaltNode"; | |
1128 } | |
1129 else if (is_ideal_safepoint()) { | |
1130 return "MachSafePointNode"; | |
1131 } | |
1132 else if (is_ideal_if()) { | |
1133 return "MachIfNode"; | |
1134 } | |
3842 | 1135 else if (is_ideal_goto()) { |
1136 return "MachGotoNode"; | |
1137 } | |
0 | 1138 else if (is_ideal_fastlock()) { |
1139 return "MachFastLockNode"; | |
1140 } | |
1141 else if (is_ideal_nop()) { | |
1142 return "MachNopNode"; | |
1143 } | |
2008 | 1144 else if (is_mach_constant()) { |
1145 return "MachConstantNode"; | |
1146 } | |
1541
b5fdf39b9749
6953576: bottom_type for matched AddPNodes doesn't always agree with ideal
never
parents:
1396
diff
changeset
|
1147 else if (captures_bottom_type(globals)) { |
0 | 1148 return "MachTypeNode"; |
1149 } else { | |
1150 return "MachNode"; | |
1151 } | |
1152 assert( false, "ShouldNotReachHere()"); | |
1153 return NULL; | |
1154 } | |
1155 | |
1156 // Compare the instruction predicates for textual equality | |
1157 bool equivalent_predicates( const InstructForm *instr1, const InstructForm *instr2 ) { | |
1158 const Predicate *pred1 = instr1->_predicate; | |
1159 const Predicate *pred2 = instr2->_predicate; | |
1160 if( pred1 == NULL && pred2 == NULL ) { | |
1161 // no predicates means they are identical | |
1162 return true; | |
1163 } | |
1164 if( pred1 != NULL && pred2 != NULL ) { | |
1165 // compare the predicates | |
475
284d0af00d53
6771309: debugging AD files is difficult without #line directives in generated code
jrose
parents:
420
diff
changeset
|
1166 if (ADLParser::equivalent_expressions(pred1->_pred, pred2->_pred)) { |
0 | 1167 return true; |
1168 } | |
1169 } | |
1170 | |
1171 return false; | |
1172 } | |
1173 | |
1174 // Check if this instruction can cisc-spill to 'alternate' | |
1175 bool InstructForm::cisc_spills_to(ArchDesc &AD, InstructForm *instr) { | |
1176 assert( _matrule != NULL && instr->_matrule != NULL, "must have match rules"); | |
1177 // Do not replace if a cisc-version has been found. | |
1178 if( cisc_spill_operand() != Not_cisc_spillable ) return false; | |
1179 | |
1180 int cisc_spill_operand = Maybe_cisc_spillable; | |
1181 char *result = NULL; | |
1182 char *result2 = NULL; | |
1183 const char *op_name = NULL; | |
1184 const char *reg_type = NULL; | |
1185 FormDict &globals = AD.globalNames(); | |
603
dbbe28fc66b5
6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents:
602
diff
changeset
|
1186 cisc_spill_operand = _matrule->matchrule_cisc_spill_match(globals, AD.get_registers(), instr->_matrule, op_name, reg_type); |
0 | 1187 if( (cisc_spill_operand != Not_cisc_spillable) && (op_name != NULL) && equivalent_predicates(this, instr) ) { |
1188 cisc_spill_operand = operand_position(op_name, Component::USE); | |
1189 int def_oper = operand_position(op_name, Component::DEF); | |
1190 if( def_oper == NameList::Not_in_list && instr->num_opnds() == num_opnds()) { | |
1191 // Do not support cisc-spilling for destination operands and | |
1192 // make sure they have the same number of operands. | |
1193 _cisc_spill_alternate = instr; | |
1194 instr->set_cisc_alternate(true); | |
1195 if( AD._cisc_spill_debug ) { | |
1196 fprintf(stderr, "Instruction %s cisc-spills-to %s\n", _ident, instr->_ident); | |
1197 fprintf(stderr, " using operand %s %s at index %d\n", reg_type, op_name, cisc_spill_operand); | |
1198 } | |
1199 // Record that a stack-version of the reg_mask is needed | |
1200 // !!!!! | |
1201 OperandForm *oper = (OperandForm*)(globals[reg_type]->is_operand()); | |
1202 assert( oper != NULL, "cisc-spilling non operand"); | |
1203 const char *reg_class_name = oper->constrained_reg_class(); | |
1204 AD.set_stack_or_reg(reg_class_name); | |
1205 const char *reg_mask_name = AD.reg_mask(*oper); | |
1206 set_cisc_reg_mask_name(reg_mask_name); | |
1207 const char *stack_or_reg_mask_name = AD.stack_or_reg_mask(*oper); | |
1208 } else { | |
1209 cisc_spill_operand = Not_cisc_spillable; | |
1210 } | |
1211 } else { | |
1212 cisc_spill_operand = Not_cisc_spillable; | |
1213 } | |
1214 | |
1215 set_cisc_spill_operand(cisc_spill_operand); | |
1216 return (cisc_spill_operand != Not_cisc_spillable); | |
1217 } | |
1218 | |
1219 // Check to see if this instruction can be replaced with the short branch | |
1220 // instruction `short-branch' | |
1221 bool InstructForm::check_branch_variant(ArchDesc &AD, InstructForm *short_branch) { | |
1222 if (_matrule != NULL && | |
1223 this != short_branch && // Don't match myself | |
1224 !is_short_branch() && // Don't match another short branch variant | |
1225 reduce_result() != NULL && | |
1226 strcmp(reduce_result(), short_branch->reduce_result()) == 0 && | |
1227 _matrule->equivalent(AD.globalNames(), short_branch->_matrule)) { | |
1228 // The instructions are equivalent. | |
3851 | 1229 |
1230 // Now verify that both instructions have the same parameters and | |
1231 // the same effects. Both branch forms should have the same inputs | |
1232 // and resulting projections to correctly replace a long branch node | |
1233 // with corresponding short branch node during code generation. | |
1234 | |
1235 bool different = false; | |
1236 if (short_branch->_components.count() != _components.count()) { | |
1237 different = true; | |
1238 } else if (_components.count() > 0) { | |
1239 short_branch->_components.reset(); | |
1240 _components.reset(); | |
1241 Component *comp; | |
1242 while ((comp = _components.iter()) != NULL) { | |
1243 Component *short_comp = short_branch->_components.iter(); | |
1244 if (short_comp == NULL || | |
1245 short_comp->_type != comp->_type || | |
1246 short_comp->_usedef != comp->_usedef) { | |
1247 different = true; | |
1248 break; | |
1249 } | |
1250 } | |
1251 if (short_branch->_components.iter() != NULL) | |
1252 different = true; | |
1253 } | |
1254 if (different) { | |
1255 globalAD->syntax_err(short_branch->_linenum, "Instruction %s and its short form %s have different parameters\n", _ident, short_branch->_ident); | |
1256 } | |
6850 | 1257 if (AD._adl_debug > 1 || AD._short_branch_debug) { |
0 | 1258 fprintf(stderr, "Instruction %s has short form %s\n", _ident, short_branch->_ident); |
1259 } | |
1260 _short_branch_form = short_branch; | |
1261 return true; | |
1262 } | |
1263 return false; | |
1264 } | |
1265 | |
1266 | |
1267 // --------------------------- FILE *output_routines | |
1268 // | |
1269 // Generate the format call for the replacement variable | |
1270 void InstructForm::rep_var_format(FILE *fp, const char *rep_var) { | |
2008 | 1271 // Handle special constant table variables. |
1272 if (strcmp(rep_var, "constanttablebase") == 0) { | |
1273 fprintf(fp, "char reg[128]; ra->dump_register(in(mach_constant_base_node_input()), reg);\n"); | |
3965
ae839d1e7d4c
7096010: c2: running with +PrintOptoAssembly crashes the VM when $constanttablebase is used
roland
parents:
3854
diff
changeset
|
1274 fprintf(fp, " st->print(\"%%s\", reg);\n"); |
2008 | 1275 return; |
1276 } | |
1277 if (strcmp(rep_var, "constantoffset") == 0) { | |
1278 fprintf(fp, "st->print(\"#%%d\", constant_offset());\n"); | |
1279 return; | |
1280 } | |
1281 if (strcmp(rep_var, "constantaddress") == 0) { | |
1282 fprintf(fp, "st->print(\"constant table base + #%%d\", constant_offset());\n"); | |
1283 return; | |
1284 } | |
1285 | |
0 | 1286 // Find replacement variable's type |
1287 const Form *form = _localNames[rep_var]; | |
1288 if (form == NULL) { | |
6850 | 1289 globalAD->syntax_err(_linenum, "Unknown replacement variable %s in format statement of %s.", |
1290 rep_var, _ident); | |
1291 return; | |
0 | 1292 } |
1293 OpClassForm *opc = form->is_opclass(); | |
1294 assert( opc, "replacement variable was not found in local names"); | |
1295 // Lookup the index position of the replacement variable | |
1296 int idx = operand_position_format(rep_var); | |
1297 if ( idx == -1 ) { | |
6850 | 1298 globalAD->syntax_err(_linenum, "Could not find replacement variable %s in format statement of %s.\n", |
1299 rep_var, _ident); | |
1300 assert(strcmp(opc->_ident, "label") == 0, "Unimplemented"); | |
1301 return; | |
0 | 1302 } |
1303 | |
1304 if (is_noninput_operand(idx)) { | |
1305 // This component isn't in the input array. Print out the static | |
1306 // name of the register. | |
1307 OperandForm* oper = form->is_operand(); | |
1308 if (oper != NULL && oper->is_bound_register()) { | |
1309 const RegDef* first = oper->get_RegClass()->find_first_elem(); | |
6850 | 1310 fprintf(fp, " st->print(\"%s\");\n", first->_regname); |
0 | 1311 } else { |
1312 globalAD->syntax_err(_linenum, "In %s can't find format for %s %s", _ident, opc->_ident, rep_var); | |
1313 } | |
1314 } else { | |
1315 // Output the format call for this operand | |
1316 fprintf(fp,"opnd_array(%d)->",idx); | |
1317 if (idx == 0) | |
1318 fprintf(fp,"int_format(ra, this, st); // %s\n", rep_var); | |
1319 else | |
1320 fprintf(fp,"ext_format(ra, this,idx%d, st); // %s\n", idx, rep_var ); | |
1321 } | |
1322 } | |
1323 | |
1324 // Seach through operands to determine parameters unique positions. | |
1325 void InstructForm::set_unique_opnds() { | |
1326 uint* uniq_idx = NULL; | |
10389 | 1327 uint nopnds = num_opnds(); |
0 | 1328 uint num_uniq = nopnds; |
10389 | 1329 uint i; |
599
0ad1cb407fa1
6805427: adlc compiler may generate incorrect machnode emission code
never
parents:
558
diff
changeset
|
1330 _uniq_idx_length = 0; |
10389 | 1331 if (nopnds > 0) { |
599
0ad1cb407fa1
6805427: adlc compiler may generate incorrect machnode emission code
never
parents:
558
diff
changeset
|
1332 // Allocate index array. Worst case we're mapping from each |
0ad1cb407fa1
6805427: adlc compiler may generate incorrect machnode emission code
never
parents:
558
diff
changeset
|
1333 // component back to an index and any DEF always goes at 0 so the |
0ad1cb407fa1
6805427: adlc compiler may generate incorrect machnode emission code
never
parents:
558
diff
changeset
|
1334 // length of the array has to be the number of components + 1. |
0ad1cb407fa1
6805427: adlc compiler may generate incorrect machnode emission code
never
parents:
558
diff
changeset
|
1335 _uniq_idx_length = _components.count() + 1; |
10389 | 1336 uniq_idx = (uint*) malloc(sizeof(uint) * _uniq_idx_length); |
1337 for (i = 0; i < _uniq_idx_length; i++) { | |
0 | 1338 uniq_idx[i] = i; |
1339 } | |
1340 } | |
1341 // Do it only if there is a match rule and no expand rule. With an | |
1342 // expand rule it is done by creating new mach node in Expand() | |
1343 // method. | |
10389 | 1344 if (nopnds > 0 && _matrule != NULL && _exprule == NULL) { |
0 | 1345 const char *name; |
1346 uint count; | |
1347 bool has_dupl_use = false; | |
1348 | |
1349 _parameters.reset(); | |
10389 | 1350 while ((name = _parameters.iter()) != NULL) { |
0 | 1351 count = 0; |
10389 | 1352 uint position = 0; |
1353 uint uniq_position = 0; | |
0 | 1354 _components.reset(); |
1355 Component *comp = NULL; | |
10389 | 1356 if (sets_result()) { |
0 | 1357 comp = _components.iter(); |
1358 position++; | |
1359 } | |
1360 // The next code is copied from the method operand_position(). | |
1361 for (; (comp = _components.iter()) != NULL; ++position) { | |
1362 // When the first component is not a DEF, | |
1363 // leave space for the result operand! | |
10389 | 1364 if (position==0 && (!comp->isa(Component::DEF))) { |
0 | 1365 ++position; |
1366 } | |
10389 | 1367 if (strcmp(name, comp->_name) == 0) { |
1368 if (++count > 1) { | |
599
0ad1cb407fa1
6805427: adlc compiler may generate incorrect machnode emission code
never
parents:
558
diff
changeset
|
1369 assert(position < _uniq_idx_length, "out of bounds"); |
0 | 1370 uniq_idx[position] = uniq_position; |
1371 has_dupl_use = true; | |
1372 } else { | |
1373 uniq_position = position; | |
1374 } | |
1375 } | |
10389 | 1376 if (comp->isa(Component::DEF) && comp->isa(Component::USE)) { |
0 | 1377 ++position; |
10389 | 1378 if (position != 1) |
0 | 1379 --position; // only use two slots for the 1st USE_DEF |
1380 } | |
1381 } | |
1382 } | |
10389 | 1383 if (has_dupl_use) { |
1384 for (i = 1; i < nopnds; i++) { | |
1385 if (i != uniq_idx[i]) { | |
0 | 1386 break; |
10389 | 1387 } |
1388 } | |
1389 uint j = i; | |
1390 for (; i < nopnds; i++) { | |
1391 if (i == uniq_idx[i]) { | |
0 | 1392 uniq_idx[i] = j++; |
10389 | 1393 } |
1394 } | |
0 | 1395 num_uniq = j; |
1396 } | |
1397 } | |
1398 _uniq_idx = uniq_idx; | |
1399 _num_uniq = num_uniq; | |
1400 } | |
1401 | |
605 | 1402 // Generate index values needed for determining the operand position |
0 | 1403 void InstructForm::index_temps(FILE *fp, FormDict &globals, const char *prefix, const char *receiver) { |
1404 uint idx = 0; // position of operand in match rule | |
1405 int cur_num_opnds = num_opnds(); | |
1406 | |
1407 // Compute the index into vector of operand pointers: | |
1408 // idx0=0 is used to indicate that info comes from this same node, not from input edge. | |
1409 // idx1 starts at oper_input_base() | |
1410 if ( cur_num_opnds >= 1 ) { | |
6850 | 1411 fprintf(fp," // Start at oper_input_base() and count operands\n"); |
1412 fprintf(fp," unsigned %sidx0 = %d;\n", prefix, oper_input_base(globals)); | |
1413 fprintf(fp," unsigned %sidx1 = %d;", prefix, oper_input_base(globals)); | |
1414 fprintf(fp," \t// %s\n", unique_opnd_ident(1)); | |
0 | 1415 |
1416 // Generate starting points for other unique operands if they exist | |
1417 for ( idx = 2; idx < num_unique_opnds(); ++idx ) { | |
1418 if( *receiver == 0 ) { | |
6850 | 1419 fprintf(fp," unsigned %sidx%d = %sidx%d + opnd_array(%d)->num_edges();", |
0 | 1420 prefix, idx, prefix, idx-1, idx-1 ); |
1421 } else { | |
6850 | 1422 fprintf(fp," unsigned %sidx%d = %sidx%d + %s_opnds[%d]->num_edges();", |
0 | 1423 prefix, idx, prefix, idx-1, receiver, idx-1 ); |
1424 } | |
6850 | 1425 fprintf(fp," \t// %s\n", unique_opnd_ident(idx)); |
0 | 1426 } |
1427 } | |
1428 if( *receiver != 0 ) { | |
1429 // This value is used by generate_peepreplace when copying a node. | |
1430 // Don't emit it in other cases since it can hide bugs with the | |
1431 // use invalid idx's. | |
6850 | 1432 fprintf(fp," unsigned %sidx%d = %sreq(); \n", prefix, idx, receiver); |
0 | 1433 } |
1434 | |
1435 } | |
1436 | |
1437 // --------------------------- | |
1438 bool InstructForm::verify() { | |
1439 // !!!!! !!!!! | |
1440 // Check that a "label" operand occurs last in the operand list, if present | |
1441 return true; | |
1442 } | |
1443 | |
1444 void InstructForm::dump() { | |
1445 output(stderr); | |
1446 } | |
1447 | |
1448 void InstructForm::output(FILE *fp) { | |
1449 fprintf(fp,"\nInstruction: %s\n", (_ident?_ident:"")); | |
1450 if (_matrule) _matrule->output(fp); | |
1451 if (_insencode) _insencode->output(fp); | |
2008 | 1452 if (_constant) _constant->output(fp); |
0 | 1453 if (_opcode) _opcode->output(fp); |
1454 if (_attribs) _attribs->output(fp); | |
1455 if (_predicate) _predicate->output(fp); | |
1456 if (_effects.Size()) { | |
1457 fprintf(fp,"Effects\n"); | |
1458 _effects.dump(); | |
1459 } | |
1460 if (_exprule) _exprule->output(fp); | |
1461 if (_rewrule) _rewrule->output(fp); | |
1462 if (_format) _format->output(fp); | |
1463 if (_peephole) _peephole->output(fp); | |
1464 } | |
1465 | |
1466 void MachNodeForm::dump() { | |
1467 output(stderr); | |
1468 } | |
1469 | |
1470 void MachNodeForm::output(FILE *fp) { | |
1471 fprintf(fp,"\nMachNode: %s\n", (_ident?_ident:"")); | |
1472 } | |
1473 | |
1474 //------------------------------build_predicate-------------------------------- | |
1475 // Build instruction predicates. If the user uses the same operand name | |
1476 // twice, we need to check that the operands are pointer-eequivalent in | |
1477 // the DFA during the labeling process. | |
1478 Predicate *InstructForm::build_predicate() { | |
1479 char buf[1024], *s=buf; | |
1480 Dict names(cmpstr,hashstr,Form::arena); // Map Names to counts | |
1481 | |
1482 MatchNode *mnode = | |
1483 strcmp(_matrule->_opType, "Set") ? _matrule : _matrule->_rChild; | |
1484 mnode->count_instr_names(names); | |
1485 | |
1486 uint first = 1; | |
1487 // Start with the predicate supplied in the .ad file. | |
1488 if( _predicate ) { | |
1489 if( first ) first=0; | |
1490 strcpy(s,"("); s += strlen(s); | |
1491 strcpy(s,_predicate->_pred); | |
1492 s += strlen(s); | |
1493 strcpy(s,")"); s += strlen(s); | |
1494 } | |
1495 for( DictI i(&names); i.test(); ++i ) { | |
1496 uintptr_t cnt = (uintptr_t)i._value; | |
1497 if( cnt > 1 ) { // Need a predicate at all? | |
1498 assert( cnt == 2, "Unimplemented" ); | |
1499 // Handle many pairs | |
1500 if( first ) first=0; | |
1501 else { // All tests must pass, so use '&&' | |
1502 strcpy(s," && "); | |
1503 s += strlen(s); | |
1504 } | |
1505 // Add predicate to working buffer | |
1506 sprintf(s,"/*%s*/(",(char*)i._key); | |
1507 s += strlen(s); | |
1508 mnode->build_instr_pred(s,(char*)i._key,0); | |
1509 s += strlen(s); | |
1510 strcpy(s," == "); s += strlen(s); | |
1511 mnode->build_instr_pred(s,(char*)i._key,1); | |
1512 s += strlen(s); | |
1513 strcpy(s,")"); s += strlen(s); | |
1514 } | |
1515 } | |
1516 if( s == buf ) s = NULL; | |
1517 else { | |
1518 assert( strlen(buf) < sizeof(buf), "String buffer overflow" ); | |
1519 s = strdup(buf); | |
1520 } | |
1521 return new Predicate(s); | |
1522 } | |
1523 | |
1524 //------------------------------EncodeForm------------------------------------- | |
1525 // Constructor | |
1526 EncodeForm::EncodeForm() | |
1527 : _encClass(cmpstr,hashstr, Form::arena) { | |
1528 } | |
1529 EncodeForm::~EncodeForm() { | |
1530 } | |
1531 | |
1532 // record a new register class | |
1533 EncClass *EncodeForm::add_EncClass(const char *className) { | |
1534 EncClass *encClass = new EncClass(className); | |
1535 _eclasses.addName(className); | |
1536 _encClass.Insert(className,encClass); | |
1537 return encClass; | |
1538 } | |
1539 | |
1540 // Lookup the function body for an encoding class | |
1541 EncClass *EncodeForm::encClass(const char *className) { | |
1542 assert( className != NULL, "Must provide a defined encoding name"); | |
1543 | |
1544 EncClass *encClass = (EncClass*)_encClass[className]; | |
1545 return encClass; | |
1546 } | |
1547 | |
1548 // Lookup the function body for an encoding class | |
1549 const char *EncodeForm::encClassBody(const char *className) { | |
1550 if( className == NULL ) return NULL; | |
1551 | |
1552 EncClass *encClass = (EncClass*)_encClass[className]; | |
1553 assert( encClass != NULL, "Encode Class is missing."); | |
1554 encClass->_code.reset(); | |
1555 const char *code = (const char*)encClass->_code.iter(); | |
1556 assert( code != NULL, "Found an empty encode class body."); | |
1557 | |
1558 return code; | |
1559 } | |
1560 | |
1561 // Lookup the function body for an encoding class | |
1562 const char *EncodeForm::encClassPrototype(const char *className) { | |
1563 assert( className != NULL, "Encode class name must be non NULL."); | |
1564 | |
1565 return className; | |
1566 } | |
1567 | |
1568 void EncodeForm::dump() { // Debug printer | |
1569 output(stderr); | |
1570 } | |
1571 | |
1572 void EncodeForm::output(FILE *fp) { // Write info to output files | |
1573 const char *name; | |
1574 fprintf(fp,"\n"); | |
1575 fprintf(fp,"-------------------- Dump EncodeForm --------------------\n"); | |
1576 for (_eclasses.reset(); (name = _eclasses.iter()) != NULL;) { | |
1577 ((EncClass*)_encClass[name])->output(fp); | |
1578 } | |
1579 fprintf(fp,"-------------------- end EncodeForm --------------------\n"); | |
1580 } | |
1581 //------------------------------EncClass--------------------------------------- | |
1582 EncClass::EncClass(const char *name) | |
1583 : _localNames(cmpstr,hashstr, Form::arena), _name(name) { | |
1584 } | |
1585 EncClass::~EncClass() { | |
1586 } | |
1587 | |
1588 // Add a parameter <type,name> pair | |
1589 void EncClass::add_parameter(const char *parameter_type, const char *parameter_name) { | |
1590 _parameter_type.addName( parameter_type ); | |
1591 _parameter_name.addName( parameter_name ); | |
1592 } | |
1593 | |
1594 // Verify operand types in parameter list | |
1595 bool EncClass::check_parameter_types(FormDict &globals) { | |
1596 // !!!!! | |
1597 return false; | |
1598 } | |
1599 | |
1600 // Add the decomposed "code" sections of an encoding's code-block | |
1601 void EncClass::add_code(const char *code) { | |
1602 _code.addName(code); | |
1603 } | |
1604 | |
1605 // Add the decomposed "replacement variables" of an encoding's code-block | |
1606 void EncClass::add_rep_var(char *replacement_var) { | |
1607 _code.addName(NameList::_signal); | |
1608 _rep_vars.addName(replacement_var); | |
1609 } | |
1610 | |
1611 // Lookup the function body for an encoding class | |
1612 int EncClass::rep_var_index(const char *rep_var) { | |
1613 uint position = 0; | |
1614 const char *name = NULL; | |
1615 | |
1616 _parameter_name.reset(); | |
1617 while ( (name = _parameter_name.iter()) != NULL ) { | |
1618 if ( strcmp(rep_var,name) == 0 ) return position; | |
1619 ++position; | |
1620 } | |
1621 | |
1622 return -1; | |
1623 } | |
1624 | |
1625 // Check after parsing | |
1626 bool EncClass::verify() { | |
1627 // 1!!!! | |
1628 // Check that each replacement variable, '$name' in architecture description | |
1629 // is actually a local variable for this encode class, or a reserved name | |
1630 // "primary, secondary, tertiary" | |
1631 return true; | |
1632 } | |
1633 | |
1634 void EncClass::dump() { | |
1635 output(stderr); | |
1636 } | |
1637 | |
1638 // Write info to output files | |
1639 void EncClass::output(FILE *fp) { | |
1640 fprintf(fp,"EncClass: %s", (_name ? _name : "")); | |
1641 | |
1642 // Output the parameter list | |
1643 _parameter_type.reset(); | |
1644 _parameter_name.reset(); | |
1645 const char *type = _parameter_type.iter(); | |
1646 const char *name = _parameter_name.iter(); | |
1647 fprintf(fp, " ( "); | |
1648 for ( ; (type != NULL) && (name != NULL); | |
1649 (type = _parameter_type.iter()), (name = _parameter_name.iter()) ) { | |
1650 fprintf(fp, " %s %s,", type, name); | |
1651 } | |
1652 fprintf(fp, " ) "); | |
1653 | |
1654 // Output the code block | |
1655 _code.reset(); | |
1656 _rep_vars.reset(); | |
1657 const char *code; | |
1658 while ( (code = _code.iter()) != NULL ) { | |
1659 if ( _code.is_signal(code) ) { | |
1660 // A replacement variable | |
1661 const char *rep_var = _rep_vars.iter(); | |
1662 fprintf(fp,"($%s)", rep_var); | |
1663 } else { | |
1664 // A section of code | |
1665 fprintf(fp,"%s", code); | |
1666 } | |
1667 } | |
1668 | |
1669 } | |
1670 | |
1671 //------------------------------Opcode----------------------------------------- | |
1672 Opcode::Opcode(char *primary, char *secondary, char *tertiary) | |
1673 : _primary(primary), _secondary(secondary), _tertiary(tertiary) { | |
1674 } | |
1675 | |
1676 Opcode::~Opcode() { | |
1677 } | |
1678 | |
1679 Opcode::opcode_type Opcode::as_opcode_type(const char *param) { | |
1680 if( strcmp(param,"primary") == 0 ) { | |
1681 return Opcode::PRIMARY; | |
1682 } | |
1683 else if( strcmp(param,"secondary") == 0 ) { | |
1684 return Opcode::SECONDARY; | |
1685 } | |
1686 else if( strcmp(param,"tertiary") == 0 ) { | |
1687 return Opcode::TERTIARY; | |
1688 } | |
1689 return Opcode::NOT_AN_OPCODE; | |
1690 } | |
1691 | |
415
4d9884b01ba6
6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents:
356
diff
changeset
|
1692 bool Opcode::print_opcode(FILE *fp, Opcode::opcode_type desired_opcode) { |
0 | 1693 // Default values previously provided by MachNode::primary()... |
415
4d9884b01ba6
6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents:
356
diff
changeset
|
1694 const char *description = NULL; |
4d9884b01ba6
6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents:
356
diff
changeset
|
1695 const char *value = NULL; |
0 | 1696 // Check if user provided any opcode definitions |
1697 if( this != NULL ) { | |
1698 // Update 'value' if user provided a definition in the instruction | |
1699 switch (desired_opcode) { | |
1700 case PRIMARY: | |
1701 description = "primary()"; | |
1702 if( _primary != NULL) { value = _primary; } | |
1703 break; | |
1704 case SECONDARY: | |
1705 description = "secondary()"; | |
1706 if( _secondary != NULL ) { value = _secondary; } | |
1707 break; | |
1708 case TERTIARY: | |
1709 description = "tertiary()"; | |
1710 if( _tertiary != NULL ) { value = _tertiary; } | |
1711 break; | |
1712 default: | |
1713 assert( false, "ShouldNotReachHere();"); | |
1714 break; | |
1715 } | |
1716 } | |
415
4d9884b01ba6
6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents:
356
diff
changeset
|
1717 if (value != NULL) { |
4d9884b01ba6
6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents:
356
diff
changeset
|
1718 fprintf(fp, "(%s /*%s*/)", value, description); |
4d9884b01ba6
6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents:
356
diff
changeset
|
1719 } |
4d9884b01ba6
6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents:
356
diff
changeset
|
1720 return value != NULL; |
0 | 1721 } |
1722 | |
1723 void Opcode::dump() { | |
1724 output(stderr); | |
1725 } | |
1726 | |
1727 // Write info to output files | |
1728 void Opcode::output(FILE *fp) { | |
1729 if (_primary != NULL) fprintf(fp,"Primary opcode: %s\n", _primary); | |
1730 if (_secondary != NULL) fprintf(fp,"Secondary opcode: %s\n", _secondary); | |
1731 if (_tertiary != NULL) fprintf(fp,"Tertiary opcode: %s\n", _tertiary); | |
1732 } | |
1733 | |
1734 //------------------------------InsEncode-------------------------------------- | |
1735 InsEncode::InsEncode() { | |
1736 } | |
1737 InsEncode::~InsEncode() { | |
1738 } | |
1739 | |
1740 // Add "encode class name" and its parameters | |
1741 NameAndList *InsEncode::add_encode(char *encoding) { | |
1742 assert( encoding != NULL, "Must provide name for encoding"); | |
1743 | |
1744 // add_parameter(NameList::_signal); | |
1745 NameAndList *encode = new NameAndList(encoding); | |
1746 _encoding.addName((char*)encode); | |
1747 | |
1748 return encode; | |
1749 } | |
1750 | |
1751 // Access the list of encodings | |
1752 void InsEncode::reset() { | |
1753 _encoding.reset(); | |
1754 // _parameter.reset(); | |
1755 } | |
1756 const char* InsEncode::encode_class_iter() { | |
1757 NameAndList *encode_class = (NameAndList*)_encoding.iter(); | |
1758 return ( encode_class != NULL ? encode_class->name() : NULL ); | |
1759 } | |
1760 // Obtain parameter name from zero based index | |
1761 const char *InsEncode::rep_var_name(InstructForm &inst, uint param_no) { | |
1762 NameAndList *params = (NameAndList*)_encoding.current(); | |
1763 assert( params != NULL, "Internal Error"); | |
1764 const char *param = (*params)[param_no]; | |
1765 | |
1766 // Remove '$' if parser placed it there. | |
1767 return ( param != NULL && *param == '$') ? (param+1) : param; | |
1768 } | |
1769 | |
1770 void InsEncode::dump() { | |
1771 output(stderr); | |
1772 } | |
1773 | |
1774 // Write info to output files | |
1775 void InsEncode::output(FILE *fp) { | |
1776 NameAndList *encoding = NULL; | |
1777 const char *parameter = NULL; | |
1778 | |
1779 fprintf(fp,"InsEncode: "); | |
1780 _encoding.reset(); | |
1781 | |
1782 while ( (encoding = (NameAndList*)_encoding.iter()) != 0 ) { | |
1783 // Output the encoding being used | |
1784 fprintf(fp,"%s(", encoding->name() ); | |
1785 | |
1786 // Output its parameter list, if any | |
1787 bool first_param = true; | |
1788 encoding->reset(); | |
1789 while ( (parameter = encoding->iter()) != 0 ) { | |
1790 // Output the ',' between parameters | |
1791 if ( ! first_param ) fprintf(fp,", "); | |
1792 first_param = false; | |
1793 // Output the parameter | |
1794 fprintf(fp,"%s", parameter); | |
1795 } // done with parameters | |
1796 fprintf(fp,") "); | |
1797 } // done with encodings | |
1798 | |
1799 fprintf(fp,"\n"); | |
1800 } | |
1801 | |
1802 //------------------------------Effect----------------------------------------- | |
1803 static int effect_lookup(const char *name) { | |
1804 if(!strcmp(name, "USE")) return Component::USE; | |
1805 if(!strcmp(name, "DEF")) return Component::DEF; | |
1806 if(!strcmp(name, "USE_DEF")) return Component::USE_DEF; | |
1807 if(!strcmp(name, "KILL")) return Component::KILL; | |
1808 if(!strcmp(name, "USE_KILL")) return Component::USE_KILL; | |
1809 if(!strcmp(name, "TEMP")) return Component::TEMP; | |
1810 if(!strcmp(name, "INVALID")) return Component::INVALID; | |
4120
f03a3c8bd5e5
7077312: Provide a CALL effect for instruct declaration in the ad file
roland
parents:
3965
diff
changeset
|
1811 if(!strcmp(name, "CALL")) return Component::CALL; |
0 | 1812 assert( false,"Invalid effect name specified\n"); |
1813 return Component::INVALID; | |
1814 } | |
1815 | |
6850 | 1816 const char *Component::getUsedefName() { |
1817 switch (_usedef) { | |
1818 case Component::INVALID: return "INVALID"; break; | |
1819 case Component::USE: return "USE"; break; | |
1820 case Component::USE_DEF: return "USE_DEF"; break; | |
1821 case Component::USE_KILL: return "USE_KILL"; break; | |
1822 case Component::KILL: return "KILL"; break; | |
1823 case Component::TEMP: return "TEMP"; break; | |
1824 case Component::DEF: return "DEF"; break; | |
1825 case Component::CALL: return "CALL"; break; | |
1826 default: assert(false, "unknown effect"); | |
1827 } | |
1828 return "Undefined Use/Def info"; | |
1829 } | |
1830 | |
0 | 1831 Effect::Effect(const char *name) : _name(name), _use_def(effect_lookup(name)) { |
1832 _ftype = Form::EFF; | |
1833 } | |
6850 | 1834 |
0 | 1835 Effect::~Effect() { |
1836 } | |
1837 | |
1838 // Dynamic type check | |
1839 Effect *Effect::is_effect() const { | |
1840 return (Effect*)this; | |
1841 } | |
1842 | |
1843 | |
1844 // True if this component is equal to the parameter. | |
1845 bool Effect::is(int use_def_kill_enum) const { | |
1846 return (_use_def == use_def_kill_enum ? true : false); | |
1847 } | |
1848 // True if this component is used/def'd/kill'd as the parameter suggests. | |
1849 bool Effect::isa(int use_def_kill_enum) const { | |
1850 return (_use_def & use_def_kill_enum) == use_def_kill_enum; | |
1851 } | |
1852 | |
1853 void Effect::dump() { | |
1854 output(stderr); | |
1855 } | |
1856 | |
1857 void Effect::output(FILE *fp) { // Write info to output files | |
1858 fprintf(fp,"Effect: %s\n", (_name?_name:"")); | |
1859 } | |
1860 | |
1861 //------------------------------ExpandRule------------------------------------- | |
1862 ExpandRule::ExpandRule() : _expand_instrs(), | |
1863 _newopconst(cmpstr, hashstr, Form::arena) { | |
1864 _ftype = Form::EXP; | |
1865 } | |
1866 | |
1867 ExpandRule::~ExpandRule() { // Destructor | |
1868 } | |
1869 | |
1870 void ExpandRule::add_instruction(NameAndList *instruction_name_and_operand_list) { | |
1871 _expand_instrs.addName((char*)instruction_name_and_operand_list); | |
1872 } | |
1873 | |
1874 void ExpandRule::reset_instructions() { | |
1875 _expand_instrs.reset(); | |
1876 } | |
1877 | |
1878 NameAndList* ExpandRule::iter_instructions() { | |
1879 return (NameAndList*)_expand_instrs.iter(); | |
1880 } | |
1881 | |
1882 | |
1883 void ExpandRule::dump() { | |
1884 output(stderr); | |
1885 } | |
1886 | |
1887 void ExpandRule::output(FILE *fp) { // Write info to output files | |
1888 NameAndList *expand_instr = NULL; | |
1889 const char *opid = NULL; | |
1890 | |
1891 fprintf(fp,"\nExpand Rule:\n"); | |
1892 | |
1893 // Iterate over the instructions 'node' expands into | |
1894 for(reset_instructions(); (expand_instr = iter_instructions()) != NULL; ) { | |
1895 fprintf(fp,"%s(", expand_instr->name()); | |
1896 | |
1897 // iterate over the operand list | |
1898 for( expand_instr->reset(); (opid = expand_instr->iter()) != NULL; ) { | |
1899 fprintf(fp,"%s ", opid); | |
1900 } | |
1901 fprintf(fp,");\n"); | |
1902 } | |
1903 } | |
1904 | |
1905 //------------------------------RewriteRule------------------------------------ | |
1906 RewriteRule::RewriteRule(char* params, char* block) | |
1907 : _tempParams(params), _tempBlock(block) { }; // Constructor | |
1908 RewriteRule::~RewriteRule() { // Destructor | |
1909 } | |
1910 | |
1911 void RewriteRule::dump() { | |
1912 output(stderr); | |
1913 } | |
1914 | |
1915 void RewriteRule::output(FILE *fp) { // Write info to output files | |
1916 fprintf(fp,"\nRewrite Rule:\n%s\n%s\n", | |
1917 (_tempParams?_tempParams:""), | |
1918 (_tempBlock?_tempBlock:"")); | |
1919 } | |
1920 | |
1921 | |
1922 //==============================MachNodes====================================== | |
1923 //------------------------------MachNodeForm----------------------------------- | |
1924 MachNodeForm::MachNodeForm(char *id) | |
1925 : _ident(id) { | |
1926 } | |
1927 | |
1928 MachNodeForm::~MachNodeForm() { | |
1929 } | |
1930 | |
1931 MachNodeForm *MachNodeForm::is_machnode() const { | |
1932 return (MachNodeForm*)this; | |
1933 } | |
1934 | |
1935 //==============================Operand Classes================================ | |
1936 //------------------------------OpClassForm------------------------------------ | |
1937 OpClassForm::OpClassForm(const char* id) : _ident(id) { | |
1938 _ftype = Form::OPCLASS; | |
1939 } | |
1940 | |
1941 OpClassForm::~OpClassForm() { | |
1942 } | |
1943 | |
1944 bool OpClassForm::ideal_only() const { return 0; } | |
1945 | |
1946 OpClassForm *OpClassForm::is_opclass() const { | |
1947 return (OpClassForm*)this; | |
1948 } | |
1949 | |
1950 Form::InterfaceType OpClassForm::interface_type(FormDict &globals) const { | |
1951 if( _oplst.count() == 0 ) return Form::no_interface; | |
1952 | |
1953 // Check that my operands have the same interface type | |
1954 Form::InterfaceType interface; | |
1955 bool first = true; | |
1956 NameList &op_list = (NameList &)_oplst; | |
1957 op_list.reset(); | |
1958 const char *op_name; | |
1959 while( (op_name = op_list.iter()) != NULL ) { | |
1960 const Form *form = globals[op_name]; | |
1961 OperandForm *operand = form->is_operand(); | |
1962 assert( operand, "Entry in operand class that is not an operand"); | |
1963 if( first ) { | |
1964 first = false; | |
1965 interface = operand->interface_type(globals); | |
1966 } else { | |
1967 interface = (interface == operand->interface_type(globals) ? interface : Form::no_interface); | |
1968 } | |
1969 } | |
1970 return interface; | |
1971 } | |
1972 | |
1973 bool OpClassForm::stack_slots_only(FormDict &globals) const { | |
1974 if( _oplst.count() == 0 ) return false; // how? | |
1975 | |
1976 NameList &op_list = (NameList &)_oplst; | |
1977 op_list.reset(); | |
1978 const char *op_name; | |
1979 while( (op_name = op_list.iter()) != NULL ) { | |
1980 const Form *form = globals[op_name]; | |
1981 OperandForm *operand = form->is_operand(); | |
1982 assert( operand, "Entry in operand class that is not an operand"); | |
1983 if( !operand->stack_slots_only(globals) ) return false; | |
1984 } | |
1985 return true; | |
1986 } | |
1987 | |
1988 | |
1989 void OpClassForm::dump() { | |
1990 output(stderr); | |
1991 } | |
1992 | |
1993 void OpClassForm::output(FILE *fp) { | |
1994 const char *name; | |
1995 fprintf(fp,"\nOperand Class: %s\n", (_ident?_ident:"")); | |
1996 fprintf(fp,"\nCount = %d\n", _oplst.count()); | |
1997 for(_oplst.reset(); (name = _oplst.iter()) != NULL;) { | |
1998 fprintf(fp,"%s, ",name); | |
1999 } | |
2000 fprintf(fp,"\n"); | |
2001 } | |
2002 | |
2003 | |
2004 //==============================Operands======================================= | |
2005 //------------------------------OperandForm------------------------------------ | |
2006 OperandForm::OperandForm(const char* id) | |
2007 : OpClassForm(id), _ideal_only(false), | |
2008 _localNames(cmpstr, hashstr, Form::arena) { | |
2009 _ftype = Form::OPER; | |
2010 | |
2011 _matrule = NULL; | |
2012 _interface = NULL; | |
2013 _attribs = NULL; | |
2014 _predicate = NULL; | |
2015 _constraint= NULL; | |
2016 _construct = NULL; | |
2017 _format = NULL; | |
2018 } | |
2019 OperandForm::OperandForm(const char* id, bool ideal_only) | |
2020 : OpClassForm(id), _ideal_only(ideal_only), | |
2021 _localNames(cmpstr, hashstr, Form::arena) { | |
2022 _ftype = Form::OPER; | |
2023 | |
2024 _matrule = NULL; | |
2025 _interface = NULL; | |
2026 _attribs = NULL; | |
2027 _predicate = NULL; | |
2028 _constraint= NULL; | |
2029 _construct = NULL; | |
2030 _format = NULL; | |
2031 } | |
2032 OperandForm::~OperandForm() { | |
2033 } | |
2034 | |
2035 | |
2036 OperandForm *OperandForm::is_operand() const { | |
2037 return (OperandForm*)this; | |
2038 } | |
2039 | |
2040 bool OperandForm::ideal_only() const { | |
2041 return _ideal_only; | |
2042 } | |
2043 | |
2044 Form::InterfaceType OperandForm::interface_type(FormDict &globals) const { | |
2045 if( _interface == NULL ) return Form::no_interface; | |
2046 | |
2047 return _interface->interface_type(globals); | |
2048 } | |
2049 | |
2050 | |
2051 bool OperandForm::stack_slots_only(FormDict &globals) const { | |
2052 if( _constraint == NULL ) return false; | |
2053 return _constraint->stack_slots_only(); | |
2054 } | |
2055 | |
2056 | |
2057 // Access op_cost attribute or return NULL. | |
2058 const char* OperandForm::cost() { | |
2059 for (Attribute* cur = _attribs; cur != NULL; cur = (Attribute*)cur->_next) { | |
2060 if( strcmp(cur->_ident,AttributeForm::_op_cost) == 0 ) { | |
2061 return cur->_val; | |
2062 } | |
2063 } | |
2064 return NULL; | |
2065 } | |
2066 | |
2067 // Return the number of leaves below this complex operand | |
2068 uint OperandForm::num_leaves() const { | |
2069 if ( ! _matrule) return 0; | |
2070 | |
2071 int num_leaves = _matrule->_numleaves; | |
2072 return num_leaves; | |
2073 } | |
2074 | |
2075 // Return the number of constants contained within this complex operand | |
2076 uint OperandForm::num_consts(FormDict &globals) const { | |
2077 if ( ! _matrule) return 0; | |
2078 | |
2079 // This is a recursive invocation on all operands in the matchrule | |
2080 return _matrule->num_consts(globals); | |
2081 } | |
2082 | |
2083 // Return the number of constants in match rule with specified type | |
2084 uint OperandForm::num_consts(FormDict &globals, Form::DataType type) const { | |
2085 if ( ! _matrule) return 0; | |
2086 | |
2087 // This is a recursive invocation on all operands in the matchrule | |
2088 return _matrule->num_consts(globals, type); | |
2089 } | |
2090 | |
2091 // Return the number of pointer constants contained within this complex operand | |
2092 uint OperandForm::num_const_ptrs(FormDict &globals) const { | |
2093 if ( ! _matrule) return 0; | |
2094 | |
2095 // This is a recursive invocation on all operands in the matchrule | |
2096 return _matrule->num_const_ptrs(globals); | |
2097 } | |
2098 | |
2099 uint OperandForm::num_edges(FormDict &globals) const { | |
2100 uint edges = 0; | |
2101 uint leaves = num_leaves(); | |
2102 uint consts = num_consts(globals); | |
2103 | |
2104 // If we are matching a constant directly, there are no leaves. | |
2105 edges = ( leaves > consts ) ? leaves - consts : 0; | |
2106 | |
2107 // !!!!! | |
2108 // Special case operands that do not have a corresponding ideal node. | |
2109 if( (edges == 0) && (consts == 0) ) { | |
2110 if( constrained_reg_class() != NULL ) { | |
2111 edges = 1; | |
2112 } else { | |
2113 if( _matrule | |
2114 && (_matrule->_lChild == NULL) && (_matrule->_rChild == NULL) ) { | |
2115 const Form *form = globals[_matrule->_opType]; | |
2116 OperandForm *oper = form ? form->is_operand() : NULL; | |
2117 if( oper ) { | |
2118 return oper->num_edges(globals); | |
2119 } | |
2120 } | |
2121 } | |
2122 } | |
2123 | |
2124 return edges; | |
2125 } | |
2126 | |
2127 | |
2128 // Check if this operand is usable for cisc-spilling | |
2129 bool OperandForm::is_cisc_reg(FormDict &globals) const { | |
2130 const char *ideal = ideal_type(globals); | |
2131 bool is_cisc_reg = (ideal && (ideal_to_Reg_type(ideal) != none)); | |
2132 return is_cisc_reg; | |
2133 } | |
2134 | |
2135 bool OpClassForm::is_cisc_mem(FormDict &globals) const { | |
2136 Form::InterfaceType my_interface = interface_type(globals); | |
2137 return (my_interface == memory_interface); | |
2138 } | |
2139 | |
2140 | |
2141 // node matches ideal 'Bool' | |
2142 bool OperandForm::is_ideal_bool() const { | |
2143 if( _matrule == NULL ) return false; | |
2144 | |
2145 return _matrule->is_ideal_bool(); | |
2146 } | |
2147 | |
2148 // Require user's name for an sRegX to be stackSlotX | |
2149 Form::DataType OperandForm::is_user_name_for_sReg() const { | |
2150 DataType data_type = none; | |
2151 if( _ident != NULL ) { | |
2152 if( strcmp(_ident,"stackSlotI") == 0 ) data_type = Form::idealI; | |
2153 else if( strcmp(_ident,"stackSlotP") == 0 ) data_type = Form::idealP; | |
2154 else if( strcmp(_ident,"stackSlotD") == 0 ) data_type = Form::idealD; | |
2155 else if( strcmp(_ident,"stackSlotF") == 0 ) data_type = Form::idealF; | |
2156 else if( strcmp(_ident,"stackSlotL") == 0 ) data_type = Form::idealL; | |
2157 } | |
2158 assert((data_type == none) || (_matrule == NULL), "No match-rule for stackSlotX"); | |
2159 | |
2160 return data_type; | |
2161 } | |
2162 | |
2163 | |
2164 // Return ideal type, if there is a single ideal type for this operand | |
2165 const char *OperandForm::ideal_type(FormDict &globals, RegisterForm *registers) const { | |
2166 const char *type = NULL; | |
2167 if (ideal_only()) type = _ident; | |
2168 else if( _matrule == NULL ) { | |
2169 // Check for condition code register | |
2170 const char *rc_name = constrained_reg_class(); | |
2171 // !!!!! | |
2172 if (rc_name == NULL) return NULL; | |
2173 // !!!!! !!!!! | |
2174 // Check constraints on result's register class | |
2175 if( registers ) { | |
2176 RegClass *reg_class = registers->getRegClass(rc_name); | |
2177 assert( reg_class != NULL, "Register class is not defined"); | |
2178 | |
2179 // Check for ideal type of entries in register class, all are the same type | |
2180 reg_class->reset(); | |
2181 RegDef *reg_def = reg_class->RegDef_iter(); | |
2182 assert( reg_def != NULL, "No entries in register class"); | |
2183 assert( reg_def->_idealtype != NULL, "Did not define ideal type for register"); | |
2184 // Return substring that names the register's ideal type | |
2185 type = reg_def->_idealtype + 3; | |
2186 assert( *(reg_def->_idealtype + 0) == 'O', "Expect Op_ prefix"); | |
2187 assert( *(reg_def->_idealtype + 1) == 'p', "Expect Op_ prefix"); | |
2188 assert( *(reg_def->_idealtype + 2) == '_', "Expect Op_ prefix"); | |
2189 } | |
2190 } | |
2191 else if( _matrule->_lChild == NULL && _matrule->_rChild == NULL ) { | |
2192 // This operand matches a single type, at the top level. | |
2193 // Check for ideal type | |
2194 type = _matrule->_opType; | |
2195 if( strcmp(type,"Bool") == 0 ) | |
2196 return "Bool"; | |
2197 // transitive lookup | |
2198 const Form *frm = globals[type]; | |
2199 OperandForm *op = frm->is_operand(); | |
2200 type = op->ideal_type(globals, registers); | |
2201 } | |
2202 return type; | |
2203 } | |
2204 | |
2205 | |
2206 // If there is a single ideal type for this interface field, return it. | |
2207 const char *OperandForm::interface_ideal_type(FormDict &globals, | |
2208 const char *field) const { | |
2209 const char *ideal_type = NULL; | |
2210 const char *value = NULL; | |
2211 | |
2212 // Check if "field" is valid for this operand's interface | |
2213 if ( ! is_interface_field(field, value) ) return ideal_type; | |
2214 | |
2215 // !!!!! !!!!! !!!!! | |
2216 // If a valid field has a constant value, identify "ConI" or "ConP" or ... | |
2217 | |
2218 // Else, lookup type of field's replacement variable | |
2219 | |
2220 return ideal_type; | |
2221 } | |
2222 | |
2223 | |
2224 RegClass* OperandForm::get_RegClass() const { | |
2225 if (_interface && !_interface->is_RegInterface()) return NULL; | |
2226 return globalAD->get_registers()->getRegClass(constrained_reg_class()); | |
2227 } | |
2228 | |
2229 | |
2230 bool OperandForm::is_bound_register() const { | |
10389 | 2231 RegClass* reg_class = get_RegClass(); |
2232 if (reg_class == NULL) { | |
2233 return false; | |
2234 } | |
2235 | |
2236 const char* name = ideal_type(globalAD->globalNames()); | |
2237 if (name == NULL) { | |
2238 return false; | |
2239 } | |
2240 | |
2241 uint size = 0; | |
2242 if (strcmp(name, "RegFlags") == 0) size = 1; | |
2243 if (strcmp(name, "RegI") == 0) size = 1; | |
2244 if (strcmp(name, "RegF") == 0) size = 1; | |
2245 if (strcmp(name, "RegD") == 0) size = 2; | |
2246 if (strcmp(name, "RegL") == 0) size = 2; | |
2247 if (strcmp(name, "RegN") == 0) size = 1; | |
2248 if (strcmp(name, "RegP") == 0) size = globalAD->get_preproc_def("_LP64") ? 2 : 1; | |
2249 if (size == 0) { | |
2250 return false; | |
2251 } | |
0 | 2252 return size == reg_class->size(); |
2253 } | |
2254 | |
2255 | |
2256 // Check if this is a valid field for this operand, | |
2257 // Return 'true' if valid, and set the value to the string the user provided. | |
2258 bool OperandForm::is_interface_field(const char *field, | |
2259 const char * &value) const { | |
2260 return false; | |
2261 } | |
2262 | |
2263 | |
2264 // Return register class name if a constraint specifies the register class. | |
2265 const char *OperandForm::constrained_reg_class() const { | |
2266 const char *reg_class = NULL; | |
2267 if ( _constraint ) { | |
2268 // !!!!! | |
2269 Constraint *constraint = _constraint; | |
2270 if ( strcmp(_constraint->_func,"ALLOC_IN_RC") == 0 ) { | |
2271 reg_class = _constraint->_arg; | |
2272 } | |
2273 } | |
2274 | |
2275 return reg_class; | |
2276 } | |
2277 | |
2278 | |
2279 // Return the register class associated with 'leaf'. | |
2280 const char *OperandForm::in_reg_class(uint leaf, FormDict &globals) { | |
2281 const char *reg_class = NULL; // "RegMask::Empty"; | |
2282 | |
2283 if((_matrule == NULL) || (_matrule->is_chain_rule(globals))) { | |
2284 reg_class = constrained_reg_class(); | |
2285 return reg_class; | |
2286 } | |
2287 const char *result = NULL; | |
2288 const char *name = NULL; | |
2289 const char *type = NULL; | |
2290 // iterate through all base operands | |
2291 // until we reach the register that corresponds to "leaf" | |
2292 // This function is not looking for an ideal type. It needs the first | |
2293 // level user type associated with the leaf. | |
2294 for(uint idx = 0;_matrule->base_operand(idx,globals,result,name,type);++idx) { | |
2295 const Form *form = (_localNames[name] ? _localNames[name] : globals[result]); | |
2296 OperandForm *oper = form ? form->is_operand() : NULL; | |
2297 if( oper ) { | |
2298 reg_class = oper->constrained_reg_class(); | |
2299 if( reg_class ) { | |
2300 reg_class = reg_class; | |
2301 } else { | |
2302 // ShouldNotReachHere(); | |
2303 } | |
2304 } else { | |
2305 // ShouldNotReachHere(); | |
2306 } | |
2307 | |
2308 // Increment our target leaf position if current leaf is not a candidate. | |
2309 if( reg_class == NULL) ++leaf; | |
2310 // Exit the loop with the value of reg_class when at the correct index | |
2311 if( idx == leaf ) break; | |
2312 // May iterate through all base operands if reg_class for 'leaf' is NULL | |
2313 } | |
2314 return reg_class; | |
2315 } | |
2316 | |
2317 | |
2318 // Recursive call to construct list of top-level operands. | |
2319 // Implementation does not modify state of internal structures | |
2320 void OperandForm::build_components() { | |
2321 if (_matrule) _matrule->append_components(_localNames, _components); | |
2322 | |
2323 // Add parameters that "do not appear in match rule". | |
2324 const char *name; | |
2325 for (_parameters.reset(); (name = _parameters.iter()) != NULL;) { | |
2326 OperandForm *opForm = (OperandForm*)_localNames[name]; | |
2327 | |
2328 if ( _components.operand_position(name) == -1 ) { | |
2329 _components.insert(name, opForm->_ident, Component::INVALID, false); | |
2330 } | |
2331 } | |
2332 | |
2333 return; | |
2334 } | |
2335 | |
2336 int OperandForm::operand_position(const char *name, int usedef) { | |
6850 | 2337 return _components.operand_position(name, usedef, this); |
0 | 2338 } |
2339 | |
2340 | |
2341 // Return zero-based position in component list, only counting constants; | |
2342 // Return -1 if not in list. | |
2343 int OperandForm::constant_position(FormDict &globals, const Component *last) { | |
605 | 2344 // Iterate through components and count constants preceding 'constant' |
603
dbbe28fc66b5
6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents:
602
diff
changeset
|
2345 int position = 0; |
0 | 2346 Component *comp; |
2347 _components.reset(); | |
2348 while( (comp = _components.iter()) != NULL && (comp != last) ) { | |
2349 // Special case for operands that take a single user-defined operand | |
2350 // Skip the initial definition in the component list. | |
2351 if( strcmp(comp->_name,this->_ident) == 0 ) continue; | |
2352 | |
2353 const char *type = comp->_type; | |
2354 // Lookup operand form for replacement variable's type | |
2355 const Form *form = globals[type]; | |
2356 assert( form != NULL, "Component's type not found"); | |
2357 OperandForm *oper = form ? form->is_operand() : NULL; | |
2358 if( oper ) { | |
2359 if( oper->_matrule->is_base_constant(globals) != Form::none ) { | |
2360 ++position; | |
2361 } | |
2362 } | |
2363 } | |
2364 | |
2365 // Check for being passed a component that was not in the list | |
2366 if( comp != last ) position = -1; | |
2367 | |
2368 return position; | |
2369 } | |
2370 // Provide position of constant by "name" | |
2371 int OperandForm::constant_position(FormDict &globals, const char *name) { | |
2372 const Component *comp = _components.search(name); | |
2373 int idx = constant_position( globals, comp ); | |
2374 | |
2375 return idx; | |
2376 } | |
2377 | |
2378 | |
2379 // Return zero-based position in component list, only counting constants; | |
2380 // Return -1 if not in list. | |
2381 int OperandForm::register_position(FormDict &globals, const char *reg_name) { | |
605 | 2382 // Iterate through components and count registers preceding 'last' |
0 | 2383 uint position = 0; |
2384 Component *comp; | |
2385 _components.reset(); | |
2386 while( (comp = _components.iter()) != NULL | |
2387 && (strcmp(comp->_name,reg_name) != 0) ) { | |
2388 // Special case for operands that take a single user-defined operand | |
2389 // Skip the initial definition in the component list. | |
2390 if( strcmp(comp->_name,this->_ident) == 0 ) continue; | |
2391 | |
2392 const char *type = comp->_type; | |
2393 // Lookup operand form for component's type | |
2394 const Form *form = globals[type]; | |
2395 assert( form != NULL, "Component's type not found"); | |
2396 OperandForm *oper = form ? form->is_operand() : NULL; | |
2397 if( oper ) { | |
2398 if( oper->_matrule->is_base_register(globals) ) { | |
2399 ++position; | |
2400 } | |
2401 } | |
2402 } | |
2403 | |
2404 return position; | |
2405 } | |
2406 | |
2407 | |
2408 const char *OperandForm::reduce_result() const { | |
2409 return _ident; | |
2410 } | |
2411 // Return the name of the operand on the right hand side of the binary match | |
2412 // Return NULL if there is no right hand side | |
2413 const char *OperandForm::reduce_right(FormDict &globals) const { | |
2414 return ( _matrule ? _matrule->reduce_right(globals) : NULL ); | |
2415 } | |
2416 | |
2417 // Similar for left | |
2418 const char *OperandForm::reduce_left(FormDict &globals) const { | |
2419 return ( _matrule ? _matrule->reduce_left(globals) : NULL ); | |
2420 } | |
2421 | |
2422 | |
2423 // --------------------------- FILE *output_routines | |
2424 // | |
2425 // Output code for disp_is_oop, if true. | |
2426 void OperandForm::disp_is_oop(FILE *fp, FormDict &globals) { | |
2427 // Check it is a memory interface with a non-user-constant disp field | |
2428 if ( this->_interface == NULL ) return; | |
2429 MemInterface *mem_interface = this->_interface->is_MemInterface(); | |
2430 if ( mem_interface == NULL ) return; | |
2431 const char *disp = mem_interface->_disp; | |
2432 if ( *disp != '$' ) return; | |
2433 | |
2434 // Lookup replacement variable in operand's component list | |
2435 const char *rep_var = disp + 1; | |
2436 const Component *comp = this->_components.search(rep_var); | |
2437 assert( comp != NULL, "Replacement variable not found in components"); | |
2438 // Lookup operand form for replacement variable's type | |
2439 const char *type = comp->_type; | |
2440 Form *form = (Form*)globals[type]; | |
2441 assert( form != NULL, "Replacement variable's type not found"); | |
2442 OperandForm *op = form->is_operand(); | |
2443 assert( op, "Memory Interface 'disp' can only emit an operand form"); | |
2444 // Check if this is a ConP, which may require relocation | |
2445 if ( op->is_base_constant(globals) == Form::idealP ) { | |
2446 // Find the constant's index: _c0, _c1, _c2, ... , _cN | |
2447 uint idx = op->constant_position( globals, rep_var); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6179
diff
changeset
|
2448 fprintf(fp," virtual relocInfo::relocType disp_reloc() const {"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6179
diff
changeset
|
2449 fprintf(fp, " return _c%d->reloc();", idx); |
0 | 2450 fprintf(fp, " }\n"); |
2451 } | |
2452 } | |
2453 | |
2454 // Generate code for internal and external format methods | |
2455 // | |
2456 // internal access to reg# node->_idx | |
2457 // access to subsumed constant _c0, _c1, | |
2458 void OperandForm::int_format(FILE *fp, FormDict &globals, uint index) { | |
2459 Form::DataType dtype; | |
2460 if (_matrule && (_matrule->is_base_register(globals) || | |
2461 strcmp(ideal_type(globalAD->globalNames()), "RegFlags") == 0)) { | |
2462 // !!!!! !!!!! | |
6850 | 2463 fprintf(fp," { char reg_str[128];\n"); |
2464 fprintf(fp," ra->dump_register(node,reg_str);\n"); | |
2465 fprintf(fp," st->print(\"%cs\",reg_str);\n",'%'); | |
2466 fprintf(fp," }\n"); | |
0 | 2467 } else if (_matrule && (dtype = _matrule->is_base_constant(globals)) != Form::none) { |
2468 format_constant( fp, index, dtype ); | |
2469 } else if (ideal_to_sReg_type(_ident) != Form::none) { | |
2470 // Special format for Stack Slot Register | |
6850 | 2471 fprintf(fp," { char reg_str[128];\n"); |
2472 fprintf(fp," ra->dump_register(node,reg_str);\n"); | |
2473 fprintf(fp," st->print(\"%cs\",reg_str);\n",'%'); | |
2474 fprintf(fp," }\n"); | |
0 | 2475 } else { |
6850 | 2476 fprintf(fp," st->print(\"No format defined for %s\n\");\n", _ident); |
0 | 2477 fflush(fp); |
2478 fprintf(stderr,"No format defined for %s\n", _ident); | |
2479 dump(); | |
2480 assert( false,"Internal error:\n output_internal_operand() attempting to output other than a Register or Constant"); | |
2481 } | |
2482 } | |
2483 | |
2484 // Similar to "int_format" but for cases where data is external to operand | |
2485 // external access to reg# node->in(idx)->_idx, | |
2486 void OperandForm::ext_format(FILE *fp, FormDict &globals, uint index) { | |
2487 Form::DataType dtype; | |
2488 if (_matrule && (_matrule->is_base_register(globals) || | |
2489 strcmp(ideal_type(globalAD->globalNames()), "RegFlags") == 0)) { | |
6850 | 2490 fprintf(fp," { char reg_str[128];\n"); |
2491 fprintf(fp," ra->dump_register(node->in(idx"); | |
2492 if ( index != 0 ) fprintf(fp, "+%d",index); | |
2493 fprintf(fp, "),reg_str);\n"); | |
2494 fprintf(fp," st->print(\"%cs\",reg_str);\n",'%'); | |
2495 fprintf(fp," }\n"); | |
0 | 2496 } else if (_matrule && (dtype = _matrule->is_base_constant(globals)) != Form::none) { |
2497 format_constant( fp, index, dtype ); | |
2498 } else if (ideal_to_sReg_type(_ident) != Form::none) { | |
2499 // Special format for Stack Slot Register | |
6850 | 2500 fprintf(fp," { char reg_str[128];\n"); |
2501 fprintf(fp," ra->dump_register(node->in(idx"); | |
0 | 2502 if ( index != 0 ) fprintf(fp, "+%d",index); |
2503 fprintf(fp, "),reg_str);\n"); | |
6850 | 2504 fprintf(fp," st->print(\"%cs\",reg_str);\n",'%'); |
2505 fprintf(fp," }\n"); | |
0 | 2506 } else { |
6850 | 2507 fprintf(fp," st->print(\"No format defined for %s\n\");\n", _ident); |
0 | 2508 assert( false,"Internal error:\n output_external_operand() attempting to output other than a Register or Constant"); |
2509 } | |
2510 } | |
2511 | |
2512 void OperandForm::format_constant(FILE *fp, uint const_index, uint const_type) { | |
2513 switch(const_type) { | |
6850 | 2514 case Form::idealI: fprintf(fp," st->print(\"#%%d\", _c%d);\n", const_index); break; |
2515 case Form::idealP: fprintf(fp," if (_c%d) _c%d->dump_on(st);\n", const_index, const_index); break; | |
6848
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6823
diff
changeset
|
2516 case Form::idealNKlass: |
6850 | 2517 case Form::idealN: fprintf(fp," if (_c%d) _c%d->dump_on(st);\n", const_index, const_index); break; |
2518 case Form::idealL: fprintf(fp," st->print(\"#%%lld\", _c%d);\n", const_index); break; | |
2519 case Form::idealF: fprintf(fp," st->print(\"#%%f\", _c%d);\n", const_index); break; | |
2520 case Form::idealD: fprintf(fp," st->print(\"#%%f\", _c%d);\n", const_index); break; | |
0 | 2521 default: |
2522 assert( false, "ShouldNotReachHere()"); | |
2523 } | |
2524 } | |
2525 | |
2526 // Return the operand form corresponding to the given index, else NULL. | |
2527 OperandForm *OperandForm::constant_operand(FormDict &globals, | |
2528 uint index) { | |
2529 // !!!!! | |
2530 // Check behavior on complex operands | |
2531 uint n_consts = num_consts(globals); | |
2532 if( n_consts > 0 ) { | |
2533 uint i = 0; | |
2534 const char *type; | |
2535 Component *comp; | |
2536 _components.reset(); | |
2537 if ((comp = _components.iter()) == NULL) { | |
2538 assert(n_consts == 1, "Bad component list detected.\n"); | |
2539 // Current operand is THE operand | |
2540 if ( index == 0 ) { | |
2541 return this; | |
2542 } | |
2543 } // end if NULL | |
2544 else { | |
2545 // Skip the first component, it can not be a DEF of a constant | |
2546 do { | |
2547 type = comp->base_type(globals); | |
2548 // Check that "type" is a 'ConI', 'ConP', ... | |
2549 if ( ideal_to_const_type(type) != Form::none ) { | |
2550 // When at correct component, get corresponding Operand | |
2551 if ( index == 0 ) { | |
2552 return globals[comp->_type]->is_operand(); | |
2553 } | |
2554 // Decrement number of constants to go | |
2555 --index; | |
2556 } | |
2557 } while((comp = _components.iter()) != NULL); | |
2558 } | |
2559 } | |
2560 | |
2561 // Did not find a constant for this index. | |
2562 return NULL; | |
2563 } | |
2564 | |
2565 // If this operand has a single ideal type, return its type | |
2566 Form::DataType OperandForm::simple_type(FormDict &globals) const { | |
2567 const char *type_name = ideal_type(globals); | |
2568 Form::DataType type = type_name ? ideal_to_const_type( type_name ) | |
2569 : Form::none; | |
2570 return type; | |
2571 } | |
2572 | |
2573 Form::DataType OperandForm::is_base_constant(FormDict &globals) const { | |
2574 if ( _matrule == NULL ) return Form::none; | |
2575 | |
2576 return _matrule->is_base_constant(globals); | |
2577 } | |
2578 | |
2579 // "true" if this operand is a simple type that is swallowed | |
2580 bool OperandForm::swallowed(FormDict &globals) const { | |
2581 Form::DataType type = simple_type(globals); | |
2582 if( type != Form::none ) { | |
2583 return true; | |
2584 } | |
2585 | |
2586 return false; | |
2587 } | |
2588 | |
2589 // Output code to access the value of the index'th constant | |
2590 void OperandForm::access_constant(FILE *fp, FormDict &globals, | |
2591 uint const_index) { | |
2592 OperandForm *oper = constant_operand(globals, const_index); | |
2593 assert( oper, "Index exceeds number of constants in operand"); | |
2594 Form::DataType dtype = oper->is_base_constant(globals); | |
2595 | |
2596 switch(dtype) { | |
2597 case idealI: fprintf(fp,"_c%d", const_index); break; | |
2598 case idealP: fprintf(fp,"_c%d->get_con()",const_index); break; | |
2599 case idealL: fprintf(fp,"_c%d", const_index); break; | |
2600 case idealF: fprintf(fp,"_c%d", const_index); break; | |
2601 case idealD: fprintf(fp,"_c%d", const_index); break; | |
2602 default: | |
2603 assert( false, "ShouldNotReachHere()"); | |
2604 } | |
2605 } | |
2606 | |
2607 | |
2608 void OperandForm::dump() { | |
2609 output(stderr); | |
2610 } | |
2611 | |
2612 void OperandForm::output(FILE *fp) { | |
2613 fprintf(fp,"\nOperand: %s\n", (_ident?_ident:"")); | |
2614 if (_matrule) _matrule->dump(); | |
2615 if (_interface) _interface->dump(); | |
2616 if (_attribs) _attribs->dump(); | |
2617 if (_predicate) _predicate->dump(); | |
2618 if (_constraint) _constraint->dump(); | |
2619 if (_construct) _construct->dump(); | |
2620 if (_format) _format->dump(); | |
2621 } | |
2622 | |
2623 //------------------------------Constraint------------------------------------- | |
2624 Constraint::Constraint(const char *func, const char *arg) | |
2625 : _func(func), _arg(arg) { | |
2626 } | |
2627 Constraint::~Constraint() { /* not owner of char* */ | |
2628 } | |
2629 | |
2630 bool Constraint::stack_slots_only() const { | |
2631 return strcmp(_func, "ALLOC_IN_RC") == 0 | |
2632 && strcmp(_arg, "stack_slots") == 0; | |
2633 } | |
2634 | |
2635 void Constraint::dump() { | |
2636 output(stderr); | |
2637 } | |
2638 | |
2639 void Constraint::output(FILE *fp) { // Write info to output files | |
2640 assert((_func != NULL && _arg != NULL),"missing constraint function or arg"); | |
2641 fprintf(fp,"Constraint: %s ( %s )\n", _func, _arg); | |
2642 } | |
2643 | |
2644 //------------------------------Predicate-------------------------------------- | |
2645 Predicate::Predicate(char *pr) | |
2646 : _pred(pr) { | |
2647 } | |
2648 Predicate::~Predicate() { | |
2649 } | |
2650 | |
2651 void Predicate::dump() { | |
2652 output(stderr); | |
2653 } | |
2654 | |
2655 void Predicate::output(FILE *fp) { | |
2656 fprintf(fp,"Predicate"); // Write to output files | |
2657 } | |
2658 //------------------------------Interface-------------------------------------- | |
2659 Interface::Interface(const char *name) : _name(name) { | |
2660 } | |
2661 Interface::~Interface() { | |
2662 } | |
2663 | |
2664 Form::InterfaceType Interface::interface_type(FormDict &globals) const { | |
2665 Interface *thsi = (Interface*)this; | |
2666 if ( thsi->is_RegInterface() ) return Form::register_interface; | |
2667 if ( thsi->is_MemInterface() ) return Form::memory_interface; | |
2668 if ( thsi->is_ConstInterface() ) return Form::constant_interface; | |
2669 if ( thsi->is_CondInterface() ) return Form::conditional_interface; | |
2670 | |
2671 return Form::no_interface; | |
2672 } | |
2673 | |
2674 RegInterface *Interface::is_RegInterface() { | |
2675 if ( strcmp(_name,"REG_INTER") != 0 ) | |
2676 return NULL; | |
2677 return (RegInterface*)this; | |
2678 } | |
2679 MemInterface *Interface::is_MemInterface() { | |
2680 if ( strcmp(_name,"MEMORY_INTER") != 0 ) return NULL; | |
2681 return (MemInterface*)this; | |
2682 } | |
2683 ConstInterface *Interface::is_ConstInterface() { | |
2684 if ( strcmp(_name,"CONST_INTER") != 0 ) return NULL; | |
2685 return (ConstInterface*)this; | |
2686 } | |
2687 CondInterface *Interface::is_CondInterface() { | |
2688 if ( strcmp(_name,"COND_INTER") != 0 ) return NULL; | |
2689 return (CondInterface*)this; | |
2690 } | |
2691 | |
2692 | |
2693 void Interface::dump() { | |
2694 output(stderr); | |
2695 } | |
2696 | |
2697 // Write info to output files | |
2698 void Interface::output(FILE *fp) { | |
2699 fprintf(fp,"Interface: %s\n", (_name ? _name : "") ); | |
2700 } | |
2701 | |
2702 //------------------------------RegInterface----------------------------------- | |
2703 RegInterface::RegInterface() : Interface("REG_INTER") { | |
2704 } | |
2705 RegInterface::~RegInterface() { | |
2706 } | |
2707 | |
2708 void RegInterface::dump() { | |
2709 output(stderr); | |
2710 } | |
2711 | |
2712 // Write info to output files | |
2713 void RegInterface::output(FILE *fp) { | |
2714 Interface::output(fp); | |
2715 } | |
2716 | |
2717 //------------------------------ConstInterface--------------------------------- | |
2718 ConstInterface::ConstInterface() : Interface("CONST_INTER") { | |
2719 } | |
2720 ConstInterface::~ConstInterface() { | |
2721 } | |
2722 | |
2723 void ConstInterface::dump() { | |
2724 output(stderr); | |
2725 } | |
2726 | |
2727 // Write info to output files | |
2728 void ConstInterface::output(FILE *fp) { | |
2729 Interface::output(fp); | |
2730 } | |
2731 | |
2732 //------------------------------MemInterface----------------------------------- | |
2733 MemInterface::MemInterface(char *base, char *index, char *scale, char *disp) | |
2734 : Interface("MEMORY_INTER"), _base(base), _index(index), _scale(scale), _disp(disp) { | |
2735 } | |
2736 MemInterface::~MemInterface() { | |
2737 // not owner of any character arrays | |
2738 } | |
2739 | |
2740 void MemInterface::dump() { | |
2741 output(stderr); | |
2742 } | |
2743 | |
2744 // Write info to output files | |
2745 void MemInterface::output(FILE *fp) { | |
2746 Interface::output(fp); | |
2747 if ( _base != NULL ) fprintf(fp," base == %s\n", _base); | |
2748 if ( _index != NULL ) fprintf(fp," index == %s\n", _index); | |
2749 if ( _scale != NULL ) fprintf(fp," scale == %s\n", _scale); | |
2750 if ( _disp != NULL ) fprintf(fp," disp == %s\n", _disp); | |
2751 // fprintf(fp,"\n"); | |
2752 } | |
2753 | |
2754 //------------------------------CondInterface---------------------------------- | |
415
4d9884b01ba6
6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents:
356
diff
changeset
|
2755 CondInterface::CondInterface(const char* equal, const char* equal_format, |
4d9884b01ba6
6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents:
356
diff
changeset
|
2756 const char* not_equal, const char* not_equal_format, |
4d9884b01ba6
6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents:
356
diff
changeset
|
2757 const char* less, const char* less_format, |
4d9884b01ba6
6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents:
356
diff
changeset
|
2758 const char* greater_equal, const char* greater_equal_format, |
4d9884b01ba6
6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents:
356
diff
changeset
|
2759 const char* less_equal, const char* less_equal_format, |
4d9884b01ba6
6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents:
356
diff
changeset
|
2760 const char* greater, const char* greater_format) |
0 | 2761 : Interface("COND_INTER"), |
415
4d9884b01ba6
6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents:
356
diff
changeset
|
2762 _equal(equal), _equal_format(equal_format), |
4d9884b01ba6
6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents:
356
diff
changeset
|
2763 _not_equal(not_equal), _not_equal_format(not_equal_format), |
4d9884b01ba6
6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents:
356
diff
changeset
|
2764 _less(less), _less_format(less_format), |
4d9884b01ba6
6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents:
356
diff
changeset
|
2765 _greater_equal(greater_equal), _greater_equal_format(greater_equal_format), |
4d9884b01ba6
6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents:
356
diff
changeset
|
2766 _less_equal(less_equal), _less_equal_format(less_equal_format), |
4d9884b01ba6
6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents:
356
diff
changeset
|
2767 _greater(greater), _greater_format(greater_format) { |
0 | 2768 } |
2769 CondInterface::~CondInterface() { | |
2770 // not owner of any character arrays | |
2771 } | |
2772 | |
2773 void CondInterface::dump() { | |
2774 output(stderr); | |
2775 } | |
2776 | |
2777 // Write info to output files | |
2778 void CondInterface::output(FILE *fp) { | |
2779 Interface::output(fp); | |
2780 if ( _equal != NULL ) fprintf(fp," equal == %s\n", _equal); | |
2781 if ( _not_equal != NULL ) fprintf(fp," not_equal == %s\n", _not_equal); | |
2782 if ( _less != NULL ) fprintf(fp," less == %s\n", _less); | |
2783 if ( _greater_equal != NULL ) fprintf(fp," greater_equal == %s\n", _greater_equal); | |
2784 if ( _less_equal != NULL ) fprintf(fp," less_equal == %s\n", _less_equal); | |
2785 if ( _greater != NULL ) fprintf(fp," greater == %s\n", _greater); | |
2786 // fprintf(fp,"\n"); | |
2787 } | |
2788 | |
2789 //------------------------------ConstructRule---------------------------------- | |
2790 ConstructRule::ConstructRule(char *cnstr) | |
2791 : _construct(cnstr) { | |
2792 } | |
2793 ConstructRule::~ConstructRule() { | |
2794 } | |
2795 | |
2796 void ConstructRule::dump() { | |
2797 output(stderr); | |
2798 } | |
2799 | |
2800 void ConstructRule::output(FILE *fp) { | |
2801 fprintf(fp,"\nConstruct Rule\n"); // Write to output files | |
2802 } | |
2803 | |
2804 | |
2805 //==============================Shared Forms=================================== | |
2806 //------------------------------AttributeForm---------------------------------- | |
2807 int AttributeForm::_insId = 0; // start counter at 0 | |
2808 int AttributeForm::_opId = 0; // start counter at 0 | |
2809 const char* AttributeForm::_ins_cost = "ins_cost"; // required name | |
2810 const char* AttributeForm::_op_cost = "op_cost"; // required name | |
2811 | |
2812 AttributeForm::AttributeForm(char *attr, int type, char *attrdef) | |
2813 : Form(Form::ATTR), _attrname(attr), _atype(type), _attrdef(attrdef) { | |
2814 if (type==OP_ATTR) { | |
2815 id = ++_opId; | |
2816 } | |
2817 else if (type==INS_ATTR) { | |
2818 id = ++_insId; | |
2819 } | |
2820 else assert( false,""); | |
2821 } | |
2822 AttributeForm::~AttributeForm() { | |
2823 } | |
2824 | |
2825 // Dynamic type check | |
2826 AttributeForm *AttributeForm::is_attribute() const { | |
2827 return (AttributeForm*)this; | |
2828 } | |
2829 | |
2830 | |
2831 // inlined // int AttributeForm::type() { return id;} | |
2832 | |
2833 void AttributeForm::dump() { | |
2834 output(stderr); | |
2835 } | |
2836 | |
2837 void AttributeForm::output(FILE *fp) { | |
2838 if( _attrname && _attrdef ) { | |
2839 fprintf(fp,"\n// AttributeForm \nstatic const int %s = %s;\n", | |
2840 _attrname, _attrdef); | |
2841 } | |
2842 else { | |
2843 fprintf(fp,"\n// AttributeForm missing name %s or definition %s\n", | |
2844 (_attrname?_attrname:""), (_attrdef?_attrdef:"") ); | |
2845 } | |
2846 } | |
2847 | |
2848 //------------------------------Component-------------------------------------- | |
2849 Component::Component(const char *name, const char *type, int usedef) | |
2850 : _name(name), _type(type), _usedef(usedef) { | |
2851 _ftype = Form::COMP; | |
2852 } | |
2853 Component::~Component() { | |
2854 } | |
2855 | |
2856 // True if this component is equal to the parameter. | |
2857 bool Component::is(int use_def_kill_enum) const { | |
2858 return (_usedef == use_def_kill_enum ? true : false); | |
2859 } | |
2860 // True if this component is used/def'd/kill'd as the parameter suggests. | |
2861 bool Component::isa(int use_def_kill_enum) const { | |
2862 return (_usedef & use_def_kill_enum) == use_def_kill_enum; | |
2863 } | |
2864 | |
2865 // Extend this component with additional use/def/kill behavior | |
2866 int Component::promote_use_def_info(int new_use_def) { | |
2867 _usedef |= new_use_def; | |
2868 | |
2869 return _usedef; | |
2870 } | |
2871 | |
2872 // Check the base type of this component, if it has one | |
2873 const char *Component::base_type(FormDict &globals) { | |
2874 const Form *frm = globals[_type]; | |
2875 if (frm == NULL) return NULL; | |
2876 OperandForm *op = frm->is_operand(); | |
2877 if (op == NULL) return NULL; | |
2878 if (op->ideal_only()) return op->_ident; | |
2879 return (char *)op->ideal_type(globals); | |
2880 } | |
2881 | |
2882 void Component::dump() { | |
2883 output(stderr); | |
2884 } | |
2885 | |
2886 void Component::output(FILE *fp) { | |
2887 fprintf(fp,"Component:"); // Write to output files | |
2888 fprintf(fp, " name = %s", _name); | |
2889 fprintf(fp, ", type = %s", _type); | |
6850 | 2890 assert(_usedef != 0, "unknown effect"); |
2891 fprintf(fp, ", use/def = %s\n", getUsedefName()); | |
0 | 2892 } |
2893 | |
2894 | |
2895 //------------------------------ComponentList--------------------------------- | |
2896 ComponentList::ComponentList() : NameList(), _matchcnt(0) { | |
2897 } | |
2898 ComponentList::~ComponentList() { | |
2899 // // This list may not own its elements if copied via assignment | |
2900 // Component *component; | |
2901 // for (reset(); (component = iter()) != NULL;) { | |
2902 // delete component; | |
2903 // } | |
2904 } | |
2905 | |
2906 void ComponentList::insert(Component *component, bool mflag) { | |
2907 NameList::addName((char *)component); | |
2908 if(mflag) _matchcnt++; | |
2909 } | |
2910 void ComponentList::insert(const char *name, const char *opType, int usedef, | |
2911 bool mflag) { | |
2912 Component * component = new Component(name, opType, usedef); | |
2913 insert(component, mflag); | |
2914 } | |
2915 Component *ComponentList::current() { return (Component*)NameList::current(); } | |
2916 Component *ComponentList::iter() { return (Component*)NameList::iter(); } | |
2917 Component *ComponentList::match_iter() { | |
2918 if(_iter < _matchcnt) return (Component*)NameList::iter(); | |
2919 return NULL; | |
2920 } | |
2921 Component *ComponentList::post_match_iter() { | |
2922 Component *comp = iter(); | |
2923 // At end of list? | |
2924 if ( comp == NULL ) { | |
2925 return comp; | |
2926 } | |
2927 // In post-match components? | |
2928 if (_iter > match_count()-1) { | |
2929 return comp; | |
2930 } | |
2931 | |
2932 return post_match_iter(); | |
2933 } | |
2934 | |
2935 void ComponentList::reset() { NameList::reset(); } | |
2936 int ComponentList::count() { return NameList::count(); } | |
2937 | |
2938 Component *ComponentList::operator[](int position) { | |
2939 // Shortcut complete iteration if there are not enough entries | |
2940 if (position >= count()) return NULL; | |
2941 | |
2942 int index = 0; | |
2943 Component *component = NULL; | |
2944 for (reset(); (component = iter()) != NULL;) { | |
2945 if (index == position) { | |
2946 return component; | |
2947 } | |
2948 ++index; | |
2949 } | |
2950 | |
2951 return NULL; | |
2952 } | |
2953 | |
2954 const Component *ComponentList::search(const char *name) { | |
2955 PreserveIter pi(this); | |
2956 reset(); | |
2957 for( Component *comp = NULL; ((comp = iter()) != NULL); ) { | |
2958 if( strcmp(comp->_name,name) == 0 ) return comp; | |
2959 } | |
2960 | |
2961 return NULL; | |
2962 } | |
2963 | |
2964 // Return number of USEs + number of DEFs | |
2965 // When there are no components, or the first component is a USE, | |
2966 // then we add '1' to hold a space for the 'result' operand. | |
2967 int ComponentList::num_operands() { | |
2968 PreserveIter pi(this); | |
2969 uint count = 1; // result operand | |
2970 uint position = 0; | |
2971 | |
2972 Component *component = NULL; | |
2973 for( reset(); (component = iter()) != NULL; ++position ) { | |
2974 if( component->isa(Component::USE) || | |
2975 ( position == 0 && (! component->isa(Component::DEF))) ) { | |
2976 ++count; | |
2977 } | |
2978 } | |
2979 | |
2980 return count; | |
2981 } | |
2982 | |
6850 | 2983 // Return zero-based position of operand 'name' in list; -1 if not in list. |
0 | 2984 // if parameter 'usedef' is ::USE, it will match USE, USE_DEF, ... |
6850 | 2985 int ComponentList::operand_position(const char *name, int usedef, Form *fm) { |
0 | 2986 PreserveIter pi(this); |
2987 int position = 0; | |
2988 int num_opnds = num_operands(); | |
2989 Component *component; | |
2990 Component* preceding_non_use = NULL; | |
2991 Component* first_def = NULL; | |
2992 for (reset(); (component = iter()) != NULL; ++position) { | |
2993 // When the first component is not a DEF, | |
2994 // leave space for the result operand! | |
2995 if ( position==0 && (! component->isa(Component::DEF)) ) { | |
2996 ++position; | |
2997 ++num_opnds; | |
2998 } | |
2999 if (strcmp(name, component->_name)==0 && (component->isa(usedef))) { | |
3000 // When the first entry in the component list is a DEF and a USE | |
3001 // Treat them as being separate, a DEF first, then a USE | |
3002 if( position==0 | |
3003 && usedef==Component::USE && component->isa(Component::DEF) ) { | |
3004 assert(position+1 < num_opnds, "advertised index in bounds"); | |
3005 return position+1; | |
3006 } else { | |
3007 if( preceding_non_use && strcmp(component->_name, preceding_non_use->_name) ) { | |
6850 | 3008 fprintf(stderr, "the name '%s(%s)' should not precede the name '%s(%s)'", |
3009 preceding_non_use->_name, preceding_non_use->getUsedefName(), | |
3010 name, component->getUsedefName()); | |
3011 if (fm && fm->is_instruction()) fprintf(stderr, "in form '%s'", fm->is_instruction()->_ident); | |
3012 if (fm && fm->is_operand()) fprintf(stderr, "in form '%s'", fm->is_operand()->_ident); | |
3013 fprintf(stderr, "\n"); | |
0 | 3014 } |
3015 if( position >= num_opnds ) { | |
6850 | 3016 fprintf(stderr, "the name '%s' is too late in its name list", name); |
3017 if (fm && fm->is_instruction()) fprintf(stderr, "in form '%s'", fm->is_instruction()->_ident); | |
3018 if (fm && fm->is_operand()) fprintf(stderr, "in form '%s'", fm->is_operand()->_ident); | |
3019 fprintf(stderr, "\n"); | |
0 | 3020 } |
3021 assert(position < num_opnds, "advertised index in bounds"); | |
3022 return position; | |
3023 } | |
3024 } | |
3025 if( component->isa(Component::DEF) | |
3026 && component->isa(Component::USE) ) { | |
3027 ++position; | |
3028 if( position != 1 ) --position; // only use two slots for the 1st USE_DEF | |
3029 } | |
3030 if( component->isa(Component::DEF) && !first_def ) { | |
3031 first_def = component; | |
3032 } | |
3033 if( !component->isa(Component::USE) && component != first_def ) { | |
3034 preceding_non_use = component; | |
3035 } else if( preceding_non_use && !strcmp(component->_name, preceding_non_use->_name) ) { | |
3036 preceding_non_use = NULL; | |
3037 } | |
3038 } | |
3039 return Not_in_list; | |
3040 } | |
3041 | |
3042 // Find position for this name, regardless of use/def information | |
3043 int ComponentList::operand_position(const char *name) { | |
3044 PreserveIter pi(this); | |
3045 int position = 0; | |
3046 Component *component; | |
3047 for (reset(); (component = iter()) != NULL; ++position) { | |
3048 // When the first component is not a DEF, | |
3049 // leave space for the result operand! | |
3050 if ( position==0 && (! component->isa(Component::DEF)) ) { | |
3051 ++position; | |
3052 } | |
3053 if (strcmp(name, component->_name)==0) { | |
3054 return position; | |
3055 } | |
3056 if( component->isa(Component::DEF) | |
3057 && component->isa(Component::USE) ) { | |
3058 ++position; | |
3059 if( position != 1 ) --position; // only use two slots for the 1st USE_DEF | |
3060 } | |
3061 } | |
3062 return Not_in_list; | |
3063 } | |
3064 | |
6850 | 3065 int ComponentList::operand_position_format(const char *name, Form *fm) { |
0 | 3066 PreserveIter pi(this); |
3067 int first_position = operand_position(name); | |
6850 | 3068 int use_position = operand_position(name, Component::USE, fm); |
0 | 3069 |
3070 return ((first_position < use_position) ? use_position : first_position); | |
3071 } | |
3072 | |
3073 int ComponentList::label_position() { | |
3074 PreserveIter pi(this); | |
3075 int position = 0; | |
3076 reset(); | |
3077 for( Component *comp; (comp = iter()) != NULL; ++position) { | |
3078 // When the first component is not a DEF, | |
3079 // leave space for the result operand! | |
3080 if ( position==0 && (! comp->isa(Component::DEF)) ) { | |
3081 ++position; | |
3082 } | |
3083 if (strcmp(comp->_type, "label")==0) { | |
3084 return position; | |
3085 } | |
3086 if( comp->isa(Component::DEF) | |
3087 && comp->isa(Component::USE) ) { | |
3088 ++position; | |
3089 if( position != 1 ) --position; // only use two slots for the 1st USE_DEF | |
3090 } | |
3091 } | |
3092 | |
3093 return -1; | |
3094 } | |
3095 | |
3096 int ComponentList::method_position() { | |
3097 PreserveIter pi(this); | |
3098 int position = 0; | |
3099 reset(); | |
3100 for( Component *comp; (comp = iter()) != NULL; ++position) { | |
3101 // When the first component is not a DEF, | |
3102 // leave space for the result operand! | |
3103 if ( position==0 && (! comp->isa(Component::DEF)) ) { | |
3104 ++position; | |
3105 } | |
3106 if (strcmp(comp->_type, "method")==0) { | |
3107 return position; | |
3108 } | |
3109 if( comp->isa(Component::DEF) | |
3110 && comp->isa(Component::USE) ) { | |
3111 ++position; | |
3112 if( position != 1 ) --position; // only use two slots for the 1st USE_DEF | |
3113 } | |
3114 } | |
3115 | |
3116 return -1; | |
3117 } | |
3118 | |
3119 void ComponentList::dump() { output(stderr); } | |
3120 | |
3121 void ComponentList::output(FILE *fp) { | |
3122 PreserveIter pi(this); | |
3123 fprintf(fp, "\n"); | |
3124 Component *component; | |
3125 for (reset(); (component = iter()) != NULL;) { | |
3126 component->output(fp); | |
3127 } | |
3128 fprintf(fp, "\n"); | |
3129 } | |
3130 | |
3131 //------------------------------MatchNode-------------------------------------- | |
3132 MatchNode::MatchNode(ArchDesc &ad, const char *result, const char *mexpr, | |
3133 const char *opType, MatchNode *lChild, MatchNode *rChild) | |
3134 : _AD(ad), _result(result), _name(mexpr), _opType(opType), | |
3135 _lChild(lChild), _rChild(rChild), _internalop(0), _numleaves(0), | |
3136 _commutative_id(0) { | |
3137 _numleaves = (lChild ? lChild->_numleaves : 0) | |
3138 + (rChild ? rChild->_numleaves : 0); | |
3139 } | |
3140 | |
3141 MatchNode::MatchNode(ArchDesc &ad, MatchNode& mnode) | |
3142 : _AD(ad), _result(mnode._result), _name(mnode._name), | |
3143 _opType(mnode._opType), _lChild(mnode._lChild), _rChild(mnode._rChild), | |
3144 _internalop(0), _numleaves(mnode._numleaves), | |
3145 _commutative_id(mnode._commutative_id) { | |
3146 } | |
3147 | |
3148 MatchNode::MatchNode(ArchDesc &ad, MatchNode& mnode, int clone) | |
3149 : _AD(ad), _result(mnode._result), _name(mnode._name), | |
3150 _opType(mnode._opType), | |
3151 _internalop(0), _numleaves(mnode._numleaves), | |
3152 _commutative_id(mnode._commutative_id) { | |
3153 if (mnode._lChild) { | |
3154 _lChild = new MatchNode(ad, *mnode._lChild, clone); | |
3155 } else { | |
3156 _lChild = NULL; | |
3157 } | |
3158 if (mnode._rChild) { | |
3159 _rChild = new MatchNode(ad, *mnode._rChild, clone); | |
3160 } else { | |
3161 _rChild = NULL; | |
3162 } | |
3163 } | |
3164 | |
3165 MatchNode::~MatchNode() { | |
3166 // // This node may not own its children if copied via assignment | |
3167 // if( _lChild ) delete _lChild; | |
3168 // if( _rChild ) delete _rChild; | |
3169 } | |
3170 | |
3171 bool MatchNode::find_type(const char *type, int &position) const { | |
3172 if ( (_lChild != NULL) && (_lChild->find_type(type, position)) ) return true; | |
3173 if ( (_rChild != NULL) && (_rChild->find_type(type, position)) ) return true; | |
3174 | |
3175 if (strcmp(type,_opType)==0) { | |
3176 return true; | |
3177 } else { | |
3178 ++position; | |
3179 } | |
3180 return false; | |
3181 } | |
3182 | |
3183 // Recursive call collecting info on top-level operands, not transitive. | |
3184 // Implementation does not modify state of internal structures. | |
603
dbbe28fc66b5
6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents:
602
diff
changeset
|
3185 void MatchNode::append_components(FormDict& locals, ComponentList& components, |
dbbe28fc66b5
6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents:
602
diff
changeset
|
3186 bool def_flag) const { |
dbbe28fc66b5
6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents:
602
diff
changeset
|
3187 int usedef = def_flag ? Component::DEF : Component::USE; |
0 | 3188 FormDict &globals = _AD.globalNames(); |
3189 | |
3190 assert (_name != NULL, "MatchNode::build_components encountered empty node\n"); | |
3191 // Base case | |
3192 if (_lChild==NULL && _rChild==NULL) { | |
3193 // If _opType is not an operation, do not build a component for it ##### | |
3194 const Form *f = globals[_opType]; | |
3195 if( f != NULL ) { | |
3196 // Add non-ideals that are operands, operand-classes, | |
3197 if( ! f->ideal_only() | |
3198 && (f->is_opclass() || f->is_operand()) ) { | |
3199 components.insert(_name, _opType, usedef, true); | |
3200 } | |
3201 } | |
3202 return; | |
3203 } | |
3204 // Promote results of "Set" to DEF | |
603
dbbe28fc66b5
6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents:
602
diff
changeset
|
3205 bool tmpdef_flag = (!strcmp(_opType, "Set")) ? true : false; |
dbbe28fc66b5
6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents:
602
diff
changeset
|
3206 if (_lChild) _lChild->append_components(locals, components, tmpdef_flag); |
dbbe28fc66b5
6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents:
602
diff
changeset
|
3207 tmpdef_flag = false; // only applies to component immediately following 'Set' |
dbbe28fc66b5
6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents:
602
diff
changeset
|
3208 if (_rChild) _rChild->append_components(locals, components, tmpdef_flag); |
0 | 3209 } |
3210 | |
3211 // Find the n'th base-operand in the match node, | |
3212 // recursively investigates match rules of user-defined operands. | |
3213 // | |
3214 // Implementation does not modify state of internal structures since they | |
3215 // can be shared. | |
3216 bool MatchNode::base_operand(uint &position, FormDict &globals, | |
3217 const char * &result, const char * &name, | |
3218 const char * &opType) const { | |
3219 assert (_name != NULL, "MatchNode::base_operand encountered empty node\n"); | |
3220 // Base case | |
3221 if (_lChild==NULL && _rChild==NULL) { | |
3222 // Check for special case: "Universe", "label" | |
3223 if (strcmp(_opType,"Universe") == 0 || strcmp(_opType,"label")==0 ) { | |
3224 if (position == 0) { | |
3225 result = _result; | |
3226 name = _name; | |
3227 opType = _opType; | |
3228 return 1; | |
3229 } else { | |
3230 -- position; | |
3231 return 0; | |
3232 } | |
3233 } | |
3234 | |
3235 const Form *form = globals[_opType]; | |
3236 MatchNode *matchNode = NULL; | |
3237 // Check for user-defined type | |
3238 if (form) { | |
3239 // User operand or instruction? | |
3240 OperandForm *opForm = form->is_operand(); | |
3241 InstructForm *inForm = form->is_instruction(); | |
3242 if ( opForm ) { | |
3243 matchNode = (MatchNode*)opForm->_matrule; | |
3244 } else if ( inForm ) { | |
3245 matchNode = (MatchNode*)inForm->_matrule; | |
3246 } | |
3247 } | |
3248 // if this is user-defined, recurse on match rule | |
3249 // User-defined operand and instruction forms have a match-rule. | |
3250 if (matchNode) { | |
3251 return (matchNode->base_operand(position,globals,result,name,opType)); | |
3252 } else { | |
3253 // Either not a form, or a system-defined form (no match rule). | |
3254 if (position==0) { | |
3255 result = _result; | |
3256 name = _name; | |
3257 opType = _opType; | |
3258 return 1; | |
3259 } else { | |
3260 --position; | |
3261 return 0; | |
3262 } | |
3263 } | |
3264 | |
3265 } else { | |
3266 // Examine the left child and right child as well | |
3267 if (_lChild) { | |
3268 if (_lChild->base_operand(position, globals, result, name, opType)) | |
3269 return 1; | |
3270 } | |
3271 | |
3272 if (_rChild) { | |
3273 if (_rChild->base_operand(position, globals, result, name, opType)) | |
3274 return 1; | |
3275 } | |
3276 } | |
3277 | |
3278 return 0; | |
3279 } | |
3280 | |
3281 // Recursive call on all operands' match rules in my match rule. | |
3282 uint MatchNode::num_consts(FormDict &globals) const { | |
3283 uint index = 0; | |
3284 uint num_consts = 0; | |
3285 const char *result; | |
3286 const char *name; | |
3287 const char *opType; | |
3288 | |
3289 for (uint position = index; | |
3290 base_operand(position,globals,result,name,opType); position = index) { | |
3291 ++index; | |
3292 if( ideal_to_const_type(opType) ) num_consts++; | |
3293 } | |
3294 | |
3295 return num_consts; | |
3296 } | |
3297 | |
3298 // Recursive call on all operands' match rules in my match rule. | |
3299 // Constants in match rule subtree with specified type | |
3300 uint MatchNode::num_consts(FormDict &globals, Form::DataType type) const { | |
3301 uint index = 0; | |
3302 uint num_consts = 0; | |
3303 const char *result; | |
3304 const char *name; | |
3305 const char *opType; | |
3306 | |
3307 for (uint position = index; | |
3308 base_operand(position,globals,result,name,opType); position = index) { | |
3309 ++index; | |
3310 if( ideal_to_const_type(opType) == type ) num_consts++; | |
3311 } | |
3312 | |
3313 return num_consts; | |
3314 } | |
3315 | |
3316 // Recursive call on all operands' match rules in my match rule. | |
3317 uint MatchNode::num_const_ptrs(FormDict &globals) const { | |
3318 return num_consts( globals, Form::idealP ); | |
3319 } | |
3320 | |
3321 bool MatchNode::sets_result() const { | |
3322 return ( (strcmp(_name,"Set") == 0) ? true : false ); | |
3323 } | |
3324 | |
3325 const char *MatchNode::reduce_right(FormDict &globals) const { | |
3326 // If there is no right reduction, return NULL. | |
3327 const char *rightStr = NULL; | |
3328 | |
3329 // If we are a "Set", start from the right child. | |
3330 const MatchNode *const mnode = sets_result() ? | |
6850 | 3331 (const MatchNode *)this->_rChild : |
3332 (const MatchNode *)this; | |
0 | 3333 |
3334 // If our right child exists, it is the right reduction | |
3335 if ( mnode->_rChild ) { | |
3336 rightStr = mnode->_rChild->_internalop ? mnode->_rChild->_internalop | |
3337 : mnode->_rChild->_opType; | |
3338 } | |
3339 // Else, May be simple chain rule: (Set dst operand_form), rightStr=NULL; | |
3340 return rightStr; | |
3341 } | |
3342 | |
3343 const char *MatchNode::reduce_left(FormDict &globals) const { | |
3344 // If there is no left reduction, return NULL. | |
3345 const char *leftStr = NULL; | |
3346 | |
3347 // If we are a "Set", start from the right child. | |
3348 const MatchNode *const mnode = sets_result() ? | |
6850 | 3349 (const MatchNode *)this->_rChild : |
3350 (const MatchNode *)this; | |
0 | 3351 |
3352 // If our left child exists, it is the left reduction | |
3353 if ( mnode->_lChild ) { | |
3354 leftStr = mnode->_lChild->_internalop ? mnode->_lChild->_internalop | |
3355 : mnode->_lChild->_opType; | |
3356 } else { | |
3357 // May be simple chain rule: (Set dst operand_form_source) | |
3358 if ( sets_result() ) { | |
3359 OperandForm *oper = globals[mnode->_opType]->is_operand(); | |
3360 if( oper ) { | |
3361 leftStr = mnode->_opType; | |
3362 } | |
3363 } | |
3364 } | |
3365 return leftStr; | |
3366 } | |
3367 | |
3368 //------------------------------count_instr_names------------------------------ | |
3369 // Count occurrences of operands names in the leaves of the instruction | |
3370 // match rule. | |
3371 void MatchNode::count_instr_names( Dict &names ) { | |
3372 if( !this ) return; | |
3373 if( _lChild ) _lChild->count_instr_names(names); | |
3374 if( _rChild ) _rChild->count_instr_names(names); | |
3375 if( !_lChild && !_rChild ) { | |
3376 uintptr_t cnt = (uintptr_t)names[_name]; | |
3377 cnt++; // One more name found | |
3378 names.Insert(_name,(void*)cnt); | |
3379 } | |
3380 } | |
3381 | |
3382 //------------------------------build_instr_pred------------------------------- | |
3383 // Build a path to 'name' in buf. Actually only build if cnt is zero, so we | |
3384 // can skip some leading instances of 'name'. | |
3385 int MatchNode::build_instr_pred( char *buf, const char *name, int cnt ) { | |
3386 if( _lChild ) { | |
3387 if( !cnt ) strcpy( buf, "_kids[0]->" ); | |
3388 cnt = _lChild->build_instr_pred( buf+strlen(buf), name, cnt ); | |
3389 if( cnt < 0 ) return cnt; // Found it, all done | |
3390 } | |
3391 if( _rChild ) { | |
3392 if( !cnt ) strcpy( buf, "_kids[1]->" ); | |
3393 cnt = _rChild->build_instr_pred( buf+strlen(buf), name, cnt ); | |
3394 if( cnt < 0 ) return cnt; // Found it, all done | |
3395 } | |
3396 if( !_lChild && !_rChild ) { // Found a leaf | |
3397 // Wrong name? Give up... | |
3398 if( strcmp(name,_name) ) return cnt; | |
3399 if( !cnt ) strcpy(buf,"_leaf"); | |
3400 return cnt-1; | |
3401 } | |
3402 return cnt; | |
3403 } | |
3404 | |
3405 | |
3406 //------------------------------build_internalop------------------------------- | |
3407 // Build string representation of subtree | |
3408 void MatchNode::build_internalop( ) { | |
3409 char *iop, *subtree; | |
3410 const char *lstr, *rstr; | |
3411 // Build string representation of subtree | |
3412 // Operation lchildType rchildType | |
3413 int len = (int)strlen(_opType) + 4; | |
3414 lstr = (_lChild) ? ((_lChild->_internalop) ? | |
3415 _lChild->_internalop : _lChild->_opType) : ""; | |
3416 rstr = (_rChild) ? ((_rChild->_internalop) ? | |
3417 _rChild->_internalop : _rChild->_opType) : ""; | |
3418 len += (int)strlen(lstr) + (int)strlen(rstr); | |
3419 subtree = (char *)malloc(len); | |
3420 sprintf(subtree,"_%s_%s_%s", _opType, lstr, rstr); | |
3421 // Hash the subtree string in _internalOps; if a name exists, use it | |
3422 iop = (char *)_AD._internalOps[subtree]; | |
3423 // Else create a unique name, and add it to the hash table | |
3424 if (iop == NULL) { | |
3425 iop = subtree; | |
3426 _AD._internalOps.Insert(subtree, iop); | |
3427 _AD._internalOpNames.addName(iop); | |
3428 _AD._internalMatch.Insert(iop, this); | |
3429 } | |
3430 // Add the internal operand name to the MatchNode | |
3431 _internalop = iop; | |
3432 _result = iop; | |
3433 } | |
3434 | |
3435 | |
3436 void MatchNode::dump() { | |
3437 output(stderr); | |
3438 } | |
3439 | |
3440 void MatchNode::output(FILE *fp) { | |
3441 if (_lChild==0 && _rChild==0) { | |
3442 fprintf(fp," %s",_name); // operand | |
3443 } | |
3444 else { | |
3445 fprintf(fp," (%s ",_name); // " (opcodeName " | |
3446 if(_lChild) _lChild->output(fp); // left operand | |
3447 if(_rChild) _rChild->output(fp); // right operand | |
3448 fprintf(fp,")"); // ")" | |
3449 } | |
3450 } | |
3451 | |
3452 int MatchNode::needs_ideal_memory_edge(FormDict &globals) const { | |
3453 static const char *needs_ideal_memory_list[] = { | |
6848
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6823
diff
changeset
|
3454 "StoreI","StoreL","StoreP","StoreN","StoreNKlass","StoreD","StoreF" , |
0 | 3455 "StoreB","StoreC","Store" ,"StoreFP", |
6849 | 3456 "LoadI", "LoadL", "LoadP" ,"LoadN", "LoadD" ,"LoadF" , |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6143
diff
changeset
|
3457 "LoadB" , "LoadUB", "LoadUS" ,"LoadS" ,"Load" , |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6143
diff
changeset
|
3458 "StoreVector", "LoadVector", |
164
c436414a719e
6703890: Compressed Oops: add LoadNKlass node to generate narrow oops (32-bits) compare instructions
kvn
parents:
113
diff
changeset
|
3459 "LoadRange", "LoadKlass", "LoadNKlass", "LoadL_unaligned", "LoadD_unaligned", |
6143 | 3460 "LoadPLocked", |
420
a1980da045cc
6462850: generate biased locking code in C2 ideal graph
kvn
parents:
415
diff
changeset
|
3461 "StorePConditional", "StoreIConditional", "StoreLConditional", |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
3462 "CompareAndSwapI", "CompareAndSwapL", "CompareAndSwapP", "CompareAndSwapN", |
0 | 3463 "StoreCM", |
6795
7eca5de9e0b6
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
6725
diff
changeset
|
3464 "ClearArray", |
7eca5de9e0b6
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
6725
diff
changeset
|
3465 "GetAndAddI", "GetAndSetI", "GetAndSetP", |
7eca5de9e0b6
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
6725
diff
changeset
|
3466 "GetAndAddL", "GetAndSetL", "GetAndSetN", |
0 | 3467 }; |
3468 int cnt = sizeof(needs_ideal_memory_list)/sizeof(char*); | |
3854 | 3469 if( strcmp(_opType,"PrefetchRead")==0 || |
3470 strcmp(_opType,"PrefetchWrite")==0 || | |
3471 strcmp(_opType,"PrefetchAllocation")==0 ) | |
0 | 3472 return 1; |
3473 if( _lChild ) { | |
3474 const char *opType = _lChild->_opType; | |
3475 for( int i=0; i<cnt; i++ ) | |
3476 if( strcmp(opType,needs_ideal_memory_list[i]) == 0 ) | |
3477 return 1; | |
3478 if( _lChild->needs_ideal_memory_edge(globals) ) | |
3479 return 1; | |
3480 } | |
3481 if( _rChild ) { | |
3482 const char *opType = _rChild->_opType; | |
3483 for( int i=0; i<cnt; i++ ) | |
3484 if( strcmp(opType,needs_ideal_memory_list[i]) == 0 ) | |
3485 return 1; | |
3486 if( _rChild->needs_ideal_memory_edge(globals) ) | |
3487 return 1; | |
3488 } | |
3489 | |
3490 return 0; | |
3491 } | |
3492 | |
3493 // TRUE if defines a derived oop, and so needs a base oop edge present | |
3494 // post-matching. | |
3495 int MatchNode::needs_base_oop_edge() const { | |
3496 if( !strcmp(_opType,"AddP") ) return 1; | |
3497 if( strcmp(_opType,"Set") ) return 0; | |
3498 return !strcmp(_rChild->_opType,"AddP"); | |
3499 } | |
3500 | |
3501 int InstructForm::needs_base_oop_edge(FormDict &globals) const { | |
3502 if( is_simple_chain_rule(globals) ) { | |
3503 const char *src = _matrule->_rChild->_opType; | |
3504 OperandForm *src_op = globals[src]->is_operand(); | |
3505 assert( src_op, "Not operand class of chain rule" ); | |
3506 return src_op->_matrule ? src_op->_matrule->needs_base_oop_edge() : 0; | |
3507 } // Else check instruction | |
3508 | |
3509 return _matrule ? _matrule->needs_base_oop_edge() : 0; | |
3510 } | |
3511 | |
3512 | |
3513 //-------------------------cisc spilling methods------------------------------- | |
3514 // helper routines and methods for detecting cisc-spilling instructions | |
3515 //-------------------------cisc_spill_merge------------------------------------ | |
3516 int MatchNode::cisc_spill_merge(int left_spillable, int right_spillable) { | |
3517 int cisc_spillable = Maybe_cisc_spillable; | |
3518 | |
3519 // Combine results of left and right checks | |
3520 if( (left_spillable == Maybe_cisc_spillable) && (right_spillable == Maybe_cisc_spillable) ) { | |
3521 // neither side is spillable, nor prevents cisc spilling | |
3522 cisc_spillable = Maybe_cisc_spillable; | |
3523 } | |
3524 else if( (left_spillable == Maybe_cisc_spillable) && (right_spillable > Maybe_cisc_spillable) ) { | |
3525 // right side is spillable | |
3526 cisc_spillable = right_spillable; | |
3527 } | |
3528 else if( (right_spillable == Maybe_cisc_spillable) && (left_spillable > Maybe_cisc_spillable) ) { | |
3529 // left side is spillable | |
3530 cisc_spillable = left_spillable; | |
3531 } | |
3532 else if( (left_spillable == Not_cisc_spillable) || (right_spillable == Not_cisc_spillable) ) { | |
3533 // left or right prevents cisc spilling this instruction | |
3534 cisc_spillable = Not_cisc_spillable; | |
3535 } | |
3536 else { | |
3537 // Only allow one to spill | |
3538 cisc_spillable = Not_cisc_spillable; | |
3539 } | |
3540 | |
3541 return cisc_spillable; | |
3542 } | |
3543 | |
3544 //-------------------------root_ops_match-------------------------------------- | |
3545 bool static root_ops_match(FormDict &globals, const char *op1, const char *op2) { | |
3546 // Base Case: check that the current operands/operations match | |
3547 assert( op1, "Must have op's name"); | |
3548 assert( op2, "Must have op's name"); | |
3549 const Form *form1 = globals[op1]; | |
3550 const Form *form2 = globals[op2]; | |
3551 | |
3552 return (form1 == form2); | |
3553 } | |
3554 | |
603
dbbe28fc66b5
6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents:
602
diff
changeset
|
3555 //-------------------------cisc_spill_match_node------------------------------- |
0 | 3556 // Recursively check two MatchRules for legal conversion via cisc-spilling |
603
dbbe28fc66b5
6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents:
602
diff
changeset
|
3557 int MatchNode::cisc_spill_match(FormDict& globals, RegisterForm* registers, MatchNode* mRule2, const char* &operand, const char* ®_type) { |
0 | 3558 int cisc_spillable = Maybe_cisc_spillable; |
3559 int left_spillable = Maybe_cisc_spillable; | |
3560 int right_spillable = Maybe_cisc_spillable; | |
3561 | |
3562 // Check that each has same number of operands at this level | |
3563 if( (_lChild && !(mRule2->_lChild)) || (_rChild && !(mRule2->_rChild)) ) | |
3564 return Not_cisc_spillable; | |
3565 | |
3566 // Base Case: check that the current operands/operations match | |
3567 // or are CISC spillable | |
3568 assert( _opType, "Must have _opType"); | |
3569 assert( mRule2->_opType, "Must have _opType"); | |
3570 const Form *form = globals[_opType]; | |
3571 const Form *form2 = globals[mRule2->_opType]; | |
3572 if( form == form2 ) { | |
3573 cisc_spillable = Maybe_cisc_spillable; | |
3574 } else { | |
3575 const InstructForm *form2_inst = form2 ? form2->is_instruction() : NULL; | |
3576 const char *name_left = mRule2->_lChild ? mRule2->_lChild->_opType : NULL; | |
3577 const char *name_right = mRule2->_rChild ? mRule2->_rChild->_opType : NULL; | |
624 | 3578 DataType data_type = Form::none; |
3579 if (form->is_operand()) { | |
3580 // Make sure the loadX matches the type of the reg | |
3581 data_type = form->ideal_to_Reg_type(form->is_operand()->ideal_type(globals)); | |
3582 } | |
0 | 3583 // Detect reg vs (loadX memory) |
3584 if( form->is_cisc_reg(globals) | |
3585 && form2_inst | |
624 | 3586 && data_type != Form::none |
3587 && (is_load_from_memory(mRule2->_opType) == data_type) // reg vs. (load memory) | |
0 | 3588 && (name_left != NULL) // NOT (load) |
3589 && (name_right == NULL) ) { // NOT (load memory foo) | |
3590 const Form *form2_left = name_left ? globals[name_left] : NULL; | |
3591 if( form2_left && form2_left->is_cisc_mem(globals) ) { | |
3592 cisc_spillable = Is_cisc_spillable; | |
3593 operand = _name; | |
3594 reg_type = _result; | |
3595 return Is_cisc_spillable; | |
3596 } else { | |
3597 cisc_spillable = Not_cisc_spillable; | |
3598 } | |
3599 } | |
3600 // Detect reg vs memory | |
3601 else if( form->is_cisc_reg(globals) && form2->is_cisc_mem(globals) ) { | |
3602 cisc_spillable = Is_cisc_spillable; | |
3603 operand = _name; | |
3604 reg_type = _result; | |
3605 return Is_cisc_spillable; | |
3606 } else { | |
3607 cisc_spillable = Not_cisc_spillable; | |
3608 } | |
3609 } | |
3610 | |
3611 // If cisc is still possible, check rest of tree | |
3612 if( cisc_spillable == Maybe_cisc_spillable ) { | |
3613 // Check that each has same number of operands at this level | |
3614 if( (_lChild && !(mRule2->_lChild)) || (_rChild && !(mRule2->_rChild)) ) return Not_cisc_spillable; | |
3615 | |
3616 // Check left operands | |
3617 if( (_lChild == NULL) && (mRule2->_lChild == NULL) ) { | |
3618 left_spillable = Maybe_cisc_spillable; | |
3619 } else { | |
3620 left_spillable = _lChild->cisc_spill_match(globals, registers, mRule2->_lChild, operand, reg_type); | |
3621 } | |
3622 | |
3623 // Check right operands | |
3624 if( (_rChild == NULL) && (mRule2->_rChild == NULL) ) { | |
3625 right_spillable = Maybe_cisc_spillable; | |
3626 } else { | |
3627 right_spillable = _rChild->cisc_spill_match(globals, registers, mRule2->_rChild, operand, reg_type); | |
3628 } | |
3629 | |
3630 // Combine results of left and right checks | |
3631 cisc_spillable = cisc_spill_merge(left_spillable, right_spillable); | |
3632 } | |
3633 | |
3634 return cisc_spillable; | |
3635 } | |
3636 | |
603
dbbe28fc66b5
6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents:
602
diff
changeset
|
3637 //---------------------------cisc_spill_match_rule------------------------------ |
0 | 3638 // Recursively check two MatchRules for legal conversion via cisc-spilling |
3639 // This method handles the root of Match tree, | |
3640 // general recursive checks done in MatchNode | |
603
dbbe28fc66b5
6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents:
602
diff
changeset
|
3641 int MatchRule::matchrule_cisc_spill_match(FormDict& globals, RegisterForm* registers, |
dbbe28fc66b5
6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents:
602
diff
changeset
|
3642 MatchRule* mRule2, const char* &operand, |
dbbe28fc66b5
6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents:
602
diff
changeset
|
3643 const char* ®_type) { |
0 | 3644 int cisc_spillable = Maybe_cisc_spillable; |
3645 int left_spillable = Maybe_cisc_spillable; | |
3646 int right_spillable = Maybe_cisc_spillable; | |
3647 | |
3648 // Check that each sets a result | |
3649 if( !(sets_result() && mRule2->sets_result()) ) return Not_cisc_spillable; | |
3650 // Check that each has same number of operands at this level | |
3651 if( (_lChild && !(mRule2->_lChild)) || (_rChild && !(mRule2->_rChild)) ) return Not_cisc_spillable; | |
3652 | |
3653 // Check left operands: at root, must be target of 'Set' | |
3654 if( (_lChild == NULL) || (mRule2->_lChild == NULL) ) { | |
3655 left_spillable = Not_cisc_spillable; | |
3656 } else { | |
3657 // Do not support cisc-spilling instruction's target location | |
3658 if( root_ops_match(globals, _lChild->_opType, mRule2->_lChild->_opType) ) { | |
3659 left_spillable = Maybe_cisc_spillable; | |
3660 } else { | |
3661 left_spillable = Not_cisc_spillable; | |
3662 } | |
3663 } | |
3664 | |
3665 // Check right operands: recursive walk to identify reg->mem operand | |
3666 if( (_rChild == NULL) && (mRule2->_rChild == NULL) ) { | |
3667 right_spillable = Maybe_cisc_spillable; | |
3668 } else { | |
3669 right_spillable = _rChild->cisc_spill_match(globals, registers, mRule2->_rChild, operand, reg_type); | |
3670 } | |
3671 | |
3672 // Combine results of left and right checks | |
3673 cisc_spillable = cisc_spill_merge(left_spillable, right_spillable); | |
3674 | |
3675 return cisc_spillable; | |
3676 } | |
3677 | |
3678 //----------------------------- equivalent ------------------------------------ | |
3679 // Recursively check to see if two match rules are equivalent. | |
3680 // This rule handles the root. | |
603
dbbe28fc66b5
6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents:
602
diff
changeset
|
3681 bool MatchRule::equivalent(FormDict &globals, MatchNode *mRule2) { |
0 | 3682 // Check that each sets a result |
3683 if (sets_result() != mRule2->sets_result()) { | |
3684 return false; | |
3685 } | |
3686 | |
3687 // Check that the current operands/operations match | |
3688 assert( _opType, "Must have _opType"); | |
3689 assert( mRule2->_opType, "Must have _opType"); | |
3690 const Form *form = globals[_opType]; | |
3691 const Form *form2 = globals[mRule2->_opType]; | |
3692 if( form != form2 ) { | |
3693 return false; | |
3694 } | |
3695 | |
3696 if (_lChild ) { | |
3697 if( !_lChild->equivalent(globals, mRule2->_lChild) ) | |
3698 return false; | |
3699 } else if (mRule2->_lChild) { | |
3700 return false; // I have NULL left child, mRule2 has non-NULL left child. | |
3701 } | |
3702 | |
3703 if (_rChild ) { | |
3704 if( !_rChild->equivalent(globals, mRule2->_rChild) ) | |
3705 return false; | |
3706 } else if (mRule2->_rChild) { | |
3707 return false; // I have NULL right child, mRule2 has non-NULL right child. | |
3708 } | |
3709 | |
3710 // We've made it through the gauntlet. | |
3711 return true; | |
3712 } | |
3713 | |
3714 //----------------------------- equivalent ------------------------------------ | |
3715 // Recursively check to see if two match rules are equivalent. | |
3716 // This rule handles the operands. | |
3717 bool MatchNode::equivalent(FormDict &globals, MatchNode *mNode2) { | |
3718 if( !mNode2 ) | |
3719 return false; | |
3720 | |
3721 // Check that the current operands/operations match | |
3722 assert( _opType, "Must have _opType"); | |
3723 assert( mNode2->_opType, "Must have _opType"); | |
3724 const Form *form = globals[_opType]; | |
3725 const Form *form2 = globals[mNode2->_opType]; | |
3839 | 3726 if( form != form2 ) { |
3727 return false; | |
3728 } | |
3729 | |
3730 // Check that their children also match | |
3731 if (_lChild ) { | |
3732 if( !_lChild->equivalent(globals, mNode2->_lChild) ) | |
3733 return false; | |
3734 } else if (mNode2->_lChild) { | |
3735 return false; // I have NULL left child, mNode2 has non-NULL left child. | |
3736 } | |
3737 | |
3738 if (_rChild ) { | |
3739 if( !_rChild->equivalent(globals, mNode2->_rChild) ) | |
3740 return false; | |
3741 } else if (mNode2->_rChild) { | |
3742 return false; // I have NULL right child, mNode2 has non-NULL right child. | |
3743 } | |
3744 | |
3745 // We've made it through the gauntlet. | |
3746 return true; | |
0 | 3747 } |
3748 | |
3749 //-------------------------- has_commutative_op ------------------------------- | |
3750 // Recursively check for commutative operations with subtree operands | |
3751 // which could be swapped. | |
3752 void MatchNode::count_commutative_op(int& count) { | |
3753 static const char *commut_op_list[] = { | |
3754 "AddI","AddL","AddF","AddD", | |
3755 "AndI","AndL", | |
3756 "MaxI","MinI", | |
3757 "MulI","MulL","MulF","MulD", | |
3758 "OrI" ,"OrL" , | |
3759 "XorI","XorL" | |
3760 }; | |
3761 int cnt = sizeof(commut_op_list)/sizeof(char*); | |
3762 | |
3763 if( _lChild && _rChild && (_lChild->_lChild || _rChild->_lChild) ) { | |
3764 // Don't swap if right operand is an immediate constant. | |
3765 bool is_const = false; | |
3766 if( _rChild->_lChild == NULL && _rChild->_rChild == NULL ) { | |
3767 FormDict &globals = _AD.globalNames(); | |
3768 const Form *form = globals[_rChild->_opType]; | |
3769 if ( form ) { | |
3770 OperandForm *oper = form->is_operand(); | |
3771 if( oper && oper->interface_type(globals) == Form::constant_interface ) | |
3772 is_const = true; | |
3773 } | |
3774 } | |
3775 if( !is_const ) { | |
3776 for( int i=0; i<cnt; i++ ) { | |
3777 if( strcmp(_opType, commut_op_list[i]) == 0 ) { | |
3778 count++; | |
3779 _commutative_id = count; // id should be > 0 | |
3780 break; | |
3781 } | |
3782 } | |
3783 } | |
3784 } | |
3785 if( _lChild ) | |
3786 _lChild->count_commutative_op(count); | |
3787 if( _rChild ) | |
3788 _rChild->count_commutative_op(count); | |
3789 } | |
3790 | |
3791 //-------------------------- swap_commutative_op ------------------------------ | |
3792 // Recursively swap specified commutative operation with subtree operands. | |
3793 void MatchNode::swap_commutative_op(bool atroot, int id) { | |
3794 if( _commutative_id == id ) { // id should be > 0 | |
3795 assert(_lChild && _rChild && (_lChild->_lChild || _rChild->_lChild ), | |
3796 "not swappable operation"); | |
3797 MatchNode* tmp = _lChild; | |
3798 _lChild = _rChild; | |
3799 _rChild = tmp; | |
3800 // Don't exit here since we need to build internalop. | |
3801 } | |
3802 | |
3803 bool is_set = ( strcmp(_opType, "Set") == 0 ); | |
3804 if( _lChild ) | |
3805 _lChild->swap_commutative_op(is_set, id); | |
3806 if( _rChild ) | |
3807 _rChild->swap_commutative_op(is_set, id); | |
3808 | |
3809 // If not the root, reduce this subtree to an internal operand | |
3810 if( !atroot && (_lChild || _rChild) ) { | |
3811 build_internalop(); | |
3812 } | |
3813 } | |
3814 | |
3815 //-------------------------- swap_commutative_op ------------------------------ | |
3816 // Recursively swap specified commutative operation with subtree operands. | |
603
dbbe28fc66b5
6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents:
602
diff
changeset
|
3817 void MatchRule::matchrule_swap_commutative_op(const char* instr_ident, int count, int& match_rules_cnt) { |
0 | 3818 assert(match_rules_cnt < 100," too many match rule clones"); |
3819 // Clone | |
3820 MatchRule* clone = new MatchRule(_AD, this); | |
3821 // Swap operands of commutative operation | |
3822 ((MatchNode*)clone)->swap_commutative_op(true, count); | |
3823 char* buf = (char*) malloc(strlen(instr_ident) + 4); | |
3824 sprintf(buf, "%s_%d", instr_ident, match_rules_cnt++); | |
3825 clone->_result = buf; | |
3826 | |
3827 clone->_next = this->_next; | |
3828 this-> _next = clone; | |
3829 if( (--count) > 0 ) { | |
603
dbbe28fc66b5
6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents:
602
diff
changeset
|
3830 this-> matchrule_swap_commutative_op(instr_ident, count, match_rules_cnt); |
dbbe28fc66b5
6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents:
602
diff
changeset
|
3831 clone->matchrule_swap_commutative_op(instr_ident, count, match_rules_cnt); |
0 | 3832 } |
3833 } | |
3834 | |
3835 //------------------------------MatchRule-------------------------------------- | |
3836 MatchRule::MatchRule(ArchDesc &ad) | |
3837 : MatchNode(ad), _depth(0), _construct(NULL), _numchilds(0) { | |
3838 _next = NULL; | |
3839 } | |
3840 | |
3841 MatchRule::MatchRule(ArchDesc &ad, MatchRule* mRule) | |
3842 : MatchNode(ad, *mRule, 0), _depth(mRule->_depth), | |
3843 _construct(mRule->_construct), _numchilds(mRule->_numchilds) { | |
3844 _next = NULL; | |
3845 } | |
3846 | |
3847 MatchRule::MatchRule(ArchDesc &ad, MatchNode* mroot, int depth, char *cnstr, | |
3848 int numleaves) | |
3849 : MatchNode(ad,*mroot), _depth(depth), _construct(cnstr), | |
3850 _numchilds(0) { | |
3851 _next = NULL; | |
3852 mroot->_lChild = NULL; | |
3853 mroot->_rChild = NULL; | |
3854 delete mroot; | |
3855 _numleaves = numleaves; | |
3856 _numchilds = (_lChild ? 1 : 0) + (_rChild ? 1 : 0); | |
3857 } | |
3858 MatchRule::~MatchRule() { | |
3859 } | |
3860 | |
3861 // Recursive call collecting info on top-level operands, not transitive. | |
3862 // Implementation does not modify state of internal structures. | |
603
dbbe28fc66b5
6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents:
602
diff
changeset
|
3863 void MatchRule::append_components(FormDict& locals, ComponentList& components, bool def_flag) const { |
0 | 3864 assert (_name != NULL, "MatchNode::build_components encountered empty node\n"); |
3865 | |
3866 MatchNode::append_components(locals, components, | |
3867 false /* not necessarily a def */); | |
3868 } | |
3869 | |
3870 // Recursive call on all operands' match rules in my match rule. | |
3871 // Implementation does not modify state of internal structures since they | |
3872 // can be shared. | |
3873 // The MatchNode that is called first treats its | |
3874 bool MatchRule::base_operand(uint &position0, FormDict &globals, | |
3875 const char *&result, const char * &name, | |
3876 const char * &opType)const{ | |
3877 uint position = position0; | |
3878 | |
3879 return (MatchNode::base_operand( position, globals, result, name, opType)); | |
3880 } | |
3881 | |
3882 | |
3883 bool MatchRule::is_base_register(FormDict &globals) const { | |
3884 uint position = 1; | |
3885 const char *result = NULL; | |
3886 const char *name = NULL; | |
3887 const char *opType = NULL; | |
3888 if (!base_operand(position, globals, result, name, opType)) { | |
3889 position = 0; | |
3890 if( base_operand(position, globals, result, name, opType) && | |
3891 (strcmp(opType,"RegI")==0 || | |
3892 strcmp(opType,"RegP")==0 || | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
3893 strcmp(opType,"RegN")==0 || |
0 | 3894 strcmp(opType,"RegL")==0 || |
3895 strcmp(opType,"RegF")==0 || | |
3896 strcmp(opType,"RegD")==0 || | |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6143
diff
changeset
|
3897 strcmp(opType,"VecS")==0 || |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6143
diff
changeset
|
3898 strcmp(opType,"VecD")==0 || |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6143
diff
changeset
|
3899 strcmp(opType,"VecX")==0 || |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6143
diff
changeset
|
3900 strcmp(opType,"VecY")==0 || |
0 | 3901 strcmp(opType,"Reg" )==0) ) { |
3902 return 1; | |
3903 } | |
3904 } | |
3905 return 0; | |
3906 } | |
3907 | |
3908 Form::DataType MatchRule::is_base_constant(FormDict &globals) const { | |
3909 uint position = 1; | |
3910 const char *result = NULL; | |
3911 const char *name = NULL; | |
3912 const char *opType = NULL; | |
3913 if (!base_operand(position, globals, result, name, opType)) { | |
3914 position = 0; | |
3915 if (base_operand(position, globals, result, name, opType)) { | |
3916 return ideal_to_const_type(opType); | |
3917 } | |
3918 } | |
3919 return Form::none; | |
3920 } | |
3921 | |
3922 bool MatchRule::is_chain_rule(FormDict &globals) const { | |
3923 | |
3924 // Check for chain rule, and do not generate a match list for it | |
3925 if ((_lChild == NULL) && (_rChild == NULL) ) { | |
3926 const Form *form = globals[_opType]; | |
3927 // If this is ideal, then it is a base match, not a chain rule. | |
3928 if ( form && form->is_operand() && (!form->ideal_only())) { | |
3929 return true; | |
3930 } | |
3931 } | |
3932 // Check for "Set" form of chain rule, and do not generate a match list | |
3933 if (_rChild) { | |
3934 const char *rch = _rChild->_opType; | |
3935 const Form *form = globals[rch]; | |
3936 if ((!strcmp(_opType,"Set") && | |
3937 ((form) && form->is_operand()))) { | |
3938 return true; | |
3939 } | |
3940 } | |
3941 return false; | |
3942 } | |
3943 | |
3944 int MatchRule::is_ideal_copy() const { | |
3945 if( _rChild ) { | |
3946 const char *opType = _rChild->_opType; | |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
3947 #if 1 |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
3948 if( strcmp(opType,"CastIP")==0 ) |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
3949 return 1; |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
3950 #else |
0 | 3951 if( strcmp(opType,"CastII")==0 ) |
3952 return 1; | |
3953 // Do not treat *CastPP this way, because it | |
3954 // may transfer a raw pointer to an oop. | |
3955 // If the register allocator were to coalesce this | |
3956 // into a single LRG, the GC maps would be incorrect. | |
3957 //if( strcmp(opType,"CastPP")==0 ) | |
3958 // return 1; | |
3959 //if( strcmp(opType,"CheckCastPP")==0 ) | |
3960 // return 1; | |
3961 // | |
3962 // Do not treat CastX2P or CastP2X this way, because | |
3963 // raw pointers and int types are treated differently | |
3964 // when saving local & stack info for safepoints in | |
3965 // Output(). | |
3966 //if( strcmp(opType,"CastX2P")==0 ) | |
3967 // return 1; | |
3968 //if( strcmp(opType,"CastP2X")==0 ) | |
3969 // return 1; | |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
3970 #endif |
0 | 3971 } |
3972 if( is_chain_rule(_AD.globalNames()) && | |
3973 _lChild && strncmp(_lChild->_opType,"stackSlot",9)==0 ) | |
3974 return 1; | |
3975 return 0; | |
3976 } | |
3977 | |
3978 | |
3979 int MatchRule::is_expensive() const { | |
3980 if( _rChild ) { | |
3981 const char *opType = _rChild->_opType; | |
3982 if( strcmp(opType,"AtanD")==0 || | |
3983 strcmp(opType,"CosD")==0 || | |
3984 strcmp(opType,"DivD")==0 || | |
3985 strcmp(opType,"DivF")==0 || | |
3986 strcmp(opType,"DivI")==0 || | |
3987 strcmp(opType,"ExpD")==0 || | |
3988 strcmp(opType,"LogD")==0 || | |
3989 strcmp(opType,"Log10D")==0 || | |
3990 strcmp(opType,"ModD")==0 || | |
3991 strcmp(opType,"ModF")==0 || | |
3992 strcmp(opType,"ModI")==0 || | |
3993 strcmp(opType,"PowD")==0 || | |
3994 strcmp(opType,"SinD")==0 || | |
3995 strcmp(opType,"SqrtD")==0 || | |
3996 strcmp(opType,"TanD")==0 || | |
3997 strcmp(opType,"ConvD2F")==0 || | |
3998 strcmp(opType,"ConvD2I")==0 || | |
3999 strcmp(opType,"ConvD2L")==0 || | |
4000 strcmp(opType,"ConvF2D")==0 || | |
4001 strcmp(opType,"ConvF2I")==0 || | |
4002 strcmp(opType,"ConvF2L")==0 || | |
4003 strcmp(opType,"ConvI2D")==0 || | |
4004 strcmp(opType,"ConvI2F")==0 || | |
4005 strcmp(opType,"ConvI2L")==0 || | |
4006 strcmp(opType,"ConvL2D")==0 || | |
4007 strcmp(opType,"ConvL2F")==0 || | |
4008 strcmp(opType,"ConvL2I")==0 || | |
247 | 4009 strcmp(opType,"DecodeN")==0 || |
4010 strcmp(opType,"EncodeP")==0 || | |
6848
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6823
diff
changeset
|
4011 strcmp(opType,"EncodePKlass")==0 || |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6823
diff
changeset
|
4012 strcmp(opType,"DecodeNKlass")==0 || |
0 | 4013 strcmp(opType,"RoundDouble")==0 || |
4014 strcmp(opType,"RoundFloat")==0 || | |
4015 strcmp(opType,"ReverseBytesI")==0 || | |
4016 strcmp(opType,"ReverseBytesL")==0 || | |
1396
d7f654633cfe
6946040: add intrinsic for short and char reverseBytes
never
parents:
986
diff
changeset
|
4017 strcmp(opType,"ReverseBytesUS")==0 || |
d7f654633cfe
6946040: add intrinsic for short and char reverseBytes
never
parents:
986
diff
changeset
|
4018 strcmp(opType,"ReverseBytesS")==0 || |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6143
diff
changeset
|
4019 strcmp(opType,"ReplicateB")==0 || |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6143
diff
changeset
|
4020 strcmp(opType,"ReplicateS")==0 || |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6143
diff
changeset
|
4021 strcmp(opType,"ReplicateI")==0 || |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6143
diff
changeset
|
4022 strcmp(opType,"ReplicateL")==0 || |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6143
diff
changeset
|
4023 strcmp(opType,"ReplicateF")==0 || |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6143
diff
changeset
|
4024 strcmp(opType,"ReplicateD")==0 || |
0 | 4025 0 /* 0 to line up columns nicely */ ) |
4026 return 1; | |
4027 } | |
4028 return 0; | |
4029 } | |
4030 | |
4031 bool MatchRule::is_ideal_if() const { | |
4032 if( !_opType ) return false; | |
4033 return | |
4034 !strcmp(_opType,"If" ) || | |
4035 !strcmp(_opType,"CountedLoopEnd"); | |
4036 } | |
4037 | |
4038 bool MatchRule::is_ideal_fastlock() const { | |
4039 if ( _opType && (strcmp(_opType,"Set") == 0) && _rChild ) { | |
4040 return (strcmp(_rChild->_opType,"FastLock") == 0); | |
4041 } | |
4042 return false; | |
4043 } | |
4044 | |
4045 bool MatchRule::is_ideal_membar() const { | |
4046 if( !_opType ) return false; | |
4047 return | |
4048 !strcmp(_opType,"MemBarAcquire" ) || | |
4049 !strcmp(_opType,"MemBarRelease" ) || | |
3849
f1c12354c3f7
7074017: Introduce MemBarAcquireLock/MemBarReleaseLock nodes for monitor enter/exit code paths
roland
parents:
3842
diff
changeset
|
4050 !strcmp(_opType,"MemBarAcquireLock") || |
f1c12354c3f7
7074017: Introduce MemBarAcquireLock/MemBarReleaseLock nodes for monitor enter/exit code paths
roland
parents:
3842
diff
changeset
|
4051 !strcmp(_opType,"MemBarReleaseLock") || |
0 | 4052 !strcmp(_opType,"MemBarVolatile" ) || |
4763
1dc233a8c7fe
7121140: Allocation paths require explicit memory synchronization operations for RMO systems
roland
parents:
4120
diff
changeset
|
4053 !strcmp(_opType,"MemBarCPUOrder" ) || |
1dc233a8c7fe
7121140: Allocation paths require explicit memory synchronization operations for RMO systems
roland
parents:
4120
diff
changeset
|
4054 !strcmp(_opType,"MemBarStoreStore" ); |
0 | 4055 } |
4056 | |
4057 bool MatchRule::is_ideal_loadPC() const { | |
4058 if ( _opType && (strcmp(_opType,"Set") == 0) && _rChild ) { | |
4059 return (strcmp(_rChild->_opType,"LoadPC") == 0); | |
4060 } | |
4061 return false; | |
4062 } | |
4063 | |
4064 bool MatchRule::is_ideal_box() const { | |
4065 if ( _opType && (strcmp(_opType,"Set") == 0) && _rChild ) { | |
4066 return (strcmp(_rChild->_opType,"Box") == 0); | |
4067 } | |
4068 return false; | |
4069 } | |
4070 | |
4071 bool MatchRule::is_ideal_goto() const { | |
4072 bool ideal_goto = false; | |
4073 | |
4074 if( _opType && (strcmp(_opType,"Goto") == 0) ) { | |
4075 ideal_goto = true; | |
4076 } | |
4077 return ideal_goto; | |
4078 } | |
4079 | |
4080 bool MatchRule::is_ideal_jump() const { | |
4081 if( _opType ) { | |
4082 if( !strcmp(_opType,"Jump") ) | |
4083 return true; | |
4084 } | |
4085 return false; | |
4086 } | |
4087 | |
4088 bool MatchRule::is_ideal_bool() const { | |
4089 if( _opType ) { | |
4090 if( !strcmp(_opType,"Bool") ) | |
4091 return true; | |
4092 } | |
4093 return false; | |
4094 } | |
4095 | |
4096 | |
4097 Form::DataType MatchRule::is_ideal_load() const { | |
4098 Form::DataType ideal_load = Form::none; | |
4099 | |
4100 if ( _opType && (strcmp(_opType,"Set") == 0) && _rChild ) { | |
4101 const char *opType = _rChild->_opType; | |
4102 ideal_load = is_load_from_memory(opType); | |
4103 } | |
4104 | |
4105 return ideal_load; | |
4106 } | |
4107 | |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6143
diff
changeset
|
4108 bool MatchRule::is_vector() const { |
6802
0702f188baeb
7200233: C2: can't use expand rules for vector instruction rules
kvn
parents:
6795
diff
changeset
|
4109 static const char *vector_list[] = { |
0702f188baeb
7200233: C2: can't use expand rules for vector instruction rules
kvn
parents:
6795
diff
changeset
|
4110 "AddVB","AddVS","AddVI","AddVL","AddVF","AddVD", |
0702f188baeb
7200233: C2: can't use expand rules for vector instruction rules
kvn
parents:
6795
diff
changeset
|
4111 "SubVB","SubVS","SubVI","SubVL","SubVF","SubVD", |
0702f188baeb
7200233: C2: can't use expand rules for vector instruction rules
kvn
parents:
6795
diff
changeset
|
4112 "MulVS","MulVI","MulVF","MulVD", |
0702f188baeb
7200233: C2: can't use expand rules for vector instruction rules
kvn
parents:
6795
diff
changeset
|
4113 "DivVF","DivVD", |
0702f188baeb
7200233: C2: can't use expand rules for vector instruction rules
kvn
parents:
6795
diff
changeset
|
4114 "AndV" ,"XorV" ,"OrV", |
6823 | 4115 "LShiftCntV","RShiftCntV", |
6802
0702f188baeb
7200233: C2: can't use expand rules for vector instruction rules
kvn
parents:
6795
diff
changeset
|
4116 "LShiftVB","LShiftVS","LShiftVI","LShiftVL", |
0702f188baeb
7200233: C2: can't use expand rules for vector instruction rules
kvn
parents:
6795
diff
changeset
|
4117 "RShiftVB","RShiftVS","RShiftVI","RShiftVL", |
0702f188baeb
7200233: C2: can't use expand rules for vector instruction rules
kvn
parents:
6795
diff
changeset
|
4118 "URShiftVB","URShiftVS","URShiftVI","URShiftVL", |
0702f188baeb
7200233: C2: can't use expand rules for vector instruction rules
kvn
parents:
6795
diff
changeset
|
4119 "ReplicateB","ReplicateS","ReplicateI","ReplicateL","ReplicateF","ReplicateD", |
0702f188baeb
7200233: C2: can't use expand rules for vector instruction rules
kvn
parents:
6795
diff
changeset
|
4120 "LoadVector","StoreVector", |
0702f188baeb
7200233: C2: can't use expand rules for vector instruction rules
kvn
parents:
6795
diff
changeset
|
4121 // Next are not supported currently. |
0702f188baeb
7200233: C2: can't use expand rules for vector instruction rules
kvn
parents:
6795
diff
changeset
|
4122 "PackB","PackS","PackI","PackL","PackF","PackD","Pack2L","Pack2D", |
0702f188baeb
7200233: C2: can't use expand rules for vector instruction rules
kvn
parents:
6795
diff
changeset
|
4123 "ExtractB","ExtractUB","ExtractC","ExtractS","ExtractI","ExtractL","ExtractF","ExtractD" |
0702f188baeb
7200233: C2: can't use expand rules for vector instruction rules
kvn
parents:
6795
diff
changeset
|
4124 }; |
0702f188baeb
7200233: C2: can't use expand rules for vector instruction rules
kvn
parents:
6795
diff
changeset
|
4125 int cnt = sizeof(vector_list)/sizeof(char*); |
0702f188baeb
7200233: C2: can't use expand rules for vector instruction rules
kvn
parents:
6795
diff
changeset
|
4126 if (_rChild) { |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6143
diff
changeset
|
4127 const char *opType = _rChild->_opType; |
6802
0702f188baeb
7200233: C2: can't use expand rules for vector instruction rules
kvn
parents:
6795
diff
changeset
|
4128 for (int i=0; i<cnt; i++) |
0702f188baeb
7200233: C2: can't use expand rules for vector instruction rules
kvn
parents:
6795
diff
changeset
|
4129 if (strcmp(opType,vector_list[i]) == 0) |
0702f188baeb
7200233: C2: can't use expand rules for vector instruction rules
kvn
parents:
6795
diff
changeset
|
4130 return true; |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6143
diff
changeset
|
4131 } |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6143
diff
changeset
|
4132 return false; |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6143
diff
changeset
|
4133 } |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
6143
diff
changeset
|
4134 |
0 | 4135 |
855
f9094a5e1c8a
6857159: local schedule failed with checkcast of Thread.currentThread()
never
parents:
681
diff
changeset
|
4136 bool MatchRule::skip_antidep_check() const { |
f9094a5e1c8a
6857159: local schedule failed with checkcast of Thread.currentThread()
never
parents:
681
diff
changeset
|
4137 // Some loads operate on what is effectively immutable memory so we |
f9094a5e1c8a
6857159: local schedule failed with checkcast of Thread.currentThread()
never
parents:
681
diff
changeset
|
4138 // should skip the anti dep computations. For some of these nodes |
f9094a5e1c8a
6857159: local schedule failed with checkcast of Thread.currentThread()
never
parents:
681
diff
changeset
|
4139 // the rewritable field keeps the anti dep logic from triggering but |
f9094a5e1c8a
6857159: local schedule failed with checkcast of Thread.currentThread()
never
parents:
681
diff
changeset
|
4140 // for certain kinds of LoadKlass it does not since they are |
f9094a5e1c8a
6857159: local schedule failed with checkcast of Thread.currentThread()
never
parents:
681
diff
changeset
|
4141 // actually reading memory which could be rewritten by the runtime, |
f9094a5e1c8a
6857159: local schedule failed with checkcast of Thread.currentThread()
never
parents:
681
diff
changeset
|
4142 // though never by generated code. This disables it uniformly for |
f9094a5e1c8a
6857159: local schedule failed with checkcast of Thread.currentThread()
never
parents:
681
diff
changeset
|
4143 // the nodes that behave like this: LoadKlass, LoadNKlass and |
f9094a5e1c8a
6857159: local schedule failed with checkcast of Thread.currentThread()
never
parents:
681
diff
changeset
|
4144 // LoadRange. |
f9094a5e1c8a
6857159: local schedule failed with checkcast of Thread.currentThread()
never
parents:
681
diff
changeset
|
4145 if ( _opType && (strcmp(_opType,"Set") == 0) && _rChild ) { |
f9094a5e1c8a
6857159: local schedule failed with checkcast of Thread.currentThread()
never
parents:
681
diff
changeset
|
4146 const char *opType = _rChild->_opType; |
f9094a5e1c8a
6857159: local schedule failed with checkcast of Thread.currentThread()
never
parents:
681
diff
changeset
|
4147 if (strcmp("LoadKlass", opType) == 0 || |
f9094a5e1c8a
6857159: local schedule failed with checkcast of Thread.currentThread()
never
parents:
681
diff
changeset
|
4148 strcmp("LoadNKlass", opType) == 0 || |
f9094a5e1c8a
6857159: local schedule failed with checkcast of Thread.currentThread()
never
parents:
681
diff
changeset
|
4149 strcmp("LoadRange", opType) == 0) { |
f9094a5e1c8a
6857159: local schedule failed with checkcast of Thread.currentThread()
never
parents:
681
diff
changeset
|
4150 return true; |
f9094a5e1c8a
6857159: local schedule failed with checkcast of Thread.currentThread()
never
parents:
681
diff
changeset
|
4151 } |
f9094a5e1c8a
6857159: local schedule failed with checkcast of Thread.currentThread()
never
parents:
681
diff
changeset
|
4152 } |
f9094a5e1c8a
6857159: local schedule failed with checkcast of Thread.currentThread()
never
parents:
681
diff
changeset
|
4153 |
f9094a5e1c8a
6857159: local schedule failed with checkcast of Thread.currentThread()
never
parents:
681
diff
changeset
|
4154 return false; |
f9094a5e1c8a
6857159: local schedule failed with checkcast of Thread.currentThread()
never
parents:
681
diff
changeset
|
4155 } |
f9094a5e1c8a
6857159: local schedule failed with checkcast of Thread.currentThread()
never
parents:
681
diff
changeset
|
4156 |
f9094a5e1c8a
6857159: local schedule failed with checkcast of Thread.currentThread()
never
parents:
681
diff
changeset
|
4157 |
0 | 4158 Form::DataType MatchRule::is_ideal_store() const { |
4159 Form::DataType ideal_store = Form::none; | |
4160 | |
4161 if ( _opType && (strcmp(_opType,"Set") == 0) && _rChild ) { | |
4162 const char *opType = _rChild->_opType; | |
4163 ideal_store = is_store_to_memory(opType); | |
4164 } | |
4165 | |
4166 return ideal_store; | |
4167 } | |
4168 | |
4169 | |
4170 void MatchRule::dump() { | |
4171 output(stderr); | |
4172 } | |
4173 | |
6850 | 4174 // Write just one line. |
4175 void MatchRule::output_short(FILE *fp) { | |
0 | 4176 fprintf(fp,"MatchRule: ( %s",_name); |
4177 if (_lChild) _lChild->output(fp); | |
4178 if (_rChild) _rChild->output(fp); | |
6850 | 4179 fprintf(fp," )"); |
4180 } | |
4181 | |
4182 void MatchRule::output(FILE *fp) { | |
4183 output_short(fp); | |
4184 fprintf(fp,"\n nesting depth = %d\n", _depth); | |
0 | 4185 if (_result) fprintf(fp," Result Type = %s", _result); |
4186 fprintf(fp,"\n"); | |
4187 } | |
4188 | |
4189 //------------------------------Attribute-------------------------------------- | |
4190 Attribute::Attribute(char *id, char* val, int type) | |
4191 : _ident(id), _val(val), _atype(type) { | |
4192 } | |
4193 Attribute::~Attribute() { | |
4194 } | |
4195 | |
4196 int Attribute::int_val(ArchDesc &ad) { | |
4197 // Make sure it is an integer constant: | |
4198 int result = 0; | |
4199 if (!_val || !ADLParser::is_int_token(_val, result)) { | |
4200 ad.syntax_err(0, "Attribute %s must have an integer value: %s", | |
4201 _ident, _val ? _val : ""); | |
4202 } | |
4203 return result; | |
4204 } | |
4205 | |
4206 void Attribute::dump() { | |
4207 output(stderr); | |
4208 } // Debug printer | |
4209 | |
4210 // Write to output files | |
4211 void Attribute::output(FILE *fp) { | |
4212 fprintf(fp,"Attribute: %s %s\n", (_ident?_ident:""), (_val?_val:"")); | |
4213 } | |
4214 | |
4215 //------------------------------FormatRule---------------------------------- | |
4216 FormatRule::FormatRule(char *temp) | |
4217 : _temp(temp) { | |
4218 } | |
4219 FormatRule::~FormatRule() { | |
4220 } | |
4221 | |
4222 void FormatRule::dump() { | |
4223 output(stderr); | |
4224 } | |
4225 | |
4226 // Write to output files | |
4227 void FormatRule::output(FILE *fp) { | |
4228 fprintf(fp,"\nFormat Rule: \n%s", (_temp?_temp:"")); | |
4229 fprintf(fp,"\n"); | |
4230 } |