Path: blob/jdk8u272-b10-aarch32-20201026/hotspot/src/share/vm/adlc/formssel.hpp
48789 views
/*1* Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#ifndef SHARE_VM_ADLC_FORMSSEL_HPP25#define SHARE_VM_ADLC_FORMSSEL_HPP2627// FORMSSEL.HPP - ADL Parser Instruction Selection Forms Classes2829// Class List30class Form;31class InstructForm;32class MachNodeForm;33class OperandForm;34class OpClassForm;35class AttributeForm;36class RegisterForm;37class PipelineForm;38class SourceForm;39class EncodeForm;40class Component;41class Constraint;42class Predicate;43class MatchRule;44class Attribute;45class Effect;46class ExpandRule;47class RewriteRule;48class ConstructRule;49class FormatRule;50class Peephole;51class EncClass;52class Interface;53class RegInterface;54class ConstInterface;55class MemInterface;56class CondInterface;57class Opcode;58class InsEncode;59class RegDef;60class RegClass;61class CodeSnippetRegClass;62class ConditionalRegClass;63class AllocClass;64class ResourceForm;65class PipeDesc;66class PipeClass;67class PeepMatch;68class PeepConstraint;69class PeepReplace;70class MatchList;7172class ArchDesc;7374//==============================Instructions===================================75//------------------------------InstructForm-----------------------------------76class InstructForm : public Form {77private:78bool _ideal_only; // Not a user-defined instruction79// Members used for tracking CISC-spilling80int _cisc_spill_operand;// Which operand may cisc-spill81void set_cisc_spill_operand(uint op_index) { _cisc_spill_operand = op_index; }82bool _is_cisc_alternate;83InstructForm *_cisc_spill_alternate;// cisc possible replacement84const char *_cisc_reg_mask_name;85InstructForm *_short_branch_form;86bool _is_short_branch;87bool _is_mach_constant; // True if Node is a MachConstantNode.88bool _needs_constant_base; // True if Node needs the mach_constant_base input.89uint _alignment;9091public:92// Public Data93const char *_ident; // Name of this instruction94NameList _parameters; // Locally defined names95FormDict _localNames; // Table of operands & their types96MatchRule *_matrule; // Matching rule for this instruction97Opcode *_opcode; // Encoding of the opcode for instruction98char *_size; // Size of instruction99InsEncode *_insencode; // Encoding class instruction belongs to100InsEncode *_constant; // Encoding class constant value belongs to101bool _is_postalloc_expand; // Indicates that encoding just does a lateExpand.102Attribute *_attribs; // List of Attribute rules103Predicate *_predicate; // Predicate test for this instruction104FormDict _effects; // Dictionary of effect rules105ExpandRule *_exprule; // Expand rule for this instruction106RewriteRule *_rewrule; // Rewrite rule for this instruction107FormatRule *_format; // Format for assembly generation108Peephole *_peephole; // List of peephole rules for instruction109const char *_ins_pipe; // Instruction Scheduling description class110111uint *_uniq_idx; // Indexes of unique operands112uint _uniq_idx_length; // Length of _uniq_idx array113uint _num_uniq; // Number of unique operands114ComponentList _components; // List of Components matches MachNode's115// operand structure116117bool _has_call; // contain a call and caller save registers should be saved?118119// Public Methods120InstructForm(const char *id, bool ideal_only = false);121InstructForm(const char *id, InstructForm *instr, MatchRule *rule);122~InstructForm();123124// Dynamic type check125virtual InstructForm *is_instruction() const;126127virtual bool ideal_only() const;128129// This instruction sets a result130virtual bool sets_result() const;131// This instruction needs projections for additional DEFs or KILLs132virtual bool needs_projections();133// This instruction needs extra nodes for temporary inputs134virtual bool has_temps();135// This instruction defines or kills more than one object136virtual uint num_defs_or_kills();137// This instruction has an expand rule?138virtual bool expands() const ;139// This instruction has a late expand rule?140virtual bool postalloc_expands() const;141// Return this instruction's first peephole rule, or NULL142virtual Peephole *peepholes() const;143// Add a peephole rule to this instruction144virtual void append_peephole(Peephole *peep);145146virtual bool is_pinned(FormDict &globals); // should be pinned inside block147virtual bool is_projection(FormDict &globals); // node requires projection148virtual bool is_parm(FormDict &globals); // node matches ideal 'Parm'149// ideal opcode enumeration150virtual const char *ideal_Opcode(FormDict &globals) const;151virtual int is_expensive() const; // node matches ideal 'CosD'152virtual int is_empty_encoding() const; // _size=0 and/or _insencode empty153virtual int is_tls_instruction() const; // tlsLoadP rule or ideal ThreadLocal154virtual int is_ideal_copy() const; // node matches ideal 'Copy*'155virtual bool is_ideal_negD() const; // node matches ideal 'NegD'156virtual bool is_ideal_if() const; // node matches ideal 'If'157virtual bool is_ideal_fastlock() const; // node matches 'FastLock'158virtual bool is_ideal_membar() const; // node matches ideal 'MemBarXXX'159virtual bool is_ideal_loadPC() const; // node matches ideal 'LoadPC'160virtual bool is_ideal_box() const; // node matches ideal 'Box'161virtual bool is_ideal_goto() const; // node matches ideal 'Goto'162virtual bool is_ideal_branch() const; // "" 'If' | 'Goto' | 'LoopEnd' | 'Jump'163virtual bool is_ideal_jump() const; // node matches ideal 'Jump'164virtual bool is_ideal_return() const; // node matches ideal 'Return'165virtual bool is_ideal_halt() const; // node matches ideal 'Halt'166virtual bool is_ideal_safepoint() const; // node matches 'SafePoint'167virtual bool is_ideal_nop() const; // node matches 'Nop'168virtual bool is_ideal_control() const; // control node169virtual bool is_vector() const; // vector instruction170171virtual Form::CallType is_ideal_call() const; // matches ideal 'Call'172virtual Form::DataType is_ideal_load() const; // node matches ideal 'LoadXNode'173// Should antidep checks be disabled for this Instruct174// See definition of MatchRule::skip_antidep_check175bool skip_antidep_check() const;176virtual Form::DataType is_ideal_store() const;// node matches ideal 'StoreXNode'177bool is_ideal_mem() const { return is_ideal_load() != Form::none || is_ideal_store() != Form::none; }178virtual uint two_address(FormDict &globals); // output reg must match input reg179// when chaining a constant to an instruction, return 'true' and set opType180virtual Form::DataType is_chain_of_constant(FormDict &globals);181virtual Form::DataType is_chain_of_constant(FormDict &globals, const char * &opType);182virtual Form::DataType is_chain_of_constant(FormDict &globals, const char * &opType, const char * &result_type);183184// Check if a simple chain rule185virtual bool is_simple_chain_rule(FormDict &globals) const;186187// check for structural rematerialization188virtual bool rematerialize(FormDict &globals, RegisterForm *registers);189190// loads from memory, so must check for anti-dependence191virtual bool needs_anti_dependence_check(FormDict &globals) const;192virtual int memory_operand(FormDict &globals) const;193bool is_wide_memory_kill(FormDict &globals) const;194195enum memory_operand_type {196NO_MEMORY_OPERAND = -1,197MANY_MEMORY_OPERANDS = 999999198};199200201// This instruction captures the machine-independent bottom_type202// Expected use is for pointer vs oop determination for LoadP203virtual bool captures_bottom_type(FormDict& globals) const;204205virtual const char *cost(); // Access ins_cost attribute206virtual uint num_opnds(); // Count of num_opnds for MachNode class207// Counts USE_DEF opnds twice. See also num_unique_opnds().208virtual uint num_post_match_opnds();209virtual uint num_consts(FormDict &globals) const;// Constants in match rule210// Constants in match rule with specified type211virtual uint num_consts(FormDict &globals, Form::DataType type) const;212213// Return the register class associated with 'leaf'.214virtual const char *out_reg_class(FormDict &globals);215216// number of ideal node inputs to skip217virtual uint oper_input_base(FormDict &globals);218219// Does this instruction need a base-oop edge?220int needs_base_oop_edge(FormDict &globals) const;221222// Build instruction predicates. If the user uses the same operand name223// twice, we need to check that the operands are pointer-eequivalent in224// the DFA during the labeling process.225Predicate *build_predicate();226227virtual void build_components(); // top-level operands228// Return zero-based position in component list; -1 if not in list.229virtual int operand_position(const char *name, int usedef);230virtual int operand_position_format(const char *name);231232// Return zero-based position in component list; -1 if not in list.233virtual int label_position();234virtual int method_position();235// Return number of relocation entries needed for this instruction.236virtual uint reloc(FormDict &globals);237238const char *opnd_ident(int idx); // Name of operand #idx.239const char *reduce_result();240// Return the name of the operand on the right hand side of the binary match241// Return NULL if there is no right hand side242const char *reduce_right(FormDict &globals) const;243const char *reduce_left(FormDict &globals) const;244245// Base class for this instruction, MachNode except for calls246virtual const char *mach_base_class(FormDict &globals) const;247248// Check if this instruction can cisc-spill to 'alternate'249bool cisc_spills_to(ArchDesc &AD, InstructForm *alternate);250InstructForm *cisc_spill_alternate() { return _cisc_spill_alternate; }251int cisc_spill_operand() const { return _cisc_spill_operand; }252bool is_cisc_alternate() const { return _is_cisc_alternate; }253void set_cisc_alternate(bool val) { _is_cisc_alternate = val; }254const char *cisc_reg_mask_name() const { return _cisc_reg_mask_name; }255void set_cisc_reg_mask_name(const char *rm_name) { _cisc_reg_mask_name = rm_name; }256// Output cisc-method prototypes and method bodies257void declare_cisc_version(ArchDesc &AD, FILE *fp_cpp);258bool define_cisc_version (ArchDesc &AD, FILE *fp_cpp);259260bool check_branch_variant(ArchDesc &AD, InstructForm *short_branch);261262bool is_short_branch() { return _is_short_branch; }263void set_short_branch(bool val) { _is_short_branch = val; }264265bool is_mach_constant() const { return _is_mach_constant; }266void set_is_mach_constant(bool x) { _is_mach_constant = x; }267bool needs_constant_base() const { return _needs_constant_base; }268void set_needs_constant_base(bool x) { _needs_constant_base = x; }269270InstructForm *short_branch_form() { return _short_branch_form; }271bool has_short_branch_form() { return _short_branch_form != NULL; }272// Output short branch prototypes and method bodies273void declare_short_branch_methods(FILE *fp_cpp);274bool define_short_branch_methods(ArchDesc &AD, FILE *fp_cpp);275276uint alignment() { return _alignment; }277void set_alignment(uint val) { _alignment = val; }278279// Seach through operands to determine operands unique positions.280void set_unique_opnds();281uint num_unique_opnds() { return _num_uniq; }282uint unique_opnds_idx(int idx) {283if (_uniq_idx != NULL && idx > 0) {284assert((uint)idx < _uniq_idx_length, "out of bounds");285return _uniq_idx[idx];286} else {287return idx;288}289}290const char *unique_opnd_ident(uint idx); // Name of operand at unique idx.291292// Operands which are only KILLs aren't part of the input array and293// require special handling in some cases. Their position in this294// operand list is higher than the number of unique operands.295bool is_noninput_operand(uint idx) {296return (idx >= num_unique_opnds());297}298299// --------------------------- FILE *output_routines300//301// Generate the format call for the replacement variable302void rep_var_format(FILE *fp, const char *rep_var);303// Generate index values needed for determining the operand position304void index_temps (FILE *fp, FormDict &globals, const char *prefix = "", const char *receiver = "");305// ---------------------------306307virtual bool verify(); // Check consistency after parsing308309virtual void dump(); // Debug printer310virtual void output(FILE *fp); // Write to output files311};312313//------------------------------EncodeForm-------------------------------------314class EncodeForm : public Form {315private:316317public:318// Public Data319NameList _eclasses; // List of encode class names320Dict _encClass; // Map encode class names to EncClass objects321322// Public Methods323EncodeForm();324~EncodeForm();325326EncClass *add_EncClass(const char *className);327EncClass *encClass(const char *className);328329const char *encClassPrototype(const char *className);330const char *encClassBody(const char *className);331332void dump(); // Debug printer333void output(FILE *fp); // Write info to output files334};335336//------------------------------EncClass---------------------------------------337class EncClass : public Form {338public:339// NameList for parameter type and name340NameList _parameter_type;341NameList _parameter_name;342343// Breakdown the encoding into strings separated by $replacement_variables344// There is an entry in _strings, perhaps NULL, that precedes each _rep_vars345NameList _code; // Strings passed through to tty->print346NameList _rep_vars; // replacement variables347348NameList _parameters; // Locally defined names349FormDict _localNames; // Table of components & their types350351public:352// Public Data353const char *_name; // encoding class name354355// Public Methods356EncClass(const char *name);357~EncClass();358359// --------------------------- Parameters360// Add a parameter <type,name> pair361void add_parameter(const char *parameter_type, const char *parameter_name);362// Verify operand types in parameter list363bool check_parameter_types(FormDict &globals);364// Obtain the zero-based index corresponding to a replacement variable365int rep_var_index(const char *rep_var);366int num_args() { return _parameter_name.count(); }367368// --------------------------- Code Block369// Add code370void add_code(const char *string_preceding_replacement_var);371// Add a replacement variable or one of its subfields372// Subfields are stored with a leading '$'373void add_rep_var(char *replacement_var);374375bool verify();376void dump();377void output(FILE *fp);378};379380//------------------------------MachNode---------------------------------------381class MachNodeForm: public Form {382private:383384public:385char *_ident; // Name of this instruction386const char *_machnode_pipe; // Instruction Scheduline description class387388// Public Methods389MachNodeForm(char *id);390~MachNodeForm();391392virtual MachNodeForm *is_machnode() const;393394void dump(); // Debug printer395void output(FILE *fp); // Write info to output files396};397398//------------------------------Opcode-----------------------------------------399class Opcode : public Form {400private:401402public:403// Public Data404// Strings representing instruction opcodes, user defines placement in emit405char *_primary;406char *_secondary;407char *_tertiary;408409enum opcode_type {410NOT_AN_OPCODE = -1,411PRIMARY = 1,412SECONDARY = 2,413TERTIARY = 3414};415416// Public Methods417Opcode(char *primary, char *secondary, char *tertiary);418~Opcode();419420static Opcode::opcode_type as_opcode_type(const char *designator);421422void dump();423void output(FILE *fp);424425// --------------------------- FILE *output_routines426bool print_opcode(FILE *fp, Opcode::opcode_type desired_opcode);427};428429//------------------------------InsEncode--------------------------------------430class InsEncode : public Form {431private:432// Public Data (access directly only for reads)433// The encodings can only have the values predefined by the ADLC:434// blank, RegReg, RegMem, MemReg, ...435NameList _encoding;436// NameList _parameter;437// The parameters for each encoding are preceeded by a NameList::_signal438// and follow the parameters for the previous encoding.439440// char *_encode; // Type of instruction encoding441442public:443// Public Methods444InsEncode();445~InsEncode();446447// Add "encode class name" and its parameters448NameAndList *add_encode(char *encode_method_name);449// Parameters are added to the returned "NameAndList" by the parser450451// Access the list of encodings452void reset();453const char *encode_class_iter();454455// Returns the number of arguments to the current encoding in the iteration456int current_encoding_num_args() {457return ((NameAndList*)_encoding.current())->count();458}459460// --------------------------- Parameters461// The following call depends upon position within encode_class_iteration462//463// Obtain parameter name from zero based index464const char *rep_var_name(InstructForm &inst, uint param_no);465// ---------------------------466467void dump();468void output(FILE *fp);469};470471//------------------------------Effect-----------------------------------------472class Effect : public Form {473private:474475public:476// Public Data477const char *_name; // Pre-defined name for effect478int _use_def; // Enumeration value of effect479480// Public Methods481Effect(const char *name); // Constructor482~Effect(); // Destructor483484// Dynamic type check485virtual Effect *is_effect() const;486487// Return 'true' if this use def info equals the parameter488bool is(int use_def_kill_enum) const;489// Return 'true' if this use def info is a superset of parameter490bool isa(int use_def_kill_enum) const;491492void dump(); // Debug printer493void output(FILE *fp); // Write info to output files494};495496//------------------------------ExpandRule-------------------------------------497class ExpandRule : public Form {498private:499NameList _expand_instrs; // ordered list of instructions and operands500501public:502// Public Data503NameList _newopers; // List of newly created operands504Dict _newopconst; // Map new operands to their constructors505506void add_instruction(NameAndList *instruction_name_and_operand_list);507void reset_instructions();508NameAndList *iter_instructions();509510// Public Methods511ExpandRule(); // Constructor512~ExpandRule(); // Destructor513514void dump(); // Debug printer515void output(FILE *fp); // Write info to output files516};517518//------------------------------RewriteRule------------------------------------519class RewriteRule : public Form {520private:521522public:523// Public Data524SourceForm *_condition; // Rewrite condition code525InstructForm *_instrs; // List of instructions to expand to526OperandForm *_opers; // List of operands generated by expand527char *_tempParams; // Hold string until parser is finished.528char *_tempBlock; // Hold string until parser is finished.529530// Public Methods531RewriteRule(char* params, char* block) ;532~RewriteRule(); // Destructor533void dump(); // Debug printer534void output(FILE *fp); // Write info to output files535};536537538//==============================Operands=======================================539//------------------------------OpClassForm------------------------------------540class OpClassForm : public Form {541public:542// Public Data543const char *_ident; // Name of this operand544NameList _oplst; // List of operand forms included in class545546// Public Methods547OpClassForm(const char *id);548~OpClassForm();549550// dynamic type check551virtual OpClassForm *is_opclass() const;552virtual Form::InterfaceType interface_type(FormDict &globals) const;553virtual bool stack_slots_only(FormDict &globals) const;554555virtual bool is_cisc_mem(FormDict &globals) const;556557558// Min and Max opcodes of operands in this operand class559int _minCode;560int _maxCode;561562virtual bool ideal_only() const;563virtual void dump(); // Debug printer564virtual void output(FILE *fp); // Write to output files565};566567//------------------------------OperandForm------------------------------------568class OperandForm : public OpClassForm {569private:570bool _ideal_only; // Not a user-defined instruction571572public:573// Public Data574NameList _parameters; // Locally defined names575FormDict _localNames; // Table of components & their types576MatchRule *_matrule; // Matching rule for this operand577Interface *_interface; // Encoding interface for this operand578Attribute *_attribs; // List of Attribute rules579Predicate *_predicate; // Predicate test for this operand580Constraint *_constraint; // Constraint Rule for this operand581ConstructRule *_construct; // Construction of operand data after matching582FormatRule *_format; // Format for assembly generation583NameList _classes; // List of opclasses which contain this oper584585ComponentList _components; //586587// Public Methods588OperandForm(const char *id);589OperandForm(const char *id, bool ideal_only);590~OperandForm();591592// Dynamic type check593virtual OperandForm *is_operand() const;594595virtual bool ideal_only() const;596virtual Form::InterfaceType interface_type(FormDict &globals) const;597virtual bool stack_slots_only(FormDict &globals) const;598599virtual const char *cost(); // Access ins_cost attribute600virtual uint num_leaves() const;// Leaves in complex operand601// Constants in operands' match rules602virtual uint num_consts(FormDict &globals) const;603// Constants in operand's match rule with specified type604virtual uint num_consts(FormDict &globals, Form::DataType type) const;605// Pointer Constants in operands' match rules606virtual uint num_const_ptrs(FormDict &globals) const;607// The number of input edges in the machine world == num_leaves - num_consts608virtual uint num_edges(FormDict &globals) const;609610// Check if this operand is usable for cisc-spilling611virtual bool is_cisc_reg(FormDict &globals) const;612613// node matches ideal 'Bool', grab condition codes from the ideal world614virtual bool is_ideal_bool() const;615616// Has an integer constant suitable for spill offsets617bool has_conI(FormDict &globals) const {618return (num_consts(globals,idealI) == 1) && !is_ideal_bool(); }619bool has_conL(FormDict &globals) const {620return (num_consts(globals,idealL) == 1) && !is_ideal_bool(); }621622// Node is user-defined operand for an sRegX623virtual Form::DataType is_user_name_for_sReg() const;624625// Return ideal type, if there is a single ideal type for this operand626virtual const char *ideal_type(FormDict &globals, RegisterForm *registers = NULL) const;627// If there is a single ideal type for this interface field, return it.628virtual const char *interface_ideal_type(FormDict &globals,629const char *field_name) const;630631// Return true if this operand represents a bound register class632bool is_bound_register() const;633634// Return the Register class for this operand. Returns NULL if635// operand isn't a register form.636RegClass* get_RegClass() const;637638virtual bool is_interface_field(const char *field_name,639const char * &value) const;640641// If this operand has a single ideal type, return its type642virtual Form::DataType simple_type(FormDict &globals) const;643// If this operand is an ideal constant, return its type644virtual Form::DataType is_base_constant(FormDict &globals) const;645646// "true" if this operand is a simple type that is swallowed647virtual bool swallowed(FormDict &globals) const;648649// Return register class name if a constraint specifies the register class.650virtual const char *constrained_reg_class() const;651// Return the register class associated with 'leaf'.652virtual const char *in_reg_class(uint leaf, FormDict &globals);653654// Build component list from MatchRule and operand's parameter list655virtual void build_components(); // top-level operands656657// Return zero-based position in component list; -1 if not in list.658virtual int operand_position(const char *name, int usedef);659660// Return zero-based position in component list; -1 if not in list.661virtual int constant_position(FormDict &globals, const Component *comp);662virtual int constant_position(FormDict &globals, const char *local_name);663// Return the operand form corresponding to the given index, else NULL.664virtual OperandForm *constant_operand(FormDict &globals, uint const_index);665666// Return zero-based position in component list; -1 if not in list.667virtual int register_position(FormDict &globals, const char *regname);668669const char *reduce_result() const;670// Return the name of the operand on the right hand side of the binary match671// Return NULL if there is no right hand side672const char *reduce_right(FormDict &globals) const;673const char *reduce_left(FormDict &globals) const;674675676// --------------------------- FILE *output_routines677//678// Output code for disp_is_oop, if true.679void disp_is_oop(FILE *fp, FormDict &globals);680// Generate code for internal and external format methods681void int_format(FILE *fp, FormDict &globals, uint index);682void ext_format(FILE *fp, FormDict &globals, uint index);683void format_constant(FILE *fp, uint con_index, uint con_type);684// Output code to access the value of the index'th constant685void access_constant(FILE *fp, FormDict &globals,686uint con_index);687// ---------------------------688689690virtual void dump(); // Debug printer691virtual void output(FILE *fp); // Write to output files692};693694//------------------------------Constraint-------------------------------------695class Constraint : public Form {696private:697698public:699const char *_func; // Constraint function700const char *_arg; // function's argument701702// Public Methods703Constraint(const char *func, const char *arg); // Constructor704~Constraint();705706bool stack_slots_only() const;707708void dump(); // Debug printer709void output(FILE *fp); // Write info to output files710};711712//------------------------------Predicate--------------------------------------713class Predicate : public Form {714private:715716public:717// Public Data718char *_pred; // C++ source string for predicate719720// Public Methods721Predicate(char *pr);722~Predicate();723724void dump();725void output(FILE *fp);726};727728//------------------------------Interface--------------------------------------729class Interface : public Form {730private:731732public:733// Public Data734const char *_name; // String representing the interface name735736// Public Methods737Interface(const char *name);738~Interface();739740virtual Form::InterfaceType interface_type(FormDict &globals) const;741742RegInterface *is_RegInterface();743MemInterface *is_MemInterface();744ConstInterface *is_ConstInterface();745CondInterface *is_CondInterface();746747748void dump();749void output(FILE *fp);750};751752//------------------------------RegInterface-----------------------------------753class RegInterface : public Interface {754private:755756public:757// Public Methods758RegInterface();759~RegInterface();760761void dump();762void output(FILE *fp);763};764765//------------------------------ConstInterface---------------------------------766class ConstInterface : public Interface {767private:768769public:770// Public Methods771ConstInterface();772~ConstInterface();773774void dump();775void output(FILE *fp);776};777778//------------------------------MemInterface-----------------------------------779class MemInterface : public Interface {780private:781782public:783// Public Data784char *_base; // Base address785char *_index; // index786char *_scale; // scaling factor787char *_disp; // displacement788789// Public Methods790MemInterface(char *base, char *index, char *scale, char *disp);791~MemInterface();792793void dump();794void output(FILE *fp);795};796797//------------------------------CondInterface----------------------------------798class CondInterface : public Interface {799private:800801public:802const char *_equal;803const char *_not_equal;804const char *_less;805const char *_greater_equal;806const char *_less_equal;807const char *_greater;808const char *_overflow;809const char *_no_overflow;810const char *_equal_format;811const char *_not_equal_format;812const char *_less_format;813const char *_greater_equal_format;814const char *_less_equal_format;815const char *_greater_format;816const char *_overflow_format;817const char *_no_overflow_format;818819// Public Methods820CondInterface(const char* equal, const char* equal_format,821const char* not_equal, const char* not_equal_format,822const char* less, const char* less_format,823const char* greater_equal, const char* greater_equal_format,824const char* less_equal, const char* less_equal_format,825const char* greater, const char* greater_format,826const char* overflow, const char* overflow_format,827const char* no_overflow, const char* no_overflow_format);828~CondInterface();829830void dump();831void output(FILE *fp);832};833834//------------------------------ConstructRule----------------------------------835class ConstructRule : public Form {836private:837838public:839// Public Data840char *_expr; // String representing the match expression841char *_construct; // String representing C++ constructor code842843// Public Methods844ConstructRule(char *cnstr);845~ConstructRule();846847void dump();848void output(FILE *fp);849};850851852//==============================Shared=========================================853//------------------------------AttributeForm----------------------------------854class AttributeForm : public Form {855private:856// counters for unique instruction or operand ID857static int _insId; // user-defined machine instruction types858static int _opId; // user-defined operand types859860int id; // hold type for this object861862public:863// Public Data864char *_attrname; // Name of attribute865int _atype; // Either INS_ATTR or OP_ATTR866char *_attrdef; // C++ source which evaluates to constant867868// Public Methods869AttributeForm(char *attr, int type, char *attrdef);870~AttributeForm();871872// Dynamic type check873virtual AttributeForm *is_attribute() const;874875int type() { return id;} // return this object's "id"876877static const char* _ins_cost; // "ins_cost"878static const char* _op_cost; // "op_cost"879880void dump(); // Debug printer881void output(FILE *fp); // Write output files882};883884//------------------------------Component--------------------------------------885class Component : public Form {886private:887888public:889// Public Data890const char *_name; // Name of this component891const char *_type; // Type of this component892int _usedef; // Value of component893894// Public Methods895Component(const char *name, const char *type, int usedef);896~Component();897898899// Return 'true' if this use def info equals the parameter900bool is(int use_def_kill_enum) const;901// Return 'true' if this use def info is a superset of parameter902bool isa(int use_def_kill_enum) const;903int promote_use_def_info(int new_use_def);904const char *base_type(FormDict &globals);905// Form::DataType is_base_constant(FormDict &globals);906907void dump(); // Debug printer908void output(FILE *fp); // Write to output files909const char* getUsedefName();910911public:912// Implementation depends upon working bit intersection and union.913enum use_def_enum {914INVALID = 0x0,915USE = 0x1,916DEF = 0x2, USE_DEF = 0x3,917KILL = 0x4, USE_KILL = 0x5,918SYNTHETIC = 0x8,919TEMP = USE | SYNTHETIC,920CALL = 0x10921};922};923924925//------------------------------MatchNode--------------------------------------926class MatchNode : public Form {927private:928929public:930// Public Data931const char *_result; // The name of the output of this node932const char *_name; // The name that appeared in the match rule933const char *_opType; // The Operation/Type matched934MatchNode *_lChild; // Left child in expression tree935MatchNode *_rChild; // Right child in expression tree936int _numleaves; // Sum of numleaves for all direct children937ArchDesc &_AD; // Reference to ArchDesc object938char *_internalop; // String representing internal operand939int _commutative_id; // id of commutative operation940941// Public Methods942MatchNode(ArchDesc &ad, const char *result = 0, const char *expr = 0,943const char *opType=0, MatchNode *lChild=NULL,944MatchNode *rChild=NULL);945MatchNode(ArchDesc &ad, MatchNode& mNode); // Shallow copy constructor;946MatchNode(ArchDesc &ad, MatchNode& mNode, int clone); // Construct clone947~MatchNode();948949// return 0 if not found:950// return 1 if found and position is incremented by operand offset in rule951bool find_name(const char *str, int &position) const;952bool find_type(const char *str, int &position) const;953virtual void append_components(FormDict& locals, ComponentList& components,954bool def_flag = false) const;955bool base_operand(uint &position, FormDict &globals,956const char * &result, const char * &name,957const char * &opType) const;958// recursive count on operands959uint num_consts(FormDict &globals) const;960uint num_const_ptrs(FormDict &globals) const;961// recursive count of constants with specified type962uint num_consts(FormDict &globals, Form::DataType type) const;963// uint num_consts() const; // Local inspection only964int needs_ideal_memory_edge(FormDict &globals) const;965int needs_base_oop_edge() const;966967// Help build instruction predicates. Search for operand names.968void count_instr_names( Dict &names );969int build_instr_pred( char *buf, const char *name, int cnt );970void build_internalop( );971972// Return the name of the operands associated with reducing to this operand:973// The result type, plus the left and right sides of the binary match974// Return NULL if there is no left or right hand side975bool sets_result() const; // rule "Set"s result of match976const char *reduce_right(FormDict &globals) const;977const char *reduce_left (FormDict &globals) const;978979// Recursive version of check in MatchRule980int cisc_spill_match(FormDict& globals, RegisterForm* registers,981MatchNode* mRule2, const char* &operand,982const char* ®_type);983int cisc_spill_merge(int left_result, int right_result);984985virtual bool equivalent(FormDict& globals, MatchNode* mNode2);986987void count_commutative_op(int& count);988void swap_commutative_op(bool atroot, int count);989990void dump();991void output(FILE *fp);992};993994//------------------------------MatchRule--------------------------------------995class MatchRule : public MatchNode {996private:997998public:999// Public Data1000const char *_machType; // Machine type index1001int _depth; // Expression tree depth1002char *_construct; // String representing C++ constructor code1003int _numchilds; // Number of direct children1004MatchRule *_next; // Pointer to next match rule10051006// Public Methods1007MatchRule(ArchDesc &ad);1008MatchRule(ArchDesc &ad, MatchRule* mRule); // Shallow copy constructor;1009MatchRule(ArchDesc &ad, MatchNode* mroot, int depth, char* construct, int numleaves);1010~MatchRule();10111012virtual void append_components(FormDict& locals, ComponentList& components, bool def_flag = false) const;1013// Recursive call on all operands' match rules in my match rule.1014bool base_operand(uint &position, FormDict &globals,1015const char * &result, const char * &name,1016const char * &opType) const;101710181019bool is_base_register(FormDict &globals) const;1020Form::DataType is_base_constant(FormDict &globals) const;1021bool is_chain_rule(FormDict &globals) const;1022int is_ideal_copy() const;1023int is_expensive() const; // node matches ideal 'CosD'1024bool is_ideal_if() const; // node matches ideal 'If'1025bool is_ideal_fastlock() const; // node matches ideal 'FastLock'1026bool is_ideal_jump() const; // node matches ideal 'Jump'1027bool is_ideal_membar() const; // node matches ideal 'MemBarXXX'1028bool is_ideal_loadPC() const; // node matches ideal 'LoadPC'1029bool is_ideal_box() const; // node matches ideal 'Box'1030bool is_ideal_goto() const; // node matches ideal 'Goto'1031bool is_ideal_loopEnd() const; // node matches ideal 'LoopEnd'1032bool is_ideal_bool() const; // node matches ideal 'Bool'1033bool is_vector() const; // vector instruction1034Form::DataType is_ideal_load() const;// node matches ideal 'LoadXNode'1035// Should antidep checks be disabled for this rule1036// See definition of MatchRule::skip_antidep_check1037bool skip_antidep_check() const;1038Form::DataType is_ideal_store() const;// node matches ideal 'StoreXNode'10391040// Check if 'mRule2' is a cisc-spill variant of this MatchRule1041int matchrule_cisc_spill_match(FormDict &globals, RegisterForm* registers,1042MatchRule* mRule2, const char* &operand,1043const char* ®_type);10441045// Check if 'mRule2' is equivalent to this MatchRule1046virtual bool equivalent(FormDict& globals, MatchNode* mRule2);10471048void matchrule_swap_commutative_op(const char* instr_ident, int count, int& match_rules_cnt);10491050void dump();1051void output_short(FILE *fp);1052void output(FILE *fp);1053};10541055//------------------------------Attribute--------------------------------------1056class Attribute : public Form {1057private:10581059public:1060// Public Data1061char *_ident; // Name of predefined attribute1062char *_val; // C++ source which evaluates to constant1063int _atype; // Either INS_ATTR or OP_ATTR1064int int_val(ArchDesc &ad); // Return atoi(_val), ensuring syntax.10651066// Public Methods1067Attribute(char *id, char* val, int type);1068~Attribute();10691070void dump();1071void output(FILE *fp);1072};10731074//------------------------------FormatRule-------------------------------------1075class FormatRule : public Form {1076private:10771078public:1079// Public Data1080// There is an entry in _strings, perhaps NULL, that precedes each _rep_vars1081NameList _strings; // Strings passed through to tty->print1082NameList _rep_vars; // replacement variables1083char *_temp; // String representing the assembly code10841085// Public Methods1086FormatRule(char *temp);1087~FormatRule();10881089void dump();1090void output(FILE *fp);1091};10921093#endif // SHARE_VM_ADLC_FORMSSEL_HPP109410951096