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 
34  static llvm::StringRef GetPluginNameStatic() { return "mips64"; }
35 
36  static llvm::StringRef GetPluginDescriptionStatic();
37 
41 
44  switch (inst_type) {
48  return true;
49 
51  return false;
52  }
53  return false;
54  }
55 
56  llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }
57 
58  bool SetTargetTriple(const lldb_private::ArchSpec &arch) override;
59 
61  lldb_private::InstructionType inst_type) override {
63  }
64 
65  bool ReadInstruction() override;
66 
67  bool EvaluateInstruction(uint32_t evaluate_options) override;
68 
71  lldb_private::OptionValueDictionary *test_data) override {
72  return false;
73  }
74 
75  bool GetRegisterInfo(lldb::RegisterKind reg_kind, uint32_t reg_num,
76  lldb_private::RegisterInfo &reg_info) override;
77 
78  bool
80 
81 protected:
82  typedef struct {
83  const char *op_name;
84  bool (EmulateInstructionMIPS64::*callback)(llvm::MCInst &insn);
85  const char *insn_name;
86  } MipsOpcode;
87 
88  static MipsOpcode *GetOpcodeForInstruction(const char *op_name);
89 
90  bool Emulate_DADDiu(llvm::MCInst &insn);
91 
92  bool Emulate_DSUBU_DADDU(llvm::MCInst &insn);
93 
94  bool Emulate_LUI(llvm::MCInst &insn);
95 
96  bool Emulate_SD(llvm::MCInst &insn);
97 
98  bool Emulate_LD(llvm::MCInst &insn);
99 
100  bool Emulate_LDST_Imm(llvm::MCInst &insn);
101 
102  bool Emulate_LDST_Reg(llvm::MCInst &insn);
103 
104  bool Emulate_BXX_3ops(llvm::MCInst &insn);
105 
106  bool Emulate_BXX_3ops_C(llvm::MCInst &insn);
107 
108  bool Emulate_BXX_2ops(llvm::MCInst &insn);
109 
110  bool Emulate_BXX_2ops_C(llvm::MCInst &insn);
111 
112  bool Emulate_Bcond_Link_C(llvm::MCInst &insn);
113 
114  bool Emulate_Bcond_Link(llvm::MCInst &insn);
115 
116  bool Emulate_FP_branch(llvm::MCInst &insn);
117 
118  bool Emulate_3D_branch(llvm::MCInst &insn);
119 
120  bool Emulate_BAL(llvm::MCInst &insn);
121 
122  bool Emulate_BALC(llvm::MCInst &insn);
123 
124  bool Emulate_BC(llvm::MCInst &insn);
125 
126  bool Emulate_J(llvm::MCInst &insn);
127 
128  bool Emulate_JAL(llvm::MCInst &insn);
129 
130  bool Emulate_JALR(llvm::MCInst &insn);
131 
132  bool Emulate_JIALC(llvm::MCInst &insn);
133 
134  bool Emulate_JIC(llvm::MCInst &insn);
135 
136  bool Emulate_JR(llvm::MCInst &insn);
137 
138  bool Emulate_BC1EQZ(llvm::MCInst &insn);
139 
140  bool Emulate_BC1NEZ(llvm::MCInst &insn);
141 
142  bool Emulate_BNZB(llvm::MCInst &insn);
143 
144  bool Emulate_BNZH(llvm::MCInst &insn);
145 
146  bool Emulate_BNZW(llvm::MCInst &insn);
147 
148  bool Emulate_BNZD(llvm::MCInst &insn);
149 
150  bool Emulate_BZB(llvm::MCInst &insn);
151 
152  bool Emulate_BZH(llvm::MCInst &insn);
153 
154  bool Emulate_BZW(llvm::MCInst &insn);
155 
156  bool Emulate_BZD(llvm::MCInst &insn);
157 
158  bool Emulate_MSA_Branch_DF(llvm::MCInst &insn, int element_byte_size,
159  bool bnz);
160 
161  bool Emulate_BNZV(llvm::MCInst &insn);
162 
163  bool Emulate_BZV(llvm::MCInst &insn);
164 
165  bool Emulate_MSA_Branch_V(llvm::MCInst &insn, bool bnz);
166 
167  bool nonvolatile_reg_p(uint64_t regnum);
168 
169  const char *GetRegisterName(unsigned reg_num, bool alternate_name);
170 
171 private:
172  std::unique_ptr<llvm::MCDisassembler> m_disasm;
173  std::unique_ptr<llvm::MCSubtargetInfo> m_subtype_info;
174  std::unique_ptr<llvm::MCRegisterInfo> m_reg_info;
175  std::unique_ptr<llvm::MCAsmInfo> m_asm_info;
176  std::unique_ptr<llvm::MCContext> m_context;
177  std::unique_ptr<llvm::MCInstrInfo> m_insn_info;
178 };
179 
180 #endif // LLDB_SOURCE_PLUGINS_INSTRUCTION_MIPS64_EMULATEINSTRUCTIONMIPS64_H
EmulateInstructionMIPS64::Emulate_3D_branch
bool Emulate_3D_branch(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS64.cpp:2094
EmulateInstructionMIPS64::Emulate_Bcond_Link_C
bool Emulate_Bcond_Link_C(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS64.cpp:1496
lldb_private::eInstructionTypePCModifying
@ eInstructionTypePCModifying
Definition: lldb-private-enumerations.h:123
EmulateInstructionMIPS64::Emulate_BZH
bool Emulate_BZH(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS64.cpp:2167
llvm
Definition: Debugger.h:49
EmulateInstructionMIPS64::Emulate_JALR
bool Emulate_JALR(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS64.cpp:1843
lldb_private::ArchSpec
Definition: ArchSpec.h:33
EmulateInstructionMIPS64::Emulate_BXX_2ops_C
bool Emulate_BXX_2ops_C(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS64.cpp:1728
EmulateInstructionMIPS64::Emulate_MSA_Branch_DF
bool Emulate_MSA_Branch_DF(llvm::MCInst &insn, int element_byte_size, bool bnz)
Definition: EmulateInstructionMIPS64.cpp:2179
EmulateInstructionMIPS64::Emulate_BXX_2ops
bool Emulate_BXX_2ops(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS64.cpp:1564
EmulateInstructionMIPS64::Emulate_DADDiu
bool Emulate_DADDiu(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS64.cpp:1067
EmulateInstructionMIPS64::Emulate_JIC
bool Emulate_JIC(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS64.cpp:1916
EmulateInstructionMIPS64::CreateFunctionEntryUnwind
bool CreateFunctionEntryUnwind(lldb_private::UnwindPlan &unwind_plan) override
Definition: EmulateInstructionMIPS64.cpp:1019
EmulateInstructionMIPS64::Emulate_BC1NEZ
bool Emulate_BC1NEZ(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS64.cpp:2051
EmulateInstructionMIPS64::Emulate_BNZW
bool Emulate_BNZW(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS64.cpp:2155
EmulateInstructionMIPS64::nonvolatile_reg_p
bool nonvolatile_reg_p(uint64_t regnum)
Definition: EmulateInstructionMIPS64.cpp:1046
EmulateInstructionMIPS64::GetRegisterInfo
bool GetRegisterInfo(lldb::RegisterKind reg_kind, uint32_t reg_num, lldb_private::RegisterInfo &reg_info) override
Definition: EmulateInstructionMIPS64.cpp:575
EmulateInstructionMIPS64::Emulate_BNZH
bool Emulate_BNZH(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS64.cpp:2151
EmulateInstructionMIPS64::SetTargetTriple
bool SetTargetTriple(const lldb_private::ArchSpec &arch) override
Definition: EmulateInstructionMIPS64.cpp:201
EmulateInstructionMIPS64::Emulate_BXX_3ops_C
bool Emulate_BXX_3ops_C(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS64.cpp:1649
EmulateInstructionMIPS64::SupportsEmulatingInstructionsOfType
bool SupportsEmulatingInstructionsOfType(lldb_private::InstructionType inst_type) override
Definition: EmulateInstructionMIPS64.h:60
EmulateInstructionMIPS64
Definition: EmulateInstructionMIPS64.h:26
lldb_private::Stream
Definition: Stream.h:28
EmulateInstructionMIPS64::Emulate_BNZD
bool Emulate_BNZD(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS64.cpp:2159
EmulateInstructionMIPS64::Terminate
static void Terminate()
Definition: EmulateInstructionMIPS64.cpp:179
EmulateInstructionMIPS64::ReadInstruction
bool ReadInstruction() override
Definition: EmulateInstructionMIPS64.cpp:932
EmulateInstructionMIPS64::Emulate_BZV
bool Emulate_BZV(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS64.cpp:2243
lldb_private::eInstructionTypeAll
@ eInstructionTypeAll
Definition: lldb-private-enumerations.h:125
EmulateInstructionMIPS64::m_disasm
std::unique_ptr< llvm::MCDisassembler > m_disasm
Definition: EmulateInstructionMIPS64.h:172
EmulateInstructionMIPS64::GetPluginName
llvm::StringRef GetPluginName() override
Definition: EmulateInstructionMIPS64.h:56
OptionValue.h
EmulateInstructionMIPS64::Emulate_FP_branch
bool Emulate_FP_branch(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS64.cpp:1969
EmulateInstructionMIPS64::m_insn_info
std::unique_ptr< llvm::MCInstrInfo > m_insn_info
Definition: EmulateInstructionMIPS64.h:177
EmulateInstructionMIPS64::Emulate_LDST_Imm
bool Emulate_LDST_Imm(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS64.cpp:2282
EmulateInstructionMIPS64::Emulate_BNZB
bool Emulate_BNZB(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS64.cpp:2147
EmulateInstructionMIPS64::CreateInstance
static lldb_private::EmulateInstruction * CreateInstance(const lldb_private::ArchSpec &arch, lldb_private::InstructionType inst_type)
Definition: EmulateInstructionMIPS64.cpp:188
EmulateInstructionMIPS64::MipsOpcode::insn_name
const char * insn_name
Definition: EmulateInstructionMIPS64.h:85
EmulateInstruction.h
EmulateInstructionMIPS64::Emulate_BZD
bool Emulate_BZD(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS64.cpp:2175
EmulateInstructionMIPS64::Emulate_JR
bool Emulate_JR(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS64.cpp:1942
EmulateInstructionMIPS64::Emulate_JIALC
bool Emulate_JIALC(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS64.cpp:1878
EmulateInstructionMIPS64::GetPluginNameStatic
static llvm::StringRef GetPluginNameStatic()
Definition: EmulateInstructionMIPS64.h:34
EmulateInstructionMIPS64::Emulate_BC
bool Emulate_BC(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS64.cpp:1616
EmulateInstructionMIPS64::GetOpcodeForInstruction
static MipsOpcode * GetOpcodeForInstruction(const char *op_name)
Definition: EmulateInstructionMIPS64.cpp:658
EmulateInstructionMIPS64::Emulate_BNZV
bool Emulate_BNZV(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS64.cpp:2239
EmulateInstructionMIPS64::Emulate_BZW
bool Emulate_BZW(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS64.cpp:2171
EmulateInstructionMIPS64::Emulate_J
bool Emulate_J(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS64.cpp:1788
EmulateInstructionMIPS64::m_context
std::unique_ptr< llvm::MCContext > m_context
Definition: EmulateInstructionMIPS64.h:176
EmulateInstructionMIPS64::TestEmulation
bool TestEmulation(lldb_private::Stream *out_stream, lldb_private::ArchSpec &arch, lldb_private::OptionValueDictionary *test_data) override
Definition: EmulateInstructionMIPS64.h:69
EmulateInstructionMIPS64::MipsOpcode
Definition: EmulateInstructionMIPS64.h:82
EmulateInstructionMIPS64::Emulate_MSA_Branch_V
bool Emulate_MSA_Branch_V(llvm::MCInst &insn, bool bnz)
Definition: EmulateInstructionMIPS64.cpp:2247
EmulateInstructionMIPS64::Emulate_LDST_Reg
bool Emulate_LDST_Reg(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS64.cpp:2315
EmulateInstructionMIPS64::Emulate_Bcond_Link
bool Emulate_Bcond_Link(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS64.cpp:1385
EmulateInstructionMIPS64::Emulate_BC1EQZ
bool Emulate_BC1EQZ(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS64.cpp:2015
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:1334
EmulateInstructionMIPS64::Emulate_BALC
bool Emulate_BALC(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS64.cpp:1461
EmulateInstructionMIPS64::GetRegisterName
const char * GetRegisterName(unsigned reg_num, bool alternate_name)
Definition: EmulateInstructionMIPS64.cpp:206
EmulateInstructionMIPS64::m_asm_info
std::unique_ptr< llvm::MCAsmInfo > m_asm_info
Definition: EmulateInstructionMIPS64.h:175
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:1234
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:949
uint32_t
lldb_private::EmulateInstruction
Definition: EmulateInstruction.h:93
EmulateInstructionMIPS64::Emulate_SD
bool Emulate_SD(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS64.cpp:1131
EmulateInstructionMIPS64::Emulate_BZB
bool Emulate_BZB(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS64.cpp:2163
EmulateInstructionMIPS64::m_reg_info
std::unique_ptr< llvm::MCRegisterInfo > m_reg_info
Definition: EmulateInstructionMIPS64.h:174
EmulateInstructionMIPS64::GetPluginDescriptionStatic
static llvm::StringRef GetPluginDescriptionStatic()
Definition: EmulateInstructionMIPS64.cpp:183
EmulateInstructionMIPS64::Emulate_BAL
bool Emulate_BAL(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS64.cpp:1430
lldb_private::eInstructionTypePrologueEpilogue
@ eInstructionTypePrologueEpilogue
Definition: lldb-private-enumerations.h:120
EmulateInstructionMIPS64::MipsOpcode::op_name
const char * op_name
Definition: EmulateInstructionMIPS64.h:83
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:1251
Status.h
EmulateInstructionMIPS64::Emulate_LD
bool Emulate_LD(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS64.cpp:1188
EmulateInstructionMIPS64::Emulate_JAL
bool Emulate_JAL(llvm::MCInst &insn)
Definition: EmulateInstructionMIPS64.cpp:1812
lldb_private::OptionValueDictionary
Definition: OptionValueDictionary.h:18
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:173