basic.isa revision 2706
12089SN/A// -*- mode:c++ -*- 22022SN/A 32706Sksewell@umich.edu// Copyright (c) 2003-2006 The Regents of The University of Michigan 42706Sksewell@umich.edu// All rights reserved. 52706Sksewell@umich.edu// 62706Sksewell@umich.edu// Redistribution and use in source and binary forms, with or without 72706Sksewell@umich.edu// modification, are permitted provided that the following conditions are 82706Sksewell@umich.edu// met: redistributions of source code must retain the above copyright 92706Sksewell@umich.edu// notice, this list of conditions and the following disclaimer; 102706Sksewell@umich.edu// redistributions in binary form must reproduce the above copyright 112706Sksewell@umich.edu// notice, this list of conditions and the following disclaimer in the 122706Sksewell@umich.edu// documentation and/or other materials provided with the distribution; 132706Sksewell@umich.edu// neither the name of the copyright holders nor the names of its 142706Sksewell@umich.edu// contributors may be used to endorse or promote products derived from 152706Sksewell@umich.edu// this software without specific prior written permission. 162706Sksewell@umich.edu// 172706Sksewell@umich.edu// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 182706Sksewell@umich.edu// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 192706Sksewell@umich.edu// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 202706Sksewell@umich.edu// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 212706Sksewell@umich.edu// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 222706Sksewell@umich.edu// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 232706Sksewell@umich.edu// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 242706Sksewell@umich.edu// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 252706Sksewell@umich.edu// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 262706Sksewell@umich.edu// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 272706Sksewell@umich.edu// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 282706Sksewell@umich.edu// 292706Sksewell@umich.edu// Authors: Korey Sewell 302706Sksewell@umich.edu 312022SN/A// Declarations for execute() methods. 322022SN/Adef template BasicExecDeclare {{ 332022SN/A Fault execute(%(CPU_exec_context)s *, Trace::InstRecord *) const; 342022SN/A}}; 352022SN/A 362022SN/A// Basic instruction class declaration template. 372022SN/Adef template BasicDeclare {{ 382022SN/A /** 392022SN/A * Static instruction class for "%(mnemonic)s". 402022SN/A */ 412022SN/A class %(class_name)s : public %(base_class)s 422022SN/A { 432686Sksewell@umich.edu public: 442022SN/A /// Constructor. 452022SN/A %(class_name)s(MachInst machInst); 462022SN/A %(BasicExecDeclare)s 472686Sksewell@umich.edu }; 482022SN/A}}; 492022SN/A 502022SN/A// Basic instruction class constructor template. 512022SN/Adef template BasicConstructor {{ 522022SN/A inline %(class_name)s::%(class_name)s(MachInst machInst) : %(base_class)s("%(mnemonic)s", machInst, %(op_class)s) 532022SN/A { 542022SN/A %(constructor)s; 552022SN/A } 562022SN/A}}; 572022SN/A 582686Sksewell@umich.edu 592022SN/A// Basic instruction class execute method template. 602022SN/Adef template BasicExecute {{ 612022SN/A Fault %(class_name)s::execute(%(CPU_exec_context)s *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; 682022SN/A %(code)s; 692022SN/A 702239SN/A if(fault == NoFault) 712022SN/A { 722104SN/A %(op_wb)s; 732022SN/A } 742022SN/A return fault; 752022SN/A } 762022SN/A}}; 772022SN/A 782022SN/A// Basic decode template. 792022SN/Adef template BasicDecode {{ 802022SN/A return new %(class_name)s(machInst); 812022SN/A}}; 822022SN/A 832022SN/A// Basic decode template, passing mnemonic in as string arg to constructor. 842022SN/Adef template BasicDecodeWithMnemonic {{ 852022SN/A return new %(class_name)s("%(mnemonic)s", machInst); 862022SN/A}}; 872022SN/A 882022SN/A// The most basic instruction format... used only for a few misc. insts 892083SN/Adef format BasicOp(code, *flags) {{ 902028SN/A iop = InstObjParams(name, Name, 'MipsStaticInst', CodeBlock(code), flags) 912022SN/A header_output = BasicDeclare.subst(iop) 922022SN/A decoder_output = BasicConstructor.subst(iop) 932022SN/A decode_block = BasicDecode.subst(iop) 942022SN/A exec_output = BasicExecute.subst(iop) 952022SN/A}}; 96