src/share/vm/adlc/formssel.hpp

Fri, 15 Jun 2012 01:25:19 -0700

author
kvn
date
Fri, 15 Jun 2012 01:25:19 -0700
changeset 3882
8c92982cbbc4
parent 3316
f03a3c8bd5e5
child 4161
d336b3173277
permissions
-rw-r--r--

7119644: Increase superword's vector size up to 256 bits
Summary: Increase vector size up to 256-bits for YMM AVX registers on x86.
Reviewed-by: never, twisti, roland

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

mercurial