unimp.hh revision 12291
112291Sgabeblack@google.com/* 212291Sgabeblack@google.com * Copyright (c) 2003-2005 The Regents of The University of Michigan 312291Sgabeblack@google.com * All rights reserved. 412291Sgabeblack@google.com * 512291Sgabeblack@google.com * Redistribution and use in source and binary forms, with or without 612291Sgabeblack@google.com * modification, are permitted provided that the following conditions are 712291Sgabeblack@google.com * met: redistributions of source code must retain the above copyright 812291Sgabeblack@google.com * notice, this list of conditions and the following disclaimer; 912291Sgabeblack@google.com * redistributions in binary form must reproduce the above copyright 1012291Sgabeblack@google.com * notice, this list of conditions and the following disclaimer in the 1112291Sgabeblack@google.com * documentation and/or other materials provided with the distribution; 1212291Sgabeblack@google.com * neither the name of the copyright holders nor the names of its 1312291Sgabeblack@google.com * contributors may be used to endorse or promote products derived from 1412291Sgabeblack@google.com * this software without specific prior written permission. 1512291Sgabeblack@google.com * 1612291Sgabeblack@google.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1712291Sgabeblack@google.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1812291Sgabeblack@google.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 1912291Sgabeblack@google.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 2012291Sgabeblack@google.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2112291Sgabeblack@google.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 2212291Sgabeblack@google.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2312291Sgabeblack@google.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2412291Sgabeblack@google.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2512291Sgabeblack@google.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 2612291Sgabeblack@google.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2712291Sgabeblack@google.com * 2812291Sgabeblack@google.com * Authors: Steve Reinhardt 2912291Sgabeblack@google.com */ 3012291Sgabeblack@google.com 3112291Sgabeblack@google.com#ifndef __ARCH_SPARC_INSTS_UNIMP_HH__ 3212291Sgabeblack@google.com#define __ARCH_SPARC_INSTS_UNIMP_HH__ 3312291Sgabeblack@google.com 3412291Sgabeblack@google.com#include "arch/sparc/insts/static_inst.hh" 3512291Sgabeblack@google.com#include "base/cprintf.hh" 3612291Sgabeblack@google.com 3712291Sgabeblack@google.comnamespace SparcISA 3812291Sgabeblack@google.com{ 3912291Sgabeblack@google.com 4012291Sgabeblack@google.com//////////////////////////////////////////////////////////////////// 4112291Sgabeblack@google.com// 4212291Sgabeblack@google.com// Unimplemented instructions 4312291Sgabeblack@google.com// 4412291Sgabeblack@google.com 4512291Sgabeblack@google.com/** 4612291Sgabeblack@google.com * Static instruction class for unimplemented instructions that 4712291Sgabeblack@google.com * cause simulator termination. Note that these are recognized 4812291Sgabeblack@google.com * (legal) instructions that the simulator does not support; the 4912291Sgabeblack@google.com * 'Unknown' class is used for unrecognized/illegal instructions. 5012291Sgabeblack@google.com * This is a leaf class. 5112291Sgabeblack@google.com */ 5212291Sgabeblack@google.comclass FailUnimplemented : public SparcStaticInst 5312291Sgabeblack@google.com{ 5412291Sgabeblack@google.com public: 5512291Sgabeblack@google.com /// Constructor 5612291Sgabeblack@google.com FailUnimplemented(const char *_mnemonic, ExtMachInst _machInst) : 5712291Sgabeblack@google.com SparcStaticInst(_mnemonic, _machInst, No_OpClass) 5812291Sgabeblack@google.com { 5912291Sgabeblack@google.com // don't call execute() (which panics) if we're on a 6012291Sgabeblack@google.com // speculative path 6112291Sgabeblack@google.com flags[IsNonSpeculative] = true; 6212291Sgabeblack@google.com } 6312291Sgabeblack@google.com 6412291Sgabeblack@google.com Fault 6512291Sgabeblack@google.com execute(ExecContext *xc, Trace::InstRecord *traceData) const override 6612291Sgabeblack@google.com { 6712291Sgabeblack@google.com panic("attempt to execute unimplemented instruction '%s' " 6812291Sgabeblack@google.com "(inst 0x%08x)", mnemonic, machInst); 6912291Sgabeblack@google.com } 7012291Sgabeblack@google.com 7112291Sgabeblack@google.com std::string 7212291Sgabeblack@google.com generateDisassembly(Addr pc, const SymbolTable *symtab) const override 7312291Sgabeblack@google.com { 7412291Sgabeblack@google.com return csprintf("%-10s (unimplemented)", mnemonic); 7512291Sgabeblack@google.com } 7612291Sgabeblack@google.com}; 7712291Sgabeblack@google.com 7812291Sgabeblack@google.com/** 7912291Sgabeblack@google.com * Base class for unimplemented instructions that cause a warning 8012291Sgabeblack@google.com * to be printed (but do not terminate simulation). This 8112291Sgabeblack@google.com * implementation is a little screwy in that it will print a 8212291Sgabeblack@google.com * warning for each instance of a particular unimplemented machine 8312291Sgabeblack@google.com * instruction, not just for each unimplemented opcode. Should 8412291Sgabeblack@google.com * probably make the 'warned' flag a static member of the derived 8512291Sgabeblack@google.com * class. 8612291Sgabeblack@google.com */ 8712291Sgabeblack@google.comclass WarnUnimplemented : public SparcStaticInst 8812291Sgabeblack@google.com{ 8912291Sgabeblack@google.com private: 9012291Sgabeblack@google.com /// Have we warned on this instruction yet? 9112291Sgabeblack@google.com mutable bool warned; 9212291Sgabeblack@google.com 9312291Sgabeblack@google.com public: 9412291Sgabeblack@google.com /// Constructor 9512291Sgabeblack@google.com WarnUnimplemented(const char *_mnemonic, ExtMachInst _machInst) : 9612291Sgabeblack@google.com SparcStaticInst(_mnemonic, _machInst, No_OpClass), warned(false) 9712291Sgabeblack@google.com { 9812291Sgabeblack@google.com // don't call execute() (which panics) if we're on a 9912291Sgabeblack@google.com // speculative path 10012291Sgabeblack@google.com flags[IsNonSpeculative] = true; 10112291Sgabeblack@google.com } 10212291Sgabeblack@google.com 10312291Sgabeblack@google.com Fault 10412291Sgabeblack@google.com execute(ExecContext *xc, Trace::InstRecord *traceData) const override 10512291Sgabeblack@google.com { 10612291Sgabeblack@google.com if (!warned) { 10712291Sgabeblack@google.com warn("instruction '%s' unimplemented\n", mnemonic); 10812291Sgabeblack@google.com warned = true; 10912291Sgabeblack@google.com } 11012291Sgabeblack@google.com return NoFault; 11112291Sgabeblack@google.com } 11212291Sgabeblack@google.com 11312291Sgabeblack@google.com std::string 11412291Sgabeblack@google.com generateDisassembly(Addr pc, const SymbolTable *symtab) const override 11512291Sgabeblack@google.com { 11612291Sgabeblack@google.com return csprintf("%-10s (unimplemented)", mnemonic); 11712291Sgabeblack@google.com } 11812291Sgabeblack@google.com}; 11912291Sgabeblack@google.com 12012291Sgabeblack@google.com} 12112291Sgabeblack@google.com 12212291Sgabeblack@google.com#endif // __ARCH_SPARC_INSTS_UNIMP_HH__ 123