archDesc.cpp revision 4444
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith// Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith// DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith// This code is free software; you can redistribute it and/or modify it
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith// under the terms of the GNU General Public License version 2 only, as
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith// published by the Free Software Foundation.
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith// This code is distributed in the hope that it will be useful, but WITHOUT
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith// version 2 for more details (a copy is included in the LICENSE file that
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith// accompanied this code).
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith// You should have received a copy of the GNU General Public License version
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith// 2 along with this work; if not, write to the Free Software Foundation,
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith// Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith// Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith// or visit www.oracle.com if you need additional information or have any
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith// archDesc.cpp - Internal format for architecture definition
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith//--------------------------- utility functions -----------------------------
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith return (('a' <= lower && lower <= 'z') ? (lower + ('A'-'a')) : lower);
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith// Utilities to characterize effect statements
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith case Component::USE_DEF: return true; break;
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith return false;
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith case Component::USE_KILL: return true; break;
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith return false;
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith case Component::USE_KILL: return true; break;
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith return false;
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith//---------------------------ChainList Methods-------------------------------
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmithvoid ChainList::insert(const char *name, const char *cost, const char *rule) {
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmithbool ChainList::iter(const char * &name, const char * &cost, const char * &rule) {
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith if (n && c && r) {
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith fprintf(fp, "\nChain Rules: output resets iterator\n");
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith for(reset(); (iter(name,cost,rule)) == true; ) {
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith fprintf(fp, "Chain to <%s> at cost #%s using %s_rule\n",name, cost ? cost : "0", rule);
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith // // Check for transitive chain rules
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith // Form *form = (Form *)_globalNames[rule];
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith // if (form->is_instruction()) {
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith // // chain_rule(fp, indent, name, cost, rule);
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith // chain_rule(fp, indent, name, cost, rule);
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith fprintf(fp, "No entries in this ChainList\n");
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith//---------------------------MatchList Methods-------------------------------
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmithbool MatchList::search(const char *opc, const char *res, const char *lch,
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith bool tmp = false;
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith if ((res == _resultStr) || (res && _resultStr && !strcmp(res, _resultStr))) {
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith if ((lch == _lchild) || (lch && _lchild && !strcmp(lch, _lchild))) {
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith if ((rch == _rchild) || (rch && _rchild && !strcmp(rch, _rchild))) {
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith if (ADLParser::equivalent_expressions(prStr, predStr)) {
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith tmp = _next->search(opc, res, lch, rch, pr);
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith fprintf(fp, "\nMatchList output is Unimplemented();\n");
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith//---------------------------ArchDesc Constructor and Destructor-------------
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith : _globalNames(cmpstr,hashstr, Form::arena),
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith _preproc_table(cmpstr,hashstr, Form::arena),
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith _internalMatch(cmpstr,hashstr, Form::arena),
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith // Initialize the opcode to MatchList table with NULLs
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith for( int i=0; i<_last_opcode; ++i ) {
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith // Set-up the global tables
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith initKeywords(_globalNames); // Initialize the Name Table with keywords
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith // Prime user-defined types with predefined types: Set, RegI, RegF, ...
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith // Initialize flags & counters
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith // Initialize match rule flags
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith for (int i = 0; i < _last_opcode; i++) {
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith // Initialize I/O Files
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith _ADL_file._name = NULL; _ADL_file._fp = NULL;
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith // Machine dependent output files
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith _DFA_file._name = NULL; _DFA_file._fp = NULL;
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith _HPP_file._name = NULL; _HPP_file._fp = NULL;
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith _CPP_file._name = NULL; _CPP_file._fp = NULL;
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith _bug_file._name = "bugs.out"; _bug_file._fp = NULL;
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith // Initialize Register & Pipeline Form Pointers
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith // Clean-up and quit
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith//---------------------------ArchDesc methods: Public ----------------------
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith// Store forms according to type
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmithvoid ArchDesc::addForm(PreHeaderForm *ptr) { _pre_header.addForm(ptr); };
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmithvoid ArchDesc::addForm(HeaderForm *ptr) { _header.addForm(ptr); };
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmithvoid ArchDesc::addForm(SourceForm *ptr) { _source.addForm(ptr); };
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmithvoid ArchDesc::addForm(EncodeForm *ptr) { _encode = ptr; };
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmithvoid ArchDesc::addForm(InstructForm *ptr) { _instructions.addForm(ptr); };
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmithvoid ArchDesc::addForm(MachNodeForm *ptr) { _machnodes.addForm(ptr); };
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmithvoid ArchDesc::addForm(OperandForm *ptr) { _operands.addForm(ptr); };
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmithvoid ArchDesc::addForm(OpClassForm *ptr) { _opclass.addForm(ptr); };
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmithvoid ArchDesc::addForm(AttributeForm *ptr) { _attributes.addForm(ptr); };
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmithvoid ArchDesc::addForm(RegisterForm *ptr) { _register = ptr; };
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmithvoid ArchDesc::addForm(FrameForm *ptr) { _frame = ptr; };
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmithvoid ArchDesc::addForm(PipelineForm *ptr) { _pipeline = ptr; };
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith// Build MatchList array and construct MatchLists
const char *defaultCost =
bool has_root = false;
const char *defaultCost =
return left;
return right;
const char *result) {
const char *cost) {
if (index == 0) {
if (mnode) {
if (mnode) {
const char *cost) {
const char *resultop;
const char *opcode;
if (index == 0) {
if (mnode) {
if (mnode) {
return count;
++count;
return count;
return count;
if (_register)
if (!_quiet_mode)
if (!_quiet_mode)
if (!_quiet_mode)
if ( _encode ) {
const char *pref;
switch(flag) {
delete[] rc_name;
return regMask;
if( _register ) {
return reg_mask;
return reg_mask;
abort();
return regMask;
abort();
abort();
abort();
abort();
return result;
if( _register ) {
char last_char = 0;
switch(last_char) {
switch(last_char) {
return NULL;
return NULL;
bool ideal_only) {
return opForm;
char *ident = (char *)NodeClassNames[i];
constructOperand(ident, true);
char *ident = (char *)NodeClassNames[j];
constructOperand(ident, true);
int idealIndex = 0;
const char* flag;
if (def)
int must_clone = 0;