base.isa revision 7087:fb8d5786ff30
1955SN/A// -*- mode:c++ -*- 2955SN/A 311408Sandreas.sandberg@arm.com// Copyright (c) 2007 The Hewlett-Packard Development Company 49812Sandreas.hansson@arm.com// All rights reserved. 59812Sandreas.hansson@arm.com// 69812Sandreas.hansson@arm.com// The license below extends only to copyright in the software and shall 79812Sandreas.hansson@arm.com// not be construed as granting a license to any other intellectual 89812Sandreas.hansson@arm.com// property including but not limited to intellectual property relating 99812Sandreas.hansson@arm.com// to a hardware implementation of the functionality of the software 109812Sandreas.hansson@arm.com// licensed hereunder. You may use the software subject to the license 119812Sandreas.hansson@arm.com// terms below provided that you ensure that this notice is replicated 129812Sandreas.hansson@arm.com// unmodified and in its entirety in all distributions of the software, 139812Sandreas.hansson@arm.com// modified or unmodified, in source code or in binary form. 149812Sandreas.hansson@arm.com// 157816Ssteve.reinhardt@amd.com// Redistribution and use in source and binary forms, with or without 165871Snate@binkert.org// modification, are permitted provided that the following conditions are 171762SN/A// met: redistributions of source code must retain the above copyright 18955SN/A// notice, this list of conditions and the following disclaimer; 19955SN/A// redistributions in binary form must reproduce the above copyright 20955SN/A// notice, this list of conditions and the following disclaimer in the 21955SN/A// documentation and/or other materials provided with the distribution; 22955SN/A// neither the name of the copyright holders nor the names of its 23955SN/A// contributors may be used to endorse or promote products derived from 24955SN/A// this software without specific prior written permission. 25955SN/A// 26955SN/A// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 27955SN/A// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28955SN/A// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 29955SN/A// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 30955SN/A// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 31955SN/A// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 32955SN/A// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 33955SN/A// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 34955SN/A// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 35955SN/A// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 36955SN/A// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37955SN/A// 38955SN/A// Authors: Gabe Black 39955SN/A 40955SN/Alet {{ 41955SN/A # This will be populated with mappings between microop mnemonics and 422665Ssaidi@eecs.umich.edu # the classes that represent them. 432665Ssaidi@eecs.umich.edu microopClasses = {} 445863Snate@binkert.org}}; 45955SN/A 46955SN/A////////////////////////////////////////////////////////////////////////// 47955SN/A// 48955SN/A// Base class for the python representation of x86 microops 49955SN/A// 508878Ssteve.reinhardt@amd.com////////////////////////////////////////////////////////////////////////// 512632Sstever@eecs.umich.edu 528878Ssteve.reinhardt@amd.comlet {{ 532632Sstever@eecs.umich.edu class X86Microop(object): 54955SN/A 558878Ssteve.reinhardt@amd.com generatorNameTemplate = "generate_%s_%d" 562632Sstever@eecs.umich.edu 572761Sstever@eecs.umich.edu generatorTemplate = ''' 582632Sstever@eecs.umich.edu StaticInstPtr 592632Sstever@eecs.umich.edu ''' + generatorNameTemplate + '''(StaticInstPtr curMacroop) 602632Sstever@eecs.umich.edu { 612761Sstever@eecs.umich.edu static const char *macrocodeBlock = romMnemonic; 622761Sstever@eecs.umich.edu static const ExtMachInst dummyExtMachInst; 632761Sstever@eecs.umich.edu static const EmulEnv dummyEmulEnv(0, 0, 1, 1, 1); 648878Ssteve.reinhardt@amd.com 658878Ssteve.reinhardt@amd.com Macroop * macroop = dynamic_cast<Macroop *>(curMacroop.get()); 662761Sstever@eecs.umich.edu const ExtMachInst &machInst = 672761Sstever@eecs.umich.edu macroop ? macroop->getExtMachInst() : dummyExtMachInst; 682761Sstever@eecs.umich.edu const EmulEnv &env = 692761Sstever@eecs.umich.edu macroop ? macroop->getEmulEnv() : dummyEmulEnv; 702761Sstever@eecs.umich.edu // env may not be used in the microop's constructor. 718878Ssteve.reinhardt@amd.com InstRegIndex reg(env.reg); 728878Ssteve.reinhardt@amd.com reg = reg; 732632Sstever@eecs.umich.edu using namespace RomLabels; 742632Sstever@eecs.umich.edu return %s; 758878Ssteve.reinhardt@amd.com } 768878Ssteve.reinhardt@amd.com ''' 772632Sstever@eecs.umich.edu 78955SN/A def __init__(self, name): 79955SN/A self.name = name 80955SN/A 815863Snate@binkert.org # This converts a python bool into a C++ bool 825863Snate@binkert.org def cppBool(self, val): 835863Snate@binkert.org if val: 845863Snate@binkert.org return "true" 855863Snate@binkert.org else: 865863Snate@binkert.org return "false" 875863Snate@binkert.org 885863Snate@binkert.org # This converts a list of python bools into 895863Snate@binkert.org # a comma seperated list of C++ bools. 905863Snate@binkert.org def microFlagsText(self, vals): 915863Snate@binkert.org text = "" 928878Ssteve.reinhardt@amd.com for val in vals: 935863Snate@binkert.org text += ", %s" % self.cppBool(val) 945863Snate@binkert.org return text 955863Snate@binkert.org 969812Sandreas.hansson@arm.com def getAllocator(self, mnemonic, *microFlags): 979812Sandreas.hansson@arm.com return 'new %s(machInst, %s)' % \ 985863Snate@binkert.org (self.className, mnemonic, self.microFlagsText(microFlags)) 999812Sandreas.hansson@arm.com 1005863Snate@binkert.org def getGeneratorDef(self, micropc): 1015863Snate@binkert.org return self.generatorTemplate % \ 1025863Snate@binkert.org (self.className, micropc, \ 1039812Sandreas.hansson@arm.com self.getAllocator(True, True, False, False)) 1049812Sandreas.hansson@arm.com 1055863Snate@binkert.org def getGenerator(self, micropc): 1065863Snate@binkert.org return self.generatorNameTemplate % (self.className, micropc) 1078878Ssteve.reinhardt@amd.com}}; 1085863Snate@binkert.org