8000592: Improve adlc usability

Tue, 09 Oct 2012 16:09:31 -0700

author
kvn
date
Tue, 09 Oct 2012 16:09:31 -0700
changeset 4161
d336b3173277
parent 4160
f6badecb7ea7
child 4162
94e9408dbf50

8000592: Improve adlc usability
Summary: several changes to adlc to improve its usability
Reviewed-by: kvn
Contributed-by: goetz.lindenmaier@sap.com

src/share/vm/adlc/adlparse.cpp file | annotate | diff | comparison | revisions
src/share/vm/adlc/archDesc.cpp file | annotate | diff | comparison | revisions
src/share/vm/adlc/archDesc.hpp file | annotate | diff | comparison | revisions
src/share/vm/adlc/dict2.cpp file | annotate | diff | comparison | revisions
src/share/vm/adlc/filebuff.hpp file | annotate | diff | comparison | revisions
src/share/vm/adlc/forms.hpp file | annotate | diff | comparison | revisions
src/share/vm/adlc/formssel.cpp file | annotate | diff | comparison | revisions
src/share/vm/adlc/formssel.hpp file | annotate | diff | comparison | revisions
src/share/vm/adlc/main.cpp file | annotate | diff | comparison | revisions
src/share/vm/adlc/output_c.cpp file | annotate | diff | comparison | revisions
src/share/vm/adlc/output_h.cpp file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/vm/adlc/adlparse.cpp	Tue Oct 09 12:40:05 2012 -0700
     1.2 +++ b/src/share/vm/adlc/adlparse.cpp	Tue Oct 09 16:09:31 2012 -0700
     1.3 @@ -1392,7 +1392,7 @@
     1.4        _AD.addForm(machnode);
     1.5      }
     1.6      else if (!strcmp(ident, "attributes")) {
     1.7 -      bool vsi_seen = false, bhds_seen = false;
     1.8 +      bool vsi_seen = false;
     1.9  
    1.10        skipws();
    1.11        if ( (_curchar != '%')
    1.12 @@ -1436,7 +1436,6 @@
    1.13            }
    1.14  
    1.15            pipeline->_branchHasDelaySlot = true;
    1.16 -          bhds_seen = true;
    1.17            continue;
    1.18          }
    1.19  
    1.20 @@ -1639,6 +1638,12 @@
    1.21      next_char();                   // Skip "(" or ","
    1.22      ident = get_ident();           // Grab next identifier
    1.23  
    1.24 +    if (_AD._adl_debug > 1) {
    1.25 +      if (ident != NULL) {
    1.26 +        fprintf(stderr, "resource_parse: identifier: %s\n", ident);
    1.27 +      }
    1.28 +    }
    1.29 +
    1.30      if (ident == NULL) {
    1.31        parse_err(SYNERR, "keyword identifier expected at \"%c\"\n", _curchar);
    1.32        return;
    1.33 @@ -2427,7 +2432,6 @@
    1.34    int        lparen = 0;          // keep track of parenthesis nesting depth
    1.35    int        rparen = 0;          // position of instruction at this depth
    1.36    InstructForm *inst_seen  = NULL;
    1.37 -  InstructForm *child_seen = NULL;
    1.38  
    1.39    // Walk the match tree,
    1.40    // Record <parent, position, instruction name, input position>
    1.41 @@ -2437,7 +2441,7 @@
    1.42      if (_curchar == '(') {
    1.43        ++lparen;
    1.44        next_char();
    1.45 -      child_seen = peep_match_child_parse(match, parent, position, rparen);
    1.46 +      ( void ) peep_match_child_parse(match, parent, position, rparen);
    1.47      }
    1.48      // Right paren signals end of an input, may be more
    1.49      else if (_curchar == ')') {
    1.50 @@ -3154,6 +3158,9 @@
    1.51  
    1.52  
    1.53  //------------------------------size_parse-----------------------------------
    1.54 +// Parse a 'size(<expr>)' attribute which specifies the size of the
    1.55 +// emitted instructions in bytes. <expr> can be a C++ expression,
    1.56 +// e.g. a constant.
    1.57  char* ADLParser::size_parse(InstructForm *instr) {
    1.58    char* sizeOfInstr = NULL;
    1.59  
    1.60 @@ -4274,7 +4281,17 @@
    1.61              || ((c >= '0') && (c <= '9'))
    1.62              || ((c == '_')) || ((c == ':')) || ((c == '#')) );
    1.63    if (start == end) {             // We popped out on the first try
    1.64 -    parse_err(SYNERR, "identifier expected at %c\n", c);
    1.65 +    // It can occur that `start' contains the rest of the input file.
    1.66 +    // In this case the output should be truncated.
    1.67 +    if (strlen(start) > 24) {
    1.68 +      char buf[32];
    1.69 +      strncpy(buf, start, 20);
    1.70 +      buf[20] = '\0';
    1.71 +      strcat(buf, "[...]");
    1.72 +      parse_err(SYNERR, "Identifier expected, but found '%s'.", buf);
    1.73 +    } else {
    1.74 +      parse_err(SYNERR, "Identifier expected, but found '%s'.", start);
    1.75 +    }
    1.76      start = NULL;
    1.77    }
    1.78    else {
     2.1 --- a/src/share/vm/adlc/archDesc.cpp	Tue Oct 09 12:40:05 2012 -0700
     2.2 +++ b/src/share/vm/adlc/archDesc.cpp	Tue Oct 09 16:09:31 2012 -0700
     2.3 @@ -221,6 +221,7 @@
     2.4        _register = NULL;
     2.5        _encode = NULL;
     2.6        _pipeline = NULL;
     2.7 +      _frame = NULL;
     2.8  }
     2.9  
    2.10  ArchDesc::~ArchDesc() {
    2.11 @@ -648,7 +649,10 @@
    2.12  // Return the textual binding for a given CPP flag name.
    2.13  // Return NULL if there is no binding, or it has been #undef-ed.
    2.14  char* ArchDesc::get_preproc_def(const char* flag) {
    2.15 -  SourceForm* deff = (SourceForm*) _preproc_table[flag];
    2.16 +  // In case of syntax errors, flag may take the value NULL.
    2.17 +  SourceForm* deff = NULL;
    2.18 +  if (flag != NULL)
    2.19 +    deff = (SourceForm*) _preproc_table[flag];
    2.20    return (deff == NULL) ? NULL : deff->_code;
    2.21  }
    2.22  
    2.23 @@ -803,7 +807,9 @@
    2.24      while (i++ <= 15)  fputc(' ', errfile);
    2.25      fprintf(errfile, "%-8s:", pref);
    2.26      vfprintf(errfile, fmt, args);
    2.27 -    fprintf(errfile, "\n"); }
    2.28 +    fprintf(errfile, "\n");
    2.29 +    fflush(errfile);
    2.30 +  }
    2.31    return 1;
    2.32  }
    2.33  
    2.34 @@ -855,8 +861,14 @@
    2.35  
    2.36    // Check constraints on result's register class
    2.37    const char *result_class = opForm.constrained_reg_class();
    2.38 -  if (!result_class) opForm.dump();
    2.39 -  assert( result_class, "Resulting register class was not defined for operand");
    2.40 +  if (result_class == NULL) {
    2.41 +    opForm.dump();
    2.42 +    syntax_err(opForm._linenum,
    2.43 +               "Use of an undefined result class for operand: %s",
    2.44 +               opForm._ident);
    2.45 +    abort();
    2.46 +  }
    2.47 +
    2.48    regMask = reg_class_to_reg_mask( result_class );
    2.49  
    2.50    return regMask;
    2.51 @@ -865,8 +877,14 @@
    2.52  // Obtain the name of the RegMask for an InstructForm
    2.53  const char *ArchDesc::reg_mask(InstructForm &inForm) {
    2.54    const char *result = inForm.reduce_result();
    2.55 -  assert( result,
    2.56 -          "Did not find result operand or RegMask for this instruction");
    2.57 +
    2.58 +  if (result == NULL) {
    2.59 +    syntax_err(inForm._linenum,
    2.60 +               "Did not find result operand or RegMask"
    2.61 +               " for this instruction: %s",
    2.62 +               inForm._ident);
    2.63 +    abort();
    2.64 +  }
    2.65  
    2.66    // Instructions producing 'Universe' use RegMask::Empty
    2.67    if( strcmp(result,"Universe")==0 ) {
    2.68 @@ -875,10 +893,17 @@
    2.69  
    2.70    // Lookup this result operand and get its register class
    2.71    Form *form = (Form*)_globalNames[result];
    2.72 -  assert( form, "Result operand must be defined");
    2.73 +  if (form == NULL) {
    2.74 +    syntax_err(inForm._linenum,
    2.75 +               "Did not find result operand for result: %s", result);
    2.76 +    abort();
    2.77 +  }
    2.78    OperandForm *oper = form->is_operand();
    2.79 -  if (oper == NULL) form->dump();
    2.80 -  assert( oper, "Result must be an OperandForm");
    2.81 +  if (oper == NULL) {
    2.82 +    syntax_err(inForm._linenum, "Form is not an OperandForm:");
    2.83 +    form->dump();
    2.84 +    abort();
    2.85 +  }
    2.86    return reg_mask( *oper );
    2.87  }
    2.88  
    2.89 @@ -887,7 +912,13 @@
    2.90  char *ArchDesc::stack_or_reg_mask(OperandForm  &opForm) {
    2.91    // name of cisc_spillable version
    2.92    const char *reg_mask_name = reg_mask(opForm);
    2.93 -  assert( reg_mask_name != NULL, "called with incorrect opForm");
    2.94 +
    2.95 +  if (reg_mask_name == NULL) {
    2.96 +     syntax_err(opForm._linenum,
    2.97 +                "Did not find reg_mask for opForm: %s",
    2.98 +                opForm._ident);
    2.99 +     abort();
   2.100 +  }
   2.101  
   2.102    const char *stack_or = "STACK_OR_";
   2.103    int   length         = (int)strlen(stack_or) + (int)strlen(reg_mask_name) + 1;
     3.1 --- a/src/share/vm/adlc/archDesc.hpp	Tue Oct 09 12:40:05 2012 -0700
     3.2 +++ b/src/share/vm/adlc/archDesc.hpp	Tue Oct 09 16:09:31 2012 -0700
     3.3 @@ -365,13 +365,14 @@
     3.4  // A derived class defines the appropriate output for a specific mapping.
     3.5  class OutputMap {
     3.6  protected:
     3.7 -  FILE     *_hpp;
     3.8 -  FILE     *_cpp;
     3.9 -  FormDict &_globals;
    3.10 -  ArchDesc &_AD;
    3.11 +  FILE       *_hpp;
    3.12 +  FILE       *_cpp;
    3.13 +  FormDict   &_globals;
    3.14 +  ArchDesc   &_AD;
    3.15 +  const char *_name;
    3.16  public:
    3.17 -  OutputMap (FILE *decl_file, FILE *def_file, FormDict &globals, ArchDesc &AD)
    3.18 -    : _hpp(decl_file), _cpp(def_file), _globals(globals), _AD(AD) {};
    3.19 +  OutputMap (FILE *decl_file, FILE *def_file, FormDict &globals, ArchDesc &AD, const char *name)
    3.20 +    : _hpp(decl_file), _cpp(def_file), _globals(globals), _AD(AD), _name(name) {};
    3.21    // Access files used by this routine
    3.22    FILE        *decl_file() { return _hpp; }
    3.23    FILE        *def_file()  { return _cpp; }
     4.1 --- a/src/share/vm/adlc/dict2.cpp	Tue Oct 09 12:40:05 2012 -0700
     4.2 +++ b/src/share/vm/adlc/dict2.cpp	Tue Oct 09 16:09:31 2012 -0700
     4.3 @@ -33,7 +33,7 @@
     4.4  // String hash tables
     4.5  #define MAXID 20
     4.6  static char initflag = 0;       // True after 1st initialization
     4.7 -static char shft[MAXID] = {1,2,3,4,5,6,7,1,2,3,4,5,6,7,1,2,3,4,5,6};
     4.8 +static char shft[MAXID + 1] = {1,2,3,4,5,6,7,1,2,3,4,5,6,7,1,2,3,4,5,6,7};
     4.9  static short xsum[MAXID];
    4.10  
    4.11  //------------------------------bucket---------------------------------------
     5.1 --- a/src/share/vm/adlc/filebuff.hpp	Tue Oct 09 12:40:05 2012 -0700
     5.2 +++ b/src/share/vm/adlc/filebuff.hpp	Tue Oct 09 16:09:31 2012 -0700
     5.3 @@ -31,10 +31,14 @@
     5.4  using namespace std;
     5.5  
     5.6  // STRUCTURE FOR HANDLING INPUT AND OUTPUT FILES
     5.7 -typedef struct {
     5.8 +
     5.9 +class BufferedFile {
    5.10 + public:
    5.11    const char *_name;
    5.12    FILE *_fp;
    5.13 -} BufferedFile;
    5.14 +  inline BufferedFile() { _name = NULL; _fp = NULL; };
    5.15 +  inline ~BufferedFile() {};
    5.16 +};
    5.17  
    5.18  class ArchDesc;
    5.19  
     6.1 --- a/src/share/vm/adlc/forms.hpp	Tue Oct 09 12:40:05 2012 -0700
     6.2 +++ b/src/share/vm/adlc/forms.hpp	Tue Oct 09 16:09:31 2012 -0700
     6.3 @@ -449,11 +449,11 @@
     6.4    // Return number of USEs + number of DEFs
     6.5    int        num_operands();
     6.6    // Return zero-based position in list;  -1 if not in list.
     6.7 -  int        operand_position(const char *name, int usedef);
     6.8 +  int        operand_position(const char *name, int usedef, Form *fm);
     6.9    // Find position for this name, regardless of use/def information
    6.10    int        operand_position(const char *name);
    6.11    // Find position for this name when looked up for output via "format"
    6.12 -  int        operand_position_format(const char *name);
    6.13 +  int        operand_position_format(const char *name, Form *fm);
    6.14    // Find position for the Label when looked up for output via "format"
    6.15    int        label_position();
    6.16    // Find position for the Method when looked up for output via "format"
     7.1 --- a/src/share/vm/adlc/formssel.cpp	Tue Oct 09 12:40:05 2012 -0700
     7.2 +++ b/src/share/vm/adlc/formssel.cpp	Tue Oct 09 16:09:31 2012 -0700
     7.3 @@ -567,7 +567,7 @@
     7.4          if( strcmp(rc_name,"stack_slots") ) {
     7.5            // Check for ideal_type of RegFlags
     7.6            const char *type = opform->ideal_type( globals, registers );
     7.7 -          if( !strcmp(type,"RegFlags") )
     7.8 +          if( (type != NULL) && !strcmp(type, "RegFlags") )
     7.9              rematerialize = true;
    7.10          } else
    7.11            rematerialize = false; // Do not rematerialize things target stk
    7.12 @@ -795,6 +795,20 @@
    7.13    return num_opnds;
    7.14  }
    7.15  
    7.16 +const char *InstructForm::opnd_ident(int idx) {
    7.17 +  return _components.at(idx)->_name;
    7.18 +}
    7.19 +
    7.20 +const char *InstructForm::unique_opnd_ident(int idx) {
    7.21 +  uint i;
    7.22 +  for (i = 1; i < num_opnds(); ++i) {
    7.23 +    if (unique_opnds_idx(i) == idx) {
    7.24 +      break;
    7.25 +    }
    7.26 +  }
    7.27 +  return (_components.at(i) != NULL) ? _components.at(i)->_name : "";
    7.28 +}
    7.29 +
    7.30  // Return count of unmatched operands.
    7.31  uint InstructForm::num_post_match_opnds() {
    7.32    uint  num_post_match_opnds = _components.count();
    7.33 @@ -866,6 +880,9 @@
    7.34    return base;
    7.35  }
    7.36  
    7.37 +// This function determines the order of the MachOper in _opnds[]
    7.38 +// by writing the operand names into the _components list.
    7.39 +//
    7.40  // Implementation does not modify state of internal structures
    7.41  void InstructForm::build_components() {
    7.42    // Add top-level operands to the components
    7.43 @@ -961,11 +978,11 @@
    7.44  
    7.45  // Return zero-based position in component list;  -1 if not in list.
    7.46  int   InstructForm::operand_position(const char *name, int usedef) {
    7.47 -  return unique_opnds_idx(_components.operand_position(name, usedef));
    7.48 +  return unique_opnds_idx(_components.operand_position(name, usedef, this));
    7.49  }
    7.50  
    7.51  int   InstructForm::operand_position_format(const char *name) {
    7.52 -  return unique_opnds_idx(_components.operand_position_format(name));
    7.53 +  return unique_opnds_idx(_components.operand_position_format(name, this));
    7.54  }
    7.55  
    7.56  // Return zero-based position in component list; -1 if not in list.
    7.57 @@ -1225,7 +1242,7 @@
    7.58      if (different) {
    7.59        globalAD->syntax_err(short_branch->_linenum, "Instruction %s and its short form %s have different parameters\n", _ident, short_branch->_ident);
    7.60      }
    7.61 -    if (AD._short_branch_debug) {
    7.62 +    if (AD._adl_debug > 1 || AD._short_branch_debug) {
    7.63        fprintf(stderr, "Instruction %s has short form %s\n", _ident, short_branch->_ident);
    7.64      }
    7.65      _short_branch_form = short_branch;
    7.66 @@ -1257,16 +1274,19 @@
    7.67    // Find replacement variable's type
    7.68    const Form *form   = _localNames[rep_var];
    7.69    if (form == NULL) {
    7.70 -    fprintf(stderr, "unknown replacement variable in format statement: '%s'\n", rep_var);
    7.71 -    assert(false, "ShouldNotReachHere()");
    7.72 +    globalAD->syntax_err(_linenum, "Unknown replacement variable %s in format statement of %s.",
    7.73 +                         rep_var, _ident);
    7.74 +    return;
    7.75    }
    7.76    OpClassForm *opc   = form->is_opclass();
    7.77    assert( opc, "replacement variable was not found in local names");
    7.78    // Lookup the index position of the replacement variable
    7.79    int idx  = operand_position_format(rep_var);
    7.80    if ( idx == -1 ) {
    7.81 -    assert( strcmp(opc->_ident,"label")==0, "Unimplemented");
    7.82 -    assert( false, "ShouldNotReachHere()");
    7.83 +    globalAD->syntax_err(_linenum, "Could not find replacement variable %s in format statement of %s.\n",
    7.84 +                         rep_var, _ident);
    7.85 +    assert(strcmp(opc->_ident, "label") == 0, "Unimplemented");
    7.86 +    return;
    7.87    }
    7.88  
    7.89    if (is_noninput_operand(idx)) {
    7.90 @@ -1275,7 +1295,7 @@
    7.91      OperandForm* oper = form->is_operand();
    7.92      if (oper != NULL && oper->is_bound_register()) {
    7.93        const RegDef* first = oper->get_RegClass()->find_first_elem();
    7.94 -      fprintf(fp, "    tty->print(\"%s\");\n", first->_regname);
    7.95 +      fprintf(fp, "    st->print(\"%s\");\n", first->_regname);
    7.96      } else {
    7.97        globalAD->syntax_err(_linenum, "In %s can't find format for %s %s", _ident, opc->_ident, rep_var);
    7.98      }
    7.99 @@ -1373,26 +1393,28 @@
   7.100    // idx0=0 is used to indicate that info comes from this same node, not from input edge.
   7.101    // idx1 starts at oper_input_base()
   7.102    if ( cur_num_opnds >= 1 ) {
   7.103 -    fprintf(fp,"    // Start at oper_input_base() and count operands\n");
   7.104 -    fprintf(fp,"    unsigned %sidx0 = %d;\n", prefix, oper_input_base(globals));
   7.105 -    fprintf(fp,"    unsigned %sidx1 = %d;\n", prefix, oper_input_base(globals));
   7.106 +    fprintf(fp,"  // Start at oper_input_base() and count operands\n");
   7.107 +    fprintf(fp,"  unsigned %sidx0 = %d;\n", prefix, oper_input_base(globals));
   7.108 +    fprintf(fp,"  unsigned %sidx1 = %d;", prefix, oper_input_base(globals));
   7.109 +    fprintf(fp," \t// %s\n", unique_opnd_ident(1));
   7.110  
   7.111      // Generate starting points for other unique operands if they exist
   7.112      for ( idx = 2; idx < num_unique_opnds(); ++idx ) {
   7.113        if( *receiver == 0 ) {
   7.114 -        fprintf(fp,"    unsigned %sidx%d = %sidx%d + opnd_array(%d)->num_edges();\n",
   7.115 +        fprintf(fp,"  unsigned %sidx%d = %sidx%d + opnd_array(%d)->num_edges();",
   7.116                  prefix, idx, prefix, idx-1, idx-1 );
   7.117        } else {
   7.118 -        fprintf(fp,"    unsigned %sidx%d = %sidx%d + %s_opnds[%d]->num_edges();\n",
   7.119 +        fprintf(fp,"  unsigned %sidx%d = %sidx%d + %s_opnds[%d]->num_edges();",
   7.120                  prefix, idx, prefix, idx-1, receiver, idx-1 );
   7.121        }
   7.122 +      fprintf(fp," \t// %s\n", unique_opnd_ident(idx));
   7.123      }
   7.124    }
   7.125    if( *receiver != 0 ) {
   7.126      // This value is used by generate_peepreplace when copying a node.
   7.127      // Don't emit it in other cases since it can hide bugs with the
   7.128      // use invalid idx's.
   7.129 -    fprintf(fp,"    unsigned %sidx%d = %sreq(); \n", prefix, idx, receiver);
   7.130 +    fprintf(fp,"  unsigned %sidx%d = %sreq(); \n", prefix, idx, receiver);
   7.131    }
   7.132  
   7.133  }
   7.134 @@ -1776,9 +1798,25 @@
   7.135    return Component::INVALID;
   7.136  }
   7.137  
   7.138 +const char *Component::getUsedefName() {
   7.139 +  switch (_usedef) {
   7.140 +    case Component::INVALID:  return "INVALID";  break;
   7.141 +    case Component::USE:      return "USE";      break;
   7.142 +    case Component::USE_DEF:  return "USE_DEF";  break;
   7.143 +    case Component::USE_KILL: return "USE_KILL"; break;
   7.144 +    case Component::KILL:     return "KILL";     break;
   7.145 +    case Component::TEMP:     return "TEMP";     break;
   7.146 +    case Component::DEF:      return "DEF";      break;
   7.147 +    case Component::CALL:     return "CALL";     break;
   7.148 +    default: assert(false, "unknown effect");
   7.149 +  }
   7.150 +  return "Undefined Use/Def info";
   7.151 +}
   7.152 +
   7.153  Effect::Effect(const char *name) : _name(name), _use_def(effect_lookup(name)) {
   7.154    _ftype = Form::EFF;
   7.155  }
   7.156 +
   7.157  Effect::~Effect() {
   7.158  }
   7.159  
   7.160 @@ -2275,7 +2313,7 @@
   7.161  }
   7.162  
   7.163  int OperandForm::operand_position(const char *name, int usedef) {
   7.164 -  return _components.operand_position(name, usedef);
   7.165 +  return _components.operand_position(name, usedef, this);
   7.166  }
   7.167  
   7.168  
   7.169 @@ -2401,20 +2439,20 @@
   7.170    if (_matrule && (_matrule->is_base_register(globals) ||
   7.171                     strcmp(ideal_type(globalAD->globalNames()), "RegFlags") == 0)) {
   7.172      // !!!!! !!!!!
   7.173 -    fprintf(fp,    "{ char reg_str[128];\n");
   7.174 -    fprintf(fp,"      ra->dump_register(node,reg_str);\n");
   7.175 -    fprintf(fp,"      tty->print(\"%cs\",reg_str);\n",'%');
   7.176 -    fprintf(fp,"    }\n");
   7.177 +    fprintf(fp,"  { char reg_str[128];\n");
   7.178 +    fprintf(fp,"    ra->dump_register(node,reg_str);\n");
   7.179 +    fprintf(fp,"    st->print(\"%cs\",reg_str);\n",'%');
   7.180 +    fprintf(fp,"  }\n");
   7.181    } else if (_matrule && (dtype = _matrule->is_base_constant(globals)) != Form::none) {
   7.182      format_constant( fp, index, dtype );
   7.183    } else if (ideal_to_sReg_type(_ident) != Form::none) {
   7.184      // Special format for Stack Slot Register
   7.185 -    fprintf(fp,    "{ char reg_str[128];\n");
   7.186 -    fprintf(fp,"      ra->dump_register(node,reg_str);\n");
   7.187 -    fprintf(fp,"      tty->print(\"%cs\",reg_str);\n",'%');
   7.188 -    fprintf(fp,"    }\n");
   7.189 +    fprintf(fp,"  { char reg_str[128];\n");
   7.190 +    fprintf(fp,"    ra->dump_register(node,reg_str);\n");
   7.191 +    fprintf(fp,"    st->print(\"%cs\",reg_str);\n",'%');
   7.192 +    fprintf(fp,"  }\n");
   7.193    } else {
   7.194 -    fprintf(fp,"tty->print(\"No format defined for %s\n\");\n", _ident);
   7.195 +    fprintf(fp,"  st->print(\"No format defined for %s\n\");\n", _ident);
   7.196      fflush(fp);
   7.197      fprintf(stderr,"No format defined for %s\n", _ident);
   7.198      dump();
   7.199 @@ -2428,37 +2466,37 @@
   7.200    Form::DataType dtype;
   7.201    if (_matrule && (_matrule->is_base_register(globals) ||
   7.202                     strcmp(ideal_type(globalAD->globalNames()), "RegFlags") == 0)) {
   7.203 -    fprintf(fp,    "{ char reg_str[128];\n");
   7.204 -    fprintf(fp,"      ra->dump_register(node->in(idx");
   7.205 -    if ( index != 0 ) fprintf(fp,                  "+%d",index);
   7.206 -    fprintf(fp,                                       "),reg_str);\n");
   7.207 -    fprintf(fp,"      tty->print(\"%cs\",reg_str);\n",'%');
   7.208 -    fprintf(fp,"    }\n");
   7.209 +    fprintf(fp,"  { char reg_str[128];\n");
   7.210 +    fprintf(fp,"    ra->dump_register(node->in(idx");
   7.211 +    if ( index != 0 ) fprintf(fp,              "+%d",index);
   7.212 +    fprintf(fp,                                      "),reg_str);\n");
   7.213 +    fprintf(fp,"    st->print(\"%cs\",reg_str);\n",'%');
   7.214 +    fprintf(fp,"  }\n");
   7.215    } else if (_matrule && (dtype = _matrule->is_base_constant(globals)) != Form::none) {
   7.216      format_constant( fp, index, dtype );
   7.217    } else if (ideal_to_sReg_type(_ident) != Form::none) {
   7.218      // Special format for Stack Slot Register
   7.219 -    fprintf(fp,    "{ char reg_str[128];\n");
   7.220 -    fprintf(fp,"      ra->dump_register(node->in(idx");
   7.221 +    fprintf(fp,"  { char reg_str[128];\n");
   7.222 +    fprintf(fp,"    ra->dump_register(node->in(idx");
   7.223      if ( index != 0 ) fprintf(fp,                  "+%d",index);
   7.224      fprintf(fp,                                       "),reg_str);\n");
   7.225 -    fprintf(fp,"      tty->print(\"%cs\",reg_str);\n",'%');
   7.226 -    fprintf(fp,"    }\n");
   7.227 +    fprintf(fp,"    st->print(\"%cs\",reg_str);\n",'%');
   7.228 +    fprintf(fp,"  }\n");
   7.229    } else {
   7.230 -    fprintf(fp,"tty->print(\"No format defined for %s\n\");\n", _ident);
   7.231 +    fprintf(fp,"  st->print(\"No format defined for %s\n\");\n", _ident);
   7.232      assert( false,"Internal error:\n  output_external_operand() attempting to output other than a Register or Constant");
   7.233    }
   7.234  }
   7.235  
   7.236  void OperandForm::format_constant(FILE *fp, uint const_index, uint const_type) {
   7.237    switch(const_type) {
   7.238 -  case Form::idealI:  fprintf(fp,"st->print(\"#%%d\", _c%d);\n", const_index); break;
   7.239 -  case Form::idealP:  fprintf(fp,"_c%d->dump_on(st);\n",         const_index); break;
   7.240 +  case Form::idealI: fprintf(fp,"  st->print(\"#%%d\", _c%d);\n", const_index); break;
   7.241 +  case Form::idealP: fprintf(fp,"  if (_c%d) _c%d->dump_on(st);\n", const_index, const_index); break;
   7.242    case Form::idealNKlass:
   7.243 -  case Form::idealN:  fprintf(fp,"_c%d->dump_on(st);\n",         const_index); break;
   7.244 -  case Form::idealL:  fprintf(fp,"st->print(\"#%%lld\", _c%d);\n", const_index); break;
   7.245 -  case Form::idealF:  fprintf(fp,"st->print(\"#%%f\", _c%d);\n", const_index); break;
   7.246 -  case Form::idealD:  fprintf(fp,"st->print(\"#%%f\", _c%d);\n", const_index); break;
   7.247 +  case Form::idealN: fprintf(fp,"  if (_c%d) _c%d->dump_on(st);\n", const_index, const_index); break;
   7.248 +  case Form::idealL: fprintf(fp,"  st->print(\"#%%lld\", _c%d);\n", const_index); break;
   7.249 +  case Form::idealF: fprintf(fp,"  st->print(\"#%%f\", _c%d);\n", const_index); break;
   7.250 +  case Form::idealD: fprintf(fp,"  st->print(\"#%%f\", _c%d);\n", const_index); break;
   7.251    default:
   7.252      assert( false, "ShouldNotReachHere()");
   7.253    }
   7.254 @@ -2828,17 +2866,8 @@
   7.255    fprintf(fp,"Component:");  // Write to output files
   7.256    fprintf(fp, "  name = %s", _name);
   7.257    fprintf(fp, ", type = %s", _type);
   7.258 -  const char * usedef = "Undefined Use/Def info";
   7.259 -  switch (_usedef) {
   7.260 -    case USE:      usedef = "USE";      break;
   7.261 -    case USE_DEF:  usedef = "USE_DEF";  break;
   7.262 -    case USE_KILL: usedef = "USE_KILL"; break;
   7.263 -    case KILL:     usedef = "KILL";     break;
   7.264 -    case TEMP:     usedef = "TEMP";     break;
   7.265 -    case DEF:      usedef = "DEF";      break;
   7.266 -    default: assert(false, "unknown effect");
   7.267 -  }
   7.268 -  fprintf(fp, ", use/def = %s\n", usedef);
   7.269 +  assert(_usedef != 0, "unknown effect");
   7.270 +  fprintf(fp, ", use/def = %s\n", getUsedefName());
   7.271  }
   7.272  
   7.273  
   7.274 @@ -2930,9 +2959,9 @@
   7.275    return count;
   7.276  }
   7.277  
   7.278 -// Return zero-based position in list;  -1 if not in list.
   7.279 +// Return zero-based position of operand 'name' in list;  -1 if not in list.
   7.280  // if parameter 'usedef' is ::USE, it will match USE, USE_DEF, ...
   7.281 -int ComponentList::operand_position(const char *name, int usedef) {
   7.282 +int ComponentList::operand_position(const char *name, int usedef, Form *fm) {
   7.283    PreserveIter pi(this);
   7.284    int position = 0;
   7.285    int num_opnds = num_operands();
   7.286 @@ -2955,10 +2984,18 @@
   7.287          return position+1;
   7.288        } else {
   7.289          if( preceding_non_use && strcmp(component->_name, preceding_non_use->_name) ) {
   7.290 -          fprintf(stderr, "the name '%s' should not precede the name '%s'\n", preceding_non_use->_name, name);
   7.291 +          fprintf(stderr, "the name '%s(%s)' should not precede the name '%s(%s)'",
   7.292 +                  preceding_non_use->_name, preceding_non_use->getUsedefName(),
   7.293 +                  name, component->getUsedefName());
   7.294 +          if (fm && fm->is_instruction()) fprintf(stderr,  "in form '%s'", fm->is_instruction()->_ident);
   7.295 +          if (fm && fm->is_operand()) fprintf(stderr,  "in form '%s'", fm->is_operand()->_ident);
   7.296 +          fprintf(stderr,  "\n");
   7.297          }
   7.298          if( position >= num_opnds ) {
   7.299 -          fprintf(stderr, "the name '%s' is too late in its name list\n", name);
   7.300 +          fprintf(stderr, "the name '%s' is too late in its name list", name);
   7.301 +          if (fm && fm->is_instruction()) fprintf(stderr,  "in form '%s'", fm->is_instruction()->_ident);
   7.302 +          if (fm && fm->is_operand()) fprintf(stderr,  "in form '%s'", fm->is_operand()->_ident);
   7.303 +          fprintf(stderr,  "\n");
   7.304          }
   7.305          assert(position < num_opnds, "advertised index in bounds");
   7.306          return position;
   7.307 @@ -3004,10 +3041,10 @@
   7.308    return Not_in_list;
   7.309  }
   7.310  
   7.311 -int ComponentList::operand_position_format(const char *name) {
   7.312 +int ComponentList::operand_position_format(const char *name, Form *fm) {
   7.313    PreserveIter pi(this);
   7.314    int  first_position = operand_position(name);
   7.315 -  int  use_position   = operand_position(name, Component::USE);
   7.316 +  int  use_position   = operand_position(name, Component::USE, fm);
   7.317  
   7.318    return ((first_position < use_position) ? use_position : first_position);
   7.319  }
   7.320 @@ -3270,8 +3307,8 @@
   7.321  
   7.322    // If we are a "Set", start from the right child.
   7.323    const MatchNode *const mnode = sets_result() ?
   7.324 -    (const MatchNode *const)this->_rChild :
   7.325 -    (const MatchNode *const)this;
   7.326 +    (const MatchNode *)this->_rChild :
   7.327 +    (const MatchNode *)this;
   7.328  
   7.329    // If our right child exists, it is the right reduction
   7.330    if ( mnode->_rChild ) {
   7.331 @@ -3288,8 +3325,8 @@
   7.332  
   7.333    // If we are a "Set", start from the right child.
   7.334    const MatchNode *const mnode = sets_result() ?
   7.335 -    (const MatchNode *const)this->_rChild :
   7.336 -    (const MatchNode *const)this;
   7.337 +    (const MatchNode *)this->_rChild :
   7.338 +    (const MatchNode *)this;
   7.339  
   7.340    // If our left child exists, it is the left reduction
   7.341    if ( mnode->_lChild ) {
   7.342 @@ -4113,12 +4150,17 @@
   7.343    output(stderr);
   7.344  }
   7.345  
   7.346 -void MatchRule::output(FILE *fp) {
   7.347 +// Write just one line.
   7.348 +void MatchRule::output_short(FILE *fp) {
   7.349    fprintf(fp,"MatchRule: ( %s",_name);
   7.350    if (_lChild) _lChild->output(fp);
   7.351    if (_rChild) _rChild->output(fp);
   7.352 -  fprintf(fp," )\n");
   7.353 -  fprintf(fp,"   nesting depth = %d\n", _depth);
   7.354 +  fprintf(fp," )");
   7.355 +}
   7.356 +
   7.357 +void MatchRule::output(FILE *fp) {
   7.358 +  output_short(fp);
   7.359 +  fprintf(fp,"\n   nesting depth = %d\n", _depth);
   7.360    if (_result) fprintf(fp,"   Result Type = %s", _result);
   7.361    fprintf(fp,"\n");
   7.362  }
     8.1 --- a/src/share/vm/adlc/formssel.hpp	Tue Oct 09 12:40:05 2012 -0700
     8.2 +++ b/src/share/vm/adlc/formssel.hpp	Tue Oct 09 16:09:31 2012 -0700
     8.3 @@ -76,7 +76,7 @@
     8.4  private:
     8.5    bool           _ideal_only;       // Not a user-defined instruction
     8.6    // Members used for tracking CISC-spilling
     8.7 -  uint           _cisc_spill_operand;// Which operand may cisc-spill
     8.8 +  int            _cisc_spill_operand;// Which operand may cisc-spill
     8.9    void           set_cisc_spill_operand(uint op_index) { _cisc_spill_operand = op_index; }
    8.10    bool           _is_cisc_alternate;
    8.11    InstructForm  *_cisc_spill_alternate;// cisc possible replacement
    8.12 @@ -103,7 +103,7 @@
    8.13    RewriteRule   *_rewrule;         // Rewrite rule for this instruction
    8.14    FormatRule    *_format;          // Format for assembly generation
    8.15    Peephole      *_peephole;        // List of peephole rules for instruction
    8.16 -  const char    *_ins_pipe;        // Instruction Scheduline description class
    8.17 +  const char    *_ins_pipe;        // Instruction Scheduling description class
    8.18  
    8.19    uint          *_uniq_idx;        // Indexes of unique operands
    8.20    int            _uniq_idx_length; // Length of _uniq_idx array
    8.21 @@ -198,6 +198,7 @@
    8.22  
    8.23    virtual const char *cost();      // Access ins_cost attribute
    8.24    virtual uint        num_opnds(); // Count of num_opnds for MachNode class
    8.25 +                                   // Counts USE_DEF opnds twice.  See also num_unique_opnds().
    8.26    virtual uint        num_post_match_opnds();
    8.27    virtual uint        num_consts(FormDict &globals) const;// Constants in match rule
    8.28    // Constants in match rule with specified type
    8.29 @@ -228,6 +229,7 @@
    8.30    // Return number of relocation entries needed for this instruction.
    8.31    virtual uint        reloc(FormDict &globals);
    8.32  
    8.33 +  const char         *opnd_ident(int idx);  // Name of operand #idx.
    8.34    const char         *reduce_result();
    8.35    // Return the name of the operand on the right hand side of the binary match
    8.36    // Return NULL if there is no right hand side
    8.37 @@ -240,7 +242,7 @@
    8.38    // Check if this instruction can cisc-spill to 'alternate'
    8.39    bool                cisc_spills_to(ArchDesc &AD, InstructForm *alternate);
    8.40    InstructForm       *cisc_spill_alternate() { return _cisc_spill_alternate; }
    8.41 -  uint                cisc_spill_operand() const { return _cisc_spill_operand; }
    8.42 +  int                 cisc_spill_operand() const { return _cisc_spill_operand; }
    8.43    bool                is_cisc_alternate() const { return _is_cisc_alternate; }
    8.44    void                set_cisc_alternate(bool val) { _is_cisc_alternate = val; }
    8.45    const char         *cisc_reg_mask_name() const { return _cisc_reg_mask_name; }
    8.46 @@ -277,6 +279,7 @@
    8.47                            return idx;
    8.48                          }
    8.49    }
    8.50 +  const char         *unique_opnd_ident(int idx);  // Name of operand at unique idx.
    8.51  
    8.52    // Operands which are only KILLs aren't part of the input array and
    8.53    // require special handling in some cases.  Their position in this
    8.54 @@ -889,6 +892,7 @@
    8.55  
    8.56    void dump();                     // Debug printer
    8.57    void output(FILE *fp);           // Write to output files
    8.58 +  const char* getUsedefName();
    8.59  
    8.60  public:
    8.61    // Implementation depends upon working bit intersection and union.
    8.62 @@ -1030,6 +1034,7 @@
    8.63    void       matchrule_swap_commutative_op(const char* instr_ident, int count, int& match_rules_cnt);
    8.64  
    8.65    void dump();
    8.66 +  void output_short(FILE *fp);
    8.67    void output(FILE *fp);
    8.68  };
    8.69  
     9.1 --- a/src/share/vm/adlc/main.cpp	Tue Oct 09 12:40:05 2012 -0700
     9.2 +++ b/src/share/vm/adlc/main.cpp	Tue Oct 09 16:09:31 2012 -0700
     9.3 @@ -341,14 +341,20 @@
     9.4  static void usage(ArchDesc& AD)
     9.5  {
     9.6    printf("Architecture Description Language Compiler\n\n");
     9.7 -  printf("Usage: adl [-doqw] [-Dflag[=def]] [-Uflag] [-cFILENAME] [-hFILENAME] [-aDFAFILE] ADLFILE\n");
     9.8 +  printf("Usage: adlc [-doqwTs] [-#]* [-D<FLAG>[=<DEF>]] [-U<FLAG>] [-c<CPP_FILE_NAME>] [-h<HPP_FILE_NAME>] [-a<DFA_FILE_NAME>] [-v<GLOBALS_FILE_NAME>] <ADL_FILE_NAME>\n");
     9.9    printf(" d  produce DFA debugging info\n");
    9.10    printf(" o  no output produced, syntax and semantic checking only\n");
    9.11    printf(" q  quiet mode, supresses all non-essential messages\n");
    9.12    printf(" w  suppress warning messages\n");
    9.13 +  printf(" T  make DFA as many subroutine calls\n");
    9.14 +  printf(" s  output which instructions are cisc-spillable\n");
    9.15 +  printf(" D  define preprocessor symbol\n");
    9.16 +  printf(" U  undefine preprocessor symbol\n");
    9.17    printf(" c  specify CPP file name (default: %s)\n", AD._CPP_file._name);
    9.18    printf(" h  specify HPP file name (default: %s)\n", AD._HPP_file._name);
    9.19    printf(" a  specify DFA output file name\n");
    9.20 +  printf(" v  specify adGlobals output file name\n");
    9.21 +  printf(" #  increment ADL debug level\n");
    9.22    printf("\n");
    9.23  }
    9.24  
    9.25 @@ -450,22 +456,6 @@
    9.26    return fname;
    9.27  }
    9.28  
    9.29 -//------------------------------strip_path_and_ext------------------------------
    9.30 -static char *strip_path_and_ext(char *fname)
    9.31 -{
    9.32 -  char *ep;
    9.33 -  char *sp;
    9.34 -
    9.35 -  if (fname) {
    9.36 -    for (sp = fname; *sp; sp++)
    9.37 -      if (*sp == '/')  fname = sp+1;
    9.38 -    ep = fname;                    // start at first character and look for '.'
    9.39 -    while (ep <= (fname + strlen(fname) - 1) && *ep != '.') ep++;
    9.40 -    if (*ep == '.')     *ep = '\0'; // truncate string at '.'
    9.41 -  }
    9.42 -  return fname;
    9.43 -}
    9.44 -
    9.45  //------------------------------base_plus_suffix-------------------------------
    9.46  // New concatenated string
    9.47  static char *base_plus_suffix(const char* base, const char *suffix)
    9.48 @@ -477,18 +467,6 @@
    9.49    return fname;
    9.50  }
    9.51  
    9.52 -
    9.53 -//------------------------------prefix_plus_base_plus_suffix-------------------
    9.54 -// New concatenated string
    9.55 -static char *prefix_plus_base_plus_suffix(const char* prefix, const char* base, const char *suffix)
    9.56 -{
    9.57 -  int len = (int)strlen(prefix) + (int)strlen(base) + (int)strlen(suffix) + 1;
    9.58 -
    9.59 -  char* fname = new char[len];
    9.60 -  sprintf(fname,"%s%s%s",prefix,base,suffix);
    9.61 -  return fname;
    9.62 -}
    9.63 -
    9.64  //------------------------------get_legal_text---------------------------------
    9.65  // Get pointer to legal text at the beginning of AD file.
    9.66  // This code assumes that a legal text starts at the beginning of .ad files,
    10.1 --- a/src/share/vm/adlc/output_c.cpp	Tue Oct 09 12:40:05 2012 -0700
    10.2 +++ b/src/share/vm/adlc/output_c.cpp	Tue Oct 09 16:09:31 2012 -0700
    10.3 @@ -518,6 +518,14 @@
    10.4  
    10.5      int cycles = piperesource->_cycles;
    10.6      uint stage          = pipeline->_stages.index(piperesource->_stage);
    10.7 +    if (NameList::Not_in_list == stage) {
    10.8 +      fprintf(stderr,
    10.9 +              "pipeline_res_mask_initializer: "
   10.10 +              "semantic error: "
   10.11 +              "pipeline stage undeclared: %s\n",
   10.12 +              piperesource->_stage);
   10.13 +      exit(1);
   10.14 +    }
   10.15      uint upper_limit    = stage+cycles-1;
   10.16      uint lower_limit    = stage-1;
   10.17      uint upper_idx      = upper_limit >> 5;
   10.18 @@ -1000,7 +1008,7 @@
   10.19    }
   10.20    fprintf(fp_cpp, "};\n\n");
   10.21    fprintf(fp_cpp, "#ifndef PRODUCT\n");
   10.22 -  fprintf(fp_cpp, "void Bundle::dump() const {\n");
   10.23 +  fprintf(fp_cpp, "void Bundle::dump(outputStream *st) const {\n");
   10.24    fprintf(fp_cpp, "  static const char * bundle_flags[] = {\n");
   10.25    fprintf(fp_cpp, "    \"\",\n");
   10.26    fprintf(fp_cpp, "    \"use nop delay\",\n");
   10.27 @@ -1019,22 +1027,22 @@
   10.28    // See if the same string is in the table
   10.29    fprintf(fp_cpp, "  bool needs_comma = false;\n\n");
   10.30    fprintf(fp_cpp, "  if (_flags) {\n");
   10.31 -  fprintf(fp_cpp, "    tty->print(\"%%s\", bundle_flags[_flags]);\n");
   10.32 +  fprintf(fp_cpp, "    st->print(\"%%s\", bundle_flags[_flags]);\n");
   10.33    fprintf(fp_cpp, "    needs_comma = true;\n");
   10.34    fprintf(fp_cpp, "  };\n");
   10.35    fprintf(fp_cpp, "  if (instr_count()) {\n");
   10.36 -  fprintf(fp_cpp, "    tty->print(\"%%s%%d instr%%s\", needs_comma ? \", \" : \"\", instr_count(), instr_count() != 1 ? \"s\" : \"\");\n");
   10.37 +  fprintf(fp_cpp, "    st->print(\"%%s%%d instr%%s\", needs_comma ? \", \" : \"\", instr_count(), instr_count() != 1 ? \"s\" : \"\");\n");
   10.38    fprintf(fp_cpp, "    needs_comma = true;\n");
   10.39    fprintf(fp_cpp, "  };\n");
   10.40    fprintf(fp_cpp, "  uint r = resources_used();\n");
   10.41    fprintf(fp_cpp, "  if (r) {\n");
   10.42 -  fprintf(fp_cpp, "    tty->print(\"%%sresource%%s:\", needs_comma ? \", \" : \"\", (r & (r-1)) != 0 ? \"s\" : \"\");\n");
   10.43 +  fprintf(fp_cpp, "    st->print(\"%%sresource%%s:\", needs_comma ? \", \" : \"\", (r & (r-1)) != 0 ? \"s\" : \"\");\n");
   10.44    fprintf(fp_cpp, "    for (uint i = 0; i < %d; i++)\n", _pipeline->_rescount);
   10.45    fprintf(fp_cpp, "      if ((r & (1 << i)) != 0)\n");
   10.46 -  fprintf(fp_cpp, "        tty->print(\" %%s\", resource_names[i]);\n");
   10.47 +  fprintf(fp_cpp, "        st->print(\" %%s\", resource_names[i]);\n");
   10.48    fprintf(fp_cpp, "    needs_comma = true;\n");
   10.49    fprintf(fp_cpp, "  };\n");
   10.50 -  fprintf(fp_cpp, "  tty->print(\"\\n\");\n");
   10.51 +  fprintf(fp_cpp, "  st->print(\"\\n\");\n");
   10.52    fprintf(fp_cpp, "}\n");
   10.53    fprintf(fp_cpp, "#endif\n");
   10.54  }
   10.55 @@ -1048,39 +1056,6 @@
   10.56            node, regMask);
   10.57  }
   10.58  
   10.59 -// Scan the peepmatch and output a test for each instruction
   10.60 -static void check_peepmatch_instruction_tree(FILE *fp, PeepMatch *pmatch, PeepConstraint *pconstraint) {
   10.61 -  int         parent        = -1;
   10.62 -  int         inst_position = 0;
   10.63 -  const char* inst_name     = NULL;
   10.64 -  int         input         = 0;
   10.65 -  fprintf(fp, "      // Check instruction sub-tree\n");
   10.66 -  pmatch->reset();
   10.67 -  for( pmatch->next_instruction( parent, inst_position, inst_name, input );
   10.68 -       inst_name != NULL;
   10.69 -       pmatch->next_instruction( parent, inst_position, inst_name, input ) ) {
   10.70 -    // If this is not a placeholder
   10.71 -    if( ! pmatch->is_placeholder() ) {
   10.72 -      // Define temporaries 'inst#', based on parent and parent's input index
   10.73 -      if( parent != -1 ) {                // root was initialized
   10.74 -        fprintf(fp, "  inst%d = inst%d->in(%d);\n",
   10.75 -                inst_position, parent, input);
   10.76 -      }
   10.77 -
   10.78 -      // When not the root
   10.79 -      // Test we have the correct instruction by comparing the rule
   10.80 -      if( parent != -1 ) {
   10.81 -        fprintf(fp, "  matches = matches &&  ( inst%d->rule() == %s_rule );",
   10.82 -                inst_position, inst_name);
   10.83 -      }
   10.84 -    } else {
   10.85 -      // Check that user did not try to constrain a placeholder
   10.86 -      assert( ! pconstraint->constrains_instruction(inst_position),
   10.87 -              "fatal(): Can not constrain a placeholder instruction");
   10.88 -    }
   10.89 -  }
   10.90 -}
   10.91 -
   10.92  static void print_block_index(FILE *fp, int inst_position) {
   10.93    assert( inst_position >= 0, "Instruction number less than zero");
   10.94    fprintf(fp, "block_index");
   10.95 @@ -1242,7 +1217,7 @@
   10.96          if( left_op_index != 0 ) {
   10.97            assert( (left_index <= 9999) && (left_op_index <= 9999), "exceed string size");
   10.98            // Must have index into operands
   10.99 -          sprintf(left_reg_index,",inst%d_idx%d", left_index, left_op_index);
  10.100 +          sprintf(left_reg_index,",inst%d_idx%d", (int)left_index, left_op_index);
  10.101          } else {
  10.102            strcpy(left_reg_index, "");
  10.103          }
  10.104 @@ -1255,7 +1230,7 @@
  10.105            if( right_op_index != 0 ) {
  10.106              assert( (right_index <= 9999) && (right_op_index <= 9999), "exceed string size");
  10.107              // Must have index into operands
  10.108 -            sprintf(right_reg_index,",inst%d_idx%d", right_index, right_op_index);
  10.109 +            sprintf(right_reg_index,",inst%d_idx%d", (int)right_index, right_op_index);
  10.110            } else {
  10.111              strcpy(right_reg_index, "");
  10.112            }
  10.113 @@ -1645,7 +1620,7 @@
  10.114            new_pos = new_inst->operand_position(parameter,Component::USE);
  10.115            exp_pos += node->num_opnds();
  10.116            // If there is no use of the created operand, just skip it
  10.117 -          if (new_pos != -1) {
  10.118 +          if (new_pos != NameList::Not_in_list) {
  10.119              //Copy the operand from the original made above
  10.120              fprintf(fp,"  n%d->set_opnd_array(%d, op%d->clone(C)); // %s\n",
  10.121                      cnt, new_pos, exp_pos-node->num_opnds(), opid);
  10.122 @@ -1789,7 +1764,8 @@
  10.123        // Build mapping from num_edges to local variables
  10.124        fprintf(fp,"  unsigned num0 = 0;\n");
  10.125        for( i = 1; i < cur_num_opnds; i++ ) {
  10.126 -        fprintf(fp,"  unsigned num%d = opnd_array(%d)->num_edges();\n",i,i);
  10.127 +        fprintf(fp,"  unsigned num%d = opnd_array(%d)->num_edges();",i,i);
  10.128 +        fprintf(fp, " \t// %s\n", node->opnd_ident(i));
  10.129        }
  10.130        // Build a mapping from operand index to input edges
  10.131        fprintf(fp,"  unsigned idx0 = oper_input_base();\n");
  10.132 @@ -1934,6 +1910,7 @@
  10.133    }
  10.134  
  10.135    // Track necessary state when identifying a replacement variable
  10.136 +  // @arg rep_var: The formal parameter of the encoding.
  10.137    void update_state(const char *rep_var) {
  10.138      // A replacement variable or one of its subfields
  10.139      // Obtain replacement variable from list
  10.140 @@ -1955,7 +1932,7 @@
  10.141          }
  10.142        }
  10.143        else {
  10.144 -        // Lookup its position in parameter list
  10.145 +        // Lookup its position in (formal) parameter list of encoding
  10.146          int   param_no  = _encoding.rep_var_index(rep_var);
  10.147          if ( param_no == -1 ) {
  10.148            _AD.syntax_err( _encoding._linenum,
  10.149 @@ -1964,6 +1941,7 @@
  10.150          }
  10.151  
  10.152          // Lookup the corresponding ins_encode parameter
  10.153 +        // This is the argument (actual parameter) to the encoding.
  10.154          const char *inst_rep_var = _ins_encode.rep_var_name(_inst, param_no);
  10.155          if (inst_rep_var == NULL) {
  10.156            _AD.syntax_err( _ins_encode._linenum,
  10.157 @@ -2329,6 +2307,7 @@
  10.158            // Add parameter for index position, if not result operand
  10.159            if( _operand_idx != 0 ) fprintf(_fp,",idx%d", _operand_idx);
  10.160            fprintf(_fp,")");
  10.161 +          fprintf(_fp, "/* %s */", _operand_name);
  10.162          }
  10.163        } else {
  10.164          assert( _reg_status == LITERAL_OUTPUT, "should have output register literal in emit_rep_var");
  10.165 @@ -2368,7 +2347,7 @@
  10.166          }
  10.167        } else {
  10.168          assert( _constant_status == LITERAL_OUTPUT, "should have output constant literal in emit_rep_var");
  10.169 -        // Cosntant literal has already been sent to output file, nothing more needed
  10.170 +        // Constant literal has already been sent to output file, nothing more needed
  10.171        }
  10.172      }
  10.173      else if ( strcmp(rep_var,"$disp") == 0 ) {
  10.174 @@ -2387,6 +2366,8 @@
  10.175      }
  10.176      else {
  10.177        printf("emit_field: %s\n",rep_var);
  10.178 +      globalAD->syntax_err(_inst._linenum, "Unknown replacement variable %s in format statement of %s.",
  10.179 +                           rep_var, _inst._ident);
  10.180        assert( false, "UnImplemented()");
  10.181      }
  10.182    }
  10.183 @@ -2484,14 +2465,14 @@
  10.184  
  10.185    //(1)
  10.186    // Output instruction's emit prototype
  10.187 -  fprintf(fp,"uint  %sNode::size(PhaseRegAlloc *ra_) const {\n",
  10.188 +  fprintf(fp,"uint %sNode::size(PhaseRegAlloc *ra_) const {\n",
  10.189            inst._ident);
  10.190  
  10.191 -  fprintf(fp, " assert(VerifyOops || MachNode::size(ra_) <= %s, \"bad fixed size\");\n", inst._size);
  10.192 +  fprintf(fp, "  assert(VerifyOops || MachNode::size(ra_) <= %s, \"bad fixed size\");\n", inst._size);
  10.193  
  10.194    //(2)
  10.195    // Print the size
  10.196 -  fprintf(fp, " return (VerifyOops ? MachNode::size(ra_) : %s);\n", inst._size);
  10.197 +  fprintf(fp, "  return (VerifyOops ? MachNode::size(ra_) : %s);\n", inst._size);
  10.198  
  10.199    // (3) and (4)
  10.200    fprintf(fp,"}\n");
  10.201 @@ -2579,7 +2560,7 @@
  10.202    }
  10.203  
  10.204    // (3) and (4)
  10.205 -  fprintf(fp, "}\n");
  10.206 +  fprintf(fp, "}\n\n");
  10.207  }
  10.208  
  10.209  // defineEvalConstant ---------------------------------------------------------
  10.210 @@ -2727,12 +2708,12 @@
  10.211  // (2)  }
  10.212  //
  10.213  static void defineClone(FILE *fp, FormDict &globalNames, OperandForm &oper) {
  10.214 -  fprintf(fp,"MachOper  *%sOper::clone(Compile* C) const {\n", oper._ident);
  10.215 +  fprintf(fp,"MachOper *%sOper::clone(Compile* C) const {\n", oper._ident);
  10.216    // Check for constants that need to be copied over
  10.217    const int  num_consts    = oper.num_consts(globalNames);
  10.218    const bool is_ideal_bool = oper.is_ideal_bool();
  10.219    if( (num_consts > 0) ) {
  10.220 -    fprintf(fp,"  return  new (C) %sOper(", oper._ident);
  10.221 +    fprintf(fp,"  return new (C) %sOper(", oper._ident);
  10.222      // generate parameters for constants
  10.223      int i = 0;
  10.224      fprintf(fp,"_c%d", i);
  10.225 @@ -2744,21 +2725,12 @@
  10.226    }
  10.227    else {
  10.228      assert( num_consts == 0, "Currently support zero or one constant per operand clone function");
  10.229 -    fprintf(fp,"  return  new (C) %sOper();\n", oper._ident);
  10.230 +    fprintf(fp,"  return new (C) %sOper();\n", oper._ident);
  10.231    }
  10.232    // finish method
  10.233    fprintf(fp,"}\n");
  10.234  }
  10.235  
  10.236 -static void define_hash(FILE *fp, char *operand) {
  10.237 -  fprintf(fp,"uint %sOper::hash() const { return 5; }\n", operand);
  10.238 -}
  10.239 -
  10.240 -static void define_cmp(FILE *fp, char *operand) {
  10.241 -  fprintf(fp,"uint %sOper::cmp( const MachOper &oper ) const { return opcode() == oper.opcode(); }\n", operand);
  10.242 -}
  10.243 -
  10.244 -
  10.245  // Helper functions for bug 4796752, abstracted with minimal modification
  10.246  // from define_oper_interface()
  10.247  OperandForm *rep_var_to_operand(const char *encoding, OperandForm &oper, FormDict &globals) {
  10.248 @@ -2852,14 +2824,14 @@
  10.249    } else if ( (strcmp(name,"disp") == 0) ) {
  10.250      fprintf(fp,"(PhaseRegAlloc *ra_, const Node *node, int idx) const { \n");
  10.251    } else {
  10.252 -    fprintf(fp,"() const { ");
  10.253 +    fprintf(fp,"() const { \n");
  10.254    }
  10.255  
  10.256    // Check for hexadecimal value OR replacement variable
  10.257    if( *encoding == '$' ) {
  10.258      // Replacement variable
  10.259      const char *rep_var = encoding + 1;
  10.260 -    fprintf(fp,"// Replacement variable: %s\n", encoding+1);
  10.261 +    fprintf(fp,"    // Replacement variable: %s\n", encoding+1);
  10.262      // Lookup replacement variable, rep_var, in operand's component list
  10.263      const Component *comp = oper._components.search(rep_var);
  10.264      assert( comp != NULL, "Replacement variable not found in components");
  10.265 @@ -2880,10 +2852,10 @@
  10.266      } else if ( op->ideal_to_sReg_type(op->_ident) != Form::none ) {
  10.267        // StackSlot for an sReg comes either from input node or from self, when idx==0
  10.268        fprintf(fp,"    if( idx != 0 ) {\n");
  10.269 -      fprintf(fp,"      // Access register number for input operand\n");
  10.270 +      fprintf(fp,"      // Access stack offset (register number) for input operand\n");
  10.271        fprintf(fp,"      return ra_->reg2offset(ra_->get_reg_first(node->in(idx)));/* sReg */\n");
  10.272        fprintf(fp,"    }\n");
  10.273 -      fprintf(fp,"    // Access register number from myself\n");
  10.274 +      fprintf(fp,"    // Access stack offset (register number) from myself\n");
  10.275        fprintf(fp,"    return ra_->reg2offset(ra_->get_reg_first(node));/* sReg */\n");
  10.276      } else if (op->_matrule && op->_matrule->is_base_constant(globals)) {
  10.277        // Constant
  10.278 @@ -2900,7 +2872,7 @@
  10.279    }
  10.280    else if( *encoding == '0' && *(encoding+1) == 'x' ) {
  10.281      // Hex value
  10.282 -    fprintf(fp,"return %s;", encoding);
  10.283 +    fprintf(fp,"    return %s;\n", encoding);
  10.284    } else {
  10.285      assert( false, "Do not support octal or decimal encode constants");
  10.286    }
  10.287 @@ -3133,8 +3105,8 @@
  10.288      // Output the definition for number of relocation entries
  10.289      uint reloc_size = instr->reloc(_globalNames);
  10.290      if ( reloc_size != 0 ) {
  10.291 -      fprintf(fp,"int  %sNode::reloc()   const {\n", instr->_ident);
  10.292 -      fprintf(fp,  "  return  %d;\n", reloc_size );
  10.293 +      fprintf(fp,"int %sNode::reloc() const {\n", instr->_ident);
  10.294 +      fprintf(fp,"  return %d;\n", reloc_size);
  10.295        fprintf(fp,"}\n");
  10.296        fprintf(fp,"\n");
  10.297      }
  10.298 @@ -3241,7 +3213,7 @@
  10.299  class OutputReduceOp : public OutputMap {
  10.300  public:
  10.301    OutputReduceOp(FILE *hpp, FILE *cpp, FormDict &globals, ArchDesc &AD)
  10.302 -    : OutputMap(hpp, cpp, globals, AD) {};
  10.303 +    : OutputMap(hpp, cpp, globals, AD, "reduceOp") {};
  10.304  
  10.305    void declaration() { fprintf(_hpp, "extern const int   reduceOp[];\n"); }
  10.306    void definition()  { fprintf(_cpp, "const        int   reduceOp[] = {\n"); }
  10.307 @@ -3276,7 +3248,7 @@
  10.308  class OutputLeftOp : public OutputMap {
  10.309  public:
  10.310    OutputLeftOp(FILE *hpp, FILE *cpp, FormDict &globals, ArchDesc &AD)
  10.311 -    : OutputMap(hpp, cpp, globals, AD) {};
  10.312 +    : OutputMap(hpp, cpp, globals, AD, "leftOp") {};
  10.313  
  10.314    void declaration() { fprintf(_hpp, "extern const int   leftOp[];\n"); }
  10.315    void definition()  { fprintf(_cpp, "const        int   leftOp[] = {\n"); }
  10.316 @@ -3306,7 +3278,7 @@
  10.317  class OutputRightOp : public OutputMap {
  10.318  public:
  10.319    OutputRightOp(FILE *hpp, FILE *cpp, FormDict &globals, ArchDesc &AD)
  10.320 -    : OutputMap(hpp, cpp, globals, AD) {};
  10.321 +    : OutputMap(hpp, cpp, globals, AD, "rightOp") {};
  10.322  
  10.323    void declaration() { fprintf(_hpp, "extern const int   rightOp[];\n"); }
  10.324    void definition()  { fprintf(_cpp, "const        int   rightOp[] = {\n"); }
  10.325 @@ -3336,11 +3308,11 @@
  10.326  class OutputRuleName : public OutputMap {
  10.327  public:
  10.328    OutputRuleName(FILE *hpp, FILE *cpp, FormDict &globals, ArchDesc &AD)
  10.329 -    : OutputMap(hpp, cpp, globals, AD) {};
  10.330 +    : OutputMap(hpp, cpp, globals, AD, "ruleName") {};
  10.331  
  10.332    void declaration() { fprintf(_hpp, "extern const char *ruleName[];\n"); }
  10.333    void definition()  { fprintf(_cpp, "const char        *ruleName[] = {\n"); }
  10.334 -  void closing()     { fprintf(_cpp, "  \"no trailing comma\"\n");
  10.335 +  void closing()     { fprintf(_cpp, "  \"invalid rule name\" // no trailing comma\n");
  10.336                         OutputMap::closing();
  10.337    }
  10.338    void map(OpClassForm &opc)  { fprintf(_cpp, "  \"%s\"", _AD.machOperEnum(opc._ident) ); }
  10.339 @@ -3354,7 +3326,7 @@
  10.340  class OutputSwallowed : public OutputMap {
  10.341  public:
  10.342    OutputSwallowed(FILE *hpp, FILE *cpp, FormDict &globals, ArchDesc &AD)
  10.343 -    : OutputMap(hpp, cpp, globals, AD) {};
  10.344 +    : OutputMap(hpp, cpp, globals, AD, "swallowed") {};
  10.345  
  10.346    void declaration() { fprintf(_hpp, "extern const bool  swallowed[];\n"); }
  10.347    void definition()  { fprintf(_cpp, "const        bool  swallowed[] = {\n"); }
  10.348 @@ -3375,7 +3347,7 @@
  10.349  class OutputInstChainRule : public OutputMap {
  10.350  public:
  10.351    OutputInstChainRule(FILE *hpp, FILE *cpp, FormDict &globals, ArchDesc &AD)
  10.352 -    : OutputMap(hpp, cpp, globals, AD) {};
  10.353 +    : OutputMap(hpp, cpp, globals, AD, "instruction_chain_rule") {};
  10.354  
  10.355    void declaration() { fprintf(_hpp, "extern const bool  instruction_chain_rule[];\n"); }
  10.356    void definition()  { fprintf(_cpp, "const        bool  instruction_chain_rule[] = {\n"); }
  10.357 @@ -3416,7 +3388,7 @@
  10.358      if ( op->ideal_only() )  continue;
  10.359  
  10.360      // Generate the entry for this opcode
  10.361 -    map.map(*op);    fprintf(fp_cpp, ", // %d\n", idx);
  10.362 +    fprintf(fp_cpp, "  /* %4d */", idx); map.map(*op); fprintf(fp_cpp, ",\n");
  10.363      ++idx;
  10.364    };
  10.365    fprintf(fp_cpp, "  // last operand\n");
  10.366 @@ -3425,7 +3397,7 @@
  10.367    map.record_position(OutputMap::BEGIN_OPCLASSES, idx );
  10.368    _opclass.reset();
  10.369    for(; (opc = (OpClassForm*)_opclass.iter()) != NULL; ) {
  10.370 -    map.map(*opc);    fprintf(fp_cpp, ", // %d\n", idx);
  10.371 +    fprintf(fp_cpp, "  /* %4d */", idx); map.map(*opc); fprintf(fp_cpp, ",\n");
  10.372      ++idx;
  10.373    };
  10.374    fprintf(fp_cpp, "  // last operand class\n");
  10.375 @@ -3435,7 +3407,7 @@
  10.376    _internalOpNames.reset();
  10.377    char *name = NULL;
  10.378    for(; (name = (char *)_internalOpNames.iter()) != NULL; ) {
  10.379 -    map.map(name);    fprintf(fp_cpp, ", // %d\n", idx);
  10.380 +    fprintf(fp_cpp, "  /* %4d */", idx); map.map(name); fprintf(fp_cpp, ",\n");
  10.381      ++idx;
  10.382    };
  10.383    fprintf(fp_cpp, "  // last internally defined operand\n");
  10.384 @@ -3453,7 +3425,7 @@
  10.385          if ( ! inst->is_simple_chain_rule(_globalNames) ) continue;
  10.386          if ( inst->rematerialize(_globalNames, get_registers()) ) continue;
  10.387  
  10.388 -        map.map(*inst);      fprintf(fp_cpp, ", // %d\n", idx);
  10.389 +        fprintf(fp_cpp, "  /* %4d */", idx); map.map(*inst); fprintf(fp_cpp, ",\n");
  10.390          ++idx;
  10.391        };
  10.392        map.record_position(OutputMap::BEGIN_REMATERIALIZE, idx );
  10.393 @@ -3464,7 +3436,7 @@
  10.394          if ( ! inst->is_simple_chain_rule(_globalNames) ) continue;
  10.395          if ( ! inst->rematerialize(_globalNames, get_registers()) ) continue;
  10.396  
  10.397 -        map.map(*inst);      fprintf(fp_cpp, ", // %d\n", idx);
  10.398 +        fprintf(fp_cpp, "  /* %4d */", idx); map.map(*inst); fprintf(fp_cpp, ",\n");
  10.399          ++idx;
  10.400        };
  10.401        map.record_position(OutputMap::END_INST_CHAIN_RULES, idx );
  10.402 @@ -3478,7 +3450,7 @@
  10.403          if ( inst->is_simple_chain_rule(_globalNames) ) continue;
  10.404          if ( ! inst->rematerialize(_globalNames, get_registers()) ) continue;
  10.405  
  10.406 -        map.map(*inst);      fprintf(fp_cpp, ", // %d\n", idx);
  10.407 +        fprintf(fp_cpp, "  /* %4d */", idx); map.map(*inst); fprintf(fp_cpp, ",\n");
  10.408          ++idx;
  10.409        };
  10.410        map.record_position(OutputMap::END_REMATERIALIZE, idx );
  10.411 @@ -3489,7 +3461,7 @@
  10.412          if ( inst->is_simple_chain_rule(_globalNames) ) continue;
  10.413          if ( inst->rematerialize(_globalNames, get_registers()) ) continue;
  10.414  
  10.415 -        map.map(*inst);      fprintf(fp_cpp, ", // %d\n", idx);
  10.416 +        fprintf(fp_cpp, "  /* %4d */", idx); map.map(*inst); fprintf(fp_cpp, ",\n");
  10.417          ++idx;
  10.418        };
  10.419      }
  10.420 @@ -3571,7 +3543,7 @@
  10.421      next              = _register->iter_RegDefs();
  10.422      char policy       = reg_save_policy(rdef->_callconv);
  10.423      const char *comma = (next != NULL) ? "," : " // no trailing comma";
  10.424 -    fprintf(fp_cpp, "  '%c'%s\n", policy, comma);
  10.425 +    fprintf(fp_cpp, "  '%c'%s // %s\n", policy, comma, rdef->_regname);
  10.426    }
  10.427    fprintf(fp_cpp, "};\n\n");
  10.428  
  10.429 @@ -3583,7 +3555,7 @@
  10.430      next        = _register->iter_RegDefs();
  10.431      char policy = reg_save_policy(rdef->_c_conv);
  10.432      const char *comma = (next != NULL) ? "," : " // no trailing comma";
  10.433 -    fprintf(fp_cpp, "  '%c'%s\n", policy, comma);
  10.434 +    fprintf(fp_cpp, "  '%c'%s // %s\n", policy, comma, rdef->_regname);
  10.435    }
  10.436    fprintf(fp_cpp, "};\n\n");
  10.437  
  10.438 @@ -3794,7 +3766,7 @@
  10.439        // For each operand not in the match rule, call MachOperGenerator
  10.440        // with the enum for the opcode that needs to be built.
  10.441        ComponentList clist = inst->_components;
  10.442 -      int         index  = clist.operand_position(comp->_name, comp->_usedef);
  10.443 +      int         index  = clist.operand_position(comp->_name, comp->_usedef, inst);
  10.444        const char *opcode = machOperEnum(comp->_type);
  10.445        fprintf(fp_cpp, "%s node->set_opnd_array(%d, ", indent, index);
  10.446        fprintf(fp_cpp, "MachOperGenerator(%s, C));\n", opcode);
  10.447 @@ -3989,7 +3961,7 @@
  10.448      fprintf(fp_cpp, "  case %s_rule:", opClass);
  10.449  
  10.450      // Start local scope
  10.451 -    fprintf(fp_cpp, "  {\n");
  10.452 +    fprintf(fp_cpp, " {\n");
  10.453      // Generate code to construct the new MachNode
  10.454      buildMachNode(fp_cpp, inst, "     ");
  10.455      // Return result and exit scope
  10.456 @@ -4139,6 +4111,9 @@
  10.457  // Get info for the CISC_oracle and MachNode::cisc_version()
  10.458  void ArchDesc::identify_cisc_spill_instructions() {
  10.459  
  10.460 +  if (_frame == NULL)
  10.461 +    return;
  10.462 +
  10.463    // Find the user-defined operand for cisc-spilling
  10.464    if( _frame->_cisc_spilling_operand_name != NULL ) {
  10.465      const Form *form = _globalNames[_frame->_cisc_spilling_operand_name];
    11.1 --- a/src/share/vm/adlc/output_h.cpp	Tue Oct 09 12:40:05 2012 -0700
    11.2 +++ b/src/share/vm/adlc/output_h.cpp	Tue Oct 09 16:09:31 2012 -0700
    11.3 @@ -25,6 +25,8 @@
    11.4  // output_h.cpp - Class HPP file output routines for architecture definition
    11.5  #include "adlc.hpp"
    11.6  
    11.7 +// The comment delimiter used in format statements after assembler instructions.
    11.8 +#define commentSeperator "!"
    11.9  
   11.10  // Generate the #define that describes the number of registers.
   11.11  static void defineRegCount(FILE *fp, RegisterForm *registers) {
   11.12 @@ -79,10 +81,15 @@
   11.13      _register->reset_RegDefs();
   11.14      int i = 0;
   11.15      while( (reg_def = _register->iter_RegDefs()) != NULL ) {
   11.16 -      fprintf(fp_hpp,"  %s_num,\t\t// %d\n", reg_def->_regname, i++);
   11.17 +      fprintf(fp_hpp,"  %s_num,", reg_def->_regname);
   11.18 +      for (int j = 0; j < 20-(int)strlen(reg_def->_regname); j++) fprintf(fp_hpp, " ");
   11.19 +      fprintf(fp_hpp," // enum %3d, regnum %3d, reg encode %3s\n",
   11.20 +              i++,
   11.21 +              reg_def->register_num(),
   11.22 +              reg_def->register_encode());
   11.23      }
   11.24      // Finish defining enumeration
   11.25 -    fprintf(fp_hpp, "  _last_Mach_Reg\t// %d\n", i);
   11.26 +    fprintf(fp_hpp, "  _last_Mach_Reg            // %d\n", i);
   11.27      fprintf(fp_hpp, "};\n");
   11.28    }
   11.29  
   11.30 @@ -121,13 +128,24 @@
   11.31      fprintf(fp_hpp, "// in the order of occurrence in the alloc_class(es).\n");
   11.32      fprintf(fp_hpp, "enum MachRegisterEncodes {\n");
   11.33  
   11.34 +    // Find max enum string length.
   11.35 +    size_t maxlen = 0;
   11.36 +    _register->reset_RegDefs();
   11.37 +    reg_def = _register->iter_RegDefs();
   11.38 +    while (reg_def != NULL) {
   11.39 +      size_t len = strlen(reg_def->_regname);
   11.40 +      if (len > maxlen) maxlen = len;
   11.41 +      reg_def = _register->iter_RegDefs();
   11.42 +    }
   11.43 +
   11.44      // Output the register encoding for each register in the allocation classes
   11.45      _register->reset_RegDefs();
   11.46      reg_def_next = _register->iter_RegDefs();
   11.47      while( (reg_def = reg_def_next) != NULL ) {
   11.48        reg_def_next = _register->iter_RegDefs();
   11.49 -      fprintf(fp_hpp,"  %s_enc = %s%s\n",
   11.50 -              reg_def->_regname, reg_def->register_encode(), reg_def_next == NULL? "" : "," );
   11.51 +      fprintf(fp_hpp,"  %s_enc", reg_def->_regname);
   11.52 +      for (size_t i = strlen(reg_def->_regname); i < maxlen; i++) fprintf(fp_hpp, " ");
   11.53 +      fprintf(fp_hpp," = %3s%s\n", reg_def->register_encode(), reg_def_next == NULL? "" : "," );
   11.54      }
   11.55      // Finish defining enumeration
   11.56      fprintf(fp_hpp, "};\n");
   11.57 @@ -177,14 +195,6 @@
   11.58    fprintf(fp,"  virtual const RegMask *in_RegMask(int index) const;\n");
   11.59  }
   11.60  
   11.61 -static void declare_hash(FILE *fp) {
   11.62 -  fprintf(fp,"  virtual uint           hash() const;\n");
   11.63 -}
   11.64 -
   11.65 -static void declare_cmp(FILE *fp) {
   11.66 -  fprintf(fp,"  virtual uint           cmp( const MachOper &oper ) const;\n");
   11.67 -}
   11.68 -
   11.69  static void declareConstStorage(FILE *fp, FormDict &globals, OperandForm *oper) {
   11.70    int i = 0;
   11.71    Component *comp;
   11.72 @@ -372,18 +382,19 @@
   11.73  static void defineCCodeDump(OperandForm* oper, FILE *fp, int i) {
   11.74    assert(oper != NULL, "what");
   11.75    CondInterface* cond = oper->_interface->is_CondInterface();
   11.76 -  fprintf(fp, "         if( _c%d == BoolTest::eq ) st->print(\"%s\");\n",i,cond->_equal_format);
   11.77 -  fprintf(fp, "    else if( _c%d == BoolTest::ne ) st->print(\"%s\");\n",i,cond->_not_equal_format);
   11.78 -  fprintf(fp, "    else if( _c%d == BoolTest::le ) st->print(\"%s\");\n",i,cond->_less_equal_format);
   11.79 -  fprintf(fp, "    else if( _c%d == BoolTest::ge ) st->print(\"%s\");\n",i,cond->_greater_equal_format);
   11.80 -  fprintf(fp, "    else if( _c%d == BoolTest::lt ) st->print(\"%s\");\n",i,cond->_less_format);
   11.81 -  fprintf(fp, "    else if( _c%d == BoolTest::gt ) st->print(\"%s\");\n",i,cond->_greater_format);
   11.82 +  fprintf(fp, "       if( _c%d == BoolTest::eq ) st->print(\"%s\");\n",i,cond->_equal_format);
   11.83 +  fprintf(fp, "  else if( _c%d == BoolTest::ne ) st->print(\"%s\");\n",i,cond->_not_equal_format);
   11.84 +  fprintf(fp, "  else if( _c%d == BoolTest::le ) st->print(\"%s\");\n",i,cond->_less_equal_format);
   11.85 +  fprintf(fp, "  else if( _c%d == BoolTest::ge ) st->print(\"%s\");\n",i,cond->_greater_equal_format);
   11.86 +  fprintf(fp, "  else if( _c%d == BoolTest::lt ) st->print(\"%s\");\n",i,cond->_less_format);
   11.87 +  fprintf(fp, "  else if( _c%d == BoolTest::gt ) st->print(\"%s\");\n",i,cond->_greater_format);
   11.88  }
   11.89  
   11.90  // Output code that dumps constant values, increment "i" if type is constant
   11.91  static uint dump_spec_constant(FILE *fp, const char *ideal_type, uint i, OperandForm* oper) {
   11.92    if (!strcmp(ideal_type, "ConI")) {
   11.93      fprintf(fp,"   st->print(\"#%%d\", _c%d);\n", i);
   11.94 +    fprintf(fp,"   st->print(\"/0x%%08x\", _c%d);\n", i);
   11.95      ++i;
   11.96    }
   11.97    else if (!strcmp(ideal_type, "ConP")) {
   11.98 @@ -400,14 +411,19 @@
   11.99    }
  11.100    else if (!strcmp(ideal_type, "ConL")) {
  11.101      fprintf(fp,"    st->print(\"#\" INT64_FORMAT, _c%d);\n", i);
  11.102 +    fprintf(fp,"    st->print(\"/\" PTR64_FORMAT, _c%d);\n", i);
  11.103      ++i;
  11.104    }
  11.105    else if (!strcmp(ideal_type, "ConF")) {
  11.106      fprintf(fp,"    st->print(\"#%%f\", _c%d);\n", i);
  11.107 +    fprintf(fp,"    jint _c%di = JavaValue(_c%d).get_jint();\n", i, i);
  11.108 +    fprintf(fp,"    st->print(\"/0x%%x/\", _c%di);\n", i);
  11.109      ++i;
  11.110    }
  11.111    else if (!strcmp(ideal_type, "ConD")) {
  11.112      fprintf(fp,"    st->print(\"#%%f\", _c%d);\n", i);
  11.113 +    fprintf(fp,"    jlong _c%dl = JavaValue(_c%d).get_jlong();\n", i, i);
  11.114 +    fprintf(fp,"    st->print(\"/\" PTR64_FORMAT, _c%dl);\n", i);
  11.115      ++i;
  11.116    }
  11.117    else if (!strcmp(ideal_type, "Bool")) {
  11.118 @@ -429,7 +445,7 @@
  11.119    }
  11.120  
  11.121    // Local pointer indicates remaining part of format rule
  11.122 -  uint  idx = 0;                   // position of operand in match rule
  11.123 +  int idx = 0;                   // position of operand in match rule
  11.124  
  11.125    // Generate internal format function, used when stored locally
  11.126    fprintf(fp, "\n#ifndef PRODUCT\n");
  11.127 @@ -444,13 +460,12 @@
  11.128        oper._format->_rep_vars.reset();
  11.129        oper._format->_strings.reset();
  11.130        while ( (string = oper._format->_strings.iter()) != NULL ) {
  11.131 -        fprintf(fp,"  ");
  11.132  
  11.133          // Check if this is a standard string or a replacement variable
  11.134          if ( string != NameList::_signal ) {
  11.135            // Normal string
  11.136            // Pass through to st->print
  11.137 -          fprintf(fp,"st->print(\"%s\");\n", string);
  11.138 +          fprintf(fp,"  st->print(\"%s\");\n", string);
  11.139          } else {
  11.140            // Replacement variable
  11.141            const char *rep_var = oper._format->_rep_vars.iter();
  11.142 @@ -473,7 +488,7 @@
  11.143            }
  11.144  
  11.145            // output invocation of "$..."s format function
  11.146 -          if ( op != NULL )   op->int_format(fp, globals, idx);
  11.147 +          if ( op != NULL ) op->int_format(fp, globals, idx);
  11.148  
  11.149            if ( idx == -1 ) {
  11.150              fprintf(stderr,
  11.151 @@ -516,13 +531,12 @@
  11.152        oper._format->_rep_vars.reset();
  11.153        oper._format->_strings.reset();
  11.154        while ( (string = oper._format->_strings.iter()) != NULL ) {
  11.155 -        fprintf(fp,"  ");
  11.156  
  11.157          // Check if this is a standard string or a replacement variable
  11.158          if ( string != NameList::_signal ) {
  11.159            // Normal string
  11.160            // Pass through to st->print
  11.161 -          fprintf(fp,"st->print(\"%s\");\n", string);
  11.162 +          fprintf(fp,"  st->print(\"%s\");\n", string);
  11.163          } else {
  11.164            // Replacement variable
  11.165            const char *rep_var = oper._format->_rep_vars.iter();
  11.166 @@ -547,7 +561,7 @@
  11.167            if ( op != NULL )   op->ext_format(fp, globals, idx);
  11.168  
  11.169            // Lookup the index position of the replacement variable
  11.170 -          idx      = oper._components.operand_position_format(rep_var);
  11.171 +          idx      = oper._components.operand_position_format(rep_var, &oper);
  11.172            if ( idx == -1 ) {
  11.173              fprintf(stderr,
  11.174                      "Using a name, %s, that isn't in match rule\n", rep_var);
  11.175 @@ -601,7 +615,7 @@
  11.176      inst._format->_rep_vars.reset();
  11.177      inst._format->_strings.reset();
  11.178      while( (string = inst._format->_strings.iter()) != NULL ) {
  11.179 -      fprintf(fp,"    ");
  11.180 +      fprintf(fp,"  ");
  11.181        // Check if this is a standard string or a replacement variable
  11.182        if( string == NameList::_signal ) { // Replacement variable
  11.183          const char* rep_var =  inst._format->_rep_vars.iter();
  11.184 @@ -658,11 +672,12 @@
  11.185    if( call_type != Form::invalid_type ) {
  11.186      switch( call_type ) {
  11.187      case Form::JAVA_DYNAMIC:
  11.188 -      fprintf(fp,"    _method->print_short_name();\n");
  11.189 +      fprintf(fp,"  _method->print_short_name(st);\n");
  11.190        break;
  11.191      case Form::JAVA_STATIC:
  11.192 -      fprintf(fp,"    if( _method ) _method->print_short_name(st); else st->print(\" wrapper for: %%s\", _name);\n");
  11.193 -      fprintf(fp,"    if( !_method ) dump_trap_args(st);\n");
  11.194 +      fprintf(fp,"  if( _method ) _method->print_short_name(st);\n");
  11.195 +      fprintf(fp,"  else st->print(\" wrapper for: %%s\", _name);\n");
  11.196 +      fprintf(fp,"  if( !_method ) dump_trap_args(st);\n");
  11.197        break;
  11.198      case Form::JAVA_COMPILED:
  11.199      case Form::JAVA_INTERP:
  11.200 @@ -670,52 +685,46 @@
  11.201      case Form::JAVA_RUNTIME:
  11.202      case Form::JAVA_LEAF:
  11.203      case Form::JAVA_NATIVE:
  11.204 -      fprintf(fp,"    st->print(\" %%s\", _name);");
  11.205 +      fprintf(fp,"  st->print(\" %%s\", _name);");
  11.206        break;
  11.207      default:
  11.208 -      assert(0,"ShouldNotReacHere");
  11.209 +      assert(0,"ShouldNotReachHere");
  11.210      }
  11.211 -    fprintf(fp,  "    st->print_cr(\"\");\n" );
  11.212 -    fprintf(fp,  "    if (_jvms) _jvms->format(ra, this, st); else st->print_cr(\"        No JVM State Info\");\n" );
  11.213 -    fprintf(fp,  "    st->print(\"        # \");\n" );
  11.214 -    fprintf(fp,  "    if( _jvms ) _oop_map->print_on(st);\n");
  11.215 +    fprintf(fp,  "  st->print_cr(\"\");\n" );
  11.216 +    fprintf(fp,  "  if (_jvms) _jvms->format(ra, this, st); else st->print_cr(\"        No JVM State Info\");\n" );
  11.217 +    fprintf(fp,  "  st->print(\"        # \");\n" );
  11.218 +    fprintf(fp,  "  if( _jvms && _oop_map ) _oop_map->print_on(st);\n");
  11.219    }
  11.220    else if(inst.is_ideal_safepoint()) {
  11.221 -    fprintf(fp,  "    st->print(\"\");\n" );
  11.222 -    fprintf(fp,  "    if (_jvms) _jvms->format(ra, this, st); else st->print_cr(\"        No JVM State Info\");\n" );
  11.223 -    fprintf(fp,  "    st->print(\"        # \");\n" );
  11.224 -    fprintf(fp,  "    if( _jvms ) _oop_map->print_on(st);\n");
  11.225 +    fprintf(fp,  "  st->print(\"\");\n" );
  11.226 +    fprintf(fp,  "  if (_jvms) _jvms->format(ra, this, st); else st->print_cr(\"        No JVM State Info\");\n" );
  11.227 +    fprintf(fp,  "  st->print(\"        # \");\n" );
  11.228 +    fprintf(fp,  "  if( _jvms && _oop_map ) _oop_map->print_on(st);\n");
  11.229    }
  11.230    else if( inst.is_ideal_if() ) {
  11.231 -    fprintf(fp,  "    st->print(\"  P=%%f C=%%f\",_prob,_fcnt);\n" );
  11.232 +    fprintf(fp,  "  st->print(\"  P=%%f C=%%f\",_prob,_fcnt);\n" );
  11.233    }
  11.234    else if( inst.is_ideal_mem() ) {
  11.235      // Print out the field name if available to improve readability
  11.236 -    fprintf(fp,  "    if (ra->C->alias_type(adr_type())->field() != NULL) {\n");
  11.237 -    fprintf(fp,  "      ciField* f = ra->C->alias_type(adr_type())->field();\n");
  11.238 -    fprintf(fp,  "      st->print(\" ! Field: \");\n");
  11.239 -    fprintf(fp,  "      if (f->is_volatile())\n");
  11.240 -    fprintf(fp,  "        st->print(\"volatile \");\n");
  11.241 -    fprintf(fp,  "      f->holder()->name()->print_symbol_on(st);\n");
  11.242 -    fprintf(fp,  "      st->print(\".\");\n");
  11.243 -    fprintf(fp,  "      f->name()->print_symbol_on(st);\n");
  11.244 -    fprintf(fp,  "      if (f->is_constant())\n");
  11.245 -    fprintf(fp,  "        st->print(\" (constant)\");\n");
  11.246 -    fprintf(fp,  "    } else\n");
  11.247 +    fprintf(fp,  "  if (ra->C->alias_type(adr_type())->field() != NULL) {\n");
  11.248 +    fprintf(fp,  "    ciField* f = ra->C->alias_type(adr_type())->field();\n");
  11.249 +    fprintf(fp,  "    st->print(\" %s Field: \");\n", commentSeperator);
  11.250 +    fprintf(fp,  "    if (f->is_volatile())\n");
  11.251 +    fprintf(fp,  "      st->print(\"volatile \");\n");
  11.252 +    fprintf(fp,  "    f->holder()->name()->print_symbol_on(st);\n");
  11.253 +    fprintf(fp,  "    st->print(\".\");\n");
  11.254 +    fprintf(fp,  "    f->name()->print_symbol_on(st);\n");
  11.255 +    fprintf(fp,  "    if (f->is_constant())\n");
  11.256 +    fprintf(fp,  "      st->print(\" (constant)\");\n");
  11.257 +    fprintf(fp,  "  } else {\n");
  11.258      // Make sure 'Volatile' gets printed out
  11.259      fprintf(fp,  "    if (ra->C->alias_type(adr_type())->is_volatile())\n");
  11.260      fprintf(fp,  "      st->print(\" volatile!\");\n");
  11.261 +    fprintf(fp,  "  }\n");
  11.262    }
  11.263  
  11.264    // Complete the definition of the format function
  11.265 -  fprintf(fp, "  }\n#endif\n");
  11.266 -}
  11.267 -
  11.268 -static bool is_non_constant(char* x) {
  11.269 -  // Tells whether the string (part of an operator interface) is non-constant.
  11.270 -  // Simply detect whether there is an occurrence of a formal parameter,
  11.271 -  // which will always begin with '$'.
  11.272 -  return strchr(x, '$') == 0;
  11.273 +  fprintf(fp, "}\n#endif\n");
  11.274  }
  11.275  
  11.276  void ArchDesc::declare_pipe_classes(FILE *fp_hpp) {
  11.277 @@ -1107,7 +1116,7 @@
  11.278    fprintf(fp_hpp, "  static void initialize_nops(MachNode *nop_list[%d], Compile* C);\n\n",
  11.279      _pipeline->_nopcnt);
  11.280    fprintf(fp_hpp, "#ifndef PRODUCT\n");
  11.281 -  fprintf(fp_hpp, "  void dump() const;\n");
  11.282 +  fprintf(fp_hpp, "  void dump(outputStream *st = tty) const;\n");
  11.283    fprintf(fp_hpp, "#endif\n");
  11.284    fprintf(fp_hpp, "};\n\n");
  11.285  
  11.286 @@ -1252,7 +1261,7 @@
  11.287        unsigned int position = 0;
  11.288        const char  *opret, *opname, *optype;
  11.289        oper->_matrule->base_operand(position,_globalNames,opret,opname,optype);
  11.290 -      fprintf(fp,"  virtual const Type *type() const {");
  11.291 +      fprintf(fp,"  virtual const Type    *type() const {");
  11.292        const char *type = getIdealType(optype);
  11.293        if( type != NULL ) {
  11.294          Form::DataType data_type = oper->is_base_constant(_globalNames);
  11.295 @@ -1531,12 +1540,19 @@
  11.296        fprintf(fp, "  GrowableArray<Label*> _index2label;\n");
  11.297      }
  11.298      fprintf(fp,"public:\n");
  11.299 -    fprintf(fp,"  MachOper *opnd_array(uint operand_index) const { assert(operand_index < _num_opnds, \"invalid _opnd_array index\"); return _opnd_array[operand_index]; }\n");
  11.300 -    fprintf(fp,"  void      set_opnd_array(uint operand_index, MachOper *operand) { assert(operand_index < _num_opnds, \"invalid _opnd_array index\"); _opnd_array[operand_index] = operand; }\n");
  11.301 +    fprintf(fp,"  MachOper *opnd_array(uint operand_index) const {\n");
  11.302 +    fprintf(fp,"    assert(operand_index < _num_opnds, \"invalid _opnd_array index\");\n");
  11.303 +    fprintf(fp,"    return _opnd_array[operand_index];\n");
  11.304 +    fprintf(fp,"  }\n");
  11.305 +    fprintf(fp,"  void      set_opnd_array(uint operand_index, MachOper *operand) {\n");
  11.306 +    fprintf(fp,"    assert(operand_index < _num_opnds, \"invalid _opnd_array index\");\n");
  11.307 +    fprintf(fp,"    _opnd_array[operand_index] = operand;\n");
  11.308 +    fprintf(fp,"  }\n");
  11.309      fprintf(fp,"private:\n");
  11.310      if ( instr->is_ideal_jump() ) {
  11.311        fprintf(fp,"  virtual void           add_case_label(int index_num, Label* blockLabel) {\n");
  11.312 -      fprintf(fp,"                                          _index2label.at_put_grow(index_num, blockLabel);}\n");
  11.313 +      fprintf(fp,"    _index2label.at_put_grow(index_num, blockLabel);\n");
  11.314 +      fprintf(fp,"  }\n");
  11.315      }
  11.316      if( can_cisc_spill() && (instr->cisc_spill_alternate() != NULL) ) {
  11.317        fprintf(fp,"  const RegMask  *_cisc_RegMask;\n");
  11.318 @@ -1572,7 +1588,7 @@
  11.319      while (attr != NULL) {
  11.320        if (strcmp(attr->_ident,"ins_cost") &&
  11.321            strcmp(attr->_ident,"ins_short_branch")) {
  11.322 -        fprintf(fp,"  int             %s() const { return %s; }\n",
  11.323 +        fprintf(fp,"          int            %s() const { return %s; }\n",
  11.324                  attr->_ident, attr->_val);
  11.325        }
  11.326        // Check value for ins_avoid_back_to_back, and if it is true (1), set the flag
  11.327 @@ -1656,12 +1672,12 @@
  11.328  
  11.329      // Output the declaration for number of relocation entries
  11.330      if ( instr->reloc(_globalNames) != 0 ) {
  11.331 -      fprintf(fp,"  virtual int            reloc()   const;\n");
  11.332 +      fprintf(fp,"  virtual int            reloc() const;\n");
  11.333      }
  11.334  
  11.335      if (instr->alignment() != 1) {
  11.336 -      fprintf(fp,"  virtual int            alignment_required()   const { return %d; }\n", instr->alignment());
  11.337 -      fprintf(fp,"  virtual int            compute_padding(int current_offset)   const;\n");
  11.338 +      fprintf(fp,"  virtual int            alignment_required() const { return %d; }\n", instr->alignment());
  11.339 +      fprintf(fp,"  virtual int            compute_padding(int current_offset) const;\n");
  11.340      }
  11.341  
  11.342      // Starting point for inputs matcher wants.
  11.343 @@ -1831,7 +1847,7 @@
  11.344        // as is done for pointers
  11.345        //
  11.346        // Construct appropriate constant type containing the constant value.
  11.347 -      fprintf(fp,"  virtual const class Type *bottom_type() const{\n");
  11.348 +      fprintf(fp,"  virtual const class Type *bottom_type() const {\n");
  11.349        switch( data_type ) {
  11.350        case Form::idealI:
  11.351          fprintf(fp,"    return  TypeInt::make(opnd_array(1)->constant());\n");
  11.352 @@ -1862,7 +1878,7 @@
  11.353        // !!!!! !!!!!
  11.354        // Provide explicit bottom type for conversions to int
  11.355        // On Intel the result operand is a stackSlot, untyped.
  11.356 -      fprintf(fp,"  virtual const class Type *bottom_type() const{");
  11.357 +      fprintf(fp,"  virtual const class Type *bottom_type() const {");
  11.358        fprintf(fp,   " return  TypeInt::INT;");
  11.359        fprintf(fp, " };\n");
  11.360      }*/
  11.361 @@ -1883,7 +1899,7 @@
  11.362        // BoxNode provides the address of a stack slot.
  11.363        // Define its bottom type to be TypeRawPtr::BOTTOM instead of TypePtr::BOTTOM
  11.364        // This prevent s insert_anti_dependencies from complaining. It will
  11.365 -      // complain if it see that the pointer base is TypePtr::BOTTOM since
  11.366 +      // complain if it sees that the pointer base is TypePtr::BOTTOM since
  11.367        // it doesn't understand what that might alias.
  11.368        fprintf(fp,"  const Type            *bottom_type() const { return TypeRawPtr::BOTTOM; } // Box?\n");
  11.369      }
  11.370 @@ -2046,7 +2062,7 @@
  11.371  class OutputMachOperands : public OutputMap {
  11.372  public:
  11.373    OutputMachOperands(FILE *hpp, FILE *cpp, FormDict &globals, ArchDesc &AD)
  11.374 -    : OutputMap(hpp, cpp, globals, AD) {};
  11.375 +    : OutputMap(hpp, cpp, globals, AD, "MachOperands") {};
  11.376  
  11.377    void declaration() { }
  11.378    void definition()  { fprintf(_cpp, "enum MachOperands {\n"); }
  11.379 @@ -2081,7 +2097,7 @@
  11.380    int end_instructions;
  11.381  public:
  11.382    OutputMachOpcodes(FILE *hpp, FILE *cpp, FormDict &globals, ArchDesc &AD)
  11.383 -    : OutputMap(hpp, cpp, globals, AD),
  11.384 +    : OutputMap(hpp, cpp, globals, AD, "MachOpcodes"),
  11.385        begin_inst_chain_rule(-1), end_inst_chain_rule(-1), end_instructions(-1)
  11.386    {};
  11.387  

mercurial