unimp.isa revision 12236:126ac9da6050
16145Snate@binkert.org// -*- mode:c++ -*- 26145Snate@binkert.org 36145Snate@binkert.org// Copyright (c) 2003-2005 The Regents of The University of Michigan 46145Snate@binkert.org// All rights reserved. 56145Snate@binkert.org// 66145Snate@binkert.org// Redistribution and use in source and binary forms, with or without 76145Snate@binkert.org// modification, are permitted provided that the following conditions are 86145Snate@binkert.org// met: redistributions of source code must retain the above copyright 96145Snate@binkert.org// notice, this list of conditions and the following disclaimer; 106145Snate@binkert.org// redistributions in binary form must reproduce the above copyright 116145Snate@binkert.org// notice, this list of conditions and the following disclaimer in the 126145Snate@binkert.org// documentation and/or other materials provided with the distribution; 136145Snate@binkert.org// neither the name of the copyright holders nor the names of its 146145Snate@binkert.org// contributors may be used to endorse or promote products derived from 156145Snate@binkert.org// this software without specific prior written permission. 166145Snate@binkert.org// 176145Snate@binkert.org// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 186145Snate@binkert.org// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 196145Snate@binkert.org// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 206145Snate@binkert.org// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 216145Snate@binkert.org// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 226145Snate@binkert.org// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 236145Snate@binkert.org// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 246145Snate@binkert.org// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 256145Snate@binkert.org// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 266145Snate@binkert.org// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 276145Snate@binkert.org// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 286145Snate@binkert.org// 296145Snate@binkert.org// Authors: Steve Reinhardt 306145Snate@binkert.org 316145Snate@binkert.org//////////////////////////////////////////////////////////////////// 326145Snate@binkert.org// 336145Snate@binkert.org// Unimplemented instructions 347039Snate@binkert.org// 357039Snate@binkert.org 366145Snate@binkert.orgoutput header {{ 377055Snate@binkert.org /** 387454Snate@binkert.org * Static instruction class for unimplemented instructions that 397055Snate@binkert.org * cause simulator termination. Note that these are recognized 407055Snate@binkert.org * (legal) instructions that the simulator does not support; the 417055Snate@binkert.org * 'Unknown' class is used for unrecognized/illegal instructions. 426145Snate@binkert.org * This is a leaf class. 437039Snate@binkert.org */ 447039Snate@binkert.org class FailUnimplemented : public AlphaStaticInst 457039Snate@binkert.org { 467039Snate@binkert.org public: 477039Snate@binkert.org /// Constructor 487039Snate@binkert.org FailUnimplemented(const char *_mnemonic, ExtMachInst _machInst) 497039Snate@binkert.org : AlphaStaticInst(_mnemonic, _machInst, No_OpClass) 506145Snate@binkert.org { 517039Snate@binkert.org // don't call execute() (which panics) if we're on a 526145Snate@binkert.org // speculative path 537039Snate@binkert.org flags[IsNonSpeculative] = true; 548054Sksewell@umich.edu } 556145Snate@binkert.org 567039Snate@binkert.org Fault execute(ExecContext *, Trace::InstRecord *) const; 577039Snate@binkert.org 587039Snate@binkert.org std::string 597039Snate@binkert.org generateDisassembly(Addr pc, const SymbolTable *symtab) const; 607039Snate@binkert.org }; 617039Snate@binkert.org 627039Snate@binkert.org /** 637039Snate@binkert.org * Base class for unimplemented instructions that cause a warning 647039Snate@binkert.org * to be printed (but do not terminate simulation). This 657039Snate@binkert.org * implementation is a little screwy in that it will print a 6610004Snilay@cs.wisc.edu * warning for each instance of a particular unimplemented machine 676145Snate@binkert.org * instruction, not just for each unimplemented opcode. Should 687039Snate@binkert.org * probably make the 'warned' flag a static member of the derived 697039Snate@binkert.org * class. 706145Snate@binkert.org */ 717039Snate@binkert.org class WarnUnimplemented : public AlphaStaticInst 727039Snate@binkert.org { 736145Snate@binkert.org private: 747039Snate@binkert.org /// Have we warned on this instruction yet? 757039Snate@binkert.org mutable bool warned; 766145Snate@binkert.org 777039Snate@binkert.org public: 787039Snate@binkert.org /// Constructor 796145Snate@binkert.org WarnUnimplemented(const char *_mnemonic, ExtMachInst _machInst) 807039Snate@binkert.org : AlphaStaticInst(_mnemonic, _machInst, No_OpClass), warned(false) 817039Snate@binkert.org { 827039Snate@binkert.org // don't call execute() (which panics) if we're on a 837039Snate@binkert.org // speculative path 847039Snate@binkert.org flags[IsNonSpeculative] = true; 856145Snate@binkert.org } 867039Snate@binkert.org 877454Snate@binkert.org Fault execute(ExecContext *, Trace::InstRecord *) const; 886145Snate@binkert.org 897039Snate@binkert.org std::string 907039Snate@binkert.org generateDisassembly(Addr pc, const SymbolTable *symtab) const; 916145Snate@binkert.org }; 927454Snate@binkert.org}}; 937039Snate@binkert.org 946145Snate@binkert.orgoutput decoder {{ 957039Snate@binkert.org std::string 967039Snate@binkert.org FailUnimplemented::generateDisassembly(Addr pc, 976145Snate@binkert.org const SymbolTable *symtab) const 987055Snate@binkert.org { 996145Snate@binkert.org return csprintf("%-10s (unimplemented)", mnemonic); 1007039Snate@binkert.org } 1017039Snate@binkert.org 1027039Snate@binkert.org std::string 1037039Snate@binkert.org WarnUnimplemented::generateDisassembly(Addr pc, 1047039Snate@binkert.org const SymbolTable *symtab) const 1057039Snate@binkert.org { 1067039Snate@binkert.org#ifdef SS_COMPATIBLE_DISASSEMBLY 1077039Snate@binkert.org return csprintf("%-10s", mnemonic); 1087039Snate@binkert.org#else 1097039Snate@binkert.org return csprintf("%-10s (unimplemented)", mnemonic); 1106145Snate@binkert.org#endif 11110086Snilay@cs.wisc.edu } 1126145Snate@binkert.org}}; 1137454Snate@binkert.org 1146145Snate@binkert.orgoutput exec {{ 1156145Snate@binkert.org Fault 1167055Snate@binkert.org FailUnimplemented::execute(ExecContext *xc, 1177055Snate@binkert.org Trace::InstRecord *traceData) const 1186145Snate@binkert.org { 1197039Snate@binkert.org panic("attempt to execute unimplemented instruction '%s' " 1207055Snate@binkert.org "(inst 0x%08x, opcode 0x%x)", mnemonic, machInst, OPCODE); 1217039Snate@binkert.org return std::make_shared<UnimplementedOpcodeFault>(); 1226145Snate@binkert.org } 1236145Snate@binkert.org 1247039Snate@binkert.org Fault 125 WarnUnimplemented::execute(ExecContext *xc, 126 Trace::InstRecord *traceData) const 127 { 128 if (!warned) { 129 warn("instruction '%s' unimplemented\n", mnemonic); 130 warned = true; 131 } 132 133 return NoFault; 134 } 135}}; 136 137 138def format FailUnimpl() {{ 139 iop = InstObjParams(name, 'FailUnimplemented') 140 decode_block = BasicDecodeWithMnemonic.subst(iop) 141}}; 142 143def format WarnUnimpl() {{ 144 iop = InstObjParams(name, 'WarnUnimplemented') 145 decode_block = BasicDecodeWithMnemonic.subst(iop) 146}}; 147 148output header {{ 149 /** 150 * Static instruction class for unknown (illegal) instructions. 151 * These cause simulator termination if they are executed in a 152 * non-speculative mode. This is a leaf class. 153 */ 154 class Unknown : public AlphaStaticInst 155 { 156 public: 157 /// Constructor 158 Unknown(ExtMachInst _machInst) 159 : AlphaStaticInst("unknown", _machInst, No_OpClass) 160 { 161 // don't call execute() (which panics) if we're on a 162 // speculative path 163 flags[IsNonSpeculative] = true; 164 } 165 166 Fault execute(ExecContext *, Trace::InstRecord *) const; 167 168 std::string 169 generateDisassembly(Addr pc, const SymbolTable *symtab) const; 170 }; 171}}; 172 173