src/share/vm/adlc/output_c.cpp

changeset 2561
ab42c7e1cf83
parent 2350
2f644f85485d
child 2708
1d1603768966
     1.1 --- a/src/share/vm/adlc/output_c.cpp	Thu Feb 10 00:47:59 2011 -0800
     1.2 +++ b/src/share/vm/adlc/output_c.cpp	Thu Feb 10 14:25:59 2011 -0800
     1.3 @@ -1698,7 +1698,75 @@
     1.4      fprintf(fp,"\n");
     1.5    } // done generating expand rule
     1.6  
     1.7 -  else if( node->_matrule != NULL ) {
     1.8 +  // Generate projections for instruction's additional DEFs and KILLs
     1.9 +  if( ! node->expands() && (node->needs_projections() || node->has_temps())) {
    1.10 +    // Get string representing the MachNode that projections point at
    1.11 +    const char *machNode = "this";
    1.12 +    // Generate the projections
    1.13 +    fprintf(fp,"  // Add projection edges for additional defs or kills\n");
    1.14 +
    1.15 +    // Examine each component to see if it is a DEF or KILL
    1.16 +    node->_components.reset();
    1.17 +    // Skip the first component, if already handled as (SET dst (...))
    1.18 +    Component *comp = NULL;
    1.19 +    // For kills, the choice of projection numbers is arbitrary
    1.20 +    int proj_no = 1;
    1.21 +    bool declared_def  = false;
    1.22 +    bool declared_kill = false;
    1.23 +
    1.24 +    while( (comp = node->_components.iter()) != NULL ) {
    1.25 +      // Lookup register class associated with operand type
    1.26 +      Form        *form = (Form*)_globalNames[comp->_type];
    1.27 +      assert( form, "component type must be a defined form");
    1.28 +      OperandForm *op   = form->is_operand();
    1.29 +
    1.30 +      if (comp->is(Component::TEMP)) {
    1.31 +        fprintf(fp, "  // TEMP %s\n", comp->_name);
    1.32 +        if (!declared_def) {
    1.33 +          // Define the variable "def" to hold new MachProjNodes
    1.34 +          fprintf(fp, "  MachTempNode *def;\n");
    1.35 +          declared_def = true;
    1.36 +        }
    1.37 +        if (op && op->_interface && op->_interface->is_RegInterface()) {
    1.38 +          fprintf(fp,"  def = new (C) MachTempNode(state->MachOperGenerator( %s, C ));\n",
    1.39 +                  machOperEnum(op->_ident));
    1.40 +          fprintf(fp,"  add_req(def);\n");
    1.41 +          // The operand for TEMP is already constructed during
    1.42 +          // this mach node construction, see buildMachNode().
    1.43 +          //
    1.44 +          // int idx  = node->operand_position_format(comp->_name);
    1.45 +          // fprintf(fp,"  set_opnd_array(%d, state->MachOperGenerator( %s, C ));\n",
    1.46 +          //         idx, machOperEnum(op->_ident));
    1.47 +        } else {
    1.48 +          assert(false, "can't have temps which aren't registers");
    1.49 +        }
    1.50 +      } else if (comp->isa(Component::KILL)) {
    1.51 +        fprintf(fp, "  // DEF/KILL %s\n", comp->_name);
    1.52 +
    1.53 +        if (!declared_kill) {
    1.54 +          // Define the variable "kill" to hold new MachProjNodes
    1.55 +          fprintf(fp, "  MachProjNode *kill;\n");
    1.56 +          declared_kill = true;
    1.57 +        }
    1.58 +
    1.59 +        assert( op, "Support additional KILLS for base operands");
    1.60 +        const char *regmask    = reg_mask(*op);
    1.61 +        const char *ideal_type = op->ideal_type(_globalNames, _register);
    1.62 +
    1.63 +        if (!op->is_bound_register()) {
    1.64 +          syntax_err(node->_linenum, "In %s only bound registers can be killed: %s %s\n",
    1.65 +                     node->_ident, comp->_type, comp->_name);
    1.66 +        }
    1.67 +
    1.68 +        fprintf(fp,"  kill = ");
    1.69 +        fprintf(fp,"new (C, 1) MachProjNode( %s, %d, (%s), Op_%s );\n",
    1.70 +                machNode, proj_no++, regmask, ideal_type);
    1.71 +        fprintf(fp,"  proj_list.push(kill);\n");
    1.72 +      }
    1.73 +    }
    1.74 +  }
    1.75 +
    1.76 +  if( !node->expands() && node->_matrule != NULL ) {
    1.77      // Remove duplicated operands and inputs which use the same name.
    1.78      // Seach through match operands for the same name usage.
    1.79      uint cur_num_opnds = node->num_opnds();
    1.80 @@ -1752,72 +1820,6 @@
    1.81      }
    1.82    }
    1.83  
    1.84 -
    1.85 -  // Generate projections for instruction's additional DEFs and KILLs
    1.86 -  if( ! node->expands() && (node->needs_projections() || node->has_temps())) {
    1.87 -    // Get string representing the MachNode that projections point at
    1.88 -    const char *machNode = "this";
    1.89 -    // Generate the projections
    1.90 -    fprintf(fp,"  // Add projection edges for additional defs or kills\n");
    1.91 -
    1.92 -    // Examine each component to see if it is a DEF or KILL
    1.93 -    node->_components.reset();
    1.94 -    // Skip the first component, if already handled as (SET dst (...))
    1.95 -    Component *comp = NULL;
    1.96 -    // For kills, the choice of projection numbers is arbitrary
    1.97 -    int proj_no = 1;
    1.98 -    bool declared_def  = false;
    1.99 -    bool declared_kill = false;
   1.100 -
   1.101 -    while( (comp = node->_components.iter()) != NULL ) {
   1.102 -      // Lookup register class associated with operand type
   1.103 -      Form        *form = (Form*)_globalNames[comp->_type];
   1.104 -      assert( form, "component type must be a defined form");
   1.105 -      OperandForm *op   = form->is_operand();
   1.106 -
   1.107 -      if (comp->is(Component::TEMP)) {
   1.108 -        fprintf(fp, "  // TEMP %s\n", comp->_name);
   1.109 -        if (!declared_def) {
   1.110 -          // Define the variable "def" to hold new MachProjNodes
   1.111 -          fprintf(fp, "  MachTempNode *def;\n");
   1.112 -          declared_def = true;
   1.113 -        }
   1.114 -        if (op && op->_interface && op->_interface->is_RegInterface()) {
   1.115 -          fprintf(fp,"  def = new (C) MachTempNode(state->MachOperGenerator( %s, C ));\n",
   1.116 -                  machOperEnum(op->_ident));
   1.117 -          fprintf(fp,"  add_req(def);\n");
   1.118 -          int idx  = node->operand_position_format(comp->_name);
   1.119 -          fprintf(fp,"  set_opnd_array(%d, state->MachOperGenerator( %s, C ));\n",
   1.120 -                  idx, machOperEnum(op->_ident));
   1.121 -        } else {
   1.122 -          assert(false, "can't have temps which aren't registers");
   1.123 -        }
   1.124 -      } else if (comp->isa(Component::KILL)) {
   1.125 -        fprintf(fp, "  // DEF/KILL %s\n", comp->_name);
   1.126 -
   1.127 -        if (!declared_kill) {
   1.128 -          // Define the variable "kill" to hold new MachProjNodes
   1.129 -          fprintf(fp, "  MachProjNode *kill;\n");
   1.130 -          declared_kill = true;
   1.131 -        }
   1.132 -
   1.133 -        assert( op, "Support additional KILLS for base operands");
   1.134 -        const char *regmask    = reg_mask(*op);
   1.135 -        const char *ideal_type = op->ideal_type(_globalNames, _register);
   1.136 -
   1.137 -        if (!op->is_bound_register()) {
   1.138 -          syntax_err(node->_linenum, "In %s only bound registers can be killed: %s %s\n",
   1.139 -                     node->_ident, comp->_type, comp->_name);
   1.140 -        }
   1.141 -
   1.142 -        fprintf(fp,"  kill = ");
   1.143 -        fprintf(fp,"new (C, 1) MachProjNode( %s, %d, (%s), Op_%s );\n",
   1.144 -                machNode, proj_no++, regmask, ideal_type);
   1.145 -        fprintf(fp,"  proj_list.push(kill);\n");
   1.146 -      }
   1.147 -    }
   1.148 -  }
   1.149 -
   1.150    // If the node is a MachConstantNode, insert the MachConstantBaseNode edge.
   1.151    // NOTE: this edge must be the last input (see MachConstantNode::mach_constant_base_node_input).
   1.152    if (node->is_mach_constant()) {
   1.153 @@ -3776,12 +3778,10 @@
   1.154        }
   1.155        dont_care = true;
   1.156        // For each operand not in the match rule, call MachOperGenerator
   1.157 -      // with the enum for the opcode that needs to be built
   1.158 -      // and the node just built, the parent of the operand.
   1.159 +      // with the enum for the opcode that needs to be built.
   1.160        ComponentList clist = inst->_components;
   1.161        int         index  = clist.operand_position(comp->_name, comp->_usedef);
   1.162        const char *opcode = machOperEnum(comp->_type);
   1.163 -      const char *parent = "node";
   1.164        fprintf(fp_cpp, "%s node->set_opnd_array(%d, ", indent, index);
   1.165        fprintf(fp_cpp, "MachOperGenerator(%s, C));\n", opcode);
   1.166        }

mercurial