3 // Copyright (c) 2007 MIPS Technologies, Inc.
4 // All rights reserved.
6 // Redistribution and use in source and binary forms, with or without
7 // modification, are permitted provided that the following conditions are
8 // met: redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer;
10 // redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution;
13 // neither the name of the copyright holders nor the names of its
14 // contributors may be used to endorse or promote products derived from
15 // this software without specific prior written permission.
17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 // Authors: Korey Sewell
31 ////////////////////////////////////////////////////////////////////
33 // Unimplemented instructions
38 * Static instruction class for unimplemented instructions that
39 * cause simulator termination. Note that these are recognized
40 * (legal) instructions that the simulator does not support; the
41 * 'Unknown' class is used for unrecognized/illegal instructions.
42 * This is a leaf class.
44 class FailUnimplemented : public MipsStaticInst
48 FailUnimplemented(const char *_mnemonic, MachInst _machInst)
49 : MipsStaticInst(_mnemonic, _machInst, No_OpClass)
51 // don't call execute() (which panics) if we're on a
53 flags[IsNonSpeculative] = true;
56 Fault execute(ExecContext *, Trace::InstRecord *) const override;
58 std::string generateDisassembly(
59 Addr pc, const SymbolTable *symtab) const override;
61 class CP0Unimplemented : public MipsStaticInst
65 CP0Unimplemented(const char *_mnemonic, MachInst _machInst)
66 : MipsStaticInst(_mnemonic, _machInst, No_OpClass)
68 // don't call execute() (which panics) if we're on a
70 flags[IsNonSpeculative] = true;
73 Fault execute(ExecContext *, Trace::InstRecord *) const override;
75 std::string generateDisassembly(
76 Addr pc, const SymbolTable *symtab) const override;
78 class CP1Unimplemented : public MipsStaticInst
82 CP1Unimplemented(const char *_mnemonic, MachInst _machInst)
83 : MipsStaticInst(_mnemonic, _machInst, No_OpClass)
85 // don't call execute() (which panics) if we're on a
87 flags[IsNonSpeculative] = true;
90 Fault execute(ExecContext *, Trace::InstRecord *) const override;
92 std::string generateDisassembly(
93 Addr pc, const SymbolTable *symtab) const override;
95 class CP2Unimplemented : public MipsStaticInst
99 CP2Unimplemented(const char *_mnemonic, MachInst _machInst)
100 : MipsStaticInst(_mnemonic, _machInst, No_OpClass)
102 // don't call execute() (which panics) if we're on a
104 flags[IsNonSpeculative] = true;
107 Fault execute(ExecContext *, Trace::InstRecord *) const override;
109 std::string generateDisassembly(
110 Addr pc, const SymbolTable *symtab) const override;
114 * Base class for unimplemented instructions that cause a warning
115 * to be printed (but do not terminate simulation). This
116 * implementation is a little screwy in that it will print a
117 * warning for each instance of a particular unimplemented machine
118 * instruction, not just for each unimplemented opcode. Should
119 * probably make the 'warned' flag a static member of the derived
122 class WarnUnimplemented : public MipsStaticInst
125 /// Have we warned on this instruction yet?
130 WarnUnimplemented(const char *_mnemonic, MachInst _machInst)
131 : MipsStaticInst(_mnemonic, _machInst, No_OpClass), warned(false)
133 // don't call execute() (which panics) if we're on a
135 flags[IsNonSpeculative] = true;
138 Fault execute(ExecContext *, Trace::InstRecord *) const override;
140 std::string generateDisassembly(
141 Addr pc, const SymbolTable *symtab) const override;
147 FailUnimplemented::generateDisassembly(Addr pc,
148 const SymbolTable *symtab) const
150 return csprintf("%-10s (unimplemented)", mnemonic);
154 CP0Unimplemented::generateDisassembly(Addr pc,
155 const SymbolTable *symtab) const
157 return csprintf("%-10s (unimplemented)", mnemonic);
161 CP1Unimplemented::generateDisassembly(Addr pc,
162 const SymbolTable *symtab) const
164 return csprintf("%-10s (unimplemented)", mnemonic);
167 CP2Unimplemented::generateDisassembly(Addr pc,
168 const SymbolTable *symtab) const
170 return csprintf("%-10s (unimplemented)", mnemonic);
174 WarnUnimplemented::generateDisassembly(Addr pc,
175 const SymbolTable *symtab) const
177 return csprintf("%-10s (unimplemented)", mnemonic);
183 FailUnimplemented::execute(ExecContext *xc,
184 Trace::InstRecord *traceData) const
186 panic("attempt to execute unimplemented instruction '%s' "
187 "(inst 0x%08x, opcode 0x%x, binary:%s)", mnemonic, machInst, OPCODE,
188 inst2string(machInst));
193 CP0Unimplemented::execute(ExecContext *xc,
194 Trace::InstRecord *traceData) const
197 if (!isCoprocessorEnabled(xc, 0))
198 return std::make_shared<CoprocessorUnusableFault>(0);
200 return std::make_shared<ReservedInstructionFault>();
202 panic("attempt to execute unimplemented instruction '%s' "
203 "(inst %#08x, opcode %#x, binary:%s)",
204 mnemonic, machInst, OPCODE, inst2string(machInst));
210 CP1Unimplemented::execute(ExecContext *xc,
211 Trace::InstRecord *traceData) const
214 if (!isCoprocessorEnabled(xc, 1))
215 return std::make_shared<CoprocessorUnusableFault>(1);
217 return std::make_shared<ReservedInstructionFault>();
219 panic("attempt to execute unimplemented instruction '%s' "
220 "(inst %#08x, opcode %#x, binary:%s)",
221 mnemonic, machInst, OPCODE, inst2string(machInst));
227 CP2Unimplemented::execute(ExecContext *xc,
228 Trace::InstRecord *traceData) const
231 if (!isCoprocessorEnabled(xc, 2))
232 return std::make_shared<CoprocessorUnusableFault>(2);
234 return std::make_shared<ReservedInstructionFault>();
236 panic("attempt to execute unimplemented instruction '%s' "
237 "(inst %#08x, opcode %#x, binary:%s)",
238 mnemonic, machInst, OPCODE, inst2string(machInst));
244 WarnUnimplemented::execute(ExecContext *xc,
245 Trace::InstRecord *traceData) const
248 warn("\tinstruction '%s' unimplemented\n", mnemonic);
257 def format FailUnimpl() {{
258 iop = InstObjParams(name, 'FailUnimplemented')
259 decode_block = BasicDecodeWithMnemonic.subst(iop)
262 def format CP0Unimpl() {{
263 iop = InstObjParams(name, 'CP0Unimplemented')
264 decode_block = BasicDecodeWithMnemonic.subst(iop)
266 def format CP1Unimpl() {{
267 iop = InstObjParams(name, 'CP1Unimplemented')
268 decode_block = BasicDecodeWithMnemonic.subst(iop)
270 def format CP2Unimpl() {{
271 iop = InstObjParams(name, 'CP2Unimplemented')
272 decode_block = BasicDecodeWithMnemonic.subst(iop)
274 def format WarnUnimpl() {{
275 iop = InstObjParams(name, 'WarnUnimplemented')
276 decode_block = BasicDecodeWithMnemonic.subst(iop)