basic.isa revision 3931
13931Ssaidi@eecs.umich.edu// Copyright (c) 2006-2007 The Regents of The University of Michigan 22632Sstever@eecs.umich.edu// All rights reserved. 32632Sstever@eecs.umich.edu// 42632Sstever@eecs.umich.edu// Redistribution and use in source and binary forms, with or without 52632Sstever@eecs.umich.edu// modification, are permitted provided that the following conditions are 62632Sstever@eecs.umich.edu// met: redistributions of source code must retain the above copyright 72632Sstever@eecs.umich.edu// notice, this list of conditions and the following disclaimer; 82632Sstever@eecs.umich.edu// redistributions in binary form must reproduce the above copyright 92632Sstever@eecs.umich.edu// notice, this list of conditions and the following disclaimer in the 102632Sstever@eecs.umich.edu// documentation and/or other materials provided with the distribution; 112632Sstever@eecs.umich.edu// neither the name of the copyright holders nor the names of its 122632Sstever@eecs.umich.edu// contributors may be used to endorse or promote products derived from 132632Sstever@eecs.umich.edu// this software without specific prior written permission. 142632Sstever@eecs.umich.edu// 152632Sstever@eecs.umich.edu// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 162632Sstever@eecs.umich.edu// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 172632Sstever@eecs.umich.edu// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 182632Sstever@eecs.umich.edu// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 192632Sstever@eecs.umich.edu// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 202632Sstever@eecs.umich.edu// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 212632Sstever@eecs.umich.edu// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 222632Sstever@eecs.umich.edu// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 232632Sstever@eecs.umich.edu// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 242632Sstever@eecs.umich.edu// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 252632Sstever@eecs.umich.edu// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 262632Sstever@eecs.umich.edu// 272632Sstever@eecs.umich.edu// Authors: Ali Saidi 282632Sstever@eecs.umich.edu// Gabe Black 292632Sstever@eecs.umich.edu// Steve Reinhardt 302022SN/A 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 363275Sgblack@eecs.umich.edu// Definitions of execute methods that panic. 373275Sgblack@eecs.umich.edudef template BasicExecPanic {{ 383275Sgblack@eecs.umich.edu Fault execute(%(CPU_exec_context)s *, Trace::InstRecord *) const 393275Sgblack@eecs.umich.edu { 403275Sgblack@eecs.umich.edu panic("Execute method called when it shouldn't!"); 413275Sgblack@eecs.umich.edu } 423275Sgblack@eecs.umich.edu}}; 433275Sgblack@eecs.umich.edu 442022SN/A// Basic instruction class declaration template. 452022SN/Adef template BasicDeclare {{ 462022SN/A /** 472022SN/A * Static instruction class for "%(mnemonic)s". 482022SN/A */ 492022SN/A class %(class_name)s : public %(base_class)s 502022SN/A { 512224SN/A public: 522224SN/A // Constructor. 533384Sgblack@eecs.umich.edu %(class_name)s(ExtMachInst machInst); 542224SN/A %(BasicExecDeclare)s 552224SN/A }; 562022SN/A}}; 572022SN/A 582022SN/A// Basic instruction class constructor template. 592022SN/Adef template BasicConstructor {{ 603384Sgblack@eecs.umich.edu inline %(class_name)s::%(class_name)s(ExtMachInst machInst) 612224SN/A : %(base_class)s("%(mnemonic)s", machInst, %(op_class)s) 622022SN/A { 632022SN/A %(constructor)s; 642022SN/A } 652022SN/A}}; 662022SN/A 672022SN/A// Basic instruction class execute method template. 682022SN/Adef template BasicExecute {{ 692224SN/A Fault %(class_name)s::execute(%(CPU_exec_context)s *xc, 702224SN/A Trace::InstRecord *traceData) const 712022SN/A { 722224SN/A Fault fault = NoFault; 732022SN/A 743931Ssaidi@eecs.umich.edu %(fp_enable_check)s; 752224SN/A %(op_decl)s; 762224SN/A %(op_rd)s; 772224SN/A %(code)s; 782022SN/A 792224SN/A if(fault == NoFault) 802224SN/A { 812224SN/A %(op_wb)s; 822224SN/A } 832224SN/A return fault; 842022SN/A } 852022SN/A}}; 862022SN/A 872022SN/A// Basic decode template. 882022SN/Adef template BasicDecode {{ 892022SN/A return new %(class_name)s(machInst); 902022SN/A}}; 912022SN/A 923272Sgblack@eecs.umich.edu// Basic decode template, passing mnemonic in as string arg to constructor. 933272Sgblack@eecs.umich.edudef template BasicDecodeWithMnemonic {{ 943272Sgblack@eecs.umich.edu return new %(class_name)s("%(mnemonic)s", machInst); 953272Sgblack@eecs.umich.edu}}; 963272Sgblack@eecs.umich.edu 972022SN/A// The most basic instruction format... used only for a few misc. insts 982022SN/Adef format BasicOperate(code, *flags) {{ 992224SN/A iop = InstObjParams(name, Name, 'SparcStaticInst', 1002224SN/A CodeBlock(code), flags) 1012022SN/A header_output = BasicDeclare.subst(iop) 1022022SN/A decoder_output = BasicConstructor.subst(iop) 1032022SN/A decode_block = BasicDecode.subst(iop) 1042022SN/A exec_output = BasicExecute.subst(iop) 1052022SN/A}}; 106