< prev index next >

src/share/vm/adlc/output_h.cpp

Print this page




1641     // encoding class information in the _insencode slot.
1642     if ( instr->_insencode ) {
1643       if (instr->postalloc_expands()) {
1644         fprintf(fp,"  virtual bool           requires_postalloc_expand() const { return true; }\n");
1645         fprintf(fp,"  virtual void           postalloc_expand(GrowableArray <Node *> *nodes, PhaseRegAlloc *ra_);\n");
1646       } else {
1647         fprintf(fp,"  virtual void           emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const;\n");
1648       }
1649     }
1650 
1651     // virtual function for getting the size of an instruction
1652     if ( instr->_size ) {
1653       fprintf(fp,"  virtual uint           size(PhaseRegAlloc *ra_) const;\n");
1654     }
1655 
1656     // Return the top-level ideal opcode.
1657     // Use MachNode::ideal_Opcode() for nodes based on MachNode class
1658     // if the ideal_Opcode == Op_Node.
1659     if ( strcmp("Node", instr->ideal_Opcode(_globalNames)) != 0 ||
1660          strcmp("MachNode", instr->mach_base_class(_globalNames)) != 0 ) {
1661       fprintf(fp,"  virtual int            ideal_Opcode() const { return Op_%s; }\n",
1662             instr->ideal_Opcode(_globalNames) );
1663     }
1664 
1665     if (instr->needs_constant_base() &&
1666         !instr->is_mach_constant()) {  // These inherit the funcion from MachConstantNode.
1667       fprintf(fp,"  virtual uint           mach_constant_base_node_input() const { ");
1668       if (instr->is_ideal_call() != Form::invalid_type &&
1669           instr->is_ideal_call() != Form::JAVA_LEAF) {
1670         // MachConstantBase goes behind arguments, but before jvms.
1671         fprintf(fp,"assert(tf() && tf()->domain(), \"\"); return tf()->domain()->cnt();");
1672       } else {
1673         fprintf(fp,"return req()-1;");
1674       }
1675       fprintf(fp," }\n");
1676     }
1677 
1678     // Allow machine-independent optimization, invert the sense of the IF test
1679     if( instr->is_ideal_if() ) {
1680       fprintf(fp,"  virtual void           negate() { \n");
1681       // Identify which operand contains the negate(able) ideal condition code


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
2096     for (int i = 1; i < _last_opcode; i++) {
2097       if (_mlistab[i] == NULL) continue;
2098       fprintf(fp, "  void  _sub_Op_%s(const Node *n);\n", NodeClassNames[i]);
2099     }
2100   }
2101   fprintf(fp,"};\n");
2102   fprintf(fp,"\n");
2103   fprintf(fp,"\n");
2104 
2105 }
2106 
2107 
2108 //---------------------------buildMachOperEnum---------------------------------
2109 // Build enumeration for densely packed operands.
2110 // This enumeration is used to index into the arrays in the State objects
2111 // that indicate cost and a successfull rule match.
2112 
2113 // Information needed to generate the ReduceOp mapping for the DFA
2114 class OutputMachOperands : public OutputMap {
2115 public:
2116   OutputMachOperands(FILE *hpp, FILE *cpp, FormDict &globals, ArchDesc &AD)




1641     // encoding class information in the _insencode slot.
1642     if ( instr->_insencode ) {
1643       if (instr->postalloc_expands()) {
1644         fprintf(fp,"  virtual bool           requires_postalloc_expand() const { return true; }\n");
1645         fprintf(fp,"  virtual void           postalloc_expand(GrowableArray <Node *> *nodes, PhaseRegAlloc *ra_);\n");
1646       } else {
1647         fprintf(fp,"  virtual void           emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const;\n");
1648       }
1649     }
1650 
1651     // virtual function for getting the size of an instruction
1652     if ( instr->_size ) {
1653       fprintf(fp,"  virtual uint           size(PhaseRegAlloc *ra_) const;\n");
1654     }
1655 
1656     // Return the top-level ideal opcode.
1657     // Use MachNode::ideal_Opcode() for nodes based on MachNode class
1658     // if the ideal_Opcode == Op_Node.
1659     if ( strcmp("Node", instr->ideal_Opcode(_globalNames)) != 0 ||
1660          strcmp("MachNode", instr->mach_base_class(_globalNames)) != 0 ) {
1661       fprintf(fp,"  virtual Opcodes        ideal_Opcode() const { return Opcodes::Op_%s; }\n",
1662             instr->ideal_Opcode(_globalNames) );
1663     }
1664 
1665     if (instr->needs_constant_base() &&
1666         !instr->is_mach_constant()) {  // These inherit the funcion from MachConstantNode.
1667       fprintf(fp,"  virtual uint           mach_constant_base_node_input() const { ");
1668       if (instr->is_ideal_call() != Form::invalid_type &&
1669           instr->is_ideal_call() != Form::JAVA_LEAF) {
1670         // MachConstantBase goes behind arguments, but before jvms.
1671         fprintf(fp,"assert(tf() && tf()->domain(), \"\"); return tf()->domain()->cnt();");
1672       } else {
1673         fprintf(fp,"return req()-1;");
1674       }
1675       fprintf(fp," }\n");
1676     }
1677 
1678     // Allow machine-independent optimization, invert the sense of the IF test
1679     if( instr->is_ideal_if() ) {
1680       fprintf(fp,"  virtual void           negate() { \n");
1681       // Identify which operand contains the negate(able) ideal condition code


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( Opcodes 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
2096     for (uint i = 1; i < static_cast<uint>(Opcodes::_last_opcode); i++) {
2097       if (_mlistab[i] == NULL) continue;
2098       fprintf(fp, "  void  _sub_Op_%s(const Node *n);\n", NodeClassNames[i]);
2099     }
2100   }
2101   fprintf(fp,"};\n");
2102   fprintf(fp,"\n");
2103   fprintf(fp,"\n");
2104 
2105 }
2106 
2107 
2108 //---------------------------buildMachOperEnum---------------------------------
2109 // Build enumeration for densely packed operands.
2110 // This enumeration is used to index into the arrays in the State objects
2111 // that indicate cost and a successfull rule match.
2112 
2113 // Information needed to generate the ReduceOp mapping for the DFA
2114 class OutputMachOperands : public OutputMap {
2115 public:
2116   OutputMachOperands(FILE *hpp, FILE *cpp, FormDict &globals, ArchDesc &AD)


< prev index next >