unimp.hh revision 12291:2c0d8c31fc3d
12391SN/A/*
22391SN/A * Copyright (c) 2003-2005 The Regents of The University of Michigan
32391SN/A * All rights reserved.
42391SN/A *
52391SN/A * Redistribution and use in source and binary forms, with or without
62391SN/A * modification, are permitted provided that the following conditions are
72391SN/A * met: redistributions of source code must retain the above copyright
82391SN/A * notice, this list of conditions and the following disclaimer;
92391SN/A * redistributions in binary form must reproduce the above copyright
102391SN/A * notice, this list of conditions and the following disclaimer in the
112391SN/A * documentation and/or other materials provided with the distribution;
122391SN/A * neither the name of the copyright holders nor the names of its
132391SN/A * contributors may be used to endorse or promote products derived from
142391SN/A * this software without specific prior written permission.
152391SN/A *
162391SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
172391SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
182391SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
192391SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
202391SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
212391SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
222391SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
232391SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
242391SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
252391SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
262391SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
272665Ssaidi@eecs.umich.edu *
282665Ssaidi@eecs.umich.edu * Authors: Steve Reinhardt
292391SN/A */
302391SN/A
312391SN/A#ifndef __ARCH_SPARC_INSTS_UNIMP_HH__
322391SN/A#define __ARCH_SPARC_INSTS_UNIMP_HH__
332391SN/A
342391SN/A#include "arch/sparc/insts/static_inst.hh"
352391SN/A#include "base/cprintf.hh"
362391SN/A
372391SN/Anamespace SparcISA
382462SN/A{
392414SN/A
402914Ssaidi@eecs.umich.edu////////////////////////////////////////////////////////////////////
412415SN/A//
422416SN/A// Unimplemented instructions
432416SN/A//
442462SN/A
452391SN/A/**
462391SN/A * Static instruction class for unimplemented instructions that
472391SN/A * cause simulator termination.  Note that these are recognized
482462SN/A * (legal) instructions that the simulator does not support; the
492391SN/A * 'Unknown' class is used for unrecognized/illegal instructions.
502914Ssaidi@eecs.umich.edu * This is a leaf class.
512413SN/A */
522413SN/Aclass FailUnimplemented : public SparcStaticInst
532413SN/A{
542413SN/A  public:
552413SN/A    /// Constructor
562640Sstever@eecs.umich.edu    FailUnimplemented(const char *_mnemonic, ExtMachInst _machInst) :
572413SN/A            SparcStaticInst(_mnemonic, _machInst, No_OpClass)
582413SN/A    {
592413SN/A        // don't call execute() (which panics) if we're on a
603349Sbinkertn@umich.edu        // speculative path
612413SN/A        flags[IsNonSpeculative] = true;
623349Sbinkertn@umich.edu    }
632413SN/A
642413SN/A    Fault
652413SN/A    execute(ExecContext *xc, Trace::InstRecord *traceData) const override
662521SN/A    {
672521SN/A        panic("attempt to execute unimplemented instruction '%s' "
682413SN/A              "(inst 0x%08x)", mnemonic, machInst);
692413SN/A    }
702413SN/A
712413SN/A    std::string
722416SN/A    generateDisassembly(Addr pc, const SymbolTable *symtab) const override
732416SN/A    {
742413SN/A        return csprintf("%-10s (unimplemented)", mnemonic);
752391SN/A    }
762391SN/A};
772391SN/A
782391SN/A/**
792391SN/A * Base class for unimplemented instructions that cause a warning
802391SN/A * to be printed (but do not terminate simulation).  This
813170Sstever@eecs.umich.edu * implementation is a little screwy in that it will print a
823170Sstever@eecs.umich.edu * warning for each instance of a particular unimplemented machine
833170Sstever@eecs.umich.edu * instruction, not just for each unimplemented opcode.  Should
843170Sstever@eecs.umich.edu * probably make the 'warned' flag a static member of the derived
853170Sstever@eecs.umich.edu * class.
863170Sstever@eecs.umich.edu */
873170Sstever@eecs.umich.educlass WarnUnimplemented : public SparcStaticInst
883170Sstever@eecs.umich.edu{
893170Sstever@eecs.umich.edu  private:
903170Sstever@eecs.umich.edu    /// Have we warned on this instruction yet?
913170Sstever@eecs.umich.edu    mutable bool warned;
923170Sstever@eecs.umich.edu
933170Sstever@eecs.umich.edu  public:
943170Sstever@eecs.umich.edu    /// Constructor
953170Sstever@eecs.umich.edu    WarnUnimplemented(const char *_mnemonic, ExtMachInst _machInst) :
963170Sstever@eecs.umich.edu            SparcStaticInst(_mnemonic, _machInst, No_OpClass), warned(false)
973170Sstever@eecs.umich.edu    {
983170Sstever@eecs.umich.edu        // don't call execute() (which panics) if we're on a
993170Sstever@eecs.umich.edu        // speculative path
1003170Sstever@eecs.umich.edu        flags[IsNonSpeculative] = true;
1013170Sstever@eecs.umich.edu    }
1023170Sstever@eecs.umich.edu
1033170Sstever@eecs.umich.edu    Fault
1043170Sstever@eecs.umich.edu    execute(ExecContext *xc, Trace::InstRecord *traceData) const override
1053170Sstever@eecs.umich.edu    {
1063170Sstever@eecs.umich.edu        if (!warned) {
1073170Sstever@eecs.umich.edu            warn("instruction '%s' unimplemented\n", mnemonic);
1083170Sstever@eecs.umich.edu            warned = true;
1093170Sstever@eecs.umich.edu        }
1103170Sstever@eecs.umich.edu        return NoFault;
1113170Sstever@eecs.umich.edu    }
1123170Sstever@eecs.umich.edu
1133170Sstever@eecs.umich.edu    std::string
1143170Sstever@eecs.umich.edu    generateDisassembly(Addr pc, const SymbolTable *symtab) const override
1153170Sstever@eecs.umich.edu    {
1163170Sstever@eecs.umich.edu        return csprintf("%-10s (unimplemented)", mnemonic);
1173170Sstever@eecs.umich.edu    }
1183170Sstever@eecs.umich.edu};
1193170Sstever@eecs.umich.edu
1203170Sstever@eecs.umich.edu}
1213170Sstever@eecs.umich.edu
1223170Sstever@eecs.umich.edu#endif // __ARCH_SPARC_INSTS_UNIMP_HH__
1233170Sstever@eecs.umich.edu