hotspot/src/share/vm/adlc/output_h.cpp
author drchase
Fri, 09 May 2014 16:50:54 -0400
changeset 24424 2658d7834c6e
parent 24008 da7059252295
child 24429 4efc66ee325c
permissions -rw-r--r--
8037816: Fix for 8036122 breaks build with Xcode5/clang Summary: Repaired or selectively disabled offending formats; future-proofed with additional checking Reviewed-by: kvn, jrose, stefank
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
24424
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 24008
diff changeset
     2
 * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5536
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5536
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5536
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
489c9b5090e2 Initial load
duke
parents:
diff changeset
    25
// output_h.cpp - Class HPP file output routines for architecture definition
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
#include "adlc.hpp"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
13971
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13969
diff changeset
    28
// The comment delimiter used in format statements after assembler instructions.
22853
308672304981 8028767: PPC64: (part 121): smaller shared changes needed to build C2
goetz
parents: 22850
diff changeset
    29
#if defined(PPC64)
308672304981 8028767: PPC64: (part 121): smaller shared changes needed to build C2
goetz
parents: 22850
diff changeset
    30
#define commentSeperator "\t//"
308672304981 8028767: PPC64: (part 121): smaller shared changes needed to build C2
goetz
parents: 22850
diff changeset
    31
#else
13971
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13969
diff changeset
    32
#define commentSeperator "!"
22853
308672304981 8028767: PPC64: (part 121): smaller shared changes needed to build C2
goetz
parents: 22850
diff changeset
    33
#endif
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
// Generate the #define that describes the number of registers.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
static void defineRegCount(FILE *fp, RegisterForm *registers) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
  if (registers) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
    int regCount =  AdlcVMDeps::Physical + registers->_rdefs.count();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
    fprintf(fp,"\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
    fprintf(fp,"// the number of reserved registers + machine registers.\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
    fprintf(fp,"#define REG_COUNT    %d\n", regCount);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
// Output enumeration of machine register numbers
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
// (1)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
// // Enumerate machine registers starting after reserved regs.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
// // in the order of occurrence in the register block.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
// enum MachRegisterNumbers {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
//   EAX_num = 0,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
//   ...
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
//   _last_Mach_Reg
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
// }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
void ArchDesc::buildMachRegisterNumbers(FILE *fp_hpp) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  if (_register) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
    RegDef *reg_def = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
    // Output a #define for the number of machine registers
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
    defineRegCount(fp_hpp, _register);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
    // Count all the Save_On_Entry and Always_Save registers
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
    int    saved_on_entry = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
    int  c_saved_on_entry = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
    _register->reset_RegDefs();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
    while( (reg_def = _register->iter_RegDefs()) != NULL ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
      if( strcmp(reg_def->_callconv,"SOE") == 0 ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
          strcmp(reg_def->_callconv,"AS")  == 0 )  ++saved_on_entry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
      if( strcmp(reg_def->_c_conv,"SOE") == 0 ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
          strcmp(reg_def->_c_conv,"AS")  == 0 )  ++c_saved_on_entry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
    fprintf(fp_hpp, "\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
    fprintf(fp_hpp, "// the number of save_on_entry + always_saved registers.\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
    fprintf(fp_hpp, "#define MAX_SAVED_ON_ENTRY_REG_COUNT    %d\n",   max(saved_on_entry,c_saved_on_entry));
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
    fprintf(fp_hpp, "#define     SAVED_ON_ENTRY_REG_COUNT    %d\n",   saved_on_entry);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
    fprintf(fp_hpp, "#define   C_SAVED_ON_ENTRY_REG_COUNT    %d\n", c_saved_on_entry);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
    // (1)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
    // Build definition for enumeration of register numbers
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
    fprintf(fp_hpp, "\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
    fprintf(fp_hpp, "// Enumerate machine register numbers starting after reserved regs.\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
    fprintf(fp_hpp, "// in the order of occurrence in the register block.\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
    fprintf(fp_hpp, "enum MachRegisterNumbers {\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
    // Output the register number for each register in the allocation classes
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
    _register->reset_RegDefs();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
    int i = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
    while( (reg_def = _register->iter_RegDefs()) != NULL ) {
13971
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13969
diff changeset
    88
      fprintf(fp_hpp,"  %s_num,", reg_def->_regname);
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13969
diff changeset
    89
      for (int j = 0; j < 20-(int)strlen(reg_def->_regname); j++) fprintf(fp_hpp, " ");
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13969
diff changeset
    90
      fprintf(fp_hpp," // enum %3d, regnum %3d, reg encode %3s\n",
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13969
diff changeset
    91
              i++,
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13969
diff changeset
    92
              reg_def->register_num(),
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13969
diff changeset
    93
              reg_def->register_encode());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
    // Finish defining enumeration
13971
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13969
diff changeset
    96
    fprintf(fp_hpp, "  _last_Mach_Reg            // %d\n", i);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
    fprintf(fp_hpp, "};\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
  fprintf(fp_hpp, "\n// Size of register-mask in ints\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
  fprintf(fp_hpp, "#define RM_SIZE %d\n",RegisterForm::RegMask_Size());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
  fprintf(fp_hpp, "// Unroll factor for loops over the data in a RegMask\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  fprintf(fp_hpp, "#define FORALL_BODY ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
  int len = RegisterForm::RegMask_Size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  for( int i = 0; i < len; i++ )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
    fprintf(fp_hpp, "BODY(%d) ",i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  fprintf(fp_hpp, "\n\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  fprintf(fp_hpp,"class RegMask;\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  // All RegMasks are declared "extern const ..." in ad_<arch>.hpp
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
  // fprintf(fp_hpp,"extern RegMask STACK_OR_STACK_SLOTS_mask;\n\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
// Output enumeration of machine register encodings
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
// (2)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
// // Enumerate machine registers starting after reserved regs.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
// // in the order of occurrence in the alloc_class(es).
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
// enum MachRegisterEncodes {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
//   EAX_enc = 0x00,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
//   ...
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
// }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
void ArchDesc::buildMachRegisterEncodes(FILE *fp_hpp) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
  if (_register) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
    RegDef *reg_def = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
    RegDef *reg_def_next = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
    // (2)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
    // Build definition for enumeration of encode values
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
    fprintf(fp_hpp, "\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
    fprintf(fp_hpp, "// Enumerate machine registers starting after reserved regs.\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
    fprintf(fp_hpp, "// in the order of occurrence in the alloc_class(es).\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
    fprintf(fp_hpp, "enum MachRegisterEncodes {\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
13971
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13969
diff changeset
   135
    // Find max enum string length.
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13969
diff changeset
   136
    size_t maxlen = 0;
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13969
diff changeset
   137
    _register->reset_RegDefs();
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13969
diff changeset
   138
    reg_def = _register->iter_RegDefs();
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13969
diff changeset
   139
    while (reg_def != NULL) {
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13969
diff changeset
   140
      size_t len = strlen(reg_def->_regname);
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13969
diff changeset
   141
      if (len > maxlen) maxlen = len;
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13969
diff changeset
   142
      reg_def = _register->iter_RegDefs();
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13969
diff changeset
   143
    }
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13969
diff changeset
   144
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
    // Output the register encoding for each register in the allocation classes
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
    _register->reset_RegDefs();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
    reg_def_next = _register->iter_RegDefs();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
    while( (reg_def = reg_def_next) != NULL ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
      reg_def_next = _register->iter_RegDefs();
13971
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13969
diff changeset
   150
      fprintf(fp_hpp,"  %s_enc", reg_def->_regname);
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13969
diff changeset
   151
      for (size_t i = strlen(reg_def->_regname); i < maxlen; i++) fprintf(fp_hpp, " ");
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13969
diff changeset
   152
      fprintf(fp_hpp," = %3s%s\n", reg_def->register_encode(), reg_def_next == NULL? "" : "," );
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
    // Finish defining enumeration
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
    fprintf(fp_hpp, "};\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
  } // Done with register form
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
// Declare an array containing the machine register names, strings.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
static void declareRegNames(FILE *fp, RegisterForm *registers) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
  if (registers) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
//    fprintf(fp,"\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
//    fprintf(fp,"// An array of character pointers to machine register names.\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
//    fprintf(fp,"extern const char *regName[];\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
// Declare an array containing the machine register sizes in 32-bit words.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
void ArchDesc::declareRegSizes(FILE *fp) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
// regSize[] is not used
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
// Declare an array containing the machine register encoding values
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
static void declareRegEncodes(FILE *fp, RegisterForm *registers) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
  if (registers) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
    // // //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
    // fprintf(fp,"\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
    // fprintf(fp,"// An array containing the machine register encode values\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
    // fprintf(fp,"extern const char  regEncode[];\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
// ---------------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
//------------------------------Utilities to build Instruction Classes--------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
// ---------------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
static void out_RegMask(FILE *fp) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
  fprintf(fp,"  virtual const RegMask &out_RegMask() const;\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
// ---------------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
//--------Utilities to build MachOper and MachNode derived Classes------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
// ---------------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
//------------------------------Utilities to build Operand Classes------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
static void in_RegMask(FILE *fp) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
  fprintf(fp,"  virtual const RegMask *in_RegMask(int index) const;\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
static void declareConstStorage(FILE *fp, FormDict &globals, OperandForm *oper) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
  int i = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
  Component *comp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
  if (oper->num_consts(globals) == 0) return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
  // Iterate over the component list looking for constants
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
  oper->_components.reset();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
  if ((comp = oper->_components.iter()) == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
    assert(oper->num_consts(globals) == 1, "Bad component list detected.\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
    const char *type = oper->ideal_type(globals);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
    if (!strcmp(type, "ConI")) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
      if (i > 0) fprintf(fp,", ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
      fprintf(fp,"  int32          _c%d;\n", i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
    else if (!strcmp(type, "ConP")) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
      if (i > 0) fprintf(fp,", ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
      fprintf(fp,"  const TypePtr *_c%d;\n", i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
    }
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   220
    else if (!strcmp(type, "ConN")) {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   221
      if (i > 0) fprintf(fp,", ");
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   222
      fprintf(fp,"  const TypeNarrowOop *_c%d;\n", i);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   223
    }
13969
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13728
diff changeset
   224
    else if (!strcmp(type, "ConNKlass")) {
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13728
diff changeset
   225
      if (i > 0) fprintf(fp,", ");
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13728
diff changeset
   226
      fprintf(fp,"  const TypeNarrowKlass *_c%d;\n", i);
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13728
diff changeset
   227
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
    else if (!strcmp(type, "ConL")) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
      if (i > 0) fprintf(fp,", ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
      fprintf(fp,"  jlong          _c%d;\n", i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
    else if (!strcmp(type, "ConF")) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
      if (i > 0) fprintf(fp,", ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
      fprintf(fp,"  jfloat         _c%d;\n", i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
    else if (!strcmp(type, "ConD")) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
      if (i > 0) fprintf(fp,", ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
      fprintf(fp,"  jdouble        _c%d;\n", i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
    else if (!strcmp(type, "Bool")) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
      fprintf(fp,"private:\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
      fprintf(fp,"  BoolTest::mask _c%d;\n", i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
      fprintf(fp,"public:\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
    else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
      assert(0, "Non-constant operand lacks component list.");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
  } // end if NULL
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
  else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
    oper->_components.reset();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
    while ((comp = oper->_components.iter()) != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
      if (!strcmp(comp->base_type(globals), "ConI")) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
        fprintf(fp,"  jint             _c%d;\n", i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
        i++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
      else if (!strcmp(comp->base_type(globals), "ConP")) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
        fprintf(fp,"  const TypePtr *_c%d;\n", i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
        i++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
      }
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   260
      else if (!strcmp(comp->base_type(globals), "ConN")) {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   261
        fprintf(fp,"  const TypePtr *_c%d;\n", i);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   262
        i++;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   263
      }
13969
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13728
diff changeset
   264
      else if (!strcmp(comp->base_type(globals), "ConNKlass")) {
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13728
diff changeset
   265
        fprintf(fp,"  const TypePtr *_c%d;\n", i);
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13728
diff changeset
   266
        i++;
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13728
diff changeset
   267
      }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
      else if (!strcmp(comp->base_type(globals), "ConL")) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
        fprintf(fp,"  jlong            _c%d;\n", i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
        i++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
      else if (!strcmp(comp->base_type(globals), "ConF")) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
        fprintf(fp,"  jfloat           _c%d;\n", i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
        i++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
      else if (!strcmp(comp->base_type(globals), "ConD")) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
        fprintf(fp,"  jdouble          _c%d;\n", i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
        i++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
// Declare constructor.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
// Parameters start with condition code, then all other constants
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
// (0) public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
// (1)  MachXOper(int32 ccode, int32 c0, int32 c1, ..., int32 cn)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
// (2)     : _ccode(ccode), _c0(c0), _c1(c1), ..., _cn(cn) { }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
static void defineConstructor(FILE *fp, const char *name, uint num_consts,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
                              ComponentList &lst, bool is_ideal_bool,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
                              Form::DataType constant_type, FormDict &globals) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
  fprintf(fp,"public:\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
  // generate line (1)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
  fprintf(fp,"  %sOper(", name);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
  if( num_consts == 0 ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
    fprintf(fp,") {}\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
    return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
  // generate parameters for constants
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
  uint i = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
  Component *comp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
  lst.reset();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
  if ((comp = lst.iter()) == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
    assert(num_consts == 1, "Bad component list detected.\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
    switch( constant_type ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
    case Form::idealI : {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
      fprintf(fp,is_ideal_bool ? "BoolTest::mask c%d" : "int32 c%d", i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
    }
13969
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13728
diff changeset
   313
    case Form::idealN :      { fprintf(fp,"const TypeNarrowOop *c%d", i); break; }
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13728
diff changeset
   314
    case Form::idealNKlass : { fprintf(fp,"const TypeNarrowKlass *c%d", i); break; }
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13728
diff changeset
   315
    case Form::idealP :      { fprintf(fp,"const TypePtr *c%d", i); break; }
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13728
diff changeset
   316
    case Form::idealL :      { fprintf(fp,"jlong c%d", i);   break;        }
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13728
diff changeset
   317
    case Form::idealF :      { fprintf(fp,"jfloat c%d", i);  break;        }
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13728
diff changeset
   318
    case Form::idealD :      { fprintf(fp,"jdouble c%d", i); break;        }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
    default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
      assert(!is_ideal_bool, "Non-constant operand lacks component list.");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
  } // end if NULL
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
  else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
    lst.reset();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
    while((comp = lst.iter()) != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
      if (!strcmp(comp->base_type(globals), "ConI")) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
        if (i > 0) fprintf(fp,", ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
        fprintf(fp,"int32 c%d", i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
        i++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
      else if (!strcmp(comp->base_type(globals), "ConP")) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
        if (i > 0) fprintf(fp,", ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
        fprintf(fp,"const TypePtr *c%d", i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
        i++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
      }
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   337
      else if (!strcmp(comp->base_type(globals), "ConN")) {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   338
        if (i > 0) fprintf(fp,", ");
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   339
        fprintf(fp,"const TypePtr *c%d", i);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   340
        i++;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   341
      }
13969
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13728
diff changeset
   342
      else if (!strcmp(comp->base_type(globals), "ConNKlass")) {
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13728
diff changeset
   343
        if (i > 0) fprintf(fp,", ");
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13728
diff changeset
   344
        fprintf(fp,"const TypePtr *c%d", i);
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13728
diff changeset
   345
        i++;
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13728
diff changeset
   346
      }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   347
      else if (!strcmp(comp->base_type(globals), "ConL")) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
        if (i > 0) fprintf(fp,", ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
        fprintf(fp,"jlong c%d", i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
        i++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
      else if (!strcmp(comp->base_type(globals), "ConF")) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
        if (i > 0) fprintf(fp,", ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
        fprintf(fp,"jfloat c%d", i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
        i++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
      else if (!strcmp(comp->base_type(globals), "ConD")) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
        if (i > 0) fprintf(fp,", ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
        fprintf(fp,"jdouble c%d", i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
        i++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
      else if (!strcmp(comp->base_type(globals), "Bool")) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
        if (i > 0) fprintf(fp,", ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
        fprintf(fp,"BoolTest::mask c%d", i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   365
        i++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   366
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   367
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   368
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   369
  // finish line (1) and start line (2)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   370
  fprintf(fp,")  : ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
  // generate initializers for constants
489c9b5090e2 Initial load
duke
parents:
diff changeset
   372
  i = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   373
  fprintf(fp,"_c%d(c%d)", i, i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   374
  for( i = 1; i < num_consts; ++i) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   375
    fprintf(fp,", _c%d(c%d)", i, i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   376
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   377
  // The body for the constructor is empty
489c9b5090e2 Initial load
duke
parents:
diff changeset
   378
  fprintf(fp," {}\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   379
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   380
489c9b5090e2 Initial load
duke
parents:
diff changeset
   381
// ---------------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   382
// Utilities to generate format rules for machine operands and instructions
489c9b5090e2 Initial load
duke
parents:
diff changeset
   383
// ---------------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   384
489c9b5090e2 Initial load
duke
parents:
diff changeset
   385
// Generate the format rule for condition codes
1495
128fe18951ed 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 1055
diff changeset
   386
static void defineCCodeDump(OperandForm* oper, FILE *fp, int i) {
128fe18951ed 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 1055
diff changeset
   387
  assert(oper != NULL, "what");
128fe18951ed 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 1055
diff changeset
   388
  CondInterface* cond = oper->_interface->is_CondInterface();
24424
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 24008
diff changeset
   389
  fprintf(fp, "       if( _c%d == BoolTest::eq ) st->print_raw(\"%s\");\n",i,cond->_equal_format);
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 24008
diff changeset
   390
  fprintf(fp, "  else if( _c%d == BoolTest::ne ) st->print_raw(\"%s\");\n",i,cond->_not_equal_format);
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 24008
diff changeset
   391
  fprintf(fp, "  else if( _c%d == BoolTest::le ) st->print_raw(\"%s\");\n",i,cond->_less_equal_format);
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 24008
diff changeset
   392
  fprintf(fp, "  else if( _c%d == BoolTest::ge ) st->print_raw(\"%s\");\n",i,cond->_greater_equal_format);
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 24008
diff changeset
   393
  fprintf(fp, "  else if( _c%d == BoolTest::lt ) st->print_raw(\"%s\");\n",i,cond->_less_format);
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 24008
diff changeset
   394
  fprintf(fp, "  else if( _c%d == BoolTest::gt ) st->print_raw(\"%s\");\n",i,cond->_greater_format);
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 24008
diff changeset
   395
  fprintf(fp, "  else if( _c%d == BoolTest::overflow ) st->print_raw(\"%s\");\n",i,cond->_overflow_format);
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 24008
diff changeset
   396
  fprintf(fp, "  else if( _c%d == BoolTest::no_overflow ) st->print_raw(\"%s\");\n",i,cond->_no_overflow_format);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   397
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   398
489c9b5090e2 Initial load
duke
parents:
diff changeset
   399
// Output code that dumps constant values, increment "i" if type is constant
1495
128fe18951ed 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 1055
diff changeset
   400
static uint dump_spec_constant(FILE *fp, const char *ideal_type, uint i, OperandForm* oper) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   401
  if (!strcmp(ideal_type, "ConI")) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   402
    fprintf(fp,"   st->print(\"#%%d\", _c%d);\n", i);
13971
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13969
diff changeset
   403
    fprintf(fp,"   st->print(\"/0x%%08x\", _c%d);\n", i);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   404
    ++i;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   405
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   406
  else if (!strcmp(ideal_type, "ConP")) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   407
    fprintf(fp,"    _c%d->dump_on(st);\n", i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   408
    ++i;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   409
  }
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   410
  else if (!strcmp(ideal_type, "ConN")) {
1497
cd3234c89e59 6764622: IdealGraphVisualizer fixes
never
parents: 1495
diff changeset
   411
    fprintf(fp,"    _c%d->dump_on(st);\n", i);
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   412
    ++i;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   413
  }
13969
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13728
diff changeset
   414
  else if (!strcmp(ideal_type, "ConNKlass")) {
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13728
diff changeset
   415
    fprintf(fp,"    _c%d->dump_on(st);\n", i);
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13728
diff changeset
   416
    ++i;
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13728
diff changeset
   417
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   418
  else if (!strcmp(ideal_type, "ConL")) {
24424
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 24008
diff changeset
   419
    fprintf(fp,"    st->print(\"#\" INT64_FORMAT, (int64_t)_c%d);\n", i);
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 24008
diff changeset
   420
    fprintf(fp,"    st->print(\"/\" PTR64_FORMAT, (uint64_t)_c%d);\n", i);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   421
    ++i;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   422
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   423
  else if (!strcmp(ideal_type, "ConF")) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   424
    fprintf(fp,"    st->print(\"#%%f\", _c%d);\n", i);
13971
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13969
diff changeset
   425
    fprintf(fp,"    jint _c%di = JavaValue(_c%d).get_jint();\n", i, i);
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13969
diff changeset
   426
    fprintf(fp,"    st->print(\"/0x%%x/\", _c%di);\n", i);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   427
    ++i;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   428
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   429
  else if (!strcmp(ideal_type, "ConD")) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   430
    fprintf(fp,"    st->print(\"#%%f\", _c%d);\n", i);
13971
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13969
diff changeset
   431
    fprintf(fp,"    jlong _c%dl = JavaValue(_c%d).get_jlong();\n", i, i);
24424
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 24008
diff changeset
   432
    fprintf(fp,"    st->print(\"/\" PTR64_FORMAT, (uint64_t)_c%dl);\n", i);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   433
    ++i;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   434
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   435
  else if (!strcmp(ideal_type, "Bool")) {
1495
128fe18951ed 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 1055
diff changeset
   436
    defineCCodeDump(oper, fp,i);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   437
    ++i;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   438
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   439
489c9b5090e2 Initial load
duke
parents:
diff changeset
   440
  return i;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   441
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   442
489c9b5090e2 Initial load
duke
parents:
diff changeset
   443
// Generate the format rule for an operand
489c9b5090e2 Initial load
duke
parents:
diff changeset
   444
void gen_oper_format(FILE *fp, FormDict &globals, OperandForm &oper, bool for_c_file = false) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   445
  if (!for_c_file) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   446
    // invoked after output #ifndef PRODUCT to ad_<arch>.hpp
489c9b5090e2 Initial load
duke
parents:
diff changeset
   447
    // compile the bodies separately, to cut down on recompilations
489c9b5090e2 Initial load
duke
parents:
diff changeset
   448
    fprintf(fp,"  virtual void           int_format(PhaseRegAlloc *ra, const MachNode *node, outputStream *st) const;\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   449
    fprintf(fp,"  virtual void           ext_format(PhaseRegAlloc *ra, const MachNode *node, int idx, outputStream *st) const;\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   450
    return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   451
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   452
489c9b5090e2 Initial load
duke
parents:
diff changeset
   453
  // Local pointer indicates remaining part of format rule
13971
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13969
diff changeset
   454
  int idx = 0;                   // position of operand in match rule
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   455
489c9b5090e2 Initial load
duke
parents:
diff changeset
   456
  // Generate internal format function, used when stored locally
489c9b5090e2 Initial load
duke
parents:
diff changeset
   457
  fprintf(fp, "\n#ifndef PRODUCT\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   458
  fprintf(fp,"void %sOper::int_format(PhaseRegAlloc *ra, const MachNode *node, outputStream *st) const {\n", oper._ident);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   459
  // Generate the user-defined portion of the format
489c9b5090e2 Initial load
duke
parents:
diff changeset
   460
  if (oper._format) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   461
    if ( oper._format->_strings.count() != 0 ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   462
      // No initialization code for int_format
489c9b5090e2 Initial load
duke
parents:
diff changeset
   463
489c9b5090e2 Initial load
duke
parents:
diff changeset
   464
      // Build the format from the entries in strings and rep_vars
489c9b5090e2 Initial load
duke
parents:
diff changeset
   465
      const char  *string  = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   466
      oper._format->_rep_vars.reset();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   467
      oper._format->_strings.reset();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   468
      while ( (string = oper._format->_strings.iter()) != NULL ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   469
489c9b5090e2 Initial load
duke
parents:
diff changeset
   470
        // Check if this is a standard string or a replacement variable
489c9b5090e2 Initial load
duke
parents:
diff changeset
   471
        if ( string != NameList::_signal ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   472
          // Normal string
489c9b5090e2 Initial load
duke
parents:
diff changeset
   473
          // Pass through to st->print
24424
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 24008
diff changeset
   474
          fprintf(fp,"  st->print_raw(\"%s\");\n", string);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   475
        } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   476
          // Replacement variable
489c9b5090e2 Initial load
duke
parents:
diff changeset
   477
          const char *rep_var = oper._format->_rep_vars.iter();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   478
          // Check that it is a local name, and an operand
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   479
          const Form* form = oper._localNames[rep_var];
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   480
          if (form == NULL) {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   481
            globalAD->syntax_err(oper._linenum,
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   482
                                 "\'%s\' not found in format for %s\n", rep_var, oper._ident);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   483
            assert(form, "replacement variable was not found in local names");
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   484
          }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   485
          OperandForm *op      = form->is_operand();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   486
          // Get index if register or constant
489c9b5090e2 Initial load
duke
parents:
diff changeset
   487
          if ( op->_matrule && op->_matrule->is_base_register(globals) ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   488
            idx  = oper.register_position( globals, rep_var);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   489
          }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   490
          else if (op->_matrule && op->_matrule->is_base_constant(globals)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   491
            idx  = oper.constant_position( globals, rep_var);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   492
          } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   493
            idx = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   494
          }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   495
489c9b5090e2 Initial load
duke
parents:
diff changeset
   496
          // output invocation of "$..."s format function
13971
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13969
diff changeset
   497
          if ( op != NULL ) op->int_format(fp, globals, idx);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   498
489c9b5090e2 Initial load
duke
parents:
diff changeset
   499
          if ( idx == -1 ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   500
            fprintf(stderr,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   501
                    "Using a name, %s, that isn't in match rule\n", rep_var);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   502
            assert( strcmp(op->_ident,"label")==0, "Unimplemented");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   503
          }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   504
        } // Done with a replacement variable
489c9b5090e2 Initial load
duke
parents:
diff changeset
   505
      } // Done with all format strings
489c9b5090e2 Initial load
duke
parents:
diff changeset
   506
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   507
      // Default formats for base operands (RegI, RegP, ConI, ConP, ...)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   508
      oper.int_format(fp, globals, 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   509
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   510
489c9b5090e2 Initial load
duke
parents:
diff changeset
   511
  } else { // oper._format == NULL
489c9b5090e2 Initial load
duke
parents:
diff changeset
   512
    // Provide a few special case formats where the AD writer cannot.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   513
    if ( strcmp(oper._ident,"Universe")==0 ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   514
      fprintf(fp, "  st->print(\"$$univ\");\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   515
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   516
    // labelOper::int_format is defined in ad_<...>.cpp
489c9b5090e2 Initial load
duke
parents:
diff changeset
   517
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   518
  // ALWAYS! Provide a special case output for condition codes.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   519
  if( oper.is_ideal_bool() ) {
1495
128fe18951ed 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 1055
diff changeset
   520
    defineCCodeDump(&oper, fp,0);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   521
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   522
  fprintf(fp,"}\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   523
489c9b5090e2 Initial load
duke
parents:
diff changeset
   524
  // Generate external format function, when data is stored externally
489c9b5090e2 Initial load
duke
parents:
diff changeset
   525
  fprintf(fp,"void %sOper::ext_format(PhaseRegAlloc *ra, const MachNode *node, int idx, outputStream *st) const {\n", oper._ident);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   526
  // Generate the user-defined portion of the format
489c9b5090e2 Initial load
duke
parents:
diff changeset
   527
  if (oper._format) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   528
    if ( oper._format->_strings.count() != 0 ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   529
489c9b5090e2 Initial load
duke
parents:
diff changeset
   530
      // Check for a replacement string "$..."
489c9b5090e2 Initial load
duke
parents:
diff changeset
   531
      if ( oper._format->_rep_vars.count() != 0 ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   532
        // Initialization code for ext_format
489c9b5090e2 Initial load
duke
parents:
diff changeset
   533
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   534
489c9b5090e2 Initial load
duke
parents:
diff changeset
   535
      // Build the format from the entries in strings and rep_vars
489c9b5090e2 Initial load
duke
parents:
diff changeset
   536
      const char  *string  = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   537
      oper._format->_rep_vars.reset();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   538
      oper._format->_strings.reset();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   539
      while ( (string = oper._format->_strings.iter()) != NULL ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   540
489c9b5090e2 Initial load
duke
parents:
diff changeset
   541
        // Check if this is a standard string or a replacement variable
489c9b5090e2 Initial load
duke
parents:
diff changeset
   542
        if ( string != NameList::_signal ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   543
          // Normal string
489c9b5090e2 Initial load
duke
parents:
diff changeset
   544
          // Pass through to st->print
24424
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 24008
diff changeset
   545
          fprintf(fp,"  st->print_raw(\"%s\");\n", string);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   546
        } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   547
          // Replacement variable
489c9b5090e2 Initial load
duke
parents:
diff changeset
   548
          const char *rep_var = oper._format->_rep_vars.iter();
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   549
         // Check that it is a local name, and an operand
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   550
          const Form* form = oper._localNames[rep_var];
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   551
          if (form == NULL) {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   552
            globalAD->syntax_err(oper._linenum,
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   553
                                 "\'%s\' not found in format for %s\n", rep_var, oper._ident);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   554
            assert(form, "replacement variable was not found in local names");
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   555
          }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   556
          OperandForm *op      = form->is_operand();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   557
          // Get index if register or constant
489c9b5090e2 Initial load
duke
parents:
diff changeset
   558
          if ( op->_matrule && op->_matrule->is_base_register(globals) ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   559
            idx  = oper.register_position( globals, rep_var);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   560
          }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   561
          else if (op->_matrule && op->_matrule->is_base_constant(globals)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   562
            idx  = oper.constant_position( globals, rep_var);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   563
          } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   564
            idx = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   565
          }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   566
          // output invocation of "$..."s format function
489c9b5090e2 Initial load
duke
parents:
diff changeset
   567
          if ( op != NULL )   op->ext_format(fp, globals, idx);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   568
489c9b5090e2 Initial load
duke
parents:
diff changeset
   569
          // Lookup the index position of the replacement variable
13971
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13969
diff changeset
   570
          idx      = oper._components.operand_position_format(rep_var, &oper);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   571
          if ( idx == -1 ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   572
            fprintf(stderr,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   573
                    "Using a name, %s, that isn't in match rule\n", rep_var);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   574
            assert( strcmp(op->_ident,"label")==0, "Unimplemented");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   575
          }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   576
        } // Done with a replacement variable
489c9b5090e2 Initial load
duke
parents:
diff changeset
   577
      } // Done with all format strings
489c9b5090e2 Initial load
duke
parents:
diff changeset
   578
489c9b5090e2 Initial load
duke
parents:
diff changeset
   579
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   580
      // Default formats for base operands (RegI, RegP, ConI, ConP, ...)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   581
      oper.ext_format(fp, globals, 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   582
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   583
  } else { // oper._format == NULL
489c9b5090e2 Initial load
duke
parents:
diff changeset
   584
    // Provide a few special case formats where the AD writer cannot.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   585
    if ( strcmp(oper._ident,"Universe")==0 ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   586
      fprintf(fp, "  st->print(\"$$univ\");\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   587
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   588
    // labelOper::ext_format is defined in ad_<...>.cpp
489c9b5090e2 Initial load
duke
parents:
diff changeset
   589
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   590
  // ALWAYS! Provide a special case output for condition codes.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   591
  if( oper.is_ideal_bool() ) {
1495
128fe18951ed 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 1055
diff changeset
   592
    defineCCodeDump(&oper, fp,0);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   593
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   594
  fprintf(fp, "}\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   595
  fprintf(fp, "#endif\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   596
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   597
489c9b5090e2 Initial load
duke
parents:
diff changeset
   598
489c9b5090e2 Initial load
duke
parents:
diff changeset
   599
// Generate the format rule for an instruction
489c9b5090e2 Initial load
duke
parents:
diff changeset
   600
void gen_inst_format(FILE *fp, FormDict &globals, InstructForm &inst, bool for_c_file = false) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   601
  if (!for_c_file) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   602
    // compile the bodies separately, to cut down on recompilations
489c9b5090e2 Initial load
duke
parents:
diff changeset
   603
    // #ifndef PRODUCT region generated by caller
489c9b5090e2 Initial load
duke
parents:
diff changeset
   604
    fprintf(fp,"  virtual void           format(PhaseRegAlloc *ra, outputStream *st) const;\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   605
    return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   606
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   607
489c9b5090e2 Initial load
duke
parents:
diff changeset
   608
  // Define the format function
489c9b5090e2 Initial load
duke
parents:
diff changeset
   609
  fprintf(fp, "#ifndef PRODUCT\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   610
  fprintf(fp, "void %sNode::format(PhaseRegAlloc *ra, outputStream *st) const {\n", inst._ident);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   611
489c9b5090e2 Initial load
duke
parents:
diff changeset
   612
  // Generate the user-defined portion of the format
489c9b5090e2 Initial load
duke
parents:
diff changeset
   613
  if( inst._format ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   614
    // If there are replacement variables,
2131
98f9cef66a34 6810672: Comment typos
twisti
parents: 2129
diff changeset
   615
    // Generate index values needed for determining the operand position
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   616
    if( inst._format->_rep_vars.count() )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   617
      inst.index_temps(fp, globals);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   618
489c9b5090e2 Initial load
duke
parents:
diff changeset
   619
    // Build the format from the entries in strings and rep_vars
489c9b5090e2 Initial load
duke
parents:
diff changeset
   620
    const char  *string  = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   621
    inst._format->_rep_vars.reset();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   622
    inst._format->_strings.reset();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   623
    while( (string = inst._format->_strings.iter()) != NULL ) {
13971
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13969
diff changeset
   624
      fprintf(fp,"  ");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   625
      // Check if this is a standard string or a replacement variable
1495
128fe18951ed 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 1055
diff changeset
   626
      if( string == NameList::_signal ) { // Replacement variable
128fe18951ed 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 1055
diff changeset
   627
        const char* rep_var =  inst._format->_rep_vars.iter();
128fe18951ed 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 1055
diff changeset
   628
        inst.rep_var_format( fp, rep_var);
128fe18951ed 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 1055
diff changeset
   629
      } else if( string == NameList::_signal3 ) { // Replacement variable in raw text
128fe18951ed 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 1055
diff changeset
   630
        const char* rep_var =  inst._format->_rep_vars.iter();
128fe18951ed 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 1055
diff changeset
   631
        const Form *form   = inst._localNames[rep_var];
128fe18951ed 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 1055
diff changeset
   632
        if (form == NULL) {
128fe18951ed 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 1055
diff changeset
   633
          fprintf(stderr, "unknown replacement variable in format statement: '%s'\n", rep_var);
128fe18951ed 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 1055
diff changeset
   634
          assert(false, "ShouldNotReachHere()");
128fe18951ed 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 1055
diff changeset
   635
        }
128fe18951ed 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 1055
diff changeset
   636
        OpClassForm *opc   = form->is_opclass();
128fe18951ed 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 1055
diff changeset
   637
        assert( opc, "replacement variable was not found in local names");
128fe18951ed 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 1055
diff changeset
   638
        // Lookup the index position of the replacement variable
128fe18951ed 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 1055
diff changeset
   639
        int idx  = inst.operand_position_format(rep_var);
128fe18951ed 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 1055
diff changeset
   640
        if ( idx == -1 ) {
128fe18951ed 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 1055
diff changeset
   641
          assert( strcmp(opc->_ident,"label")==0, "Unimplemented");
128fe18951ed 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 1055
diff changeset
   642
          assert( false, "ShouldNotReachHere()");
128fe18951ed 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 1055
diff changeset
   643
        }
128fe18951ed 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 1055
diff changeset
   644
128fe18951ed 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 1055
diff changeset
   645
        if (inst.is_noninput_operand(idx)) {
128fe18951ed 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 1055
diff changeset
   646
          assert( false, "ShouldNotReachHere()");
128fe18951ed 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 1055
diff changeset
   647
        } else {
128fe18951ed 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 1055
diff changeset
   648
          // Output the format call for this operand
128fe18951ed 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 1055
diff changeset
   649
          fprintf(fp,"opnd_array(%d)",idx);
128fe18951ed 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 1055
diff changeset
   650
        }
128fe18951ed 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 1055
diff changeset
   651
        rep_var =  inst._format->_rep_vars.iter();
128fe18951ed 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 1055
diff changeset
   652
        inst._format->_strings.iter();
128fe18951ed 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 1055
diff changeset
   653
        if ( strcmp(rep_var,"$constant") == 0 && opc->is_operand()) {
128fe18951ed 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 1055
diff changeset
   654
          Form::DataType constant_type = form->is_operand()->is_base_constant(globals);
128fe18951ed 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 1055
diff changeset
   655
          if ( constant_type == Form::idealD ) {
128fe18951ed 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 1055
diff changeset
   656
            fprintf(fp,"->constantD()");
128fe18951ed 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 1055
diff changeset
   657
          } else if ( constant_type == Form::idealF ) {
128fe18951ed 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 1055
diff changeset
   658
            fprintf(fp,"->constantF()");
128fe18951ed 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 1055
diff changeset
   659
          } else if ( constant_type == Form::idealL ) {
128fe18951ed 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 1055
diff changeset
   660
            fprintf(fp,"->constantL()");
128fe18951ed 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 1055
diff changeset
   661
          } else {
128fe18951ed 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 1055
diff changeset
   662
            fprintf(fp,"->constant()");
128fe18951ed 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 1055
diff changeset
   663
          }
128fe18951ed 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 1055
diff changeset
   664
        } else if ( strcmp(rep_var,"$cmpcode") == 0) {
128fe18951ed 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 1055
diff changeset
   665
            fprintf(fp,"->ccode()");
128fe18951ed 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 1055
diff changeset
   666
        } else {
128fe18951ed 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 1055
diff changeset
   667
          assert( false, "ShouldNotReachHere()");
128fe18951ed 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 1055
diff changeset
   668
        }
128fe18951ed 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 1055
diff changeset
   669
      } else if( string == NameList::_signal2 ) // Raw program text
128fe18951ed 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 1055
diff changeset
   670
        fputs(inst._format->_strings.iter(), fp);
128fe18951ed 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 1055
diff changeset
   671
      else
24424
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 24008
diff changeset
   672
        fprintf(fp,"st->print_raw(\"%s\");\n", string);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   673
    } // Done with all format strings
489c9b5090e2 Initial load
duke
parents:
diff changeset
   674
  } // Done generating the user-defined portion of the format
489c9b5090e2 Initial load
duke
parents:
diff changeset
   675
489c9b5090e2 Initial load
duke
parents:
diff changeset
   676
  // Add call debug info automatically
489c9b5090e2 Initial load
duke
parents:
diff changeset
   677
  Form::CallType call_type = inst.is_ideal_call();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   678
  if( call_type != Form::invalid_type ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   679
    switch( call_type ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   680
    case Form::JAVA_DYNAMIC:
13971
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13969
diff changeset
   681
      fprintf(fp,"  _method->print_short_name(st);\n");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   682
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   683
    case Form::JAVA_STATIC:
13971
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13969
diff changeset
   684
      fprintf(fp,"  if( _method ) _method->print_short_name(st);\n");
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13969
diff changeset
   685
      fprintf(fp,"  else st->print(\" wrapper for: %%s\", _name);\n");
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13969
diff changeset
   686
      fprintf(fp,"  if( !_method ) dump_trap_args(st);\n");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   687
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   688
    case Form::JAVA_COMPILED:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   689
    case Form::JAVA_INTERP:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   690
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   691
    case Form::JAVA_RUNTIME:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   692
    case Form::JAVA_LEAF:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   693
    case Form::JAVA_NATIVE:
13971
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13969
diff changeset
   694
      fprintf(fp,"  st->print(\" %%s\", _name);");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   695
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   696
    default:
13971
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13969
diff changeset
   697
      assert(0,"ShouldNotReachHere");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   698
    }
24424
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 24008
diff changeset
   699
    fprintf(fp,  "  st->cr();\n" );
13971
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13969
diff changeset
   700
    fprintf(fp,  "  if (_jvms) _jvms->format(ra, this, st); else st->print_cr(\"        No JVM State Info\");\n" );
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13969
diff changeset
   701
    fprintf(fp,  "  st->print(\"        # \");\n" );
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13969
diff changeset
   702
    fprintf(fp,  "  if( _jvms && _oop_map ) _oop_map->print_on(st);\n");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   703
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   704
  else if(inst.is_ideal_safepoint()) {
24424
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 24008
diff changeset
   705
    fprintf(fp,  "  st->print_raw(\"\");\n" );
13971
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13969
diff changeset
   706
    fprintf(fp,  "  if (_jvms) _jvms->format(ra, this, st); else st->print_cr(\"        No JVM State Info\");\n" );
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13969
diff changeset
   707
    fprintf(fp,  "  st->print(\"        # \");\n" );
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13969
diff changeset
   708
    fprintf(fp,  "  if( _jvms && _oop_map ) _oop_map->print_on(st);\n");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   709
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   710
  else if( inst.is_ideal_if() ) {
13971
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13969
diff changeset
   711
    fprintf(fp,  "  st->print(\"  P=%%f C=%%f\",_prob,_fcnt);\n" );
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   712
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   713
  else if( inst.is_ideal_mem() ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   714
    // Print out the field name if available to improve readability
13971
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13969
diff changeset
   715
    fprintf(fp,  "  if (ra->C->alias_type(adr_type())->field() != NULL) {\n");
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13969
diff changeset
   716
    fprintf(fp,  "    ciField* f = ra->C->alias_type(adr_type())->field();\n");
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13969
diff changeset
   717
    fprintf(fp,  "    st->print(\" %s Field: \");\n", commentSeperator);
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13969
diff changeset
   718
    fprintf(fp,  "    if (f->is_volatile())\n");
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13969
diff changeset
   719
    fprintf(fp,  "      st->print(\"volatile \");\n");
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13969
diff changeset
   720
    fprintf(fp,  "    f->holder()->name()->print_symbol_on(st);\n");
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13969
diff changeset
   721
    fprintf(fp,  "    st->print(\".\");\n");
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13969
diff changeset
   722
    fprintf(fp,  "    f->name()->print_symbol_on(st);\n");
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13969
diff changeset
   723
    fprintf(fp,  "    if (f->is_constant())\n");
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13969
diff changeset
   724
    fprintf(fp,  "      st->print(\" (constant)\");\n");
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13969
diff changeset
   725
    fprintf(fp,  "  } else {\n");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   726
    // Make sure 'Volatile' gets printed out
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11196
diff changeset
   727
    fprintf(fp,  "    if (ra->C->alias_type(adr_type())->is_volatile())\n");
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11196
diff changeset
   728
    fprintf(fp,  "      st->print(\" volatile!\");\n");
13971
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13969
diff changeset
   729
    fprintf(fp,  "  }\n");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   730
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   731
489c9b5090e2 Initial load
duke
parents:
diff changeset
   732
  // Complete the definition of the format function
13971
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13969
diff changeset
   733
  fprintf(fp, "}\n#endif\n");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   734
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   735
489c9b5090e2 Initial load
duke
parents:
diff changeset
   736
void ArchDesc::declare_pipe_classes(FILE *fp_hpp) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   737
  if (!_pipeline)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   738
    return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   739
489c9b5090e2 Initial load
duke
parents:
diff changeset
   740
  fprintf(fp_hpp, "\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   741
  fprintf(fp_hpp, "// Pipeline_Use_Cycle_Mask Class\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   742
  fprintf(fp_hpp, "class Pipeline_Use_Cycle_Mask {\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   743
489c9b5090e2 Initial load
duke
parents:
diff changeset
   744
  if (_pipeline->_maxcycleused <=
489c9b5090e2 Initial load
duke
parents:
diff changeset
   745
#ifdef SPARC
489c9b5090e2 Initial load
duke
parents:
diff changeset
   746
    64
489c9b5090e2 Initial load
duke
parents:
diff changeset
   747
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   748
    32
489c9b5090e2 Initial load
duke
parents:
diff changeset
   749
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   750
      ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   751
    fprintf(fp_hpp, "protected:\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   752
    fprintf(fp_hpp, "  %s _mask;\n\n", _pipeline->_maxcycleused <= 32 ? "uint" : "uint64_t" );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   753
    fprintf(fp_hpp, "public:\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   754
    fprintf(fp_hpp, "  Pipeline_Use_Cycle_Mask() : _mask(0) {}\n\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   755
    if (_pipeline->_maxcycleused <= 32)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   756
      fprintf(fp_hpp, "  Pipeline_Use_Cycle_Mask(uint mask) : _mask(mask) {}\n\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   757
    else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   758
      fprintf(fp_hpp, "  Pipeline_Use_Cycle_Mask(uint mask1, uint mask2) : _mask((((uint64_t)mask1) << 32) | mask2) {}\n\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   759
      fprintf(fp_hpp, "  Pipeline_Use_Cycle_Mask(uint64_t mask) : _mask(mask) {}\n\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   760
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   761
    fprintf(fp_hpp, "  Pipeline_Use_Cycle_Mask& operator=(const Pipeline_Use_Cycle_Mask &in) {\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   762
    fprintf(fp_hpp, "    _mask = in._mask;\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   763
    fprintf(fp_hpp, "    return *this;\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   764
    fprintf(fp_hpp, "  }\n\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   765
    fprintf(fp_hpp, "  bool overlaps(const Pipeline_Use_Cycle_Mask &in2) const {\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   766
    fprintf(fp_hpp, "    return ((_mask & in2._mask) != 0);\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   767
    fprintf(fp_hpp, "  }\n\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   768
    fprintf(fp_hpp, "  Pipeline_Use_Cycle_Mask& operator<<=(int n) {\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   769
    fprintf(fp_hpp, "    _mask <<= n;\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   770
    fprintf(fp_hpp, "    return *this;\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   771
    fprintf(fp_hpp, "  }\n\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   772
    fprintf(fp_hpp, "  void Or(const Pipeline_Use_Cycle_Mask &in2) {\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   773
    fprintf(fp_hpp, "    _mask |= in2._mask;\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   774
    fprintf(fp_hpp, "  }\n\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   775
    fprintf(fp_hpp, "  friend Pipeline_Use_Cycle_Mask operator&(const Pipeline_Use_Cycle_Mask &, const Pipeline_Use_Cycle_Mask &);\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   776
    fprintf(fp_hpp, "  friend Pipeline_Use_Cycle_Mask operator|(const Pipeline_Use_Cycle_Mask &, const Pipeline_Use_Cycle_Mask &);\n\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   777
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   778
  else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   779
    fprintf(fp_hpp, "protected:\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   780
    uint masklen = (_pipeline->_maxcycleused + 31) >> 5;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   781
    uint l;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   782
    fprintf(fp_hpp, "  uint ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   783
    for (l = 1; l <= masklen; l++)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   784
      fprintf(fp_hpp, "_mask%d%s", l, l < masklen ? ", " : ";\n\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   785
    fprintf(fp_hpp, "public:\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   786
    fprintf(fp_hpp, "  Pipeline_Use_Cycle_Mask() : ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   787
    for (l = 1; l <= masklen; l++)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   788
      fprintf(fp_hpp, "_mask%d(0)%s", l, l < masklen ? ", " : " {}\n\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   789
    fprintf(fp_hpp, "  Pipeline_Use_Cycle_Mask(");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   790
    for (l = 1; l <= masklen; l++)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   791
      fprintf(fp_hpp, "uint mask%d%s", l, l < masklen ? ", " : ") : ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   792
    for (l = 1; l <= masklen; l++)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   793
      fprintf(fp_hpp, "_mask%d(mask%d)%s", l, l, l < masklen ? ", " : " {}\n\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   794
489c9b5090e2 Initial load
duke
parents:
diff changeset
   795
    fprintf(fp_hpp, "  Pipeline_Use_Cycle_Mask& operator=(const Pipeline_Use_Cycle_Mask &in) {\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   796
    for (l = 1; l <= masklen; l++)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   797
      fprintf(fp_hpp, "    _mask%d = in._mask%d;\n", l, l);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   798
    fprintf(fp_hpp, "    return *this;\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   799
    fprintf(fp_hpp, "  }\n\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   800
    fprintf(fp_hpp, "  Pipeline_Use_Cycle_Mask intersect(const Pipeline_Use_Cycle_Mask &in2) {\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   801
    fprintf(fp_hpp, "    Pipeline_Use_Cycle_Mask out;\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   802
    for (l = 1; l <= masklen; l++)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   803
      fprintf(fp_hpp, "    out._mask%d = _mask%d & in2._mask%d;\n", l, l, l);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   804
    fprintf(fp_hpp, "    return out;\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   805
    fprintf(fp_hpp, "  }\n\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   806
    fprintf(fp_hpp, "  bool overlaps(const Pipeline_Use_Cycle_Mask &in2) const {\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   807
    fprintf(fp_hpp, "    return (");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   808
    for (l = 1; l <= masklen; l++)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   809
      fprintf(fp_hpp, "((_mask%d & in2._mask%d) != 0)%s", l, l, l < masklen ? " || " : "");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   810
    fprintf(fp_hpp, ") ? true : false;\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   811
    fprintf(fp_hpp, "  }\n\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   812
    fprintf(fp_hpp, "  Pipeline_Use_Cycle_Mask& operator<<=(int n) {\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   813
    fprintf(fp_hpp, "    if (n >= 32)\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   814
    fprintf(fp_hpp, "      do {\n       ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   815
    for (l = masklen; l > 1; l--)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   816
      fprintf(fp_hpp, " _mask%d = _mask%d;", l, l-1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   817
    fprintf(fp_hpp, " _mask%d = 0;\n", 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   818
    fprintf(fp_hpp, "      } while ((n -= 32) >= 32);\n\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   819
    fprintf(fp_hpp, "    if (n > 0) {\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   820
    fprintf(fp_hpp, "      uint m = 32 - n;\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   821
    fprintf(fp_hpp, "      uint mask = (1 << n) - 1;\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   822
    fprintf(fp_hpp, "      uint temp%d = mask & (_mask%d >> m); _mask%d <<= n;\n", 2, 1, 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   823
    for (l = 2; l < masklen; l++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   824
      fprintf(fp_hpp, "      uint temp%d = mask & (_mask%d >> m); _mask%d <<= n; _mask%d |= temp%d;\n", l+1, l, l, l, l);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   825
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   826
    fprintf(fp_hpp, "      _mask%d <<= n; _mask%d |= temp%d;\n", masklen, masklen, masklen);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   827
    fprintf(fp_hpp, "    }\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   828
489c9b5090e2 Initial load
duke
parents:
diff changeset
   829
    fprintf(fp_hpp, "    return *this;\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   830
    fprintf(fp_hpp, "  }\n\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   831
    fprintf(fp_hpp, "  void Or(const Pipeline_Use_Cycle_Mask &);\n\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   832
    fprintf(fp_hpp, "  friend Pipeline_Use_Cycle_Mask operator&(const Pipeline_Use_Cycle_Mask &, const Pipeline_Use_Cycle_Mask &);\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   833
    fprintf(fp_hpp, "  friend Pipeline_Use_Cycle_Mask operator|(const Pipeline_Use_Cycle_Mask &, const Pipeline_Use_Cycle_Mask &);\n\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   834
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   835
489c9b5090e2 Initial load
duke
parents:
diff changeset
   836
  fprintf(fp_hpp, "  friend class Pipeline_Use;\n\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   837
  fprintf(fp_hpp, "  friend class Pipeline_Use_Element;\n\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   838
  fprintf(fp_hpp, "};\n\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   839
489c9b5090e2 Initial load
duke
parents:
diff changeset
   840
  uint rescount = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   841
  const char *resource;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   842
489c9b5090e2 Initial load
duke
parents:
diff changeset
   843
  for ( _pipeline->_reslist.reset(); (resource = _pipeline->_reslist.iter()) != NULL; ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   844
      int mask = _pipeline->_resdict[resource]->is_resource()->mask();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   845
      if ((mask & (mask-1)) == 0)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   846
        rescount++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   847
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   848
489c9b5090e2 Initial load
duke
parents:
diff changeset
   849
  fprintf(fp_hpp, "// Pipeline_Use_Element Class\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   850
  fprintf(fp_hpp, "class Pipeline_Use_Element {\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   851
  fprintf(fp_hpp, "protected:\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   852
  fprintf(fp_hpp, "  // Mask of used functional units\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   853
  fprintf(fp_hpp, "  uint _used;\n\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   854
  fprintf(fp_hpp, "  // Lower and upper bound of functional unit number range\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   855
  fprintf(fp_hpp, "  uint _lb, _ub;\n\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   856
  fprintf(fp_hpp, "  // Indicates multiple functionals units available\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   857
  fprintf(fp_hpp, "  bool _multiple;\n\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   858
  fprintf(fp_hpp, "  // Mask of specific used cycles\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   859
  fprintf(fp_hpp, "  Pipeline_Use_Cycle_Mask _mask;\n\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   860
  fprintf(fp_hpp, "public:\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   861
  fprintf(fp_hpp, "  Pipeline_Use_Element() {}\n\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   862
  fprintf(fp_hpp, "  Pipeline_Use_Element(uint used, uint lb, uint ub, bool multiple, Pipeline_Use_Cycle_Mask mask)\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   863
  fprintf(fp_hpp, "  : _used(used), _lb(lb), _ub(ub), _multiple(multiple), _mask(mask) {}\n\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   864
  fprintf(fp_hpp, "  uint used() const { return _used; }\n\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   865
  fprintf(fp_hpp, "  uint lowerBound() const { return _lb; }\n\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   866
  fprintf(fp_hpp, "  uint upperBound() const { return _ub; }\n\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   867
  fprintf(fp_hpp, "  bool multiple() const { return _multiple; }\n\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   868
  fprintf(fp_hpp, "  Pipeline_Use_Cycle_Mask mask() const { return _mask; }\n\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   869
  fprintf(fp_hpp, "  bool overlaps(const Pipeline_Use_Element &in2) const {\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   870
  fprintf(fp_hpp, "    return ((_used & in2._used) != 0 && _mask.overlaps(in2._mask));\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   871
  fprintf(fp_hpp, "  }\n\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   872
  fprintf(fp_hpp, "  void step(uint cycles) {\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   873
  fprintf(fp_hpp, "    _used = 0;\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   874
  fprintf(fp_hpp, "    _mask <<= cycles;\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   875
  fprintf(fp_hpp, "  }\n\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   876
  fprintf(fp_hpp, "  friend class Pipeline_Use;\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   877
  fprintf(fp_hpp, "};\n\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   878
489c9b5090e2 Initial load
duke
parents:
diff changeset
   879
  fprintf(fp_hpp, "// Pipeline_Use Class\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   880
  fprintf(fp_hpp, "class Pipeline_Use {\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   881
  fprintf(fp_hpp, "protected:\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   882
  fprintf(fp_hpp, "  // These resources can be used\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   883
  fprintf(fp_hpp, "  uint _resources_used;\n\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   884
  fprintf(fp_hpp, "  // These resources are used; excludes multiple choice functional units\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   885
  fprintf(fp_hpp, "  uint _resources_used_exclusively;\n\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   886
  fprintf(fp_hpp, "  // Number of elements\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   887
  fprintf(fp_hpp, "  uint _count;\n\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   888
  fprintf(fp_hpp, "  // This is the array of Pipeline_Use_Elements\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   889
  fprintf(fp_hpp, "  Pipeline_Use_Element * _elements;\n\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   890
  fprintf(fp_hpp, "public:\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   891
  fprintf(fp_hpp, "  Pipeline_Use(uint resources_used, uint resources_used_exclusively, uint count, Pipeline_Use_Element *elements)\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   892
  fprintf(fp_hpp, "  : _resources_used(resources_used)\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   893
  fprintf(fp_hpp, "  , _resources_used_exclusively(resources_used_exclusively)\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   894
  fprintf(fp_hpp, "  , _count(count)\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   895
  fprintf(fp_hpp, "  , _elements(elements)\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   896
  fprintf(fp_hpp, "  {}\n\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   897
  fprintf(fp_hpp, "  uint resourcesUsed() const { return _resources_used; }\n\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   898
  fprintf(fp_hpp, "  uint resourcesUsedExclusively() const { return _resources_used_exclusively; }\n\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   899
  fprintf(fp_hpp, "  uint count() const { return _count; }\n\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   900
  fprintf(fp_hpp, "  Pipeline_Use_Element * element(uint i) const { return &_elements[i]; }\n\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   901
  fprintf(fp_hpp, "  uint full_latency(uint delay, const Pipeline_Use &pred) const;\n\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   902
  fprintf(fp_hpp, "  void add_usage(const Pipeline_Use &pred);\n\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   903
  fprintf(fp_hpp, "  void reset() {\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   904
  fprintf(fp_hpp, "    _resources_used = _resources_used_exclusively = 0;\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   905
  fprintf(fp_hpp, "  };\n\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   906
  fprintf(fp_hpp, "  void step(uint cycles) {\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   907
  fprintf(fp_hpp, "    reset();\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   908
  fprintf(fp_hpp, "    for (uint i = 0; i < %d; i++)\n",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   909
    rescount);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   910
  fprintf(fp_hpp, "      (&_elements[i])->step(cycles);\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   911
  fprintf(fp_hpp, "  };\n\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   912
  fprintf(fp_hpp, "  static const Pipeline_Use         elaborated_use;\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   913
  fprintf(fp_hpp, "  static const Pipeline_Use_Element elaborated_elements[%d];\n\n",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   914
    rescount);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   915
  fprintf(fp_hpp, "  friend class Pipeline;\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   916
  fprintf(fp_hpp, "};\n\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   917
489c9b5090e2 Initial load
duke
parents:
diff changeset
   918
  fprintf(fp_hpp, "// Pipeline Class\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   919
  fprintf(fp_hpp, "class Pipeline {\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   920
  fprintf(fp_hpp, "public:\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   921
489c9b5090e2 Initial load
duke
parents:
diff changeset
   922
  fprintf(fp_hpp, "  static bool enabled() { return %s; }\n\n",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   923
    _pipeline ? "true" : "false" );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   924
489c9b5090e2 Initial load
duke
parents:
diff changeset
   925
  assert( _pipeline->_maxInstrsPerBundle &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   926
        ( _pipeline->_instrUnitSize || _pipeline->_bundleUnitSize) &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   927
          _pipeline->_instrFetchUnitSize &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   928
          _pipeline->_instrFetchUnits,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   929
    "unspecified pipeline architecture units");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   930
489c9b5090e2 Initial load
duke
parents:
diff changeset
   931
  uint unitSize = _pipeline->_instrUnitSize ? _pipeline->_instrUnitSize : _pipeline->_bundleUnitSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   932
489c9b5090e2 Initial load
duke
parents:
diff changeset
   933
  fprintf(fp_hpp, "  enum {\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   934
  fprintf(fp_hpp, "    _variable_size_instructions = %d,\n",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   935
    _pipeline->_variableSizeInstrs ? 1 : 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   936
  fprintf(fp_hpp, "    _fixed_size_instructions = %d,\n",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   937
    _pipeline->_variableSizeInstrs ? 0 : 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   938
  fprintf(fp_hpp, "    _branch_has_delay_slot = %d,\n",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   939
    _pipeline->_branchHasDelaySlot ? 1 : 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   940
  fprintf(fp_hpp, "    _max_instrs_per_bundle = %d,\n",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   941
    _pipeline->_maxInstrsPerBundle);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   942
  fprintf(fp_hpp, "    _max_bundles_per_cycle = %d,\n",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   943
    _pipeline->_maxBundlesPerCycle);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   944
  fprintf(fp_hpp, "    _max_instrs_per_cycle = %d\n",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   945
    _pipeline->_maxBundlesPerCycle * _pipeline->_maxInstrsPerBundle);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   946
  fprintf(fp_hpp, "  };\n\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   947
489c9b5090e2 Initial load
duke
parents:
diff changeset
   948
  fprintf(fp_hpp, "  static bool instr_has_unit_size() { return %s; }\n\n",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   949
    _pipeline->_instrUnitSize != 0 ? "true" : "false" );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   950
  if( _pipeline->_bundleUnitSize != 0 )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   951
    if( _pipeline->_instrUnitSize != 0 )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   952
      fprintf(fp_hpp, "// Individual Instructions may be bundled together by the hardware\n\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   953
    else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   954
      fprintf(fp_hpp, "// Instructions exist only in bundles\n\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   955
  else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   956
    fprintf(fp_hpp, "// Bundling is not supported\n\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   957
  if( _pipeline->_instrUnitSize != 0 )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   958
    fprintf(fp_hpp, "  // Size of an instruction\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   959
  else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   960
    fprintf(fp_hpp, "  // Size of an individual instruction does not exist - unsupported\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   961
  fprintf(fp_hpp, "  static uint instr_unit_size() {");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   962
  if( _pipeline->_instrUnitSize == 0 )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   963
    fprintf(fp_hpp, " assert( false, \"Instructions are only in bundles\" );");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   964
  fprintf(fp_hpp, " return %d; };\n\n", _pipeline->_instrUnitSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   965
489c9b5090e2 Initial load
duke
parents:
diff changeset
   966
  if( _pipeline->_bundleUnitSize != 0 )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   967
    fprintf(fp_hpp, "  // Size of a bundle\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   968
  else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   969
    fprintf(fp_hpp, "  // Bundles do not exist - unsupported\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   970
  fprintf(fp_hpp, "  static uint bundle_unit_size() {");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   971
  if( _pipeline->_bundleUnitSize == 0 )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   972
    fprintf(fp_hpp, " assert( false, \"Bundles are not supported\" );");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   973
  fprintf(fp_hpp, " return %d; };\n\n", _pipeline->_bundleUnitSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   974
489c9b5090e2 Initial load
duke
parents:
diff changeset
   975
  fprintf(fp_hpp, "  static bool requires_bundling() { return %s; }\n\n",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   976
    _pipeline->_bundleUnitSize != 0 && _pipeline->_instrUnitSize == 0 ? "true" : "false" );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   977
489c9b5090e2 Initial load
duke
parents:
diff changeset
   978
  fprintf(fp_hpp, "private:\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   979
  fprintf(fp_hpp, "  Pipeline();  // Not a legal constructor\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   980
  fprintf(fp_hpp, "\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   981
  fprintf(fp_hpp, "  const unsigned char                   _read_stage_count;\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   982
  fprintf(fp_hpp, "  const unsigned char                   _write_stage;\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   983
  fprintf(fp_hpp, "  const unsigned char                   _fixed_latency;\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   984
  fprintf(fp_hpp, "  const unsigned char                   _instruction_count;\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   985
  fprintf(fp_hpp, "  const bool                            _has_fixed_latency;\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   986
  fprintf(fp_hpp, "  const bool                            _has_branch_delay;\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   987
  fprintf(fp_hpp, "  const bool                            _has_multiple_bundles;\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   988
  fprintf(fp_hpp, "  const bool                            _force_serialization;\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   989
  fprintf(fp_hpp, "  const bool                            _may_have_no_code;\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   990
  fprintf(fp_hpp, "  const enum machPipelineStages * const _read_stages;\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   991
  fprintf(fp_hpp, "  const enum machPipelineStages * const _resource_stage;\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   992
  fprintf(fp_hpp, "  const uint                    * const _resource_cycles;\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   993
  fprintf(fp_hpp, "  const Pipeline_Use                    _resource_use;\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   994
  fprintf(fp_hpp, "\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   995
  fprintf(fp_hpp, "public:\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   996
  fprintf(fp_hpp, "  Pipeline(uint                            write_stage,\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   997
  fprintf(fp_hpp, "           uint                            count,\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   998
  fprintf(fp_hpp, "           bool                            has_fixed_latency,\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   999
  fprintf(fp_hpp, "           uint                            fixed_latency,\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1000
  fprintf(fp_hpp, "           uint                            instruction_count,\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1001
  fprintf(fp_hpp, "           bool                            has_branch_delay,\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1002
  fprintf(fp_hpp, "           bool                            has_multiple_bundles,\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1003
  fprintf(fp_hpp, "           bool                            force_serialization,\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1004
  fprintf(fp_hpp, "           bool                            may_have_no_code,\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1005
  fprintf(fp_hpp, "           enum machPipelineStages * const dst,\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1006
  fprintf(fp_hpp, "           enum machPipelineStages * const stage,\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1007
  fprintf(fp_hpp, "           uint                    * const cycles,\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1008
  fprintf(fp_hpp, "           Pipeline_Use                    resource_use)\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1009
  fprintf(fp_hpp, "  : _write_stage(write_stage)\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1010
  fprintf(fp_hpp, "  , _read_stage_count(count)\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1011
  fprintf(fp_hpp, "  , _has_fixed_latency(has_fixed_latency)\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1012
  fprintf(fp_hpp, "  , _fixed_latency(fixed_latency)\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1013
  fprintf(fp_hpp, "  , _read_stages(dst)\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1014
  fprintf(fp_hpp, "  , _resource_stage(stage)\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1015
  fprintf(fp_hpp, "  , _resource_cycles(cycles)\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1016
  fprintf(fp_hpp, "  , _resource_use(resource_use)\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1017
  fprintf(fp_hpp, "  , _instruction_count(instruction_count)\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1018
  fprintf(fp_hpp, "  , _has_branch_delay(has_branch_delay)\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1019
  fprintf(fp_hpp, "  , _has_multiple_bundles(has_multiple_bundles)\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1020
  fprintf(fp_hpp, "  , _force_serialization(force_serialization)\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1021
  fprintf(fp_hpp, "  , _may_have_no_code(may_have_no_code)\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1022
  fprintf(fp_hpp, "  {};\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1023
  fprintf(fp_hpp, "\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1024
  fprintf(fp_hpp, "  uint writeStage() const {\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1025
  fprintf(fp_hpp, "    return (_write_stage);\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1026
  fprintf(fp_hpp, "  }\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1027
  fprintf(fp_hpp, "\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1028
  fprintf(fp_hpp, "  enum machPipelineStages readStage(int ndx) const {\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1029
  fprintf(fp_hpp, "    return (ndx < _read_stage_count ? _read_stages[ndx] : stage_undefined);");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1030
  fprintf(fp_hpp, "  }\n\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1031
  fprintf(fp_hpp, "  uint resourcesUsed() const {\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1032
  fprintf(fp_hpp, "    return _resource_use.resourcesUsed();\n  }\n\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1033
  fprintf(fp_hpp, "  uint resourcesUsedExclusively() const {\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1034
  fprintf(fp_hpp, "    return _resource_use.resourcesUsedExclusively();\n  }\n\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1035
  fprintf(fp_hpp, "  bool hasFixedLatency() const {\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1036
  fprintf(fp_hpp, "    return (_has_fixed_latency);\n  }\n\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1037
  fprintf(fp_hpp, "  uint fixedLatency() const {\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1038
  fprintf(fp_hpp, "    return (_fixed_latency);\n  }\n\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1039
  fprintf(fp_hpp, "  uint functional_unit_latency(uint start, const Pipeline *pred) const;\n\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1040
  fprintf(fp_hpp, "  uint operand_latency(uint opnd, const Pipeline *pred) const;\n\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1041
  fprintf(fp_hpp, "  const Pipeline_Use& resourceUse() const {\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1042
  fprintf(fp_hpp, "    return (_resource_use); }\n\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1043
  fprintf(fp_hpp, "  const Pipeline_Use_Element * resourceUseElement(uint i) const {\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1044
  fprintf(fp_hpp, "    return (&_resource_use._elements[i]); }\n\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1045
  fprintf(fp_hpp, "  uint resourceUseCount() const {\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1046
  fprintf(fp_hpp, "    return (_resource_use._count); }\n\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1047
  fprintf(fp_hpp, "  uint instructionCount() const {\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1048
  fprintf(fp_hpp, "    return (_instruction_count); }\n\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1049
  fprintf(fp_hpp, "  bool hasBranchDelay() const {\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1050
  fprintf(fp_hpp, "    return (_has_branch_delay); }\n\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1051
  fprintf(fp_hpp, "  bool hasMultipleBundles() const {\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1052
  fprintf(fp_hpp, "    return (_has_multiple_bundles); }\n\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1053
  fprintf(fp_hpp, "  bool forceSerialization() const {\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1054
  fprintf(fp_hpp, "    return (_force_serialization); }\n\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1055
  fprintf(fp_hpp, "  bool mayHaveNoCode() const {\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1056
  fprintf(fp_hpp, "    return (_may_have_no_code); }\n\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1057
  fprintf(fp_hpp, "//const Pipeline_Use_Cycle_Mask& resourceUseMask(int resource) const {\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1058
  fprintf(fp_hpp, "//  return (_resource_use_masks[resource]); }\n\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1059
  fprintf(fp_hpp, "\n#ifndef PRODUCT\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1060
  fprintf(fp_hpp, "  static const char * stageName(uint i);\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1061
  fprintf(fp_hpp, "#endif\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1062
  fprintf(fp_hpp, "};\n\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1063
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1064
  fprintf(fp_hpp, "// Bundle class\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1065
  fprintf(fp_hpp, "class Bundle {\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1066
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1067
  uint mshift = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1068
  for (uint msize = _pipeline->_maxInstrsPerBundle * _pipeline->_maxBundlesPerCycle; msize != 0; msize >>= 1)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1069
    mshift++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1070
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1071
  uint rshift = rescount;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1072
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1073
  fprintf(fp_hpp, "protected:\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1074
  fprintf(fp_hpp, "  enum {\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1075
  fprintf(fp_hpp, "    _unused_delay                   = 0x%x,\n", 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1076
  fprintf(fp_hpp, "    _use_nop_delay                  = 0x%x,\n", 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1077
  fprintf(fp_hpp, "    _use_unconditional_delay        = 0x%x,\n", 2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1078
  fprintf(fp_hpp, "    _use_conditional_delay          = 0x%x,\n", 3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1079
  fprintf(fp_hpp, "    _used_in_conditional_delay      = 0x%x,\n", 4);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1080
  fprintf(fp_hpp, "    _used_in_unconditional_delay    = 0x%x,\n", 5);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1081
  fprintf(fp_hpp, "    _used_in_all_conditional_delays = 0x%x,\n", 6);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1082
  fprintf(fp_hpp, "\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1083
  fprintf(fp_hpp, "    _use_delay                      = 0x%x,\n", 3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1084
  fprintf(fp_hpp, "    _used_in_delay                  = 0x%x\n",  4);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1085
  fprintf(fp_hpp, "  };\n\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1086
  fprintf(fp_hpp, "  uint _flags          : 3,\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1087
  fprintf(fp_hpp, "       _starts_bundle  : 1,\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1088
  fprintf(fp_hpp, "       _instr_count    : %d,\n",   mshift);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1089
  fprintf(fp_hpp, "       _resources_used : %d;\n",   rshift);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1090
  fprintf(fp_hpp, "public:\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1091
  fprintf(fp_hpp, "  Bundle() : _flags(_unused_delay), _starts_bundle(0), _instr_count(0), _resources_used(0) {}\n\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1092
  fprintf(fp_hpp, "  void set_instr_count(uint i) { _instr_count  = i; }\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1093
  fprintf(fp_hpp, "  void set_resources_used(uint i) { _resources_used   = i; }\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1094
  fprintf(fp_hpp, "  void clear_usage() { _flags = _unused_delay; }\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1095
  fprintf(fp_hpp, "  void set_starts_bundle() { _starts_bundle = true; }\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1096
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1097
  fprintf(fp_hpp, "  uint flags() const { return (_flags); }\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1098
  fprintf(fp_hpp, "  uint instr_count() const { return (_instr_count); }\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1099
  fprintf(fp_hpp, "  uint resources_used() const { return (_resources_used); }\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1100
  fprintf(fp_hpp, "  bool starts_bundle() const { return (_starts_bundle != 0); }\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1101
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1102
  fprintf(fp_hpp, "  void set_use_nop_delay() { _flags = _use_nop_delay; }\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1103
  fprintf(fp_hpp, "  void set_use_unconditional_delay() { _flags = _use_unconditional_delay; }\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1104
  fprintf(fp_hpp, "  void set_use_conditional_delay() { _flags = _use_conditional_delay; }\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1105
  fprintf(fp_hpp, "  void set_used_in_unconditional_delay() { _flags = _used_in_unconditional_delay; }\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1106
  fprintf(fp_hpp, "  void set_used_in_conditional_delay() { _flags = _used_in_conditional_delay; }\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1107
  fprintf(fp_hpp, "  void set_used_in_all_conditional_delays() { _flags = _used_in_all_conditional_delays; }\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1108
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1109
  fprintf(fp_hpp, "  bool use_nop_delay() { return (_flags == _use_nop_delay); }\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1110
  fprintf(fp_hpp, "  bool use_unconditional_delay() { return (_flags == _use_unconditional_delay); }\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1111
  fprintf(fp_hpp, "  bool use_conditional_delay() { return (_flags == _use_conditional_delay); }\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1112
  fprintf(fp_hpp, "  bool used_in_unconditional_delay() { return (_flags == _used_in_unconditional_delay); }\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1113
  fprintf(fp_hpp, "  bool used_in_conditional_delay() { return (_flags == _used_in_conditional_delay); }\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1114
  fprintf(fp_hpp, "  bool used_in_all_conditional_delays() { return (_flags == _used_in_all_conditional_delays); }\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1115
  fprintf(fp_hpp, "  bool use_delay() { return ((_flags & _use_delay) != 0); }\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1116
  fprintf(fp_hpp, "  bool used_in_delay() { return ((_flags & _used_in_delay) != 0); }\n\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1117
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1118
  fprintf(fp_hpp, "  enum {\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1119
  fprintf(fp_hpp, "    _nop_count = %d\n",
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1120
    _pipeline->_nopcnt);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1121
  fprintf(fp_hpp, "  };\n\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1122
  fprintf(fp_hpp, "  static void initialize_nops(MachNode *nop_list[%d], Compile* C);\n\n",
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1123
    _pipeline->_nopcnt);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1124
  fprintf(fp_hpp, "#ifndef PRODUCT\n");
13971
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13969
diff changeset
  1125
  fprintf(fp_hpp, "  void dump(outputStream *st = tty) const;\n");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1126
  fprintf(fp_hpp, "#endif\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1127
  fprintf(fp_hpp, "};\n\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1128
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1129
//  const char *classname;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1130
//  for (_pipeline->_classlist.reset(); (classname = _pipeline->_classlist.iter()) != NULL; ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1131
//    PipeClassForm *pipeclass = _pipeline->_classdict[classname]->is_pipeclass();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1132
//    fprintf(fp_hpp, "// Pipeline Class Instance for \"%s\"\n", classname);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1133
//  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1134
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1135
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1136
//------------------------------declareClasses---------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1137
// Construct the class hierarchy of MachNode classes from the instruction &
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1138
// operand lists
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1139
void ArchDesc::declareClasses(FILE *fp) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1140
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1141
  // Declare an array containing the machine register names, strings.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1142
  declareRegNames(fp, _register);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1143
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1144
  // Declare an array containing the machine register encoding values
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1145
  declareRegEncodes(fp, _register);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1146
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1147
  // Generate declarations for the total number of operands
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1148
  fprintf(fp,"\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1149
  fprintf(fp,"// Total number of operands defined in architecture definition\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1150
  int num_operands = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1151
  OperandForm *op;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1152
  for (_operands.reset(); (op = (OperandForm*)_operands.iter()) != NULL; ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1153
    // Ensure this is a machine-world instruction
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1154
    if (op->ideal_only()) continue;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1155
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1156
    ++num_operands;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1157
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1158
  int first_operand_class = num_operands;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1159
  OpClassForm *opc;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1160
  for (_opclass.reset(); (opc = (OpClassForm*)_opclass.iter()) != NULL; ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1161
    // Ensure this is a machine-world instruction
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1162
    if (opc->ideal_only()) continue;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1163
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1164
    ++num_operands;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1165
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1166
  fprintf(fp,"#define FIRST_OPERAND_CLASS   %d\n", first_operand_class);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1167
  fprintf(fp,"#define NUM_OPERANDS          %d\n", num_operands);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1168
  fprintf(fp,"\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1169
  // Generate declarations for the total number of instructions
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1170
  fprintf(fp,"// Total number of instructions defined in architecture definition\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1171
  fprintf(fp,"#define NUM_INSTRUCTIONS   %d\n",instructFormCount());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1172
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1173
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1174
  // Generate Machine Classes for each operand defined in AD file
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1175
  fprintf(fp,"\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1176
  fprintf(fp,"//----------------------------Declare classes derived from MachOper----------\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1177
  // Iterate through all operands
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1178
  _operands.reset();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1179
  OperandForm *oper;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1180
  for( ; (oper = (OperandForm*)_operands.iter()) != NULL;) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1181
    // Ensure this is a machine-world instruction
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1182
    if (oper->ideal_only() ) continue;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1183
    // The declaration of labelOper is in machine-independent file: machnode
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1184
    if ( strcmp(oper->_ident,"label")  == 0 ) continue;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1185
    // The declaration of methodOper is in machine-independent file: machnode
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1186
    if ( strcmp(oper->_ident,"method") == 0 ) continue;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1187
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1188
    // Build class definition for this operand
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1189
    fprintf(fp,"\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1190
    fprintf(fp,"class %sOper : public MachOper { \n",oper->_ident);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1191
    fprintf(fp,"private:\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1192
    // Operand definitions that depend upon number of input edges
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1193
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1194
      uint num_edges = oper->num_edges(_globalNames);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1195
      if( num_edges != 1 ) { // Use MachOper::num_edges() {return 1;}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1196
        fprintf(fp,"  virtual uint           num_edges() const { return %d; }\n",
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1197
              num_edges );
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1198
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1199
      if( num_edges > 0 ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1200
        in_RegMask(fp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1201
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1202
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1203
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1204
    // Support storing constants inside the MachOper
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1205
    declareConstStorage(fp,_globalNames,oper);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1206
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1207
    // Support storage of the condition codes
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1208
    if( oper->is_ideal_bool() ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1209
      fprintf(fp,"  virtual int ccode() const { \n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1210
      fprintf(fp,"    switch (_c0) {\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1211
      fprintf(fp,"    case  BoolTest::eq : return equal();\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1212
      fprintf(fp,"    case  BoolTest::gt : return greater();\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1213
      fprintf(fp,"    case  BoolTest::lt : return less();\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1214
      fprintf(fp,"    case  BoolTest::ne : return not_equal();\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1215
      fprintf(fp,"    case  BoolTest::le : return less_equal();\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1216
      fprintf(fp,"    case  BoolTest::ge : return greater_equal();\n");
20289
35d78de0c547 8024924: Intrinsify java.lang.Math.addExact
rbackman
parents: 16687
diff changeset
  1217
      fprintf(fp,"    case  BoolTest::overflow : return overflow();\n");
35d78de0c547 8024924: Intrinsify java.lang.Math.addExact
rbackman
parents: 16687
diff changeset
  1218
      fprintf(fp,"    case  BoolTest::no_overflow: return no_overflow();\n");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1219
      fprintf(fp,"    default : ShouldNotReachHere(); return 0;\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1220
      fprintf(fp,"    }\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1221
      fprintf(fp,"  };\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1222
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1223
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1224
    // Support storage of the condition codes
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1225
    if( oper->is_ideal_bool() ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1226
      fprintf(fp,"  virtual void negate() { \n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1227
      fprintf(fp,"    _c0 = (BoolTest::mask)((int)_c0^0x4); \n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1228
      fprintf(fp,"  };\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1229
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1230
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1231
    // Declare constructor.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1232
    // Parameters start with condition code, then all other constants
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1233
    //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1234
    // (1)  MachXOper(int32 ccode, int32 c0, int32 c1, ..., int32 cn)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1235
    // (2)     : _ccode(ccode), _c0(c0), _c1(c1), ..., _cn(cn) { }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1236
    //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1237
    Form::DataType constant_type = oper->simple_type(_globalNames);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1238
    defineConstructor(fp, oper->_ident, oper->num_consts(_globalNames),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1239
                      oper->_components, oper->is_ideal_bool(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1240
                      constant_type, _globalNames);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1241
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1242
    // Clone function
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1243
    fprintf(fp,"  virtual MachOper      *clone(Compile* C) const;\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1244
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1245
    // Support setting a spill offset into a constant operand.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1246
    // We only support setting an 'int' offset, while in the
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1247
    // LP64 build spill offsets are added with an AddP which
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1248
    // requires a long constant.  Thus we don't support spilling
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1249
    // in frames larger than 4Gig.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1250
    if( oper->has_conI(_globalNames) ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1251
        oper->has_conL(_globalNames) )
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1252
      fprintf(fp, "  virtual void set_con( jint c0 ) { _c0 = c0; }\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1253
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1254
    // virtual functions for encoding and format
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1255
    //    fprintf(fp,"  virtual void           encode()   const {\n    %s }\n",
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1256
    //            (oper->_encrule)?(oper->_encrule->_encrule):"");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1257
    // Check the interface type, and generate the correct query functions
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1258
    // encoding queries based upon MEMORY_INTER, REG_INTER, CONST_INTER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1259
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1260
    fprintf(fp,"  virtual uint           opcode() const { return %s; }\n",
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1261
            machOperEnum(oper->_ident));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1262
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1263
    // virtual function to look up ideal return type of machine instruction
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1264
    //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1265
    // (1)  virtual const Type    *type() const { return .....; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1266
    //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1267
    if ((oper->_matrule) && (oper->_matrule->_lChild == NULL) &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1268
        (oper->_matrule->_rChild == NULL)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1269
      unsigned int position = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1270
      const char  *opret, *opname, *optype;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1271
      oper->_matrule->base_operand(position,_globalNames,opret,opname,optype);
13971
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13969
diff changeset
  1272
      fprintf(fp,"  virtual const Type    *type() const {");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1273
      const char *type = getIdealType(optype);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1274
      if( type != NULL ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1275
        Form::DataType data_type = oper->is_base_constant(_globalNames);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1276
        // Check if we are an ideal pointer type
13969
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13728
diff changeset
  1277
        if( data_type == Form::idealP || data_type == Form::idealN || data_type == Form::idealNKlass ) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1278
          // Return the ideal type we already have: <TypePtr *>
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1279
          fprintf(fp," return _c0;");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1280
        } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1281
          // Return the appropriate bottom type
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1282
          fprintf(fp," return %s;", getIdealType(optype));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1283
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1284
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1285
        fprintf(fp," ShouldNotCallThis(); return Type::BOTTOM;");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1286
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1287
      fprintf(fp," }\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1288
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1289
      // Check for user-defined stack slots, based upon sRegX
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1290
      Form::DataType data_type = oper->is_user_name_for_sReg();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1291
      if( data_type != Form::none ){
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1292
        const char *type = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1293
        switch( data_type ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1294
        case Form::idealI: type = "TypeInt::INT";   break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1295
        case Form::idealP: type = "TypePtr::BOTTOM";break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1296
        case Form::idealF: type = "Type::FLOAT";    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1297
        case Form::idealD: type = "Type::DOUBLE";   break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1298
        case Form::idealL: type = "TypeLong::LONG"; break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1299
        case Form::none: // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1300
        default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1301
          assert( false, "No support for this type of stackSlot");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1302
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1303
        fprintf(fp,"  virtual const Type    *type() const { return %s; } // stackSlotX\n", type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1304
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1305
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1306
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1307
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1308
    //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1309
    // virtual functions for defining the encoding interface.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1310
    //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1311
    // Access the linearized ideal register mask,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1312
    // map to physical register encoding
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1313
    if ( oper->_matrule && oper->_matrule->is_base_register(_globalNames) ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1314
      // Just use the default virtual 'reg' call
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1315
    } else if ( oper->ideal_to_sReg_type(oper->_ident) != Form::none ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1316
      // Special handling for operand 'sReg', a Stack Slot Register.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1317
      // Map linearized ideal register mask to stack slot number
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1318
      fprintf(fp,"  virtual int            reg(PhaseRegAlloc *ra_, const Node *node) const {\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1319
      fprintf(fp,"    return (int)OptoReg::reg2stack(ra_->get_reg_first(node));/* sReg */\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1320
      fprintf(fp,"  }\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1321
      fprintf(fp,"  virtual int            reg(PhaseRegAlloc *ra_, const Node *node, int idx) const {\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1322
      fprintf(fp,"    return (int)OptoReg::reg2stack(ra_->get_reg_first(node->in(idx)));/* sReg */\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1323
      fprintf(fp,"  }\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1324
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1325
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1326
    // Output the operand specific access functions used by an enc_class
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1327
    // These are only defined when we want to override the default virtual func
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1328
    if (oper->_interface != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1329
      fprintf(fp,"\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1330
      // Check if it is a Memory Interface
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1331
      if ( oper->_interface->is_MemInterface() != NULL ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1332
        MemInterface *mem_interface = oper->_interface->is_MemInterface();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1333
        const char *base = mem_interface->_base;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1334
        if( base != NULL ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1335
          define_oper_interface(fp, *oper, _globalNames, "base", base);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1336
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1337
        char *index = mem_interface->_index;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1338
        if( index != NULL ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1339
          define_oper_interface(fp, *oper, _globalNames, "index", index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1340
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1341
        const char *scale = mem_interface->_scale;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1342
        if( scale != NULL ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1343
          define_oper_interface(fp, *oper, _globalNames, "scale", scale);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1344
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1345
        const char *disp = mem_interface->_disp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1346
        if( disp != NULL ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1347
          define_oper_interface(fp, *oper, _globalNames, "disp", disp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1348
          oper->disp_is_oop(fp, _globalNames);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1349
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1350
        if( oper->stack_slots_only(_globalNames) ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1351
          // should not call this:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1352
          fprintf(fp,"  virtual int       constant_disp() const { return Type::OffsetBot; }");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1353
        } else if ( disp != NULL ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1354
          define_oper_interface(fp, *oper, _globalNames, "constant_disp", disp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1355
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1356
      } // end Memory Interface
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1357
      // Check if it is a Conditional Interface
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1358
      else if (oper->_interface->is_CondInterface() != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1359
        CondInterface *cInterface = oper->_interface->is_CondInterface();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1360
        const char *equal = cInterface->_equal;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1361
        if( equal != NULL ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1362
          define_oper_interface(fp, *oper, _globalNames, "equal", equal);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1363
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1364
        const char *not_equal = cInterface->_not_equal;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1365
        if( not_equal != NULL ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1366
          define_oper_interface(fp, *oper, _globalNames, "not_equal", not_equal);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1367
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1368
        const char *less = cInterface->_less;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1369
        if( less != NULL ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1370
          define_oper_interface(fp, *oper, _globalNames, "less", less);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1371
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1372
        const char *greater_equal = cInterface->_greater_equal;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1373
        if( greater_equal != NULL ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1374
          define_oper_interface(fp, *oper, _globalNames, "greater_equal", greater_equal);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1375
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1376
        const char *less_equal = cInterface->_less_equal;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1377
        if( less_equal != NULL ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1378
          define_oper_interface(fp, *oper, _globalNames, "less_equal", less_equal);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1379
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1380
        const char *greater = cInterface->_greater;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1381
        if( greater != NULL ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1382
          define_oper_interface(fp, *oper, _globalNames, "greater", greater);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1383
        }
20289
35d78de0c547 8024924: Intrinsify java.lang.Math.addExact
rbackman
parents: 16687
diff changeset
  1384
        const char *overflow = cInterface->_overflow;
35d78de0c547 8024924: Intrinsify java.lang.Math.addExact
rbackman
parents: 16687
diff changeset
  1385
        if( overflow != NULL ) {
35d78de0c547 8024924: Intrinsify java.lang.Math.addExact
rbackman
parents: 16687
diff changeset
  1386
          define_oper_interface(fp, *oper, _globalNames, "overflow", overflow);
35d78de0c547 8024924: Intrinsify java.lang.Math.addExact
rbackman
parents: 16687
diff changeset
  1387
        }
35d78de0c547 8024924: Intrinsify java.lang.Math.addExact
rbackman
parents: 16687
diff changeset
  1388
        const char *no_overflow = cInterface->_no_overflow;
35d78de0c547 8024924: Intrinsify java.lang.Math.addExact
rbackman
parents: 16687
diff changeset
  1389
        if( no_overflow != NULL ) {
35d78de0c547 8024924: Intrinsify java.lang.Math.addExact
rbackman
parents: 16687
diff changeset
  1390
          define_oper_interface(fp, *oper, _globalNames, "no_overflow", no_overflow);
35d78de0c547 8024924: Intrinsify java.lang.Math.addExact
rbackman
parents: 16687
diff changeset
  1391
        }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1392
      } // end Conditional Interface
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1393
      // Check if it is a Constant Interface
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1394
      else if (oper->_interface->is_ConstInterface() != NULL ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1395
        assert( oper->num_consts(_globalNames) == 1,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1396
                "Must have one constant when using CONST_INTER encoding");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1397
        if (!strcmp(oper->ideal_type(_globalNames), "ConI")) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1398
          // Access the locally stored constant
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1399
          fprintf(fp,"  virtual intptr_t       constant() const {");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1400
          fprintf(fp,   " return (intptr_t)_c0;");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1401
          fprintf(fp,"  }\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1402
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1403
        else if (!strcmp(oper->ideal_type(_globalNames), "ConP")) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1404
          // Access the locally stored constant
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1405
          fprintf(fp,"  virtual intptr_t       constant() const {");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1406
          fprintf(fp,   " return _c0->get_con();");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1407
          fprintf(fp, " }\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1408
          // Generate query to determine if this pointer is an oop
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  1409
          fprintf(fp,"  virtual relocInfo::relocType           constant_reloc() const {");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  1410
          fprintf(fp,   " return _c0->reloc();");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1411
          fprintf(fp, " }\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1412
        }
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
  1413
        else if (!strcmp(oper->ideal_type(_globalNames), "ConN")) {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
  1414
          // Access the locally stored constant
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
  1415
          fprintf(fp,"  virtual intptr_t       constant() const {");
3180
c589129153a4 6856025: assert(_base >= OopPtr && _base <= KlassPtr,"Not a Java pointer")
never
parents: 2131
diff changeset
  1416
          fprintf(fp,   " return _c0->get_ptrtype()->get_con();");
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
  1417
          fprintf(fp, " }\n");
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
  1418
          // Generate query to determine if this pointer is an oop
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  1419
          fprintf(fp,"  virtual relocInfo::relocType           constant_reloc() const {");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  1420
          fprintf(fp,   " return _c0->get_ptrtype()->reloc();");
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
  1421
          fprintf(fp, " }\n");
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
  1422
        }
13969
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13728
diff changeset
  1423
        else if (!strcmp(oper->ideal_type(_globalNames), "ConNKlass")) {
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13728
diff changeset
  1424
          // Access the locally stored constant
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13728
diff changeset
  1425
          fprintf(fp,"  virtual intptr_t       constant() const {");
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13728
diff changeset
  1426
          fprintf(fp,   " return _c0->get_ptrtype()->get_con();");
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13728
diff changeset
  1427
          fprintf(fp, " }\n");
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13728
diff changeset
  1428
          // Generate query to determine if this pointer is an oop
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13728
diff changeset
  1429
          fprintf(fp,"  virtual relocInfo::relocType           constant_reloc() const {");
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13728
diff changeset
  1430
          fprintf(fp,   " return _c0->get_ptrtype()->reloc();");
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13728
diff changeset
  1431
          fprintf(fp, " }\n");
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13728
diff changeset
  1432
        }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1433
        else if (!strcmp(oper->ideal_type(_globalNames), "ConL")) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1434
          fprintf(fp,"  virtual intptr_t       constant() const {");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1435
          // We don't support addressing modes with > 4Gig offsets.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1436
          // Truncate to int.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1437
          fprintf(fp,   "  return (intptr_t)_c0;");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1438
          fprintf(fp, " }\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1439
          fprintf(fp,"  virtual jlong          constantL() const {");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1440
          fprintf(fp,   " return _c0;");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1441
          fprintf(fp, " }\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1442
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1443
        else if (!strcmp(oper->ideal_type(_globalNames), "ConF")) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1444
          fprintf(fp,"  virtual intptr_t       constant() const {");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1445
          fprintf(fp,   " ShouldNotReachHere(); return 0; ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1446
          fprintf(fp, " }\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1447
          fprintf(fp,"  virtual jfloat         constantF() const {");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1448
          fprintf(fp,   " return (jfloat)_c0;");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1449
          fprintf(fp, " }\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1450
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1451
        else if (!strcmp(oper->ideal_type(_globalNames), "ConD")) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1452
          fprintf(fp,"  virtual intptr_t       constant() const {");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1453
          fprintf(fp,   " ShouldNotReachHere(); return 0; ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1454
          fprintf(fp, " }\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1455
          fprintf(fp,"  virtual jdouble        constantD() const {");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1456
          fprintf(fp,   " return _c0;");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1457
          fprintf(fp, " }\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1458
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1459
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1460
      else if (oper->_interface->is_RegInterface() != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1461
        // make sure that a fixed format string isn't used for an
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1462
        // operand which might be assiged to multiple registers.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1463
        // Otherwise the opto assembly output could be misleading.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1464
        if (oper->_format->_strings.count() != 0 && !oper->is_bound_register()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1465
          syntax_err(oper->_linenum,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1466
                     "Only bound registers can have fixed formats: %s\n",
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1467
                     oper->_ident);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1468
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1469
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1470
      else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1471
        assert( false, "ShouldNotReachHere();");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1472
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1473
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1474
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1475
    fprintf(fp,"\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1476
    // // Currently all XXXOper::hash() methods are identical (990820)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1477
    // declare_hash(fp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1478
    // // Currently all XXXOper::Cmp() methods are identical (990820)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1479
    // declare_cmp(fp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1480
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1481
    // Do not place dump_spec() and Name() into PRODUCT code
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1482
    // int_format and ext_format are not needed in PRODUCT code either
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1483
    fprintf(fp, "#ifndef PRODUCT\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1484
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1485
    // Declare int_format() and ext_format()
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1486
    gen_oper_format(fp, _globalNames, *oper);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1487
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1488
    // Machine independent print functionality for debugging
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1489
    // IF we have constants, create a dump_spec function for the derived class
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1490
    //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1491
    // (1)  virtual void           dump_spec() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1492
    // (2)    st->print("#%d", _c#);        // Constant != ConP
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1493
    //  OR    _c#->dump_on(st);             // Type ConP
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1494
    //  ...
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1495
    // (3)  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1496
    uint num_consts = oper->num_consts(_globalNames);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1497
    if( num_consts > 0 ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1498
      // line (1)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1499
      fprintf(fp, "  virtual void           dump_spec(outputStream *st) const {\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1500
      // generate format string for st->print
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1501
      // Iterate over the component list & spit out the right thing
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1502
      uint i = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1503
      const char *type = oper->ideal_type(_globalNames);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1504
      Component  *comp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1505
      oper->_components.reset();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1506
      if ((comp = oper->_components.iter()) == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1507
        assert(num_consts == 1, "Bad component list detected.\n");
1495
128fe18951ed 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 1055
diff changeset
  1508
        i = dump_spec_constant( fp, type, i, oper );
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1509
        // Check that type actually matched
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1510
        assert( i != 0, "Non-constant operand lacks component list.");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1511
      } // end if NULL
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1512
      else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1513
        // line (2)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1514
        // dump all components
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1515
        oper->_components.reset();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1516
        while((comp = oper->_components.iter()) != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1517
          type = comp->base_type(_globalNames);
1495
128fe18951ed 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 1055
diff changeset
  1518
          i = dump_spec_constant( fp, type, i, NULL );
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1519
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1520
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1521
      // finish line (3)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1522
      fprintf(fp,"  }\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1523
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1524
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1525
    fprintf(fp,"  virtual const char    *Name() const { return \"%s\";}\n",
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1526
            oper->_ident);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1527
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1528
    fprintf(fp,"#endif\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1529
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1530
    // Close definition of this XxxMachOper
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1531
    fprintf(fp,"};\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1532
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1533
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1534
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1535
  // Generate Machine Classes for each instruction defined in AD file
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1536
  fprintf(fp,"\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1537
  fprintf(fp,"//----------------------------Declare classes for Pipelines-----------------\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1538
  declare_pipe_classes(fp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1539
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1540
  // Generate Machine Classes for each instruction defined in AD file
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1541
  fprintf(fp,"\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1542
  fprintf(fp,"//----------------------------Declare classes derived from MachNode----------\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1543
  _instructions.reset();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1544
  InstructForm *instr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1545
  for( ; (instr = (InstructForm*)_instructions.iter()) != NULL; ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1546
    // Ensure this is a machine-world instruction
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1547
    if ( instr->ideal_only() ) continue;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1548
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1549
    // Build class definition for this instruction
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1550
    fprintf(fp,"\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1551
    fprintf(fp,"class %sNode : public %s { \n",
5536
f23c4e2e0d5e 6953576: bottom_type for matched AddPNodes doesn't always agree with ideal
never
parents: 4751
diff changeset
  1552
            instr->_ident, instr->mach_base_class(_globalNames) );
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1553
    fprintf(fp,"private:\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1554
    fprintf(fp,"  MachOper *_opnd_array[%d];\n", instr->num_opnds() );
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1555
    if ( instr->is_ideal_jump() ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1556
      fprintf(fp, "  GrowableArray<Label*> _index2label;\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1557
    }
22835
e1c589c71c23 8024922: PPC64 (part 116): Extend adlc to generate fields into nodes.
goetz
parents: 16687
diff changeset
  1558
e1c589c71c23 8024922: PPC64 (part 116): Extend adlc to generate fields into nodes.
goetz
parents: 16687
diff changeset
  1559
    fprintf(fp, "public:\n");
e1c589c71c23 8024922: PPC64 (part 116): Extend adlc to generate fields into nodes.
goetz
parents: 16687
diff changeset
  1560
e1c589c71c23 8024922: PPC64 (part 116): Extend adlc to generate fields into nodes.
goetz
parents: 16687
diff changeset
  1561
    Attribute *att = instr->_attribs;
e1c589c71c23 8024922: PPC64 (part 116): Extend adlc to generate fields into nodes.
goetz
parents: 16687
diff changeset
  1562
    // Fields of the node specified in the ad file.
e1c589c71c23 8024922: PPC64 (part 116): Extend adlc to generate fields into nodes.
goetz
parents: 16687
diff changeset
  1563
    while (att != NULL) {
e1c589c71c23 8024922: PPC64 (part 116): Extend adlc to generate fields into nodes.
goetz
parents: 16687
diff changeset
  1564
      if (strncmp(att->_ident, "ins_field_", 10) == 0) {
e1c589c71c23 8024922: PPC64 (part 116): Extend adlc to generate fields into nodes.
goetz
parents: 16687
diff changeset
  1565
        const char *field_name = att->_ident+10;
e1c589c71c23 8024922: PPC64 (part 116): Extend adlc to generate fields into nodes.
goetz
parents: 16687
diff changeset
  1566
        const char *field_type = att->_val;
e1c589c71c23 8024922: PPC64 (part 116): Extend adlc to generate fields into nodes.
goetz
parents: 16687
diff changeset
  1567
        fprintf(fp, "  %s _%s;\n", field_type, field_name);
e1c589c71c23 8024922: PPC64 (part 116): Extend adlc to generate fields into nodes.
goetz
parents: 16687
diff changeset
  1568
      }
e1c589c71c23 8024922: PPC64 (part 116): Extend adlc to generate fields into nodes.
goetz
parents: 16687
diff changeset
  1569
      att = (Attribute *)att->_next;
e1c589c71c23 8024922: PPC64 (part 116): Extend adlc to generate fields into nodes.
goetz
parents: 16687
diff changeset
  1570
    }
e1c589c71c23 8024922: PPC64 (part 116): Extend adlc to generate fields into nodes.
goetz
parents: 16687
diff changeset
  1571
13971
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13969
diff changeset
  1572
    fprintf(fp,"  MachOper *opnd_array(uint operand_index) const {\n");
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13969
diff changeset
  1573
    fprintf(fp,"    assert(operand_index < _num_opnds, \"invalid _opnd_array index\");\n");
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13969
diff changeset
  1574
    fprintf(fp,"    return _opnd_array[operand_index];\n");
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13969
diff changeset
  1575
    fprintf(fp,"  }\n");
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13969
diff changeset
  1576
    fprintf(fp,"  void      set_opnd_array(uint operand_index, MachOper *operand) {\n");
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13969
diff changeset
  1577
    fprintf(fp,"    assert(operand_index < _num_opnds, \"invalid _opnd_array index\");\n");
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13969
diff changeset
  1578
    fprintf(fp,"    _opnd_array[operand_index] = operand;\n");
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13969
diff changeset
  1579
    fprintf(fp,"  }\n");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1580
    fprintf(fp,"private:\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1581
    if ( instr->is_ideal_jump() ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1582
      fprintf(fp,"  virtual void           add_case_label(int index_num, Label* blockLabel) {\n");
13971
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13969
diff changeset
  1583
      fprintf(fp,"    _index2label.at_put_grow(index_num, blockLabel);\n");
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13969
diff changeset
  1584
      fprintf(fp,"  }\n");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1585
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1586
    if( can_cisc_spill() && (instr->cisc_spill_alternate() != NULL) ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1587
      fprintf(fp,"  const RegMask  *_cisc_RegMask;\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1588
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1589
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1590
    out_RegMask(fp);                      // output register mask
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1591
    fprintf(fp,"  virtual uint           rule() const { return %s_rule; }\n",
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1592
            instr->_ident);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1593
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1594
    // If this instruction contains a labelOper
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1595
    // Declare Node::methods that set operand Label's contents
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1596
    int label_position = instr->label_position();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1597
    if( label_position != -1 ) {
10266
2ea344c79e33 7079317: Incorrect branch's destination block in PrintoOptoAssembly output
kvn
parents: 10264
diff changeset
  1598
      // Set/Save the label, stored in labelOper::_branch_label
10252
0981ce1c3eef 7063628: Use cbcond on T4
kvn
parents: 7433
diff changeset
  1599
      fprintf(fp,"  virtual void           label_set( Label* label, uint block_num );\n");
10266
2ea344c79e33 7079317: Incorrect branch's destination block in PrintoOptoAssembly output
kvn
parents: 10264
diff changeset
  1600
      fprintf(fp,"  virtual void           save_label( Label** label, uint* block_num );\n");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1601
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1602
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1603
    // If this instruction contains a methodOper
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1604
    // Declare Node::methods that set operand method's contents
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1605
    int method_position = instr->method_position();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1606
    if( method_position != -1 ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1607
      // Set the address method, stored in methodOper::_method
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1608
      fprintf(fp,"  virtual void           method_set( intptr_t method );\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1609
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1610
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1611
    // virtual functions for attributes
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1612
    //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1613
    // Each instruction attribute results in a virtual call of same name.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1614
    // The ins_cost is not handled here.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1615
    Attribute *attr = instr->_attribs;
24008
da7059252295 8038297: Avoid placing CTI immediately following cbcond instruction on T4
iveresov
parents: 22872
diff changeset
  1616
    Attribute *avoid_back_to_back_attr = NULL;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1617
    while (attr != NULL) {
24008
da7059252295 8038297: Avoid placing CTI immediately following cbcond instruction on T4
iveresov
parents: 22872
diff changeset
  1618
      if (strcmp (attr->_ident, "ins_is_TrapBasedCheckNode") == 0) {
da7059252295 8038297: Avoid placing CTI immediately following cbcond instruction on T4
iveresov
parents: 22872
diff changeset
  1619
        fprintf(fp, "  virtual bool           is_TrapBasedCheckNode() const { return %s; }\n", attr->_val);
da7059252295 8038297: Avoid placing CTI immediately following cbcond instruction on T4
iveresov
parents: 22872
diff changeset
  1620
      } else if (strcmp (attr->_ident, "ins_cost") != 0 &&
22856
03ad2cf18166 8029015: PPC64 (part 216): opto: trap based null and range checks
goetz
parents: 22853
diff changeset
  1621
          strncmp(attr->_ident, "ins_field_", 10) != 0 &&
03ad2cf18166 8029015: PPC64 (part 216): opto: trap based null and range checks
goetz
parents: 22853
diff changeset
  1622
          // Must match function in node.hpp: return type bool, no prefix "ins_".
03ad2cf18166 8029015: PPC64 (part 216): opto: trap based null and range checks
goetz
parents: 22853
diff changeset
  1623
          strcmp (attr->_ident, "ins_is_TrapBasedCheckNode") != 0 &&
03ad2cf18166 8029015: PPC64 (part 216): opto: trap based null and range checks
goetz
parents: 22853
diff changeset
  1624
          strcmp (attr->_ident, "ins_short_branch") != 0) {
03ad2cf18166 8029015: PPC64 (part 216): opto: trap based null and range checks
goetz
parents: 22853
diff changeset
  1625
        fprintf(fp, "  virtual int            %s() const { return %s; }\n", attr->_ident, attr->_val);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1626
      }
24008
da7059252295 8038297: Avoid placing CTI immediately following cbcond instruction on T4
iveresov
parents: 22872
diff changeset
  1627
      if (strcmp(attr->_ident, "ins_avoid_back_to_back") == 0) {
da7059252295 8038297: Avoid placing CTI immediately following cbcond instruction on T4
iveresov
parents: 22872
diff changeset
  1628
        avoid_back_to_back_attr = attr;
da7059252295 8038297: Avoid placing CTI immediately following cbcond instruction on T4
iveresov
parents: 22872
diff changeset
  1629
      }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1630
      attr = (Attribute *)attr->_next;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1631
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1632
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1633
    // virtual functions for encode and format
7433
b418028612ad 6961690: load oops from constant table on SPARC
twisti
parents: 5547
diff changeset
  1634
b418028612ad 6961690: load oops from constant table on SPARC
twisti
parents: 5547
diff changeset
  1635
    // Virtual function for evaluating the constant.
b418028612ad 6961690: load oops from constant table on SPARC
twisti
parents: 5547
diff changeset
  1636
    if (instr->is_mach_constant()) {
b418028612ad 6961690: load oops from constant table on SPARC
twisti
parents: 5547
diff changeset
  1637
      fprintf(fp,"  virtual void           eval_constant(Compile* C);\n");
b418028612ad 6961690: load oops from constant table on SPARC
twisti
parents: 5547
diff changeset
  1638
    }
b418028612ad 6961690: load oops from constant table on SPARC
twisti
parents: 5547
diff changeset
  1639
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1640
    // Output the opcode function and the encode function here using the
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1641
    // encoding class information in the _insencode slot.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1642
    if ( instr->_insencode ) {
22844
90f76a40ed8a 8003854: PPC64 (part 115): Introduce PostallocExpand that expands nodes after register allocation
goetz
parents: 22838
diff changeset
  1643
      if (instr->postalloc_expands()) {
90f76a40ed8a 8003854: PPC64 (part 115): Introduce PostallocExpand that expands nodes after register allocation
goetz
parents: 22838
diff changeset
  1644
        fprintf(fp,"  virtual bool           requires_postalloc_expand() const { return true; }\n");
90f76a40ed8a 8003854: PPC64 (part 115): Introduce PostallocExpand that expands nodes after register allocation
goetz
parents: 22838
diff changeset
  1645
        fprintf(fp,"  virtual void           postalloc_expand(GrowableArray <Node *> *nodes, PhaseRegAlloc *ra_);\n");
90f76a40ed8a 8003854: PPC64 (part 115): Introduce PostallocExpand that expands nodes after register allocation
goetz
parents: 22838
diff changeset
  1646
      } else {
90f76a40ed8a 8003854: PPC64 (part 115): Introduce PostallocExpand that expands nodes after register allocation
goetz
parents: 22838
diff changeset
  1647
        fprintf(fp,"  virtual void           emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const;\n");
90f76a40ed8a 8003854: PPC64 (part 115): Introduce PostallocExpand that expands nodes after register allocation
goetz
parents: 22838
diff changeset
  1648
      }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1649
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1650
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1651
    // virtual function for getting the size of an instruction
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1652
    if ( instr->_size ) {
7433
b418028612ad 6961690: load oops from constant table on SPARC
twisti
parents: 5547
diff changeset
  1653
      fprintf(fp,"  virtual uint           size(PhaseRegAlloc *ra_) const;\n");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1654
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1655
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1656
    // Return the top-level ideal opcode.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1657
    // Use MachNode::ideal_Opcode() for nodes based on MachNode class
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1658
    // if the ideal_Opcode == Op_Node.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1659
    if ( strcmp("Node", instr->ideal_Opcode(_globalNames)) != 0 ||
5536
f23c4e2e0d5e 6953576: bottom_type for matched AddPNodes doesn't always agree with ideal
never
parents: 4751
diff changeset
  1660
         strcmp("MachNode", instr->mach_base_class(_globalNames)) != 0 ) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1661
      fprintf(fp,"  virtual int            ideal_Opcode() const { return Op_%s; }\n",
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1662
            instr->ideal_Opcode(_globalNames) );
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1663
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1664
22850
4e69ce7e1101 8028580: PPC64 (part 114/120): Support for Call nodes with constants.
goetz
parents: 22844
diff changeset
  1665
    if (instr->needs_constant_base() &&
4e69ce7e1101 8028580: PPC64 (part 114/120): Support for Call nodes with constants.
goetz
parents: 22844
diff changeset
  1666
        !instr->is_mach_constant()) {  // These inherit the funcion from MachConstantNode.
22865
3b8857d7b3cc 8030863: PPC64: (part 220): ConstantTableBase for calls between args and jvms
goetz
parents: 22856
diff changeset
  1667
      fprintf(fp,"  virtual uint           mach_constant_base_node_input() const { ");
3b8857d7b3cc 8030863: PPC64: (part 220): ConstantTableBase for calls between args and jvms
goetz
parents: 22856
diff changeset
  1668
      if (instr->is_ideal_call() != Form::invalid_type &&
3b8857d7b3cc 8030863: PPC64: (part 220): ConstantTableBase for calls between args and jvms
goetz
parents: 22856
diff changeset
  1669
          instr->is_ideal_call() != Form::JAVA_LEAF) {
3b8857d7b3cc 8030863: PPC64: (part 220): ConstantTableBase for calls between args and jvms
goetz
parents: 22856
diff changeset
  1670
        // MachConstantBase goes behind arguments, but before jvms.
3b8857d7b3cc 8030863: PPC64: (part 220): ConstantTableBase for calls between args and jvms
goetz
parents: 22856
diff changeset
  1671
        fprintf(fp,"assert(tf() && tf()->domain(), \"\"); return tf()->domain()->cnt();");
3b8857d7b3cc 8030863: PPC64: (part 220): ConstantTableBase for calls between args and jvms
goetz
parents: 22856
diff changeset
  1672
      } else {
3b8857d7b3cc 8030863: PPC64: (part 220): ConstantTableBase for calls between args and jvms
goetz
parents: 22856
diff changeset
  1673
        fprintf(fp,"return req()-1;");
3b8857d7b3cc 8030863: PPC64: (part 220): ConstantTableBase for calls between args and jvms
goetz
parents: 22856
diff changeset
  1674
      }
3b8857d7b3cc 8030863: PPC64: (part 220): ConstantTableBase for calls between args and jvms
goetz
parents: 22856
diff changeset
  1675
      fprintf(fp," }\n");
22850
4e69ce7e1101 8028580: PPC64 (part 114/120): Support for Call nodes with constants.
goetz
parents: 22844
diff changeset
  1676
    }
4e69ce7e1101 8028580: PPC64 (part 114/120): Support for Call nodes with constants.
goetz
parents: 22844
diff changeset
  1677
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1678
    // Allow machine-independent optimization, invert the sense of the IF test
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1679
    if( instr->is_ideal_if() ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1680
      fprintf(fp,"  virtual void           negate() { \n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1681
      // Identify which operand contains the negate(able) ideal condition code
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1682
      int   idx = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1683
      instr->_components.reset();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1684
      for( Component *comp; (comp = instr->_components.iter()) != NULL; ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1685
        // Check that component is an operand
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1686
        Form *form = (Form*)_globalNames[comp->_type];
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1687
        OperandForm *opForm = form ? form->is_operand() : NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1688
        if( opForm == NULL ) continue;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1689
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1690
        // Lookup the position of the operand in the instruction.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1691
        if( opForm->is_ideal_bool() ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1692
          idx = instr->operand_position(comp->_name, comp->_usedef);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1693
          assert( idx != NameList::Not_in_list, "Did not find component in list that contained it.");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1694
          break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1695
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1696
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1697
      fprintf(fp,"    opnd_array(%d)->negate();\n", idx);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1698
      fprintf(fp,"    _prob = 1.0f - _prob;\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1699
      fprintf(fp,"  };\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1700
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1701
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1702
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1703
    // Identify which input register matches the input register.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1704
    uint  matching_input = instr->two_address(_globalNames);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1705
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1706
    // Generate the method if it returns != 0 otherwise use MachNode::two_adr()
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1707
    if( matching_input != 0 ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1708
      fprintf(fp,"  virtual uint           two_adr() const  ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1709
      fprintf(fp,"{ return oper_input_base()");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1710
      for( uint i = 2; i <= matching_input; i++ )
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1711
        fprintf(fp," + opnd_array(%d)->num_edges()",i-1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1712
      fprintf(fp,"; }\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1713
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1714
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1715
    // Declare cisc_version, if applicable
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1716
    //   MachNode *cisc_version( int offset /* ,... */ );
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1717
    instr->declare_cisc_version(*this, fp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1718
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1719
    // If there is an explicit peephole rule, build it
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1720
    if ( instr->peepholes() != NULL ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1721
      fprintf(fp,"  virtual MachNode      *peephole(Block *block, int block_index, PhaseRegAlloc *ra_, int &deleted, Compile *C);\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1722
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1723
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1724
    // Output the declaration for number of relocation entries
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1725
    if ( instr->reloc(_globalNames) != 0 ) {
13971
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13969
diff changeset
  1726
      fprintf(fp,"  virtual int            reloc() const;\n");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1727
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1728
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1729
    if (instr->alignment() != 1) {
13971
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13969
diff changeset
  1730
      fprintf(fp,"  virtual int            alignment_required() const { return %d; }\n", instr->alignment());
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13969
diff changeset
  1731
      fprintf(fp,"  virtual int            compute_padding(int current_offset) const;\n");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1732
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1733
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1734
    // Starting point for inputs matcher wants.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1735
    // Use MachNode::oper_input_base() for nodes based on MachNode class
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1736
    // if the base == 1.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1737
    if ( instr->oper_input_base(_globalNames) != 1 ||
5536
f23c4e2e0d5e 6953576: bottom_type for matched AddPNodes doesn't always agree with ideal
never
parents: 4751
diff changeset
  1738
         strcmp("MachNode", instr->mach_base_class(_globalNames)) != 0 ) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1739
      fprintf(fp,"  virtual uint           oper_input_base() const { return %d; }\n",
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1740
            instr->oper_input_base(_globalNames));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1741
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1742
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1743
    // Make the constructor and following methods 'public:'
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1744
    fprintf(fp,"public:\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1745
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1746
    // Constructor
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1747
    if ( instr->is_ideal_jump() ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1748
      fprintf(fp,"  %sNode() : _index2label(MinJumpTableSize*2) { ", instr->_ident);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1749
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1750
      fprintf(fp,"  %sNode() { ", instr->_ident);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1751
      if( can_cisc_spill() && (instr->cisc_spill_alternate() != NULL) ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1752
        fprintf(fp,"_cisc_RegMask = NULL; ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1753
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1754
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1755
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1756
    fprintf(fp," _num_opnds = %d; _opnds = _opnd_array; ", instr->num_opnds());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1757
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1758
    bool node_flags_set = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1759
    // flag: if this instruction matches an ideal 'Copy*' node
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1760
    if ( instr->is_ideal_copy() != 0 ) {
10255
bab46e6f7661 7069452: Cleanup NodeFlags
kvn
parents: 10252
diff changeset
  1761
      fprintf(fp,"init_flags(Flag_is_Copy");
bab46e6f7661 7069452: Cleanup NodeFlags
kvn
parents: 10252
diff changeset
  1762
      node_flags_set = true;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1763
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1764
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1765
    // Is an instruction is a constant?  If so, get its type
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1766
    Form::DataType  data_type;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1767
    const char     *opType = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1768
    const char     *result = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1769
    data_type    = instr->is_chain_of_constant(_globalNames, opType, result);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1770
    // Check if this instruction is a constant
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1771
    if ( data_type != Form::none ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1772
      if ( node_flags_set ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1773
        fprintf(fp," | Flag_is_Con");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1774
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1775
        fprintf(fp,"init_flags(Flag_is_Con");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1776
        node_flags_set = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1777
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1778
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1779
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1780
    // flag: if this instruction is cisc alternate
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1781
    if ( can_cisc_spill() && instr->is_cisc_alternate() ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1782
      if ( node_flags_set ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1783
        fprintf(fp," | Flag_is_cisc_alternate");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1784
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1785
        fprintf(fp,"init_flags(Flag_is_cisc_alternate");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1786
        node_flags_set = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1787
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1788
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1789
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1790
    // flag: if this instruction has short branch form
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1791
    if ( instr->has_short_branch_form() ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1792
      if ( node_flags_set ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1793
        fprintf(fp," | Flag_may_be_short_branch");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1794
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1795
        fprintf(fp,"init_flags(Flag_may_be_short_branch");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1796
        node_flags_set = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1797
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1798
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1799
10264
6879f93d268d 7063629: use cbcond in C2 generated code on T4
kvn
parents: 10255
diff changeset
  1800
    // flag: if this instruction should not be generated back to back.
24008
da7059252295 8038297: Avoid placing CTI immediately following cbcond instruction on T4
iveresov
parents: 22872
diff changeset
  1801
    if (avoid_back_to_back_attr != NULL) {
da7059252295 8038297: Avoid placing CTI immediately following cbcond instruction on T4
iveresov
parents: 22872
diff changeset
  1802
      if (node_flags_set) {
da7059252295 8038297: Avoid placing CTI immediately following cbcond instruction on T4
iveresov
parents: 22872
diff changeset
  1803
        fprintf(fp," | (%s)", avoid_back_to_back_attr->_val);
10264
6879f93d268d 7063629: use cbcond in C2 generated code on T4
kvn
parents: 10255
diff changeset
  1804
      } else {
24008
da7059252295 8038297: Avoid placing CTI immediately following cbcond instruction on T4
iveresov
parents: 22872
diff changeset
  1805
        fprintf(fp,"init_flags((%s)", avoid_back_to_back_attr->_val);
10264
6879f93d268d 7063629: use cbcond in C2 generated code on T4
kvn
parents: 10255
diff changeset
  1806
        node_flags_set = true;
6879f93d268d 7063629: use cbcond in C2 generated code on T4
kvn
parents: 10255
diff changeset
  1807
      }
6879f93d268d 7063629: use cbcond in C2 generated code on T4
kvn
parents: 10255
diff changeset
  1808
    }
6879f93d268d 7063629: use cbcond in C2 generated code on T4
kvn
parents: 10255
diff changeset
  1809
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1810
    // Check if machine instructions that USE memory, but do not DEF memory,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1811
    // depend upon a node that defines memory in machine-independent graph.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1812
    if ( instr->needs_anti_dependence_check(_globalNames) ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1813
      if ( node_flags_set ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1814
        fprintf(fp," | Flag_needs_anti_dependence_check");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1815
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1816
        fprintf(fp,"init_flags(Flag_needs_anti_dependence_check");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1817
        node_flags_set = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1818
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1819
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1820
11196
a310a659c580 7077312: Provide a CALL effect for instruct declaration in the ad file
roland
parents: 10266
diff changeset
  1821
    // flag: if this instruction is implemented with a call
a310a659c580 7077312: Provide a CALL effect for instruct declaration in the ad file
roland
parents: 10266
diff changeset
  1822
    if ( instr->_has_call ) {
a310a659c580 7077312: Provide a CALL effect for instruct declaration in the ad file
roland
parents: 10266
diff changeset
  1823
      if ( node_flags_set ) {
a310a659c580 7077312: Provide a CALL effect for instruct declaration in the ad file
roland
parents: 10266
diff changeset
  1824
        fprintf(fp," | Flag_has_call");
a310a659c580 7077312: Provide a CALL effect for instruct declaration in the ad file
roland
parents: 10266
diff changeset
  1825
      } else {
a310a659c580 7077312: Provide a CALL effect for instruct declaration in the ad file
roland
parents: 10266
diff changeset
  1826
        fprintf(fp,"init_flags(Flag_has_call");
a310a659c580 7077312: Provide a CALL effect for instruct declaration in the ad file
roland
parents: 10266
diff changeset
  1827
        node_flags_set = true;
a310a659c580 7077312: Provide a CALL effect for instruct declaration in the ad file
roland
parents: 10266
diff changeset
  1828
      }
a310a659c580 7077312: Provide a CALL effect for instruct declaration in the ad file
roland
parents: 10266
diff changeset
  1829
    }
a310a659c580 7077312: Provide a CALL effect for instruct declaration in the ad file
roland
parents: 10266
diff changeset
  1830
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1831
    if ( node_flags_set ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1832
      fprintf(fp,"); ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1833
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1834
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1835
    fprintf(fp,"}\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1836
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1837
    // size_of, used by base class's clone to obtain the correct size.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1838
    fprintf(fp,"  virtual uint           size_of() const {");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1839
    fprintf(fp,   " return sizeof(%sNode);", instr->_ident);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1840
    fprintf(fp, " }\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1841
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1842
    // Virtual methods which are only generated to override base class
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1843
    if( instr->expands() || instr->needs_projections() ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1844
        instr->has_temps() ||
7433
b418028612ad 6961690: load oops from constant table on SPARC
twisti
parents: 5547
diff changeset
  1845
        instr->is_mach_constant() ||
22850
4e69ce7e1101 8028580: PPC64 (part 114/120): Support for Call nodes with constants.
goetz
parents: 22844
diff changeset
  1846
        instr->needs_constant_base() ||
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1847
        instr->_matrule != NULL &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1848
        instr->num_opnds() != instr->num_unique_opnds() ) {
4751
9418f690831d 6916644: C2 compiler crash on x86
never
parents: 3180
diff changeset
  1849
      fprintf(fp,"  virtual MachNode      *Expand(State *state, Node_List &proj_list, Node* mem);\n");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1850
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1851
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1852
    if (instr->is_pinned(_globalNames)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1853
      fprintf(fp,"  virtual bool           pinned() const { return ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1854
      if (instr->is_parm(_globalNames)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1855
        fprintf(fp,"_in[0]->pinned();");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1856
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1857
        fprintf(fp,"true;");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1858
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1859
      fprintf(fp," }\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1860
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1861
    if (instr->is_projection(_globalNames)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1862
      fprintf(fp,"  virtual const Node *is_block_proj() const { return this; }\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1863
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1864
    if ( instr->num_post_match_opnds() != 0
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1865
         || instr->is_chain_of_constant(_globalNames) ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1866
      fprintf(fp,"  friend MachNode *State::MachNodeGenerator(int opcode, Compile* C);\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1867
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1868
    if ( instr->rematerialize(_globalNames, get_registers()) ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1869
      fprintf(fp,"  // Rematerialize %s\n", instr->_ident);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1870
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1871
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1872
    // Declare short branch methods, if applicable
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1873
    instr->declare_short_branch_methods(fp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1874
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1875
    // See if there is an "ins_pipe" declaration for this instruction
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1876
    if (instr->_ins_pipe) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1877
      fprintf(fp,"  static  const Pipeline *pipeline_class();\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1878
      fprintf(fp,"  virtual const Pipeline *pipeline() const;\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1879
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1880
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1881
    // Generate virtual function for MachNodeX::bottom_type when necessary
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1882
    //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1883
    // Note on accuracy:  Pointer-types of machine nodes need to be accurate,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1884
    // or else alias analysis on the matched graph may produce bad code.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1885
    // Moreover, the aliasing decisions made on machine-node graph must be
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1886
    // no less accurate than those made on the ideal graph, or else the graph
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1887
    // may fail to schedule.  (Reason:  Memory ops which are reordered in
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1888
    // the ideal graph might look interdependent in the machine graph,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1889
    // thereby removing degrees of scheduling freedom that the optimizer
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1890
    // assumed would be available.)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1891
    //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1892
    // %%% We should handle many of these cases with an explicit ADL clause:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1893
    // instruct foo() %{ ... bottom_type(TypeRawPtr::BOTTOM); ... %}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1894
    if( data_type != Form::none ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1895
      // A constant's bottom_type returns a Type containing its constant value
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1896
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1897
      // !!!!!
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1898
      // Convert all ints, floats, ... to machine-independent TypeXs
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1899
      // as is done for pointers
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1900
      //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1901
      // Construct appropriate constant type containing the constant value.
13971
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13969
diff changeset
  1902
      fprintf(fp,"  virtual const class Type *bottom_type() const {\n");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1903
      switch( data_type ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1904
      case Form::idealI:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1905
        fprintf(fp,"    return  TypeInt::make(opnd_array(1)->constant());\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1906
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1907
      case Form::idealP:
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
  1908
      case Form::idealN:
13969
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13728
diff changeset
  1909
      case Form::idealNKlass:
2129
e810a33b5c67 6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents: 1497
diff changeset
  1910
        fprintf(fp,"    return  opnd_array(1)->type();\n");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1911
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1912
      case Form::idealD:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1913
        fprintf(fp,"    return  TypeD::make(opnd_array(1)->constantD());\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1914
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1915
      case Form::idealF:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1916
        fprintf(fp,"    return  TypeF::make(opnd_array(1)->constantF());\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1917
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1918
      case Form::idealL:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1919
        fprintf(fp,"    return  TypeLong::make(opnd_array(1)->constantL());\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1920
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1921
      default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1922
        assert( false, "Unimplemented()" );
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1923
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1924
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1925
      fprintf(fp,"  };\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1926
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1927
/*    else if ( instr->_matrule && instr->_matrule->_rChild &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1928
        (  strcmp("ConvF2I",instr->_matrule->_rChild->_opType)==0
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1929
        || strcmp("ConvD2I",instr->_matrule->_rChild->_opType)==0 ) ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1930
      // !!!!! !!!!!
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1931
      // Provide explicit bottom type for conversions to int
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1932
      // On Intel the result operand is a stackSlot, untyped.
13971
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13969
diff changeset
  1933
      fprintf(fp,"  virtual const class Type *bottom_type() const {");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1934
      fprintf(fp,   " return  TypeInt::INT;");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1935
      fprintf(fp, " };\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1936
    }*/
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1937
    else if( instr->is_ideal_copy() &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1938
              !strcmp(instr->_matrule->_lChild->_opType,"stackSlotP") ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1939
      // !!!!!
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1940
      // Special hack for ideal Copy of pointer.  Bottom type is oop or not depending on input.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1941
      fprintf(fp,"  const Type            *bottom_type() const { return in(1)->bottom_type(); } // Copy?\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1942
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1943
    else if( instr->is_ideal_loadPC() ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1944
      // LoadPCNode provides the return address of a call to native code.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1945
      // Define its bottom type to be TypeRawPtr::BOTTOM instead of TypePtr::BOTTOM
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1946
      // since it is a pointer to an internal VM location and must have a zero offset.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1947
      // Allocation detects derived pointers, in part, by their non-zero offsets.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1948
      fprintf(fp,"  const Type            *bottom_type() const { return TypeRawPtr::BOTTOM; } // LoadPC?\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1949
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1950
    else if( instr->is_ideal_box() ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1951
      // BoxNode provides the address of a stack slot.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1952
      // Define its bottom type to be TypeRawPtr::BOTTOM instead of TypePtr::BOTTOM
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1953
      // This prevent s insert_anti_dependencies from complaining. It will
13971
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13969
diff changeset
  1954
      // complain if it sees that the pointer base is TypePtr::BOTTOM since
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1955
      // it doesn't understand what that might alias.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1956
      fprintf(fp,"  const Type            *bottom_type() const { return TypeRawPtr::BOTTOM; } // Box?\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1957
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1958
    else if( instr->_matrule && instr->_matrule->_rChild && !strcmp(instr->_matrule->_rChild->_opType,"CMoveP") ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1959
      int offset = 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1960
      // Special special hack to see if the Cmp? has been incorporated in the conditional move
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1961
      MatchNode *rl = instr->_matrule->_rChild->_lChild;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1962
      if( rl && !strcmp(rl->_opType, "Binary") ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1963
          MatchNode *rlr = rl->_rChild;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1964
          if (rlr && strncmp(rlr->_opType, "Cmp", 3) == 0)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1965
            offset = 2;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1966
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1967
      // Special hack for ideal CMoveP; ideal type depends on inputs
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1968
      fprintf(fp,"  const Type            *bottom_type() const { const Type *t = in(oper_input_base()+%d)->bottom_type(); return (req() <= oper_input_base()+%d) ? t : t->meet(in(oper_input_base()+%d)->bottom_type()); } // CMoveP\n",
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1969
        offset, offset+1, offset+1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1970
    }
1055
f4fb9fb08038 6731641: assert(m->adr_type() == mach->adr_type(),"matcher should not change adr type")
kvn
parents: 670
diff changeset
  1971
    else if( instr->_matrule && instr->_matrule->_rChild && !strcmp(instr->_matrule->_rChild->_opType,"CMoveN") ) {
f4fb9fb08038 6731641: assert(m->adr_type() == mach->adr_type(),"matcher should not change adr type")
kvn
parents: 670
diff changeset
  1972
      int offset = 1;
f4fb9fb08038 6731641: assert(m->adr_type() == mach->adr_type(),"matcher should not change adr type")
kvn
parents: 670
diff changeset
  1973
      // Special special hack to see if the Cmp? has been incorporated in the conditional move
f4fb9fb08038 6731641: assert(m->adr_type() == mach->adr_type(),"matcher should not change adr type")
kvn
parents: 670
diff changeset
  1974
      MatchNode *rl = instr->_matrule->_rChild->_lChild;
f4fb9fb08038 6731641: assert(m->adr_type() == mach->adr_type(),"matcher should not change adr type")
kvn
parents: 670
diff changeset
  1975
      if( rl && !strcmp(rl->_opType, "Binary") ) {
f4fb9fb08038 6731641: assert(m->adr_type() == mach->adr_type(),"matcher should not change adr type")
kvn
parents: 670
diff changeset
  1976
          MatchNode *rlr = rl->_rChild;
f4fb9fb08038 6731641: assert(m->adr_type() == mach->adr_type(),"matcher should not change adr type")
kvn
parents: 670
diff changeset
  1977
          if (rlr && strncmp(rlr->_opType, "Cmp", 3) == 0)
f4fb9fb08038 6731641: assert(m->adr_type() == mach->adr_type(),"matcher should not change adr type")
kvn
parents: 670
diff changeset
  1978
            offset = 2;
f4fb9fb08038 6731641: assert(m->adr_type() == mach->adr_type(),"matcher should not change adr type")
kvn
parents: 670
diff changeset
  1979
      }
f4fb9fb08038 6731641: assert(m->adr_type() == mach->adr_type(),"matcher should not change adr type")
kvn
parents: 670
diff changeset
  1980
      // Special hack for ideal CMoveN; ideal type depends on inputs
f4fb9fb08038 6731641: assert(m->adr_type() == mach->adr_type(),"matcher should not change adr type")
kvn
parents: 670
diff changeset
  1981
      fprintf(fp,"  const Type            *bottom_type() const { const Type *t = in(oper_input_base()+%d)->bottom_type(); return (req() <= oper_input_base()+%d) ? t : t->meet(in(oper_input_base()+%d)->bottom_type()); } // CMoveN\n",
f4fb9fb08038 6731641: assert(m->adr_type() == mach->adr_type(),"matcher should not change adr type")
kvn
parents: 670
diff changeset
  1982
        offset, offset+1, offset+1);
f4fb9fb08038 6731641: assert(m->adr_type() == mach->adr_type(),"matcher should not change adr type")
kvn
parents: 670
diff changeset
  1983
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1984
    else if (instr->is_tls_instruction()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1985
      // Special hack for tlsLoadP
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1986
      fprintf(fp,"  const Type            *bottom_type() const { return TypeRawPtr::BOTTOM; } // tlsLoadP\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1987
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1988
    else if ( instr->is_ideal_if() ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1989
      fprintf(fp,"  const Type            *bottom_type() const { return TypeTuple::IFBOTH; } // matched IfNode\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1990
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1991
    else if ( instr->is_ideal_membar() ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1992
      fprintf(fp,"  const Type            *bottom_type() const { return TypeTuple::MEMBAR; } // matched MemBar\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1993
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1994
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1995
    // Check where 'ideal_type' must be customized
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1996
    /*
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1997
    if ( instr->_matrule && instr->_matrule->_rChild &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1998
        (  strcmp("ConvF2I",instr->_matrule->_rChild->_opType)==0
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1999
        || strcmp("ConvD2I",instr->_matrule->_rChild->_opType)==0 ) ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2000
      fprintf(fp,"  virtual uint           ideal_reg() const { return Compile::current()->matcher()->base2reg[Type::Int]; }\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2001
    }*/
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2002
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2003
    // Analyze machine instructions that either USE or DEF memory.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2004
    int memory_operand = instr->memory_operand(_globalNames);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2005
    // Some guys kill all of memory
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2006
    if ( instr->is_wide_memory_kill(_globalNames) ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2007
      memory_operand = InstructForm::MANY_MEMORY_OPERANDS;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2008
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2009
    if ( memory_operand != InstructForm::NO_MEMORY_OPERAND ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2010
      if( memory_operand == InstructForm::MANY_MEMORY_OPERANDS ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2011
        fprintf(fp,"  virtual const TypePtr *adr_type() const;\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2012
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2013
      fprintf(fp,"  virtual const MachOper *memory_operand() const;\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2014
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2015
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2016
    fprintf(fp, "#ifndef PRODUCT\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2017
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2018
    // virtual function for generating the user's assembler output
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2019
    gen_inst_format(fp, _globalNames,*instr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2020
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2021
    // Machine independent print functionality for debugging
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2022
    fprintf(fp,"  virtual const char    *Name() const { return \"%s\";}\n",
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2023
            instr->_ident);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2024
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2025
    fprintf(fp, "#endif\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2026
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2027
    // Close definition of this XxxMachNode
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2028
    fprintf(fp,"};\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2029
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2030
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2031
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2032
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2033
void ArchDesc::defineStateClass(FILE *fp) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2034
  static const char *state__valid    = "_valid[((uint)index) >> 5] &  (0x1 << (((uint)index) & 0x0001F))";
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2035
  static const char *state__set_valid= "_valid[((uint)index) >> 5] |= (0x1 << (((uint)index) & 0x0001F))";
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2036
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2037
  fprintf(fp,"\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2038
  fprintf(fp,"// MACROS to inline and constant fold State::valid(index)...\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2039
  fprintf(fp,"// when given a constant 'index' in dfa_<arch>.cpp\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2040
  fprintf(fp,"//   uint word   = index >> 5;       // Shift out bit position\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2041
  fprintf(fp,"//   uint bitpos = index & 0x0001F;  // Mask off word bits\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2042
  fprintf(fp,"#define STATE__VALID(index) ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2043
  fprintf(fp,"    (%s)\n", state__valid);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2044
  fprintf(fp,"\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2045
  fprintf(fp,"#define STATE__NOT_YET_VALID(index) ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2046
  fprintf(fp,"  ( (%s) == 0 )\n", state__valid);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2047
  fprintf(fp,"\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2048
  fprintf(fp,"#define STATE__VALID_CHILD(state,index) ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2049
  fprintf(fp,"  ( state && (state->%s) )\n", state__valid);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2050
  fprintf(fp,"\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2051
  fprintf(fp,"#define STATE__SET_VALID(index) ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2052
  fprintf(fp,"  (%s)\n", state__set_valid);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2053
  fprintf(fp,"\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2054
  fprintf(fp,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2055
          "//---------------------------State-------------------------------------------\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2056
  fprintf(fp,"// State contains an integral cost vector, indexed by machine operand opcodes,\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2057
  fprintf(fp,"// a rule vector consisting of machine operand/instruction opcodes, and also\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2058
  fprintf(fp,"// indexed by machine operand opcodes, pointers to the children in the label\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2059
  fprintf(fp,"// tree generated by the Label routines in ideal nodes (currently limited to\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2060
  fprintf(fp,"// two for convenience, but this could change).\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2061
  fprintf(fp,"class State : public ResourceObj {\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2062
  fprintf(fp,"public:\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2063
  fprintf(fp,"  int    _id;         // State identifier\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2064
  fprintf(fp,"  Node  *_leaf;       // Ideal (non-machine-node) leaf of match tree\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2065
  fprintf(fp,"  State *_kids[2];       // Children of state node in label tree\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2066
  fprintf(fp,"  unsigned int _cost[_LAST_MACH_OPER];  // Cost vector, indexed by operand opcodes\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2067
  fprintf(fp,"  unsigned int _rule[_LAST_MACH_OPER];  // Rule vector, indexed by operand opcodes\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2068
  fprintf(fp,"  unsigned int _valid[(_LAST_MACH_OPER/32)+1]; // Bit Map of valid Cost/Rule entries\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2069
  fprintf(fp,"\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2070
  fprintf(fp,"  State(void);                      // Constructor\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2071
  fprintf(fp,"  DEBUG_ONLY( ~State(void); )       // Destructor\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2072
  fprintf(fp,"\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2073
  fprintf(fp,"  // Methods created by ADLC and invoked by Reduce\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2074
  fprintf(fp,"  MachOper *MachOperGenerator( int opcode, Compile* C );\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2075
  fprintf(fp,"  MachNode *MachNodeGenerator( int opcode, Compile* C );\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2076
  fprintf(fp,"\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2077
  fprintf(fp,"  // Assign a state to a node, definition of method produced by ADLC\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2078
  fprintf(fp,"  bool DFA( int opcode, const Node *ideal );\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2079
  fprintf(fp,"\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2080
  fprintf(fp,"  // Access function for _valid bit vector\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2081
  fprintf(fp,"  bool valid(uint index) {\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2082
  fprintf(fp,"    return( STATE__VALID(index) != 0 );\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2083
  fprintf(fp,"  }\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2084
  fprintf(fp,"\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2085
  fprintf(fp,"  // Set function for _valid bit vector\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2086
  fprintf(fp,"  void set_valid(uint index) {\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2087
  fprintf(fp,"    STATE__SET_VALID(index);\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2088
  fprintf(fp,"  }\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2089
  fprintf(fp,"\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2090
  fprintf(fp,"#ifndef PRODUCT\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2091
  fprintf(fp,"  void dump();                // Debugging prints\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2092
  fprintf(fp,"  void dump(int depth);\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2093
  fprintf(fp,"#endif\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2094
  if (_dfa_small) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2095
    // Generate the routine name we'll need
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2096
    for (int i = 1; i < _last_opcode; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2097
      if (_mlistab[i] == NULL) continue;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2098
      fprintf(fp, "  void  _sub_Op_%s(const Node *n);\n", NodeClassNames[i]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2099
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2100
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2101
  fprintf(fp,"};\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2102
  fprintf(fp,"\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2103
  fprintf(fp,"\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2104
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2105
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2106
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2107
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2108
//---------------------------buildMachOperEnum---------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2109
// Build enumeration for densely packed operands.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2110
// This enumeration is used to index into the arrays in the State objects
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2111
// that indicate cost and a successfull rule match.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2112
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2113
// Information needed to generate the ReduceOp mapping for the DFA
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2114
class OutputMachOperands : public OutputMap {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2115
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2116
  OutputMachOperands(FILE *hpp, FILE *cpp, FormDict &globals, ArchDesc &AD)
13971
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13969
diff changeset
  2117
    : OutputMap(hpp, cpp, globals, AD, "MachOperands") {};
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2118
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2119
  void declaration() { }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2120
  void definition()  { fprintf(_cpp, "enum MachOperands {\n"); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2121
  void closing()     { fprintf(_cpp, "  _LAST_MACH_OPER\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2122
                       OutputMap::closing();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2123
  }
16687
ffab289acdc1 8006016: Memory leak at hotspot/src/share/vm/adlc/output_c.cpp
neliasso
parents: 13971
diff changeset
  2124
  void map(OpClassForm &opc)  {
ffab289acdc1 8006016: Memory leak at hotspot/src/share/vm/adlc/output_c.cpp
neliasso
parents: 13971
diff changeset
  2125
    const char* opc_ident_to_upper = _AD.machOperEnum(opc._ident);
ffab289acdc1 8006016: Memory leak at hotspot/src/share/vm/adlc/output_c.cpp
neliasso
parents: 13971
diff changeset
  2126
    fprintf(_cpp, "  %s", opc_ident_to_upper);
ffab289acdc1 8006016: Memory leak at hotspot/src/share/vm/adlc/output_c.cpp
neliasso
parents: 13971
diff changeset
  2127
    delete[] opc_ident_to_upper;
ffab289acdc1 8006016: Memory leak at hotspot/src/share/vm/adlc/output_c.cpp
neliasso
parents: 13971
diff changeset
  2128
  }
ffab289acdc1 8006016: Memory leak at hotspot/src/share/vm/adlc/output_c.cpp
neliasso
parents: 13971
diff changeset
  2129
  void map(OperandForm &oper) {
ffab289acdc1 8006016: Memory leak at hotspot/src/share/vm/adlc/output_c.cpp
neliasso
parents: 13971
diff changeset
  2130
    const char* oper_ident_to_upper = _AD.machOperEnum(oper._ident);
ffab289acdc1 8006016: Memory leak at hotspot/src/share/vm/adlc/output_c.cpp
neliasso
parents: 13971
diff changeset
  2131
    fprintf(_cpp, "  %s", oper_ident_to_upper);
ffab289acdc1 8006016: Memory leak at hotspot/src/share/vm/adlc/output_c.cpp
neliasso
parents: 13971
diff changeset
  2132
    delete[] oper_ident_to_upper;
ffab289acdc1 8006016: Memory leak at hotspot/src/share/vm/adlc/output_c.cpp
neliasso
parents: 13971
diff changeset
  2133
  }
ffab289acdc1 8006016: Memory leak at hotspot/src/share/vm/adlc/output_c.cpp
neliasso
parents: 13971
diff changeset
  2134
  void map(char *name) {
ffab289acdc1 8006016: Memory leak at hotspot/src/share/vm/adlc/output_c.cpp
neliasso
parents: 13971
diff changeset
  2135
    const char* name_to_upper = _AD.machOperEnum(name);
ffab289acdc1 8006016: Memory leak at hotspot/src/share/vm/adlc/output_c.cpp
neliasso
parents: 13971
diff changeset
  2136
    fprintf(_cpp, "  %s", name_to_upper);
ffab289acdc1 8006016: Memory leak at hotspot/src/share/vm/adlc/output_c.cpp
neliasso
parents: 13971
diff changeset
  2137
    delete[] name_to_upper;
ffab289acdc1 8006016: Memory leak at hotspot/src/share/vm/adlc/output_c.cpp
neliasso
parents: 13971
diff changeset
  2138
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2139
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2140
  bool do_instructions()      { return false; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2141
  void map(InstructForm &inst){ assert( false, "ShouldNotCallThis()"); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2142
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2143
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2144
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2145
void ArchDesc::buildMachOperEnum(FILE *fp_hpp) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2146
  // Construct the table for MachOpcodes
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2147
  OutputMachOperands output_mach_operands(fp_hpp, fp_hpp, _globalNames, *this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2148
  build_map(output_mach_operands);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2149
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2150
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2151
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2152
//---------------------------buildMachEnum----------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2153
// Build enumeration for all MachOpers and all MachNodes
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2154
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2155
// Information needed to generate the ReduceOp mapping for the DFA
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2156
class OutputMachOpcodes : public OutputMap {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2157
  int begin_inst_chain_rule;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2158
  int end_inst_chain_rule;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2159
  int begin_rematerialize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2160
  int end_rematerialize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2161
  int end_instructions;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2162
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2163
  OutputMachOpcodes(FILE *hpp, FILE *cpp, FormDict &globals, ArchDesc &AD)
13971
3c568f3dacca 8000592: Improve adlc usability
kvn
parents: 13969
diff changeset
  2164
    : OutputMap(hpp, cpp, globals, AD, "MachOpcodes"),
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2165
      begin_inst_chain_rule(-1), end_inst_chain_rule(-1), end_instructions(-1)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2166
  {};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2167
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2168
  void declaration() { }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2169
  void definition()  { fprintf(_cpp, "enum MachOpcodes {\n"); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2170
  void closing()     {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2171
    if( begin_inst_chain_rule != -1 )
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2172
      fprintf(_cpp, "  _BEGIN_INST_CHAIN_RULE = %d,\n", begin_inst_chain_rule);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2173
    if( end_inst_chain_rule   != -1 )
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2174
      fprintf(_cpp, "  _END_INST_CHAIN_RULE  = %d,\n", end_inst_chain_rule);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2175
    if( begin_rematerialize   != -1 )
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2176
      fprintf(_cpp, "  _BEGIN_REMATERIALIZE   = %d,\n", begin_rematerialize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2177
    if( end_rematerialize     != -1 )
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2178
      fprintf(_cpp, "  _END_REMATERIALIZE    = %d,\n", end_rematerialize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2179
    // always execute since do_instructions() is true, and avoids trailing comma
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2180
    fprintf(_cpp, "  _last_Mach_Node  = %d \n",  end_instructions);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2181
    OutputMap::closing();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2182
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2183
  void map(OpClassForm &opc)  { fprintf(_cpp, "  %s_rule", opc._ident ); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2184
  void map(OperandForm &oper) { fprintf(_cpp, "  %s_rule", oper._ident ); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2185
  void map(char        *name) { if (name) fprintf(_cpp, "  %s_rule", name);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2186
                                else      fprintf(_cpp, "  0"); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2187
  void map(InstructForm &inst) {fprintf(_cpp, "  %s_rule", inst._ident ); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2188
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2189
  void record_position(OutputMap::position place, int idx ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2190
    switch(place) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2191
    case OutputMap::BEGIN_INST_CHAIN_RULES :
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2192
      begin_inst_chain_rule = idx;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2193
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2194
    case OutputMap::END_INST_CHAIN_RULES :
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2195
      end_inst_chain_rule   = idx;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2196
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2197
    case OutputMap::BEGIN_REMATERIALIZE :
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2198
      begin_rematerialize   = idx;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2199
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2200
    case OutputMap::END_REMATERIALIZE :
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2201
      end_rematerialize     = idx;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2202
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2203
    case OutputMap::END_INSTRUCTIONS :
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2204
      end_instructions      = idx;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2205
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2206
    default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2207
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2208
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2209
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2210
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2211
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2212
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2213
void ArchDesc::buildMachOpcodesEnum(FILE *fp_hpp) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2214
  // Construct the table for MachOpcodes
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2215
  OutputMachOpcodes output_mach_opcodes(fp_hpp, fp_hpp, _globalNames, *this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2216
  build_map(output_mach_opcodes);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2217
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2218
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2219
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2220
// Generate an enumeration of the pipeline states, and both
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2221
// the functional units (resources) and the masks for
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2222
// specifying resources
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2223
void ArchDesc::build_pipeline_enums(FILE *fp_hpp) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2224
  int stagelen = (int)strlen("undefined");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2225
  int stagenum = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2226
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2227
  if (_pipeline) {              // Find max enum string length
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2228
    const char *stage;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2229
    for ( _pipeline->_stages.reset(); (stage = _pipeline->_stages.iter()) != NULL; ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2230
      int len = (int)strlen(stage);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2231
      if (stagelen < len) stagelen = len;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2232
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2233
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2234
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2235
  // Generate a list of stages
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2236
  fprintf(fp_hpp, "\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2237
  fprintf(fp_hpp, "// Pipeline Stages\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2238
  fprintf(fp_hpp, "enum machPipelineStages {\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2239
  fprintf(fp_hpp, "   stage_%-*s = 0,\n", stagelen, "undefined");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2240
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2241
  if( _pipeline ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2242
    const char *stage;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2243
    for ( _pipeline->_stages.reset(); (stage = _pipeline->_stages.iter()) != NULL; )
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2244
      fprintf(fp_hpp, "   stage_%-*s = %d,\n", stagelen, stage, ++stagenum);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2245
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2246
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2247
  fprintf(fp_hpp, "   stage_%-*s = %d\n", stagelen, "count", stagenum);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2248
  fprintf(fp_hpp, "};\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2249
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2250
  fprintf(fp_hpp, "\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2251
  fprintf(fp_hpp, "// Pipeline Resources\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2252
  fprintf(fp_hpp, "enum machPipelineResources {\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2253
  int rescount = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2254
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2255
  if( _pipeline ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2256
    const char *resource;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2257
    int reslen = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2258
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2259
    // Generate a list of resources, and masks
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2260
    for ( _pipeline->_reslist.reset(); (resource = _pipeline->_reslist.iter()) != NULL; ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2261
      int len = (int)strlen(resource);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2262
      if (reslen < len)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2263
        reslen = len;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2264
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2265
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2266
    for ( _pipeline->_reslist.reset(); (resource = _pipeline->_reslist.iter()) != NULL; ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2267
      const ResourceForm *resform = _pipeline->_resdict[resource]->is_resource();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2268
      int mask = resform->mask();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2269
      if ((mask & (mask-1)) == 0)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2270
        fprintf(fp_hpp, "   resource_%-*s = %d,\n", reslen, resource, rescount++);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2271
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2272
    fprintf(fp_hpp, "\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2273
    for ( _pipeline->_reslist.reset(); (resource = _pipeline->_reslist.iter()) != NULL; ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2274
      const ResourceForm *resform = _pipeline->_resdict[resource]->is_resource();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2275
      fprintf(fp_hpp, "   res_mask_%-*s = 0x%08x,\n", reslen, resource, resform->mask());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2276
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2277
    fprintf(fp_hpp, "\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2278
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2279
  fprintf(fp_hpp, "   resource_count = %d\n", rescount);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2280
  fprintf(fp_hpp, "};\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2281
}