base.isa revision 5692
14338Sgblack@eecs.umich.edu// -*- mode:c++ -*- 24338Sgblack@eecs.umich.edu 34338Sgblack@eecs.umich.edu// Copyright (c) 2007 The Hewlett-Packard Development Company 44338Sgblack@eecs.umich.edu// All rights reserved. 54338Sgblack@eecs.umich.edu// 64338Sgblack@eecs.umich.edu// Redistribution and use of this software in source and binary forms, 74338Sgblack@eecs.umich.edu// with or without modification, are permitted provided that the 84338Sgblack@eecs.umich.edu// following conditions are met: 94338Sgblack@eecs.umich.edu// 104338Sgblack@eecs.umich.edu// The software must be used only for Non-Commercial Use which means any 114338Sgblack@eecs.umich.edu// use which is NOT directed to receiving any direct monetary 124338Sgblack@eecs.umich.edu// compensation for, or commercial advantage from such use. Illustrative 134338Sgblack@eecs.umich.edu// examples of non-commercial use are academic research, personal study, 144338Sgblack@eecs.umich.edu// teaching, education and corporate research & development. 154338Sgblack@eecs.umich.edu// Illustrative examples of commercial use are distributing products for 164338Sgblack@eecs.umich.edu// commercial advantage and providing services using the software for 174338Sgblack@eecs.umich.edu// commercial advantage. 184338Sgblack@eecs.umich.edu// 194338Sgblack@eecs.umich.edu// If you wish to use this software or functionality therein that may be 204338Sgblack@eecs.umich.edu// covered by patents for commercial use, please contact: 214338Sgblack@eecs.umich.edu// Director of Intellectual Property Licensing 224338Sgblack@eecs.umich.edu// Office of Strategy and Technology 234338Sgblack@eecs.umich.edu// Hewlett-Packard Company 244338Sgblack@eecs.umich.edu// 1501 Page Mill Road 254338Sgblack@eecs.umich.edu// Palo Alto, California 94304 264338Sgblack@eecs.umich.edu// 274338Sgblack@eecs.umich.edu// Redistributions of source code must retain the above copyright notice, 284338Sgblack@eecs.umich.edu// this list of conditions and the following disclaimer. Redistributions 294338Sgblack@eecs.umich.edu// in binary form must reproduce the above copyright notice, this list of 304338Sgblack@eecs.umich.edu// conditions and the following disclaimer in the documentation and/or 314338Sgblack@eecs.umich.edu// other materials provided with the distribution. Neither the name of 324338Sgblack@eecs.umich.edu// the COPYRIGHT HOLDER(s), HEWLETT-PACKARD COMPANY, nor the names of its 334338Sgblack@eecs.umich.edu// contributors may be used to endorse or promote products derived from 344338Sgblack@eecs.umich.edu// this software without specific prior written permission. No right of 354338Sgblack@eecs.umich.edu// sublicense is granted herewith. Derivatives of the software and 364338Sgblack@eecs.umich.edu// output created using the software may be prepared, but only for 374338Sgblack@eecs.umich.edu// Non-Commercial Uses. Derivatives of the software may be shared with 384338Sgblack@eecs.umich.edu// others provided: (i) the others agree to abide by the list of 394338Sgblack@eecs.umich.edu// conditions herein which includes the Non-Commercial Use restrictions; 404338Sgblack@eecs.umich.edu// and (ii) such Derivatives of the software include the above copyright 414338Sgblack@eecs.umich.edu// notice to acknowledge the contribution from this software where 424338Sgblack@eecs.umich.edu// applicable, this list of conditions and the disclaimer below. 434338Sgblack@eecs.umich.edu// 444338Sgblack@eecs.umich.edu// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 454338Sgblack@eecs.umich.edu// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 464338Sgblack@eecs.umich.edu// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 474338Sgblack@eecs.umich.edu// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 484338Sgblack@eecs.umich.edu// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 494338Sgblack@eecs.umich.edu// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 504338Sgblack@eecs.umich.edu// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 514338Sgblack@eecs.umich.edu// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 524338Sgblack@eecs.umich.edu// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 534338Sgblack@eecs.umich.edu// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 544338Sgblack@eecs.umich.edu// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 554338Sgblack@eecs.umich.edu// 564338Sgblack@eecs.umich.edu// Authors: Gabe Black 574338Sgblack@eecs.umich.edu 584519Sgblack@eecs.umich.edulet {{ 594519Sgblack@eecs.umich.edu # This will be populated with mappings between microop mnemonics and 604519Sgblack@eecs.umich.edu # the classes that represent them. 614519Sgblack@eecs.umich.edu microopClasses = {} 624338Sgblack@eecs.umich.edu}}; 634338Sgblack@eecs.umich.edu 644519Sgblack@eecs.umich.edu////////////////////////////////////////////////////////////////////////// 654519Sgblack@eecs.umich.edu// 664519Sgblack@eecs.umich.edu// Base class for the python representation of x86 microops 674534Sgblack@eecs.umich.edu// 684534Sgblack@eecs.umich.edu////////////////////////////////////////////////////////////////////////// 694519Sgblack@eecs.umich.edu 704519Sgblack@eecs.umich.edulet {{ 714519Sgblack@eecs.umich.edu class X86Microop(object): 725666Sgblack@eecs.umich.edu 735666Sgblack@eecs.umich.edu generatorNameTemplate = "generate_%s_%d" 745666Sgblack@eecs.umich.edu 755666Sgblack@eecs.umich.edu generatorTemplate = ''' 765666Sgblack@eecs.umich.edu StaticInstPtr 775666Sgblack@eecs.umich.edu ''' + generatorNameTemplate + '''(StaticInstPtr curMacroop) 785666Sgblack@eecs.umich.edu { 795666Sgblack@eecs.umich.edu static const char * mnemonic = romMnemonic; 805666Sgblack@eecs.umich.edu static const ExtMachInst dummyExtMachInst; 815666Sgblack@eecs.umich.edu static const EmulEnv dummyEmulEnv(0, 0, 1, 1, 1); 825666Sgblack@eecs.umich.edu 835666Sgblack@eecs.umich.edu Macroop * macroop = dynamic_cast<Macroop *>(curMacroop.get()); 845666Sgblack@eecs.umich.edu const ExtMachInst &machInst = 855666Sgblack@eecs.umich.edu macroop ? macroop->getExtMachInst() : dummyExtMachInst; 865666Sgblack@eecs.umich.edu const EmulEnv &env = 875666Sgblack@eecs.umich.edu macroop ? macroop->getEmulEnv() : dummyEmulEnv; 885666Sgblack@eecs.umich.edu // env may not be used in the microop's constructor. 895666Sgblack@eecs.umich.edu RegIndex reg = env.reg; 905666Sgblack@eecs.umich.edu reg = reg; 915667Sgblack@eecs.umich.edu using namespace RomLabels; 925666Sgblack@eecs.umich.edu return %s; 935666Sgblack@eecs.umich.edu } 945666Sgblack@eecs.umich.edu ''' 955040Sgblack@eecs.umich.edu 964519Sgblack@eecs.umich.edu def __init__(self, name): 974519Sgblack@eecs.umich.edu self.name = name 984519Sgblack@eecs.umich.edu 994539Sgblack@eecs.umich.edu # This converts a python bool into a C++ bool 1004539Sgblack@eecs.umich.edu def cppBool(self, val): 1014539Sgblack@eecs.umich.edu if val: 1024539Sgblack@eecs.umich.edu return "true" 1034539Sgblack@eecs.umich.edu else: 1044539Sgblack@eecs.umich.edu return "false" 1054539Sgblack@eecs.umich.edu 1064519Sgblack@eecs.umich.edu # This converts a list of python bools into 1074519Sgblack@eecs.umich.edu # a comma seperated list of C++ bools. 1084519Sgblack@eecs.umich.edu def microFlagsText(self, vals): 1094519Sgblack@eecs.umich.edu text = "" 1104519Sgblack@eecs.umich.edu for val in vals: 1114539Sgblack@eecs.umich.edu text += ", %s" % self.cppBool(val) 1124519Sgblack@eecs.umich.edu return text 1134519Sgblack@eecs.umich.edu 1144519Sgblack@eecs.umich.edu def getAllocator(self, mnemonic, *microFlags): 1155040Sgblack@eecs.umich.edu return 'new %s(machInst, %s)' % \ 1165040Sgblack@eecs.umich.edu (self.className, mnemonic, self.microFlagsText(microFlags)) 1175666Sgblack@eecs.umich.edu 1185666Sgblack@eecs.umich.edu def getGeneratorDef(self, micropc): 1195666Sgblack@eecs.umich.edu return self.generatorTemplate % \ 1205666Sgblack@eecs.umich.edu (self.className, micropc, \ 1215692Sgblack@eecs.umich.edu self.getAllocator(True, True, False, False)) 1225666Sgblack@eecs.umich.edu 1235666Sgblack@eecs.umich.edu def getGenerator(self, micropc): 1245666Sgblack@eecs.umich.edu return self.generatorNameTemplate % (self.className, micropc) 1254338Sgblack@eecs.umich.edu}}; 126