1 //===-- EmulateInstructionPPC64.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 EmulateInstructionPPC64_h_ 11 #define EmulateInstructionPPC64_h_ 12 13 #include "lldb/Core/EmulateInstruction.h" 14 #include "lldb/Interpreter/OptionValue.h" 15 #include "lldb/Utility/Log.h" 16 17 namespace lldb_private { 18 19 class EmulateInstructionPPC64 : public EmulateInstruction { 20 public: 21 EmulateInstructionPPC64(const ArchSpec &arch); 22 23 static void Initialize(); 24 25 static void Terminate(); 26 27 static ConstString GetPluginNameStatic(); 28 29 static const char *GetPluginDescriptionStatic(); 30 31 static EmulateInstruction *CreateInstance(const ArchSpec &arch, 32 InstructionType inst_type); 33 34 static bool SupportsEmulatingInstructionsOfTypeStatic(InstructionType inst_type)35 SupportsEmulatingInstructionsOfTypeStatic(InstructionType inst_type) { 36 switch (inst_type) { 37 case eInstructionTypeAny: 38 case eInstructionTypePrologueEpilogue: 39 return true; 40 41 case eInstructionTypePCModifying: 42 case eInstructionTypeAll: 43 return false; 44 } 45 return false; 46 } 47 48 ConstString GetPluginName() override; 49 GetPluginVersion()50 uint32_t GetPluginVersion() override { return 1; } 51 52 bool SetTargetTriple(const ArchSpec &arch) override; 53 SupportsEmulatingInstructionsOfType(InstructionType inst_type)54 bool SupportsEmulatingInstructionsOfType(InstructionType inst_type) override { 55 return SupportsEmulatingInstructionsOfTypeStatic(inst_type); 56 } 57 58 bool ReadInstruction() override; 59 60 bool EvaluateInstruction(uint32_t evaluate_options) override; 61 TestEmulation(Stream * out_stream,ArchSpec & arch,OptionValueDictionary * test_data)62 bool TestEmulation(Stream *out_stream, ArchSpec &arch, 63 OptionValueDictionary *test_data) override { 64 return false; 65 } 66 67 bool GetRegisterInfo(lldb::RegisterKind reg_kind, uint32_t reg_num, 68 RegisterInfo ®_info) override; 69 70 bool CreateFunctionEntryUnwind(UnwindPlan &unwind_plan) override; 71 72 private: 73 struct Opcode { 74 uint32_t mask; 75 uint32_t value; 76 bool (EmulateInstructionPPC64::*callback)(uint32_t opcode); 77 const char *name; 78 }; 79 80 uint32_t m_fp = LLDB_INVALID_REGNUM; 81 82 Opcode *GetOpcodeForInstruction(uint32_t opcode); 83 84 bool EmulateMFSPR(uint32_t opcode); 85 bool EmulateLD(uint32_t opcode); 86 bool EmulateSTD(uint32_t opcode); 87 bool EmulateOR(uint32_t opcode); 88 bool EmulateADDI(uint32_t opcode); 89 }; 90 91 } // namespace lldb_private 92 93 #endif // EmulateInstructionPPC64_h_ 94