14276Sgblack@eecs.umich.edu// -*- mode:c++ -*- 24276Sgblack@eecs.umich.edu 34276Sgblack@eecs.umich.edu// Copyright (c) 2007 The Hewlett-Packard Development Company 44276Sgblack@eecs.umich.edu// All rights reserved. 54276Sgblack@eecs.umich.edu// 67087Snate@binkert.org// The license below extends only to copyright in the software and shall 77087Snate@binkert.org// not be construed as granting a license to any other intellectual 87087Snate@binkert.org// property including but not limited to intellectual property relating 97087Snate@binkert.org// to a hardware implementation of the functionality of the software 107087Snate@binkert.org// licensed hereunder. You may use the software subject to the license 117087Snate@binkert.org// terms below provided that you ensure that this notice is replicated 127087Snate@binkert.org// unmodified and in its entirety in all distributions of the software, 137087Snate@binkert.org// modified or unmodified, in source code or in binary form. 144276Sgblack@eecs.umich.edu// 157087Snate@binkert.org// Redistribution and use in source and binary forms, with or without 167087Snate@binkert.org// modification, are permitted provided that the following conditions are 177087Snate@binkert.org// met: redistributions of source code must retain the above copyright 187087Snate@binkert.org// notice, this list of conditions and the following disclaimer; 197087Snate@binkert.org// redistributions in binary form must reproduce the above copyright 207087Snate@binkert.org// notice, this list of conditions and the following disclaimer in the 217087Snate@binkert.org// documentation and/or other materials provided with the distribution; 227087Snate@binkert.org// neither the name of the copyright holders nor the names of its 234276Sgblack@eecs.umich.edu// contributors may be used to endorse or promote products derived from 247087Snate@binkert.org// this software without specific prior written permission. 254276Sgblack@eecs.umich.edu// 264276Sgblack@eecs.umich.edu// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 274276Sgblack@eecs.umich.edu// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 284276Sgblack@eecs.umich.edu// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 294276Sgblack@eecs.umich.edu// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 304276Sgblack@eecs.umich.edu// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 314276Sgblack@eecs.umich.edu// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 324276Sgblack@eecs.umich.edu// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 334276Sgblack@eecs.umich.edu// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 344276Sgblack@eecs.umich.edu// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 354276Sgblack@eecs.umich.edu// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 364276Sgblack@eecs.umich.edu// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 374276Sgblack@eecs.umich.edu// 384276Sgblack@eecs.umich.edu// Authors: Gabe Black 394276Sgblack@eecs.umich.edu 404276Sgblack@eecs.umich.edu//////////////////////////////////////////////////////////////////// 414276Sgblack@eecs.umich.edu// 424276Sgblack@eecs.umich.edu// Unimplemented instructions 434276Sgblack@eecs.umich.edu// 444276Sgblack@eecs.umich.edu 454276Sgblack@eecs.umich.eduoutput header {{ 464276Sgblack@eecs.umich.edu /** 474276Sgblack@eecs.umich.edu * Static instruction class for unimplemented instructions that 484276Sgblack@eecs.umich.edu * cause simulator termination. Note that these are recognized 494276Sgblack@eecs.umich.edu * (legal) instructions that the simulator does not support; the 504276Sgblack@eecs.umich.edu * 'Unknown' class is used for unrecognized/illegal instructions. 514276Sgblack@eecs.umich.edu * This is a leaf class. 524276Sgblack@eecs.umich.edu */ 534679Sgblack@eecs.umich.edu class FailUnimplemented : public X86ISA::X86StaticInst 544276Sgblack@eecs.umich.edu { 554276Sgblack@eecs.umich.edu public: 564276Sgblack@eecs.umich.edu /// Constructor 574276Sgblack@eecs.umich.edu FailUnimplemented(const char *_mnemonic, ExtMachInst _machInst) 584679Sgblack@eecs.umich.edu : X86ISA::X86StaticInst(_mnemonic, _machInst, No_OpClass) 594276Sgblack@eecs.umich.edu { 604276Sgblack@eecs.umich.edu // don't call execute() (which panics) if we're on a 614276Sgblack@eecs.umich.edu // speculative path 624276Sgblack@eecs.umich.edu flags[IsNonSpeculative] = true; 634276Sgblack@eecs.umich.edu } 644276Sgblack@eecs.umich.edu 6512236Sgabeblack@google.com Fault execute(ExecContext *, Trace::InstRecord *) const; 664276Sgblack@eecs.umich.edu 674276Sgblack@eecs.umich.edu std::string 684276Sgblack@eecs.umich.edu generateDisassembly(Addr pc, const SymbolTable *symtab) const; 694276Sgblack@eecs.umich.edu }; 704276Sgblack@eecs.umich.edu 714276Sgblack@eecs.umich.edu /** 724276Sgblack@eecs.umich.edu * Base class for unimplemented instructions that cause a warning 734276Sgblack@eecs.umich.edu * to be printed (but do not terminate simulation). This 744276Sgblack@eecs.umich.edu * implementation is a little screwy in that it will print a 754276Sgblack@eecs.umich.edu * warning for each instance of a particular unimplemented machine 764276Sgblack@eecs.umich.edu * instruction, not just for each unimplemented opcode. Should 774276Sgblack@eecs.umich.edu * probably make the 'warned' flag a static member of the derived 784276Sgblack@eecs.umich.edu * class. 794276Sgblack@eecs.umich.edu */ 804679Sgblack@eecs.umich.edu class WarnUnimplemented : public X86ISA::X86StaticInst 814276Sgblack@eecs.umich.edu { 824276Sgblack@eecs.umich.edu private: 834276Sgblack@eecs.umich.edu /// Have we warned on this instruction yet? 844276Sgblack@eecs.umich.edu mutable bool warned; 854276Sgblack@eecs.umich.edu 864276Sgblack@eecs.umich.edu public: 874276Sgblack@eecs.umich.edu /// Constructor 884276Sgblack@eecs.umich.edu WarnUnimplemented(const char *_mnemonic, ExtMachInst _machInst) 894679Sgblack@eecs.umich.edu : X86ISA::X86StaticInst(_mnemonic, _machInst, No_OpClass), warned(false) 904276Sgblack@eecs.umich.edu { 914276Sgblack@eecs.umich.edu // don't call execute() (which panics) if we're on a 924276Sgblack@eecs.umich.edu // speculative path 934276Sgblack@eecs.umich.edu flags[IsNonSpeculative] = true; 944276Sgblack@eecs.umich.edu } 954276Sgblack@eecs.umich.edu 9612236Sgabeblack@google.com Fault execute(ExecContext *, Trace::InstRecord *) const; 974276Sgblack@eecs.umich.edu 984276Sgblack@eecs.umich.edu std::string 994276Sgblack@eecs.umich.edu generateDisassembly(Addr pc, const SymbolTable *symtab) const; 1004276Sgblack@eecs.umich.edu }; 1014276Sgblack@eecs.umich.edu}}; 1024276Sgblack@eecs.umich.edu 1034276Sgblack@eecs.umich.eduoutput decoder {{ 1044276Sgblack@eecs.umich.edu std::string 1054276Sgblack@eecs.umich.edu FailUnimplemented::generateDisassembly(Addr pc, 1064276Sgblack@eecs.umich.edu const SymbolTable *symtab) const 1074276Sgblack@eecs.umich.edu { 1084276Sgblack@eecs.umich.edu return csprintf("%-10s (unimplemented)", mnemonic); 1094276Sgblack@eecs.umich.edu } 1104276Sgblack@eecs.umich.edu 1114276Sgblack@eecs.umich.edu std::string 1124276Sgblack@eecs.umich.edu WarnUnimplemented::generateDisassembly(Addr pc, 1134276Sgblack@eecs.umich.edu const SymbolTable *symtab) const 1144276Sgblack@eecs.umich.edu { 1154276Sgblack@eecs.umich.edu#ifdef SS_COMPATIBLE_DISASSEMBLY 1164276Sgblack@eecs.umich.edu return csprintf("%-10s", mnemonic); 1174276Sgblack@eecs.umich.edu#else 1184276Sgblack@eecs.umich.edu return csprintf("%-10s (unimplemented)", mnemonic); 1194276Sgblack@eecs.umich.edu#endif 1204276Sgblack@eecs.umich.edu } 1214276Sgblack@eecs.umich.edu}}; 1224276Sgblack@eecs.umich.edu 1234276Sgblack@eecs.umich.eduoutput exec {{ 1244276Sgblack@eecs.umich.edu Fault 12512234Sgabeblack@google.com FailUnimplemented::execute(ExecContext *xc, 1264276Sgblack@eecs.umich.edu Trace::InstRecord *traceData) const 1274276Sgblack@eecs.umich.edu { 1284276Sgblack@eecs.umich.edu panic("attempt to execute unimplemented instruction '%s' %s", 1294276Sgblack@eecs.umich.edu mnemonic, machInst); 1304276Sgblack@eecs.umich.edu return NoFault; 1314276Sgblack@eecs.umich.edu } 1324276Sgblack@eecs.umich.edu 1334276Sgblack@eecs.umich.edu Fault 13412234Sgabeblack@google.com WarnUnimplemented::execute(ExecContext *xc, 1354276Sgblack@eecs.umich.edu Trace::InstRecord *traceData) const 1364276Sgblack@eecs.umich.edu { 1374276Sgblack@eecs.umich.edu if (!warned) { 1384276Sgblack@eecs.umich.edu warn("instruction '%s' unimplemented\n", mnemonic); 1394276Sgblack@eecs.umich.edu warned = true; 1404276Sgblack@eecs.umich.edu } 1414276Sgblack@eecs.umich.edu 1424276Sgblack@eecs.umich.edu return NoFault; 1434276Sgblack@eecs.umich.edu } 1444276Sgblack@eecs.umich.edu}}; 1454276Sgblack@eecs.umich.edu 1464276Sgblack@eecs.umich.edu 1474276Sgblack@eecs.umich.edudef format FailUnimpl() {{ 1484276Sgblack@eecs.umich.edu iop = InstObjParams(name, 'FailUnimplemented') 1494276Sgblack@eecs.umich.edu decode_block = BasicDecodeWithMnemonic.subst(iop) 1504276Sgblack@eecs.umich.edu}}; 1514276Sgblack@eecs.umich.edu 1524276Sgblack@eecs.umich.edudef format WarnUnimpl() {{ 1534276Sgblack@eecs.umich.edu iop = InstObjParams(name, 'WarnUnimplemented') 1544276Sgblack@eecs.umich.edu decode_block = BasicDecodeWithMnemonic.subst(iop) 1554276Sgblack@eecs.umich.edu}}; 1564276Sgblack@eecs.umich.edu 157