/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#ifndef SHARE_VM_ADLC_FORMSSEL_HPP
#define SHARE_VM_ADLC_FORMSSEL_HPP
// FORMSSEL.HPP - ADL Parser Instruction Selection Forms Classes
// Class List
class Form;
class InstructForm;
class MachNodeForm;
class OperandForm;
class OpClassForm;
class AttributeForm;
class RegisterForm;
class PipelineForm;
class SourceForm;
class EncodeForm;
class Component;
class Constraint;
class Predicate;
class MatchRule;
class Attribute;
class Effect;
class ExpandRule;
class RewriteRule;
class ConstructRule;
class FormatRule;
class Peephole;
class EncClass;
class Interface;
class RegInterface;
class ConstInterface;
class MemInterface;
class CondInterface;
class Opcode;
class InsEncode;
class RegDef;
class RegClass;
class AllocClass;
class ResourceForm;
class PipeDesc;
class PipeClass;
class PeepMatch;
class PeepConstraint;
class PeepReplace;
class MatchList;
class ArchDesc;
//==============================Instructions===================================
//------------------------------InstructForm-----------------------------------
private:
// Members used for tracking CISC-spilling
bool _is_cisc_alternate;
const char *_cisc_reg_mask_name;
bool _is_short_branch;
public:
// Public Data
// operand structure
// Public Methods
~InstructForm();
// Dynamic type check
virtual InstructForm *is_instruction() const;
virtual bool ideal_only() const;
// This instruction sets a result
virtual bool sets_result() const;
// This instruction needs projections for additional DEFs or KILLs
virtual bool needs_projections();
// This instruction needs extra nodes for temporary inputs
virtual bool has_temps();
// This instruction defines or kills more than one object
virtual uint num_defs_or_kills();
// This instruction has an expand rule?
virtual bool expands() const ;
// Return this instruction's first peephole rule, or NULL
// Add a peephole rule to this instruction
// ideal opcode enumeration
virtual int is_expensive() const; // node matches ideal 'CosD'
virtual int is_empty_encoding() const; // _size=0 and/or _insencode empty
virtual int is_tls_instruction() const; // tlsLoadP rule or ideal ThreadLocal
virtual int is_ideal_copy() const; // node matches ideal 'Copy*'
virtual bool is_ideal_negD() const; // node matches ideal 'NegD'
virtual bool is_ideal_if() const; // node matches ideal 'If'
virtual bool is_ideal_fastlock() const; // node matches 'FastLock'
virtual bool is_ideal_membar() const; // node matches ideal 'MemBarXXX'
virtual bool is_ideal_loadPC() const; // node matches ideal 'LoadPC'
virtual bool is_ideal_box() const; // node matches ideal 'Box'
virtual bool is_ideal_goto() const; // node matches ideal 'Goto'
virtual bool is_ideal_branch() const; // "" 'If' | 'Goto' | 'LoopEnd' | 'Jump'
virtual bool is_ideal_jump() const; // node matches ideal 'Jump'
virtual bool is_ideal_return() const; // node matches ideal 'Return'
virtual bool is_ideal_halt() const; // node matches ideal 'Halt'
virtual bool is_ideal_safepoint() const; // node matches 'SafePoint'
virtual bool is_ideal_nop() const; // node matches 'Nop'
virtual bool is_ideal_control() const; // control node
virtual bool is_vector() const; // vector instruction
// Should antidep checks be disabled for this Instruct
// See definition of MatchRule::skip_antidep_check
bool skip_antidep_check() const;
bool is_ideal_mem() const { return is_ideal_load() != Form::none || is_ideal_store() != Form::none; }
// when chaining a constant to an instruction, return 'true' and set opType
virtual Form::DataType is_chain_of_constant(FormDict &globals, const char * &opType, const char * &result_type);
// Check if a simple chain rule
// check for structural rematerialization
// loads from memory, so must check for anti-dependence
enum memory_operand_type {
};
// This instruction captures the machine-independent bottom_type
// Expected use is for pointer vs oop determination for LoadP
virtual const char *cost(); // Access ins_cost attribute
// Counts USE_DEF opnds twice. See also num_unique_opnds().
virtual uint num_post_match_opnds();
// Constants in match rule with specified type
// Return the register class associated with 'leaf'.
// number of ideal node inputs to skip
// Does this instruction need a base-oop edge?
// Build instruction predicates. If the user uses the same operand name
// twice, we need to check that the operands are pointer-eequivalent in
// the DFA during the labeling process.
virtual void build_components(); // top-level operands
// Return zero-based position in component list; -1 if not in list.
virtual int operand_position_format(const char *name);
// Return zero-based position in component list; -1 if not in list.
virtual int label_position();
virtual int method_position();
// Return number of relocation entries needed for this instruction.
const char *reduce_result();
// Return the name of the operand on the right hand side of the binary match
// Return NULL if there is no right hand side
// Base class for this instruction, MachNode except for calls
// Check if this instruction can cisc-spill to 'alternate'
// Output cisc-method prototypes and method bodies
// Output short branch prototypes and method bodies
// Seach through operands to determine operands unique positions.
void set_unique_opnds();
} else {
return idx;
}
}
// Operands which are only KILLs aren't part of the input array and
// require special handling in some cases. Their position in this
// operand list is higher than the number of unique operands.
return (idx >= num_unique_opnds());
}
// --------------------------- FILE *output_routines
//
// Generate the format call for the replacement variable
// Generate index values needed for determining the operand position
// ---------------------------
virtual bool verify(); // Check consistency after parsing
virtual void dump(); // Debug printer
};
//------------------------------EncodeForm-------------------------------------
private:
public:
// Public Data
// Public Methods
EncodeForm();
~EncodeForm();
const char *encClassPrototype(const char *className);
const char *encClassBody(const char *className);
void dump(); // Debug printer
};
//------------------------------EncClass---------------------------------------
public:
// NameList for parameter type and name
// Breakdown the encoding into strings separated by $replacement_variables
// There is an entry in _strings, perhaps NULL, that precedes each _rep_vars
public:
// Public Data
// Public Methods
~EncClass();
// --------------------------- Parameters
// Add a parameter <type,name> pair
// Verify operand types in parameter list
// Obtain the zero-based index corresponding to a replacement variable
int rep_var_index(const char *rep_var);
// --------------------------- Code Block
// Add code
void add_code(const char *string_preceding_replacement_var);
// Add a replacement variable or one of its subfields
// Subfields are stored with a leading '$'
void add_rep_var(char *replacement_var);
bool verify();
void dump();
};
//------------------------------MachNode---------------------------------------
private:
public:
// Public Methods
MachNodeForm(char *id);
~MachNodeForm();
virtual MachNodeForm *is_machnode() const;
void dump(); // Debug printer
};
//------------------------------Opcode-----------------------------------------
private:
public:
// Public Data
// Strings representing instruction opcodes, user defines placement in emit
char *_primary;
char *_secondary;
char *_tertiary;
enum opcode_type {
};
// Public Methods
~Opcode();
void dump();
// --------------------------- FILE *output_routines
};
//------------------------------InsEncode--------------------------------------
private:
// Public Data (access directly only for reads)
// The encodings can only have the values predefined by the ADLC:
// blank, RegReg, RegMem, MemReg, ...
// NameList _parameter;
// The parameters for each encoding are preceeded by a NameList::_signal
// and follow the parameters for the previous encoding.
// char *_encode; // Type of instruction encoding
public:
// Public Methods
InsEncode();
~InsEncode();
// Add "encode class name" and its parameters
// Parameters are added to the returned "NameAndList" by the parser
// Access the list of encodings
void reset();
const char *encode_class_iter();
// Returns the number of arguments to the current encoding in the iteration
int current_encoding_num_args() {
}
// --------------------------- Parameters
// The following call depends upon position within encode_class_iteration
//
// Obtain parameter name from zero based index
// ---------------------------
void dump();
};
//------------------------------Effect-----------------------------------------
private:
public:
// Public Data
// Public Methods
~Effect(); // Destructor
// Dynamic type check
// Return 'true' if this use def info equals the parameter
bool is(int use_def_kill_enum) const;
// Return 'true' if this use def info is a superset of parameter
bool isa(int use_def_kill_enum) const;
void dump(); // Debug printer
};
//------------------------------ExpandRule-------------------------------------
private:
public:
// Public Data
void reset_instructions();
// Public Methods
ExpandRule(); // Constructor
~ExpandRule(); // Destructor
void dump(); // Debug printer
};
//------------------------------RewriteRule------------------------------------
private:
public:
// Public Data
// Public Methods
~RewriteRule(); // Destructor
void dump(); // Debug printer
};
//==============================Operands=======================================
//------------------------------OpClassForm------------------------------------
public:
// Public Data
// Public Methods
OpClassForm(const char *id);
~OpClassForm();
// dynamic type check
virtual OpClassForm *is_opclass() const;
// Min and Max opcodes of operands in this operand class
int _minCode;
int _maxCode;
virtual bool ideal_only() const;
virtual void dump(); // Debug printer
};
//------------------------------OperandForm------------------------------------
private:
public:
// Public Data
// Public Methods
OperandForm(const char *id);
~OperandForm();
// Dynamic type check
virtual OperandForm *is_operand() const;
virtual bool ideal_only() const;
virtual const char *cost(); // Access ins_cost attribute
// Constants in operands' match rules
// Constants in operand's match rule with specified type
// Pointer Constants in operands' match rules
// The number of input edges in the machine world == num_leaves - num_consts
// Check if this operand is usable for cisc-spilling
// node matches ideal 'Bool', grab condition codes from the ideal world
virtual bool is_ideal_bool() const;
// Has an integer constant suitable for spill offsets
// Node is user-defined operand for an sRegX
// Return ideal type, if there is a single ideal type for this operand
// If there is a single ideal type for this interface field, return it.
const char *field_name) const;
// Return true if this operand represents a bound register class
bool is_bound_register() const;
// Return the Register class for this operand. Returns NULL if
// operand isn't a register form.
RegClass* get_RegClass() const;
virtual bool is_interface_field(const char *field_name,
const char * &value) const;
// If this operand has a single ideal type, return its type
// If this operand is an ideal constant, return its type
// "true" if this operand is a simple type that is swallowed
// Return register class name if a constraint specifies the register class.
virtual const char *constrained_reg_class() const;
// Return the register class associated with 'leaf'.
// Build component list from MatchRule and operand's parameter list
virtual void build_components(); // top-level operands
// Return zero-based position in component list; -1 if not in list.
// Return zero-based position in component list; -1 if not in list.
// Return the operand form corresponding to the given index, else NULL.
// Return zero-based position in component list; -1 if not in list.
const char *reduce_result() const;
// Return the name of the operand on the right hand side of the binary match
// Return NULL if there is no right hand side
// --------------------------- FILE *output_routines
//
// Output code for disp_is_oop, if true.
// Generate code for internal and external format methods
// Output code to access the value of the index'th constant
// ---------------------------
virtual void dump(); // Debug printer
};
//------------------------------Constraint-------------------------------------
private:
public:
// Public Methods
~Constraint();
bool stack_slots_only() const;
void dump(); // Debug printer
};
//------------------------------Predicate--------------------------------------
private:
public:
// Public Data
// Public Methods
~Predicate();
void dump();
};
//------------------------------Interface--------------------------------------
private:
public:
// Public Data
// Public Methods
~Interface();
void dump();
};
//------------------------------RegInterface-----------------------------------
private:
public:
// Public Methods
RegInterface();
~RegInterface();
void dump();
};
//------------------------------ConstInterface---------------------------------
private:
public:
// Public Methods
~ConstInterface();
void dump();
};
//------------------------------MemInterface-----------------------------------
private:
public:
// Public Data
// Public Methods
~MemInterface();
void dump();
};
//------------------------------CondInterface----------------------------------
private:
public:
const char *_equal;
const char *_not_equal;
const char *_less;
const char *_greater_equal;
const char *_less_equal;
const char *_greater;
const char *_equal_format;
const char *_not_equal_format;
const char *_less_format;
const char *_greater_equal_format;
const char *_less_equal_format;
const char *_greater_format;
// Public Methods
const char* not_equal, const char* not_equal_format,
const char* less, const char* less_format,
const char* greater_equal, const char* greater_equal_format,
const char* less_equal, const char* less_equal_format,
const char* greater, const char* greater_format);
~CondInterface();
void dump();
};
//------------------------------ConstructRule----------------------------------
private:
public:
// Public Data
// Public Methods
ConstructRule(char *cnstr);
~ConstructRule();
void dump();
};
//==============================Shared=========================================
//------------------------------AttributeForm----------------------------------
private:
// counters for unique instruction or operand ID
public:
// Public Data
// Public Methods
~AttributeForm();
// Dynamic type check
virtual AttributeForm *is_attribute() const;
void dump(); // Debug printer
};
//------------------------------Component--------------------------------------
private:
public:
// Public Data
// Public Methods
~Component();
// Return 'true' if this use def info equals the parameter
bool is(int use_def_kill_enum) const;
// Return 'true' if this use def info is a superset of parameter
bool isa(int use_def_kill_enum) const;
int promote_use_def_info(int new_use_def);
// Form::DataType is_base_constant(FormDict &globals);
void dump(); // Debug printer
const char* getUsedefName();
public:
// Implementation depends upon working bit intersection and union.
enum use_def_enum {
};
};
//------------------------------MatchNode--------------------------------------
private:
public:
// Public Data
// Public Methods
~MatchNode();
// return 0 if not found:
// return 1 if found and position is incremented by operand offset in rule
bool def_flag = false) const;
const char * &opType) const;
// recursive count on operands
// recursive count of constants with specified type
// uint num_consts() const; // Local inspection only
int needs_base_oop_edge() const;
// Help build instruction predicates. Search for operand names.
void build_internalop( );
// Return the name of the operands associated with reducing to this operand:
// The result type, plus the left and right sides of the binary match
// Return NULL if there is no left or right hand side
bool sets_result() const; // rule "Set"s result of match
// Recursive version of check in MatchRule
const char* ®_type);
void count_commutative_op(int& count);
void dump();
};
//------------------------------MatchRule--------------------------------------
private:
public:
// Public Data
// Public Methods
~MatchRule();
virtual void append_components(FormDict& locals, ComponentList& components, bool def_flag = false) const;
// Recursive call on all operands' match rules in my match rule.
const char * &opType) const;
int is_ideal_copy() const;
int is_expensive() const; // node matches ideal 'CosD'
bool is_ideal_if() const; // node matches ideal 'If'
bool is_ideal_fastlock() const; // node matches ideal 'FastLock'
bool is_ideal_jump() const; // node matches ideal 'Jump'
bool is_ideal_membar() const; // node matches ideal 'MemBarXXX'
bool is_ideal_loadPC() const; // node matches ideal 'LoadPC'
bool is_ideal_box() const; // node matches ideal 'Box'
bool is_ideal_goto() const; // node matches ideal 'Goto'
bool is_ideal_loopEnd() const; // node matches ideal 'LoopEnd'
bool is_ideal_bool() const; // node matches ideal 'Bool'
bool is_vector() const; // vector instruction
// Should antidep checks be disabled for this rule
// See definition of MatchRule::skip_antidep_check
bool skip_antidep_check() const;
// Check if 'mRule2' is a cisc-spill variant of this MatchRule
const char* ®_type);
// Check if 'mRule2' is equivalent to this MatchRule
void dump();
};
//------------------------------Attribute--------------------------------------
private:
public:
// Public Data
// Public Methods
~Attribute();
void dump();
};
//------------------------------FormatRule-------------------------------------
private:
public:
// Public Data
// There is an entry in _strings, perhaps NULL, that precedes each _rep_vars
// Public Methods
FormatRule(char *temp);
~FormatRule();
void dump();
};
#endif // SHARE_VM_ADLC_FORMSSEL_HPP