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