basic.isa revision 10184
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// Declarations for execute() methods. 352022SN/Adef template BasicExecDeclare {{ 362022SN/A Fault execute(%(CPU_exec_context)s *, Trace::InstRecord *) const; 372022SN/A}}; 382022SN/A 392022SN/A// Basic instruction class declaration template. 402022SN/Adef template BasicDeclare {{ 412022SN/A /** 422022SN/A * Static instruction class for "%(mnemonic)s". 432022SN/A */ 442022SN/A class %(class_name)s : public %(base_class)s 452022SN/A { 462686Sksewell@umich.edu public: 472022SN/A /// Constructor. 482022SN/A %(class_name)s(MachInst machInst); 492022SN/A %(BasicExecDeclare)s 502686Sksewell@umich.edu }; 512022SN/A}}; 522022SN/A 532022SN/A// Basic instruction class constructor template. 542022SN/Adef template BasicConstructor {{ 5510184SCurtis.Dunham@arm.com %(class_name)s::%(class_name)s(MachInst machInst) : %(base_class)s("%(mnemonic)s", machInst, %(op_class)s) 562022SN/A { 572022SN/A %(constructor)s; 582022SN/A } 592022SN/A}}; 602022SN/A 612686Sksewell@umich.edu 622022SN/A// Basic instruction class execute method template. 632022SN/Adef template BasicExecute {{ 642022SN/A Fault %(class_name)s::execute(%(CPU_exec_context)s *xc, Trace::InstRecord *traceData) const 652022SN/A { 662239SN/A Fault fault = NoFault; 672022SN/A 682022SN/A %(fp_enable_check)s; 692022SN/A %(op_decl)s; 702022SN/A %(op_rd)s; 712239SN/A if(fault == NoFault) 722022SN/A { 735222Sksewell@umich.edu %(code)s; 745222Sksewell@umich.edu if(fault == NoFault){ 752104SN/A %(op_wb)s; 765222Sksewell@umich.edu } 772022SN/A } 782022SN/A return fault; 792022SN/A } 802022SN/A}}; 812022SN/A 822022SN/A// Basic decode template. 832022SN/Adef template BasicDecode {{ 842022SN/A return new %(class_name)s(machInst); 852022SN/A}}; 862022SN/A 872022SN/A// Basic decode template, passing mnemonic in as string arg to constructor. 882022SN/Adef template BasicDecodeWithMnemonic {{ 892022SN/A return new %(class_name)s("%(mnemonic)s", machInst); 902022SN/A}}; 912022SN/A 922935Sksewell@umich.edu// The most basic instruction format... 932083SN/Adef format BasicOp(code, *flags) {{ 943951Sgblack@eecs.umich.edu iop = InstObjParams(name, Name, 'MipsStaticInst', code, flags) 952022SN/A header_output = BasicDeclare.subst(iop) 962022SN/A decoder_output = BasicConstructor.subst(iop) 972022SN/A decode_block = BasicDecode.subst(iop) 982022SN/A exec_output = BasicExecute.subst(iop) 992022SN/A}}; 100