12089SN/A// -*- mode:c++ -*- 22022SN/A 35268Sksewell@umich.edu// -*- mode:c++ -*- 45222Sksewell@umich.edu 55268Sksewell@umich.edu// Copyright (c) 2003-2005 The Regents of The University of Michigan 65268Sksewell@umich.edu// All rights reserved. 75268Sksewell@umich.edu// 85268Sksewell@umich.edu// Redistribution and use in source and binary forms, with or without 95268Sksewell@umich.edu// modification, are permitted provided that the following conditions are 105268Sksewell@umich.edu// met: redistributions of source code must retain the above copyright 115268Sksewell@umich.edu// notice, this list of conditions and the following disclaimer; 125268Sksewell@umich.edu// redistributions in binary form must reproduce the above copyright 135268Sksewell@umich.edu// notice, this list of conditions and the following disclaimer in the 145268Sksewell@umich.edu// documentation and/or other materials provided with the distribution; 155268Sksewell@umich.edu// neither the name of the copyright holders nor the names of its 165268Sksewell@umich.edu// contributors may be used to endorse or promote products derived from 175268Sksewell@umich.edu// this software without specific prior written permission. 185268Sksewell@umich.edu// 195268Sksewell@umich.edu// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 205268Sksewell@umich.edu// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 215268Sksewell@umich.edu// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 225268Sksewell@umich.edu// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 235268Sksewell@umich.edu// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 245268Sksewell@umich.edu// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 255268Sksewell@umich.edu// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 265268Sksewell@umich.edu// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 275268Sksewell@umich.edu// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 285268Sksewell@umich.edu// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 295268Sksewell@umich.edu// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 305268Sksewell@umich.edu// 315268Sksewell@umich.edu// Authors: Steve Reinhardt 325268Sksewell@umich.edu// Korey Sewell 332706Sksewell@umich.edu 342022SN/A// Basic instruction class declaration template. 352022SN/Adef template BasicDeclare {{ 362022SN/A /** 372022SN/A * Static instruction class for "%(mnemonic)s". 382022SN/A */ 392022SN/A class %(class_name)s : public %(base_class)s 402022SN/A { 412686Sksewell@umich.edu public: 422022SN/A /// Constructor. 432022SN/A %(class_name)s(MachInst machInst); 4412616Sgabeblack@google.com Fault execute(ExecContext *, 4512616Sgabeblack@google.com Trace::InstRecord *) const override; 462686Sksewell@umich.edu }; 472022SN/A}}; 482022SN/A 492022SN/A// Basic instruction class constructor template. 502022SN/Adef template BasicConstructor {{ 5110184SCurtis.Dunham@arm.com %(class_name)s::%(class_name)s(MachInst machInst) : %(base_class)s("%(mnemonic)s", machInst, %(op_class)s) 522022SN/A { 532022SN/A %(constructor)s; 542022SN/A } 552022SN/A}}; 562022SN/A 572686Sksewell@umich.edu 582022SN/A// Basic instruction class execute method template. 592022SN/Adef template BasicExecute {{ 6012234Sgabeblack@google.com Fault %(class_name)s::execute( 6112234Sgabeblack@google.com ExecContext *xc, Trace::InstRecord *traceData) const 622022SN/A { 632239SN/A Fault fault = NoFault; 642022SN/A 652022SN/A %(fp_enable_check)s; 662022SN/A %(op_decl)s; 672022SN/A %(op_rd)s; 682239SN/A if(fault == NoFault) 692022SN/A { 705222Sksewell@umich.edu %(code)s; 715222Sksewell@umich.edu if(fault == NoFault){ 722104SN/A %(op_wb)s; 735222Sksewell@umich.edu } 742022SN/A } 752022SN/A return fault; 762022SN/A } 772022SN/A}}; 782022SN/A 792022SN/A// Basic decode template. 802022SN/Adef template BasicDecode {{ 812022SN/A return new %(class_name)s(machInst); 822022SN/A}}; 832022SN/A 842022SN/A// Basic decode template, passing mnemonic in as string arg to constructor. 852022SN/Adef template BasicDecodeWithMnemonic {{ 862022SN/A return new %(class_name)s("%(mnemonic)s", machInst); 872022SN/A}}; 882022SN/A 892935Sksewell@umich.edu// The most basic instruction format... 902083SN/Adef format BasicOp(code, *flags) {{ 913951Sgblack@eecs.umich.edu iop = InstObjParams(name, Name, 'MipsStaticInst', code, flags) 922022SN/A header_output = BasicDeclare.subst(iop) 932022SN/A decoder_output = BasicConstructor.subst(iop) 942022SN/A decode_block = BasicDecode.subst(iop) 952022SN/A exec_output = BasicExecute.subst(iop) 962022SN/A}}; 97