LLDB  mainline
EmulateInstructionMIPS64.h
Go to the documentation of this file.
1 //===-- EmulateInstructionMIPS64.h ------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLDB_SOURCE_PLUGINS_INSTRUCTION_MIPS64_EMULATEINSTRUCTIONMIPS64_H
10 #define LLDB_SOURCE_PLUGINS_INSTRUCTION_MIPS64_EMULATEINSTRUCTIONMIPS64_H
11 
14 #include "lldb/Utility/Status.h"
15 
16 namespace llvm {
17 class MCDisassembler;
18 class MCSubtargetInfo;
19 class MCRegisterInfo;
20 class MCAsmInfo;
21 class MCContext;
22 class MCInstrInfo;
23 class MCInst;
24 } // namespace llvm
25 
27 public:
29 
30  static void Initialize();
31 
32  static void Terminate();
33 
35 
36  static const char *GetPluginDescriptionStatic();
37 
41 
44  switch (inst_type) {
48  return true;
49 
51  return false;
52  }
53  return false;
54  }
55 
57 
58  uint32_t GetPluginVersion() override { return 1; }
59 
60  bool SetTargetTriple(const lldb_private::ArchSpec &arch) override;
61 
63  lldb_private::InstructionType inst_type) override {
65  }
66 
67  bool ReadInstruction() override;
68 
69  bool EvaluateInstruction(uint32_t evaluate_options) override;
70 
73  lldb_private::OptionValueDictionary *test_data) override {
74  return false;
75  }
76 
77  bool GetRegisterInfo(lldb::RegisterKind reg_kind, uint32_t reg_num,
78  lldb_private::RegisterInfo &reg_info) override;
79 
80  bool
82 
83 protected:
84  typedef struct {
85  const char *op_name;
86  bool (EmulateInstructionMIPS64::*callback)(llvm::MCInst &insn);
87  const char *insn_name;
88  } MipsOpcode;
89 
90  static MipsOpcode *GetOpcodeForInstruction(const char *op_name);
91 
92  bool Emulate_DADDiu(llvm::MCInst &insn);
93 
94  bool Emulate_DSUBU_DADDU(llvm::MCInst &insn);
95 
96  bool Emulate_LUI(llvm::MCInst &insn);
97 
98  bool Emulate_SD(llvm::MCInst &insn);
99 
100  bool Emulate_LD(llvm::MCInst &insn);
101 
102  bool Emulate_LDST_Imm(llvm::MCInst &insn);
103 
104  bool Emulate_LDST_Reg(llvm::MCInst &insn);
105 
106  bool Emulate_BXX_3ops(llvm::MCInst &insn);
107 
108  bool Emulate_BXX_3ops_C(llvm::MCInst &insn);
109 
110  bool Emulate_BXX_2ops(llvm::MCInst &insn);
111 
112  bool Emulate_BXX_2ops_C(llvm::MCInst &insn);
113 
114  bool Emulate_Bcond_Link_C(llvm::MCInst &insn);
115 
116  bool Emulate_Bcond_Link(llvm::MCInst &insn);
117 
118  bool Emulate_FP_branch(llvm::MCInst &insn);
119 
120  bool Emulate_3D_branch(llvm::MCInst &insn);
121 
122  bool Emulate_BAL(llvm::MCInst &insn);
123 
124  bool Emulate_BALC(llvm::MCInst &insn);
125 
126  bool Emulate_BC(llvm::MCInst &insn);
127 
128  bool Emulate_J(llvm::MCInst &insn);
129 
130  bool Emulate_JAL(llvm::MCInst &insn);
131 
132  bool Emulate_JALR(llvm::MCInst &insn);
133 
134  bool Emulate_JIALC(llvm::MCInst &insn);
135 
136  bool Emulate_JIC(llvm::MCInst &insn);
137 
138  bool Emulate_JR(llvm::MCInst &insn);
139 
140  bool Emulate_BC1EQZ(llvm::MCInst &insn);
141 
142  bool Emulate_BC1NEZ(llvm::MCInst &insn);
143 
144  bool Emulate_BNZB(llvm::MCInst &insn);
145 
146  bool Emulate_BNZH(llvm::MCInst &insn);
147 
148  bool Emulate_BNZW(llvm::MCInst &insn);
149 
150  bool Emulate_BNZD(llvm::MCInst &insn);
151 
152  bool Emulate_BZB(llvm::MCInst &insn);
153 
154  bool Emulate_BZH(llvm::MCInst &insn);
155 
156  bool Emulate_BZW(llvm::MCInst &insn);
157 
158  bool Emulate_BZD(llvm::MCInst &insn);
159 
160  bool Emulate_MSA_Branch_DF(llvm::MCInst &insn, int element_byte_size,
161  bool bnz);
162 
163  bool Emulate_BNZV(llvm::MCInst &insn);
164 
165  bool Emulate_BZV(llvm::MCInst &insn);
166 
167  bool Emulate_MSA_Branch_V(llvm::MCInst &insn, bool bnz);
168 
169  bool nonvolatile_reg_p(uint64_t regnum);
170 
171  const char *GetRegisterName(unsigned reg_num, bool alternate_name);
172 
173 private:
174  std::unique_ptr<llvm::MCDisassembler> m_disasm;
175  std::unique_ptr<llvm::MCSubtargetInfo> m_subtype_info;
176  std::unique_ptr<llvm::MCRegisterInfo> m_reg_info;
177  std::unique_ptr<llvm::MCAsmInfo> m_asm_info;
178  std::unique_ptr<llvm::MCContext> m_context;
179  std::unique_ptr<llvm::MCInstrInfo> m_insn_info;
180 };
181 
182 #endif // LLDB_SOURCE_PLUGINS_INSTRUCTION_MIPS64_EMULATEINSTRUCTIONMIPS64_H
EmulateInstructionMIPS64::Emulate_3D_branch
bool Emulate_3D_branch(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS64.cpp:2104
EmulateInstructionMIPS64::Emulate_Bcond_Link_C
bool Emulate_Bcond_Link_C(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS64.cpp:1506
lldb_private::eInstructionTypePCModifying
@ eInstructionTypePCModifying
Definition: lldb-private-enumerations.h:123
EmulateInstructionMIPS64::Emulate_BZH
bool Emulate_BZH(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS64.cpp:2177
llvm
Definition: Debugger.h:49
EmulateInstructionMIPS64::Emulate_JALR
bool Emulate_JALR(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS64.cpp:1853
lldb_private::ArchSpec
Definition: ArchSpec.h:33
EmulateInstructionMIPS64::Emulate_BXX_2ops_C
bool Emulate_BXX_2ops_C(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS64.cpp:1738
EmulateInstructionMIPS64::Emulate_MSA_Branch_DF
bool Emulate_MSA_Branch_DF(llvm::MCInst &insn, int element_byte_size, bool bnz)
Definition: EmulateInstructionMIPS64.cpp:2189
EmulateInstructionMIPS64::Emulate_BXX_2ops
bool Emulate_BXX_2ops(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS64.cpp:1574
EmulateInstructionMIPS64::Emulate_DADDiu
bool Emulate_DADDiu(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS64.cpp:1077
EmulateInstructionMIPS64::Emulate_JIC
bool Emulate_JIC(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS64.cpp:1926
EmulateInstructionMIPS64::CreateFunctionEntryUnwind
bool CreateFunctionEntryUnwind(lldb_private::UnwindPlan &unwind_plan) override
Definition: EmulateInstructionMIPS64.cpp:1029
EmulateInstructionMIPS64::Emulate_BC1NEZ
bool Emulate_BC1NEZ(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS64.cpp:2061
EmulateInstructionMIPS64::Emulate_BNZW
bool Emulate_BNZW(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS64.cpp:2165
EmulateInstructionMIPS64::nonvolatile_reg_p
bool nonvolatile_reg_p(uint64_t regnum)
Definition: EmulateInstructionMIPS64.cpp:1056
EmulateInstructionMIPS64::GetRegisterInfo
bool GetRegisterInfo(lldb::RegisterKind reg_kind, uint32_t reg_num, lldb_private::RegisterInfo &reg_info) override
Definition: EmulateInstructionMIPS64.cpp:585
EmulateInstructionMIPS64::Emulate_BNZH
bool Emulate_BNZH(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS64.cpp:2161
EmulateInstructionMIPS64::SetTargetTriple
bool SetTargetTriple(const lldb_private::ArchSpec &arch) override
Definition: EmulateInstructionMIPS64.cpp:211
EmulateInstructionMIPS64::Emulate_BXX_3ops_C
bool Emulate_BXX_3ops_C(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS64.cpp:1659
EmulateInstructionMIPS64::SupportsEmulatingInstructionsOfType
bool SupportsEmulatingInstructionsOfType(lldb_private::InstructionType inst_type) override
Definition: EmulateInstructionMIPS64.h:62
EmulateInstructionMIPS64
Definition: EmulateInstructionMIPS64.h:26
lldb_private::Stream
Definition: Stream.h:28
EmulateInstructionMIPS64::Emulate_BNZD
bool Emulate_BNZD(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS64.cpp:2169
EmulateInstructionMIPS64::Terminate
static void Terminate()
Definition: EmulateInstructionMIPS64.cpp:179
EmulateInstructionMIPS64::ReadInstruction
bool ReadInstruction() override
Definition: EmulateInstructionMIPS64.cpp:942
EmulateInstructionMIPS64::Emulate_BZV
bool Emulate_BZV(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS64.cpp:2253
lldb_private::eInstructionTypeAll
@ eInstructionTypeAll
Definition: lldb-private-enumerations.h:125
EmulateInstructionMIPS64::m_disasm
std::unique_ptr< llvm::MCDisassembler > m_disasm
Definition: EmulateInstructionMIPS64.h:174
OptionValue.h
EmulateInstructionMIPS64::Emulate_FP_branch
bool Emulate_FP_branch(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS64.cpp:1979
EmulateInstructionMIPS64::m_insn_info
std::unique_ptr< llvm::MCInstrInfo > m_insn_info
Definition: EmulateInstructionMIPS64.h:179
EmulateInstructionMIPS64::Emulate_LDST_Imm
bool Emulate_LDST_Imm(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS64.cpp:2292
EmulateInstructionMIPS64::Emulate_BNZB
bool Emulate_BNZB(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS64.cpp:2157
EmulateInstructionMIPS64::CreateInstance
static lldb_private::EmulateInstruction * CreateInstance(const lldb_private::ArchSpec &arch, lldb_private::InstructionType inst_type)
Definition: EmulateInstructionMIPS64.cpp:198
EmulateInstructionMIPS64::MipsOpcode::insn_name
const char * insn_name
Definition: EmulateInstructionMIPS64.h:87
EmulateInstruction.h
EmulateInstructionMIPS64::Emulate_BZD
bool Emulate_BZD(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS64.cpp:2185
EmulateInstructionMIPS64::Emulate_JR
bool Emulate_JR(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS64.cpp:1952
EmulateInstructionMIPS64::Emulate_JIALC
bool Emulate_JIALC(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS64.cpp:1888
EmulateInstructionMIPS64::Emulate_BC
bool Emulate_BC(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS64.cpp:1626
EmulateInstructionMIPS64::GetPluginDescriptionStatic
static const char * GetPluginDescriptionStatic()
Definition: EmulateInstructionMIPS64.cpp:193
EmulateInstructionMIPS64::GetOpcodeForInstruction
static MipsOpcode * GetOpcodeForInstruction(const char *op_name)
Definition: EmulateInstructionMIPS64.cpp:668
EmulateInstructionMIPS64::Emulate_BNZV
bool Emulate_BNZV(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS64.cpp:2249
EmulateInstructionMIPS64::GetPluginNameStatic
static lldb_private::ConstString GetPluginNameStatic()
Definition: EmulateInstructionMIPS64.cpp:183
EmulateInstructionMIPS64::Emulate_BZW
bool Emulate_BZW(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS64.cpp:2181
EmulateInstructionMIPS64::Emulate_J
bool Emulate_J(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS64.cpp:1798
EmulateInstructionMIPS64::m_context
std::unique_ptr< llvm::MCContext > m_context
Definition: EmulateInstructionMIPS64.h:178
EmulateInstructionMIPS64::TestEmulation
bool TestEmulation(lldb_private::Stream *out_stream, lldb_private::ArchSpec &arch, lldb_private::OptionValueDictionary *test_data) override
Definition: EmulateInstructionMIPS64.h:71
lldb_private::ConstString
Definition: ConstString.h:40
EmulateInstructionMIPS64::MipsOpcode
Definition: EmulateInstructionMIPS64.h:84
EmulateInstructionMIPS64::Emulate_MSA_Branch_V
bool Emulate_MSA_Branch_V(llvm::MCInst &insn, bool bnz)
Definition: EmulateInstructionMIPS64.cpp:2257
EmulateInstructionMIPS64::Emulate_LDST_Reg
bool Emulate_LDST_Reg(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS64.cpp:2325
EmulateInstructionMIPS64::Emulate_Bcond_Link
bool Emulate_Bcond_Link(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS64.cpp:1395
EmulateInstructionMIPS64::Emulate_BC1EQZ
bool Emulate_BC1EQZ(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS64.cpp:2025
EmulateInstructionMIPS64::EmulateInstructionMIPS64
EmulateInstructionMIPS64(const lldb_private::ArchSpec &arch)
Definition: EmulateInstructionMIPS64.cpp:62
EmulateInstructionMIPS64::Emulate_BXX_3ops
bool Emulate_BXX_3ops(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS64.cpp:1344
EmulateInstructionMIPS64::Emulate_BALC
bool Emulate_BALC(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS64.cpp:1471
EmulateInstructionMIPS64::GetRegisterName
const char * GetRegisterName(unsigned reg_num, bool alternate_name)
Definition: EmulateInstructionMIPS64.cpp:216
EmulateInstructionMIPS64::m_asm_info
std::unique_ptr< llvm::MCAsmInfo > m_asm_info
Definition: EmulateInstructionMIPS64.h:177
EmulateInstructionMIPS64::Initialize
static void Initialize()
Definition: EmulateInstructionMIPS64.cpp:174
lldb::RegisterKind
RegisterKind
Register numbering types.
Definition: lldb-enumerations.h:227
EmulateInstructionMIPS64::Emulate_LUI
bool Emulate_LUI(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS64.cpp:1244
EmulateInstructionMIPS64::SupportsEmulatingInstructionsOfTypeStatic
static bool SupportsEmulatingInstructionsOfTypeStatic(lldb_private::InstructionType inst_type)
Definition: EmulateInstructionMIPS64.h:42
EmulateInstructionMIPS64::EvaluateInstruction
bool EvaluateInstruction(uint32_t evaluate_options) override
Definition: EmulateInstructionMIPS64.cpp:959
uint32_t
lldb_private::EmulateInstruction
Definition: EmulateInstruction.h:93
EmulateInstructionMIPS64::Emulate_SD
bool Emulate_SD(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS64.cpp:1141
EmulateInstructionMIPS64::Emulate_BZB
bool Emulate_BZB(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS64.cpp:2173
EmulateInstructionMIPS64::m_reg_info
std::unique_ptr< llvm::MCRegisterInfo > m_reg_info
Definition: EmulateInstructionMIPS64.h:176
EmulateInstructionMIPS64::GetPluginName
lldb_private::ConstString GetPluginName() override
Definition: EmulateInstructionMIPS64.cpp:188
EmulateInstructionMIPS64::Emulate_BAL
bool Emulate_BAL(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS64.cpp:1440
lldb_private::eInstructionTypePrologueEpilogue
@ eInstructionTypePrologueEpilogue
Definition: lldb-private-enumerations.h:120
EmulateInstructionMIPS64::MipsOpcode::op_name
const char * op_name
Definition: EmulateInstructionMIPS64.h:85
lldb_private::InstructionType
InstructionType
Instruction types.
Definition: lldb-private-enumerations.h:118
EmulateInstructionMIPS64::Emulate_DSUBU_DADDU
bool Emulate_DSUBU_DADDU(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS64.cpp:1261
Status.h
EmulateInstructionMIPS64::Emulate_LD
bool Emulate_LD(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS64.cpp:1198
EmulateInstructionMIPS64::Emulate_JAL
bool Emulate_JAL(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS64.cpp:1822
lldb_private::OptionValueDictionary
Definition: OptionValueDictionary.h:18
EmulateInstructionMIPS64::GetPluginVersion
uint32_t GetPluginVersion() override
Definition: EmulateInstructionMIPS64.h:58
lldb_private::UnwindPlan
Definition: UnwindPlan.h:53
lldb_private::eInstructionTypeAny
@ eInstructionTypeAny
Definition: lldb-private-enumerations.h:119
EmulateInstructionMIPS64::m_subtype_info
std::unique_ptr< llvm::MCSubtargetInfo > m_subtype_info
Definition: EmulateInstructionMIPS64.h:175