src/share/vm/adlc/output_c.cpp

Print this page
rev 7060 : 8058880: Introduce identifier TEMP_DEF for effects in adl.


1698     } // done iterating over new instructions
1699     fprintf(fp,"\n");
1700   } // done generating expand rule
1701 
1702   // Generate projections for instruction's additional DEFs and KILLs
1703   if( ! node->expands() && (node->needs_projections() || node->has_temps())) {
1704     // Get string representing the MachNode that projections point at
1705     const char *machNode = "this";
1706     // Generate the projections
1707     fprintf(fp,"  // Add projection edges for additional defs or kills\n");
1708 
1709     // Examine each component to see if it is a DEF or KILL
1710     node->_components.reset();
1711     // Skip the first component, if already handled as (SET dst (...))
1712     Component *comp = NULL;
1713     // For kills, the choice of projection numbers is arbitrary
1714     int proj_no = 1;
1715     bool declared_def  = false;
1716     bool declared_kill = false;
1717 
1718     while( (comp = node->_components.iter()) != NULL ) {
1719       // Lookup register class associated with operand type
1720       Form        *form = (Form*)_globalNames[comp->_type];
1721       assert( form, "component type must be a defined form");
1722       OperandForm *op   = form->is_operand();
1723 
1724       if (comp->is(Component::TEMP)) {

1725         fprintf(fp, "  // TEMP %s\n", comp->_name);
1726         if (!declared_def) {
1727           // Define the variable "def" to hold new MachProjNodes
1728           fprintf(fp, "  MachTempNode *def;\n");
1729           declared_def = true;
1730         }
1731         if (op && op->_interface && op->_interface->is_RegInterface()) {
1732           fprintf(fp,"  def = new MachTempNode(state->MachOperGenerator(%s));\n",
1733                   machOperEnum(op->_ident));
1734           fprintf(fp,"  add_req(def);\n");
1735           // The operand for TEMP is already constructed during
1736           // this mach node construction, see buildMachNode().
1737           //
1738           // int idx  = node->operand_position_format(comp->_name);
1739           // fprintf(fp,"  set_opnd_array(%d, state->MachOperGenerator(%s));\n",
1740           //         idx, machOperEnum(op->_ident));
1741         } else {
1742           assert(false, "can't have temps which aren't registers");
1743         }
1744       } else if (comp->isa(Component::KILL)) {
1745         fprintf(fp, "  // DEF/KILL %s\n", comp->_name);
1746 
1747         if (!declared_kill) {
1748           // Define the variable "kill" to hold new MachProjNodes
1749           fprintf(fp, "  MachProjNode *kill;\n");
1750           declared_kill = true;
1751         }
1752 
1753         assert( op, "Support additional KILLS for base operands");
1754         const char *regmask    = reg_mask(*op);
1755         const char *ideal_type = op->ideal_type(_globalNames, _register);
1756 
1757         if (!op->is_bound_register()) {
1758           syntax_err(node->_linenum, "In %s only bound registers can be killed: %s %s\n",
1759                      node->_ident, comp->_type, comp->_name);
1760         }
1761 
1762         fprintf(fp,"  kill = ");
1763         fprintf(fp,"new MachProjNode( %s, %d, (%s), Op_%s );\n",
1764                 machNode, proj_no++, regmask, ideal_type);
1765         fprintf(fp,"  proj_list.push(kill);\n");
1766       }
1767     }
1768   }
1769 
1770   if( !node->expands() && node->_matrule != NULL ) {
1771     // Remove duplicated operands and inputs which use the same name.
1772     // Seach through match operands for the same name usage.
1773     uint cur_num_opnds = node->num_opnds();




1698     } // done iterating over new instructions
1699     fprintf(fp,"\n");
1700   } // done generating expand rule
1701 
1702   // Generate projections for instruction's additional DEFs and KILLs
1703   if( ! node->expands() && (node->needs_projections() || node->has_temps())) {
1704     // Get string representing the MachNode that projections point at
1705     const char *machNode = "this";
1706     // Generate the projections
1707     fprintf(fp,"  // Add projection edges for additional defs or kills\n");
1708 
1709     // Examine each component to see if it is a DEF or KILL
1710     node->_components.reset();
1711     // Skip the first component, if already handled as (SET dst (...))
1712     Component *comp = NULL;
1713     // For kills, the choice of projection numbers is arbitrary
1714     int proj_no = 1;
1715     bool declared_def  = false;
1716     bool declared_kill = false;
1717 
1718     while ((comp = node->_components.iter()) != NULL) {
1719       // Lookup register class associated with operand type
1720       Form *form = (Form*)_globalNames[comp->_type];
1721       assert(form, "component type must be a defined form");
1722       OperandForm *op = form->is_operand();
1723 
1724       if (comp->is(Component::TEMP) ||
1725           comp->is(Component::TEMP_DEF)) {
1726         fprintf(fp, "  // TEMP %s\n", comp->_name);
1727         if (!declared_def) {
1728           // Define the variable "def" to hold new MachProjNodes
1729           fprintf(fp, "  MachTempNode *def;\n");
1730           declared_def = true;
1731         }
1732         if (op && op->_interface && op->_interface->is_RegInterface()) {
1733           fprintf(fp,"  def = new MachTempNode(state->MachOperGenerator(%s));\n",
1734                   machOperEnum(op->_ident));
1735           fprintf(fp,"  add_req(def);\n");
1736           // The operand for TEMP is already constructed during
1737           // this mach node construction, see buildMachNode().
1738           //
1739           // int idx  = node->operand_position_format(comp->_name);
1740           // fprintf(fp,"  set_opnd_array(%d, state->MachOperGenerator(%s));\n",
1741           //         idx, machOperEnum(op->_ident));
1742         } else {
1743           assert(false, "can't have temps which aren't registers");
1744         }
1745       } else if (comp->isa(Component::KILL)) {
1746         fprintf(fp, "  // DEF/KILL %s\n", comp->_name);
1747 
1748         if (!declared_kill) {
1749           // Define the variable "kill" to hold new MachProjNodes
1750           fprintf(fp, "  MachProjNode *kill;\n");
1751           declared_kill = true;
1752         }
1753 
1754         assert(op, "Support additional KILLS for base operands");
1755         const char *regmask    = reg_mask(*op);
1756         const char *ideal_type = op->ideal_type(_globalNames, _register);
1757 
1758         if (!op->is_bound_register()) {
1759           syntax_err(node->_linenum, "In %s only bound registers can be killed: %s %s\n",
1760                      node->_ident, comp->_type, comp->_name);
1761         }
1762 
1763         fprintf(fp,"  kill = ");
1764         fprintf(fp,"new MachProjNode( %s, %d, (%s), Op_%s );\n",
1765                 machNode, proj_no++, regmask, ideal_type);
1766         fprintf(fp,"  proj_list.push(kill);\n");
1767       }
1768     }
1769   }
1770 
1771   if( !node->expands() && node->_matrule != NULL ) {
1772     // Remove duplicated operands and inputs which use the same name.
1773     // Seach through match operands for the same name usage.
1774     uint cur_num_opnds = node->num_opnds();