limmop.isa revision 12236
14524Sgblack@eecs.umich.edu// Copyright (c) 2007 The Hewlett-Packard Development Company 24524Sgblack@eecs.umich.edu// All rights reserved. 34524Sgblack@eecs.umich.edu// 47087Snate@binkert.org// The license below extends only to copyright in the software and shall 57087Snate@binkert.org// not be construed as granting a license to any other intellectual 67087Snate@binkert.org// property including but not limited to intellectual property relating 77087Snate@binkert.org// to a hardware implementation of the functionality of the software 87087Snate@binkert.org// licensed hereunder. You may use the software subject to the license 97087Snate@binkert.org// terms below provided that you ensure that this notice is replicated 107087Snate@binkert.org// unmodified and in its entirety in all distributions of the software, 117087Snate@binkert.org// modified or unmodified, in source code or in binary form. 124524Sgblack@eecs.umich.edu// 137087Snate@binkert.org// Redistribution and use in source and binary forms, with or without 147087Snate@binkert.org// modification, are permitted provided that the following conditions are 157087Snate@binkert.org// met: redistributions of source code must retain the above copyright 167087Snate@binkert.org// notice, this list of conditions and the following disclaimer; 177087Snate@binkert.org// redistributions in binary form must reproduce the above copyright 187087Snate@binkert.org// notice, this list of conditions and the following disclaimer in the 197087Snate@binkert.org// documentation and/or other materials provided with the distribution; 207087Snate@binkert.org// neither the name of the copyright holders nor the names of its 214524Sgblack@eecs.umich.edu// contributors may be used to endorse or promote products derived from 227087Snate@binkert.org// this software without specific prior written permission. 234524Sgblack@eecs.umich.edu// 244524Sgblack@eecs.umich.edu// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 254524Sgblack@eecs.umich.edu// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 264524Sgblack@eecs.umich.edu// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 274524Sgblack@eecs.umich.edu// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 284524Sgblack@eecs.umich.edu// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 294524Sgblack@eecs.umich.edu// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 304524Sgblack@eecs.umich.edu// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 314524Sgblack@eecs.umich.edu// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 324524Sgblack@eecs.umich.edu// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 334524Sgblack@eecs.umich.edu// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 344524Sgblack@eecs.umich.edu// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 354524Sgblack@eecs.umich.edu// 364524Sgblack@eecs.umich.edu// Authors: Gabe Black 374524Sgblack@eecs.umich.edu 384524Sgblack@eecs.umich.edu////////////////////////////////////////////////////////////////////////// 394524Sgblack@eecs.umich.edu// 404524Sgblack@eecs.umich.edu// LIMMOp Microop templates 414524Sgblack@eecs.umich.edu// 424524Sgblack@eecs.umich.edu////////////////////////////////////////////////////////////////////////// 434524Sgblack@eecs.umich.edu 444524Sgblack@eecs.umich.edudef template MicroLimmOpExecute {{ 4512234Sgabeblack@google.com Fault %(class_name)s::execute(ExecContext *xc, 464524Sgblack@eecs.umich.edu Trace::InstRecord *traceData) const 474524Sgblack@eecs.umich.edu { 484524Sgblack@eecs.umich.edu %(op_decl)s; 494524Sgblack@eecs.umich.edu %(op_rd)s; 504524Sgblack@eecs.umich.edu %(code)s; 514524Sgblack@eecs.umich.edu %(op_wb)s; 524524Sgblack@eecs.umich.edu return NoFault; 534524Sgblack@eecs.umich.edu } 544524Sgblack@eecs.umich.edu}}; 554524Sgblack@eecs.umich.edu 564524Sgblack@eecs.umich.edudef template MicroLimmOpDeclare {{ 574679Sgblack@eecs.umich.edu class %(class_name)s : public X86ISA::X86MicroopBase 584524Sgblack@eecs.umich.edu { 594524Sgblack@eecs.umich.edu protected: 604524Sgblack@eecs.umich.edu const RegIndex dest; 614524Sgblack@eecs.umich.edu const uint64_t imm; 624693Sgblack@eecs.umich.edu const uint8_t dataSize; 634804Sgblack@eecs.umich.edu RegIndex foldOBit; 644524Sgblack@eecs.umich.edu 654581Sgblack@eecs.umich.edu std::string generateDisassembly(Addr pc, 664581Sgblack@eecs.umich.edu const SymbolTable *symtab) const; 674581Sgblack@eecs.umich.edu 684524Sgblack@eecs.umich.edu public: 694524Sgblack@eecs.umich.edu %(class_name)s(ExtMachInst _machInst, 704524Sgblack@eecs.umich.edu const char * instMnem, 717620Sgblack@eecs.umich.edu uint64_t setFlags, InstRegIndex _dest, 727620Sgblack@eecs.umich.edu uint64_t _imm, uint8_t _dataSize); 734524Sgblack@eecs.umich.edu 7412236Sgabeblack@google.com Fault execute(ExecContext *, Trace::InstRecord *) const; 754524Sgblack@eecs.umich.edu }; 764524Sgblack@eecs.umich.edu}}; 774524Sgblack@eecs.umich.edu 784581Sgblack@eecs.umich.edudef template MicroLimmOpDisassembly {{ 794581Sgblack@eecs.umich.edu std::string %(class_name)s::generateDisassembly(Addr pc, 804581Sgblack@eecs.umich.edu const SymbolTable *symtab) const 814581Sgblack@eecs.umich.edu { 824581Sgblack@eecs.umich.edu std::stringstream response; 834581Sgblack@eecs.umich.edu 844581Sgblack@eecs.umich.edu printMnemonic(response, instMnem, mnemonic); 854804Sgblack@eecs.umich.edu printDestReg(response, 0, dataSize); 864581Sgblack@eecs.umich.edu response << ", "; 874581Sgblack@eecs.umich.edu ccprintf(response, "%#x", imm); 884581Sgblack@eecs.umich.edu return response.str(); 894581Sgblack@eecs.umich.edu } 904581Sgblack@eecs.umich.edu}}; 914581Sgblack@eecs.umich.edu 924524Sgblack@eecs.umich.edudef template MicroLimmOpConstructor {{ 9310184SCurtis.Dunham@arm.com %(class_name)s::%(class_name)s( 947620Sgblack@eecs.umich.edu ExtMachInst machInst, const char * instMnem, uint64_t setFlags, 956345Sgblack@eecs.umich.edu InstRegIndex _dest, uint64_t _imm, uint8_t _dataSize) : 964524Sgblack@eecs.umich.edu %(base_class)s(machInst, "%(mnemonic)s", instMnem, 977620Sgblack@eecs.umich.edu setFlags, %(op_class)s), 9812106SRekai.GonzalezAlberquilla@arm.com dest(_dest.index()), imm(_imm), dataSize(_dataSize) 994524Sgblack@eecs.umich.edu { 1007626Sgblack@eecs.umich.edu foldOBit = (dataSize == 1 && !machInst.rex.present) ? 1 << 6 : 0; 1017626Sgblack@eecs.umich.edu %(constructor)s; 1024524Sgblack@eecs.umich.edu } 1034524Sgblack@eecs.umich.edu}}; 1044524Sgblack@eecs.umich.edu 1054524Sgblack@eecs.umich.edulet {{ 1064576Sgblack@eecs.umich.edu class LimmOp(X86Microop): 1074792Sgblack@eecs.umich.edu def __init__(self, dest, imm, dataSize="env.dataSize"): 1084576Sgblack@eecs.umich.edu self.className = "Limm" 1094576Sgblack@eecs.umich.edu self.mnemonic = "limm" 1104524Sgblack@eecs.umich.edu self.dest = dest 1115188Sgblack@eecs.umich.edu if isinstance(imm, (int, long)): 1125188Sgblack@eecs.umich.edu imm = "ULL(%d)" % imm 1134524Sgblack@eecs.umich.edu self.imm = imm 1144792Sgblack@eecs.umich.edu self.dataSize = dataSize 1154524Sgblack@eecs.umich.edu 1167620Sgblack@eecs.umich.edu def getAllocator(self, microFlags): 1177967Sgblack@eecs.umich.edu allocString = ''' 1187967Sgblack@eecs.umich.edu (%(dataSize)s >= 4) ? 1197967Sgblack@eecs.umich.edu (StaticInstPtr)(new %(class_name)sBig(machInst, 1207967Sgblack@eecs.umich.edu macrocodeBlock, %(flags)s, %(dest)s, %(imm)s, 1217967Sgblack@eecs.umich.edu %(dataSize)s)) : 1227967Sgblack@eecs.umich.edu (StaticInstPtr)(new %(class_name)s(machInst, 1237967Sgblack@eecs.umich.edu macrocodeBlock, %(flags)s, %(dest)s, %(imm)s, 1247967Sgblack@eecs.umich.edu %(dataSize)s)) 1257967Sgblack@eecs.umich.edu ''' 1267967Sgblack@eecs.umich.edu allocator = allocString % { 1274524Sgblack@eecs.umich.edu "class_name" : self.className, 1284524Sgblack@eecs.umich.edu "mnemonic" : self.mnemonic, 1294524Sgblack@eecs.umich.edu "flags" : self.microFlagsText(microFlags), 1304693Sgblack@eecs.umich.edu "dest" : self.dest, "imm" : self.imm, 1314693Sgblack@eecs.umich.edu "dataSize" : self.dataSize} 1324576Sgblack@eecs.umich.edu return allocator 1334524Sgblack@eecs.umich.edu 1344524Sgblack@eecs.umich.edu microopClasses["limm"] = LimmOp 1356524Sgblack@eecs.umich.edu 1366524Sgblack@eecs.umich.edu class LfpimmOp(X86Microop): 1376524Sgblack@eecs.umich.edu def __init__(self, dest, imm, dataSize="env.dataSize"): 1386524Sgblack@eecs.umich.edu self.className = "Lfpimm" 1396524Sgblack@eecs.umich.edu self.mnemonic = "lfpimm" 1406524Sgblack@eecs.umich.edu self.dest = dest 1416524Sgblack@eecs.umich.edu if isinstance(imm, (int, long)): 1426524Sgblack@eecs.umich.edu imm = "ULL(%d)" % imm 1439764Sandreas@sandberg.pp.se elif isinstance(imm, float): 1449764Sandreas@sandberg.pp.se imm = "getDoubleBits(%.16f)" % imm 1456524Sgblack@eecs.umich.edu self.imm = imm 1466524Sgblack@eecs.umich.edu self.dataSize = dataSize 1476524Sgblack@eecs.umich.edu 1487620Sgblack@eecs.umich.edu def getAllocator(self, microFlags): 1497620Sgblack@eecs.umich.edu allocator = '''new %(class_name)s(machInst, macrocodeBlock, 1506524Sgblack@eecs.umich.edu %(flags)s, %(dest)s, %(imm)s, %(dataSize)s)''' % { 1516524Sgblack@eecs.umich.edu "class_name" : self.className, 1526524Sgblack@eecs.umich.edu "mnemonic" : self.mnemonic, 1536524Sgblack@eecs.umich.edu "flags" : self.microFlagsText(microFlags), 1546524Sgblack@eecs.umich.edu "dest" : self.dest, "imm" : self.imm, 1556524Sgblack@eecs.umich.edu "dataSize" : self.dataSize} 1566524Sgblack@eecs.umich.edu return allocator 1576524Sgblack@eecs.umich.edu 1586524Sgblack@eecs.umich.edu microopClasses["lfpimm"] = LfpimmOp 1594524Sgblack@eecs.umich.edu}}; 1604524Sgblack@eecs.umich.edu 1614524Sgblack@eecs.umich.edulet {{ 1624524Sgblack@eecs.umich.edu # Build up the all register version of this micro op 1637967Sgblack@eecs.umich.edu iops = [InstObjParams("limm", "Limm", 'X86MicroopBase', 1647967Sgblack@eecs.umich.edu {"code" : "DestReg = merge(DestReg, imm, dataSize);"}), 1657967Sgblack@eecs.umich.edu InstObjParams("limm", "LimmBig", 'X86MicroopBase', 1667967Sgblack@eecs.umich.edu {"code" : "DestReg = imm & mask(dataSize * 8);"})] 1677967Sgblack@eecs.umich.edu for iop in iops: 1687967Sgblack@eecs.umich.edu header_output += MicroLimmOpDeclare.subst(iop) 1697967Sgblack@eecs.umich.edu decoder_output += MicroLimmOpConstructor.subst(iop) 1707967Sgblack@eecs.umich.edu decoder_output += MicroLimmOpDisassembly.subst(iop) 1717967Sgblack@eecs.umich.edu exec_output += MicroLimmOpExecute.subst(iop) 1726524Sgblack@eecs.umich.edu 1736524Sgblack@eecs.umich.edu iop = InstObjParams("lfpimm", "Lfpimm", 'X86MicroopBase', 1748588Sgblack@eecs.umich.edu {"code" : "FpDestReg_uqw = imm"}) 1756524Sgblack@eecs.umich.edu header_output += MicroLimmOpDeclare.subst(iop) 1766524Sgblack@eecs.umich.edu decoder_output += MicroLimmOpConstructor.subst(iop) 1776524Sgblack@eecs.umich.edu decoder_output += MicroLimmOpDisassembly.subst(iop) 1786524Sgblack@eecs.umich.edu exec_output += MicroLimmOpExecute.subst(iop) 1794524Sgblack@eecs.umich.edu}}; 180