unimp.isa revision 4679:0b39fa8f5eb8
1// -*- mode:c++ -*- 2 3// Copyright (c) 2007 The Hewlett-Packard Development Company 4// All rights reserved. 5// 6// Redistribution and use of this software in source and binary forms, 7// with or without modification, are permitted provided that the 8// following conditions are met: 9// 10// The software must be used only for Non-Commercial Use which means any 11// use which is NOT directed to receiving any direct monetary 12// compensation for, or commercial advantage from such use. Illustrative 13// examples of non-commercial use are academic research, personal study, 14// teaching, education and corporate research & development. 15// Illustrative examples of commercial use are distributing products for 16// commercial advantage and providing services using the software for 17// commercial advantage. 18// 19// If you wish to use this software or functionality therein that may be 20// covered by patents for commercial use, please contact: 21// Director of Intellectual Property Licensing 22// Office of Strategy and Technology 23// Hewlett-Packard Company 24// 1501 Page Mill Road 25// Palo Alto, California 94304 26// 27// Redistributions of source code must retain the above copyright notice, 28// this list of conditions and the following disclaimer. Redistributions 29// in binary form must reproduce the above copyright notice, this list of 30// conditions and the following disclaimer in the documentation and/or 31// other materials provided with the distribution. Neither the name of 32// the COPYRIGHT HOLDER(s), HEWLETT-PACKARD COMPANY, nor the names of its 33// contributors may be used to endorse or promote products derived from 34// this software without specific prior written permission. No right of 35// sublicense is granted herewith. Derivatives of the software and 36// output created using the software may be prepared, but only for 37// Non-Commercial Uses. Derivatives of the software may be shared with 38// others provided: (i) the others agree to abide by the list of 39// conditions herein which includes the Non-Commercial Use restrictions; 40// and (ii) such Derivatives of the software include the above copyright 41// notice to acknowledge the contribution from this software where 42// applicable, this list of conditions and the disclaimer below. 43// 44// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 45// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 46// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 47// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 48// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 49// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 50// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 51// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 52// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 53// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 54// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 55// 56// Authors: Gabe Black 57 58//////////////////////////////////////////////////////////////////// 59// 60// Unimplemented instructions 61// 62 63output header {{ 64 /** 65 * Static instruction class for unimplemented instructions that 66 * cause simulator termination. Note that these are recognized 67 * (legal) instructions that the simulator does not support; the 68 * 'Unknown' class is used for unrecognized/illegal instructions. 69 * This is a leaf class. 70 */ 71 class FailUnimplemented : public X86ISA::X86StaticInst 72 { 73 public: 74 /// Constructor 75 FailUnimplemented(const char *_mnemonic, ExtMachInst _machInst) 76 : X86ISA::X86StaticInst(_mnemonic, _machInst, No_OpClass) 77 { 78 // don't call execute() (which panics) if we're on a 79 // speculative path 80 flags[IsNonSpeculative] = true; 81 } 82 83 %(BasicExecDeclare)s 84 85 std::string 86 generateDisassembly(Addr pc, const SymbolTable *symtab) const; 87 }; 88 89 /** 90 * Base class for unimplemented instructions that cause a warning 91 * to be printed (but do not terminate simulation). This 92 * implementation is a little screwy in that it will print a 93 * warning for each instance of a particular unimplemented machine 94 * instruction, not just for each unimplemented opcode. Should 95 * probably make the 'warned' flag a static member of the derived 96 * class. 97 */ 98 class WarnUnimplemented : public X86ISA::X86StaticInst 99 { 100 private: 101 /// Have we warned on this instruction yet? 102 mutable bool warned; 103 104 public: 105 /// Constructor 106 WarnUnimplemented(const char *_mnemonic, ExtMachInst _machInst) 107 : X86ISA::X86StaticInst(_mnemonic, _machInst, No_OpClass), warned(false) 108 { 109 // don't call execute() (which panics) if we're on a 110 // speculative path 111 flags[IsNonSpeculative] = true; 112 } 113 114 %(BasicExecDeclare)s 115 116 std::string 117 generateDisassembly(Addr pc, const SymbolTable *symtab) const; 118 }; 119}}; 120 121output decoder {{ 122 std::string 123 FailUnimplemented::generateDisassembly(Addr pc, 124 const SymbolTable *symtab) const 125 { 126 return csprintf("%-10s (unimplemented)", mnemonic); 127 } 128 129 std::string 130 WarnUnimplemented::generateDisassembly(Addr pc, 131 const SymbolTable *symtab) const 132 { 133#ifdef SS_COMPATIBLE_DISASSEMBLY 134 return csprintf("%-10s", mnemonic); 135#else 136 return csprintf("%-10s (unimplemented)", mnemonic); 137#endif 138 } 139}}; 140 141output exec {{ 142 Fault 143 FailUnimplemented::execute(%(CPU_exec_context)s *xc, 144 Trace::InstRecord *traceData) const 145 { 146 panic("attempt to execute unimplemented instruction '%s' %s", 147 mnemonic, machInst); 148 return NoFault; 149 } 150 151 Fault 152 WarnUnimplemented::execute(%(CPU_exec_context)s *xc, 153 Trace::InstRecord *traceData) const 154 { 155 if (!warned) { 156 warn("instruction '%s' unimplemented\n", mnemonic); 157 warned = true; 158 } 159 160 return NoFault; 161 } 162}}; 163 164 165def format FailUnimpl() {{ 166 iop = InstObjParams(name, 'FailUnimplemented') 167 decode_block = BasicDecodeWithMnemonic.subst(iop) 168}}; 169 170def format WarnUnimpl() {{ 171 iop = InstObjParams(name, 'WarnUnimplemented') 172 decode_block = BasicDecodeWithMnemonic.subst(iop) 173}}; 174 175