unimp.isa revision 12616:4b463b4dc098
1803SN/A// -*- mode:c++ -*-
21363SN/A
3803SN/A// Copyright (c) 2007-2008 The Florida State University
4803SN/A// Copyright (c) 2009 The University of Edinburgh
5803SN/A// All rights reserved.
6803SN/A//
7803SN/A// Redistribution and use in source and binary forms, with or without
8803SN/A// modification, are permitted provided that the following conditions are
9803SN/A// met: redistributions of source code must retain the above copyright
10803SN/A// notice, this list of conditions and the following disclaimer;
11803SN/A// redistributions in binary form must reproduce the above copyright
12803SN/A// notice, this list of conditions and the following disclaimer in the
13803SN/A// documentation and/or other materials provided with the distribution;
14803SN/A// neither the name of the copyright holders nor the names of its
15803SN/A// contributors may be used to endorse or promote products derived from
16803SN/A// this software without specific prior written permission.
17803SN/A//
18803SN/A// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19803SN/A// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20803SN/A// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21803SN/A// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22803SN/A// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23803SN/A// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24803SN/A// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25803SN/A// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26803SN/A// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
272665SN/A// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
282665SN/A// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
292665SN/A//
302665SN/A// Authors: Stephen Hines
31803SN/A//          Timothy M. Jones
32768SN/A
331730SN/A////////////////////////////////////////////////////////////////////
34773SN/A//
35768SN/A// Unimplemented instructions
36768SN/A//
3711793Sbrandon.potter@amd.com
3811793Sbrandon.potter@amd.comoutput header {{
39773SN/A    /**
40773SN/A     * Static instruction class for unimplemented instructions that
41768SN/A     * cause simulator termination.  Note that these are recognized
42768SN/A     * (legal) instructions that the simulator does not support; the
43768SN/A     * 'Unknown' class is used for unrecognized/illegal instructions.
44768SN/A     * This is a leaf class.
454762Snate@binkert.org     */
46768SN/A    class FailUnimplemented : public PowerStaticInst
476658Snate@binkert.org    {
488232Snate@binkert.org      public:
498229Snate@binkert.org        /// Constructor
503540Sgblack@eecs.umich.edu        FailUnimplemented(const char *_mnemonic, MachInst _machInst)
513540Sgblack@eecs.umich.edu            : PowerStaticInst(_mnemonic, _machInst, No_OpClass)
528229Snate@binkert.org        {
533348SN/A            // don't call execute() (which panics) if we're on a
543348SN/A            // speculative path
552542SN/A            flags[IsNonSpeculative] = true;
562542SN/A        }
57768SN/A
588737Skoansin.tan@gmail.com        Fault execute(ExecContext *, Trace::InstRecord *) const override;
598737Skoansin.tan@gmail.com
608737Skoansin.tan@gmail.com        std::string generateDisassembly(
618737Skoansin.tan@gmail.com                Addr pc, const SymbolTable *symtab) const override;
628737Skoansin.tan@gmail.com    };
632107SN/A
642107SN/A    /**
65773SN/A     * Base class for unimplemented instructions that cause a warning
665606Snate@binkert.org     * to be printed (but do not terminate simulation).  This
675606Snate@binkert.org     * implementation is a little screwy in that it will print a
685606Snate@binkert.org     * warning for each instance of a particular unimplemented machine
691817SN/A     * instruction, not just for each unimplemented opcode.  Should
70772SN/A     * probably make the 'warned' flag a static member of the derived
71772SN/A     * class.
724762Snate@binkert.org     */
739808Sstever@gmail.com    class WarnUnimplemented : public PowerStaticInst
745606Snate@binkert.org    {
75768SN/A      private:
76803SN/A        /// Have we warned on this instruction yet?
77803SN/A        mutable bool warned;
78803SN/A
79771SN/A      public:
80777SN/A        /// Constructor
81777SN/A        WarnUnimplemented(const char *_mnemonic, MachInst _machInst)
82773SN/A            : PowerStaticInst(_mnemonic, _machInst, No_OpClass), warned(false)
83773SN/A        {
841634SN/A            // don't call execute() (which panics) if we're on a
851634SN/A            // speculative path
861634SN/A            flags[IsNonSpeculative] = true;
877064Snate@binkert.org        }
881634SN/A
891634SN/A        Fault execute(ExecContext *, Trace::InstRecord *) const override;
902542SN/A
913349SN/A        std::string generateDisassembly(
92768SN/A                Addr pc, const SymbolTable *symtab) const override;
932641SN/A    };
94768SN/A}};
952641SN/A
96865SN/Aoutput decoder {{
972641SN/A    std::string
982641SN/A    FailUnimplemented::generateDisassembly(Addr pc,
99771SN/A                                           const SymbolTable *symtab) const
1002641SN/A    {
101803SN/A        return csprintf("%-10s (unimplemented)", mnemonic);
1021817SN/A    }
1031817SN/A
10413232Sgabeblack@google.com    std::string
1052539SN/A    WarnUnimplemented::generateDisassembly(Addr pc,
1061817SN/A                                           const SymbolTable *symtab) const
10713232Sgabeblack@google.com    {
1082539SN/A        return csprintf("%-10s (unimplemented)", mnemonic);
109865SN/A    }
110865SN/A}};
111865SN/A
112865SN/Aoutput exec {{
11313232Sgabeblack@google.com    Fault
1142539SN/A    FailUnimplemented::execute(ExecContext *xc,
115865SN/A                               Trace::InstRecord *traceData) const
116865SN/A    {
11713232Sgabeblack@google.com        panic("attempt to execute unimplemented instruction '%s' "
1182539SN/A              "(inst 0x%08x, opcode 0x%x, binary:%s)", mnemonic, machInst, OPCODE,
1191817SN/A              inst2string(machInst));
12013232Sgabeblack@google.com        return std::make_shared<UnimplementedOpcodeFault>();
1212542SN/A    }
1221817SN/A
12313232Sgabeblack@google.com    Fault
1242542SN/A    WarnUnimplemented::execute(ExecContext *xc,
1251817SN/A                               Trace::InstRecord *traceData) const
12613232Sgabeblack@google.com    {
1272539SN/A        if (!warned) {
128803SN/A            warn("\tinstruction '%s' unimplemented\n", mnemonic);
12913232Sgabeblack@google.com            warned = true;
1302539SN/A        }
1311817SN/A
1325635Sgblack@eecs.umich.edu        return NoFault;
13313232Sgabeblack@google.com    }
1341817SN/A}};
13513232Sgabeblack@google.com
1362539SN/A
137803SN/Adef format FailUnimpl() {{
1382641SN/A    iop = InstObjParams(name, 'FailUnimplemented')
139803SN/A    decode_block = BasicDecodeWithMnemonic.subst(iop)
1402641SN/A}};
1412539SN/A
14213232Sgabeblack@google.comdef format WarnUnimpl() {{
1432539SN/A    iop = InstObjParams(name, 'WarnUnimplemented')
1442539SN/A    decode_block = BasicDecodeWithMnemonic.subst(iop)
1452641SN/A}};
1462539SN/A
1472641SN/A