trap.isa revision 7741
13995Sgblack@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: Gabe Black 282632Sstever@eecs.umich.edu// Steve Reinhardt 292632Sstever@eecs.umich.edu 302022SN/A//////////////////////////////////////////////////////////////////// 312022SN/A// 322022SN/A// Trap instructions 332022SN/A// 342022SN/A 352022SN/Aoutput header {{ 362022SN/A /** 372469SN/A * Base class for trap instructions, 382469SN/A * or instructions that always fault. 392022SN/A */ 402022SN/A class Trap : public SparcStaticInst 412022SN/A { 422224SN/A protected: 432022SN/A 442224SN/A // Constructor 452469SN/A Trap(const char *mnem, ExtMachInst _machInst, OpClass __opClass) : 462561SN/A SparcStaticInst(mnem, _machInst, __opClass), trapNum(SW_TRAP) 472224SN/A { 482224SN/A } 492022SN/A 502224SN/A std::string generateDisassembly(Addr pc, 512224SN/A const SymbolTable *symtab) const; 522561SN/A 532561SN/A int trapNum; 542022SN/A }; 552022SN/A}}; 562022SN/A 572022SN/Aoutput decoder {{ 587741Sgblack@eecs.umich.edu std::string 597741Sgblack@eecs.umich.edu Trap::generateDisassembly(Addr pc, const SymbolTable *symtab) const 602022SN/A { 612561SN/A std::stringstream response; 622561SN/A 632561SN/A printMnemonic(response, mnemonic); 642561SN/A ccprintf(response, " "); 652561SN/A printReg(response, _srcRegIdx[0]); 662561SN/A ccprintf(response, ", 0x%x", trapNum); 672561SN/A ccprintf(response, ", or "); 682561SN/A printReg(response, _srcRegIdx[1]); 692561SN/A return response.str(); 702022SN/A } 712022SN/A}}; 722022SN/A 732022SN/Adef template TrapExecute {{ 747741Sgblack@eecs.umich.edu Fault 757741Sgblack@eecs.umich.edu %(class_name)s::execute(%(CPU_exec_context)s *xc, 762224SN/A Trace::InstRecord *traceData) const 772022SN/A { 782469SN/A Fault fault = NoFault; 792488SN/A %(op_decl)s; 802488SN/A %(op_rd)s; 812469SN/A %(code)s 822469SN/A return fault; 832022SN/A } 842022SN/A}}; 852022SN/A 863996Sgblack@eecs.umich.edudef template FpUnimplExecute {{ 877741Sgblack@eecs.umich.edu Fault 887741Sgblack@eecs.umich.edu %(class_name)s::execute(%(CPU_exec_context)s *xc, 893996Sgblack@eecs.umich.edu Trace::InstRecord *traceData) const 903996Sgblack@eecs.umich.edu { 913996Sgblack@eecs.umich.edu Fault fault = NoFault; 923996Sgblack@eecs.umich.edu %(op_decl)s; 933996Sgblack@eecs.umich.edu %(op_rd)s; 943996Sgblack@eecs.umich.edu %(code)s 953996Sgblack@eecs.umich.edu %(op_wb)s; 963996Sgblack@eecs.umich.edu return fault; 973996Sgblack@eecs.umich.edu } 983996Sgblack@eecs.umich.edu}}; 993996Sgblack@eecs.umich.edu 1002022SN/Adef format Trap(code, *opt_flags) {{ 1013792Sgblack@eecs.umich.edu iop = InstObjParams(name, Name, 'Trap', code, opt_flags) 1022022SN/A header_output = BasicDeclare.subst(iop) 1032022SN/A decoder_output = BasicConstructor.subst(iop) 1042469SN/A decode_block = BasicDecode.subst(iop) 1052022SN/A exec_output = TrapExecute.subst(iop) 1062022SN/A}}; 1073995Sgblack@eecs.umich.edu 1083995Sgblack@eecs.umich.eduoutput header {{ 1093995Sgblack@eecs.umich.edu class FpUnimpl : public SparcStaticInst 1103995Sgblack@eecs.umich.edu { 1113995Sgblack@eecs.umich.edu protected: 1123995Sgblack@eecs.umich.edu FpUnimpl(const char *mnem, 1133995Sgblack@eecs.umich.edu ExtMachInst _machInst, OpClass __opClass) 1143995Sgblack@eecs.umich.edu : SparcStaticInst(mnem, _machInst, __opClass) 1153995Sgblack@eecs.umich.edu { 1163995Sgblack@eecs.umich.edu } 1173995Sgblack@eecs.umich.edu 1187741Sgblack@eecs.umich.edu std::string 1197741Sgblack@eecs.umich.edu generateDisassembly(Addr pc, const SymbolTable *symtab) const 1203995Sgblack@eecs.umich.edu { 1213995Sgblack@eecs.umich.edu return mnemonic; 1223995Sgblack@eecs.umich.edu } 1233995Sgblack@eecs.umich.edu }; 1243995Sgblack@eecs.umich.edu}}; 1253995Sgblack@eecs.umich.edu 1263995Sgblack@eecs.umich.edudef format FpUnimpl(*flags) {{ 1273995Sgblack@eecs.umich.edu fpunimpl_code = ''' 1283995Sgblack@eecs.umich.edu Fsr = insertBits(Fsr, 16, 14, 3); 1293995Sgblack@eecs.umich.edu fault = new FpExceptionOther; 1303995Sgblack@eecs.umich.edu ''' 1313995Sgblack@eecs.umich.edu iop = InstObjParams(name, Name, 'FpUnimpl', fpunimpl_code, flags) 1323995Sgblack@eecs.umich.edu header_output = BasicDeclare.subst(iop) 1333995Sgblack@eecs.umich.edu decoder_output = BasicConstructor.subst(iop) 1343995Sgblack@eecs.umich.edu decode_block = BasicDecode.subst(iop) 1353996Sgblack@eecs.umich.edu exec_output = FpUnimplExecute.subst(iop) 1363995Sgblack@eecs.umich.edu}}; 137