base.isa revision 4338
11689SN/A// -*- mode:c++ -*- 27854SAli.Saidi@ARM.com 37854SAli.Saidi@ARM.com// Copyright (c) 2007 The Hewlett-Packard Development Company 47854SAli.Saidi@ARM.com// All rights reserved. 57854SAli.Saidi@ARM.com// 67854SAli.Saidi@ARM.com// Redistribution and use of this software in source and binary forms, 77854SAli.Saidi@ARM.com// with or without modification, are permitted provided that the 87854SAli.Saidi@ARM.com// following conditions are met: 97854SAli.Saidi@ARM.com// 107854SAli.Saidi@ARM.com// The software must be used only for Non-Commercial Use which means any 117854SAli.Saidi@ARM.com// use which is NOT directed to receiving any direct monetary 127854SAli.Saidi@ARM.com// compensation for, or commercial advantage from such use. Illustrative 137854SAli.Saidi@ARM.com// examples of non-commercial use are academic research, personal study, 142329SN/A// teaching, education and corporate research & development. 151689SN/A// Illustrative examples of commercial use are distributing products for 161689SN/A// commercial advantage and providing services using the software for 171689SN/A// commercial advantage. 181689SN/A// 191689SN/A// If you wish to use this software or functionality therein that may be 201689SN/A// covered by patents for commercial use, please contact: 211689SN/A// Director of Intellectual Property Licensing 221689SN/A// Office of Strategy and Technology 231689SN/A// Hewlett-Packard Company 241689SN/A// 1501 Page Mill Road 251689SN/A// Palo Alto, California 94304 261689SN/A// 271689SN/A// Redistributions of source code must retain the above copyright notice, 281689SN/A// this list of conditions and the following disclaimer. Redistributions 291689SN/A// in binary form must reproduce the above copyright notice, this list of 301689SN/A// conditions and the following disclaimer in the documentation and/or 311689SN/A// other materials provided with the distribution. Neither the name of 321689SN/A// the COPYRIGHT HOLDER(s), HEWLETT-PACKARD COMPANY, nor the names of its 331689SN/A// contributors may be used to endorse or promote products derived from 341689SN/A// this software without specific prior written permission. No right of 351689SN/A// sublicense is granted herewith. Derivatives of the software and 361689SN/A// output created using the software may be prepared, but only for 371689SN/A// Non-Commercial Uses. Derivatives of the software may be shared with 381689SN/A// others provided: (i) the others agree to abide by the list of 392665Ssaidi@eecs.umich.edu// conditions herein which includes the Non-Commercial Use restrictions; 402665Ssaidi@eecs.umich.edu// and (ii) such Derivatives of the software include the above copyright 412935Sksewell@umich.edu// notice to acknowledge the contribution from this software where 421689SN/A// applicable, this list of conditions and the disclaimer below. 431689SN/A// 441060SN/A// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 451060SN/A// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 463773Sgblack@eecs.umich.edu// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 476329Sgblack@eecs.umich.edu// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 481858SN/A// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 496658Snate@binkert.org// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 501717SN/A// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 518232Snate@binkert.org// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 528232Snate@binkert.org// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 535529Snate@binkert.org// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 541060SN/A// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 556221Snate@binkert.org// 566221Snate@binkert.org// Authors: Gabe Black 571061SN/A 585529Snate@binkert.org//The operand types a microop template can be specialized with 594329Sktlim@umich.eduoutput header {{ 604329Sktlim@umich.edu enum OperandType { 612292SN/A RegisterOperand, 622292SN/A ImmediateOperand 632292SN/A }; 642292SN/A}}; 653788Sgblack@eecs.umich.edu 663798Sgblack@eecs.umich.edu//A class which is the base of all x86 micro ops it provides a function to 675529Snate@binkert.org//set necessary flags appropriately. 682361SN/Aoutput header {{ 691060SN/A class X86MicroOpBase : public X86StaticInst 702292SN/A { 712292SN/A protected: 726221Snate@binkert.org X86MicroOpBase(bool isMicro, bool isDelayed, 736221Snate@binkert.org bool isFirst, bool isLast, 742292SN/A const char *mnem, ExtMachInst _machInst, 756221Snate@binkert.org OpClass __opClass) : 766221Snate@binkert.org X86StaticInst(mnem, _machInst, __opClass) 776221Snate@binkert.org { 782292SN/A flags[IsMicroOp] = isMicro; 796221Snate@binkert.org flags[IsDelayedCommit] = isDelayed; 806221Snate@binkert.org flags[IsFirstMicroOp] = isFirst; 816221Snate@binkert.org flags[IsLastMicroOp] = isLast; 822292SN/A } 836221Snate@binkert.org }; 842292SN/A}}; 856221Snate@binkert.org 862292SN/A// This sets up a class which is templated on the type of 876221Snate@binkert.org// arguments a particular flavor of a microcode instruction 882292SN/A// can accept. It's parameters are specialized to create polymorphic 892292SN/A// behavior in microops. 902292SN/Adef template BaseMicroOpTemplateDeclare {{ 912292SN/A template%(signature)s 922292SN/A class %(class_name)s; 932292SN/A}}; 942292SN/A 952292SN/Alet {{ 962292SN/A def buildBaseMicroOpTemplate(Name, numParams): 972292SN/A signature = "<" 982292SN/A signature += "int SignatureOperandTypeSpecifier0" 991060SN/A for count in xrange(1,numParams): 1001060SN/A signature += \ 1011061SN/A ", int SingatureOperandTypeSpecifier%d" % count 1021060SN/A signature += ">" 1032292SN/A subs = {"signature" : signature, "class_name" : Name} 1041062SN/A return BaseMicroOpTemplateDeclare.subst(subs) 1051062SN/A 1068240Snate@binkert.org RegOpType = "RegisterOperand" 1071062SN/A ImmOpType = "ImmediateOperand" 1081062SN/A 1091062SN/A def buildMicroOpTemplateDict(*params): 1108240Snate@binkert.org signature = "<" 1111062SN/A if len(params): 1121062SN/A signature += params[0] 1131062SN/A if len(params) > 1: 1148240Snate@binkert.org for param in params[1:]: 1151062SN/A signature += ", %s" % param 1161062SN/A signature += ">" 1172301SN/A subs = {"param_dec" : "", "param_arg_dec" : "", 1188240Snate@binkert.org "param_init" : "", "signature" : signature} 1192301SN/A for count in xrange(len(params)): 1202301SN/A subs["param_dec"] += "uint64_t param%d;\n" % count 1212292SN/A subs["param_arg_dec"] += ", uint64_t _param%d" % count 1228240Snate@binkert.org subs["param_init"] += ", param%d(_param%d)" % (count, count) 1232292SN/A return subs 1242292SN/A}}; 1251062SN/A 1268240Snate@binkert.org// A tmeplate for building a specialized version of the microcode 1271062SN/A// instruction which knows specifies which arguments it wants 1281062SN/Adef template MicroOpDeclare {{ 1291062SN/A template<> 1308240Snate@binkert.org class %(class_name)s%(signature)s : public X86MicroOpBase 1311062SN/A { 1321062SN/A protected: 1331062SN/A %(param_dec)s 1348240Snate@binkert.org void buildMe(); 1351062SN/A 1361062SN/A public: 1371062SN/A %(class_name)s(bool isMicro, bool isDelayed, 1388240Snate@binkert.org bool isFirst, bool isLast, 1392292SN/A ExtMachInst _machInst %(param_arg_dec)s); 1401062SN/A 1411062SN/A %(class_name)s(ExtMachInst _machInst %(param_arg_dec)s); 1428240Snate@binkert.org 1432292SN/A %(BasicExecDeclare)s 1441062SN/A }; 1452292SN/A}}; 1468240Snate@binkert.org 1472292SN/Adef template MicroOpConstructor {{ 1482292SN/A 1491062SN/A inline void %(class_name)s%(signature)s::buildMe() 1508240Snate@binkert.org { 1511062SN/A %(constructor)s; 1521062SN/A } 1531062SN/A 1548240Snate@binkert.org inline %(class_name)s%(signature)s::%(class_name)s( 1551062SN/A ExtMachInst machInst %(param_arg_dec)s) : 1561062SN/A %(base_class)s(false, false, false, false, 1571062SN/A "%(mnemonic)s", machInst, %(op_class)s) 1588240Snate@binkert.org %(param_init)s 1591062SN/A { 1601062SN/A buildMe(); 1611062SN/A } 1628240Snate@binkert.org 1631062SN/A inline %(class_name)s%(signature)s::%(class_name)s( 1641062SN/A bool isMicro, bool isDelayed, bool isFirst, bool isLast, 1651062SN/A ExtMachInst machInst %(param_arg_dec)s) 1668240Snate@binkert.org : %(base_class)s(isMicro, isDelayed, isFirst, isLast, 1671062SN/A "%(mnemonic)s", machInst, %(op_class)s) 1681062SN/A %(param_init)s 1692301SN/A { 1708240Snate@binkert.org buildMe(); 1712301SN/A } 1722301SN/A}}; 1732301SN/A