1 //===-- EmulateInstructionMIPS64.h ------------------------------------*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 #ifndef EmulateInstructionMIPS64_h_ 11 #define EmulateInstructionMIPS64_h_ 12 13 namespace llvm 14 { 15 class MCDisassembler; 16 class MCSubtargetInfo; 17 class MCRegisterInfo; 18 class MCAsmInfo; 19 class MCContext; 20 class MCInstrInfo; 21 class MCInst; 22 } 23 24 #include "lldb/Core/EmulateInstruction.h" 25 #include "lldb/Core/Error.h" 26 #include "lldb/Interpreter/OptionValue.h" 27 28 class EmulateInstructionMIPS64 : public lldb_private::EmulateInstruction 29 { 30 public: 31 static void 32 Initialize (); 33 34 static void 35 Terminate (); 36 37 static lldb_private::ConstString 38 GetPluginNameStatic (); 39 40 static const char * 41 GetPluginDescriptionStatic (); 42 43 static lldb_private::EmulateInstruction * 44 CreateInstance (const lldb_private::ArchSpec &arch, 45 lldb_private::InstructionType inst_type); 46 47 static bool SupportsEmulatingInstructionsOfTypeStatic(lldb_private::InstructionType inst_type)48 SupportsEmulatingInstructionsOfTypeStatic (lldb_private::InstructionType inst_type) 49 { 50 switch (inst_type) 51 { 52 case lldb_private::eInstructionTypeAny: 53 case lldb_private::eInstructionTypePrologueEpilogue: 54 case lldb_private::eInstructionTypePCModifying: 55 return true; 56 57 case lldb_private::eInstructionTypeAll: 58 return false; 59 } 60 return false; 61 } 62 63 virtual lldb_private::ConstString 64 GetPluginName(); 65 66 virtual lldb_private::ConstString GetShortPluginName()67 GetShortPluginName() 68 { 69 return GetPluginNameStatic(); 70 } 71 72 virtual uint32_t GetPluginVersion()73 GetPluginVersion() 74 { 75 return 1; 76 } 77 78 bool 79 SetTargetTriple (const lldb_private::ArchSpec &arch); 80 81 EmulateInstructionMIPS64 (const lldb_private::ArchSpec &arch); 82 83 virtual bool SupportsEmulatingInstructionsOfType(lldb_private::InstructionType inst_type)84 SupportsEmulatingInstructionsOfType (lldb_private::InstructionType inst_type) 85 { 86 return SupportsEmulatingInstructionsOfTypeStatic (inst_type); 87 } 88 89 virtual bool 90 ReadInstruction (); 91 92 virtual bool 93 EvaluateInstruction (uint32_t evaluate_options); 94 95 virtual bool TestEmulation(lldb_private::Stream * out_stream,lldb_private::ArchSpec & arch,lldb_private::OptionValueDictionary * test_data)96 TestEmulation (lldb_private::Stream *out_stream, 97 lldb_private::ArchSpec &arch, 98 lldb_private::OptionValueDictionary *test_data) 99 { 100 return false; 101 } 102 103 virtual bool 104 GetRegisterInfo (lldb::RegisterKind reg_kind, 105 uint32_t reg_num, 106 lldb_private::RegisterInfo ®_info); 107 108 virtual bool 109 CreateFunctionEntryUnwind (lldb_private::UnwindPlan &unwind_plan); 110 111 112 protected: 113 114 typedef struct 115 { 116 const char *op_name; 117 bool (EmulateInstructionMIPS64::*callback) (llvm::MCInst& insn); 118 const char *insn_name; 119 } MipsOpcode; 120 121 static MipsOpcode* 122 GetOpcodeForInstruction (const char *op_name); 123 124 bool 125 Emulate_DADDiu (llvm::MCInst& insn); 126 127 bool 128 Emulate_SD (llvm::MCInst& insn); 129 130 bool 131 Emulate_SW (llvm::MCInst& insn); 132 133 bool 134 Emulate_LW (llvm::MCInst& insn); 135 136 bool 137 Emulate_LD (llvm::MCInst& insn); 138 139 bool 140 Emulate_BEQ (llvm::MCInst& insn); 141 142 bool 143 Emulate_BNE (llvm::MCInst& insn); 144 145 bool 146 Emulate_BEQL (llvm::MCInst& insn); 147 148 bool 149 Emulate_BNEL (llvm::MCInst& insn); 150 151 bool 152 Emulate_BGEZALL (llvm::MCInst& insn); 153 154 bool 155 Emulate_BAL (llvm::MCInst& insn); 156 157 bool 158 Emulate_BGEZAL (llvm::MCInst& insn); 159 160 bool 161 Emulate_BALC (llvm::MCInst& insn); 162 163 bool 164 Emulate_BC (llvm::MCInst& insn); 165 166 bool 167 Emulate_BGEZ (llvm::MCInst& insn); 168 169 bool 170 Emulate_BLEZALC (llvm::MCInst& insn); 171 172 bool 173 Emulate_BGEZALC (llvm::MCInst& insn); 174 175 bool 176 Emulate_BLTZALC (llvm::MCInst& insn); 177 178 bool 179 Emulate_BGTZALC (llvm::MCInst& insn); 180 181 bool 182 Emulate_BEQZALC (llvm::MCInst& insn); 183 184 bool 185 Emulate_BNEZALC (llvm::MCInst& insn); 186 187 bool 188 Emulate_BEQC (llvm::MCInst& insn); 189 190 bool 191 Emulate_BNEC (llvm::MCInst& insn); 192 193 bool 194 Emulate_BLTC (llvm::MCInst& insn); 195 196 bool 197 Emulate_BGEC (llvm::MCInst& insn); 198 199 bool 200 Emulate_BLTUC (llvm::MCInst& insn); 201 202 bool 203 Emulate_BGEUC (llvm::MCInst& insn); 204 205 bool 206 Emulate_BLTZC (llvm::MCInst& insn); 207 208 bool 209 Emulate_BLEZC (llvm::MCInst& insn); 210 211 bool 212 Emulate_BGEZC (llvm::MCInst& insn); 213 214 bool 215 Emulate_BGTZC (llvm::MCInst& insn); 216 217 bool 218 Emulate_BEQZC (llvm::MCInst& insn); 219 220 bool 221 Emulate_BNEZC (llvm::MCInst& insn); 222 223 bool 224 Emulate_BGEZL (llvm::MCInst& insn); 225 226 bool 227 Emulate_BGTZ (llvm::MCInst& insn); 228 229 bool 230 Emulate_BGTZL (llvm::MCInst& insn); 231 232 bool 233 Emulate_BLEZ (llvm::MCInst& insn); 234 235 bool 236 Emulate_BLEZL (llvm::MCInst& insn); 237 238 bool 239 Emulate_BLTZ (llvm::MCInst& insn); 240 241 bool 242 Emulate_BLTZAL (llvm::MCInst& insn); 243 244 bool 245 Emulate_BLTZALL (llvm::MCInst& insn); 246 247 bool 248 Emulate_BLTZL (llvm::MCInst& insn); 249 250 bool 251 Emulate_BOVC (llvm::MCInst& insn); 252 253 bool 254 Emulate_BNVC (llvm::MCInst& insn); 255 256 bool 257 Emulate_J (llvm::MCInst& insn); 258 259 bool 260 Emulate_JAL (llvm::MCInst& insn); 261 262 bool 263 Emulate_JALR (llvm::MCInst& insn); 264 265 bool 266 Emulate_JIALC (llvm::MCInst& insn); 267 268 bool 269 Emulate_JIC (llvm::MCInst& insn); 270 271 bool 272 Emulate_JR (llvm::MCInst& insn); 273 274 bool 275 Emulate_BC1F (llvm::MCInst& insn); 276 277 bool 278 Emulate_BC1T (llvm::MCInst& insn); 279 280 bool 281 Emulate_BC1FL (llvm::MCInst& insn); 282 283 bool 284 Emulate_BC1TL (llvm::MCInst& insn); 285 286 bool 287 Emulate_BC1EQZ (llvm::MCInst& insn); 288 289 bool 290 Emulate_BC1NEZ (llvm::MCInst& insn); 291 292 bool 293 Emulate_BC1ANY2F (llvm::MCInst& insn); 294 295 bool 296 Emulate_BC1ANY2T (llvm::MCInst& insn); 297 298 bool 299 Emulate_BC1ANY4F (llvm::MCInst& insn); 300 301 bool 302 Emulate_BC1ANY4T (llvm::MCInst& insn); 303 304 bool 305 nonvolatile_reg_p (uint64_t regnum); 306 307 const char * 308 GetRegisterName (unsigned reg_num, bool altnernate_name); 309 310 private: 311 std::unique_ptr<llvm::MCDisassembler> m_disasm; 312 std::unique_ptr<llvm::MCSubtargetInfo> m_subtype_info; 313 std::unique_ptr<llvm::MCRegisterInfo> m_reg_info; 314 std::unique_ptr<llvm::MCAsmInfo> m_asm_info; 315 std::unique_ptr<llvm::MCContext> m_context; 316 std::unique_ptr<llvm::MCInstrInfo> m_insn_info; 317 }; 318 319 #endif // EmulateInstructionMIPS64_h_ 320