noop.isa revision 2686
12101SN/A// -*- mode:c++ -*- 22084SN/A 32084SN/A//////////////////////////////////////////////////////////////////// 42084SN/A// 52084SN/A// Nop 62084SN/A// 72084SN/A 82084SN/Aoutput header {{ 92084SN/A /** 102084SN/A * Static instruction class for no-ops. This is a leaf class. 112084SN/A */ 122101SN/A class Nop : public MipsStaticInst 132084SN/A { 142084SN/A /// Disassembly of original instruction. 152084SN/A const std::string originalDisassembly; 162084SN/A 172084SN/A public: 182084SN/A /// Constructor 192084SN/A Nop(const std::string _originalDisassembly, MachInst _machInst) 202101SN/A : MipsStaticInst("nop", _machInst, No_OpClass), 212084SN/A originalDisassembly(_originalDisassembly) 222084SN/A { 232084SN/A flags[IsNop] = true; 242084SN/A } 252084SN/A 262084SN/A ~Nop() { } 272084SN/A 282084SN/A std::string 292084SN/A generateDisassembly(Addr pc, const SymbolTable *symtab) const; 302084SN/A 312084SN/A %(BasicExecDeclare)s 322084SN/A }; 332084SN/A}}; 342084SN/A 352084SN/Aoutput decoder {{ 362084SN/A std::string Nop::generateDisassembly(Addr pc, 372084SN/A const SymbolTable *symtab) const 382084SN/A { 392686Sksewell@umich.edu return csprintf("%-10s %s", "nop", originalDisassembly); 402084SN/A } 412084SN/A 422084SN/A /// Helper function for decoding nops. Substitute Nop object 432084SN/A /// for original inst passed in as arg (and delete latter). 442084SN/A inline 452101SN/A MipsStaticInst * 462101SN/A makeNop(MipsStaticInst *inst) 472084SN/A { 482101SN/A MipsStaticInst *nop = new Nop(inst->disassemble(0), inst->machInst); 492084SN/A delete inst; 502084SN/A return nop; 512084SN/A } 522084SN/A}}; 532084SN/A 542084SN/Aoutput exec {{ 552084SN/A Fault 562084SN/A Nop::execute(%(CPU_exec_context)s *, Trace::InstRecord *) const 572084SN/A { 582239SN/A return NoFault; 592084SN/A } 602084SN/A}}; 612084SN/A 622135SN/A// integer & FP operate instructions use RT as dest, so check for 632135SN/A// RT == 0 to detect nops 642084SN/Adef template OperateNopCheckDecode {{ 652084SN/A { 662101SN/A MipsStaticInst *i = new %(class_name)s(machInst); 672239SN/A 682239SN/A //if (RD == 0) { 692239SN/A // i = makeNop(i); 702239SN/A //} 712239SN/A 722084SN/A return i; 732084SN/A } 742084SN/A}}; 752084SN/A 762084SN/A 772084SN/A// Like BasicOperate format, but generates NOP if RC/FC == 31 782084SN/Adef format BasicOperateWithNopCheck(code, *opt_args) {{ 792101SN/A iop = InstObjParams(name, Name, 'MipsStaticInst', CodeBlock(code), 802084SN/A opt_args) 812084SN/A header_output = BasicDeclare.subst(iop) 822084SN/A decoder_output = BasicConstructor.subst(iop) 832084SN/A decode_block = OperateNopCheckDecode.subst(iop) 842084SN/A exec_output = BasicExecute.subst(iop) 852084SN/A}}; 862084SN/A 872470SN/Adef format Nop() {{ 882686Sksewell@umich.edu decode_block = 'return new Nop(\"\",machInst);\n' 892470SN/A}}; 902470SN/A 91