unimp.isa revision 5222
12083SN/A// -*- mode:c++ -*-
22083SN/A
35222Sksewell@umich.edu// Copyright N) 2007 MIPS Technologies, Inc.  All Rights Reserved
42706Sksewell@umich.edu
55222Sksewell@umich.edu//  This software is part of the M5 simulator.
65222Sksewell@umich.edu
75222Sksewell@umich.edu//  THIS IS A LEGAL AGREEMENT.  BY DOWNLOADING, USING, COPYING, CREATING
85222Sksewell@umich.edu//  DERIVATIVE WORKS, AND/OR DISTRIBUTING THIS SOFTWARE YOU ARE AGREEING
95222Sksewell@umich.edu//  TO THESE TERMS AND CONDITIONS.
105222Sksewell@umich.edu
115222Sksewell@umich.edu//  Permission is granted to use, copy, create derivative works and
125222Sksewell@umich.edu//  distribute this software and such derivative works for any purpose,
135222Sksewell@umich.edu//  so long as (1) the copyright notice above, this grant of permission,
145222Sksewell@umich.edu//  and the disclaimer below appear in all copies and derivative works
155222Sksewell@umich.edu//  made, (2) the copyright notice above is augmented as appropriate to
165222Sksewell@umich.edu//  reflect the addition of any new copyrightable work in a derivative
175222Sksewell@umich.edu//  work (e.g., Copyright N) <Publication Year> Copyright Owner), and (3)
185222Sksewell@umich.edu//  the name of MIPS Technologies, Inc. ($(B!H(BMIPS$(B!I(B) is not used in any
195222Sksewell@umich.edu//  advertising or publicity pertaining to the use or distribution of
205222Sksewell@umich.edu//  this software without specific, written prior authorization.
215222Sksewell@umich.edu
225222Sksewell@umich.edu//  THIS SOFTWARE IS PROVIDED $(B!H(BAS IS.$(B!I(B  MIPS MAKES NO WARRANTIES AND
235222Sksewell@umich.edu//  DISCLAIMS ALL WARRANTIES, WHETHER EXPRESS, STATUTORY, IMPLIED OR
245222Sksewell@umich.edu//  OTHERWISE, INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
255222Sksewell@umich.edu//  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND
265222Sksewell@umich.edu//  NON-INFRINGEMENT OF THIRD PARTY RIGHTS, REGARDING THIS SOFTWARE.
275222Sksewell@umich.edu//  IN NO EVENT SHALL MIPS BE LIABLE FOR ANY DAMAGES, INCLUDING DIRECT,
285222Sksewell@umich.edu//  INDIRECT, INCIDENTAL, CONSEQUENTIAL, SPECIAL, OR PUNITIVE DAMAGES OF
295222Sksewell@umich.edu//  ANY KIND OR NATURE, ARISING OUT OF OR IN CONNECTION WITH THIS AGREEMENT,
305222Sksewell@umich.edu//  THIS SOFTWARE AND/OR THE USE OF THIS SOFTWARE, WHETHER SUCH LIABILITY
315222Sksewell@umich.edu//  IS ASSERTED ON THE BASIS OF CONTRACT, TORT (INCLUDING NEGLIGENCE OR
325222Sksewell@umich.edu//  STRICT LIABILITY), OR OTHERWISE, EVEN IF MIPS HAS BEEN WARNED OF THE
335222Sksewell@umich.edu//  POSSIBILITY OF ANY SUCH LOSS OR DAMAGE IN ADVANCE.
345222Sksewell@umich.edu
355222Sksewell@umich.edu//Authors: Korey L. Sewell
365222Sksewell@umich.edu
372706Sksewell@umich.edu
382706Sksewell@umich.edu////////////////////////////////////////////////////////////////////
392706Sksewell@umich.edu//
402706Sksewell@umich.edu// Unimplemented instructions
412706Sksewell@umich.edu//
422649Ssaidi@eecs.umich.edu
432083SN/Aoutput header {{
442083SN/A    /**
452083SN/A     * Static instruction class for unimplemented instructions that
462083SN/A     * cause simulator termination.  Note that these are recognized
472083SN/A     * (legal) instructions that the simulator does not support; the
482083SN/A     * 'Unknown' class is used for unrecognized/illegal instructions.
492083SN/A     * This is a leaf class.
502083SN/A     */
512125SN/A    class FailUnimplemented : public MipsStaticInst
522083SN/A    {
532083SN/A      public:
542083SN/A        /// Constructor
552083SN/A        FailUnimplemented(const char *_mnemonic, MachInst _machInst)
562125SN/A            : MipsStaticInst(_mnemonic, _machInst, No_OpClass)
572083SN/A        {
582083SN/A            // don't call execute() (which panics) if we're on a
592083SN/A            // speculative path
602083SN/A            flags[IsNonSpeculative] = true;
612083SN/A        }
622083SN/A
632083SN/A        %(BasicExecDeclare)s
642083SN/A
652083SN/A        std::string
662083SN/A        generateDisassembly(Addr pc, const SymbolTable *symtab) const;
672083SN/A    };
685222Sksewell@umich.edu    class CP0Unimplemented : public MipsStaticInst
695222Sksewell@umich.edu    {
705222Sksewell@umich.edu      public:
715222Sksewell@umich.edu        /// Constructor
725222Sksewell@umich.edu        CP0Unimplemented(const char *_mnemonic, MachInst _machInst)
735222Sksewell@umich.edu            : MipsStaticInst(_mnemonic, _machInst, No_OpClass)
745222Sksewell@umich.edu        {
755222Sksewell@umich.edu            // don't call execute() (which panics) if we're on a
765222Sksewell@umich.edu            // speculative path
775222Sksewell@umich.edu            flags[IsNonSpeculative] = true;
785222Sksewell@umich.edu        }
795222Sksewell@umich.edu
805222Sksewell@umich.edu        %(BasicExecDeclare)s
815222Sksewell@umich.edu
825222Sksewell@umich.edu        std::string
835222Sksewell@umich.edu        generateDisassembly(Addr pc, const SymbolTable *symtab) const;
845222Sksewell@umich.edu    };
855222Sksewell@umich.edu    class CP1Unimplemented : public MipsStaticInst
865222Sksewell@umich.edu    {
875222Sksewell@umich.edu      public:
885222Sksewell@umich.edu        /// Constructor
895222Sksewell@umich.edu        CP1Unimplemented(const char *_mnemonic, MachInst _machInst)
905222Sksewell@umich.edu            : MipsStaticInst(_mnemonic, _machInst, No_OpClass)
915222Sksewell@umich.edu        {
925222Sksewell@umich.edu            // don't call execute() (which panics) if we're on a
935222Sksewell@umich.edu            // speculative path
945222Sksewell@umich.edu            flags[IsNonSpeculative] = true;
955222Sksewell@umich.edu        }
965222Sksewell@umich.edu
975222Sksewell@umich.edu        %(BasicExecDeclare)s
985222Sksewell@umich.edu
995222Sksewell@umich.edu        std::string
1005222Sksewell@umich.edu        generateDisassembly(Addr pc, const SymbolTable *symtab) const;
1015222Sksewell@umich.edu    };
1025222Sksewell@umich.edu    class CP2Unimplemented : public MipsStaticInst
1035222Sksewell@umich.edu    {
1045222Sksewell@umich.edu      public:
1055222Sksewell@umich.edu        /// Constructor
1065222Sksewell@umich.edu        CP2Unimplemented(const char *_mnemonic, MachInst _machInst)
1075222Sksewell@umich.edu            : MipsStaticInst(_mnemonic, _machInst, No_OpClass)
1085222Sksewell@umich.edu        {
1095222Sksewell@umich.edu            // don't call execute() (which panics) if we're on a
1105222Sksewell@umich.edu            // speculative path
1115222Sksewell@umich.edu            flags[IsNonSpeculative] = true;
1125222Sksewell@umich.edu        }
1135222Sksewell@umich.edu
1145222Sksewell@umich.edu        %(BasicExecDeclare)s
1155222Sksewell@umich.edu
1165222Sksewell@umich.edu        std::string
1175222Sksewell@umich.edu        generateDisassembly(Addr pc, const SymbolTable *symtab) const;
1185222Sksewell@umich.edu    };
1192083SN/A
1202083SN/A    /**
1212083SN/A     * Base class for unimplemented instructions that cause a warning
1222083SN/A     * to be printed (but do not terminate simulation).  This
1232083SN/A     * implementation is a little screwy in that it will print a
1242083SN/A     * warning for each instance of a particular unimplemented machine
1252083SN/A     * instruction, not just for each unimplemented opcode.  Should
1262083SN/A     * probably make the 'warned' flag a static member of the derived
1272083SN/A     * class.
1282083SN/A     */
1292125SN/A    class WarnUnimplemented : public MipsStaticInst
1302083SN/A    {
1312083SN/A      private:
1322083SN/A        /// Have we warned on this instruction yet?
1332083SN/A        mutable bool warned;
1342083SN/A
1352083SN/A      public:
1362083SN/A        /// Constructor
1372083SN/A        WarnUnimplemented(const char *_mnemonic, MachInst _machInst)
1382125SN/A            : MipsStaticInst(_mnemonic, _machInst, No_OpClass), warned(false)
1392083SN/A        {
1402083SN/A            // don't call execute() (which panics) if we're on a
1412083SN/A            // speculative path
1422083SN/A            flags[IsNonSpeculative] = true;
1432083SN/A        }
1442083SN/A
1452083SN/A        %(BasicExecDeclare)s
1462083SN/A
1472083SN/A        std::string
1482083SN/A        generateDisassembly(Addr pc, const SymbolTable *symtab) const;
1492083SN/A    };
1502083SN/A}};
1512083SN/A
1522083SN/Aoutput decoder {{
1532083SN/A    std::string
1542083SN/A    FailUnimplemented::generateDisassembly(Addr pc,
1552083SN/A                                           const SymbolTable *symtab) const
1562083SN/A    {
1572083SN/A        return csprintf("%-10s (unimplemented)", mnemonic);
1582083SN/A    }
1592083SN/A
1602083SN/A    std::string
1615222Sksewell@umich.edu    CP0Unimplemented::generateDisassembly(Addr pc,
1625222Sksewell@umich.edu                                           const SymbolTable *symtab) const
1635222Sksewell@umich.edu    {
1645222Sksewell@umich.edu        return csprintf("%-10s (unimplemented)", mnemonic);
1655222Sksewell@umich.edu    }
1665222Sksewell@umich.edu
1675222Sksewell@umich.edu    std::string
1685222Sksewell@umich.edu    CP1Unimplemented::generateDisassembly(Addr pc,
1695222Sksewell@umich.edu                                           const SymbolTable *symtab) const
1705222Sksewell@umich.edu    {
1715222Sksewell@umich.edu        return csprintf("%-10s (unimplemented)", mnemonic);
1725222Sksewell@umich.edu    }
1735222Sksewell@umich.edu    std::string
1745222Sksewell@umich.edu    CP2Unimplemented::generateDisassembly(Addr pc,
1755222Sksewell@umich.edu                                           const SymbolTable *symtab) const
1765222Sksewell@umich.edu    {
1775222Sksewell@umich.edu        return csprintf("%-10s (unimplemented)", mnemonic);
1785222Sksewell@umich.edu    }
1795222Sksewell@umich.edu
1805222Sksewell@umich.edu    std::string
1812083SN/A    WarnUnimplemented::generateDisassembly(Addr pc,
1822083SN/A                                           const SymbolTable *symtab) const
1832083SN/A    {
1842083SN/A        return csprintf("%-10s (unimplemented)", mnemonic);
1852083SN/A    }
1862083SN/A}};
1872083SN/A
1882083SN/Aoutput exec {{
1892083SN/A    Fault
1902083SN/A    FailUnimplemented::execute(%(CPU_exec_context)s *xc,
1912083SN/A                               Trace::InstRecord *traceData) const
1922083SN/A    {
1932083SN/A        panic("attempt to execute unimplemented instruction '%s' "
1942495SN/A              "(inst 0x%08x, opcode 0x%x, binary:%s)", mnemonic, machInst, OPCODE,
1952495SN/A              inst2string(machInst));
1962447SN/A        return new UnimplementedOpcodeFault;
1972083SN/A    }
1982083SN/A
1992083SN/A    Fault
2005222Sksewell@umich.edu    CP0Unimplemented::execute(%(CPU_exec_context)s *xc,
2015222Sksewell@umich.edu                               Trace::InstRecord *traceData) const
2025222Sksewell@umich.edu    {
2035222Sksewell@umich.edu#if  FULL_SYSTEM
2045222Sksewell@umich.edu      if (!isCoprocessorEnabled(xc, 0)) {
2055222Sksewell@umich.edu        return new CoprocessorUnusableFault(0);
2065222Sksewell@umich.edu      }
2075222Sksewell@umich.edu      return new ReservedInstructionFault;
2085222Sksewell@umich.edu#else
2095222Sksewell@umich.edu        panic("attempt to execute unimplemented instruction '%s' "
2105222Sksewell@umich.edu              "(inst 0x%08x, opcode 0x%x, binary:%s)", mnemonic, machInst, OPCODE,
2115222Sksewell@umich.edu              inst2string(machInst));
2125222Sksewell@umich.edu        return new UnimplementedOpcodeFault;
2135222Sksewell@umich.edu#endif
2145222Sksewell@umich.edu    }
2155222Sksewell@umich.edu
2165222Sksewell@umich.edu    Fault
2175222Sksewell@umich.edu    CP1Unimplemented::execute(%(CPU_exec_context)s *xc,
2185222Sksewell@umich.edu                               Trace::InstRecord *traceData) const
2195222Sksewell@umich.edu    {
2205222Sksewell@umich.edu#if  FULL_SYSTEM
2215222Sksewell@umich.edu      if (!isCoprocessorEnabled(xc, 1)) {
2225222Sksewell@umich.edu        return new CoprocessorUnusableFault(1);
2235222Sksewell@umich.edu      }
2245222Sksewell@umich.edu      return new ReservedInstructionFault;
2255222Sksewell@umich.edu#else
2265222Sksewell@umich.edu        panic("attempt to execute unimplemented instruction '%s' "
2275222Sksewell@umich.edu              "(inst 0x%08x, opcode 0x%x, binary:%s)", mnemonic, machInst, OPCODE,
2285222Sksewell@umich.edu              inst2string(machInst));
2295222Sksewell@umich.edu        return new UnimplementedOpcodeFault;
2305222Sksewell@umich.edu#endif
2315222Sksewell@umich.edu    }
2325222Sksewell@umich.edu    Fault
2335222Sksewell@umich.edu    CP2Unimplemented::execute(%(CPU_exec_context)s *xc,
2345222Sksewell@umich.edu                               Trace::InstRecord *traceData) const
2355222Sksewell@umich.edu    {
2365222Sksewell@umich.edu#if  FULL_SYSTEM
2375222Sksewell@umich.edu      if (!isCoprocessorEnabled(xc, 2)) {
2385222Sksewell@umich.edu        return new CoprocessorUnusableFault(2);
2395222Sksewell@umich.edu      }
2405222Sksewell@umich.edu      return new ReservedInstructionFault;
2415222Sksewell@umich.edu#else
2425222Sksewell@umich.edu        panic("attempt to execute unimplemented instruction '%s' "
2435222Sksewell@umich.edu              "(inst 0x%08x, opcode 0x%x, binary:%s)", mnemonic, machInst, OPCODE,
2445222Sksewell@umich.edu              inst2string(machInst));
2455222Sksewell@umich.edu        return new UnimplementedOpcodeFault;
2465222Sksewell@umich.edu#endif
2475222Sksewell@umich.edu    }
2485222Sksewell@umich.edu
2495222Sksewell@umich.edu    Fault
2502083SN/A    WarnUnimplemented::execute(%(CPU_exec_context)s *xc,
2512083SN/A                               Trace::InstRecord *traceData) const
2522083SN/A    {
2532083SN/A        if (!warned) {
2542686Sksewell@umich.edu            warn("\tinstruction '%s' unimplemented\n", mnemonic);
2552083SN/A            warned = true;
2562083SN/A        }
2572083SN/A
2582239SN/A        return NoFault;
2592083SN/A    }
2602083SN/A}};
2612083SN/A
2622083SN/A
2632083SN/Adef format FailUnimpl() {{
2642083SN/A    iop = InstObjParams(name, 'FailUnimplemented')
2652083SN/A    decode_block = BasicDecodeWithMnemonic.subst(iop)
2665222Sksewell@umich.edu
2672083SN/A}};
2685222Sksewell@umich.edudef format CP0Unimpl() {{
2695222Sksewell@umich.edu    iop = InstObjParams(name, 'CP0Unimplemented')
2705222Sksewell@umich.edu    decode_block = BasicDecodeWithMnemonic.subst(iop)
2715222Sksewell@umich.edu}};
2725222Sksewell@umich.edudef format CP1Unimpl() {{
2735222Sksewell@umich.edu    iop = InstObjParams(name, 'CP1Unimplemented')
2745222Sksewell@umich.edu    decode_block = BasicDecodeWithMnemonic.subst(iop)
2755222Sksewell@umich.edu}};
2765222Sksewell@umich.edudef format CP2Unimpl() {{
2775222Sksewell@umich.edu    iop = InstObjParams(name, 'CP2Unimplemented')
2785222Sksewell@umich.edu    decode_block = BasicDecodeWithMnemonic.subst(iop)
2795222Sksewell@umich.edu}};
2802083SN/Adef format WarnUnimpl() {{
2812083SN/A    iop = InstObjParams(name, 'WarnUnimplemented')
2822083SN/A    decode_block = BasicDecodeWithMnemonic.subst(iop)
2832083SN/A}};
2842083SN/A
285