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