/javac_compiler/HotspotSource/JavaHotSpotSrc/src/vm/adlc/output_h.cpp
C++ | 1450 lines | 1105 code | 110 blank | 235 comment | 321 complexity | 4f1381224612b83af400c247fe9ba814 MD5 | raw file
Possible License(s): MPL-2.0-no-copyleft-exception, Apache-2.0, CPL-1.0, AGPL-1.0, JSON, LGPL-2.1, GPL-2.0, BSD-3-Clause, BSD-3-Clause-No-Nuclear-License-2014, Unlicense, LGPL-2.0
Large files files are truncated, but you can click here to view the full file
- /*
- * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
- // output_h.cpp - Class HPP file output routines for architecture definition
- #include "adlc.hpp"
-
-
- // Generate the #define that describes the number of registers.
- static void defineRegCount(FILE *fp, RegisterForm *registers) {
- if (registers) {
- int regCount = AdlcVMDeps::Physical + registers->_rdefs.count();
- fprintf(fp,"\n");
- fprintf(fp,"// the number of reserved registers + machine registers.\n");
- fprintf(fp,"#define REG_COUNT %d\n", regCount);
- }
- }
-
- // Output enumeration of machine register numbers
- // (1)
- // // Enumerate machine registers starting after reserved regs.
- // // in the order of occurrence in the register block.
- // enum MachRegisterNumbers {
- // EAX_num = 0,
- // ...
- // _last_Mach_Reg
- // }
- void ArchDesc::buildMachRegisterNumbers(FILE *fp_hpp) {
- if (_register) {
- RegDef *reg_def = NULL;
-
- // Output a #define for the number of machine registers
- defineRegCount(fp_hpp, _register);
-
- // Count all the Save_On_Entry and Always_Save registers
- int saved_on_entry = 0;
- int c_saved_on_entry = 0;
- _register->reset_RegDefs();
- while( (reg_def = _register->iter_RegDefs()) != NULL ) {
- if( strcmp(reg_def->_callconv,"SOE") == 0 ||
- strcmp(reg_def->_callconv,"AS") == 0 ) ++saved_on_entry;
- if( strcmp(reg_def->_c_conv,"SOE") == 0 ||
- strcmp(reg_def->_c_conv,"AS") == 0 ) ++c_saved_on_entry;
- }
- fprintf(fp_hpp, "\n");
- fprintf(fp_hpp, "// the number of save_on_entry + always_saved registers.\n");
- fprintf(fp_hpp, "#define MAX_SAVED_ON_ENTRY_REG_COUNT %d\n", max(saved_on_entry,c_saved_on_entry));
- fprintf(fp_hpp, "#define SAVED_ON_ENTRY_REG_COUNT %d\n", saved_on_entry);
- fprintf(fp_hpp, "#define C_SAVED_ON_ENTRY_REG_COUNT %d\n", c_saved_on_entry);
-
- // (1)
- // Build definition for enumeration of register numbers
- fprintf(fp_hpp, "\n");
- fprintf(fp_hpp, "// Enumerate machine register numbers starting after reserved regs.\n");
- fprintf(fp_hpp, "// in the order of occurrence in the register block.\n");
- fprintf(fp_hpp, "enum MachRegisterNumbers {\n");
-
- // Output the register number for each register in the allocation classes
- _register->reset_RegDefs();
- int i = 0;
- while( (reg_def = _register->iter_RegDefs()) != NULL ) {
- fprintf(fp_hpp," %s_num,\t\t// %d\n", reg_def->_regname, i++);
- }
- // Finish defining enumeration
- fprintf(fp_hpp, " _last_Mach_Reg\t// %d\n", i);
- fprintf(fp_hpp, "};\n");
- }
-
- fprintf(fp_hpp, "\n// Size of register-mask in ints\n");
- fprintf(fp_hpp, "#define RM_SIZE %d\n",RegisterForm::RegMask_Size());
- fprintf(fp_hpp, "// Unroll factor for loops over the data in a RegMask\n");
- fprintf(fp_hpp, "#define FORALL_BODY ");
- int len = RegisterForm::RegMask_Size();
- for( int i = 0; i < len; i++ )
- fprintf(fp_hpp, "BODY(%d) ",i);
- fprintf(fp_hpp, "\n\n");
-
- fprintf(fp_hpp,"class RegMask;\n");
- // All RegMasks are declared "extern const ..." in ad_<arch>.hpp
- // fprintf(fp_hpp,"extern RegMask STACK_OR_STACK_SLOTS_mask;\n\n");
- }
-
-
- // Output enumeration of machine register encodings
- // (2)
- // // Enumerate machine registers starting after reserved regs.
- // // in the order of occurrence in the alloc_class(es).
- // enum MachRegisterEncodes {
- // EAX_enc = 0x00,
- // ...
- // }
- void ArchDesc::buildMachRegisterEncodes(FILE *fp_hpp) {
- if (_register) {
- RegDef *reg_def = NULL;
- RegDef *reg_def_next = NULL;
-
- // (2)
- // Build definition for enumeration of encode values
- fprintf(fp_hpp, "\n");
- fprintf(fp_hpp, "// Enumerate machine registers starting after reserved regs.\n");
- fprintf(fp_hpp, "// in the order of occurrence in the alloc_class(es).\n");
- fprintf(fp_hpp, "enum MachRegisterEncodes {\n");
-
- // Output the register encoding for each register in the allocation classes
- _register->reset_RegDefs();
- reg_def_next = _register->iter_RegDefs();
- while( (reg_def = reg_def_next) != NULL ) {
- reg_def_next = _register->iter_RegDefs();
- fprintf(fp_hpp," %s_enc = %s%s\n",
- reg_def->_regname, reg_def->register_encode(), reg_def_next == NULL? "" : "," );
- }
- // Finish defining enumeration
- fprintf(fp_hpp, "};\n");
-
- } // Done with register form
- }
-
-
- // Declare an array containing the machine register names, strings.
- static void declareRegNames(FILE *fp, RegisterForm *registers) {
- if (registers) {
- // fprintf(fp,"\n");
- // fprintf(fp,"// An array of character pointers to machine register names.\n");
- // fprintf(fp,"extern const char *regName[];\n");
- }
- }
-
- // Declare an array containing the machine register sizes in 32-bit words.
- void ArchDesc::declareRegSizes(FILE *fp) {
- // regSize[] is not used
- }
-
- // Declare an array containing the machine register encoding values
- static void declareRegEncodes(FILE *fp, RegisterForm *registers) {
- if (registers) {
- // // //
- // fprintf(fp,"\n");
- // fprintf(fp,"// An array containing the machine register encode values\n");
- // fprintf(fp,"extern const char regEncode[];\n");
- }
- }
-
-
- // ---------------------------------------------------------------------------
- //------------------------------Utilities to build Instruction Classes--------
- // ---------------------------------------------------------------------------
- static void out_RegMask(FILE *fp) {
- fprintf(fp," virtual const RegMask &out_RegMask() const;\n");
- }
-
- // ---------------------------------------------------------------------------
- //--------Utilities to build MachOper and MachNode derived Classes------------
- // ---------------------------------------------------------------------------
-
- //------------------------------Utilities to build Operand Classes------------
- static void in_RegMask(FILE *fp) {
- fprintf(fp," virtual const RegMask *in_RegMask(int index) const;\n");
- }
-
- static void declare_hash(FILE *fp) {
- fprintf(fp," virtual uint hash() const;\n");
- }
-
- static void declare_cmp(FILE *fp) {
- fprintf(fp," virtual uint cmp( const MachOper &oper ) const;\n");
- }
-
- static void declareConstStorage(FILE *fp, FormDict &globals, OperandForm *oper) {
- int i = 0;
- Component *comp;
-
- if (oper->num_consts(globals) == 0) return;
- // Iterate over the component list looking for constants
- oper->_components.reset();
- if ((comp = oper->_components.iter()) == NULL) {
- assert(oper->num_consts(globals) == 1, "Bad component list detected.\n");
- const char *type = oper->ideal_type(globals);
- if (!strcmp(type, "ConI")) {
- if (i > 0) fprintf(fp,", ");
- fprintf(fp," int32 _c%d;\n", i);
- }
- else if (!strcmp(type, "ConP")) {
- if (i > 0) fprintf(fp,", ");
- fprintf(fp," const TypePtr *_c%d;\n", i);
- }
- else if (!strcmp(type, "ConN")) {
- if (i > 0) fprintf(fp,", ");
- fprintf(fp," const TypeNarrowOop *_c%d;\n", i);
- }
- else if (!strcmp(type, "ConL")) {
- if (i > 0) fprintf(fp,", ");
- fprintf(fp," jlong _c%d;\n", i);
- }
- else if (!strcmp(type, "ConF")) {
- if (i > 0) fprintf(fp,", ");
- fprintf(fp," jfloat _c%d;\n", i);
- }
- else if (!strcmp(type, "ConD")) {
- if (i > 0) fprintf(fp,", ");
- fprintf(fp," jdouble _c%d;\n", i);
- }
- else if (!strcmp(type, "Bool")) {
- fprintf(fp,"private:\n");
- fprintf(fp," BoolTest::mask _c%d;\n", i);
- fprintf(fp,"public:\n");
- }
- else {
- assert(0, "Non-constant operand lacks component list.");
- }
- } // end if NULL
- else {
- oper->_components.reset();
- while ((comp = oper->_components.iter()) != NULL) {
- if (!strcmp(comp->base_type(globals), "ConI")) {
- fprintf(fp," jint _c%d;\n", i);
- i++;
- }
- else if (!strcmp(comp->base_type(globals), "ConP")) {
- fprintf(fp," const TypePtr *_c%d;\n", i);
- i++;
- }
- else if (!strcmp(comp->base_type(globals), "ConN")) {
- fprintf(fp," const TypePtr *_c%d;\n", i);
- i++;
- }
- else if (!strcmp(comp->base_type(globals), "ConL")) {
- fprintf(fp," jlong _c%d;\n", i);
- i++;
- }
- else if (!strcmp(comp->base_type(globals), "ConF")) {
- fprintf(fp," jfloat _c%d;\n", i);
- i++;
- }
- else if (!strcmp(comp->base_type(globals), "ConD")) {
- fprintf(fp," jdouble _c%d;\n", i);
- i++;
- }
- }
- }
- }
-
- // Declare constructor.
- // Parameters start with condition code, then all other constants
- //
- // (0) public:
- // (1) MachXOper(int32 ccode, int32 c0, int32 c1, ..., int32 cn)
- // (2) : _ccode(ccode), _c0(c0), _c1(c1), ..., _cn(cn) { }
- //
- static void defineConstructor(FILE *fp, const char *name, uint num_consts,
- ComponentList &lst, bool is_ideal_bool,
- Form::DataType constant_type, FormDict &globals) {
- fprintf(fp,"public:\n");
- // generate line (1)
- fprintf(fp," %sOper(", name);
- if( num_consts == 0 ) {
- fprintf(fp,") {}\n");
- return;
- }
-
- // generate parameters for constants
- uint i = 0;
- Component *comp;
- lst.reset();
- if ((comp = lst.iter()) == NULL) {
- assert(num_consts == 1, "Bad component list detected.\n");
- switch( constant_type ) {
- case Form::idealI : {
- fprintf(fp,is_ideal_bool ? "BoolTest::mask c%d" : "int32 c%d", i);
- break;
- }
- case Form::idealN : { fprintf(fp,"const TypeNarrowOop *c%d", i); break; }
- case Form::idealP : { fprintf(fp,"const TypePtr *c%d", i); break; }
- case Form::idealL : { fprintf(fp,"jlong c%d", i); break; }
- case Form::idealF : { fprintf(fp,"jfloat c%d", i); break; }
- case Form::idealD : { fprintf(fp,"jdouble c%d", i); break; }
- default:
- assert(!is_ideal_bool, "Non-constant operand lacks component list.");
- break;
- }
- } // end if NULL
- else {
- lst.reset();
- while((comp = lst.iter()) != NULL) {
- if (!strcmp(comp->base_type(globals), "ConI")) {
- if (i > 0) fprintf(fp,", ");
- fprintf(fp,"int32 c%d", i);
- i++;
- }
- else if (!strcmp(comp->base_type(globals), "ConP")) {
- if (i > 0) fprintf(fp,", ");
- fprintf(fp,"const TypePtr *c%d", i);
- i++;
- }
- else if (!strcmp(comp->base_type(globals), "ConN")) {
- if (i > 0) fprintf(fp,", ");
- fprintf(fp,"const TypePtr *c%d", i);
- i++;
- }
- else if (!strcmp(comp->base_type(globals), "ConL")) {
- if (i > 0) fprintf(fp,", ");
- fprintf(fp,"jlong c%d", i);
- i++;
- }
- else if (!strcmp(comp->base_type(globals), "ConF")) {
- if (i > 0) fprintf(fp,", ");
- fprintf(fp,"jfloat c%d", i);
- i++;
- }
- else if (!strcmp(comp->base_type(globals), "ConD")) {
- if (i > 0) fprintf(fp,", ");
- fprintf(fp,"jdouble c%d", i);
- i++;
- }
- else if (!strcmp(comp->base_type(globals), "Bool")) {
- if (i > 0) fprintf(fp,", ");
- fprintf(fp,"BoolTest::mask c%d", i);
- i++;
- }
- }
- }
- // finish line (1) and start line (2)
- fprintf(fp,") : ");
- // generate initializers for constants
- i = 0;
- fprintf(fp,"_c%d(c%d)", i, i);
- for( i = 1; i < num_consts; ++i) {
- fprintf(fp,", _c%d(c%d)", i, i);
- }
- // The body for the constructor is empty
- fprintf(fp," {}\n");
- }
-
- // ---------------------------------------------------------------------------
- // Utilities to generate format rules for machine operands and instructions
- // ---------------------------------------------------------------------------
-
- // Generate the format rule for condition codes
- static void defineCCodeDump(OperandForm* oper, FILE *fp, int i) {
- assert(oper != NULL, "what");
- CondInterface* cond = oper->_interface->is_CondInterface();
- fprintf(fp, " if( _c%d == BoolTest::eq ) st->print(\"%s\");\n",i,cond->_equal_format);
- fprintf(fp, " else if( _c%d == BoolTest::ne ) st->print(\"%s\");\n",i,cond->_not_equal_format);
- fprintf(fp, " else if( _c%d == BoolTest::le ) st->print(\"%s\");\n",i,cond->_less_equal_format);
- fprintf(fp, " else if( _c%d == BoolTest::ge ) st->print(\"%s\");\n",i,cond->_greater_equal_format);
- fprintf(fp, " else if( _c%d == BoolTest::lt ) st->print(\"%s\");\n",i,cond->_less_format);
- fprintf(fp, " else if( _c%d == BoolTest::gt ) st->print(\"%s\");\n",i,cond->_greater_format);
- }
-
- // Output code that dumps constant values, increment "i" if type is constant
- static uint dump_spec_constant(FILE *fp, const char *ideal_type, uint i, OperandForm* oper) {
- if (!strcmp(ideal_type, "ConI")) {
- fprintf(fp," st->print(\"#%%d\", _c%d);\n", i);
- ++i;
- }
- else if (!strcmp(ideal_type, "ConP")) {
- fprintf(fp," _c%d->dump_on(st);\n", i);
- ++i;
- }
- else if (!strcmp(ideal_type, "ConN")) {
- fprintf(fp," _c%d->dump_on(st);\n", i);
- ++i;
- }
- else if (!strcmp(ideal_type, "ConL")) {
- fprintf(fp," st->print(\"#\" INT64_FORMAT, _c%d);\n", i);
- ++i;
- }
- else if (!strcmp(ideal_type, "ConF")) {
- fprintf(fp," st->print(\"#%%f\", _c%d);\n", i);
- ++i;
- }
- else if (!strcmp(ideal_type, "ConD")) {
- fprintf(fp," st->print(\"#%%f\", _c%d);\n", i);
- ++i;
- }
- else if (!strcmp(ideal_type, "Bool")) {
- defineCCodeDump(oper, fp,i);
- ++i;
- }
-
- return i;
- }
-
- // Generate the format rule for an operand
- void gen_oper_format(FILE *fp, FormDict &globals, OperandForm &oper, bool for_c_file = false) {
- if (!for_c_file) {
- // invoked after output #ifndef PRODUCT to ad_<arch>.hpp
- // compile the bodies separately, to cut down on recompilations
- fprintf(fp," virtual void int_format(PhaseRegAlloc *ra, const MachNode *node, outputStream *st) const;\n");
- fprintf(fp," virtual void ext_format(PhaseRegAlloc *ra, const MachNode *node, int idx, outputStream *st) const;\n");
- return;
- }
-
- // Local pointer indicates remaining part of format rule
- uint idx = 0; // position of operand in match rule
-
- // Generate internal format function, used when stored locally
- fprintf(fp, "\n#ifndef PRODUCT\n");
- fprintf(fp,"void %sOper::int_format(PhaseRegAlloc *ra, const MachNode *node, outputStream *st) const {\n", oper._ident);
- // Generate the user-defined portion of the format
- if (oper._format) {
- if ( oper._format->_strings.count() != 0 ) {
- // No initialization code for int_format
-
- // Build the format from the entries in strings and rep_vars
- const char *string = NULL;
- oper._format->_rep_vars.reset();
- oper._format->_strings.reset();
- while ( (string = oper._format->_strings.iter()) != NULL ) {
- fprintf(fp," ");
-
- // Check if this is a standard string or a replacement variable
- if ( string != NameList::_signal ) {
- // Normal string
- // Pass through to st->print
- fprintf(fp,"st->print(\"%s\");\n", string);
- } else {
- // Replacement variable
- const char *rep_var = oper._format->_rep_vars.iter();
- // Check that it is a local name, and an operand
- const Form* form = oper._localNames[rep_var];
- if (form == NULL) {
- globalAD->syntax_err(oper._linenum,
- "\'%s\' not found in format for %s\n", rep_var, oper._ident);
- assert(form, "replacement variable was not found in local names");
- }
- OperandForm *op = form->is_operand();
- // Get index if register or constant
- if ( op->_matrule && op->_matrule->is_base_register(globals) ) {
- idx = oper.register_position( globals, rep_var);
- }
- else if (op->_matrule && op->_matrule->is_base_constant(globals)) {
- idx = oper.constant_position( globals, rep_var);
- } else {
- idx = 0;
- }
-
- // output invocation of "$..."s format function
- if ( op != NULL ) op->int_format(fp, globals, idx);
-
- if ( idx == -1 ) {
- fprintf(stderr,
- "Using a name, %s, that isn't in match rule\n", rep_var);
- assert( strcmp(op->_ident,"label")==0, "Unimplemented");
- }
- } // Done with a replacement variable
- } // Done with all format strings
- } else {
- // Default formats for base operands (RegI, RegP, ConI, ConP, ...)
- oper.int_format(fp, globals, 0);
- }
-
- } else { // oper._format == NULL
- // Provide a few special case formats where the AD writer cannot.
- if ( strcmp(oper._ident,"Universe")==0 ) {
- fprintf(fp, " st->print(\"$$univ\");\n");
- }
- // labelOper::int_format is defined in ad_<...>.cpp
- }
- // ALWAYS! Provide a special case output for condition codes.
- if( oper.is_ideal_bool() ) {
- defineCCodeDump(&oper, fp,0);
- }
- fprintf(fp,"}\n");
-
- // Generate external format function, when data is stored externally
- fprintf(fp,"void %sOper::ext_format(PhaseRegAlloc *ra, const MachNode *node, int idx, outputStream *st) const {\n", oper._ident);
- // Generate the user-defined portion of the format
- if (oper._format) {
- if ( oper._format->_strings.count() != 0 ) {
-
- // Check for a replacement string "$..."
- if ( oper._format->_rep_vars.count() != 0 ) {
- // Initialization code for ext_format
- }
-
- // Build the format from the entries in strings and rep_vars
- const char *string = NULL;
- oper._format->_rep_vars.reset();
- oper._format->_strings.reset();
- while ( (string = oper._format->_strings.iter()) != NULL ) {
- fprintf(fp," ");
-
- // Check if this is a standard string or a replacement variable
- if ( string != NameList::_signal ) {
- // Normal string
- // Pass through to st->print
- fprintf(fp,"st->print(\"%s\");\n", string);
- } else {
- // Replacement variable
- const char *rep_var = oper._format->_rep_vars.iter();
- // Check that it is a local name, and an operand
- const Form* form = oper._localNames[rep_var];
- if (form == NULL) {
- globalAD->syntax_err(oper._linenum,
- "\'%s\' not found in format for %s\n", rep_var, oper._ident);
- assert(form, "replacement variable was not found in local names");
- }
- OperandForm *op = form->is_operand();
- // Get index if register or constant
- if ( op->_matrule && op->_matrule->is_base_register(globals) ) {
- idx = oper.register_position( globals, rep_var);
- }
- else if (op->_matrule && op->_matrule->is_base_constant(globals)) {
- idx = oper.constant_position( globals, rep_var);
- } else {
- idx = 0;
- }
- // output invocation of "$..."s format function
- if ( op != NULL ) op->ext_format(fp, globals, idx);
-
- // Lookup the index position of the replacement variable
- idx = oper._components.operand_position_format(rep_var);
- if ( idx == -1 ) {
- fprintf(stderr,
- "Using a name, %s, that isn't in match rule\n", rep_var);
- assert( strcmp(op->_ident,"label")==0, "Unimplemented");
- }
- } // Done with a replacement variable
- } // Done with all format strings
-
- } else {
- // Default formats for base operands (RegI, RegP, ConI, ConP, ...)
- oper.ext_format(fp, globals, 0);
- }
- } else { // oper._format == NULL
- // Provide a few special case formats where the AD writer cannot.
- if ( strcmp(oper._ident,"Universe")==0 ) {
- fprintf(fp, " st->print(\"$$univ\");\n");
- }
- // labelOper::ext_format is defined in ad_<...>.cpp
- }
- // ALWAYS! Provide a special case output for condition codes.
- if( oper.is_ideal_bool() ) {
- defineCCodeDump(&oper, fp,0);
- }
- fprintf(fp, "}\n");
- fprintf(fp, "#endif\n");
- }
-
-
- // Generate the format rule for an instruction
- void gen_inst_format(FILE *fp, FormDict &globals, InstructForm &inst, bool for_c_file = false) {
- if (!for_c_file) {
- // compile the bodies separately, to cut down on recompilations
- // #ifndef PRODUCT region generated by caller
- fprintf(fp," virtual void format(PhaseRegAlloc *ra, outputStream *st) const;\n");
- return;
- }
-
- // Define the format function
- fprintf(fp, "#ifndef PRODUCT\n");
- fprintf(fp, "void %sNode::format(PhaseRegAlloc *ra, outputStream *st) const {\n", inst._ident);
-
- // Generate the user-defined portion of the format
- if( inst._format ) {
- // If there are replacement variables,
- // Generate index values needed for determining the operand position
- if( inst._format->_rep_vars.count() )
- inst.index_temps(fp, globals);
-
- // Build the format from the entries in strings and rep_vars
- const char *string = NULL;
- inst._format->_rep_vars.reset();
- inst._format->_strings.reset();
- while( (string = inst._format->_strings.iter()) != NULL ) {
- fprintf(fp," ");
- // Check if this is a standard string or a replacement variable
- if( string == NameList::_signal ) { // Replacement variable
- const char* rep_var = inst._format->_rep_vars.iter();
- inst.rep_var_format( fp, rep_var);
- } else if( string == NameList::_signal3 ) { // Replacement variable in raw text
- const char* rep_var = inst._format->_rep_vars.iter();
- const Form *form = inst._localNames[rep_var];
- if (form == NULL) {
- fprintf(stderr, "unknown replacement variable in format statement: '%s'\n", rep_var);
- assert(false, "ShouldNotReachHere()");
- }
- OpClassForm *opc = form->is_opclass();
- assert( opc, "replacement variable was not found in local names");
- // Lookup the index position of the replacement variable
- int idx = inst.operand_position_format(rep_var);
- if ( idx == -1 ) {
- assert( strcmp(opc->_ident,"label")==0, "Unimplemented");
- assert( false, "ShouldNotReachHere()");
- }
-
- if (inst.is_noninput_operand(idx)) {
- assert( false, "ShouldNotReachHere()");
- } else {
- // Output the format call for this operand
- fprintf(fp,"opnd_array(%d)",idx);
- }
- rep_var = inst._format->_rep_vars.iter();
- inst._format->_strings.iter();
- if ( strcmp(rep_var,"$constant") == 0 && opc->is_operand()) {
- Form::DataType constant_type = form->is_operand()->is_base_constant(globals);
- if ( constant_type == Form::idealD ) {
- fprintf(fp,"->constantD()");
- } else if ( constant_type == Form::idealF ) {
- fprintf(fp,"->constantF()");
- } else if ( constant_type == Form::idealL ) {
- fprintf(fp,"->constantL()");
- } else {
- fprintf(fp,"->constant()");
- }
- } else if ( strcmp(rep_var,"$cmpcode") == 0) {
- fprintf(fp,"->ccode()");
- } else {
- assert( false, "ShouldNotReachHere()");
- }
- } else if( string == NameList::_signal2 ) // Raw program text
- fputs(inst._format->_strings.iter(), fp);
- else
- fprintf(fp,"st->print(\"%s\");\n", string);
- } // Done with all format strings
- } // Done generating the user-defined portion of the format
-
- // Add call debug info automatically
- Form::CallType call_type = inst.is_ideal_call();
- if( call_type != Form::invalid_type ) {
- switch( call_type ) {
- case Form::JAVA_DYNAMIC:
- fprintf(fp," _method->print_short_name();\n");
- break;
- case Form::JAVA_STATIC:
- fprintf(fp," if( _method ) _method->print_short_name(st); else st->print(\" wrapper for: %%s\", _name);\n");
- fprintf(fp," if( !_method ) dump_trap_args(st);\n");
- break;
- case Form::JAVA_COMPILED:
- case Form::JAVA_INTERP:
- break;
- case Form::JAVA_RUNTIME:
- case Form::JAVA_LEAF:
- case Form::JAVA_NATIVE:
- fprintf(fp," st->print(\" %%s\", _name);");
- break;
- default:
- assert(0,"ShouldNotReacHere");
- }
- fprintf(fp, " st->print_cr(\"\");\n" );
- fprintf(fp, " if (_jvms) _jvms->format(ra, this, st); else st->print_cr(\" No JVM State Info\");\n" );
- fprintf(fp, " st->print(\" # \");\n" );
- fprintf(fp, " if( _jvms ) _oop_map->print_on(st);\n");
- }
- else if(inst.is_ideal_safepoint()) {
- fprintf(fp, " st->print(\"\");\n" );
- fprintf(fp, " if (_jvms) _jvms->format(ra, this, st); else st->print_cr(\" No JVM State Info\");\n" );
- fprintf(fp, " st->print(\" # \");\n" );
- fprintf(fp, " if( _jvms ) _oop_map->print_on(st);\n");
- }
- else if( inst.is_ideal_if() ) {
- fprintf(fp, " st->print(\" P=%%f C=%%f\",_prob,_fcnt);\n" );
- }
- else if( inst.is_ideal_mem() ) {
- // Print out the field name if available to improve readability
- fprintf(fp, " if (ra->C->alias_type(adr_type())->field() != NULL) {\n");
- fprintf(fp, " st->print(\" ! Field \");\n");
- fprintf(fp, " if( ra->C->alias_type(adr_type())->is_volatile() )\n");
- fprintf(fp, " st->print(\" Volatile\");\n");
- fprintf(fp, " ra->C->alias_type(adr_type())->field()->holder()->name()->print_symbol_on(st);\n");
- fprintf(fp, " st->print(\".\");\n");
- fprintf(fp, " ra->C->alias_type(adr_type())->field()->name()->print_symbol_on(st);\n");
- fprintf(fp, " } else\n");
- // Make sure 'Volatile' gets printed out
- fprintf(fp, " if( ra->C->alias_type(adr_type())->is_volatile() )\n");
- fprintf(fp, " st->print(\" Volatile!\");\n");
- }
-
- // Complete the definition of the format function
- fprintf(fp, " }\n#endif\n");
- }
-
- static bool is_non_constant(char* x) {
- // Tells whether the string (part of an operator interface) is non-constant.
- // Simply detect whether there is an occurrence of a formal parameter,
- // which will always begin with '$'.
- return strchr(x, '$') == 0;
- }
-
- void ArchDesc::declare_pipe_classes(FILE *fp_hpp) {
- if (!_pipeline)
- return;
-
- fprintf(fp_hpp, "\n");
- fprintf(fp_hpp, "// Pipeline_Use_Cycle_Mask Class\n");
- fprintf(fp_hpp, "class Pipeline_Use_Cycle_Mask {\n");
-
- if (_pipeline->_maxcycleused <=
- #ifdef SPARC
- 64
- #else
- 32
- #endif
- ) {
- fprintf(fp_hpp, "protected:\n");
- fprintf(fp_hpp, " %s _mask;\n\n", _pipeline->_maxcycleused <= 32 ? "uint" : "uint64_t" );
- fprintf(fp_hpp, "public:\n");
- fprintf(fp_hpp, " Pipeline_Use_Cycle_Mask() : _mask(0) {}\n\n");
- if (_pipeline->_maxcycleused <= 32)
- fprintf(fp_hpp, " Pipeline_Use_Cycle_Mask(uint mask) : _mask(mask) {}\n\n");
- else {
- fprintf(fp_hpp, " Pipeline_Use_Cycle_Mask(uint mask1, uint mask2) : _mask((((uint64_t)mask1) << 32) | mask2) {}\n\n");
- fprintf(fp_hpp, " Pipeline_Use_Cycle_Mask(uint64_t mask) : _mask(mask) {}\n\n");
- }
- fprintf(fp_hpp, " Pipeline_Use_Cycle_Mask& operator=(const Pipeline_Use_Cycle_Mask &in) {\n");
- fprintf(fp_hpp, " _mask = in._mask;\n");
- fprintf(fp_hpp, " return *this;\n");
- fprintf(fp_hpp, " }\n\n");
- fprintf(fp_hpp, " bool overlaps(const Pipeline_Use_Cycle_Mask &in2) const {\n");
- fprintf(fp_hpp, " return ((_mask & in2._mask) != 0);\n");
- fprintf(fp_hpp, " }\n\n");
- fprintf(fp_hpp, " Pipeline_Use_Cycle_Mask& operator<<=(int n) {\n");
- fprintf(fp_hpp, " _mask <<= n;\n");
- fprintf(fp_hpp, " return *this;\n");
- fprintf(fp_hpp, " }\n\n");
- fprintf(fp_hpp, " void Or(const Pipeline_Use_Cycle_Mask &in2) {\n");
- fprintf(fp_hpp, " _mask |= in2._mask;\n");
- fprintf(fp_hpp, " }\n\n");
- fprintf(fp_hpp, " friend Pipeline_Use_Cycle_Mask operator&(const Pipeline_Use_Cycle_Mask &, const Pipeline_Use_Cycle_Mask &);\n");
- fprintf(fp_hpp, " friend Pipeline_Use_Cycle_Mask operator|(const Pipeline_Use_Cycle_Mask &, const Pipeline_Use_Cycle_Mask &);\n\n");
- }
- else {
- fprintf(fp_hpp, "protected:\n");
- uint masklen = (_pipeline->_maxcycleused + 31) >> 5;
- uint l;
- fprintf(fp_hpp, " uint ");
- for (l = 1; l <= masklen; l++)
- fprintf(fp_hpp, "_mask%d%s", l, l < masklen ? ", " : ";\n\n");
- fprintf(fp_hpp, "public:\n");
- fprintf(fp_hpp, " Pipeline_Use_Cycle_Mask() : ");
- for (l = 1; l <= masklen; l++)
- fprintf(fp_hpp, "_mask%d(0)%s", l, l < masklen ? ", " : " {}\n\n");
- fprintf(fp_hpp, " Pipeline_Use_Cycle_Mask(");
- for (l = 1; l <= masklen; l++)
- fprintf(fp_hpp, "uint mask%d%s", l, l < masklen ? ", " : ") : ");
- for (l = 1; l <= masklen; l++)
- fprintf(fp_hpp, "_mask%d(mask%d)%s", l, l, l < masklen ? ", " : " {}\n\n");
-
- fprintf(fp_hpp, " Pipeline_Use_Cycle_Mask& operator=(const Pipeline_Use_Cycle_Mask &in) {\n");
- for (l = 1; l <= masklen; l++)
- fprintf(fp_hpp, " _mask%d = in._mask%d;\n", l, l);
- fprintf(fp_hpp, " return *this;\n");
- fprintf(fp_hpp, " }\n\n");
- fprintf(fp_hpp, " Pipeline_Use_Cycle_Mask intersect(const Pipeline_Use_Cycle_Mask &in2) {\n");
- fprintf(fp_hpp, " Pipeline_Use_Cycle_Mask out;\n");
- for (l = 1; l <= masklen; l++)
- fprintf(fp_hpp, " out._mask%d = _mask%d & in2._mask%d;\n", l, l, l);
- fprintf(fp_hpp, " return out;\n");
- fprintf(fp_hpp, " }\n\n");
- fprintf(fp_hpp, " bool overlaps(const Pipeline_Use_Cycle_Mask &in2) const {\n");
- fprintf(fp_hpp, " return (");
- for (l = 1; l <= masklen; l++)
- fprintf(fp_hpp, "((_mask%d & in2._mask%d) != 0)%s", l, l, l < masklen ? " || " : "");
- fprintf(fp_hpp, ") ? true : false;\n");
- fprintf(fp_hpp, " }\n\n");
- fprintf(fp_hpp, " Pipeline_Use_Cycle_Mask& operator<<=(int n) {\n");
- fprintf(fp_hpp, " if (n >= 32)\n");
- fprintf(fp_hpp, " do {\n ");
- for (l = masklen; l > 1; l--)
- fprintf(fp_hpp, " _mask%d = _mask%d;", l, l-1);
- fprintf(fp_hpp, " _mask%d = 0;\n", 1);
- fprintf(fp_hpp, " } while ((n -= 32) >= 32);\n\n");
- fprintf(fp_hpp, " if (n > 0) {\n");
- fprintf(fp_hpp, " uint m = 32 - n;\n");
- fprintf(fp_hpp, " uint mask = (1 << n) - 1;\n");
- fprintf(fp_hpp, " uint temp%d = mask & (_mask%d >> m); _mask%d <<= n;\n", 2, 1, 1);
- for (l = 2; l < masklen; l++) {
- fprintf(fp_hpp, " uint temp%d = mask & (_mask%d >> m); _mask%d <<= n; _mask%d |= temp%d;\n", l+1, l, l, l, l);
- }
- fprintf(fp_hpp, " _mask%d <<= n; _mask%d |= temp%d;\n", masklen, masklen, masklen);
- fprintf(fp_hpp, " }\n");
-
- fprintf(fp_hpp, " return *this;\n");
- fprintf(fp_hpp, " }\n\n");
- fprintf(fp_hpp, " void Or(const Pipeline_Use_Cycle_Mask &);\n\n");
- fprintf(fp_hpp, " friend Pipeline_Use_Cycle_Mask operator&(const Pipeline_Use_Cycle_Mask &, const Pipeline_Use_Cycle_Mask &);\n");
- fprintf(fp_hpp, " friend Pipeline_Use_Cycle_Mask operator|(const Pipeline_Use_Cycle_Mask &, const Pipeline_Use_Cycle_Mask &);\n\n");
- }
-
- fprintf(fp_hpp, " friend class Pipeline_Use;\n\n");
- fprintf(fp_hpp, " friend class Pipeline_Use_Element;\n\n");
- fprintf(fp_hpp, "};\n\n");
-
- uint rescount = 0;
- const char *resource;
-
- for ( _pipeline->_reslist.reset(); (resource = _pipeline->_reslist.iter()) != NULL; ) {
- int mask = _pipeline->_resdict[resource]->is_resource()->mask();
- if ((mask & (mask-1)) == 0)
- rescount++;
- }
-
- fprintf(fp_hpp, "// Pipeline_Use_Element Class\n");
- fprintf(fp_hpp, "class Pipeline_Use_Element {\n");
- fprintf(fp_hpp, "protected:\n");
- fprintf(fp_hpp, " // Mask of used functional units\n");
- fprintf(fp_hpp, " uint _used;\n\n");
- fprintf(fp_hpp, " // Lower and upper bound of functional unit number range\n");
- fprintf(fp_hpp, " uint _lb, _ub;\n\n");
- fprintf(fp_hpp, " // Indicates multiple functionals units available\n");
- fprintf(fp_hpp, " bool _multiple;\n\n");
- fprintf(fp_hpp, " // Mask of specific used cycles\n");
- fprintf(fp_hpp, " Pipeline_Use_Cycle_Mask _mask;\n\n");
- fprintf(fp_hpp, "public:\n");
- fprintf(fp_hpp, " Pipeline_Use_Element() {}\n\n");
- fprintf(fp_hpp, " Pipeline_Use_Element(uint used, uint lb, uint ub, bool multiple, Pipeline_Use_Cycle_Mask mask)\n");
- fprintf(fp_hpp, " : _used(used), _lb(lb), _ub(ub), _multiple(multiple), _mask(mask) {}\n\n");
- fprintf(fp_hpp, " uint used() const { return _used; }\n\n");
- fprintf(fp_hpp, " uint lowerBound() const { return _lb; }\n\n");
- fprintf(fp_hpp, " uint upperBound() const { return _ub; }\n\n");
- fprintf(fp_hpp, " bool multiple() const { return _multiple; }\n\n");
- fprintf(fp_hpp, " Pipeline_Use_Cycle_Mask mask() const { return _mask; }\n\n");
- fprintf(fp_hpp, " bool overlaps(const Pipeline_Use_Element &in2) const {\n");
- fprintf(fp_hpp, " return ((_used & in2._used) != 0 && _mask.overlaps(in2._mask));\n");
- fprintf(fp_hpp, " }\n\n");
- fprintf(fp_hpp, " void step(uint cycles) {\n");
- fprintf(fp_hpp, " _used = 0;\n");
- fprintf(fp_hpp, " _mask <<= cycles;\n");
- fprintf(fp_hpp, " }\n\n");
- fprintf(fp_hpp, " friend class Pipeline_Use;\n");
- fprintf(fp_hpp, "};\n\n");
-
- fprintf(fp_hpp, "// Pipeline_Use Class\n");
- fprintf(fp_hpp, "class Pipeline_Use {\n");
- fprintf(fp_hpp, "protected:\n");
- fprintf(fp_hpp, " // These resources can be used\n");
- fprintf(fp_hpp, " uint _resources_used;\n\n");
- fprintf(fp_hpp, " // These resources are used; excludes multiple choice functional units\n");
- fprintf(fp_hpp, " uint _resources_used_exclusively;\n\n");
- fprintf(fp_hpp, " // Number of elements\n");
- fprintf(fp_hpp, " uint _count;\n\n");
- fprintf(fp_hpp, " // This is the array of Pipeline_Use_Elements\n");
- fprintf(fp_hpp, " Pipeline_Use_Element * _elements;\n\n");
- fprintf(fp_hpp, "public:\n");
- fprintf(fp_hpp, " Pipeline_Use(uint resources_used, uint resources_used_exclusively, uint count, Pipeline_Use_Element *elements)\n");
- fprintf(fp_hpp, " : _resources_used(resources_used)\n");
- fprintf(fp_hpp, " , _resources_used_exclusively(resources_used_exclusively)\n");
- fprintf(fp_hpp, " , _count(count)\n");
- fprintf(fp_hpp, " , _elements(elements)\n");
- fprintf(fp_hpp, " {}\n\n");
- fprintf(fp_hpp, " uint resourcesUsed() const { return _resources_used; }\n\n");
- fprintf(fp_hpp, " uint resourcesUsedExclusively() const { return _resources_used_exclusively; }\n\n");
- fprintf(fp_hpp, " uint count() const { return _count; }\n\n");
- fprintf(fp_hpp, " Pipeline_Use_Element * element(uint i) const { return &_elements[i]; }\n\n");
- fprintf(fp_hpp, " uint full_latency(uint delay, const Pipeline_Use &pred) const;\n\n");
- fprintf(fp_hpp, " void add_usage(const Pipeline_Use &pred);\n\n");
- fprintf(fp_hpp, " void reset() {\n");
- fprintf(fp_hpp, " _resources_used = _resources_used_exclusively = 0;\n");
- fprintf(fp_hpp, " };\n\n");
- fprintf(fp_hpp, " void step(uint cycles) {\n");
- fprintf(fp_hpp, " reset();\n");
- fprintf(fp_hpp, " for (uint i = 0; i < %d; i++)\n",
- rescount);
- fprintf(fp_hpp, " (&_elements[i])->step(cycles);\n");
- fprintf(fp_hpp, " };\n\n");
- fprintf(fp_hpp, " static const Pipeline_Use elaborated_use;\n");
- fprintf(fp_hpp, " static const Pipeline_Use_Element elaborated_elements[%d];\n\n",
- rescount);
- fprintf(fp_hpp, " friend class Pipeline;\n");
- fprintf(fp_hpp, "};\n\n");
-
- fprintf(fp_hpp, "// Pipeline Class\n");
- fprintf(fp_hpp, "class Pipeline {\n");
- fprintf(fp_hpp, "public:\n");
-
- fprintf(fp_hpp, " static bool enabled() { return %s; }\n\n",
- _pipeline ? "true" : "false" );
-
- assert( _pipeline->_maxInstrsPerBundle &&
- ( _pipeline->_instrUnitSize || _pipeline->_bundleUnitSize) &&
- _pipeline->_instrFetchUnitSize &&
- _pipeline->_instrFetchUnits,
- "unspecified pipeline architecture units");
-
- uint unitSize = _pipeline->_instrUnitSize ? _pipeline->_instrUnitSize : _pipeline->_bundleUnitSize;
-
- fprintf(fp_hpp, " enum {\n");
- fprintf(fp_hpp, " _variable_size_instructions = %d,\n",
- _pipeline->_variableSizeInstrs ? 1 : 0);
- fprintf(fp_hpp, " _fixed_size_instructions = %d,\n",
- _pipeline->_variableSizeInstrs ? 0 : 1);
- fprintf(fp_hpp, " _branch_has_delay_slot = %d,\n",
- _pipeline->_branchHasDelaySlot ? 1 : 0);
- fprintf(fp_hpp, " _max_instrs_per_bundle = %d,\n",
- _pipeline->_maxInstrsPerBundle);
- fprintf(fp_hpp, " _max_bundles_per_cycle = %d,\n",
- _pipeline->_maxBundlesPerCycle);
- fprintf(fp_hpp, " _max_instrs_per_cycle = %d\n",
- _pipeline->_maxBundlesPerCycle * _pipeline->_maxInstrsPerBundle);
- fprintf(fp_hpp, " };\n\n");
-
- fprintf(fp_hpp, " static bool instr_has_unit_size() { return %s; }\n\n",
- _pipeline->_instrUnitSize != 0 ? "true" : "false" );
- if( _pipeline->_bundleUnitSize != 0 )
- if( _pipeline->_instrUnitSize != 0 )
- fprintf(fp_hpp, "// Individual Instructions may be bundled together by the hardware\n\n");
- else
- fprintf(fp_hpp, "// Instructions exist only in bundles\n\n");
- else
- fprintf(fp_hpp, "// Bundling is not supported\n\n");
- if( _pipeline->_instrUnitSize != 0 )
- fprintf(fp_hpp, " // Size of an instruction\n");
- else
- fprintf(fp_hpp, " // Size of an individual instruction does not exist - unsupported\n");
- fprintf(fp_hpp, " static uint instr_unit_size() {");
- if( _pipeline->_instrUnitSize == 0 )
- fprintf(fp_hpp, " assert( false, \"Instructions are only in bundles\" );");
- fprintf(fp_hpp, " return %d; };\n\n", _pipeline->_instrUnitSize);
-
- if( _pipeline->_bundleUnitSize != 0 )
- fprintf(fp_hpp, " // Size of a bundle\n");
- else
- fprintf(fp_hpp, " // Bundles do not exist - unsupported\n");
- fprintf(fp_hpp, " static uint bundle_unit_size() {");
- if( _pipeline->_bundleUnitSize == 0 )
- fprintf(fp_hpp, " assert( false, \"Bundles are not supported\" );");
- fprintf(fp_hpp, " return %d; };\n\n", _pipeline->_bundleUnitSize);
-
- fprintf(fp_hpp, " static bool requires_bundling() { return %s; }\n\n",
- _pipeline->_bundleUnitSize != 0 && _pipeline->_instrUnitSize == 0 ? "true" : "false" );
-
- fprintf(fp_hpp, "private:\n");
- fprintf(fp_hpp, " Pipeline(); // Not a legal constructor\n");
- fprintf(fp_hpp, "\n");
- fprintf(fp_hpp, " const unsigned char _read_stage_count;\n");
- fprintf(fp_hpp, " const unsigned char _write_stage;\n");
- fprintf(fp_hpp, " const unsigned char _fixed_latency;\n");
- fprintf(fp_hpp, " const unsigned char _instruction_count;\n");
- fprintf(fp_hpp, " const bool _has_fixed_latency;\n");
- fprintf(fp_hpp, " const bool _has_branch_delay;\n");
- fprintf(fp_hpp, " const bool _has_multiple_bundles;\n");
- fprintf(fp_hpp, " const bool _force_serialization;\n");
- fprintf(fp_hpp, " const bool _may_have_no_code;\n");
- fprintf(fp_hpp, " const enum machPipelineStages * const _read_stages;\n");
- fprintf(fp_hpp, " const enum machPipelineStages * const _resource_stage;\n");
- fprintf(fp_hpp, " const uint * const _resource_cycles;\n");
- fprintf(fp_hpp, " const Pipeline_Use _resource_use;\n");
- fprintf(fp_hpp, "\n");
- fprintf(fp_hpp, "public:\n");
- fprintf(fp_hpp, " Pipeline(uint write_stage,\n");
- fprintf(fp_hpp, " uint count,\n");
- fprintf(fp_hpp, " bool has_fixed_latency,\n");
- fprintf(fp_hpp, " uint fixed_latency,\n");
- fprintf(fp_hpp, " uint instruction_count,\n");
- fprintf(fp_hpp, " bool has_branch_delay,\n");
- fprintf(fp_hpp, " bool has_multiple_bundles,\n");
- fprintf(fp_hpp, " bool force_serialization,\n");
- fprintf(fp_hpp, " bool may_have_no_code,\n");
- fprintf(fp_hpp, " enum machPipelineStages * const dst,\n");
- fprintf(fp_hpp, " enum machPipelineStages * const stage,\n");
- fprintf(fp_hpp, " uint * const cycles,\n");
- fprintf(fp_hpp, " Pipeline_Use resource_use)\n");
- fprintf(fp_hpp, " : _write_stage(write_stage)\n");
- fprintf(fp_hpp, " , _read_stage_count(count)\n");
- fprintf(fp_hpp, " , _has_fixed_latency(has_fixed_latency)\n");
- fprintf(fp_hpp, " , _fixed_latency(fixed_latency)\n");
- fprintf(fp_hpp, " , _read_stages(dst)\n");
- fprintf(fp_hpp, " , _resource_stage(stage)\n");
- fprintf(fp_hpp, " , _resource_cycles(cycles)\n");
- fprintf(fp_hpp, " , _resource_use(resource_use)\n");
- fprintf(fp_hpp, " , _instruction_count(instruction_count)\n");
- fprintf(fp_hpp, " , _has_branch_delay(has_branch_delay)\n");
- fprintf(fp_hpp, " , _has_multiple_bundles(has_multiple_bundles)\n");
- fprintf(fp_hpp, " , _force_serialization(force_serialization)\n");
- fprintf(fp_hpp, " , _may_have_no_code(may_have_no_code)\n");
- fprintf(fp_hpp, " {};\n");
- fprintf(fp_hpp, "\n");
- fprintf(fp_hpp, " uint writeStage() const {\n");
- fprintf(fp_hpp, " return (_write_stage);\n");
- fprintf(fp_hpp, " }\n");
- fprintf(fp_hpp, "\n");
- fprintf(fp_hpp, " enum machPipelineStages readStage(int ndx) const {\n");
- fprintf(fp_hpp, " return (ndx < _read_stage_count ? _read_stages[ndx] : stage_undefined);");
- fprintf(fp_hpp, " }\n\n");
- fprintf(fp_hpp, " uint resourcesUsed() const {\n");
- fprintf(fp_hpp, " return _resource_use.resourcesUsed();\n }\n\n");
- fprintf(fp_hpp, " uint resourcesUsedExclusively() const {\n");
- fprintf(fp_hpp, " return _resource_use.resourcesUsedExclusively();\n }\n\n");
- fprintf(fp_hpp, " bool hasFixedLatency() const {\n");
- fprintf(fp_hpp, " return (_has_fixed_latency);\n }\n\n");
- fprintf(fp_hpp, " uint fixedLatency() const {\n");
- fprintf(fp_hpp, " return (_fixed_latency);\n }\n\n");
- fprintf(fp_hpp, " uint functional_unit_latency(uint start, const Pipeline *pred) const;\n\n");
- fprintf(fp_hpp, " uint operand_latency(uint opnd, const Pipeline *pred) const;\n\n");
- fprintf(fp_hpp, " const Pipeline_Use& resourceUse() const {\n");
- fprintf(fp_hpp, " return (_resource_use); }\n\n");
- fprintf(fp_hpp, " const Pipeline_Use_Element * resourceUseElement(uint i) const {\n");
- fprintf(fp_hpp, " return (&_resource_use._elements[i]); }\n\n");
- fprintf(fp_hpp, " uint resourceUseCount() const {\n");
- fprintf(fp_hpp, " return (_resource_use._count); }\n\n");
- fprintf(fp_hpp, " uint instructionCount() const {\n");
- fprintf(fp_hpp, " return (_instruction_count); }\n\n");
- fprintf(fp_hpp, " bool hasBranchDelay() const {\n");
- fprintf(fp_hpp, " return (_has_branch_delay); }\n\n");
- fprintf(fp_hpp, " bool hasMultipleBundles() const {\n");
- fprintf(fp_hpp, " return (_has_multiple_bundles); }\n\n");
- fprintf(fp_hpp, " bool forceSerialization() const {\n");
- fprintf(fp_hpp, " return (_force_serialization); }\n\n");
- fprintf(fp_hpp, " bool mayHaveNoCode() const {\n");
- fprintf(fp_hpp, " return (_may_have_no_code); }\n\n");
- fprintf(fp_hpp, "//const Pipeline_Use_Cycle_Mask& resourceUseMask(int resource) const {\n");
- fprintf(fp_hpp, "// return (_resource_use_masks[resource]); }\n\n");
- fprintf(fp_hpp, "\n#ifndef PRODUCT\n");
- fprintf(fp_hpp, " static const char * stageName(uint i);\n");
- fprintf(fp_hpp, "#endif\n");
- fprintf(fp_hpp, "};\n\n");
-
- fprintf(fp_hpp, "// Bundle class\n");
- fprintf(fp_hpp, "class Bundle {\n");
-
- uint mshift = 0;
- for (uint msize = _pipeline->_maxInstrsPerBundle * _pipeline->_maxBundlesPerCycle; msize != 0; msize >>= 1)
- mshift++;
-
- uint rshift = rescount;
-
- fprintf(fp_hpp, "protected:\n");
- fprintf(fp_hpp, " enum {\n");
- fprintf(fp_hpp, " _unused_delay = 0x%x,\n", 0);
- fprintf(fp_hpp, " _use_nop_delay = 0x%x,\n", 1);
- fprintf(fp_hpp, " _use_unconditional_delay = 0x%x,\n", 2);
- fprintf(fp_hpp, " _use_conditional_delay = 0x%x,\n", 3);
- fprintf(fp_hpp, " _used_in_conditional_delay = 0x%x,\n", 4);
- fprintf(fp_hpp, " _used_in_unconditional_delay = 0x%x,\n", 5);
- fprintf(fp_hpp, " _used_in_all_conditional_delays = 0x%x,\n", 6);
- fprintf(fp_hpp, "\n");
- fprintf(fp_hpp, " _use_delay = 0x%x,\n", 3);
- fprintf(fp_hpp, " _used_in_delay = 0x%x\n", 4);
- fprintf(fp_hpp, " };\n\n");
- fprintf(fp_hpp, " uint _flags : 3,\n");
- fprintf(fp_hpp, " _starts_bundle : 1,\n");
- fprintf(fp_hpp, " _instr_count : %d,\n", mshift);
- fprintf(fp_hpp, " _resources_used : %d;\n", rshift);
- fprintf(fp_hpp, "public:\n");
- fprintf(fp_hpp, " Bundle() : _flags(_unused_delay), _starts_bundle(0), _instr_count(0), _resources_used(0) {}\n\n");
- fprintf(fp_hpp, " void set_instr_count(uint i) { _instr_count = i; }\n");
- fprintf(fp_hpp, " void set_resources_used(uint i) { _resources_used = i; }\n");
- fprintf(fp_hpp, " void clear_usage() { _flags = _unused_delay; }\n");
- fprintf(fp_hpp, " void set_starts_bundle() { _starts_bundle = true; }\n");
-
- fprintf(fp_hpp, " uint flags() const { return (_flags); }\n");
- fprintf(fp_hpp, " uint instr_count() const { return (_instr_count); }\n");
- fprintf(fp_hpp, " uint resources_used() const { return (_resources_used); }\n");
- fprintf(fp_hpp, " bool starts_bundle() const { return (_starts_bundle != 0); }\n");
-
- fprintf(fp_hpp, " void set_use_nop_delay() { _flags = _use_nop_delay; }\n");
- fprintf(fp_hpp, " void set_use_unconditional_delay() { _flags = _use_unconditional_delay; }\n");
- fprintf(fp_hpp, " void set_use_conditional_delay() { _flags = _use_conditional_delay; }\n");
- fprintf(fp_hpp, " void set_used_in_unconditional_delay() { _flags = _used_in_unconditional_delay; }\n");
- fprintf(fp_hpp, " void set_used_in_conditional_delay() { _flags = _used_in_conditional_delay; }\n");
- fprintf(fp_hpp, " void set_used_in_all_conditional_delays() { _flags = _used_in_all_conditional_delays; }\n");
-
- fprintf(fp_hpp, " bool use_nop_delay() { return (_flags == _use_nop_delay); }\n");
- fprintf(fp_hpp, " bool use_unconditional_delay() { return (_flags == _use_unconditional_delay); }\n");
- fprintf(fp_hpp, " bool use_conditional_delay() { return (_flags == _use_conditional_delay); }\n");
- fprintf(fp_hpp, " bool used_in_unconditional_delay() { return (_flags == _used_in_unconditional_delay); }\n");
- fprintf(fp_hpp, " bool used_in_conditional_delay() { return (_flags == _used_in_conditional_delay); }\n");
- fprintf(fp_hpp, " bool used_in_all_conditional_delays() { return (_flags == _used_in_all_conditional_delays); }\n");
- fprintf(fp_hpp, " bool use_delay() { return ((_flags & _use_delay) != 0); }\n");
- fprintf(fp_hpp, " bool used_in_delay() { return ((_flags & _used_in_delay) != 0); }\n\n");
-
- fprintf(fp_hpp, " enum {\n");
- fprintf(fp_hpp, " _nop_count = %d\n",
- _pipeline->_nopcnt);
- fprintf(fp_hpp, " };\n\n");
- fprintf(fp_hpp, " static void initialize_nops(MachNode *nop_list[%d], Compile* C);\n\n",
- _pipeline->_nopcnt);
- fprintf(fp_hpp, "#ifndef PRODUCT\n");
- fprintf(fp_hpp, " void dump() const;\n");
- fprintf(fp_hpp, "#endif\n");
- fprintf(fp_hpp, "};\n\n");
-
- // const char *classname;
- // for (_pipeline->_classlist.reset(); (classname = _pipeline->_classlist.iter()) != NULL; ) {
- // PipeClassForm *pipeclass = _pipeline->_classdict[classname]->is_pipeclass();
- // fprintf(fp_hpp, "// Pipeline Class Instance for \"%s\"\n", classname);
- // }
- }
-
- //------------------------------declareClasses---------------------------------
- // Construct the class hierarchy of MachNode classes from the instruction &
- // operand lists
- void ArchDesc::declareClasses(FILE *fp) {
-
- // Declare…
Large files files are truncated, but you can click here to view the full file