src/share/vm/adlc/output_h.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File 8054033 Sdiff src/share/vm/adlc

src/share/vm/adlc/output_h.cpp

Print this page




1102   fprintf(fp_hpp, "  void set_use_nop_delay() { _flags = _use_nop_delay; }\n");
1103   fprintf(fp_hpp, "  void set_use_unconditional_delay() { _flags = _use_unconditional_delay; }\n");
1104   fprintf(fp_hpp, "  void set_use_conditional_delay() { _flags = _use_conditional_delay; }\n");
1105   fprintf(fp_hpp, "  void set_used_in_unconditional_delay() { _flags = _used_in_unconditional_delay; }\n");
1106   fprintf(fp_hpp, "  void set_used_in_conditional_delay() { _flags = _used_in_conditional_delay; }\n");
1107   fprintf(fp_hpp, "  void set_used_in_all_conditional_delays() { _flags = _used_in_all_conditional_delays; }\n");
1108 
1109   fprintf(fp_hpp, "  bool use_nop_delay() { return (_flags == _use_nop_delay); }\n");
1110   fprintf(fp_hpp, "  bool use_unconditional_delay() { return (_flags == _use_unconditional_delay); }\n");
1111   fprintf(fp_hpp, "  bool use_conditional_delay() { return (_flags == _use_conditional_delay); }\n");
1112   fprintf(fp_hpp, "  bool used_in_unconditional_delay() { return (_flags == _used_in_unconditional_delay); }\n");
1113   fprintf(fp_hpp, "  bool used_in_conditional_delay() { return (_flags == _used_in_conditional_delay); }\n");
1114   fprintf(fp_hpp, "  bool used_in_all_conditional_delays() { return (_flags == _used_in_all_conditional_delays); }\n");
1115   fprintf(fp_hpp, "  bool use_delay() { return ((_flags & _use_delay) != 0); }\n");
1116   fprintf(fp_hpp, "  bool used_in_delay() { return ((_flags & _used_in_delay) != 0); }\n\n");
1117 
1118   fprintf(fp_hpp, "  enum {\n");
1119   fprintf(fp_hpp, "    _nop_count = %d\n",
1120     _pipeline->_nopcnt);
1121   fprintf(fp_hpp, "  };\n\n");
1122   fprintf(fp_hpp, "  static void initialize_nops(MachNode *nop_list[%d], Compile* C);\n\n",
1123     _pipeline->_nopcnt);
1124   fprintf(fp_hpp, "#ifndef PRODUCT\n");
1125   fprintf(fp_hpp, "  void dump(outputStream *st = tty) const;\n");
1126   fprintf(fp_hpp, "#endif\n");
1127   fprintf(fp_hpp, "};\n\n");
1128 
1129 //  const char *classname;
1130 //  for (_pipeline->_classlist.reset(); (classname = _pipeline->_classlist.iter()) != NULL; ) {
1131 //    PipeClassForm *pipeclass = _pipeline->_classdict[classname]->is_pipeclass();
1132 //    fprintf(fp_hpp, "// Pipeline Class Instance for \"%s\"\n", classname);
1133 //  }
1134 }
1135 
1136 //------------------------------declareClasses---------------------------------
1137 // Construct the class hierarchy of MachNode classes from the instruction &
1138 // operand lists
1139 void ArchDesc::declareClasses(FILE *fp) {
1140 
1141   // Declare an array containing the machine register names, strings.
1142   declareRegNames(fp, _register);


1223 
1224     // Support storage of the condition codes
1225     if( oper->is_ideal_bool() ) {
1226       fprintf(fp,"  virtual void negate() { \n");
1227       fprintf(fp,"    _c0 = (BoolTest::mask)((int)_c0^0x4); \n");
1228       fprintf(fp,"  };\n");
1229     }
1230 
1231     // Declare constructor.
1232     // Parameters start with condition code, then all other constants
1233     //
1234     // (1)  MachXOper(int32 ccode, int32 c0, int32 c1, ..., int32 cn)
1235     // (2)     : _ccode(ccode), _c0(c0), _c1(c1), ..., _cn(cn) { }
1236     //
1237     Form::DataType constant_type = oper->simple_type(_globalNames);
1238     defineConstructor(fp, oper->_ident, oper->num_consts(_globalNames),
1239                       oper->_components, oper->is_ideal_bool(),
1240                       constant_type, _globalNames);
1241 
1242     // Clone function
1243     fprintf(fp,"  virtual MachOper      *clone(Compile* C) const;\n");
1244 
1245     // Support setting a spill offset into a constant operand.
1246     // We only support setting an 'int' offset, while in the
1247     // LP64 build spill offsets are added with an AddP which
1248     // requires a long constant.  Thus we don't support spilling
1249     // in frames larger than 4Gig.
1250     if( oper->has_conI(_globalNames) ||
1251         oper->has_conL(_globalNames) )
1252       fprintf(fp, "  virtual void set_con( jint c0 ) { _c0 = c0; }\n");
1253 
1254     // virtual functions for encoding and format
1255     //    fprintf(fp,"  virtual void           encode()   const {\n    %s }\n",
1256     //            (oper->_encrule)?(oper->_encrule->_encrule):"");
1257     // Check the interface type, and generate the correct query functions
1258     // encoding queries based upon MEMORY_INTER, REG_INTER, CONST_INTER.
1259 
1260     fprintf(fp,"  virtual uint           opcode() const { return %s; }\n",
1261             machOperEnum(oper->_ident));
1262 
1263     // virtual function to look up ideal return type of machine instruction


1701 
1702 
1703     // Identify which input register matches the input register.
1704     uint  matching_input = instr->two_address(_globalNames);
1705 
1706     // Generate the method if it returns != 0 otherwise use MachNode::two_adr()
1707     if( matching_input != 0 ) {
1708       fprintf(fp,"  virtual uint           two_adr() const  ");
1709       fprintf(fp,"{ return oper_input_base()");
1710       for( uint i = 2; i <= matching_input; i++ )
1711         fprintf(fp," + opnd_array(%d)->num_edges()",i-1);
1712       fprintf(fp,"; }\n");
1713     }
1714 
1715     // Declare cisc_version, if applicable
1716     //   MachNode *cisc_version( int offset /* ,... */ );
1717     instr->declare_cisc_version(*this, fp);
1718 
1719     // If there is an explicit peephole rule, build it
1720     if ( instr->peepholes() != NULL ) {
1721       fprintf(fp,"  virtual MachNode      *peephole(Block *block, int block_index, PhaseRegAlloc *ra_, int &deleted, Compile *C);\n");
1722     }
1723 
1724     // Output the declaration for number of relocation entries
1725     if ( instr->reloc(_globalNames) != 0 ) {
1726       fprintf(fp,"  virtual int            reloc() const;\n");
1727     }
1728 
1729     if (instr->alignment() != 1) {
1730       fprintf(fp,"  virtual int            alignment_required() const { return %d; }\n", instr->alignment());
1731       fprintf(fp,"  virtual int            compute_padding(int current_offset) const;\n");
1732     }
1733 
1734     // Starting point for inputs matcher wants.
1735     // Use MachNode::oper_input_base() for nodes based on MachNode class
1736     // if the base == 1.
1737     if ( instr->oper_input_base(_globalNames) != 1 ||
1738          strcmp("MachNode", instr->mach_base_class(_globalNames)) != 0 ) {
1739       fprintf(fp,"  virtual uint           oper_input_base() const { return %d; }\n",
1740             instr->oper_input_base(_globalNames));
1741     }


1846         instr->needs_constant_base() ||
1847         instr->_matrule != NULL &&
1848         instr->num_opnds() != instr->num_unique_opnds() ) {
1849       fprintf(fp,"  virtual MachNode      *Expand(State *state, Node_List &proj_list, Node* mem);\n");
1850     }
1851 
1852     if (instr->is_pinned(_globalNames)) {
1853       fprintf(fp,"  virtual bool           pinned() const { return ");
1854       if (instr->is_parm(_globalNames)) {
1855         fprintf(fp,"_in[0]->pinned();");
1856       } else {
1857         fprintf(fp,"true;");
1858       }
1859       fprintf(fp," }\n");
1860     }
1861     if (instr->is_projection(_globalNames)) {
1862       fprintf(fp,"  virtual const Node *is_block_proj() const { return this; }\n");
1863     }
1864     if ( instr->num_post_match_opnds() != 0
1865          || instr->is_chain_of_constant(_globalNames) ) {
1866       fprintf(fp,"  friend MachNode *State::MachNodeGenerator(int opcode, Compile* C);\n");
1867     }
1868     if ( instr->rematerialize(_globalNames, get_registers()) ) {
1869       fprintf(fp,"  // Rematerialize %s\n", instr->_ident);
1870     }
1871 
1872     // Declare short branch methods, if applicable
1873     instr->declare_short_branch_methods(fp);
1874 
1875     // See if there is an "ins_pipe" declaration for this instruction
1876     if (instr->_ins_pipe) {
1877       fprintf(fp,"  static  const Pipeline *pipeline_class();\n");
1878       fprintf(fp,"  virtual const Pipeline *pipeline() const;\n");
1879     }
1880 
1881     // Generate virtual function for MachNodeX::bottom_type when necessary
1882     //
1883     // Note on accuracy:  Pointer-types of machine nodes need to be accurate,
1884     // or else alias analysis on the matched graph may produce bad code.
1885     // Moreover, the aliasing decisions made on machine-node graph must be
1886     // no less accurate than those made on the ideal graph, or else the graph


2054   fprintf(fp,
2055           "//---------------------------State-------------------------------------------\n");
2056   fprintf(fp,"// State contains an integral cost vector, indexed by machine operand opcodes,\n");
2057   fprintf(fp,"// a rule vector consisting of machine operand/instruction opcodes, and also\n");
2058   fprintf(fp,"// indexed by machine operand opcodes, pointers to the children in the label\n");
2059   fprintf(fp,"// tree generated by the Label routines in ideal nodes (currently limited to\n");
2060   fprintf(fp,"// two for convenience, but this could change).\n");
2061   fprintf(fp,"class State : public ResourceObj {\n");
2062   fprintf(fp,"public:\n");
2063   fprintf(fp,"  int    _id;         // State identifier\n");
2064   fprintf(fp,"  Node  *_leaf;       // Ideal (non-machine-node) leaf of match tree\n");
2065   fprintf(fp,"  State *_kids[2];       // Children of state node in label tree\n");
2066   fprintf(fp,"  unsigned int _cost[_LAST_MACH_OPER];  // Cost vector, indexed by operand opcodes\n");
2067   fprintf(fp,"  unsigned int _rule[_LAST_MACH_OPER];  // Rule vector, indexed by operand opcodes\n");
2068   fprintf(fp,"  unsigned int _valid[(_LAST_MACH_OPER/32)+1]; // Bit Map of valid Cost/Rule entries\n");
2069   fprintf(fp,"\n");
2070   fprintf(fp,"  State(void);                      // Constructor\n");
2071   fprintf(fp,"  DEBUG_ONLY( ~State(void); )       // Destructor\n");
2072   fprintf(fp,"\n");
2073   fprintf(fp,"  // Methods created by ADLC and invoked by Reduce\n");
2074   fprintf(fp,"  MachOper *MachOperGenerator( int opcode, Compile* C );\n");
2075   fprintf(fp,"  MachNode *MachNodeGenerator( int opcode, Compile* C );\n");
2076   fprintf(fp,"\n");
2077   fprintf(fp,"  // Assign a state to a node, definition of method produced by ADLC\n");
2078   fprintf(fp,"  bool DFA( int opcode, const Node *ideal );\n");
2079   fprintf(fp,"\n");
2080   fprintf(fp,"  // Access function for _valid bit vector\n");
2081   fprintf(fp,"  bool valid(uint index) {\n");
2082   fprintf(fp,"    return( STATE__VALID(index) != 0 );\n");
2083   fprintf(fp,"  }\n");
2084   fprintf(fp,"\n");
2085   fprintf(fp,"  // Set function for _valid bit vector\n");
2086   fprintf(fp,"  void set_valid(uint index) {\n");
2087   fprintf(fp,"    STATE__SET_VALID(index);\n");
2088   fprintf(fp,"  }\n");
2089   fprintf(fp,"\n");
2090   fprintf(fp,"#ifndef PRODUCT\n");
2091   fprintf(fp,"  void dump();                // Debugging prints\n");
2092   fprintf(fp,"  void dump(int depth);\n");
2093   fprintf(fp,"#endif\n");
2094   if (_dfa_small) {
2095     // Generate the routine name we'll need




1102   fprintf(fp_hpp, "  void set_use_nop_delay() { _flags = _use_nop_delay; }\n");
1103   fprintf(fp_hpp, "  void set_use_unconditional_delay() { _flags = _use_unconditional_delay; }\n");
1104   fprintf(fp_hpp, "  void set_use_conditional_delay() { _flags = _use_conditional_delay; }\n");
1105   fprintf(fp_hpp, "  void set_used_in_unconditional_delay() { _flags = _used_in_unconditional_delay; }\n");
1106   fprintf(fp_hpp, "  void set_used_in_conditional_delay() { _flags = _used_in_conditional_delay; }\n");
1107   fprintf(fp_hpp, "  void set_used_in_all_conditional_delays() { _flags = _used_in_all_conditional_delays; }\n");
1108 
1109   fprintf(fp_hpp, "  bool use_nop_delay() { return (_flags == _use_nop_delay); }\n");
1110   fprintf(fp_hpp, "  bool use_unconditional_delay() { return (_flags == _use_unconditional_delay); }\n");
1111   fprintf(fp_hpp, "  bool use_conditional_delay() { return (_flags == _use_conditional_delay); }\n");
1112   fprintf(fp_hpp, "  bool used_in_unconditional_delay() { return (_flags == _used_in_unconditional_delay); }\n");
1113   fprintf(fp_hpp, "  bool used_in_conditional_delay() { return (_flags == _used_in_conditional_delay); }\n");
1114   fprintf(fp_hpp, "  bool used_in_all_conditional_delays() { return (_flags == _used_in_all_conditional_delays); }\n");
1115   fprintf(fp_hpp, "  bool use_delay() { return ((_flags & _use_delay) != 0); }\n");
1116   fprintf(fp_hpp, "  bool used_in_delay() { return ((_flags & _used_in_delay) != 0); }\n\n");
1117 
1118   fprintf(fp_hpp, "  enum {\n");
1119   fprintf(fp_hpp, "    _nop_count = %d\n",
1120     _pipeline->_nopcnt);
1121   fprintf(fp_hpp, "  };\n\n");
1122   fprintf(fp_hpp, "  static void initialize_nops(MachNode *nop_list[%d]);\n\n",
1123     _pipeline->_nopcnt);
1124   fprintf(fp_hpp, "#ifndef PRODUCT\n");
1125   fprintf(fp_hpp, "  void dump(outputStream *st = tty) const;\n");
1126   fprintf(fp_hpp, "#endif\n");
1127   fprintf(fp_hpp, "};\n\n");
1128 
1129 //  const char *classname;
1130 //  for (_pipeline->_classlist.reset(); (classname = _pipeline->_classlist.iter()) != NULL; ) {
1131 //    PipeClassForm *pipeclass = _pipeline->_classdict[classname]->is_pipeclass();
1132 //    fprintf(fp_hpp, "// Pipeline Class Instance for \"%s\"\n", classname);
1133 //  }
1134 }
1135 
1136 //------------------------------declareClasses---------------------------------
1137 // Construct the class hierarchy of MachNode classes from the instruction &
1138 // operand lists
1139 void ArchDesc::declareClasses(FILE *fp) {
1140 
1141   // Declare an array containing the machine register names, strings.
1142   declareRegNames(fp, _register);


1223 
1224     // Support storage of the condition codes
1225     if( oper->is_ideal_bool() ) {
1226       fprintf(fp,"  virtual void negate() { \n");
1227       fprintf(fp,"    _c0 = (BoolTest::mask)((int)_c0^0x4); \n");
1228       fprintf(fp,"  };\n");
1229     }
1230 
1231     // Declare constructor.
1232     // Parameters start with condition code, then all other constants
1233     //
1234     // (1)  MachXOper(int32 ccode, int32 c0, int32 c1, ..., int32 cn)
1235     // (2)     : _ccode(ccode), _c0(c0), _c1(c1), ..., _cn(cn) { }
1236     //
1237     Form::DataType constant_type = oper->simple_type(_globalNames);
1238     defineConstructor(fp, oper->_ident, oper->num_consts(_globalNames),
1239                       oper->_components, oper->is_ideal_bool(),
1240                       constant_type, _globalNames);
1241 
1242     // Clone function
1243     fprintf(fp,"  virtual MachOper      *clone() const;\n");
1244 
1245     // Support setting a spill offset into a constant operand.
1246     // We only support setting an 'int' offset, while in the
1247     // LP64 build spill offsets are added with an AddP which
1248     // requires a long constant.  Thus we don't support spilling
1249     // in frames larger than 4Gig.
1250     if( oper->has_conI(_globalNames) ||
1251         oper->has_conL(_globalNames) )
1252       fprintf(fp, "  virtual void set_con( jint c0 ) { _c0 = c0; }\n");
1253 
1254     // virtual functions for encoding and format
1255     //    fprintf(fp,"  virtual void           encode()   const {\n    %s }\n",
1256     //            (oper->_encrule)?(oper->_encrule->_encrule):"");
1257     // Check the interface type, and generate the correct query functions
1258     // encoding queries based upon MEMORY_INTER, REG_INTER, CONST_INTER.
1259 
1260     fprintf(fp,"  virtual uint           opcode() const { return %s; }\n",
1261             machOperEnum(oper->_ident));
1262 
1263     // virtual function to look up ideal return type of machine instruction


1701 
1702 
1703     // Identify which input register matches the input register.
1704     uint  matching_input = instr->two_address(_globalNames);
1705 
1706     // Generate the method if it returns != 0 otherwise use MachNode::two_adr()
1707     if( matching_input != 0 ) {
1708       fprintf(fp,"  virtual uint           two_adr() const  ");
1709       fprintf(fp,"{ return oper_input_base()");
1710       for( uint i = 2; i <= matching_input; i++ )
1711         fprintf(fp," + opnd_array(%d)->num_edges()",i-1);
1712       fprintf(fp,"; }\n");
1713     }
1714 
1715     // Declare cisc_version, if applicable
1716     //   MachNode *cisc_version( int offset /* ,... */ );
1717     instr->declare_cisc_version(*this, fp);
1718 
1719     // If there is an explicit peephole rule, build it
1720     if ( instr->peepholes() != NULL ) {
1721       fprintf(fp,"  virtual MachNode      *peephole(Block *block, int block_index, PhaseRegAlloc *ra_, int &deleted);\n");
1722     }
1723 
1724     // Output the declaration for number of relocation entries
1725     if ( instr->reloc(_globalNames) != 0 ) {
1726       fprintf(fp,"  virtual int            reloc() const;\n");
1727     }
1728 
1729     if (instr->alignment() != 1) {
1730       fprintf(fp,"  virtual int            alignment_required() const { return %d; }\n", instr->alignment());
1731       fprintf(fp,"  virtual int            compute_padding(int current_offset) const;\n");
1732     }
1733 
1734     // Starting point for inputs matcher wants.
1735     // Use MachNode::oper_input_base() for nodes based on MachNode class
1736     // if the base == 1.
1737     if ( instr->oper_input_base(_globalNames) != 1 ||
1738          strcmp("MachNode", instr->mach_base_class(_globalNames)) != 0 ) {
1739       fprintf(fp,"  virtual uint           oper_input_base() const { return %d; }\n",
1740             instr->oper_input_base(_globalNames));
1741     }


1846         instr->needs_constant_base() ||
1847         instr->_matrule != NULL &&
1848         instr->num_opnds() != instr->num_unique_opnds() ) {
1849       fprintf(fp,"  virtual MachNode      *Expand(State *state, Node_List &proj_list, Node* mem);\n");
1850     }
1851 
1852     if (instr->is_pinned(_globalNames)) {
1853       fprintf(fp,"  virtual bool           pinned() const { return ");
1854       if (instr->is_parm(_globalNames)) {
1855         fprintf(fp,"_in[0]->pinned();");
1856       } else {
1857         fprintf(fp,"true;");
1858       }
1859       fprintf(fp," }\n");
1860     }
1861     if (instr->is_projection(_globalNames)) {
1862       fprintf(fp,"  virtual const Node *is_block_proj() const { return this; }\n");
1863     }
1864     if ( instr->num_post_match_opnds() != 0
1865          || instr->is_chain_of_constant(_globalNames) ) {
1866       fprintf(fp,"  friend MachNode *State::MachNodeGenerator(int opcode);\n");
1867     }
1868     if ( instr->rematerialize(_globalNames, get_registers()) ) {
1869       fprintf(fp,"  // Rematerialize %s\n", instr->_ident);
1870     }
1871 
1872     // Declare short branch methods, if applicable
1873     instr->declare_short_branch_methods(fp);
1874 
1875     // See if there is an "ins_pipe" declaration for this instruction
1876     if (instr->_ins_pipe) {
1877       fprintf(fp,"  static  const Pipeline *pipeline_class();\n");
1878       fprintf(fp,"  virtual const Pipeline *pipeline() const;\n");
1879     }
1880 
1881     // Generate virtual function for MachNodeX::bottom_type when necessary
1882     //
1883     // Note on accuracy:  Pointer-types of machine nodes need to be accurate,
1884     // or else alias analysis on the matched graph may produce bad code.
1885     // Moreover, the aliasing decisions made on machine-node graph must be
1886     // no less accurate than those made on the ideal graph, or else the graph


2054   fprintf(fp,
2055           "//---------------------------State-------------------------------------------\n");
2056   fprintf(fp,"// State contains an integral cost vector, indexed by machine operand opcodes,\n");
2057   fprintf(fp,"// a rule vector consisting of machine operand/instruction opcodes, and also\n");
2058   fprintf(fp,"// indexed by machine operand opcodes, pointers to the children in the label\n");
2059   fprintf(fp,"// tree generated by the Label routines in ideal nodes (currently limited to\n");
2060   fprintf(fp,"// two for convenience, but this could change).\n");
2061   fprintf(fp,"class State : public ResourceObj {\n");
2062   fprintf(fp,"public:\n");
2063   fprintf(fp,"  int    _id;         // State identifier\n");
2064   fprintf(fp,"  Node  *_leaf;       // Ideal (non-machine-node) leaf of match tree\n");
2065   fprintf(fp,"  State *_kids[2];       // Children of state node in label tree\n");
2066   fprintf(fp,"  unsigned int _cost[_LAST_MACH_OPER];  // Cost vector, indexed by operand opcodes\n");
2067   fprintf(fp,"  unsigned int _rule[_LAST_MACH_OPER];  // Rule vector, indexed by operand opcodes\n");
2068   fprintf(fp,"  unsigned int _valid[(_LAST_MACH_OPER/32)+1]; // Bit Map of valid Cost/Rule entries\n");
2069   fprintf(fp,"\n");
2070   fprintf(fp,"  State(void);                      // Constructor\n");
2071   fprintf(fp,"  DEBUG_ONLY( ~State(void); )       // Destructor\n");
2072   fprintf(fp,"\n");
2073   fprintf(fp,"  // Methods created by ADLC and invoked by Reduce\n");
2074   fprintf(fp,"  MachOper *MachOperGenerator( int opcode );\n");
2075   fprintf(fp,"  MachNode *MachNodeGenerator( int opcode );\n");
2076   fprintf(fp,"\n");
2077   fprintf(fp,"  // Assign a state to a node, definition of method produced by ADLC\n");
2078   fprintf(fp,"  bool DFA( int opcode, const Node *ideal );\n");
2079   fprintf(fp,"\n");
2080   fprintf(fp,"  // Access function for _valid bit vector\n");
2081   fprintf(fp,"  bool valid(uint index) {\n");
2082   fprintf(fp,"    return( STATE__VALID(index) != 0 );\n");
2083   fprintf(fp,"  }\n");
2084   fprintf(fp,"\n");
2085   fprintf(fp,"  // Set function for _valid bit vector\n");
2086   fprintf(fp,"  void set_valid(uint index) {\n");
2087   fprintf(fp,"    STATE__SET_VALID(index);\n");
2088   fprintf(fp,"  }\n");
2089   fprintf(fp,"\n");
2090   fprintf(fp,"#ifndef PRODUCT\n");
2091   fprintf(fp,"  void dump();                // Debugging prints\n");
2092   fprintf(fp,"  void dump(int depth);\n");
2093   fprintf(fp,"#endif\n");
2094   if (_dfa_small) {
2095     // Generate the routine name we'll need


src/share/vm/adlc/output_h.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File