unimp.isa revision 2706
12083SN/A// -*- mode:c++ -*-
22083SN/A
32706Sksewell@umich.edu
42083SN/A// Copyright (c) 2003-2005 The Regents of The University of Michigan
52083SN/A// All rights reserved.
62083SN/A//
72083SN/A// Redistribution and use in source and binary forms, with or without
82083SN/A// modification, are permitted provided that the following conditions are
92083SN/A// met: redistributions of source code must retain the above copyright
102083SN/A// notice, this list of conditions and the following disclaimer;
112083SN/A// redistributions in binary form must reproduce the above copyright
122083SN/A// notice, this list of conditions and the following disclaimer in the
132083SN/A// documentation and/or other materials provided with the distribution;
142083SN/A// neither the name of the copyright holders nor the names of its
152083SN/A// contributors may be used to endorse or promote products derived from
162083SN/A// this software without specific prior written permission.
172083SN/A//
182083SN/A// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
192083SN/A// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
202083SN/A// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
212083SN/A// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
222083SN/A// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
232083SN/A// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
242083SN/A// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
252083SN/A// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
262083SN/A// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
272083SN/A// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
282083SN/A// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
292706Sksewell@umich.edu//
302706Sksewell@umich.edu// Authors: Korey Sewell
312706Sksewell@umich.edu
322706Sksewell@umich.edu////////////////////////////////////////////////////////////////////
332706Sksewell@umich.edu//
342706Sksewell@umich.edu// Unimplemented instructions
352706Sksewell@umich.edu//
362649Ssaidi@eecs.umich.edu
372083SN/Aoutput header {{
382083SN/A    /**
392083SN/A     * Static instruction class for unimplemented instructions that
402083SN/A     * cause simulator termination.  Note that these are recognized
412083SN/A     * (legal) instructions that the simulator does not support; the
422083SN/A     * 'Unknown' class is used for unrecognized/illegal instructions.
432083SN/A     * This is a leaf class.
442083SN/A     */
452125SN/A    class FailUnimplemented : public MipsStaticInst
462083SN/A    {
472083SN/A      public:
482083SN/A        /// Constructor
492083SN/A        FailUnimplemented(const char *_mnemonic, MachInst _machInst)
502125SN/A            : MipsStaticInst(_mnemonic, _machInst, No_OpClass)
512083SN/A        {
522083SN/A            // don't call execute() (which panics) if we're on a
532083SN/A            // speculative path
542083SN/A            flags[IsNonSpeculative] = true;
552083SN/A        }
562083SN/A
572083SN/A        %(BasicExecDeclare)s
582083SN/A
592083SN/A        std::string
602083SN/A        generateDisassembly(Addr pc, const SymbolTable *symtab) const;
612083SN/A    };
622083SN/A
632083SN/A    /**
642083SN/A     * Base class for unimplemented instructions that cause a warning
652083SN/A     * to be printed (but do not terminate simulation).  This
662083SN/A     * implementation is a little screwy in that it will print a
672083SN/A     * warning for each instance of a particular unimplemented machine
682083SN/A     * instruction, not just for each unimplemented opcode.  Should
692083SN/A     * probably make the 'warned' flag a static member of the derived
702083SN/A     * class.
712083SN/A     */
722125SN/A    class WarnUnimplemented : public MipsStaticInst
732083SN/A    {
742083SN/A      private:
752083SN/A        /// Have we warned on this instruction yet?
762083SN/A        mutable bool warned;
772083SN/A
782083SN/A      public:
792083SN/A        /// Constructor
802083SN/A        WarnUnimplemented(const char *_mnemonic, MachInst _machInst)
812125SN/A            : MipsStaticInst(_mnemonic, _machInst, No_OpClass), warned(false)
822083SN/A        {
832083SN/A            // don't call execute() (which panics) if we're on a
842083SN/A            // speculative path
852083SN/A            flags[IsNonSpeculative] = true;
862083SN/A        }
872083SN/A
882083SN/A        %(BasicExecDeclare)s
892083SN/A
902083SN/A        std::string
912083SN/A        generateDisassembly(Addr pc, const SymbolTable *symtab) const;
922083SN/A    };
932083SN/A}};
942083SN/A
952083SN/Aoutput decoder {{
962083SN/A    std::string
972083SN/A    FailUnimplemented::generateDisassembly(Addr pc,
982083SN/A                                           const SymbolTable *symtab) const
992083SN/A    {
1002083SN/A        return csprintf("%-10s (unimplemented)", mnemonic);
1012083SN/A    }
1022083SN/A
1032083SN/A    std::string
1042083SN/A    WarnUnimplemented::generateDisassembly(Addr pc,
1052083SN/A                                           const SymbolTable *symtab) const
1062083SN/A    {
1072083SN/A        return csprintf("%-10s (unimplemented)", mnemonic);
1082083SN/A    }
1092083SN/A}};
1102083SN/A
1112083SN/Aoutput exec {{
1122083SN/A    Fault
1132083SN/A    FailUnimplemented::execute(%(CPU_exec_context)s *xc,
1142083SN/A                               Trace::InstRecord *traceData) const
1152083SN/A    {
1162083SN/A        panic("attempt to execute unimplemented instruction '%s' "
1172495SN/A              "(inst 0x%08x, opcode 0x%x, binary:%s)", mnemonic, machInst, OPCODE,
1182495SN/A              inst2string(machInst));
1192447SN/A        return new UnimplementedOpcodeFault;
1202083SN/A    }
1212083SN/A
1222083SN/A    Fault
1232083SN/A    WarnUnimplemented::execute(%(CPU_exec_context)s *xc,
1242083SN/A                               Trace::InstRecord *traceData) const
1252083SN/A    {
1262083SN/A        if (!warned) {
1272686Sksewell@umich.edu            warn("\tinstruction '%s' unimplemented\n", mnemonic);
1282083SN/A            warned = true;
1292083SN/A        }
1302083SN/A
1312239SN/A        return NoFault;
1322083SN/A    }
1332083SN/A}};
1342083SN/A
1352083SN/A
1362083SN/Adef format FailUnimpl() {{
1372083SN/A    iop = InstObjParams(name, 'FailUnimplemented')
1382083SN/A    decode_block = BasicDecodeWithMnemonic.subst(iop)
1392083SN/A}};
1402083SN/A
1412083SN/Adef format WarnUnimpl() {{
1422083SN/A    iop = InstObjParams(name, 'WarnUnimplemented')
1432083SN/A    decode_block = BasicDecodeWithMnemonic.subst(iop)
1442083SN/A}};
1452083SN/A
146