Mercurial > hg > truffle
annotate src/share/vm/adlc/formssel.hpp @ 1293:51db1e4b379d
6932536: JSR 292 modified JDK MethodHandlesTest fails on x86_64
Summary: A modified MethodHandlesTest revealed two bugs on x86_64.
Reviewed-by: never, jrose
author | twisti |
---|---|
date | Mon, 08 Mar 2010 04:46:30 -0800 |
parents | f9094a5e1c8a |
children | b5fdf39b9749 |
rev | line source |
---|---|
0 | 1 /* |
603
dbbe28fc66b5
6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents:
599
diff
changeset
|
2 * Copyright 1998-2009 Sun Microsystems, Inc. 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 * | |
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, | |
20 * CA 95054 USA or visit www.sun.com if you need additional information or | |
21 * have any questions. | |
22 * | |
23 */ | |
24 | |
25 // FORMSSEL.HPP - ADL Parser Instruction Selection Forms Classes | |
26 | |
27 // Class List | |
28 class Form; | |
29 class InstructForm; | |
30 class MachNodeForm; | |
31 class OperandForm; | |
32 class OpClassForm; | |
33 class AttributeForm; | |
34 class RegisterForm; | |
35 class PipelineForm; | |
36 class SourceForm; | |
37 class EncodeForm; | |
38 class Component; | |
39 class Constraint; | |
40 class Predicate; | |
41 class MatchRule; | |
42 class Attribute; | |
43 class Effect; | |
44 class ExpandRule; | |
45 class RewriteRule; | |
46 class ConstructRule; | |
47 class FormatRule; | |
48 class Peephole; | |
49 class EncClass; | |
50 class Interface; | |
51 class RegInterface; | |
52 class ConstInterface; | |
53 class MemInterface; | |
54 class CondInterface; | |
55 class Opcode; | |
56 class InsEncode; | |
57 class RegDef; | |
58 class RegClass; | |
59 class AllocClass; | |
60 class ResourceForm; | |
61 class PipeDesc; | |
62 class PipeClass; | |
63 class PeepMatch; | |
64 class PeepConstraint; | |
65 class PeepReplace; | |
66 class MatchList; | |
67 | |
68 class ArchDesc; | |
69 | |
70 //==============================Instructions=================================== | |
71 //------------------------------InstructForm----------------------------------- | |
72 class InstructForm : public Form { | |
73 private: | |
74 bool _ideal_only; // Not a user-defined instruction | |
75 // Members used for tracking CISC-spilling | |
76 uint _cisc_spill_operand;// Which operand may cisc-spill | |
77 void set_cisc_spill_operand(uint op_index) { _cisc_spill_operand = op_index; } | |
78 bool _is_cisc_alternate; | |
79 InstructForm *_cisc_spill_alternate;// cisc possible replacement | |
80 const char *_cisc_reg_mask_name; | |
81 InstructForm *_short_branch_form; | |
82 bool _is_short_branch; | |
83 uint _alignment; | |
84 | |
85 public: | |
86 // Public Data | |
87 const char *_ident; // Name of this instruction | |
88 NameList _parameters; // Locally defined names | |
89 FormDict _localNames; // Table of operands & their types | |
90 MatchRule *_matrule; // Matching rule for this instruction | |
91 Opcode *_opcode; // Encoding of the opcode for instruction | |
92 char *_size; // Size of instruction | |
93 InsEncode *_insencode; // Encoding class instruction belongs to | |
94 Attribute *_attribs; // List of Attribute rules | |
95 Predicate *_predicate; // Predicate test for this instruction | |
96 FormDict _effects; // Dictionary of effect rules | |
97 ExpandRule *_exprule; // Expand rule for this instruction | |
98 RewriteRule *_rewrule; // Rewrite rule for this instruction | |
99 FormatRule *_format; // Format for assembly generation | |
100 Peephole *_peephole; // List of peephole rules for instruction | |
101 const char *_ins_pipe; // Instruction Scheduline description class | |
102 | |
103 uint *_uniq_idx; // Indexes of unique operands | |
599
0ad1cb407fa1
6805427: adlc compiler may generate incorrect machnode emission code
never
parents:
470
diff
changeset
|
104 int _uniq_idx_length; // Length of _uniq_idx array |
0 | 105 uint _num_uniq; // Number of unique operands |
106 ComponentList _components; // List of Components matches MachNode's | |
107 // operand structure | |
108 | |
109 // Public Methods | |
110 InstructForm(const char *id, bool ideal_only = false); | |
111 InstructForm(const char *id, InstructForm *instr, MatchRule *rule); | |
112 ~InstructForm(); | |
113 | |
114 // Dynamic type check | |
115 virtual InstructForm *is_instruction() const; | |
116 | |
117 virtual bool ideal_only() const; | |
118 | |
119 // This instruction sets a result | |
120 virtual bool sets_result() const; | |
121 // This instruction needs projections for additional DEFs or KILLs | |
122 virtual bool needs_projections(); | |
123 // This instruction needs extra nodes for temporary inputs | |
124 virtual bool has_temps(); | |
125 // This instruction defines or kills more than one object | |
126 virtual uint num_defs_or_kills(); | |
127 // This instruction has an expand rule? | |
128 virtual bool expands() const ; | |
129 // Return this instruction's first peephole rule, or NULL | |
130 virtual Peephole *peepholes() const; | |
131 // Add a peephole rule to this instruction | |
132 virtual void append_peephole(Peephole *peep); | |
133 | |
134 virtual bool is_pinned(FormDict &globals); // should be pinned inside block | |
135 virtual bool is_projection(FormDict &globals); // node requires projection | |
136 virtual bool is_parm(FormDict &globals); // node matches ideal 'Parm' | |
137 // ideal opcode enumeration | |
138 virtual const char *ideal_Opcode(FormDict &globals) const; | |
139 virtual int is_expensive() const; // node matches ideal 'CosD' | |
140 virtual int is_empty_encoding() const; // _size=0 and/or _insencode empty | |
141 virtual int is_tls_instruction() const; // tlsLoadP rule or ideal ThreadLocal | |
142 virtual int is_ideal_copy() const; // node matches ideal 'Copy*' | |
143 virtual bool is_ideal_unlock() const; // node matches ideal 'Unlock' | |
144 virtual bool is_ideal_call_leaf() const; // node matches ideal 'CallLeaf' | |
145 virtual bool is_ideal_if() const; // node matches ideal 'If' | |
146 virtual bool is_ideal_fastlock() const; // node matches 'FastLock' | |
147 virtual bool is_ideal_membar() const; // node matches ideal 'MemBarXXX' | |
148 virtual bool is_ideal_loadPC() const; // node matches ideal 'LoadPC' | |
149 virtual bool is_ideal_box() const; // node matches ideal 'Box' | |
150 virtual bool is_ideal_goto() const; // node matches ideal 'Goto' | |
151 virtual bool is_ideal_branch() const; // "" 'If' | 'Goto' | 'LoopEnd' | 'Jump' | |
152 virtual bool is_ideal_jump() const; // node matches ideal 'Jump' | |
153 virtual bool is_ideal_return() const; // node matches ideal 'Return' | |
154 virtual bool is_ideal_halt() const; // node matches ideal 'Halt' | |
155 virtual bool is_ideal_safepoint() const; // node matches 'SafePoint' | |
156 virtual bool is_ideal_nop() const; // node matches 'Nop' | |
157 virtual bool is_ideal_control() const; // control node | |
158 | |
159 virtual Form::CallType is_ideal_call() const; // matches ideal 'Call' | |
160 virtual Form::DataType is_ideal_load() const; // node matches ideal 'LoadXNode' | |
855
f9094a5e1c8a
6857159: local schedule failed with checkcast of Thread.currentThread()
never
parents:
605
diff
changeset
|
161 // Should antidep checks be disabled for this Instruct |
f9094a5e1c8a
6857159: local schedule failed with checkcast of Thread.currentThread()
never
parents:
605
diff
changeset
|
162 // See definition of MatchRule::skip_antidep_check |
f9094a5e1c8a
6857159: local schedule failed with checkcast of Thread.currentThread()
never
parents:
605
diff
changeset
|
163 bool skip_antidep_check() const; |
0 | 164 virtual Form::DataType is_ideal_store() const;// node matches ideal 'StoreXNode' |
165 bool is_ideal_mem() const { return is_ideal_load() != Form::none || is_ideal_store() != Form::none; } | |
166 virtual uint two_address(FormDict &globals); // output reg must match input reg | |
167 // when chaining a constant to an instruction, return 'true' and set opType | |
168 virtual Form::DataType is_chain_of_constant(FormDict &globals); | |
169 virtual Form::DataType is_chain_of_constant(FormDict &globals, const char * &opType); | |
170 virtual Form::DataType is_chain_of_constant(FormDict &globals, const char * &opType, const char * &result_type); | |
171 | |
172 // Check if a simple chain rule | |
173 virtual bool is_simple_chain_rule(FormDict &globals) const; | |
174 | |
175 // check for structural rematerialization | |
176 virtual bool rematerialize(FormDict &globals, RegisterForm *registers); | |
177 | |
178 // loads from memory, so must check for anti-dependence | |
179 virtual bool needs_anti_dependence_check(FormDict &globals) const; | |
180 virtual int memory_operand(FormDict &globals) const; | |
181 bool is_wide_memory_kill(FormDict &globals) const; | |
182 | |
183 enum memory_operand_type { | |
184 NO_MEMORY_OPERAND = -1, | |
185 MANY_MEMORY_OPERANDS = 999999 | |
186 }; | |
187 | |
188 | |
189 // This instruction captures the machine-independent bottom_type | |
190 // Expected use is for pointer vs oop determination for LoadP | |
191 virtual bool captures_bottom_type() const; | |
192 | |
193 virtual const char *cost(); // Access ins_cost attribute | |
194 virtual uint num_opnds(); // Count of num_opnds for MachNode class | |
195 virtual uint num_post_match_opnds(); | |
196 virtual uint num_consts(FormDict &globals) const;// Constants in match rule | |
197 // Constants in match rule with specified type | |
198 virtual uint num_consts(FormDict &globals, Form::DataType type) const; | |
199 | |
200 // Return the register class associated with 'leaf'. | |
201 virtual const char *out_reg_class(FormDict &globals); | |
202 | |
203 // number of ideal node inputs to skip | |
204 virtual uint oper_input_base(FormDict &globals); | |
205 | |
206 // Does this instruction need a base-oop edge? | |
207 int needs_base_oop_edge(FormDict &globals) const; | |
208 | |
209 // Build instruction predicates. If the user uses the same operand name | |
210 // twice, we need to check that the operands are pointer-eequivalent in | |
211 // the DFA during the labeling process. | |
212 Predicate *build_predicate(); | |
213 | |
214 virtual void build_components(); // top-level operands | |
215 // Return zero-based position in component list; -1 if not in list. | |
216 virtual int operand_position(const char *name, int usedef); | |
217 virtual int operand_position_format(const char *name); | |
218 | |
219 // Return zero-based position in component list; -1 if not in list. | |
220 virtual int label_position(); | |
221 virtual int method_position(); | |
222 // Return number of relocation entries needed for this instruction. | |
223 virtual uint reloc(FormDict &globals); | |
224 | |
225 const char *reduce_result(); | |
226 // Return the name of the operand on the right hand side of the binary match | |
227 // Return NULL if there is no right hand side | |
228 const char *reduce_right(FormDict &globals) const; | |
229 const char *reduce_left(FormDict &globals) const; | |
230 | |
231 // Base class for this instruction, MachNode except for calls | |
232 virtual const char *mach_base_class() const; | |
233 | |
234 // Check if this instruction can cisc-spill to 'alternate' | |
235 bool cisc_spills_to(ArchDesc &AD, InstructForm *alternate); | |
236 InstructForm *cisc_spill_alternate() { return _cisc_spill_alternate; } | |
237 uint cisc_spill_operand() const { return _cisc_spill_operand; } | |
238 bool is_cisc_alternate() const { return _is_cisc_alternate; } | |
239 void set_cisc_alternate(bool val) { _is_cisc_alternate = val; } | |
240 const char *cisc_reg_mask_name() const { return _cisc_reg_mask_name; } | |
241 void set_cisc_reg_mask_name(const char *rm_name) { _cisc_reg_mask_name = rm_name; } | |
242 // Output cisc-method prototypes and method bodies | |
243 void declare_cisc_version(ArchDesc &AD, FILE *fp_cpp); | |
244 bool define_cisc_version (ArchDesc &AD, FILE *fp_cpp); | |
245 | |
246 bool check_branch_variant(ArchDesc &AD, InstructForm *short_branch); | |
247 | |
248 bool is_short_branch() { return _is_short_branch; } | |
249 void set_short_branch(bool val) { _is_short_branch = val; } | |
250 | |
251 InstructForm *short_branch_form() { return _short_branch_form; } | |
252 bool has_short_branch_form() { return _short_branch_form != NULL; } | |
253 // Output short branch prototypes and method bodies | |
254 void declare_short_branch_methods(FILE *fp_cpp); | |
255 bool define_short_branch_methods(FILE *fp_cpp); | |
256 | |
257 uint alignment() { return _alignment; } | |
258 void set_alignment(uint val) { _alignment = val; } | |
259 | |
260 // Seach through operands to determine operands unique positions. | |
261 void set_unique_opnds(); | |
262 uint num_unique_opnds() { return _num_uniq; } | |
263 uint unique_opnds_idx(int idx) { | |
599
0ad1cb407fa1
6805427: adlc compiler may generate incorrect machnode emission code
never
parents:
470
diff
changeset
|
264 if( _uniq_idx != NULL && idx > 0 ) { |
0ad1cb407fa1
6805427: adlc compiler may generate incorrect machnode emission code
never
parents:
470
diff
changeset
|
265 assert(idx < _uniq_idx_length, "out of bounds"); |
0 | 266 return _uniq_idx[idx]; |
599
0ad1cb407fa1
6805427: adlc compiler may generate incorrect machnode emission code
never
parents:
470
diff
changeset
|
267 } else { |
0 | 268 return idx; |
599
0ad1cb407fa1
6805427: adlc compiler may generate incorrect machnode emission code
never
parents:
470
diff
changeset
|
269 } |
0ad1cb407fa1
6805427: adlc compiler may generate incorrect machnode emission code
never
parents:
470
diff
changeset
|
270 } |
0 | 271 |
272 // Operands which are only KILLs aren't part of the input array and | |
273 // require special handling in some cases. Their position in this | |
274 // operand list is higher than the number of unique operands. | |
275 bool is_noninput_operand(uint idx) { | |
276 return (idx >= num_unique_opnds()); | |
277 } | |
278 | |
279 // --------------------------- FILE *output_routines | |
280 // | |
281 // Generate the format call for the replacement variable | |
282 void rep_var_format(FILE *fp, const char *rep_var); | |
605 | 283 // Generate index values needed for determining the operand position |
0 | 284 void index_temps (FILE *fp, FormDict &globals, const char *prefix = "", const char *receiver = ""); |
285 // --------------------------- | |
286 | |
287 virtual bool verify(); // Check consistency after parsing | |
288 | |
289 virtual void dump(); // Debug printer | |
290 virtual void output(FILE *fp); // Write to output files | |
291 }; | |
292 | |
293 //------------------------------EncodeForm------------------------------------- | |
294 class EncodeForm : public Form { | |
295 private: | |
296 | |
297 public: | |
298 // Public Data | |
299 NameList _eclasses; // List of encode class names | |
300 Dict _encClass; // Map encode class names to EncClass objects | |
301 | |
302 // Public Methods | |
303 EncodeForm(); | |
304 ~EncodeForm(); | |
305 | |
306 EncClass *add_EncClass(const char *className); | |
307 EncClass *encClass(const char *className); | |
308 | |
309 const char *encClassPrototype(const char *className); | |
310 const char *encClassBody(const char *className); | |
311 | |
312 void dump(); // Debug printer | |
313 void output(FILE *fp); // Write info to output files | |
314 }; | |
315 | |
316 //------------------------------EncClass--------------------------------------- | |
317 class EncClass : public Form { | |
318 public: | |
319 // NameList for parameter type and name | |
320 NameList _parameter_type; | |
321 NameList _parameter_name; | |
322 | |
323 // Breakdown the encoding into strings separated by $replacement_variables | |
324 // There is an entry in _strings, perhaps NULL, that precedes each _rep_vars | |
325 NameList _code; // Strings passed through to tty->print | |
326 NameList _rep_vars; // replacement variables | |
327 | |
328 NameList _parameters; // Locally defined names | |
329 FormDict _localNames; // Table of components & their types | |
330 | |
331 public: | |
332 // Public Data | |
333 const char *_name; // encoding class name | |
334 | |
335 // Public Methods | |
336 EncClass(const char *name); | |
337 ~EncClass(); | |
338 | |
339 // --------------------------- Parameters | |
340 // Add a parameter <type,name> pair | |
341 void add_parameter(const char *parameter_type, const char *parameter_name); | |
342 // Verify operand types in parameter list | |
343 bool check_parameter_types(FormDict &globals); | |
344 // Obtain the zero-based index corresponding to a replacement variable | |
345 int rep_var_index(const char *rep_var); | |
346 int num_args() { return _parameter_name.count(); } | |
347 | |
348 // --------------------------- Code Block | |
349 // Add code | |
605 | 350 void add_code(const char *string_preceding_replacement_var); |
0 | 351 // Add a replacement variable or one of its subfields |
352 // Subfields are stored with a leading '$' | |
353 void add_rep_var(char *replacement_var); | |
354 | |
355 bool verify(); | |
356 void dump(); | |
357 void output(FILE *fp); | |
358 }; | |
359 | |
360 //------------------------------MachNode--------------------------------------- | |
361 class MachNodeForm: public Form { | |
362 private: | |
363 | |
364 public: | |
365 char *_ident; // Name of this instruction | |
366 const char *_machnode_pipe; // Instruction Scheduline description class | |
367 | |
368 // Public Methods | |
369 MachNodeForm(char *id); | |
370 ~MachNodeForm(); | |
371 | |
372 virtual MachNodeForm *is_machnode() const; | |
373 | |
374 void dump(); // Debug printer | |
375 void output(FILE *fp); // Write info to output files | |
376 }; | |
377 | |
378 //------------------------------Opcode----------------------------------------- | |
379 class Opcode : public Form { | |
380 private: | |
381 | |
382 public: | |
383 // Public Data | |
384 // Strings representing instruction opcodes, user defines placement in emit | |
385 char *_primary; | |
386 char *_secondary; | |
387 char *_tertiary; | |
388 | |
389 enum opcode_type { | |
390 NOT_AN_OPCODE = -1, | |
391 PRIMARY = 1, | |
392 SECONDARY = 2, | |
393 TERTIARY = 3 | |
394 }; | |
395 | |
396 // Public Methods | |
397 Opcode(char *primary, char *secondary, char *tertiary); | |
398 ~Opcode(); | |
399 | |
400 static Opcode::opcode_type as_opcode_type(const char *designator); | |
401 | |
402 void dump(); | |
403 void output(FILE *fp); | |
404 | |
405 // --------------------------- FILE *output_routines | |
415
4d9884b01ba6
6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents:
0
diff
changeset
|
406 bool print_opcode(FILE *fp, Opcode::opcode_type desired_opcode); |
0 | 407 }; |
408 | |
409 //------------------------------InsEncode-------------------------------------- | |
410 class InsEncode : public Form { | |
411 private: | |
412 // Public Data (access directly only for reads) | |
413 // The encodings can only have the values predefined by the ADLC: | |
414 // blank, RegReg, RegMem, MemReg, ... | |
415 NameList _encoding; | |
416 // NameList _parameter; | |
417 // The parameters for each encoding are preceeded by a NameList::_signal | |
418 // and follow the parameters for the previous encoding. | |
419 | |
420 // char *_encode; // Type of instruction encoding | |
421 | |
422 public: | |
423 // Public Methods | |
424 InsEncode(); | |
425 ~InsEncode(); | |
426 | |
427 // Add "encode class name" and its parameters | |
428 NameAndList *add_encode(char *encode_method_name); | |
429 // Parameters are added to the returned "NameAndList" by the parser | |
430 | |
431 // Access the list of encodings | |
432 void reset(); | |
433 const char *encode_class_iter(); | |
434 | |
435 // Returns the number of arguments to the current encoding in the iteration | |
436 int current_encoding_num_args() { | |
437 return ((NameAndList*)_encoding.current())->count(); | |
438 } | |
439 | |
440 // --------------------------- Parameters | |
441 // The following call depends upon position within encode_class_iteration | |
442 // | |
443 // Obtain parameter name from zero based index | |
444 const char *rep_var_name(InstructForm &inst, uint param_no); | |
445 // --------------------------- | |
446 | |
447 void dump(); | |
448 void output(FILE *fp); | |
449 }; | |
450 | |
451 //------------------------------Effect----------------------------------------- | |
452 class Effect : public Form { | |
453 private: | |
454 | |
455 public: | |
456 // Public Data | |
457 const char *_name; // Pre-defined name for effect | |
458 int _use_def; // Enumeration value of effect | |
459 | |
460 // Public Methods | |
461 Effect(const char *name); // Constructor | |
462 ~Effect(); // Destructor | |
463 | |
464 // Dynamic type check | |
465 virtual Effect *is_effect() const; | |
466 | |
467 // Return 'true' if this use def info equals the parameter | |
468 bool is(int use_def_kill_enum) const; | |
469 // Return 'true' if this use def info is a superset of parameter | |
470 bool isa(int use_def_kill_enum) const; | |
471 | |
472 void dump(); // Debug printer | |
473 void output(FILE *fp); // Write info to output files | |
474 }; | |
475 | |
476 //------------------------------ExpandRule------------------------------------- | |
477 class ExpandRule : public Form { | |
478 private: | |
479 NameList _expand_instrs; // ordered list of instructions and operands | |
480 | |
481 public: | |
482 // Public Data | |
483 NameList _newopers; // List of newly created operands | |
484 Dict _newopconst; // Map new operands to their constructors | |
485 | |
486 void add_instruction(NameAndList *instruction_name_and_operand_list); | |
487 void reset_instructions(); | |
488 NameAndList *iter_instructions(); | |
489 | |
490 // Public Methods | |
491 ExpandRule(); // Constructor | |
492 ~ExpandRule(); // Destructor | |
493 | |
494 void dump(); // Debug printer | |
495 void output(FILE *fp); // Write info to output files | |
496 }; | |
497 | |
498 //------------------------------RewriteRule------------------------------------ | |
499 class RewriteRule : public Form { | |
500 private: | |
501 | |
502 public: | |
503 // Public Data | |
504 SourceForm *_condition; // Rewrite condition code | |
505 InstructForm *_instrs; // List of instructions to expand to | |
506 OperandForm *_opers; // List of operands generated by expand | |
507 char *_tempParams; // Hold string until parser is finished. | |
508 char *_tempBlock; // Hold string until parser is finished. | |
509 | |
510 // Public Methods | |
511 RewriteRule(char* params, char* block) ; | |
512 ~RewriteRule(); // Destructor | |
513 void dump(); // Debug printer | |
514 void output(FILE *fp); // Write info to output files | |
515 }; | |
516 | |
517 | |
518 //==============================Operands======================================= | |
519 //------------------------------OpClassForm------------------------------------ | |
520 class OpClassForm : public Form { | |
521 public: | |
522 // Public Data | |
523 const char *_ident; // Name of this operand | |
524 NameList _oplst; // List of operand forms included in class | |
525 | |
526 // Public Methods | |
527 OpClassForm(const char *id); | |
528 ~OpClassForm(); | |
529 | |
530 // dynamic type check | |
531 virtual OpClassForm *is_opclass() const; | |
532 virtual Form::InterfaceType interface_type(FormDict &globals) const; | |
533 virtual bool stack_slots_only(FormDict &globals) const; | |
534 | |
535 virtual bool is_cisc_mem(FormDict &globals) const; | |
536 | |
537 | |
538 // Min and Max opcodes of operands in this operand class | |
539 int _minCode; | |
540 int _maxCode; | |
541 | |
542 virtual bool ideal_only() const; | |
543 virtual void dump(); // Debug printer | |
544 virtual void output(FILE *fp); // Write to output files | |
545 }; | |
546 | |
547 //------------------------------OperandForm------------------------------------ | |
548 class OperandForm : public OpClassForm { | |
549 private: | |
550 bool _ideal_only; // Not a user-defined instruction | |
551 | |
552 public: | |
553 // Public Data | |
554 NameList _parameters; // Locally defined names | |
555 FormDict _localNames; // Table of components & their types | |
556 MatchRule *_matrule; // Matching rule for this operand | |
557 Interface *_interface; // Encoding interface for this operand | |
558 Attribute *_attribs; // List of Attribute rules | |
559 Predicate *_predicate; // Predicate test for this operand | |
560 Constraint *_constraint; // Constraint Rule for this operand | |
561 ConstructRule *_construct; // Construction of operand data after matching | |
562 FormatRule *_format; // Format for assembly generation | |
563 NameList _classes; // List of opclasses which contain this oper | |
564 | |
565 ComponentList _components; // | |
566 | |
567 // Public Methods | |
568 OperandForm(const char *id); | |
569 OperandForm(const char *id, bool ideal_only); | |
570 ~OperandForm(); | |
571 | |
572 // Dynamic type check | |
573 virtual OperandForm *is_operand() const; | |
574 | |
575 virtual bool ideal_only() const; | |
576 virtual Form::InterfaceType interface_type(FormDict &globals) const; | |
577 virtual bool stack_slots_only(FormDict &globals) const; | |
578 | |
579 virtual const char *cost(); // Access ins_cost attribute | |
580 virtual uint num_leaves() const;// Leaves in complex operand | |
581 // Constants in operands' match rules | |
582 virtual uint num_consts(FormDict &globals) const; | |
583 // Constants in operand's match rule with specified type | |
584 virtual uint num_consts(FormDict &globals, Form::DataType type) const; | |
585 // Pointer Constants in operands' match rules | |
586 virtual uint num_const_ptrs(FormDict &globals) const; | |
587 // The number of input edges in the machine world == num_leaves - num_consts | |
588 virtual uint num_edges(FormDict &globals) const; | |
589 | |
590 // Check if this operand is usable for cisc-spilling | |
591 virtual bool is_cisc_reg(FormDict &globals) const; | |
592 | |
593 // node matches ideal 'Bool', grab condition codes from the ideal world | |
594 virtual bool is_ideal_bool() const; | |
595 | |
596 // Has an integer constant suitable for spill offsets | |
597 bool has_conI(FormDict &globals) const { | |
598 return (num_consts(globals,idealI) == 1) && !is_ideal_bool(); } | |
599 bool has_conL(FormDict &globals) const { | |
600 return (num_consts(globals,idealL) == 1) && !is_ideal_bool(); } | |
601 | |
602 // Node is user-defined operand for an sRegX | |
603 virtual Form::DataType is_user_name_for_sReg() const; | |
604 | |
605 // Return ideal type, if there is a single ideal type for this operand | |
606 virtual const char *ideal_type(FormDict &globals, RegisterForm *registers = NULL) const; | |
607 // If there is a single ideal type for this interface field, return it. | |
608 virtual const char *interface_ideal_type(FormDict &globals, | |
609 const char *field_name) const; | |
610 | |
611 // Return true if this operand represents a bound register class | |
612 bool is_bound_register() const; | |
613 | |
614 // Return the Register class for this operand. Returns NULL if | |
615 // operand isn't a register form. | |
616 RegClass* get_RegClass() const; | |
617 | |
618 virtual bool is_interface_field(const char *field_name, | |
619 const char * &value) const; | |
620 | |
621 // If this operand has a single ideal type, return its type | |
622 virtual Form::DataType simple_type(FormDict &globals) const; | |
623 // If this operand is an ideal constant, return its type | |
624 virtual Form::DataType is_base_constant(FormDict &globals) const; | |
625 | |
626 // "true" if this operand is a simple type that is swallowed | |
627 virtual bool swallowed(FormDict &globals) const; | |
628 | |
629 // Return register class name if a constraint specifies the register class. | |
630 virtual const char *constrained_reg_class() const; | |
631 // Return the register class associated with 'leaf'. | |
632 virtual const char *in_reg_class(uint leaf, FormDict &globals); | |
633 | |
634 // Build component list from MatchRule and operand's parameter list | |
635 virtual void build_components(); // top-level operands | |
636 | |
637 // Return zero-based position in component list; -1 if not in list. | |
638 virtual int operand_position(const char *name, int usedef); | |
639 | |
640 // Return zero-based position in component list; -1 if not in list. | |
641 virtual int constant_position(FormDict &globals, const Component *comp); | |
642 virtual int constant_position(FormDict &globals, const char *local_name); | |
643 // Return the operand form corresponding to the given index, else NULL. | |
644 virtual OperandForm *constant_operand(FormDict &globals, uint const_index); | |
645 | |
646 // Return zero-based position in component list; -1 if not in list. | |
647 virtual int register_position(FormDict &globals, const char *regname); | |
648 | |
649 const char *reduce_result() const; | |
650 // Return the name of the operand on the right hand side of the binary match | |
651 // Return NULL if there is no right hand side | |
652 const char *reduce_right(FormDict &globals) const; | |
653 const char *reduce_left(FormDict &globals) const; | |
654 | |
655 | |
656 // --------------------------- FILE *output_routines | |
657 // | |
658 // Output code for disp_is_oop, if true. | |
659 void disp_is_oop(FILE *fp, FormDict &globals); | |
660 // Generate code for internal and external format methods | |
661 void int_format(FILE *fp, FormDict &globals, uint index); | |
662 void ext_format(FILE *fp, FormDict &globals, uint index); | |
663 void format_constant(FILE *fp, uint con_index, uint con_type); | |
664 // Output code to access the value of the index'th constant | |
665 void access_constant(FILE *fp, FormDict &globals, | |
666 uint con_index); | |
667 // --------------------------- | |
668 | |
669 | |
670 virtual void dump(); // Debug printer | |
671 virtual void output(FILE *fp); // Write to output files | |
672 }; | |
673 | |
674 //------------------------------Constraint------------------------------------- | |
675 class Constraint : public Form { | |
676 private: | |
677 | |
678 public: | |
679 const char *_func; // Constraint function | |
680 const char *_arg; // function's argument | |
681 | |
682 // Public Methods | |
683 Constraint(const char *func, const char *arg); // Constructor | |
684 ~Constraint(); | |
685 | |
686 bool stack_slots_only() const; | |
687 | |
688 void dump(); // Debug printer | |
689 void output(FILE *fp); // Write info to output files | |
690 }; | |
691 | |
692 //------------------------------Predicate-------------------------------------- | |
693 class Predicate : public Form { | |
694 private: | |
695 | |
696 public: | |
697 // Public Data | |
698 char *_pred; // C++ source string for predicate | |
699 | |
700 // Public Methods | |
701 Predicate(char *pr); | |
702 ~Predicate(); | |
703 | |
704 void dump(); | |
705 void output(FILE *fp); | |
706 }; | |
707 | |
708 //------------------------------Interface-------------------------------------- | |
709 class Interface : public Form { | |
710 private: | |
711 | |
712 public: | |
713 // Public Data | |
714 const char *_name; // String representing the interface name | |
715 | |
716 // Public Methods | |
717 Interface(const char *name); | |
718 ~Interface(); | |
719 | |
720 virtual Form::InterfaceType interface_type(FormDict &globals) const; | |
721 | |
722 RegInterface *is_RegInterface(); | |
723 MemInterface *is_MemInterface(); | |
724 ConstInterface *is_ConstInterface(); | |
725 CondInterface *is_CondInterface(); | |
726 | |
727 | |
728 void dump(); | |
729 void output(FILE *fp); | |
730 }; | |
731 | |
732 //------------------------------RegInterface----------------------------------- | |
733 class RegInterface : public Interface { | |
734 private: | |
735 | |
736 public: | |
737 // Public Methods | |
738 RegInterface(); | |
739 ~RegInterface(); | |
740 | |
741 void dump(); | |
742 void output(FILE *fp); | |
743 }; | |
744 | |
745 //------------------------------ConstInterface--------------------------------- | |
746 class ConstInterface : public Interface { | |
747 private: | |
748 | |
749 public: | |
750 // Public Methods | |
751 ConstInterface(); | |
752 ~ConstInterface(); | |
753 | |
754 void dump(); | |
755 void output(FILE *fp); | |
756 }; | |
757 | |
758 //------------------------------MemInterface----------------------------------- | |
759 class MemInterface : public Interface { | |
760 private: | |
761 | |
762 public: | |
763 // Public Data | |
764 char *_base; // Base address | |
765 char *_index; // index | |
766 char *_scale; // scaling factor | |
767 char *_disp; // displacement | |
768 | |
769 // Public Methods | |
770 MemInterface(char *base, char *index, char *scale, char *disp); | |
771 ~MemInterface(); | |
772 | |
773 void dump(); | |
774 void output(FILE *fp); | |
775 }; | |
776 | |
777 //------------------------------CondInterface---------------------------------- | |
778 class CondInterface : public Interface { | |
779 private: | |
780 | |
781 public: | |
782 const char *_equal; | |
783 const char *_not_equal; | |
784 const char *_less; | |
785 const char *_greater_equal; | |
786 const char *_less_equal; | |
787 const char *_greater; | |
415
4d9884b01ba6
6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents:
0
diff
changeset
|
788 const char *_equal_format; |
4d9884b01ba6
6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents:
0
diff
changeset
|
789 const char *_not_equal_format; |
4d9884b01ba6
6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents:
0
diff
changeset
|
790 const char *_less_format; |
4d9884b01ba6
6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents:
0
diff
changeset
|
791 const char *_greater_equal_format; |
4d9884b01ba6
6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents:
0
diff
changeset
|
792 const char *_less_equal_format; |
4d9884b01ba6
6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents:
0
diff
changeset
|
793 const char *_greater_format; |
0 | 794 |
795 // Public Methods | |
415
4d9884b01ba6
6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents:
0
diff
changeset
|
796 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:
0
diff
changeset
|
797 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:
0
diff
changeset
|
798 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:
0
diff
changeset
|
799 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:
0
diff
changeset
|
800 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:
0
diff
changeset
|
801 const char* greater, const char* greater_format); |
0 | 802 ~CondInterface(); |
803 | |
804 void dump(); | |
805 void output(FILE *fp); | |
806 }; | |
807 | |
808 //------------------------------ConstructRule---------------------------------- | |
809 class ConstructRule : public Form { | |
810 private: | |
811 | |
812 public: | |
813 // Public Data | |
814 char *_expr; // String representing the match expression | |
815 char *_construct; // String representing C++ constructor code | |
816 | |
817 // Public Methods | |
818 ConstructRule(char *cnstr); | |
819 ~ConstructRule(); | |
820 | |
821 void dump(); | |
822 void output(FILE *fp); | |
823 }; | |
824 | |
825 | |
826 //==============================Shared========================================= | |
827 //------------------------------AttributeForm---------------------------------- | |
828 class AttributeForm : public Form { | |
829 private: | |
830 // counters for unique instruction or operand ID | |
831 static int _insId; // user-defined machine instruction types | |
832 static int _opId; // user-defined operand types | |
833 | |
834 int id; // hold type for this object | |
835 | |
836 public: | |
837 // Public Data | |
838 char *_attrname; // Name of attribute | |
839 int _atype; // Either INS_ATTR or OP_ATTR | |
840 char *_attrdef; // C++ source which evaluates to constant | |
841 | |
842 // Public Methods | |
843 AttributeForm(char *attr, int type, char *attrdef); | |
844 ~AttributeForm(); | |
845 | |
846 // Dynamic type check | |
847 virtual AttributeForm *is_attribute() const; | |
848 | |
849 int type() { return id;} // return this object's "id" | |
850 | |
851 static const char* _ins_cost; // "ins_cost" | |
852 static const char* _ins_pc_relative; // "ins_pc_relative" | |
853 static const char* _op_cost; // "op_cost" | |
854 | |
855 void dump(); // Debug printer | |
856 void output(FILE *fp); // Write output files | |
857 }; | |
858 | |
859 //------------------------------Component-------------------------------------- | |
860 class Component : public Form { | |
861 private: | |
862 | |
863 public: | |
864 // Public Data | |
865 const char *_name; // Name of this component | |
866 const char *_type; // Type of this component | |
867 int _usedef; // Value of component | |
868 | |
869 // Public Methods | |
870 Component(const char *name, const char *type, int usedef); | |
871 ~Component(); | |
872 | |
873 | |
874 // Return 'true' if this use def info equals the parameter | |
875 bool is(int use_def_kill_enum) const; | |
876 // Return 'true' if this use def info is a superset of parameter | |
877 bool isa(int use_def_kill_enum) const; | |
878 int promote_use_def_info(int new_use_def); | |
879 const char *base_type(FormDict &globals); | |
880 // Form::DataType is_base_constant(FormDict &globals); | |
881 | |
882 void dump(); // Debug printer | |
883 void output(FILE *fp); // Write to output files | |
884 | |
885 public: | |
886 // Implementation depends upon working bit intersection and union. | |
887 enum use_def_enum { | |
888 INVALID = 0x0, | |
889 USE = 0x1, | |
890 DEF = 0x2, USE_DEF = 0x3, | |
891 KILL = 0x4, USE_KILL = 0x5, | |
892 SYNTHETIC = 0x8, | |
893 TEMP = USE | SYNTHETIC | |
894 }; | |
895 }; | |
896 | |
897 | |
898 //------------------------------MatchNode-------------------------------------- | |
899 class MatchNode : public Form { | |
900 private: | |
901 | |
902 public: | |
903 // Public Data | |
904 const char *_result; // The name of the output of this node | |
905 const char *_name; // The name that appeared in the match rule | |
906 const char *_opType; // The Operation/Type matched | |
907 MatchNode *_lChild; // Left child in expression tree | |
908 MatchNode *_rChild; // Right child in expression tree | |
909 int _numleaves; // Sum of numleaves for all direct children | |
910 ArchDesc &_AD; // Reference to ArchDesc object | |
911 char *_internalop; // String representing internal operand | |
912 int _commutative_id; // id of commutative operation | |
913 | |
914 // Public Methods | |
915 MatchNode(ArchDesc &ad, const char *result = 0, const char *expr = 0, | |
916 const char *opType=0, MatchNode *lChild=NULL, | |
917 MatchNode *rChild=NULL); | |
918 MatchNode(ArchDesc &ad, MatchNode& mNode); // Shallow copy constructor; | |
919 MatchNode(ArchDesc &ad, MatchNode& mNode, int clone); // Construct clone | |
920 ~MatchNode(); | |
921 | |
922 // return 0 if not found: | |
923 // return 1 if found and position is incremented by operand offset in rule | |
924 bool find_name(const char *str, int &position) const; | |
925 bool find_type(const char *str, int &position) const; | |
603
dbbe28fc66b5
6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents:
599
diff
changeset
|
926 virtual void append_components(FormDict& locals, ComponentList& components, |
dbbe28fc66b5
6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents:
599
diff
changeset
|
927 bool def_flag = false) const; |
0 | 928 bool base_operand(uint &position, FormDict &globals, |
929 const char * &result, const char * &name, | |
930 const char * &opType) const; | |
931 // recursive count on operands | |
932 uint num_consts(FormDict &globals) const; | |
933 uint num_const_ptrs(FormDict &globals) const; | |
934 // recursive count of constants with specified type | |
935 uint num_consts(FormDict &globals, Form::DataType type) const; | |
936 // uint num_consts() const; // Local inspection only | |
937 int needs_ideal_memory_edge(FormDict &globals) const; | |
938 int needs_base_oop_edge() const; | |
939 | |
940 // Help build instruction predicates. Search for operand names. | |
941 void count_instr_names( Dict &names ); | |
942 int build_instr_pred( char *buf, const char *name, int cnt ); | |
943 void build_internalop( ); | |
944 | |
945 // Return the name of the operands associated with reducing to this operand: | |
946 // The result type, plus the left and right sides of the binary match | |
947 // Return NULL if there is no left or right hand side | |
948 bool sets_result() const; // rule "Set"s result of match | |
949 const char *reduce_right(FormDict &globals) const; | |
950 const char *reduce_left (FormDict &globals) const; | |
951 | |
952 // Recursive version of check in MatchRule | |
603
dbbe28fc66b5
6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents:
599
diff
changeset
|
953 int cisc_spill_match(FormDict& globals, RegisterForm* registers, |
dbbe28fc66b5
6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents:
599
diff
changeset
|
954 MatchNode* mRule2, const char* &operand, |
dbbe28fc66b5
6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents:
599
diff
changeset
|
955 const char* ®_type); |
0 | 956 int cisc_spill_merge(int left_result, int right_result); |
957 | |
603
dbbe28fc66b5
6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents:
599
diff
changeset
|
958 virtual bool equivalent(FormDict& globals, MatchNode* mNode2); |
0 | 959 |
960 void count_commutative_op(int& count); | |
961 void swap_commutative_op(bool atroot, int count); | |
962 | |
963 void dump(); | |
964 void output(FILE *fp); | |
965 }; | |
966 | |
967 //------------------------------MatchRule-------------------------------------- | |
968 class MatchRule : public MatchNode { | |
969 private: | |
970 | |
971 public: | |
972 // Public Data | |
973 const char *_machType; // Machine type index | |
974 int _depth; // Expression tree depth | |
975 char *_construct; // String representing C++ constructor code | |
976 int _numchilds; // Number of direct children | |
977 MatchRule *_next; // Pointer to next match rule | |
978 | |
979 // Public Methods | |
980 MatchRule(ArchDesc &ad); | |
981 MatchRule(ArchDesc &ad, MatchRule* mRule); // Shallow copy constructor; | |
982 MatchRule(ArchDesc &ad, MatchNode* mroot, int depth, char* construct, int numleaves); | |
983 ~MatchRule(); | |
984 | |
603
dbbe28fc66b5
6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents:
599
diff
changeset
|
985 virtual void append_components(FormDict& locals, ComponentList& components, bool def_flag = false) const; |
0 | 986 // Recursive call on all operands' match rules in my match rule. |
987 bool base_operand(uint &position, FormDict &globals, | |
988 const char * &result, const char * &name, | |
989 const char * &opType) const; | |
990 | |
991 | |
992 bool is_base_register(FormDict &globals) const; | |
993 Form::DataType is_base_constant(FormDict &globals) const; | |
994 bool is_chain_rule(FormDict &globals) const; | |
995 int is_ideal_copy() const; | |
996 int is_expensive() const; // node matches ideal 'CosD' | |
997 bool is_ideal_unlock() const; | |
998 bool is_ideal_call_leaf() const; | |
999 bool is_ideal_if() const; // node matches ideal 'If' | |
1000 bool is_ideal_fastlock() const; // node matches ideal 'FastLock' | |
1001 bool is_ideal_jump() const; // node matches ideal 'Jump' | |
1002 bool is_ideal_membar() const; // node matches ideal 'MemBarXXX' | |
1003 bool is_ideal_loadPC() const; // node matches ideal 'LoadPC' | |
1004 bool is_ideal_box() const; // node matches ideal 'Box' | |
1005 bool is_ideal_goto() const; // node matches ideal 'Goto' | |
1006 bool is_ideal_loopEnd() const; // node matches ideal 'LoopEnd' | |
1007 bool is_ideal_bool() const; // node matches ideal 'Bool' | |
1008 Form::DataType is_ideal_load() const;// node matches ideal 'LoadXNode' | |
855
f9094a5e1c8a
6857159: local schedule failed with checkcast of Thread.currentThread()
never
parents:
605
diff
changeset
|
1009 // Should antidep checks be disabled for this rule |
f9094a5e1c8a
6857159: local schedule failed with checkcast of Thread.currentThread()
never
parents:
605
diff
changeset
|
1010 // See definition of MatchRule::skip_antidep_check |
f9094a5e1c8a
6857159: local schedule failed with checkcast of Thread.currentThread()
never
parents:
605
diff
changeset
|
1011 bool skip_antidep_check() const; |
0 | 1012 Form::DataType is_ideal_store() const;// node matches ideal 'StoreXNode' |
1013 | |
1014 // Check if 'mRule2' is a cisc-spill variant of this MatchRule | |
603
dbbe28fc66b5
6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents:
599
diff
changeset
|
1015 int matchrule_cisc_spill_match(FormDict &globals, RegisterForm* registers, |
dbbe28fc66b5
6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents:
599
diff
changeset
|
1016 MatchRule* mRule2, const char* &operand, |
dbbe28fc66b5
6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents:
599
diff
changeset
|
1017 const char* ®_type); |
0 | 1018 |
1019 // Check if 'mRule2' is equivalent to this MatchRule | |
603
dbbe28fc66b5
6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents:
599
diff
changeset
|
1020 virtual bool equivalent(FormDict& globals, MatchNode* mRule2); |
0 | 1021 |
603
dbbe28fc66b5
6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents:
599
diff
changeset
|
1022 void matchrule_swap_commutative_op(const char* instr_ident, int count, int& match_rules_cnt); |
0 | 1023 |
1024 void dump(); | |
1025 void output(FILE *fp); | |
1026 }; | |
1027 | |
1028 //------------------------------Attribute-------------------------------------- | |
1029 class Attribute : public Form { | |
1030 private: | |
1031 | |
1032 public: | |
1033 // Public Data | |
1034 char *_ident; // Name of predefined attribute | |
1035 char *_val; // C++ source which evaluates to constant | |
1036 int _atype; // Either INS_ATTR or OP_ATTR | |
1037 int int_val(ArchDesc &ad); // Return atoi(_val), ensuring syntax. | |
1038 | |
1039 // Public Methods | |
1040 Attribute(char *id, char* val, int type); | |
1041 ~Attribute(); | |
1042 | |
1043 void dump(); | |
1044 void output(FILE *fp); | |
1045 }; | |
1046 | |
1047 //------------------------------FormatRule------------------------------------- | |
1048 class FormatRule : public Form { | |
1049 private: | |
1050 | |
1051 public: | |
1052 // Public Data | |
1053 // There is an entry in _strings, perhaps NULL, that precedes each _rep_vars | |
1054 NameList _strings; // Strings passed through to tty->print | |
1055 NameList _rep_vars; // replacement variables | |
1056 char *_temp; // String representing the assembly code | |
1057 | |
1058 // Public Methods | |
1059 FormatRule(char *temp); | |
1060 ~FormatRule(); | |
1061 | |
1062 void dump(); | |
1063 void output(FILE *fp); | |
1064 }; |