base.isa revision 4343
14338Sgblack@eecs.umich.edu// -*- mode:c++ -*- 24338Sgblack@eecs.umich.edu 34338Sgblack@eecs.umich.edu// Copyright (c) 2007 The Hewlett-Packard Development Company 44338Sgblack@eecs.umich.edu// All rights reserved. 54338Sgblack@eecs.umich.edu// 64338Sgblack@eecs.umich.edu// Redistribution and use of this software in source and binary forms, 74338Sgblack@eecs.umich.edu// with or without modification, are permitted provided that the 84338Sgblack@eecs.umich.edu// following conditions are met: 94338Sgblack@eecs.umich.edu// 104338Sgblack@eecs.umich.edu// The software must be used only for Non-Commercial Use which means any 114338Sgblack@eecs.umich.edu// use which is NOT directed to receiving any direct monetary 124338Sgblack@eecs.umich.edu// compensation for, or commercial advantage from such use. Illustrative 134338Sgblack@eecs.umich.edu// examples of non-commercial use are academic research, personal study, 144338Sgblack@eecs.umich.edu// teaching, education and corporate research & development. 154338Sgblack@eecs.umich.edu// Illustrative examples of commercial use are distributing products for 164338Sgblack@eecs.umich.edu// commercial advantage and providing services using the software for 174338Sgblack@eecs.umich.edu// commercial advantage. 184338Sgblack@eecs.umich.edu// 194338Sgblack@eecs.umich.edu// If you wish to use this software or functionality therein that may be 204338Sgblack@eecs.umich.edu// covered by patents for commercial use, please contact: 214338Sgblack@eecs.umich.edu// Director of Intellectual Property Licensing 224338Sgblack@eecs.umich.edu// Office of Strategy and Technology 234338Sgblack@eecs.umich.edu// Hewlett-Packard Company 244338Sgblack@eecs.umich.edu// 1501 Page Mill Road 254338Sgblack@eecs.umich.edu// Palo Alto, California 94304 264338Sgblack@eecs.umich.edu// 274338Sgblack@eecs.umich.edu// Redistributions of source code must retain the above copyright notice, 284338Sgblack@eecs.umich.edu// this list of conditions and the following disclaimer. Redistributions 294338Sgblack@eecs.umich.edu// in binary form must reproduce the above copyright notice, this list of 304338Sgblack@eecs.umich.edu// conditions and the following disclaimer in the documentation and/or 314338Sgblack@eecs.umich.edu// other materials provided with the distribution. Neither the name of 324338Sgblack@eecs.umich.edu// the COPYRIGHT HOLDER(s), HEWLETT-PACKARD COMPANY, nor the names of its 334338Sgblack@eecs.umich.edu// contributors may be used to endorse or promote products derived from 344338Sgblack@eecs.umich.edu// this software without specific prior written permission. No right of 354338Sgblack@eecs.umich.edu// sublicense is granted herewith. Derivatives of the software and 364338Sgblack@eecs.umich.edu// output created using the software may be prepared, but only for 374338Sgblack@eecs.umich.edu// Non-Commercial Uses. Derivatives of the software may be shared with 384338Sgblack@eecs.umich.edu// others provided: (i) the others agree to abide by the list of 394338Sgblack@eecs.umich.edu// conditions herein which includes the Non-Commercial Use restrictions; 404338Sgblack@eecs.umich.edu// and (ii) such Derivatives of the software include the above copyright 414338Sgblack@eecs.umich.edu// notice to acknowledge the contribution from this software where 424338Sgblack@eecs.umich.edu// applicable, this list of conditions and the disclaimer below. 434338Sgblack@eecs.umich.edu// 444338Sgblack@eecs.umich.edu// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 454338Sgblack@eecs.umich.edu// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 464338Sgblack@eecs.umich.edu// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 474338Sgblack@eecs.umich.edu// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 484338Sgblack@eecs.umich.edu// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 494338Sgblack@eecs.umich.edu// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 504338Sgblack@eecs.umich.edu// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 514338Sgblack@eecs.umich.edu// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 524338Sgblack@eecs.umich.edu// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 534338Sgblack@eecs.umich.edu// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 544338Sgblack@eecs.umich.edu// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 554338Sgblack@eecs.umich.edu// 564338Sgblack@eecs.umich.edu// Authors: Gabe Black 574338Sgblack@eecs.umich.edu 584338Sgblack@eecs.umich.edu//The operand types a microop template can be specialized with 594338Sgblack@eecs.umich.eduoutput header {{ 604338Sgblack@eecs.umich.edu enum OperandType { 614338Sgblack@eecs.umich.edu RegisterOperand, 624338Sgblack@eecs.umich.edu ImmediateOperand 634338Sgblack@eecs.umich.edu }; 644338Sgblack@eecs.umich.edu}}; 654338Sgblack@eecs.umich.edu 664338Sgblack@eecs.umich.edu//A class which is the base of all x86 micro ops it provides a function to 674338Sgblack@eecs.umich.edu//set necessary flags appropriately. 684338Sgblack@eecs.umich.eduoutput header {{ 694338Sgblack@eecs.umich.edu class X86MicroOpBase : public X86StaticInst 704338Sgblack@eecs.umich.edu { 714338Sgblack@eecs.umich.edu protected: 724343Sgblack@eecs.umich.edu uint8_t opSize; 734343Sgblack@eecs.umich.edu uint8_t addrSize; 744343Sgblack@eecs.umich.edu 754338Sgblack@eecs.umich.edu X86MicroOpBase(bool isMicro, bool isDelayed, 764338Sgblack@eecs.umich.edu bool isFirst, bool isLast, 774338Sgblack@eecs.umich.edu const char *mnem, ExtMachInst _machInst, 784338Sgblack@eecs.umich.edu OpClass __opClass) : 794338Sgblack@eecs.umich.edu X86StaticInst(mnem, _machInst, __opClass) 804338Sgblack@eecs.umich.edu { 814338Sgblack@eecs.umich.edu flags[IsMicroOp] = isMicro; 824338Sgblack@eecs.umich.edu flags[IsDelayedCommit] = isDelayed; 834338Sgblack@eecs.umich.edu flags[IsFirstMicroOp] = isFirst; 844338Sgblack@eecs.umich.edu flags[IsLastMicroOp] = isLast; 854338Sgblack@eecs.umich.edu } 864338Sgblack@eecs.umich.edu }; 874338Sgblack@eecs.umich.edu}}; 884338Sgblack@eecs.umich.edu 894338Sgblack@eecs.umich.edu// This sets up a class which is templated on the type of 904338Sgblack@eecs.umich.edu// arguments a particular flavor of a microcode instruction 914338Sgblack@eecs.umich.edu// can accept. It's parameters are specialized to create polymorphic 924338Sgblack@eecs.umich.edu// behavior in microops. 934338Sgblack@eecs.umich.edudef template BaseMicroOpTemplateDeclare {{ 944338Sgblack@eecs.umich.edu template%(signature)s 954338Sgblack@eecs.umich.edu class %(class_name)s; 964338Sgblack@eecs.umich.edu}}; 974338Sgblack@eecs.umich.edu 984338Sgblack@eecs.umich.edulet {{ 994338Sgblack@eecs.umich.edu def buildBaseMicroOpTemplate(Name, numParams): 1004338Sgblack@eecs.umich.edu signature = "<" 1014338Sgblack@eecs.umich.edu signature += "int SignatureOperandTypeSpecifier0" 1024338Sgblack@eecs.umich.edu for count in xrange(1,numParams): 1034338Sgblack@eecs.umich.edu signature += \ 1044338Sgblack@eecs.umich.edu ", int SingatureOperandTypeSpecifier%d" % count 1054338Sgblack@eecs.umich.edu signature += ">" 1064338Sgblack@eecs.umich.edu subs = {"signature" : signature, "class_name" : Name} 1074338Sgblack@eecs.umich.edu return BaseMicroOpTemplateDeclare.subst(subs) 1084338Sgblack@eecs.umich.edu 1094338Sgblack@eecs.umich.edu RegOpType = "RegisterOperand" 1104338Sgblack@eecs.umich.edu ImmOpType = "ImmediateOperand" 1114338Sgblack@eecs.umich.edu 1124338Sgblack@eecs.umich.edu def buildMicroOpTemplateDict(*params): 1134338Sgblack@eecs.umich.edu signature = "<" 1144338Sgblack@eecs.umich.edu if len(params): 1154338Sgblack@eecs.umich.edu signature += params[0] 1164338Sgblack@eecs.umich.edu if len(params) > 1: 1174338Sgblack@eecs.umich.edu for param in params[1:]: 1184338Sgblack@eecs.umich.edu signature += ", %s" % param 1194338Sgblack@eecs.umich.edu signature += ">" 1204338Sgblack@eecs.umich.edu subs = {"param_dec" : "", "param_arg_dec" : "", 1214338Sgblack@eecs.umich.edu "param_init" : "", "signature" : signature} 1224338Sgblack@eecs.umich.edu for count in xrange(len(params)): 1234338Sgblack@eecs.umich.edu subs["param_dec"] += "uint64_t param%d;\n" % count 1244338Sgblack@eecs.umich.edu subs["param_arg_dec"] += ", uint64_t _param%d" % count 1254338Sgblack@eecs.umich.edu subs["param_init"] += ", param%d(_param%d)" % (count, count) 1264338Sgblack@eecs.umich.edu return subs 1274338Sgblack@eecs.umich.edu}}; 1284338Sgblack@eecs.umich.edu 1294338Sgblack@eecs.umich.edu// A tmeplate for building a specialized version of the microcode 1304338Sgblack@eecs.umich.edu// instruction which knows specifies which arguments it wants 1314338Sgblack@eecs.umich.edudef template MicroOpDeclare {{ 1324338Sgblack@eecs.umich.edu template<> 1334338Sgblack@eecs.umich.edu class %(class_name)s%(signature)s : public X86MicroOpBase 1344338Sgblack@eecs.umich.edu { 1354338Sgblack@eecs.umich.edu protected: 1364338Sgblack@eecs.umich.edu %(param_dec)s 1374338Sgblack@eecs.umich.edu void buildMe(); 1384338Sgblack@eecs.umich.edu 1394338Sgblack@eecs.umich.edu public: 1404338Sgblack@eecs.umich.edu %(class_name)s(bool isMicro, bool isDelayed, 1414338Sgblack@eecs.umich.edu bool isFirst, bool isLast, 1424338Sgblack@eecs.umich.edu ExtMachInst _machInst %(param_arg_dec)s); 1434338Sgblack@eecs.umich.edu 1444338Sgblack@eecs.umich.edu %(class_name)s(ExtMachInst _machInst %(param_arg_dec)s); 1454338Sgblack@eecs.umich.edu 1464338Sgblack@eecs.umich.edu %(BasicExecDeclare)s 1474338Sgblack@eecs.umich.edu }; 1484338Sgblack@eecs.umich.edu}}; 1494338Sgblack@eecs.umich.edu 1504338Sgblack@eecs.umich.edudef template MicroOpConstructor {{ 1514338Sgblack@eecs.umich.edu 1524338Sgblack@eecs.umich.edu inline void %(class_name)s%(signature)s::buildMe() 1534338Sgblack@eecs.umich.edu { 1544338Sgblack@eecs.umich.edu %(constructor)s; 1554338Sgblack@eecs.umich.edu } 1564338Sgblack@eecs.umich.edu 1574338Sgblack@eecs.umich.edu inline %(class_name)s%(signature)s::%(class_name)s( 1584338Sgblack@eecs.umich.edu ExtMachInst machInst %(param_arg_dec)s) : 1594338Sgblack@eecs.umich.edu %(base_class)s(false, false, false, false, 1604338Sgblack@eecs.umich.edu "%(mnemonic)s", machInst, %(op_class)s) 1614338Sgblack@eecs.umich.edu %(param_init)s 1624338Sgblack@eecs.umich.edu { 1634338Sgblack@eecs.umich.edu buildMe(); 1644338Sgblack@eecs.umich.edu } 1654338Sgblack@eecs.umich.edu 1664338Sgblack@eecs.umich.edu inline %(class_name)s%(signature)s::%(class_name)s( 1674338Sgblack@eecs.umich.edu bool isMicro, bool isDelayed, bool isFirst, bool isLast, 1684338Sgblack@eecs.umich.edu ExtMachInst machInst %(param_arg_dec)s) 1694338Sgblack@eecs.umich.edu : %(base_class)s(isMicro, isDelayed, isFirst, isLast, 1704338Sgblack@eecs.umich.edu "%(mnemonic)s", machInst, %(op_class)s) 1714338Sgblack@eecs.umich.edu %(param_init)s 1724338Sgblack@eecs.umich.edu { 1734338Sgblack@eecs.umich.edu buildMe(); 1744338Sgblack@eecs.umich.edu } 1754338Sgblack@eecs.umich.edu}}; 176