0N/A//
3845N/A// Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
0N/A// DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A//
0N/A// This code is free software; you can redistribute it and/or modify it
0N/A// under the terms of the GNU General Public License version 2 only, as
0N/A// published by the Free Software Foundation.
0N/A//
0N/A// This code is distributed in the hope that it will be useful, but WITHOUT
0N/A// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A// version 2 for more details (a copy is included in the LICENSE file that
0N/A// accompanied this code).
0N/A//
0N/A// You should have received a copy of the GNU General Public License version
0N/A// 2 along with this work; if not, write to the Free Software Foundation,
0N/A// Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A//
1472N/A// Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1472N/A// or visit www.oracle.com if you need additional information or have any
1472N/A// questions.
0N/A//
0N/A//
0N/A
0N/A
0N/A// archDesc.cpp - Internal format for architecture definition
0N/A#include "adlc.hpp"
0N/A
0N/Astatic FILE *errfile = stderr;
0N/A
0N/A//--------------------------- utility functions -----------------------------
0N/Ainline char toUpper(char lower) {
0N/A return (('a' <= lower && lower <= 'z') ? (lower + ('A'-'a')) : lower);
0N/A}
0N/Achar *toUpper(const char *str) {
0N/A char *upper = new char[strlen(str)+1];
0N/A char *result = upper;
0N/A const char *end = str + strlen(str);
0N/A for (; str < end; ++str, ++upper) {
0N/A *upper = toUpper(*str);
0N/A }
0N/A *upper = '\0';
0N/A return result;
0N/A}
0N/A
0N/A// Utilities to characterize effect statements
0N/Astatic bool is_def(int usedef) {
0N/A switch(usedef) {
0N/A case Component::DEF:
0N/A case Component::USE_DEF: return true; break;
0N/A }
0N/A return false;
0N/A}
0N/A
0N/Astatic bool is_use(int usedef) {
0N/A switch(usedef) {
0N/A case Component::USE:
0N/A case Component::USE_DEF:
0N/A case Component::USE_KILL: return true; break;
0N/A }
0N/A return false;
0N/A}
0N/A
0N/Astatic bool is_kill(int usedef) {
0N/A switch(usedef) {
0N/A case Component::KILL:
0N/A case Component::USE_KILL: return true; break;
0N/A }
0N/A return false;
0N/A}
0N/A
0N/A//---------------------------ChainList Methods-------------------------------
0N/AChainList::ChainList() {
0N/A}
0N/A
0N/Avoid ChainList::insert(const char *name, const char *cost, const char *rule) {
0N/A _name.addName(name);
0N/A _cost.addName(cost);
0N/A _rule.addName(rule);
0N/A}
0N/A
0N/Abool ChainList::search(const char *name) {
0N/A return _name.search(name);
0N/A}
0N/A
0N/Avoid ChainList::reset() {
0N/A _name.reset();
0N/A _cost.reset();
0N/A _rule.reset();
0N/A}
0N/A
0N/Abool ChainList::iter(const char * &name, const char * &cost, const char * &rule) {
0N/A bool notDone = false;
0N/A const char *n = _name.iter();
0N/A const char *c = _cost.iter();
0N/A const char *r = _rule.iter();
0N/A
0N/A if (n && c && r) {
0N/A notDone = true;
0N/A name = n;
0N/A cost = c;
0N/A rule = r;
0N/A }
0N/A
0N/A return notDone;
0N/A}
0N/A
0N/Avoid ChainList::dump() {
0N/A output(stderr);
0N/A}
0N/A
0N/Avoid ChainList::output(FILE *fp) {
0N/A fprintf(fp, "\nChain Rules: output resets iterator\n");
0N/A const char *cost = NULL;
0N/A const char *name = NULL;
0N/A const char *rule = NULL;
0N/A bool chains_exist = false;
0N/A for(reset(); (iter(name,cost,rule)) == true; ) {
0N/A fprintf(fp, "Chain to <%s> at cost #%s using %s_rule\n",name, cost ? cost : "0", rule);
0N/A // // Check for transitive chain rules
0N/A // Form *form = (Form *)_globalNames[rule];
0N/A // if (form->is_instruction()) {
0N/A // // chain_rule(fp, indent, name, cost, rule);
0N/A // chain_rule(fp, indent, name, cost, rule);
0N/A // }
0N/A }
0N/A reset();
0N/A if( ! chains_exist ) {
0N/A fprintf(fp, "No entries in this ChainList\n");
0N/A }
0N/A}
0N/A
0N/A
0N/A//---------------------------MatchList Methods-------------------------------
0N/Abool MatchList::search(const char *opc, const char *res, const char *lch,
0N/A const char *rch, Predicate *pr) {
0N/A bool tmp = false;
0N/A if ((res == _resultStr) || (res && _resultStr && !strcmp(res, _resultStr))) {
0N/A if ((lch == _lchild) || (lch && _lchild && !strcmp(lch, _lchild))) {
0N/A if ((rch == _rchild) || (rch && _rchild && !strcmp(rch, _rchild))) {
0N/A char * predStr = get_pred();
0N/A char * prStr = pr?pr->_pred:NULL;
475N/A if (ADLParser::equivalent_expressions(prStr, predStr)) {
0N/A return true;
0N/A }
0N/A }
0N/A }
0N/A }
0N/A if (_next) {
0N/A tmp = _next->search(opc, res, lch, rch, pr);
0N/A }
0N/A return tmp;
0N/A}
0N/A
0N/A
0N/Avoid MatchList::dump() {
0N/A output(stderr);
0N/A}
0N/A
0N/Avoid MatchList::output(FILE *fp) {
0N/A fprintf(fp, "\nMatchList output is Unimplemented();\n");
0N/A}
0N/A
0N/A
0N/A//---------------------------ArchDesc Constructor and Destructor-------------
0N/A
0N/AArchDesc::ArchDesc()
0N/A : _globalNames(cmpstr,hashstr, Form::arena),
0N/A _globalDefs(cmpstr,hashstr, Form::arena),
0N/A _preproc_table(cmpstr,hashstr, Form::arena),
0N/A _idealIndex(cmpstr,hashstr, Form::arena),
0N/A _internalOps(cmpstr,hashstr, Form::arena),
0N/A _internalMatch(cmpstr,hashstr, Form::arena),
0N/A _chainRules(cmpstr,hashstr, Form::arena),
0N/A _cisc_spill_operand(NULL) {
0N/A
0N/A // Initialize the opcode to MatchList table with NULLs
0N/A for( int i=0; i<_last_opcode; ++i ) {
0N/A _mlistab[i] = NULL;
0N/A }
0N/A
0N/A // Set-up the global tables
0N/A initKeywords(_globalNames); // Initialize the Name Table with keywords
0N/A
0N/A // Prime user-defined types with predefined types: Set, RegI, RegF, ...
0N/A initBaseOpTypes();
0N/A
0N/A // Initialize flags & counters
0N/A _TotalLines = 0;
0N/A _no_output = 0;
0N/A _quiet_mode = 0;
0N/A _disable_warnings = 0;
0N/A _dfa_debug = 0;
0N/A _dfa_small = 0;
0N/A _adl_debug = 0;
0N/A _adlocation_debug = 0;
0N/A _internalOpCounter = 0;
0N/A _cisc_spill_debug = false;
0N/A _short_branch_debug = false;
0N/A
0N/A // Initialize match rule flags
0N/A for (int i = 0; i < _last_opcode; i++) {
0N/A _has_match_rule[i] = false;
0N/A }
0N/A
0N/A // Error/Warning Counts
0N/A _syntax_errs = 0;
0N/A _semantic_errs = 0;
0N/A _warnings = 0;
0N/A _internal_errs = 0;
0N/A
0N/A // Initialize I/O Files
0N/A _ADL_file._name = NULL; _ADL_file._fp = NULL;
0N/A // Machine dependent output files
433N/A _DFA_file._name = NULL; _DFA_file._fp = NULL;
433N/A _HPP_file._name = NULL; _HPP_file._fp = NULL;
433N/A _CPP_file._name = NULL; _CPP_file._fp = NULL;
0N/A _bug_file._name = "bugs.out"; _bug_file._fp = NULL;
0N/A
0N/A // Initialize Register & Pipeline Form Pointers
0N/A _register = NULL;
0N/A _encode = NULL;
0N/A _pipeline = NULL;
4033N/A _frame = NULL;
0N/A}
0N/A
0N/AArchDesc::~ArchDesc() {
0N/A // Clean-up and quit
0N/A
0N/A}
0N/A
0N/A//---------------------------ArchDesc methods: Public ----------------------
0N/A// Store forms according to type
0N/Avoid ArchDesc::addForm(PreHeaderForm *ptr) { _pre_header.addForm(ptr); };
0N/Avoid ArchDesc::addForm(HeaderForm *ptr) { _header.addForm(ptr); };
0N/Avoid ArchDesc::addForm(SourceForm *ptr) { _source.addForm(ptr); };
0N/Avoid ArchDesc::addForm(EncodeForm *ptr) { _encode = ptr; };
0N/Avoid ArchDesc::addForm(InstructForm *ptr) { _instructions.addForm(ptr); };
0N/Avoid ArchDesc::addForm(MachNodeForm *ptr) { _machnodes.addForm(ptr); };
0N/Avoid ArchDesc::addForm(OperandForm *ptr) { _operands.addForm(ptr); };
0N/Avoid ArchDesc::addForm(OpClassForm *ptr) { _opclass.addForm(ptr); };
0N/Avoid ArchDesc::addForm(AttributeForm *ptr) { _attributes.addForm(ptr); };
0N/Avoid ArchDesc::addForm(RegisterForm *ptr) { _register = ptr; };
0N/Avoid ArchDesc::addForm(FrameForm *ptr) { _frame = ptr; };
0N/Avoid ArchDesc::addForm(PipelineForm *ptr) { _pipeline = ptr; };
0N/A
0N/A// Build MatchList array and construct MatchLists
0N/Avoid ArchDesc::generateMatchLists() {
0N/A // Call inspection routines to populate array
0N/A inspectOperands();
0N/A inspectInstructions();
0N/A}
0N/A
0N/A// Build MatchList structures for operands
0N/Avoid ArchDesc::inspectOperands() {
0N/A
0N/A // Iterate through all operands
0N/A _operands.reset();
0N/A OperandForm *op;
0N/A for( ; (op = (OperandForm*)_operands.iter()) != NULL;) {
0N/A // Construct list of top-level operands (components)
0N/A op->build_components();
0N/A
0N/A // Ensure that match field is defined.
0N/A if ( op->_matrule == NULL ) continue;
0N/A
0N/A // Type check match rules
0N/A check_optype(op->_matrule);
0N/A
0N/A // Construct chain rules
0N/A build_chain_rule(op);
0N/A
0N/A MatchRule &mrule = *op->_matrule;
0N/A Predicate *pred = op->_predicate;
0N/A
0N/A // Grab the machine type of the operand
0N/A const char *rootOp = op->_ident;
0N/A mrule._machType = rootOp;
0N/A
0N/A // Check for special cases
0N/A if (strcmp(rootOp,"Universe")==0) continue;
0N/A if (strcmp(rootOp,"label")==0) continue;
0N/A // !!!!! !!!!!
0N/A assert( strcmp(rootOp,"sReg") != 0, "Disable untyped 'sReg'");
0N/A if (strcmp(rootOp,"sRegI")==0) continue;
0N/A if (strcmp(rootOp,"sRegP")==0) continue;
0N/A if (strcmp(rootOp,"sRegF")==0) continue;
0N/A if (strcmp(rootOp,"sRegD")==0) continue;
0N/A if (strcmp(rootOp,"sRegL")==0) continue;
0N/A
0N/A // Cost for this match
0N/A const char *costStr = op->cost();
0N/A const char *defaultCost =
0N/A ((AttributeForm*)_globalNames[AttributeForm::_op_cost])->_attrdef;
0N/A const char *cost = costStr? costStr : defaultCost;
0N/A
0N/A // Find result type for match.
0N/A const char *result = op->reduce_result();
0N/A bool has_root = false;
0N/A
0N/A // Construct a MatchList for this entry
0N/A buildMatchList(op->_matrule, result, rootOp, pred, cost);
0N/A }
0N/A}
0N/A
0N/A// Build MatchList structures for instructions
0N/Avoid ArchDesc::inspectInstructions() {
0N/A
0N/A // Iterate through all instructions
0N/A _instructions.reset();
0N/A InstructForm *instr;
0N/A for( ; (instr = (InstructForm*)_instructions.iter()) != NULL; ) {
0N/A // Construct list of top-level operands (components)
0N/A instr->build_components();
0N/A
0N/A // Ensure that match field is defined.
0N/A if ( instr->_matrule == NULL ) continue;
0N/A
0N/A MatchRule &mrule = *instr->_matrule;
0N/A Predicate *pred = instr->build_predicate();
0N/A
0N/A // Grab the machine type of the operand
0N/A const char *rootOp = instr->_ident;
0N/A mrule._machType = rootOp;
0N/A
0N/A // Cost for this match
0N/A const char *costStr = instr->cost();
0N/A const char *defaultCost =
0N/A ((AttributeForm*)_globalNames[AttributeForm::_ins_cost])->_attrdef;
0N/A const char *cost = costStr? costStr : defaultCost;
0N/A
0N/A // Find result type for match
0N/A const char *result = instr->reduce_result();
0N/A
2678N/A if ( instr->is_ideal_branch() && instr->label_position() == -1 ||
2678N/A !instr->is_ideal_branch() && instr->label_position() != -1) {
2678N/A syntax_err(instr->_linenum, "%s: Only branches to a label are supported\n", rootOp);
2678N/A }
2678N/A
0N/A Attribute *attr = instr->_attribs;
0N/A while (attr != NULL) {
0N/A if (strcmp(attr->_ident,"ins_short_branch") == 0 &&
0N/A attr->int_val(*this) != 0) {
2667N/A if (!instr->is_ideal_branch() || instr->label_position() == -1) {
2667N/A syntax_err(instr->_linenum, "%s: Only short branch to a label is supported\n", rootOp);
2667N/A }
0N/A instr->set_short_branch(true);
0N/A } else if (strcmp(attr->_ident,"ins_alignment") == 0 &&
0N/A attr->int_val(*this) != 0) {
0N/A instr->set_alignment(attr->int_val(*this));
0N/A }
0N/A attr = (Attribute *)attr->_next;
0N/A }
0N/A
0N/A if (!instr->is_short_branch()) {
0N/A buildMatchList(instr->_matrule, result, mrule._machType, pred, cost);
0N/A }
0N/A }
0N/A}
0N/A
0N/Astatic int setsResult(MatchRule &mrule) {
0N/A if (strcmp(mrule._name,"Set") == 0) return 1;
0N/A return 0;
0N/A}
0N/A
0N/Aconst char *ArchDesc::getMatchListIndex(MatchRule &mrule) {
0N/A if (setsResult(mrule)) {
0N/A // right child
0N/A return mrule._rChild->_opType;
0N/A } else {
0N/A // first entry
0N/A return mrule._opType;
0N/A }
0N/A}
0N/A
0N/A
0N/A//------------------------------result of reduction----------------------------
0N/A
0N/A
0N/A//------------------------------left reduction---------------------------------
0N/A// Return the left reduction associated with an internal name
0N/Aconst char *ArchDesc::reduceLeft(char *internalName) {
0N/A const char *left = NULL;
0N/A MatchNode *mnode = (MatchNode*)_internalMatch[internalName];
0N/A if (mnode->_lChild) {
0N/A mnode = mnode->_lChild;
0N/A left = mnode->_internalop ? mnode->_internalop : mnode->_opType;
0N/A }
0N/A return left;
0N/A}
0N/A
0N/A
0N/A//------------------------------right reduction--------------------------------
0N/Aconst char *ArchDesc::reduceRight(char *internalName) {
0N/A const char *right = NULL;
0N/A MatchNode *mnode = (MatchNode*)_internalMatch[internalName];
0N/A if (mnode->_rChild) {
0N/A mnode = mnode->_rChild;
0N/A right = mnode->_internalop ? mnode->_internalop : mnode->_opType;
0N/A }
0N/A return right;
0N/A}
0N/A
0N/A
0N/A//------------------------------check_optype-----------------------------------
0N/Avoid ArchDesc::check_optype(MatchRule *mrule) {
0N/A MatchRule *rule = mrule;
0N/A
0N/A // !!!!!
0N/A // // Cycle through the list of match rules
0N/A // while(mrule) {
0N/A // // Check for a filled in type field
0N/A // if (mrule->_opType == NULL) {
0N/A // const Form *form = operands[_result];
0N/A // OpClassForm *opcForm = form ? form->is_opclass() : NULL;
0N/A // assert(opcForm != NULL, "Match Rule contains invalid operand name.");
0N/A // }
0N/A // char *opType = opcForm->_ident;
0N/A // }
0N/A}
0N/A
0N/A//------------------------------add_chain_rule_entry--------------------------
0N/Avoid ArchDesc::add_chain_rule_entry(const char *src, const char *cost,
0N/A const char *result) {
0N/A // Look-up the operation in chain rule table
0N/A ChainList *lst = (ChainList *)_chainRules[src];
0N/A if (lst == NULL) {
0N/A lst = new ChainList();
0N/A _chainRules.Insert(src, lst);
0N/A }
0N/A if (!lst->search(result)) {
0N/A if (cost == NULL) {
0N/A cost = ((AttributeForm*)_globalNames[AttributeForm::_op_cost])->_attrdef;
0N/A }
0N/A lst->insert(result, cost, result);
0N/A }
0N/A}
0N/A
0N/A//------------------------------build_chain_rule-------------------------------
0N/Avoid ArchDesc::build_chain_rule(OperandForm *oper) {
0N/A MatchRule *rule;
0N/A
0N/A // Check for chain rules here
0N/A // If this is only a chain rule
0N/A if ((oper->_matrule) && (oper->_matrule->_lChild == NULL) &&
0N/A (oper->_matrule->_rChild == NULL)) {
0N/A
603N/A {
603N/A const Form *form = _globalNames[oper->_matrule->_opType];
603N/A if ((form) && form->is_operand() &&
603N/A (form->ideal_only() == false)) {
603N/A add_chain_rule_entry(oper->_matrule->_opType, oper->cost(), oper->_ident);
603N/A }
0N/A }
0N/A // Check for additional chain rules
0N/A if (oper->_matrule->_next) {
0N/A rule = oper->_matrule;
0N/A do {
0N/A rule = rule->_next;
0N/A // Any extra match rules after the first must be chain rules
0N/A const Form *form = _globalNames[rule->_opType];
0N/A if ((form) && form->is_operand() &&
0N/A (form->ideal_only() == false)) {
0N/A add_chain_rule_entry(rule->_opType, oper->cost(), oper->_ident);
0N/A }
0N/A } while(rule->_next != NULL);
0N/A }
0N/A }
0N/A else if ((oper->_matrule) && (oper->_matrule->_next)) {
0N/A // Regardles of whether the first matchrule is a chain rule, check the list
0N/A rule = oper->_matrule;
0N/A do {
0N/A rule = rule->_next;
0N/A // Any extra match rules after the first must be chain rules
0N/A const Form *form = _globalNames[rule->_opType];
0N/A if ((form) && form->is_operand() &&
0N/A (form->ideal_only() == false)) {
0N/A assert( oper->cost(), "This case expects NULL cost, not default cost");
0N/A add_chain_rule_entry(rule->_opType, oper->cost(), oper->_ident);
0N/A }
0N/A } while(rule->_next != NULL);
0N/A }
0N/A
0N/A}
0N/A
0N/A//------------------------------buildMatchList---------------------------------
0N/A// operands and instructions provide the result
0N/Avoid ArchDesc::buildMatchList(MatchRule *mrule, const char *resultStr,
0N/A const char *rootOp, Predicate *pred,
0N/A const char *cost) {
0N/A const char *leftstr, *rightstr;
0N/A MatchNode *mnode;
0N/A
0N/A leftstr = rightstr = NULL;
0N/A // Check for chain rule, and do not generate a match list for it
0N/A if ( mrule->is_chain_rule(_globalNames) ) {
0N/A return;
0N/A }
0N/A
0N/A // Identify index position among ideal operands
0N/A intptr_t index = _last_opcode;
0N/A const char *indexStr = getMatchListIndex(*mrule);
0N/A index = (intptr_t)_idealIndex[indexStr];
0N/A if (index == 0) {
0N/A fprintf(stderr, "Ideal node missing: %s\n", indexStr);
0N/A assert(index != 0, "Failed lookup of ideal node\n");
0N/A }
0N/A
0N/A // Check that this will be placed appropriately in the DFA
0N/A if (index >= _last_opcode) {
0N/A fprintf(stderr, "Invalid match rule %s <-- ( %s )\n",
0N/A resultStr ? resultStr : " ",
0N/A rootOp ? rootOp : " ");
0N/A assert(index < _last_opcode, "Matching item not in ideal graph\n");
0N/A return;
0N/A }
0N/A
0N/A
0N/A // Walk the MatchRule, generating MatchList entries for each level
0N/A // of the rule (each nesting of parentheses)
0N/A // Check for "Set"
0N/A if (!strcmp(mrule->_opType, "Set")) {
0N/A mnode = mrule->_rChild;
0N/A buildMList(mnode, rootOp, resultStr, pred, cost);
0N/A return;
0N/A }
0N/A // Build MatchLists for children
0N/A // Check each child for an internal operand name, and use that name
0N/A // for the parent's matchlist entry if it exists
0N/A mnode = mrule->_lChild;
0N/A if (mnode) {
0N/A buildMList(mnode, NULL, NULL, NULL, NULL);
0N/A leftstr = mnode->_internalop ? mnode->_internalop : mnode->_opType;
0N/A }
0N/A mnode = mrule->_rChild;
0N/A if (mnode) {
0N/A buildMList(mnode, NULL, NULL, NULL, NULL);
0N/A rightstr = mnode->_internalop ? mnode->_internalop : mnode->_opType;
0N/A }
0N/A // Search for an identical matchlist entry already on the list
0N/A if ((_mlistab[index] == NULL) ||
0N/A (_mlistab[index] &&
0N/A !_mlistab[index]->search(rootOp, resultStr, leftstr, rightstr, pred))) {
0N/A // Place this match rule at front of list
0N/A MatchList *mList =
0N/A new MatchList(_mlistab[index], pred, cost,
0N/A rootOp, resultStr, leftstr, rightstr);
0N/A _mlistab[index] = mList;
0N/A }
0N/A}
0N/A
0N/A// Recursive call for construction of match lists
0N/Avoid ArchDesc::buildMList(MatchNode *node, const char *rootOp,
0N/A const char *resultOp, Predicate *pred,
0N/A const char *cost) {
0N/A const char *leftstr, *rightstr;
0N/A const char *resultop;
0N/A const char *opcode;
0N/A MatchNode *mnode;
0N/A Form *form;
0N/A
0N/A leftstr = rightstr = NULL;
0N/A // Do not process leaves of the Match Tree if they are not ideal
0N/A if ((node) && (node->_lChild == NULL) && (node->_rChild == NULL) &&
0N/A ((form = (Form *)_globalNames[node->_opType]) != NULL) &&
0N/A (!form->ideal_only())) {
0N/A return;
0N/A }
0N/A
0N/A // Identify index position among ideal operands
0N/A intptr_t index = _last_opcode;
0N/A const char *indexStr = node ? node->_opType : (char *) " ";
0N/A index = (intptr_t)_idealIndex[indexStr];
0N/A if (index == 0) {
0N/A fprintf(stderr, "error: operand \"%s\" not found\n", indexStr);
0N/A assert(0, "fatal error");
0N/A }
0N/A
0N/A // Build MatchLists for children
0N/A // Check each child for an internal operand name, and use that name
0N/A // for the parent's matchlist entry if it exists
0N/A mnode = node->_lChild;
0N/A if (mnode) {
0N/A buildMList(mnode, NULL, NULL, NULL, NULL);
0N/A leftstr = mnode->_internalop ? mnode->_internalop : mnode->_opType;
0N/A }
0N/A mnode = node->_rChild;
0N/A if (mnode) {
0N/A buildMList(mnode, NULL, NULL, NULL, NULL);
0N/A rightstr = mnode->_internalop ? mnode->_internalop : mnode->_opType;
0N/A }
0N/A // Grab the string for the opcode of this list entry
0N/A if (rootOp == NULL) {
0N/A opcode = (node->_internalop) ? node->_internalop : node->_opType;
0N/A } else {
0N/A opcode = rootOp;
0N/A }
0N/A // Grab the string for the result of this list entry
0N/A if (resultOp == NULL) {
0N/A resultop = (node->_internalop) ? node->_internalop : node->_opType;
0N/A }
0N/A else resultop = resultOp;
0N/A // Search for an identical matchlist entry already on the list
0N/A if ((_mlistab[index] == NULL) || (_mlistab[index] &&
0N/A !_mlistab[index]->search(opcode, resultop, leftstr, rightstr, pred))) {
0N/A // Place this match rule at front of list
0N/A MatchList *mList =
0N/A new MatchList(_mlistab[index],pred,cost,
0N/A opcode, resultop, leftstr, rightstr);
0N/A _mlistab[index] = mList;
0N/A }
0N/A}
0N/A
0N/A// Count number of OperandForms defined
0N/Aint ArchDesc::operandFormCount() {
0N/A // Only interested in ones with non-NULL match rule
0N/A int count = 0; _operands.reset();
0N/A OperandForm *cur;
0N/A for( ; (cur = (OperandForm*)_operands.iter()) != NULL; ) {
0N/A if (cur->_matrule != NULL) ++count;
0N/A };
0N/A return count;
0N/A}
0N/A
0N/A// Count number of OpClassForms defined
0N/Aint ArchDesc::opclassFormCount() {
0N/A // Only interested in ones with non-NULL match rule
0N/A int count = 0; _operands.reset();
0N/A OpClassForm *cur;
0N/A for( ; (cur = (OpClassForm*)_opclass.iter()) != NULL; ) {
0N/A ++count;
0N/A };
0N/A return count;
0N/A}
0N/A
0N/A// Count number of InstructForms defined
0N/Aint ArchDesc::instructFormCount() {
0N/A // Only interested in ones with non-NULL match rule
0N/A int count = 0; _instructions.reset();
0N/A InstructForm *cur;
0N/A for( ; (cur = (InstructForm*)_instructions.iter()) != NULL; ) {
0N/A if (cur->_matrule != NULL) ++count;
0N/A };
0N/A return count;
0N/A}
0N/A
0N/A
0N/A//------------------------------get_preproc_def--------------------------------
0N/A// Return the textual binding for a given CPP flag name.
0N/A// Return NULL if there is no binding, or it has been #undef-ed.
0N/Achar* ArchDesc::get_preproc_def(const char* flag) {
4033N/A // In case of syntax errors, flag may take the value NULL.
4033N/A SourceForm* deff = NULL;
4033N/A if (flag != NULL)
4033N/A deff = (SourceForm*) _preproc_table[flag];
0N/A return (deff == NULL) ? NULL : deff->_code;
0N/A}
0N/A
0N/A
0N/A//------------------------------set_preproc_def--------------------------------
0N/A// Change or create a textual binding for a given CPP flag name.
0N/A// Giving NULL means the flag name is to be #undef-ed.
0N/A// In any case, _preproc_list collects all names either #defined or #undef-ed.
0N/Avoid ArchDesc::set_preproc_def(const char* flag, const char* def) {
0N/A SourceForm* deff = (SourceForm*) _preproc_table[flag];
0N/A if (deff == NULL) {
0N/A deff = new SourceForm(NULL);
0N/A _preproc_table.Insert(flag, deff);
0N/A _preproc_list.addName(flag); // this supports iteration
0N/A }
0N/A deff->_code = (char*) def;
0N/A}
0N/A
0N/A
0N/Abool ArchDesc::verify() {
0N/A
0N/A if (_register)
0N/A assert( _register->verify(), "Register declarations failed verification");
0N/A if (!_quiet_mode)
0N/A fprintf(stderr,"\n");
0N/A // fprintf(stderr,"---------------------------- Verify Operands ---------------\n");
0N/A // _operands.verify();
0N/A // fprintf(stderr,"\n");
0N/A // fprintf(stderr,"---------------------------- Verify Operand Classes --------\n");
0N/A // _opclass.verify();
0N/A // fprintf(stderr,"\n");
0N/A // fprintf(stderr,"---------------------------- Verify Attributes ------------\n");
0N/A // _attributes.verify();
0N/A // fprintf(stderr,"\n");
0N/A if (!_quiet_mode)
0N/A fprintf(stderr,"---------------------------- Verify Instructions ----------------------------\n");
0N/A _instructions.verify();
0N/A if (!_quiet_mode)
0N/A fprintf(stderr,"\n");
0N/A // if ( _encode ) {
0N/A // fprintf(stderr,"---------------------------- Verify Encodings --------------\n");
0N/A // _encode->verify();
0N/A // }
0N/A
0N/A //if (_pipeline) _pipeline->verify();
0N/A
0N/A return true;
0N/A}
0N/A
0N/A
0N/Avoid ArchDesc::dump() {
0N/A _pre_header.dump();
0N/A _header.dump();
0N/A _source.dump();
0N/A if (_register) _register->dump();
0N/A fprintf(stderr,"\n");
0N/A fprintf(stderr,"------------------ Dump Operands ---------------------\n");
0N/A _operands.dump();
0N/A fprintf(stderr,"\n");
0N/A fprintf(stderr,"------------------ Dump Operand Classes --------------\n");
0N/A _opclass.dump();
0N/A fprintf(stderr,"\n");
0N/A fprintf(stderr,"------------------ Dump Attributes ------------------\n");
0N/A _attributes.dump();
0N/A fprintf(stderr,"\n");
0N/A fprintf(stderr,"------------------ Dump Instructions -----------------\n");
0N/A _instructions.dump();
0N/A if ( _encode ) {
0N/A fprintf(stderr,"------------------ Dump Encodings --------------------\n");
0N/A _encode->dump();
0N/A }
0N/A if (_pipeline) _pipeline->dump();
0N/A}
0N/A
0N/A
0N/A//------------------------------init_keywords----------------------------------
0N/A// Load the kewords into the global name table
0N/Avoid ArchDesc::initKeywords(FormDict& names) {
0N/A // Insert keyword strings into Global Name Table. Keywords have a NULL value
0N/A // field for quick easy identification when checking identifiers.
0N/A names.Insert("instruct", NULL);
0N/A names.Insert("operand", NULL);
0N/A names.Insert("attribute", NULL);
0N/A names.Insert("source", NULL);
0N/A names.Insert("register", NULL);
0N/A names.Insert("pipeline", NULL);
0N/A names.Insert("constraint", NULL);
0N/A names.Insert("predicate", NULL);
0N/A names.Insert("encode", NULL);
0N/A names.Insert("enc_class", NULL);
0N/A names.Insert("interface", NULL);
0N/A names.Insert("opcode", NULL);
0N/A names.Insert("ins_encode", NULL);
0N/A names.Insert("match", NULL);
0N/A names.Insert("effect", NULL);
0N/A names.Insert("expand", NULL);
0N/A names.Insert("rewrite", NULL);
0N/A names.Insert("reg_def", NULL);
0N/A names.Insert("reg_class", NULL);
0N/A names.Insert("alloc_class", NULL);
0N/A names.Insert("resource", NULL);
0N/A names.Insert("pipe_class", NULL);
0N/A names.Insert("pipe_desc", NULL);
0N/A}
0N/A
0N/A
0N/A//------------------------------internal_err----------------------------------
0N/A// Issue a parser error message, and skip to the end of the current line
0N/Avoid ArchDesc::internal_err(const char *fmt, ...) {
0N/A va_list args;
0N/A
0N/A va_start(args, fmt);
0N/A _internal_errs += emit_msg(0, INTERNAL_ERR, 0, fmt, args);
0N/A va_end(args);
0N/A
0N/A _no_output = 1;
0N/A}
0N/A
0N/A//------------------------------syntax_err----------------------------------
0N/A// Issue a parser error message, and skip to the end of the current line
0N/Avoid ArchDesc::syntax_err(int lineno, const char *fmt, ...) {
0N/A va_list args;
0N/A
0N/A va_start(args, fmt);
0N/A _internal_errs += emit_msg(0, SYNERR, lineno, fmt, args);
0N/A va_end(args);
0N/A
0N/A _no_output = 1;
0N/A}
0N/A
0N/A//------------------------------emit_msg---------------------------------------
0N/A// Emit a user message, typically a warning or error
0N/Aint ArchDesc::emit_msg(int quiet, int flag, int line, const char *fmt,
0N/A va_list args) {
0N/A static int last_lineno = -1;
0N/A int i;
0N/A const char *pref;
0N/A
0N/A switch(flag) {
0N/A case 0: pref = "Warning: "; break;
0N/A case 1: pref = "Syntax Error: "; break;
0N/A case 2: pref = "Semantic Error: "; break;
0N/A case 3: pref = "Internal Error: "; break;
0N/A default: assert(0, ""); break;
0N/A }
0N/A
0N/A if (line == last_lineno) return 0;
0N/A last_lineno = line;
0N/A
0N/A if (!quiet) { /* no output if in quiet mode */
0N/A i = fprintf(errfile, "%s(%d) ", _ADL_file._name, line);
0N/A while (i++ <= 15) fputc(' ', errfile);
0N/A fprintf(errfile, "%-8s:", pref);
0N/A vfprintf(errfile, fmt, args);
4033N/A fprintf(errfile, "\n");
4033N/A fflush(errfile);
4033N/A }
0N/A return 1;
0N/A}
0N/A
0N/A
0N/A// ---------------------------------------------------------------------------
0N/A//--------Utilities to build mappings for machine registers ------------------
0N/A// ---------------------------------------------------------------------------
0N/A
0N/A// Construct the name of the register mask.
0N/Astatic const char *getRegMask(const char *reg_class_name) {
0N/A if( reg_class_name == NULL ) return "RegMask::Empty";
0N/A
0N/A if (strcmp(reg_class_name,"Universe")==0) {
0N/A return "RegMask::Empty";
0N/A } else if (strcmp(reg_class_name,"stack_slots")==0) {
0N/A return "(Compile::current()->FIRST_STACK_mask())";
0N/A } else {
0N/A char *rc_name = toUpper(reg_class_name);
0N/A const char *mask = "_mask";
2964N/A int length = (int)strlen(rc_name) + (int)strlen(mask) + 5;
0N/A char *regMask = new char[length];
2964N/A sprintf(regMask,"%s%s()", rc_name, mask);
4444N/A delete[] rc_name;
0N/A return regMask;
0N/A }
0N/A}
0N/A
0N/A// Convert a register class name to its register mask.
0N/Aconst char *ArchDesc::reg_class_to_reg_mask(const char *rc_name) {
0N/A const char *reg_mask = "RegMask::Empty";
0N/A
0N/A if( _register ) {
0N/A RegClass *reg_class = _register->getRegClass(rc_name);
0N/A if (reg_class == NULL) {
0N/A syntax_err(0, "Use of an undefined register class %s", rc_name);
0N/A return reg_mask;
0N/A }
0N/A
0N/A // Construct the name of the register mask.
0N/A reg_mask = getRegMask(rc_name);
0N/A }
0N/A
0N/A return reg_mask;
0N/A}
0N/A
0N/A
0N/A// Obtain the name of the RegMask for an OperandForm
0N/Aconst char *ArchDesc::reg_mask(OperandForm &opForm) {
0N/A const char *regMask = "RegMask::Empty";
0N/A
0N/A // Check constraints on result's register class
0N/A const char *result_class = opForm.constrained_reg_class();
4033N/A if (result_class == NULL) {
4033N/A opForm.dump();
4033N/A syntax_err(opForm._linenum,
4033N/A "Use of an undefined result class for operand: %s",
4033N/A opForm._ident);
4033N/A abort();
4033N/A }
4033N/A
0N/A regMask = reg_class_to_reg_mask( result_class );
0N/A
0N/A return regMask;
0N/A}
0N/A
0N/A// Obtain the name of the RegMask for an InstructForm
0N/Aconst char *ArchDesc::reg_mask(InstructForm &inForm) {
0N/A const char *result = inForm.reduce_result();
4033N/A
4033N/A if (result == NULL) {
4033N/A syntax_err(inForm._linenum,
4033N/A "Did not find result operand or RegMask"
4033N/A " for this instruction: %s",
4033N/A inForm._ident);
4033N/A abort();
4033N/A }
0N/A
0N/A // Instructions producing 'Universe' use RegMask::Empty
0N/A if( strcmp(result,"Universe")==0 ) {
0N/A return "RegMask::Empty";
0N/A }
0N/A
0N/A // Lookup this result operand and get its register class
0N/A Form *form = (Form*)_globalNames[result];
4033N/A if (form == NULL) {
4033N/A syntax_err(inForm._linenum,
4033N/A "Did not find result operand for result: %s", result);
4033N/A abort();
4033N/A }
0N/A OperandForm *oper = form->is_operand();
4033N/A if (oper == NULL) {
4033N/A syntax_err(inForm._linenum, "Form is not an OperandForm:");
4033N/A form->dump();
4033N/A abort();
4033N/A }
0N/A return reg_mask( *oper );
0N/A}
0N/A
0N/A
0N/A// Obtain the STACK_OR_reg_mask name for an OperandForm
0N/Achar *ArchDesc::stack_or_reg_mask(OperandForm &opForm) {
0N/A // name of cisc_spillable version
0N/A const char *reg_mask_name = reg_mask(opForm);
4033N/A
4033N/A if (reg_mask_name == NULL) {
4033N/A syntax_err(opForm._linenum,
4033N/A "Did not find reg_mask for opForm: %s",
4033N/A opForm._ident);
4033N/A abort();
4033N/A }
0N/A
0N/A const char *stack_or = "STACK_OR_";
0N/A int length = (int)strlen(stack_or) + (int)strlen(reg_mask_name) + 1;
0N/A char *result = new char[length];
0N/A sprintf(result,"%s%s", stack_or, reg_mask_name);
0N/A
0N/A return result;
0N/A}
0N/A
0N/A// Record that the register class must generate a stack_or_reg_mask
0N/Avoid ArchDesc::set_stack_or_reg(const char *reg_class_name) {
0N/A if( _register ) {
0N/A RegClass *reg_class = _register->getRegClass(reg_class_name);
0N/A reg_class->_stack_or_reg = true;
0N/A }
0N/A}
0N/A
0N/A
0N/A// Return the type signature for the ideal operation
0N/Aconst char *ArchDesc::getIdealType(const char *idealOp) {
0N/A // Find last character in idealOp, it specifies the type
0N/A char last_char = 0;
0N/A const char *ptr = idealOp;
3845N/A for (; *ptr != '\0'; ++ptr) {
0N/A last_char = *ptr;
0N/A }
0N/A
3845N/A // Match Vector types.
3845N/A if (strncmp(idealOp, "Vec",3)==0) {
3845N/A switch(last_char) {
3845N/A case 'S': return "TypeVect::VECTS";
3845N/A case 'D': return "TypeVect::VECTD";
3845N/A case 'X': return "TypeVect::VECTX";
3845N/A case 'Y': return "TypeVect::VECTY";
3845N/A default:
3845N/A internal_err("Vector type %s with unrecognized type\n",idealOp);
3845N/A }
3845N/A }
3845N/A
0N/A // !!!!!
3845N/A switch(last_char) {
0N/A case 'I': return "TypeInt::INT";
0N/A case 'P': return "TypePtr::BOTTOM";
113N/A case 'N': return "TypeNarrowOop::BOTTOM";
0N/A case 'F': return "Type::FLOAT";
0N/A case 'D': return "Type::DOUBLE";
0N/A case 'L': return "TypeLong::LONG";
0N/A case 's': return "TypeInt::CC /*flags*/";
0N/A default:
0N/A return NULL;
0N/A // !!!!!
0N/A // internal_err("Ideal type %s with unrecognized type\n",idealOp);
0N/A break;
0N/A }
0N/A
0N/A return NULL;
0N/A}
0N/A
0N/A
0N/A
0N/AOperandForm *ArchDesc::constructOperand(const char *ident,
0N/A bool ideal_only) {
0N/A OperandForm *opForm = new OperandForm(ident, ideal_only);
0N/A _globalNames.Insert(ident, opForm);
0N/A addForm(opForm);
0N/A
0N/A return opForm;
0N/A}
0N/A
0N/A
0N/A// Import predefined base types: Set = 1, RegI, RegP, ...
0N/Avoid ArchDesc::initBaseOpTypes() {
0N/A // Create OperandForm and assign type for each opcode.
0N/A for (int i = 1; i < _last_machine_leaf; ++i) {
0N/A char *ident = (char *)NodeClassNames[i];
0N/A constructOperand(ident, true);
0N/A }
0N/A // Create InstructForm and assign type for each ideal instruction.
0N/A for ( int j = _last_machine_leaf+1; j < _last_opcode; ++j) {
0N/A char *ident = (char *)NodeClassNames[j];
113N/A if(!strcmp(ident, "ConI") || !strcmp(ident, "ConP") || !strcmp(ident, "ConN") ||
0N/A !strcmp(ident, "ConF") || !strcmp(ident, "ConD") ||
0N/A !strcmp(ident, "ConL") || !strcmp(ident, "Con" ) ||
0N/A !strcmp(ident, "Bool") ) {
0N/A constructOperand(ident, true);
0N/A }
0N/A else {
0N/A InstructForm *insForm = new InstructForm(ident, true);
0N/A // insForm->_opcode = nextUserOpType(ident);
0N/A _globalNames.Insert(ident,insForm);
0N/A addForm(insForm);
0N/A }
0N/A }
0N/A
0N/A { OperandForm *opForm;
0N/A // Create operand type "Universe" for return instructions.
0N/A const char *ident = "Universe";
0N/A opForm = constructOperand(ident, false);
0N/A
0N/A // Create operand type "label" for branch targets
0N/A ident = "label";
0N/A opForm = constructOperand(ident, false);
0N/A
0N/A // !!!!! Update - when adding a new sReg/stackSlot type
0N/A // Create operand types "sReg[IPFDL]" for stack slot registers
0N/A opForm = constructOperand("sRegI", false);
0N/A opForm->_constraint = new Constraint("ALLOC_IN_RC", "stack_slots");
0N/A opForm = constructOperand("sRegP", false);
0N/A opForm->_constraint = new Constraint("ALLOC_IN_RC", "stack_slots");
0N/A opForm = constructOperand("sRegF", false);
0N/A opForm->_constraint = new Constraint("ALLOC_IN_RC", "stack_slots");
0N/A opForm = constructOperand("sRegD", false);
0N/A opForm->_constraint = new Constraint("ALLOC_IN_RC", "stack_slots");
0N/A opForm = constructOperand("sRegL", false);
0N/A opForm->_constraint = new Constraint("ALLOC_IN_RC", "stack_slots");
0N/A
0N/A // Create operand type "method" for call targets
0N/A ident = "method";
0N/A opForm = constructOperand(ident, false);
0N/A }
0N/A
0N/A // Create Effect Forms for each of the legal effects
0N/A // USE, DEF, USE_DEF, KILL, USE_KILL
0N/A {
0N/A const char *ident = "USE";
0N/A Effect *eForm = new Effect(ident);
0N/A _globalNames.Insert(ident, eForm);
0N/A ident = "DEF";
0N/A eForm = new Effect(ident);
0N/A _globalNames.Insert(ident, eForm);
0N/A ident = "USE_DEF";
0N/A eForm = new Effect(ident);
0N/A _globalNames.Insert(ident, eForm);
0N/A ident = "KILL";
0N/A eForm = new Effect(ident);
0N/A _globalNames.Insert(ident, eForm);
0N/A ident = "USE_KILL";
0N/A eForm = new Effect(ident);
0N/A _globalNames.Insert(ident, eForm);
0N/A ident = "TEMP";
0N/A eForm = new Effect(ident);
0N/A _globalNames.Insert(ident, eForm);
2963N/A ident = "CALL";
2963N/A eForm = new Effect(ident);
2963N/A _globalNames.Insert(ident, eForm);
0N/A }
0N/A
0N/A //
0N/A // Build mapping from ideal names to ideal indices
0N/A int idealIndex = 0;
0N/A for (idealIndex = 1; idealIndex < _last_machine_leaf; ++idealIndex) {
0N/A const char *idealName = NodeClassNames[idealIndex];
603N/A _idealIndex.Insert((void*) idealName, (void*) (intptr_t) idealIndex);
0N/A }
0N/A for ( idealIndex = _last_machine_leaf+1;
0N/A idealIndex < _last_opcode; ++idealIndex) {
0N/A const char *idealName = NodeClassNames[idealIndex];
603N/A _idealIndex.Insert((void*) idealName, (void*) (intptr_t) idealIndex);
0N/A }
0N/A
0N/A}
0N/A
0N/A
0N/A//---------------------------addSUNcopyright-------------------------------
0N/A// output SUN copyright info
0N/Avoid ArchDesc::addSunCopyright(char* legal, int size, FILE *fp) {
968N/A size_t count = fwrite(legal, 1, size, fp);
968N/A assert(count == (size_t) size, "copyright info truncated");
0N/A fprintf(fp,"\n");
0N/A fprintf(fp,"// Machine Generated File. Do Not Edit!\n");
0N/A fprintf(fp,"\n");
0N/A}
0N/A
0N/A
1879N/A//---------------------------addIncludeGuardStart--------------------------
1879N/A// output the start of an include guard.
1879N/Avoid ArchDesc::addIncludeGuardStart(ADLFILE &adlfile, const char* guardString) {
0N/A // Build #include lines
0N/A fprintf(adlfile._fp, "\n");
1879N/A fprintf(adlfile._fp, "#ifndef %s\n", guardString);
1879N/A fprintf(adlfile._fp, "#define %s\n", guardString);
0N/A fprintf(adlfile._fp, "\n");
0N/A
0N/A}
0N/A
1879N/A//---------------------------addIncludeGuardEnd--------------------------
1879N/A// output the end of an include guard.
1879N/Avoid ArchDesc::addIncludeGuardEnd(ADLFILE &adlfile, const char* guardString) {
1879N/A // Build #include lines
1879N/A fprintf(adlfile._fp, "\n");
1879N/A fprintf(adlfile._fp, "#endif // %s\n", guardString);
1879N/A
1879N/A}
1879N/A
1879N/A//---------------------------addInclude--------------------------
1879N/A// output the #include line for this file.
1879N/Avoid ArchDesc::addInclude(ADLFILE &adlfile, const char* fileName) {
1879N/A fprintf(adlfile._fp, "#include \"%s\"\n", fileName);
1879N/A
1879N/A}
1879N/A
1879N/Avoid ArchDesc::addInclude(ADLFILE &adlfile, const char* includeDir, const char* fileName) {
1879N/A fprintf(adlfile._fp, "#include \"%s/%s\"\n", includeDir, fileName);
1879N/A
1879N/A}
0N/A
0N/A//---------------------------addPreprocessorChecks-----------------------------
0N/A// Output C preprocessor code to verify the backend compilation environment.
0N/A// The idea is to force code produced by "adlc -DHS64" to be compiled by a
0N/A// command of the form "CC ... -DHS64 ...", so that any #ifdefs in the source
0N/A// blocks select C code that is consistent with adlc's selections of AD code.
0N/Avoid ArchDesc::addPreprocessorChecks(FILE *fp) {
0N/A const char* flag;
0N/A _preproc_list.reset();
0N/A if (_preproc_list.count() > 0 && !_preproc_list.current_is_signal()) {
0N/A fprintf(fp, "// Check consistency of C++ compilation with ADLC options:\n");
0N/A }
0N/A for (_preproc_list.reset(); (flag = _preproc_list.iter()) != NULL; ) {
0N/A if (_preproc_list.current_is_signal()) break;
0N/A char* def = get_preproc_def(flag);
0N/A fprintf(fp, "// Check adlc ");
0N/A if (def)
0N/A fprintf(fp, "-D%s=%s\n", flag, def);
0N/A else fprintf(fp, "-U%s\n", flag);
0N/A fprintf(fp, "#%s %s\n",
0N/A def ? "ifndef" : "ifdef", flag);
0N/A fprintf(fp, "# error \"%s %s be defined\"\n",
0N/A flag, def ? "must" : "must not");
0N/A fprintf(fp, "#endif // %s\n", flag);
0N/A }
0N/A}
0N/A
0N/A
0N/A// Convert operand name into enum name
0N/Aconst char *ArchDesc::machOperEnum(const char *opName) {
0N/A return ArchDesc::getMachOperEnum(opName);
0N/A}
0N/A
0N/A// Convert operand name into enum name
0N/Aconst char *ArchDesc::getMachOperEnum(const char *opName) {
0N/A return (opName ? toUpper(opName) : opName);
0N/A}
0N/A
0N/A//---------------------------buildMustCloneMap-----------------------------
0N/A// Flag cases when machine needs cloned values or instructions
0N/Avoid ArchDesc::buildMustCloneMap(FILE *fp_hpp, FILE *fp_cpp) {
0N/A // Build external declarations for mappings
0N/A fprintf(fp_hpp, "// Mapping from machine-independent opcode to boolean\n");
0N/A fprintf(fp_hpp, "// Flag cases where machine needs cloned values or instructions\n");
0N/A fprintf(fp_hpp, "extern const char must_clone[];\n");
0N/A fprintf(fp_hpp, "\n");
0N/A
0N/A // Build mapping from ideal names to ideal indices
0N/A fprintf(fp_cpp, "\n");
0N/A fprintf(fp_cpp, "// Mapping from machine-independent opcode to boolean\n");
0N/A fprintf(fp_cpp, "const char must_clone[] = {\n");
0N/A for (int idealIndex = 0; idealIndex < _last_opcode; ++idealIndex) {
0N/A int must_clone = 0;
0N/A const char *idealName = NodeClassNames[idealIndex];
0N/A // Previously selected constants for cloning
0N/A // !!!!!
0N/A // These are the current machine-dependent clones
0N/A if ( strcmp(idealName,"CmpI") == 0
0N/A || strcmp(idealName,"CmpU") == 0
0N/A || strcmp(idealName,"CmpP") == 0
113N/A || strcmp(idealName,"CmpN") == 0
0N/A || strcmp(idealName,"CmpL") == 0
0N/A || strcmp(idealName,"CmpD") == 0
0N/A || strcmp(idealName,"CmpF") == 0
0N/A || strcmp(idealName,"FastLock") == 0
0N/A || strcmp(idealName,"FastUnlock") == 0
0N/A || strcmp(idealName,"Bool") == 0
0N/A || strcmp(idealName,"Binary") == 0 ) {
0N/A // Removed ConI from the must_clone list. CPUs that cannot use
0N/A // large constants as immediates manifest the constant as an
0N/A // instruction. The must_clone flag prevents the constant from
0N/A // floating up out of loops.
0N/A must_clone = 1;
0N/A }
0N/A fprintf(fp_cpp, " %d%s // %s: %d\n", must_clone,
0N/A (idealIndex != (_last_opcode - 1)) ? "," : " // no trailing comma",
0N/A idealName, idealIndex);
0N/A }
0N/A // Finish defining table
0N/A fprintf(fp_cpp, "};\n");
0N/A}