]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.h
Vendor import of lldb trunk r290819:
[FreeBSD/FreeBSD.git] / source / Plugins / Instruction / MIPS / EmulateInstructionMIPS.h
1 //===-- EmulateInstructionMIPS.h ------------------------------------*- C++
2 //-*-===//
3 //
4 //                     The LLVM Compiler Infrastructure
5 //
6 // This file is distributed under the University of Illinois Open Source
7 // License. See LICENSE.TXT for details.
8 //
9 //===----------------------------------------------------------------------===//
10
11 #ifndef EmulateInstructionMIPS_h_
12 #define EmulateInstructionMIPS_h_
13
14 namespace llvm {
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 EmulateInstructionMIPS : public lldb_private::EmulateInstruction {
29 public:
30   static void Initialize();
31
32   static void Terminate();
33
34   static lldb_private::ConstString GetPluginNameStatic();
35
36   static const char *GetPluginDescriptionStatic();
37
38   static lldb_private::EmulateInstruction *
39   CreateInstance(const lldb_private::ArchSpec &arch,
40                  lldb_private::InstructionType inst_type);
41
42   static bool SupportsEmulatingInstructionsOfTypeStatic(
43       lldb_private::InstructionType inst_type) {
44     switch (inst_type) {
45     case lldb_private::eInstructionTypeAny:
46     case lldb_private::eInstructionTypePrologueEpilogue:
47     case lldb_private::eInstructionTypePCModifying:
48       return true;
49
50     case lldb_private::eInstructionTypeAll:
51       return false;
52     }
53     return false;
54   }
55
56   lldb_private::ConstString GetPluginName() override;
57
58   uint32_t GetPluginVersion() override { return 1; }
59
60   bool SetTargetTriple(const lldb_private::ArchSpec &arch) override;
61
62   EmulateInstructionMIPS(const lldb_private::ArchSpec &arch);
63
64   bool SupportsEmulatingInstructionsOfType(
65       lldb_private::InstructionType inst_type) override {
66     return SupportsEmulatingInstructionsOfTypeStatic(inst_type);
67   }
68
69   bool ReadInstruction() override;
70
71   bool EvaluateInstruction(uint32_t evaluate_options) override;
72
73   bool SetInstruction(const lldb_private::Opcode &insn_opcode,
74                       const lldb_private::Address &inst_addr,
75                       lldb_private::Target *target) override;
76
77   bool TestEmulation(lldb_private::Stream *out_stream,
78                      lldb_private::ArchSpec &arch,
79                      lldb_private::OptionValueDictionary *test_data) override {
80     return false;
81   }
82
83   bool GetRegisterInfo(lldb::RegisterKind reg_kind, uint32_t reg_num,
84                        lldb_private::RegisterInfo &reg_info) override;
85
86   bool
87   CreateFunctionEntryUnwind(lldb_private::UnwindPlan &unwind_plan) override;
88
89 protected:
90   typedef struct {
91     const char *op_name;
92     bool (EmulateInstructionMIPS::*callback)(llvm::MCInst &insn);
93     const char *insn_name;
94   } MipsOpcode;
95
96   static MipsOpcode *GetOpcodeForInstruction(const char *op_name);
97
98   uint32_t GetSizeOfInstruction(lldb_private::DataExtractor &data,
99                                 uint64_t inst_addr);
100
101   bool Emulate_ADDiu(llvm::MCInst &insn);
102
103   bool Emulate_SUBU_ADDU(llvm::MCInst &insn);
104
105   bool Emulate_LUI(llvm::MCInst &insn);
106
107   bool Emulate_SW(llvm::MCInst &insn);
108
109   bool Emulate_LW(llvm::MCInst &insn);
110
111   bool Emulate_ADDIUSP(llvm::MCInst &insn);
112
113   bool Emulate_ADDIUS5(llvm::MCInst &insn);
114
115   bool Emulate_SWSP(llvm::MCInst &insn);
116
117   bool Emulate_SWM16_32(llvm::MCInst &insn);
118
119   bool Emulate_LWSP(llvm::MCInst &insn);
120
121   bool Emulate_LWM16_32(llvm::MCInst &insn);
122
123   bool Emulate_JRADDIUSP(llvm::MCInst &insn);
124
125   bool Emulate_LDST_Imm(llvm::MCInst &insn);
126
127   bool Emulate_LDST_Reg(llvm::MCInst &insn);
128
129   bool Emulate_BXX_3ops(llvm::MCInst &insn);
130
131   bool Emulate_BXX_3ops_C(llvm::MCInst &insn);
132
133   bool Emulate_BXX_2ops(llvm::MCInst &insn);
134
135   bool Emulate_BXX_2ops_C(llvm::MCInst &insn);
136
137   bool Emulate_Bcond_Link_C(llvm::MCInst &insn);
138
139   bool Emulate_Bcond_Link(llvm::MCInst &insn);
140
141   bool Emulate_FP_branch(llvm::MCInst &insn);
142
143   bool Emulate_3D_branch(llvm::MCInst &insn);
144
145   bool Emulate_BAL(llvm::MCInst &insn);
146
147   bool Emulate_BALC(llvm::MCInst &insn);
148
149   bool Emulate_BC(llvm::MCInst &insn);
150
151   bool Emulate_J(llvm::MCInst &insn);
152
153   bool Emulate_JAL(llvm::MCInst &insn);
154
155   bool Emulate_JALR(llvm::MCInst &insn);
156
157   bool Emulate_JIALC(llvm::MCInst &insn);
158
159   bool Emulate_JIC(llvm::MCInst &insn);
160
161   bool Emulate_JR(llvm::MCInst &insn);
162
163   bool Emulate_BC1EQZ(llvm::MCInst &insn);
164
165   bool Emulate_BC1NEZ(llvm::MCInst &insn);
166
167   bool Emulate_BNZB(llvm::MCInst &insn);
168
169   bool Emulate_BNZH(llvm::MCInst &insn);
170
171   bool Emulate_BNZW(llvm::MCInst &insn);
172
173   bool Emulate_BNZD(llvm::MCInst &insn);
174
175   bool Emulate_BZB(llvm::MCInst &insn);
176
177   bool Emulate_BZH(llvm::MCInst &insn);
178
179   bool Emulate_BZW(llvm::MCInst &insn);
180
181   bool Emulate_BZD(llvm::MCInst &insn);
182
183   bool Emulate_MSA_Branch_DF(llvm::MCInst &insn, int element_byte_size,
184                              bool bnz);
185
186   bool Emulate_BNZV(llvm::MCInst &insn);
187
188   bool Emulate_BZV(llvm::MCInst &insn);
189
190   bool Emulate_MSA_Branch_V(llvm::MCInst &insn, bool bnz);
191
192   bool Emulate_B16_MM(llvm::MCInst &insn);
193
194   bool Emulate_Branch_MM(llvm::MCInst &insn);
195
196   bool Emulate_JALRx16_MM(llvm::MCInst &insn);
197
198   bool Emulate_JALx(llvm::MCInst &insn);
199
200   bool Emulate_JALRS(llvm::MCInst &insn);
201
202   bool nonvolatile_reg_p(uint32_t regnum);
203
204   const char *GetRegisterName(unsigned reg_num, bool altnernate_name);
205
206 private:
207   std::unique_ptr<llvm::MCDisassembler> m_disasm;
208   std::unique_ptr<llvm::MCDisassembler> m_alt_disasm;
209   std::unique_ptr<llvm::MCSubtargetInfo> m_subtype_info;
210   std::unique_ptr<llvm::MCSubtargetInfo> m_alt_subtype_info;
211   std::unique_ptr<llvm::MCRegisterInfo> m_reg_info;
212   std::unique_ptr<llvm::MCAsmInfo> m_asm_info;
213   std::unique_ptr<llvm::MCContext> m_context;
214   std::unique_ptr<llvm::MCInstrInfo> m_insn_info;
215   uint32_t m_next_inst_size;
216   bool m_use_alt_disaasm;
217 };
218
219 #endif // EmulateInstructionMIPS_h_