limmop.isa revision 5788
15409Sgblack@eecs.umich.edu// Copyright (c) 2007 The Hewlett-Packard Development Company 24519Sgblack@eecs.umich.edu// All rights reserved. 34519Sgblack@eecs.umich.edu// 44519Sgblack@eecs.umich.edu// Redistribution and use of this software in source and binary forms, 54519Sgblack@eecs.umich.edu// with or without modification, are permitted provided that the 64519Sgblack@eecs.umich.edu// following conditions are met: 74519Sgblack@eecs.umich.edu// 84519Sgblack@eecs.umich.edu// The software must be used only for Non-Commercial Use which means any 94519Sgblack@eecs.umich.edu// use which is NOT directed to receiving any direct monetary 104519Sgblack@eecs.umich.edu// compensation for, or commercial advantage from such use. Illustrative 114519Sgblack@eecs.umich.edu// examples of non-commercial use are academic research, personal study, 124519Sgblack@eecs.umich.edu// teaching, education and corporate research & development. 134519Sgblack@eecs.umich.edu// Illustrative examples of commercial use are distributing products for 144519Sgblack@eecs.umich.edu// commercial advantage and providing services using the software for 154519Sgblack@eecs.umich.edu// commercial advantage. 164519Sgblack@eecs.umich.edu// 174519Sgblack@eecs.umich.edu// If you wish to use this software or functionality therein that may be 184519Sgblack@eecs.umich.edu// covered by patents for commercial use, please contact: 194519Sgblack@eecs.umich.edu// Director of Intellectual Property Licensing 204519Sgblack@eecs.umich.edu// Office of Strategy and Technology 214519Sgblack@eecs.umich.edu// Hewlett-Packard Company 224519Sgblack@eecs.umich.edu// 1501 Page Mill Road 234519Sgblack@eecs.umich.edu// Palo Alto, California 94304 244519Sgblack@eecs.umich.edu// 254519Sgblack@eecs.umich.edu// Redistributions of source code must retain the above copyright notice, 264519Sgblack@eecs.umich.edu// this list of conditions and the following disclaimer. Redistributions 274519Sgblack@eecs.umich.edu// in binary form must reproduce the above copyright notice, this list of 284519Sgblack@eecs.umich.edu// conditions and the following disclaimer in the documentation and/or 294519Sgblack@eecs.umich.edu// other materials provided with the distribution. Neither the name of 304519Sgblack@eecs.umich.edu// the COPYRIGHT HOLDER(s), HEWLETT-PACKARD COMPANY, nor the names of its 314519Sgblack@eecs.umich.edu// contributors may be used to endorse or promote products derived from 324519Sgblack@eecs.umich.edu// this software without specific prior written permission. No right of 334519Sgblack@eecs.umich.edu// sublicense is granted herewith. Derivatives of the software and 344519Sgblack@eecs.umich.edu// output created using the software may be prepared, but only for 354519Sgblack@eecs.umich.edu// Non-Commercial Uses. Derivatives of the software may be shared with 364519Sgblack@eecs.umich.edu// others provided: (i) the others agree to abide by the list of 374519Sgblack@eecs.umich.edu// conditions herein which includes the Non-Commercial Use restrictions; 384519Sgblack@eecs.umich.edu// and (ii) such Derivatives of the software include the above copyright 394519Sgblack@eecs.umich.edu// notice to acknowledge the contribution from this software where 404519Sgblack@eecs.umich.edu// applicable, this list of conditions and the disclaimer below. 414519Sgblack@eecs.umich.edu// 424519Sgblack@eecs.umich.edu// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 434519Sgblack@eecs.umich.edu// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 444519Sgblack@eecs.umich.edu// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 454519Sgblack@eecs.umich.edu// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 464519Sgblack@eecs.umich.edu// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 474519Sgblack@eecs.umich.edu// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 484519Sgblack@eecs.umich.edu// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 494519Sgblack@eecs.umich.edu// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 504519Sgblack@eecs.umich.edu// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 514519Sgblack@eecs.umich.edu// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 524519Sgblack@eecs.umich.edu// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 534519Sgblack@eecs.umich.edu// 544519Sgblack@eecs.umich.edu// Authors: Gabe Black 554519Sgblack@eecs.umich.edu 564519Sgblack@eecs.umich.edu////////////////////////////////////////////////////////////////////////// 574519Sgblack@eecs.umich.edu// 584519Sgblack@eecs.umich.edu// LIMMOp Microop templates 594519Sgblack@eecs.umich.edu// 604519Sgblack@eecs.umich.edu////////////////////////////////////////////////////////////////////////// 614519Sgblack@eecs.umich.edu 624519Sgblack@eecs.umich.edudef template MicroLimmOpExecute {{ 634519Sgblack@eecs.umich.edu Fault %(class_name)s::execute(%(CPU_exec_context)s *xc, 644519Sgblack@eecs.umich.edu Trace::InstRecord *traceData) const 654519Sgblack@eecs.umich.edu { 664519Sgblack@eecs.umich.edu %(op_decl)s; 674519Sgblack@eecs.umich.edu %(op_rd)s; 684809Sgblack@eecs.umich.edu %(code)s; 694519Sgblack@eecs.umich.edu %(op_wb)s; 704519Sgblack@eecs.umich.edu return NoFault; 714688Sgblack@eecs.umich.edu } 724688Sgblack@eecs.umich.edu}}; 734688Sgblack@eecs.umich.edu 744688Sgblack@eecs.umich.edudef template MicroLimmOpDeclare {{ 754688Sgblack@eecs.umich.edu class %(class_name)s : public X86ISA::X86MicroopBase 764688Sgblack@eecs.umich.edu { 774708Sgblack@eecs.umich.edu protected: 784708Sgblack@eecs.umich.edu const RegIndex dest; 794708Sgblack@eecs.umich.edu const uint64_t imm; 804708Sgblack@eecs.umich.edu const uint8_t dataSize; 814519Sgblack@eecs.umich.edu RegIndex foldOBit; 824519Sgblack@eecs.umich.edu void buildMe(); 834519Sgblack@eecs.umich.edu 844519Sgblack@eecs.umich.edu std::string generateDisassembly(Addr pc, 854519Sgblack@eecs.umich.edu const SymbolTable *symtab) const; 864519Sgblack@eecs.umich.edu 874519Sgblack@eecs.umich.edu public: 884519Sgblack@eecs.umich.edu %(class_name)s(ExtMachInst _machInst, 894519Sgblack@eecs.umich.edu const char * instMnem, 904519Sgblack@eecs.umich.edu bool isMicro, bool isDelayed, bool isFirst, bool isLast, 914519Sgblack@eecs.umich.edu RegIndex _dest, uint64_t _imm, uint8_t _dataSize); 924951Sgblack@eecs.umich.edu 934519Sgblack@eecs.umich.edu %(class_name)s(ExtMachInst _machInst, 944519Sgblack@eecs.umich.edu const char * instMnem, 954519Sgblack@eecs.umich.edu RegIndex _dest, uint64_t _imm, uint8_t _dataSize); 964519Sgblack@eecs.umich.edu 974519Sgblack@eecs.umich.edu %(BasicExecDeclare)s 984519Sgblack@eecs.umich.edu }; 994688Sgblack@eecs.umich.edu}}; 1004688Sgblack@eecs.umich.edu 1014688Sgblack@eecs.umich.edudef template MicroLimmOpDisassembly {{ 1024688Sgblack@eecs.umich.edu std::string %(class_name)s::generateDisassembly(Addr pc, 1034688Sgblack@eecs.umich.edu const SymbolTable *symtab) const 1044688Sgblack@eecs.umich.edu { 1054708Sgblack@eecs.umich.edu std::stringstream response; 1064708Sgblack@eecs.umich.edu 1074708Sgblack@eecs.umich.edu printMnemonic(response, instMnem, mnemonic); 1084708Sgblack@eecs.umich.edu printDestReg(response, 0, dataSize); 1094519Sgblack@eecs.umich.edu response << ", "; 1104519Sgblack@eecs.umich.edu ccprintf(response, "%#x", imm); 1114519Sgblack@eecs.umich.edu return response.str(); 1124519Sgblack@eecs.umich.edu } 1134519Sgblack@eecs.umich.edu}}; 1144519Sgblack@eecs.umich.edu 1154519Sgblack@eecs.umich.edudef template MicroLimmOpConstructor {{ 1164519Sgblack@eecs.umich.edu 1174519Sgblack@eecs.umich.edu inline void %(class_name)s::buildMe() 1184519Sgblack@eecs.umich.edu { 1194519Sgblack@eecs.umich.edu foldOBit = (dataSize == 1 && !machInst.rex.present) ? 1 << 6 : 0; 1204519Sgblack@eecs.umich.edu %(constructor)s; 1214519Sgblack@eecs.umich.edu } 1224519Sgblack@eecs.umich.edu 1234519Sgblack@eecs.umich.edu inline %(class_name)s::%(class_name)s( 1244519Sgblack@eecs.umich.edu ExtMachInst machInst, const char * instMnem, 1254519Sgblack@eecs.umich.edu RegIndex _dest, uint64_t _imm, uint8_t _dataSize) : 1264519Sgblack@eecs.umich.edu %(base_class)s(machInst, "%(mnemonic)s", instMnem, 1274519Sgblack@eecs.umich.edu false, false, false, false, %(op_class)s), 1284519Sgblack@eecs.umich.edu dest(_dest), imm(_imm), dataSize(_dataSize) 1294519Sgblack@eecs.umich.edu { 1304712Sgblack@eecs.umich.edu buildMe(); 1314519Sgblack@eecs.umich.edu } 1324519Sgblack@eecs.umich.edu 1334519Sgblack@eecs.umich.edu inline %(class_name)s::%(class_name)s( 1344519Sgblack@eecs.umich.edu ExtMachInst machInst, const char * instMnem, 1354712Sgblack@eecs.umich.edu bool isMicro, bool isDelayed, bool isFirst, bool isLast, 1364519Sgblack@eecs.umich.edu RegIndex _dest, uint64_t _imm, uint8_t _dataSize) : 1374519Sgblack@eecs.umich.edu %(base_class)s(machInst, "%(mnemonic)s", instMnem, 1384519Sgblack@eecs.umich.edu isMicro, isDelayed, isFirst, isLast, %(op_class)s), 1394519Sgblack@eecs.umich.edu dest(_dest), imm(_imm), dataSize(_dataSize) 1404519Sgblack@eecs.umich.edu { 1414519Sgblack@eecs.umich.edu buildMe(); 1424519Sgblack@eecs.umich.edu } 1434951Sgblack@eecs.umich.edu}}; 1444519Sgblack@eecs.umich.edu 1454519Sgblack@eecs.umich.edulet {{ 1464519Sgblack@eecs.umich.edu class LimmOp(X86Microop): 1474519Sgblack@eecs.umich.edu def __init__(self, dest, imm, dataSize="env.dataSize"): 1484519Sgblack@eecs.umich.edu self.className = "Limm" 1494951Sgblack@eecs.umich.edu self.mnemonic = "limm" 1504519Sgblack@eecs.umich.edu self.dest = dest 1514519Sgblack@eecs.umich.edu if isinstance(imm, (int, long)): 1524951Sgblack@eecs.umich.edu imm = "ULL(%d)" % imm 1534712Sgblack@eecs.umich.edu self.imm = imm 1544519Sgblack@eecs.umich.edu self.dataSize = dataSize 1554951Sgblack@eecs.umich.edu 1564519Sgblack@eecs.umich.edu def getAllocator(self, *microFlags): 1574951Sgblack@eecs.umich.edu allocator = '''new %(class_name)s(machInst, macrocodeBlock 1584712Sgblack@eecs.umich.edu %(flags)s, %(dest)s, %(imm)s, %(dataSize)s)''' % { 1594519Sgblack@eecs.umich.edu "class_name" : self.className, 1604519Sgblack@eecs.umich.edu "mnemonic" : self.mnemonic, 1614519Sgblack@eecs.umich.edu "flags" : self.microFlagsText(microFlags), 1624519Sgblack@eecs.umich.edu "dest" : self.dest, "imm" : self.imm, 1634519Sgblack@eecs.umich.edu "dataSize" : self.dataSize} 1644519Sgblack@eecs.umich.edu return allocator 1654519Sgblack@eecs.umich.edu 1664519Sgblack@eecs.umich.edu microopClasses["limm"] = LimmOp 1674519Sgblack@eecs.umich.edu}}; 1684519Sgblack@eecs.umich.edu 1694519Sgblack@eecs.umich.edulet {{ 1704519Sgblack@eecs.umich.edu # Build up the all register version of this micro op 1714519Sgblack@eecs.umich.edu iop = InstObjParams("limm", "Limm", 'X86MicroopBase', 1724519Sgblack@eecs.umich.edu {"code" : "DestReg = merge(DestReg, imm, dataSize);"}) 1734519Sgblack@eecs.umich.edu header_output += MicroLimmOpDeclare.subst(iop) 1744712Sgblack@eecs.umich.edu decoder_output += MicroLimmOpConstructor.subst(iop) 1754519Sgblack@eecs.umich.edu decoder_output += MicroLimmOpDisassembly.subst(iop) 1764581Sgblack@eecs.umich.edu exec_output += MicroLimmOpExecute.subst(iop) 1774688Sgblack@eecs.umich.edu}}; 1784581Sgblack@eecs.umich.edu