basic.isa revision 5222
12089SN/A// -*- mode:c++ -*- 22022SN/A 35222Sksewell@umich.edu// Copyright .AN) 2007 MIPS Technologies, Inc. All Rights Reserved 45222Sksewell@umich.edu 55222Sksewell@umich.edu// This software is part of the M5 simulator. 65222Sksewell@umich.edu 75222Sksewell@umich.edu// THIS IS A LEGAL AGREEMENT. BY DOWNLOADING, USING, COPYING, CREATING 85222Sksewell@umich.edu// DERIVATIVE WORKS, AND/OR DISTRIBUTING THIS SOFTWARE YOU ARE AGREEING 95222Sksewell@umich.edu// TO THESE TERMS AND CONDITIONS. 105222Sksewell@umich.edu 115222Sksewell@umich.edu// Permission is granted to use, copy, create derivative works and 125222Sksewell@umich.edu// distribute this software and such derivative works for any purpose, 135222Sksewell@umich.edu// so long as (1) the copyright notice above, this grant of permission, 145222Sksewell@umich.edu// and the disclaimer below appear in all copies and derivative works 155222Sksewell@umich.edu// made, (2) the copyright notice above is augmented as appropriate to 165222Sksewell@umich.edu// reflect the addition of any new copyrightable work in a derivative 175222Sksewell@umich.edu// work (e.g., Copyright .AN) <Publication Year> Copyright Owner), and (3) 185222Sksewell@umich.edu// the name of MIPS Technologies, Inc. ($B!H(BMIPS$B!I(B) is not used in any 195222Sksewell@umich.edu// advertising or publicity pertaining to the use or distribution of 205222Sksewell@umich.edu// this software without specific, written prior authorization. 215222Sksewell@umich.edu 225222Sksewell@umich.edu// THIS SOFTWARE IS PROVIDED $B!H(BAS IS.$B!I(B MIPS MAKES NO WARRANTIES AND 235222Sksewell@umich.edu// DISCLAIMS ALL WARRANTIES, WHETHER EXPRESS, STATUTORY, IMPLIED OR 245222Sksewell@umich.edu// OTHERWISE, INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 255222Sksewell@umich.edu// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND 265222Sksewell@umich.edu// NON-INFRINGEMENT OF THIRD PARTY RIGHTS, REGARDING THIS SOFTWARE. 275222Sksewell@umich.edu// IN NO EVENT SHALL MIPS BE LIABLE FOR ANY DAMAGES, INCLUDING DIRECT, 285222Sksewell@umich.edu// INDIRECT, INCIDENTAL, CONSEQUENTIAL, SPECIAL, OR PUNITIVE DAMAGES OF 295222Sksewell@umich.edu// ANY KIND OR NATURE, ARISING OUT OF OR IN CONNECTION WITH THIS AGREEMENT, 305222Sksewell@umich.edu// THIS SOFTWARE AND/OR THE USE OF THIS SOFTWARE, WHETHER SUCH LIABILITY 315222Sksewell@umich.edu// IS ASSERTED ON THE BASIS OF CONTRACT, TORT (INCLUDING NEGLIGENCE OR 325222Sksewell@umich.edu// STRICT LIABILITY), OR OTHERWISE, EVEN IF MIPS HAS BEEN WARNED OF THE 335222Sksewell@umich.edu// POSSIBILITY OF ANY SUCH LOSS OR DAMAGE IN ADVANCE. 345222Sksewell@umich.edu 355222Sksewell@umich.edu//Authors: Steven K. Reinhardt 365222Sksewell@umich.edu// Korey L. Sewell 372706Sksewell@umich.edu 382022SN/A// Declarations for execute() methods. 392022SN/Adef template BasicExecDeclare {{ 402022SN/A Fault execute(%(CPU_exec_context)s *, Trace::InstRecord *) const; 412022SN/A}}; 422022SN/A 432022SN/A// Basic instruction class declaration template. 442022SN/Adef template BasicDeclare {{ 452022SN/A /** 462022SN/A * Static instruction class for "%(mnemonic)s". 472022SN/A */ 482022SN/A class %(class_name)s : public %(base_class)s 492022SN/A { 502686Sksewell@umich.edu public: 512022SN/A /// Constructor. 522022SN/A %(class_name)s(MachInst machInst); 532022SN/A %(BasicExecDeclare)s 542686Sksewell@umich.edu }; 552022SN/A}}; 562022SN/A 572022SN/A// Basic instruction class constructor template. 582022SN/Adef template BasicConstructor {{ 592022SN/A inline %(class_name)s::%(class_name)s(MachInst machInst) : %(base_class)s("%(mnemonic)s", machInst, %(op_class)s) 602022SN/A { 612022SN/A %(constructor)s; 622022SN/A } 632022SN/A}}; 642022SN/A 652686Sksewell@umich.edu 662022SN/A// Basic instruction class execute method template. 672022SN/Adef template BasicExecute {{ 682022SN/A Fault %(class_name)s::execute(%(CPU_exec_context)s *xc, Trace::InstRecord *traceData) const 692022SN/A { 702239SN/A Fault fault = NoFault; 712022SN/A 722022SN/A %(fp_enable_check)s; 732022SN/A %(op_decl)s; 742022SN/A %(op_rd)s; 752239SN/A if(fault == NoFault) 762022SN/A { 775222Sksewell@umich.edu %(code)s; 785222Sksewell@umich.edu if(fault == NoFault){ 792104SN/A %(op_wb)s; 805222Sksewell@umich.edu } 812022SN/A } 822022SN/A return fault; 832022SN/A } 842022SN/A}}; 852022SN/A 862022SN/A// Basic decode template. 872022SN/Adef template BasicDecode {{ 882022SN/A return new %(class_name)s(machInst); 892022SN/A}}; 902022SN/A 912022SN/A// Basic decode template, passing mnemonic in as string arg to constructor. 922022SN/Adef template BasicDecodeWithMnemonic {{ 932022SN/A return new %(class_name)s("%(mnemonic)s", machInst); 942022SN/A}}; 952022SN/A 962935Sksewell@umich.edu// The most basic instruction format... 972083SN/Adef format BasicOp(code, *flags) {{ 983951Sgblack@eecs.umich.edu iop = InstObjParams(name, Name, 'MipsStaticInst', code, flags) 992022SN/A header_output = BasicDeclare.subst(iop) 1002022SN/A decoder_output = BasicConstructor.subst(iop) 1012022SN/A decode_block = BasicDecode.subst(iop) 1022022SN/A exec_output = BasicExecute.subst(iop) 1032022SN/A}}; 104