seqop.isa revision 7087
15347Ssaidi@eecs.umich.edu// Copyright (c) 2008 The Hewlett-Packard Development Company 27534Ssteve.reinhardt@amd.com// All rights reserved. 33395Shsul@eecs.umich.edu// 43395Shsul@eecs.umich.edu// The license below extends only to copyright in the software and shall 53395Shsul@eecs.umich.edu// not be construed as granting a license to any other intellectual 63395Shsul@eecs.umich.edu// property including but not limited to intellectual property relating 73395Shsul@eecs.umich.edu// to a hardware implementation of the functionality of the software 83395Shsul@eecs.umich.edu// licensed hereunder. You may use the software subject to the license 93395Shsul@eecs.umich.edu// terms below provided that you ensure that this notice is replicated 103395Shsul@eecs.umich.edu// unmodified and in its entirety in all distributions of the software, 113395Shsul@eecs.umich.edu// modified or unmodified, in source code or in binary form. 123395Shsul@eecs.umich.edu// 133395Shsul@eecs.umich.edu// Redistribution and use in source and binary forms, with or without 143395Shsul@eecs.umich.edu// modification, are permitted provided that the following conditions are 153395Shsul@eecs.umich.edu// met: redistributions of source code must retain the above copyright 163395Shsul@eecs.umich.edu// notice, this list of conditions and the following disclaimer; 173395Shsul@eecs.umich.edu// redistributions in binary form must reproduce the above copyright 183395Shsul@eecs.umich.edu// notice, this list of conditions and the following disclaimer in the 193395Shsul@eecs.umich.edu// documentation and/or other materials provided with the distribution; 203395Shsul@eecs.umich.edu// neither the name of the copyright holders nor the names of its 213395Shsul@eecs.umich.edu// contributors may be used to endorse or promote products derived from 223395Shsul@eecs.umich.edu// this software without specific prior written permission. 233395Shsul@eecs.umich.edu// 243395Shsul@eecs.umich.edu// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 253395Shsul@eecs.umich.edu// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 263395Shsul@eecs.umich.edu// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 273395Shsul@eecs.umich.edu// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 283395Shsul@eecs.umich.edu// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 293395Shsul@eecs.umich.edu// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 303395Shsul@eecs.umich.edu// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 313509Shsul@eecs.umich.edu// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 326654Snate@binkert.org// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 333395Shsul@eecs.umich.edu// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 346654Snate@binkert.org// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 353395Shsul@eecs.umich.edu// 366654Snate@binkert.org// Authors: Gabe Black 378724Srdreslin@umich.edu 386654Snate@binkert.orgoutput header {{ 396654Snate@binkert.org class SeqOpBase : public X86ISA::X86MicroopBase 403395Shsul@eecs.umich.edu { 419139Snilay@cs.wisc.edu protected: 429139Snilay@cs.wisc.edu uint16_t target; 439139Snilay@cs.wisc.edu uint8_t cc; 449139Snilay@cs.wisc.edu 459139Snilay@cs.wisc.edu public: 469139Snilay@cs.wisc.edu SeqOpBase(ExtMachInst _machInst, const char * instMnem, 479139Snilay@cs.wisc.edu const char * mnemonic, 489139Snilay@cs.wisc.edu bool isMicro, bool isDelayed, bool isFirst, bool isLast, 499139Snilay@cs.wisc.edu uint16_t _target, uint8_t _cc); 509139Snilay@cs.wisc.edu 519139Snilay@cs.wisc.edu SeqOpBase(ExtMachInst _machInst, const char * instMnem, 529139Snilay@cs.wisc.edu const char * mnemonic, 539139Snilay@cs.wisc.edu uint16_t _target, uint8_t _cc); 549139Snilay@cs.wisc.edu 559139Snilay@cs.wisc.edu std::string generateDisassembly(Addr pc, 563481Shsul@eecs.umich.edu const SymbolTable *symtab) const; 579139Snilay@cs.wisc.edu }; 583481Shsul@eecs.umich.edu}}; 599139Snilay@cs.wisc.edu 609139Snilay@cs.wisc.edudef template SeqOpDeclare {{ 619139Snilay@cs.wisc.edu class %(class_name)s : public %(base_class)s 629139Snilay@cs.wisc.edu { 639139Snilay@cs.wisc.edu private: 649139Snilay@cs.wisc.edu void buildMe(); 659139Snilay@cs.wisc.edu public: 669139Snilay@cs.wisc.edu %(class_name)s(ExtMachInst _machInst, const char * instMnem, 679139Snilay@cs.wisc.edu bool isMicro, bool isDelayed, bool isFirst, bool isLast, 689139Snilay@cs.wisc.edu uint16_t _target, uint8_t _cc); 698718Snilay@cs.wisc.edu 709139Snilay@cs.wisc.edu %(class_name)s(ExtMachInst _machInst, const char * instMnem, 713481Shsul@eecs.umich.edu uint16_t _target, uint8_t _cc); 729139Snilay@cs.wisc.edu 733481Shsul@eecs.umich.edu %(BasicExecDeclare)s 743481Shsul@eecs.umich.edu }; 759139Snilay@cs.wisc.edu}}; 769139Snilay@cs.wisc.edu 773481Shsul@eecs.umich.edudef template SeqOpExecute {{ 789139Snilay@cs.wisc.edu Fault %(class_name)s::execute(%(CPU_exec_context)s *xc, 799139Snilay@cs.wisc.edu Trace::InstRecord *traceData) const 809139Snilay@cs.wisc.edu { 819139Snilay@cs.wisc.edu %(op_decl)s; 829139Snilay@cs.wisc.edu %(op_rd)s; 833481Shsul@eecs.umich.edu if (%(cond_test)s) { 843481Shsul@eecs.umich.edu %(code)s; 853481Shsul@eecs.umich.edu } else { 868919Snilay@cs.wisc.edu %(else_code)s; 878919Snilay@cs.wisc.edu } 888919Snilay@cs.wisc.edu %(op_wb)s; 898919Snilay@cs.wisc.edu return NoFault; 908919Snilay@cs.wisc.edu } 918919Snilay@cs.wisc.edu}}; 928919Snilay@cs.wisc.edu 938919Snilay@cs.wisc.eduoutput decoder {{ 948919Snilay@cs.wisc.edu inline SeqOpBase::SeqOpBase( 958919Snilay@cs.wisc.edu ExtMachInst machInst, const char * mnemonic, const char * instMnem, 968919Snilay@cs.wisc.edu uint16_t _target, uint8_t _cc) : 978919Snilay@cs.wisc.edu X86MicroopBase(machInst, mnemonic, instMnem, 988919Snilay@cs.wisc.edu false, false, false, false, No_OpClass), 998919Snilay@cs.wisc.edu target(_target), cc(_cc) 1008919Snilay@cs.wisc.edu { 1013481Shsul@eecs.umich.edu } 1023481Shsul@eecs.umich.edu 1033395Shsul@eecs.umich.edu inline SeqOpBase::SeqOpBase( 1043395Shsul@eecs.umich.edu ExtMachInst machInst, const char * mnemonic, const char * instMnem, 1053395Shsul@eecs.umich.edu bool isMicro, bool isDelayed, bool isFirst, bool isLast, 1064167Sbinkertn@umich.edu uint16_t _target, uint8_t _cc) : 1073395Shsul@eecs.umich.edu X86MicroopBase(machInst, mnemonic, instMnem, 1083395Shsul@eecs.umich.edu isMicro, isDelayed, isFirst, isLast, No_OpClass), 1093395Shsul@eecs.umich.edu target(_target), cc(_cc) 1103511Shsul@eecs.umich.edu { 1113395Shsul@eecs.umich.edu } 1123395Shsul@eecs.umich.edu}}; 1133395Shsul@eecs.umich.edu 1145211Ssaidi@eecs.umich.edudef template SeqOpConstructor {{ 1155211Ssaidi@eecs.umich.edu 1163395Shsul@eecs.umich.edu inline void %(class_name)s::buildMe() 1173395Shsul@eecs.umich.edu { 1183395Shsul@eecs.umich.edu %(constructor)s; 1195370Ssaidi@eecs.umich.edu } 1206654Snate@binkert.org 1215370Ssaidi@eecs.umich.edu inline %(class_name)s::%(class_name)s( 1225371Shsul@eecs.umich.edu ExtMachInst machInst, const char * instMnem, 1236654Snate@binkert.org uint16_t _target, uint8_t _cc) : 1245370Ssaidi@eecs.umich.edu %(base_class)s(machInst, "%(mnemonic)s", instMnem, _target, _cc) 1253395Shsul@eecs.umich.edu { 1263395Shsul@eecs.umich.edu buildMe(); 1273481Shsul@eecs.umich.edu } 1283481Shsul@eecs.umich.edu 1298318Sksewell@umich.edu inline %(class_name)s::%(class_name)s( 1306144Sksewell@umich.edu ExtMachInst machInst, const char * instMnem, 1318311Sksewell@umich.edu bool isMicro, bool isDelayed, bool isFirst, bool isLast, 1326144Sksewell@umich.edu uint16_t _target, uint8_t _cc) : 1336641Sksewell@umich.edu %(base_class)s(machInst, "%(mnemonic)s", instMnem, 1346641Sksewell@umich.edu isMicro, isDelayed, isFirst, isLast, _target, _cc) 1356641Sksewell@umich.edu { 1366641Sksewell@umich.edu buildMe(); 1373481Shsul@eecs.umich.edu } 1383481Shsul@eecs.umich.edu}}; 1393481Shsul@eecs.umich.edu 1403481Shsul@eecs.umich.eduoutput decoder {{ 1413481Shsul@eecs.umich.edu std::string SeqOpBase::generateDisassembly(Addr pc, 1425361Srstrong@cs.ucsd.edu const SymbolTable *symtab) const 1435369Ssaidi@eecs.umich.edu { 1443481Shsul@eecs.umich.edu std::stringstream response; 1458803Sgblack@eecs.umich.edu 1469129Sandreas.hansson@arm.com printMnemonic(response, instMnem, mnemonic); 1475369Ssaidi@eecs.umich.edu ccprintf(response, "%#x", target); 1488311Sksewell@umich.edu 1498311Sksewell@umich.edu return response.str(); 1508887Sgeoffrey.blake@arm.com } 1518887Sgeoffrey.blake@arm.com}}; 1528887Sgeoffrey.blake@arm.com 1533481Shsul@eecs.umich.edulet {{ 1545311Ssaidi@eecs.umich.edu class SeqOp(X86Microop): 1553481Shsul@eecs.umich.edu def __init__(self, target, flags=None): 1563395Shsul@eecs.umich.edu self.target = target 1573395Shsul@eecs.umich.edu if flags: 1588211Satgutier@umich.edu if not isinstance(flags, (list, tuple)): 1598211Satgutier@umich.edu raise Exception, "flags must be a list or tuple of flags" 1608211Satgutier@umich.edu self.cond = " | ".join(flags) 1618211Satgutier@umich.edu self.className += "Flags" 1628211Satgutier@umich.edu else: 1633395Shsul@eecs.umich.edu self.cond = "0" 1643395Shsul@eecs.umich.edu 1653478Shsul@eecs.umich.edu def getAllocator(self, *microFlags): 1663395Shsul@eecs.umich.edu allocator = '''new %(class_name)s(machInst, macrocodeBlock 1673478Shsul@eecs.umich.edu %(flags)s, %(target)s, %(cc)s)''' % { 1683395Shsul@eecs.umich.edu "class_name" : self.className, 1693395Shsul@eecs.umich.edu "flags" : self.microFlagsText(microFlags), 1703478Shsul@eecs.umich.edu "target" : self.target, 1718803Sgblack@eecs.umich.edu "cc" : self.cond} 1728803Sgblack@eecs.umich.edu return allocator 1739129Sandreas.hansson@arm.com 1749129Sandreas.hansson@arm.com class Br(SeqOp): 1753480Shsul@eecs.umich.edu className = "MicroBranch" 1765361Srstrong@cs.ucsd.edu 1775369Ssaidi@eecs.umich.edu def getAllocator(self, *microFlags): 1785361Srstrong@cs.ucsd.edu (is_micro, is_delayed, is_first, is_last) = microFlags 1795361Srstrong@cs.ucsd.edu is_last = False 1805361Srstrong@cs.ucsd.edu is_delayed = True 1815369Ssaidi@eecs.umich.edu microFlags = (is_micro, is_delayed, is_first, is_last) 1825361Srstrong@cs.ucsd.edu return super(Br, self).getAllocator(*microFlags) 1835361Srstrong@cs.ucsd.edu 1845378Ssaidi@eecs.umich.edu class Eret(SeqOp): 1856654Snate@binkert.org target = "normalMicroPC(0)" 1865361Srstrong@cs.ucsd.edu className = "Eret" 1875361Srstrong@cs.ucsd.edu 1885361Srstrong@cs.ucsd.edu def __init__(self, flags=None): 1895361Srstrong@cs.ucsd.edu if flags: 1905361Srstrong@cs.ucsd.edu if not isinstance(flags, (list, tuple)): 1915361Srstrong@cs.ucsd.edu raise Exception, "flags must be a list or tuple of flags" 1925361Srstrong@cs.ucsd.edu self.cond = " | ".join(flags) 1935361Srstrong@cs.ucsd.edu self.className += "Flags" 1945361Srstrong@cs.ucsd.edu else: 1955361Srstrong@cs.ucsd.edu self.cond = "0" 1965361Srstrong@cs.ucsd.edu 1978311Sksewell@umich.edu def getAllocator(self, *microFlags): 1988311Sksewell@umich.edu (is_micro, is_delayed, is_first, is_last) = microFlags 1995353Svilas.sridharan@gmail.com is_last = True 2008887Sgeoffrey.blake@arm.com is_delayed = False 2018887Sgeoffrey.blake@arm.com microFlags = (is_micro, is_delayed, is_first, is_last) 2028887Sgeoffrey.blake@arm.com return super(Eret, self).getAllocator(*microFlags) 2038887Sgeoffrey.blake@arm.com 2048887Sgeoffrey.blake@arm.com iop = InstObjParams("br", "MicroBranchFlags", "SeqOpBase", 2058211Satgutier@umich.edu {"code": "nuIP = target", 2068211Satgutier@umich.edu "else_code": "nuIP = nuIP", 2078211Satgutier@umich.edu "cond_test": "checkCondition(ccFlagBits, cc)"}) 2088211Satgutier@umich.edu exec_output += SeqOpExecute.subst(iop) 2093395Shsul@eecs.umich.edu header_output += SeqOpDeclare.subst(iop) 2105361Srstrong@cs.ucsd.edu decoder_output += SeqOpConstructor.subst(iop) 2115369Ssaidi@eecs.umich.edu iop = InstObjParams("br", "MicroBranch", "SeqOpBase", 2125361Srstrong@cs.ucsd.edu {"code": "nuIP = target", 2135361Srstrong@cs.ucsd.edu "else_code": "nuIP = nuIP", 2145361Srstrong@cs.ucsd.edu "cond_test": "true"}) 2155361Srstrong@cs.ucsd.edu exec_output += SeqOpExecute.subst(iop) 2165361Srstrong@cs.ucsd.edu header_output += SeqOpDeclare.subst(iop) 2175378Ssaidi@eecs.umich.edu decoder_output += SeqOpConstructor.subst(iop) 2186654Snate@binkert.org microopClasses["br"] = Br 2195369Ssaidi@eecs.umich.edu 2205361Srstrong@cs.ucsd.edu iop = InstObjParams("eret", "EretFlags", "SeqOpBase", 2215361Srstrong@cs.ucsd.edu {"code": "", "else_code": "", 2225361Srstrong@cs.ucsd.edu "cond_test": "checkCondition(ccFlagBits, cc)"}) 2235361Srstrong@cs.ucsd.edu exec_output += SeqOpExecute.subst(iop) 2245361Srstrong@cs.ucsd.edu header_output += SeqOpDeclare.subst(iop) 2255361Srstrong@cs.ucsd.edu decoder_output += SeqOpConstructor.subst(iop) 2265361Srstrong@cs.ucsd.edu iop = InstObjParams("eret", "Eret", "SeqOpBase", 2275361Srstrong@cs.ucsd.edu {"code": "", "else_code": "", 2285361Srstrong@cs.ucsd.edu "cond_test": "true"}) 2295361Srstrong@cs.ucsd.edu exec_output += SeqOpExecute.subst(iop) 2307531Ssteve.reinhardt@amd.com header_output += SeqOpDeclare.subst(iop) 2315369Ssaidi@eecs.umich.edu decoder_output += SeqOpConstructor.subst(iop) 2325361Srstrong@cs.ucsd.edu microopClasses["eret"] = Eret 2333395Shsul@eecs.umich.edu}}; 2343395Shsul@eecs.umich.edu