LLDB  mainline
EmulateInstructionMIPS.h
Go to the documentation of this file.
1 //===-- EmulateInstructionMIPS.h ------------------------------------*- C++
2 //-*-===//
3 //
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #ifndef LLDB_SOURCE_PLUGINS_INSTRUCTION_MIPS_EMULATEINSTRUCTIONMIPS_H
11 #define LLDB_SOURCE_PLUGINS_INSTRUCTION_MIPS_EMULATEINSTRUCTIONMIPS_H
12 
13 namespace llvm {
14 class MCDisassembler;
15 class MCSubtargetInfo;
16 class MCRegisterInfo;
17 class MCAsmInfo;
18 class MCContext;
19 class MCInstrInfo;
20 class MCInst;
21 }
22 
23 namespace lldb_private {
24  class OptionValueDictionary;
25 }
26 
28 #include "lldb/Utility/Status.h"
29 
31 public:
32  static void Initialize();
33 
34  static void Terminate();
35 
37 
38  static const char *GetPluginDescriptionStatic();
39 
43 
46  switch (inst_type) {
50  return true;
51 
53  return false;
54  }
55  return false;
56  }
57 
59 
60  uint32_t GetPluginVersion() override { return 1; }
61 
62  bool SetTargetTriple(const lldb_private::ArchSpec &arch) override;
63 
65 
67  lldb_private::InstructionType inst_type) override {
69  }
70 
71  bool ReadInstruction() override;
72 
73  bool EvaluateInstruction(uint32_t evaluate_options) override;
74 
75  bool SetInstruction(const lldb_private::Opcode &insn_opcode,
76  const lldb_private::Address &inst_addr,
77  lldb_private::Target *target) override;
78 
81  lldb_private::OptionValueDictionary *test_data) override {
82  return false;
83  }
84 
85  bool GetRegisterInfo(lldb::RegisterKind reg_kind, uint32_t reg_num,
86  lldb_private::RegisterInfo &reg_info) override;
87 
88  bool
90 
91 protected:
92  typedef struct {
93  const char *op_name;
94  bool (EmulateInstructionMIPS::*callback)(llvm::MCInst &insn);
95  const char *insn_name;
96  } MipsOpcode;
97 
98  static MipsOpcode *GetOpcodeForInstruction(const char *op_name);
99 
101  uint64_t inst_addr);
102 
103  bool Emulate_ADDiu(llvm::MCInst &insn);
104 
105  bool Emulate_SUBU_ADDU(llvm::MCInst &insn);
106 
107  bool Emulate_LUI(llvm::MCInst &insn);
108 
109  bool Emulate_SW(llvm::MCInst &insn);
110 
111  bool Emulate_LW(llvm::MCInst &insn);
112 
113  bool Emulate_ADDIUSP(llvm::MCInst &insn);
114 
115  bool Emulate_ADDIUS5(llvm::MCInst &insn);
116 
117  bool Emulate_SWSP(llvm::MCInst &insn);
118 
119  bool Emulate_SWM16_32(llvm::MCInst &insn);
120 
121  bool Emulate_LWSP(llvm::MCInst &insn);
122 
123  bool Emulate_LWM16_32(llvm::MCInst &insn);
124 
125  bool Emulate_JRADDIUSP(llvm::MCInst &insn);
126 
127  bool Emulate_LDST_Imm(llvm::MCInst &insn);
128 
129  bool Emulate_LDST_Reg(llvm::MCInst &insn);
130 
131  bool Emulate_BXX_3ops(llvm::MCInst &insn);
132 
133  bool Emulate_BXX_3ops_C(llvm::MCInst &insn);
134 
135  bool Emulate_BXX_2ops(llvm::MCInst &insn);
136 
137  bool Emulate_BXX_2ops_C(llvm::MCInst &insn);
138 
139  bool Emulate_Bcond_Link_C(llvm::MCInst &insn);
140 
141  bool Emulate_Bcond_Link(llvm::MCInst &insn);
142 
143  bool Emulate_FP_branch(llvm::MCInst &insn);
144 
145  bool Emulate_3D_branch(llvm::MCInst &insn);
146 
147  bool Emulate_BAL(llvm::MCInst &insn);
148 
149  bool Emulate_BALC(llvm::MCInst &insn);
150 
151  bool Emulate_BC(llvm::MCInst &insn);
152 
153  bool Emulate_J(llvm::MCInst &insn);
154 
155  bool Emulate_JAL(llvm::MCInst &insn);
156 
157  bool Emulate_JALR(llvm::MCInst &insn);
158 
159  bool Emulate_JIALC(llvm::MCInst &insn);
160 
161  bool Emulate_JIC(llvm::MCInst &insn);
162 
163  bool Emulate_JR(llvm::MCInst &insn);
164 
165  bool Emulate_BC1EQZ(llvm::MCInst &insn);
166 
167  bool Emulate_BC1NEZ(llvm::MCInst &insn);
168 
169  bool Emulate_BNZB(llvm::MCInst &insn);
170 
171  bool Emulate_BNZH(llvm::MCInst &insn);
172 
173  bool Emulate_BNZW(llvm::MCInst &insn);
174 
175  bool Emulate_BNZD(llvm::MCInst &insn);
176 
177  bool Emulate_BZB(llvm::MCInst &insn);
178 
179  bool Emulate_BZH(llvm::MCInst &insn);
180 
181  bool Emulate_BZW(llvm::MCInst &insn);
182 
183  bool Emulate_BZD(llvm::MCInst &insn);
184 
185  bool Emulate_MSA_Branch_DF(llvm::MCInst &insn, int element_byte_size,
186  bool bnz);
187 
188  bool Emulate_BNZV(llvm::MCInst &insn);
189 
190  bool Emulate_BZV(llvm::MCInst &insn);
191 
192  bool Emulate_MSA_Branch_V(llvm::MCInst &insn, bool bnz);
193 
194  bool Emulate_B16_MM(llvm::MCInst &insn);
195 
196  bool Emulate_Branch_MM(llvm::MCInst &insn);
197 
198  bool Emulate_JALRx16_MM(llvm::MCInst &insn);
199 
200  bool Emulate_JALx(llvm::MCInst &insn);
201 
202  bool Emulate_JALRS(llvm::MCInst &insn);
203 
204  bool nonvolatile_reg_p(uint32_t regnum);
205 
206  const char *GetRegisterName(unsigned reg_num, bool alternate_name);
207 
208 private:
209  std::unique_ptr<llvm::MCDisassembler> m_disasm;
210  std::unique_ptr<llvm::MCDisassembler> m_alt_disasm;
211  std::unique_ptr<llvm::MCSubtargetInfo> m_subtype_info;
212  std::unique_ptr<llvm::MCSubtargetInfo> m_alt_subtype_info;
213  std::unique_ptr<llvm::MCRegisterInfo> m_reg_info;
214  std::unique_ptr<llvm::MCAsmInfo> m_asm_info;
215  std::unique_ptr<llvm::MCContext> m_context;
216  std::unique_ptr<llvm::MCInstrInfo> m_insn_info;
219 };
220 
221 #endif // LLDB_SOURCE_PLUGINS_INSTRUCTION_MIPS_EMULATEINSTRUCTIONMIPS_H
EmulateInstructionMIPS::Emulate_ADDiu
bool Emulate_ADDiu(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS.cpp:1184
EmulateInstructionMIPS::Emulate_BZV
bool Emulate_BZV(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS.cpp:2941
EmulateInstructionMIPS::Emulate_JR
bool Emulate_JR(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS.cpp:2650
EmulateInstructionMIPS::nonvolatile_reg_p
bool nonvolatile_reg_p(uint32_t regnum)
Definition: EmulateInstructionMIPS.cpp:1163
lldb_private::eInstructionTypePCModifying
@ eInstructionTypePCModifying
Definition: lldb-private-enumerations.h:123
llvm
Definition: Debugger.h:49
EmulateInstructionMIPS::Emulate_BALC
bool Emulate_BALC(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS.cpp:2443
EmulateInstructionMIPS::Emulate_J
bool Emulate_J(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS.cpp:2497
EmulateInstructionMIPS::GetRegisterInfo
bool GetRegisterInfo(lldb::RegisterKind reg_kind, uint32_t reg_num, lldb_private::RegisterInfo &reg_info) override
Definition: EmulateInstructionMIPS.cpp:598
lldb_private::ArchSpec
Definition: ArchSpec.h:33
EmulateInstructionMIPS::m_insn_info
std::unique_ptr< llvm::MCInstrInfo > m_insn_info
Definition: EmulateInstructionMIPS.h:216
EmulateInstructionMIPS::SetTargetTriple
bool SetTargetTriple(const lldb_private::ArchSpec &arch) override
Definition: EmulateInstructionMIPS.cpp:224
lldb_private::Opcode
Definition: Opcode.h:29
EmulateInstructionMIPS::Emulate_BC1EQZ
bool Emulate_BC1EQZ(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS.cpp:2714
EmulateInstructionMIPS::EvaluateInstruction
bool EvaluateInstruction(uint32_t evaluate_options) override
Definition: EmulateInstructionMIPS.cpp:1062
EmulateInstructionMIPS::GetSizeOfInstruction
uint32_t GetSizeOfInstruction(lldb_private::DataExtractor &data, uint64_t inst_addr)
Definition: EmulateInstructionMIPS.cpp:978
EmulateInstructionMIPS::EmulateInstructionMIPS
EmulateInstructionMIPS(const lldb_private::ArchSpec &arch)
Definition: EmulateInstructionMIPS.cpp:62
EmulateInstructionMIPS::m_next_inst_size
uint32_t m_next_inst_size
Definition: EmulateInstructionMIPS.h:217
EmulateInstructionMIPS::Initialize
static void Initialize()
Definition: EmulateInstructionMIPS.cpp:187
EmulateInstructionMIPS::Emulate_MSA_Branch_V
bool Emulate_MSA_Branch_V(llvm::MCInst &insn, bool bnz)
Definition: EmulateInstructionMIPS.cpp:2945
EmulateInstructionMIPS::GetPluginVersion
uint32_t GetPluginVersion() override
Definition: EmulateInstructionMIPS.h:60
EmulateInstructionMIPS::SupportsEmulatingInstructionsOfTypeStatic
static bool SupportsEmulatingInstructionsOfTypeStatic(lldb_private::InstructionType inst_type)
Definition: EmulateInstructionMIPS.h:44
EmulateInstructionMIPS::Emulate_LDST_Imm
bool Emulate_LDST_Imm(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS.cpp:2980
EmulateInstructionMIPS::Emulate_ADDIUS5
bool Emulate_ADDIUS5(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS.cpp:1468
EmulateInstructionMIPS::ReadInstruction
bool ReadInstruction() override
Definition: EmulateInstructionMIPS.cpp:1045
EmulateInstructionMIPS::Emulate_BZD
bool Emulate_BZD(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS.cpp:2873
lldb_private::Stream
Definition: Stream.h:28
lldb_private::Target
Definition: Target.h:445
EmulateInstructionMIPS::Emulate_FP_branch
bool Emulate_FP_branch(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS.cpp:2677
EmulateInstructionMIPS::GetOpcodeForInstruction
static MipsOpcode * GetOpcodeForInstruction(const char *op_name)
Definition: EmulateInstructionMIPS.cpp:681
EmulateInstructionMIPS::Emulate_JALRx16_MM
bool Emulate_JALRx16_MM(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS.cpp:2291
lldb_private::eInstructionTypeAll
@ eInstructionTypeAll
Definition: lldb-private-enumerations.h:125
EmulateInstructionMIPS::Emulate_B16_MM
bool Emulate_B16_MM(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS.cpp:2163
EmulateInstructionMIPS::m_context
std::unique_ptr< llvm::MCContext > m_context
Definition: EmulateInstructionMIPS.h:215
EmulateInstructionMIPS::m_disasm
std::unique_ptr< llvm::MCDisassembler > m_disasm
Definition: EmulateInstructionMIPS.h:209
EmulateInstructionMIPS::Emulate_BNZH
bool Emulate_BNZH(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS.cpp:2849
EmulateInstructionMIPS::Emulate_SUBU_ADDU
bool Emulate_SUBU_ADDU(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS.cpp:1347
EmulateInstructionMIPS::Emulate_LDST_Reg
bool Emulate_LDST_Reg(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS.cpp:3013
EmulateInstructionMIPS::Emulate_BXX_3ops
bool Emulate_BXX_3ops(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS.cpp:1803
EmulateInstruction.h
EmulateInstructionMIPS::Emulate_BXX_3ops_C
bool Emulate_BXX_3ops_C(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS.cpp:1852
lldb_private::DataExtractor
Definition: DataExtractor.h:48
EmulateInstructionMIPS::Emulate_LUI
bool Emulate_LUI(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS.cpp:1425
EmulateInstructionMIPS::m_alt_subtype_info
std::unique_ptr< llvm::MCSubtargetInfo > m_alt_subtype_info
Definition: EmulateInstructionMIPS.h:212
EmulateInstructionMIPS::Emulate_Bcond_Link_C
bool Emulate_Bcond_Link_C(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS.cpp:1931
EmulateInstructionMIPS::CreateFunctionEntryUnwind
bool CreateFunctionEntryUnwind(lldb_private::UnwindPlan &unwind_plan) override
Definition: EmulateInstructionMIPS.cpp:1137
EmulateInstructionMIPS::Emulate_BZW
bool Emulate_BZW(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS.cpp:2869
EmulateInstructionMIPS::m_subtype_info
std::unique_ptr< llvm::MCSubtargetInfo > m_subtype_info
Definition: EmulateInstructionMIPS.h:211
EmulateInstructionMIPS::Emulate_BZB
bool Emulate_BZB(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS.cpp:2861
lldb_private::ConstString
Definition: ConstString.h:40
EmulateInstructionMIPS::Emulate_JIALC
bool Emulate_JIALC(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS.cpp:2586
EmulateInstructionMIPS::MipsOpcode::insn_name
const char * insn_name
Definition: EmulateInstructionMIPS.h:95
EmulateInstructionMIPS::Emulate_JAL
bool Emulate_JAL(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS.cpp:2520
EmulateInstructionMIPS::Emulate_LWM16_32
bool Emulate_LWM16_32(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS.cpp:1694
EmulateInstructionMIPS::Emulate_JRADDIUSP
bool Emulate_JRADDIUSP(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS.cpp:1751
EmulateInstructionMIPS::Emulate_MSA_Branch_DF
bool Emulate_MSA_Branch_DF(llvm::MCInst &insn, int element_byte_size, bool bnz)
Definition: EmulateInstructionMIPS.cpp:2877
EmulateInstructionMIPS::MipsOpcode
Definition: EmulateInstructionMIPS.h:92
EmulateInstructionMIPS::Emulate_BXX_2ops_C
bool Emulate_BXX_2ops_C(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS.cpp:2103
EmulateInstructionMIPS::Emulate_SWM16_32
bool Emulate_SWM16_32(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS.cpp:1566
EmulateInstructionMIPS::MipsOpcode::op_name
const char * op_name
Definition: EmulateInstructionMIPS.h:93
EmulateInstructionMIPS::Emulate_BC
bool Emulate_BC(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS.cpp:2474
EmulateInstructionMIPS::Emulate_Branch_MM
bool Emulate_Branch_MM(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS.cpp:2190
lldb::RegisterKind
RegisterKind
Register numbering types.
Definition: lldb-enumerations.h:227
EmulateInstructionMIPS::Emulate_BZH
bool Emulate_BZH(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS.cpp:2865
EmulateInstructionMIPS::Emulate_BXX_2ops
bool Emulate_BXX_2ops(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS.cpp:2050
EmulateInstructionMIPS::Emulate_JALx
bool Emulate_JALx(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS.cpp:2330
EmulateInstructionMIPS::Terminate
static void Terminate()
Definition: EmulateInstructionMIPS.cpp:192
EmulateInstructionMIPS::m_alt_disasm
std::unique_ptr< llvm::MCDisassembler > m_alt_disasm
Definition: EmulateInstructionMIPS.h:210
EmulateInstructionMIPS::Emulate_BNZV
bool Emulate_BNZV(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS.cpp:2937
EmulateInstructionMIPS::Emulate_BNZB
bool Emulate_BNZB(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS.cpp:2845
EmulateInstructionMIPS::Emulate_LW
bool Emulate_LW(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS.cpp:1300
EmulateInstructionMIPS::Emulate_3D_branch
bool Emulate_3D_branch(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS.cpp:2793
uint32_t
EmulateInstructionMIPS::Emulate_BAL
bool Emulate_BAL(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS.cpp:2412
lldb_private::EmulateInstruction
Definition: EmulateInstruction.h:93
lldb_private::Address
Definition: Address.h:59
EmulateInstructionMIPS::TestEmulation
bool TestEmulation(lldb_private::Stream *out_stream, lldb_private::ArchSpec &arch, lldb_private::OptionValueDictionary *test_data) override
Definition: EmulateInstructionMIPS.h:79
EmulateInstructionMIPS::Emulate_BNZW
bool Emulate_BNZW(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS.cpp:2853
EmulateInstructionMIPS::SetInstruction
bool SetInstruction(const lldb_private::Opcode &insn_opcode, const lldb_private::Address &inst_addr, lldb_private::Target *target) override
Definition: EmulateInstructionMIPS.cpp:998
EmulateInstructionMIPS::Emulate_BC1NEZ
bool Emulate_BC1NEZ(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS.cpp:2750
EmulateInstructionMIPS::Emulate_JIC
bool Emulate_JIC(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS.cpp:2624
EmulateInstructionMIPS::Emulate_BNZD
bool Emulate_BNZD(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS.cpp:2857
EmulateInstructionMIPS::SupportsEmulatingInstructionsOfType
bool SupportsEmulatingInstructionsOfType(lldb_private::InstructionType inst_type) override
Definition: EmulateInstructionMIPS.h:66
lldb_private::eInstructionTypePrologueEpilogue
@ eInstructionTypePrologueEpilogue
Definition: lldb-private-enumerations.h:120
EmulateInstructionMIPS::Emulate_SWSP
bool Emulate_SWSP(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS.cpp:1501
lldb_private::InstructionType
InstructionType
Instruction types.
Definition: lldb-private-enumerations.h:118
EmulateInstructionMIPS::GetPluginDescriptionStatic
static const char * GetPluginDescriptionStatic()
Definition: EmulateInstructionMIPS.cpp:206
EmulateInstructionMIPS::Emulate_JALRS
bool Emulate_JALRS(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS.cpp:2375
Status.h
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
EmulateInstructionMIPS::Emulate_Bcond_Link
bool Emulate_Bcond_Link(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS.cpp:2000
EmulateInstructionMIPS::GetPluginName
lldb_private::ConstString GetPluginName() override
Definition: EmulateInstructionMIPS.cpp:201
lldb_private::OptionValueDictionary
Definition: OptionValueDictionary.h:18
EmulateInstructionMIPS::m_asm_info
std::unique_ptr< llvm::MCAsmInfo > m_asm_info
Definition: EmulateInstructionMIPS.h:214
EmulateInstructionMIPS::Emulate_JALR
bool Emulate_JALR(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS.cpp:2551
EmulateInstructionMIPS::GetRegisterName
const char * GetRegisterName(unsigned reg_num, bool alternate_name)
Definition: EmulateInstructionMIPS.cpp:229
EmulateInstructionMIPS::CreateInstance
static lldb_private::EmulateInstruction * CreateInstance(const lldb_private::ArchSpec &arch, lldb_private::InstructionType inst_type)
Definition: EmulateInstructionMIPS.cpp:211
EmulateInstructionMIPS::Emulate_LWSP
bool Emulate_LWSP(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS.cpp:1643
EmulateInstructionMIPS::m_use_alt_disaasm
bool m_use_alt_disaasm
Definition: EmulateInstructionMIPS.h:218
lldb_private::UnwindPlan
Definition: UnwindPlan.h:53
EmulateInstructionMIPS::Emulate_SW
bool Emulate_SW(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS.cpp:1236
lldb_private::eInstructionTypeAny
@ eInstructionTypeAny
Definition: lldb-private-enumerations.h:119
EmulateInstructionMIPS::m_reg_info
std::unique_ptr< llvm::MCRegisterInfo > m_reg_info
Definition: EmulateInstructionMIPS.h:213
EmulateInstructionMIPS::GetPluginNameStatic
static lldb_private::ConstString GetPluginNameStatic()
Definition: EmulateInstructionMIPS.cpp:196
EmulateInstructionMIPS
Definition: EmulateInstructionMIPS.h:30
EmulateInstructionMIPS::Emulate_ADDIUSP
bool Emulate_ADDIUSP(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS.cpp:1442