unimp.hh revision 12291:2c0d8c31fc3d
14120Sgblack@eecs.umich.edu/*
24120Sgblack@eecs.umich.edu * Copyright (c) 2003-2005 The Regents of The University of Michigan
34120Sgblack@eecs.umich.edu * All rights reserved.
44120Sgblack@eecs.umich.edu *
57087Snate@binkert.org * Redistribution and use in source and binary forms, with or without
67087Snate@binkert.org * modification, are permitted provided that the following conditions are
77087Snate@binkert.org * met: redistributions of source code must retain the above copyright
87087Snate@binkert.org * notice, this list of conditions and the following disclaimer;
97087Snate@binkert.org * redistributions in binary form must reproduce the above copyright
107087Snate@binkert.org * notice, this list of conditions and the following disclaimer in the
117087Snate@binkert.org * documentation and/or other materials provided with the distribution;
127087Snate@binkert.org * neither the name of the copyright holders nor the names of its
134120Sgblack@eecs.umich.edu * contributors may be used to endorse or promote products derived from
147087Snate@binkert.org * this software without specific prior written permission.
157087Snate@binkert.org *
167087Snate@binkert.org * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
177087Snate@binkert.org * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
187087Snate@binkert.org * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
197087Snate@binkert.org * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
207087Snate@binkert.org * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
217087Snate@binkert.org * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
224120Sgblack@eecs.umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
237087Snate@binkert.org * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
244120Sgblack@eecs.umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
254120Sgblack@eecs.umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
264120Sgblack@eecs.umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
274120Sgblack@eecs.umich.edu *
284120Sgblack@eecs.umich.edu * Authors: Steve Reinhardt
294120Sgblack@eecs.umich.edu */
304120Sgblack@eecs.umich.edu
314120Sgblack@eecs.umich.edu#ifndef __ARCH_SPARC_INSTS_UNIMP_HH__
324120Sgblack@eecs.umich.edu#define __ARCH_SPARC_INSTS_UNIMP_HH__
334120Sgblack@eecs.umich.edu
344120Sgblack@eecs.umich.edu#include "arch/sparc/insts/static_inst.hh"
354120Sgblack@eecs.umich.edu#include "base/cprintf.hh"
364120Sgblack@eecs.umich.edu
374120Sgblack@eecs.umich.edunamespace SparcISA
384120Sgblack@eecs.umich.edu{
394120Sgblack@eecs.umich.edu
404120Sgblack@eecs.umich.edu////////////////////////////////////////////////////////////////////
414120Sgblack@eecs.umich.edu//
424120Sgblack@eecs.umich.edu// Unimplemented instructions
434141Sgblack@eecs.umich.edu//
444136Sgblack@eecs.umich.edu
456214Snate@binkert.org/**
464141Sgblack@eecs.umich.edu * Static instruction class for unimplemented instructions that
474121Sgblack@eecs.umich.edu * cause simulator termination.  Note that these are recognized
484120Sgblack@eecs.umich.edu * (legal) instructions that the simulator does not support; the
494120Sgblack@eecs.umich.edu * 'Unknown' class is used for unrecognized/illegal instructions.
504120Sgblack@eecs.umich.edu * This is a leaf class.
514121Sgblack@eecs.umich.edu */
524121Sgblack@eecs.umich.educlass FailUnimplemented : public SparcStaticInst
534121Sgblack@eecs.umich.edu{
544121Sgblack@eecs.umich.edu  public:
554121Sgblack@eecs.umich.edu    /// Constructor
564121Sgblack@eecs.umich.edu    FailUnimplemented(const char *_mnemonic, ExtMachInst _machInst) :
574121Sgblack@eecs.umich.edu            SparcStaticInst(_mnemonic, _machInst, No_OpClass)
584121Sgblack@eecs.umich.edu    {
594121Sgblack@eecs.umich.edu        // don't call execute() (which panics) if we're on a
604121Sgblack@eecs.umich.edu        // speculative path
614121Sgblack@eecs.umich.edu        flags[IsNonSpeculative] = true;
624121Sgblack@eecs.umich.edu    }
634141Sgblack@eecs.umich.edu
644141Sgblack@eecs.umich.edu    Fault
654141Sgblack@eecs.umich.edu    execute(ExecContext *xc, Trace::InstRecord *traceData) const override
665127Sgblack@eecs.umich.edu    {
674141Sgblack@eecs.umich.edu        panic("attempt to execute unimplemented instruction '%s' "
684121Sgblack@eecs.umich.edu              "(inst 0x%08x)", mnemonic, machInst);
694121Sgblack@eecs.umich.edu    }
704141Sgblack@eecs.umich.edu
716974Stjones1@inf.ed.ac.uk    std::string
726974Stjones1@inf.ed.ac.uk    generateDisassembly(Addr pc, const SymbolTable *symtab) const override
737623Sgblack@eecs.umich.edu    {
749329Sdam.sunwoo@arm.com        return csprintf("%-10s (unimplemented)", mnemonic);
759329Sdam.sunwoo@arm.com    }
769329Sdam.sunwoo@arm.com};
779057SAli.Saidi@ARM.com
789057SAli.Saidi@ARM.com/**
799057SAli.Saidi@ARM.com * Base class for unimplemented instructions that cause a warning
809057SAli.Saidi@ARM.com * to be printed (but do not terminate simulation).  This
819057SAli.Saidi@ARM.com * implementation is a little screwy in that it will print a
829057SAli.Saidi@ARM.com * warning for each instance of a particular unimplemented machine
839057SAli.Saidi@ARM.com * instruction, not just for each unimplemented opcode.  Should
849057SAli.Saidi@ARM.com * probably make the 'warned' flag a static member of the derived
859057SAli.Saidi@ARM.com * class.
869057SAli.Saidi@ARM.com */
879057SAli.Saidi@ARM.comclass WarnUnimplemented : public SparcStaticInst
888902Sandreas.hansson@arm.com{
894120Sgblack@eecs.umich.edu  private:
904120Sgblack@eecs.umich.edu    /// Have we warned on this instruction yet?
91    mutable bool warned;
92
93  public:
94    /// Constructor
95    WarnUnimplemented(const char *_mnemonic, ExtMachInst _machInst) :
96            SparcStaticInst(_mnemonic, _machInst, No_OpClass), warned(false)
97    {
98        // don't call execute() (which panics) if we're on a
99        // speculative path
100        flags[IsNonSpeculative] = true;
101    }
102
103    Fault
104    execute(ExecContext *xc, Trace::InstRecord *traceData) const override
105    {
106        if (!warned) {
107            warn("instruction '%s' unimplemented\n", mnemonic);
108            warned = true;
109        }
110        return NoFault;
111    }
112
113    std::string
114    generateDisassembly(Addr pc, const SymbolTable *symtab) const override
115    {
116        return csprintf("%-10s (unimplemented)", mnemonic);
117    }
118};
119
120}
121
122#endif // __ARCH_SPARC_INSTS_UNIMP_HH__
123