src/share/vm/adlc/formssel.hpp

Tue, 23 Nov 2010 13:22:55 -0800

author
stefank
date
Tue, 23 Nov 2010 13:22:55 -0800
changeset 2314
f95d63e2154a
parent 1907
c18cbe5936b8
child 2350
2f644f85485d
permissions
-rw-r--r--

6989984: Use standard include model for Hospot
Summary: Replaced MakeDeps and the includeDB files with more standardized solutions.
Reviewed-by: coleenp, kvn, kamg

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

mercurial