seqop.isa revision 9010
12137SN/A// Copyright (c) 2008 The Hewlett-Packard Development Company 25268Sksewell@umich.edu// All rights reserved. 35254Sksewell@umich.edu// 45254Sksewell@umich.edu// The license below extends only to copyright in the software and shall 52137SN/A// not be construed as granting a license to any other intellectual 65254Sksewell@umich.edu// property including but not limited to intellectual property relating 75254Sksewell@umich.edu// to a hardware implementation of the functionality of the software 85254Sksewell@umich.edu// licensed hereunder. You may use the software subject to the license 95254Sksewell@umich.edu// terms below provided that you ensure that this notice is replicated 105254Sksewell@umich.edu// unmodified and in its entirety in all distributions of the software, 115254Sksewell@umich.edu// modified or unmodified, in source code or in binary form. 125254Sksewell@umich.edu// 135254Sksewell@umich.edu// Redistribution and use in source and binary forms, with or without 145254Sksewell@umich.edu// modification, are permitted provided that the following conditions are 155254Sksewell@umich.edu// met: redistributions of source code must retain the above copyright 162137SN/A// notice, this list of conditions and the following disclaimer; 175254Sksewell@umich.edu// redistributions in binary form must reproduce the above copyright 185254Sksewell@umich.edu// notice, this list of conditions and the following disclaimer in the 195254Sksewell@umich.edu// documentation and/or other materials provided with the distribution; 205254Sksewell@umich.edu// neither the name of the copyright holders nor the names of its 215254Sksewell@umich.edu// contributors may be used to endorse or promote products derived from 225254Sksewell@umich.edu// this software without specific prior written permission. 235254Sksewell@umich.edu// 245254Sksewell@umich.edu// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 255254Sksewell@umich.edu// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 265254Sksewell@umich.edu// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 275254Sksewell@umich.edu// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 282665Ssaidi@eecs.umich.edu// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 295268Sksewell@umich.edu// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 305268Sksewell@umich.edu// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 312137SN/A// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 322137SN/A// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 3311793Sbrandon.potter@amd.com// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 3411793Sbrandon.potter@amd.com// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 3511793Sbrandon.potter@amd.com// 362597SN/A// Authors: Gabe Black 372137SN/A 382680Sktlim@umich.eduoutput header {{ 398232Snate@binkert.org class SeqOpBase : public X86ISA::X86MicroopBase 402137SN/A { 418229Snate@binkert.org protected: 422137SN/A uint16_t target; 4311794Sbrandon.potter@amd.com uint8_t cc; 448229Snate@binkert.org 454661Sksewell@umich.edu public: 462137SN/A SeqOpBase(ExtMachInst _machInst, const char * instMnem, 472137SN/A const char * mnemonic, uint64_t setFlags, 482137SN/A uint16_t _target, uint8_t _cc); 492137SN/A 502137SN/A SeqOpBase(ExtMachInst _machInst, const char * instMnem, 512137SN/A const char * mnemonic, 5211851Sbrandon.potter@amd.com uint16_t _target, uint8_t _cc); 532680Sktlim@umich.edu 542137SN/A std::string generateDisassembly(Addr pc, 556701Sgblack@eecs.umich.edu const SymbolTable *symtab) const; 566701Sgblack@eecs.umich.edu }; 572137SN/A}}; 582137SN/A 599149SAli.Saidi@ARM.comdef template SeqOpDeclare {{ 609149SAli.Saidi@ARM.com class %(class_name)s : public %(base_class)s 612137SN/A { 622137SN/A public: 632137SN/A %(class_name)s(ExtMachInst _machInst, const char * instMnem, 648706Sandreas.hansson@arm.com uint64_t setFlags, uint16_t _target, uint8_t _cc); 652137SN/A 662137SN/A %(BasicExecDeclare)s 672137SN/A }; 682484SN/A}}; 692137SN/A 702137SN/Adef template SeqOpExecute {{ 712137SN/A Fault %(class_name)s::execute(%(CPU_exec_context)s *xc, 7211851Sbrandon.potter@amd.com Trace::InstRecord *traceData) const 732680Sktlim@umich.edu { 742137SN/A %(op_decl)s; 756701Sgblack@eecs.umich.edu %(op_rd)s; 766701Sgblack@eecs.umich.edu if (%(cond_test)s) { 776701Sgblack@eecs.umich.edu %(code)s; 786701Sgblack@eecs.umich.edu } else { 792137SN/A %(else_code)s; 802137SN/A } 816378Sgblack@eecs.umich.edu %(op_wb)s; 8211320Ssteve.reinhardt@amd.com return NoFault; 836378Sgblack@eecs.umich.edu } 846701Sgblack@eecs.umich.edu}}; 856378Sgblack@eecs.umich.edu 866378Sgblack@eecs.umich.eduoutput decoder {{ 878706Sandreas.hansson@arm.com inline SeqOpBase::SeqOpBase( 886378Sgblack@eecs.umich.edu ExtMachInst machInst, const char * mnemonic, const char * instMnem, 896378Sgblack@eecs.umich.edu uint64_t setFlags, uint16_t _target, uint8_t _cc) : 902137SN/A X86MicroopBase(machInst, mnemonic, instMnem, setFlags, No_OpClass), 912484SN/A target(_target), cc(_cc) 922137SN/A { 932137SN/A } 942137SN/A}}; 952137SN/A 962137SN/Adef template SeqOpConstructor {{ 972137SN/A inline %(class_name)s::%(class_name)s( 982137SN/A ExtMachInst machInst, const char * instMnem, 992484SN/A uint64_t setFlags, uint16_t _target, uint8_t _cc) : 1002137SN/A %(base_class)s(machInst, "%(mnemonic)s", instMnem, 10111851Sbrandon.potter@amd.com setFlags, _target, _cc) 1022680Sktlim@umich.edu { 1032137SN/A %(constructor)s; 1046701Sgblack@eecs.umich.edu %(cond_control_flag_init)s; 1056701Sgblack@eecs.umich.edu } 1066701Sgblack@eecs.umich.edu}}; 1076701Sgblack@eecs.umich.edu 1082137SN/Aoutput decoder {{ 1092137SN/A std::string SeqOpBase::generateDisassembly(Addr pc, 1102137SN/A const SymbolTable *symtab) const 1116378Sgblack@eecs.umich.edu { 1126378Sgblack@eecs.umich.edu std::stringstream response; 1136378Sgblack@eecs.umich.edu 1146701Sgblack@eecs.umich.edu printMnemonic(response, instMnem, mnemonic); 1156378Sgblack@eecs.umich.edu ccprintf(response, "%#x", target); 1168706Sandreas.hansson@arm.com 1176378Sgblack@eecs.umich.edu return response.str(); 1182137SN/A } 1196378Sgblack@eecs.umich.edu}}; 1206378Sgblack@eecs.umich.edu 1212137SN/Alet {{ 1222484SN/A class SeqOp(X86Microop): 1232137SN/A def __init__(self, target, flags=None): 1242137SN/A self.target = target 1252137SN/A if flags: 1262137SN/A if not isinstance(flags, (list, tuple)): 1272137SN/A raise Exception, "flags must be a list or tuple of flags" 1282137SN/A self.cond = " | ".join(flags) 1292137SN/A self.className += "Flags" 1306808Sgblack@eecs.umich.edu else: 13111851Sbrandon.potter@amd.com self.cond = "0" 1326808Sgblack@eecs.umich.edu 1336808Sgblack@eecs.umich.edu def getAllocator(self, microFlags): 1346808Sgblack@eecs.umich.edu allocator = '''new %(class_name)s(machInst, macrocodeBlock, 1356808Sgblack@eecs.umich.edu %(flags)s, %(target)s, %(cc)s)''' % { 1366808Sgblack@eecs.umich.edu "class_name" : self.className, 1376808Sgblack@eecs.umich.edu "flags" : self.microFlagsText(microFlags), 1386808Sgblack@eecs.umich.edu "target" : self.target, 1396808Sgblack@eecs.umich.edu "cc" : self.cond} 1402137SN/A return allocator 1412484SN/A 1422137SN/A class Br(SeqOp): 1432137SN/A className = "MicroBranch" 14413570Sbrandon.potter@amd.com 14513570Sbrandon.potter@amd.com def getAllocator(self, microFlags): 1462553SN/A if "IsLastMicroop" in microFlags: 1472137SN/A microFlags.remove("IsLastMicroop") 1482484SN/A if not "IsDelayedCommit" in microFlags: 1492484SN/A microFlags.append("IsDelayedCommit") 1502137SN/A return super(Br, self).getAllocator(microFlags) 1512137SN/A 1522484SN/A class Eret(SeqOp): 1532137SN/A target = "normalMicroPC(0)" 1542484SN/A className = "Eret" 1552137SN/A 1562553SN/A def __init__(self, flags=None): 1572484SN/A if flags: 1585748SSteve.Reinhardt@amd.com if not isinstance(flags, (list, tuple)): 1592484SN/A raise Exception, "flags must be a list or tuple of flags" 1602137SN/A self.cond = " | ".join(flags) 1612484SN/A self.className += "Flags" 1622484SN/A else: 1632137SN/A self.cond = "0" 1642137SN/A 1652484SN/A def getAllocator(self, microFlags): 1662484SN/A if not "IsLastMicroop" in microFlags: 1672484SN/A microFlags.append("IsLastMicroop") 1682484SN/A if "IsDelayedCommit" in microFlags: 1692484SN/A microFlags.remove("IsDelayedCommit") 1702484SN/A return super(Eret, self).getAllocator(microFlags) 1712484SN/A 1722484SN/A iop = InstObjParams("br", "MicroBranchFlags", "SeqOpBase", 1732484SN/A {"code": "nuIP = target;", 1742137SN/A "else_code": "nuIP = nuIP;", 1752484SN/A "cond_test": "checkCondition(ccFlagBits | cfofBits | \ 1762484SN/A ecfBit | ezfBit, cc)", 1772137SN/A "cond_control_flag_init": "flags[IsCondControl] = true"}) 1784661Sksewell@umich.edu exec_output += SeqOpExecute.subst(iop) 1792484SN/A header_output += SeqOpDeclare.subst(iop) 1805513SMichael.Adler@intel.com decoder_output += SeqOpConstructor.subst(iop) 1812484SN/A iop = InstObjParams("br", "MicroBranch", "SeqOpBase", 1822137SN/A {"code": "nuIP = target;", 1834661Sksewell@umich.edu "else_code": "nuIP = nuIP;", 1842484SN/A "cond_test": "true", 1852484SN/A "cond_control_flag_init": ""}) 1865748SSteve.Reinhardt@amd.com exec_output += SeqOpExecute.subst(iop) 1872491SN/A header_output += SeqOpDeclare.subst(iop) 1882484SN/A decoder_output += SeqOpConstructor.subst(iop) 1892484SN/A microopClasses["br"] = Br 1902491SN/A 1912491SN/A iop = InstObjParams("eret", "EretFlags", "SeqOpBase", 1922137SN/A {"code": "", "else_code": "", 1932484SN/A "cond_test": "checkCondition(ccFlagBits | cfofBits | \ 1942484SN/A ecfBit | ezfBit, cc)", 1955867Sksewell@umich.edu "cond_control_flag_init": ""}) 1962686Sksewell@umich.edu exec_output += SeqOpExecute.subst(iop) 1972484SN/A header_output += SeqOpDeclare.subst(iop) 1982484SN/A decoder_output += SeqOpConstructor.subst(iop) 1992484SN/A iop = InstObjParams("eret", "Eret", "SeqOpBase", 2002484SN/A {"code": "", "else_code": "", 2015513SMichael.Adler@intel.com "cond_test": "true", 2022137SN/A "cond_control_flag_init": ""}) 2032484SN/A exec_output += SeqOpExecute.subst(iop) 2042484SN/A header_output += SeqOpDeclare.subst(iop) 2052484SN/A decoder_output += SeqOpConstructor.subst(iop) 2062484SN/A microopClasses["eret"] = Eret 2072484SN/A}}; 2082495SN/A