LLDB mainline
EmulateInstructionLoongArch.h
Go to the documentation of this file.
1//===---EmulateInstructionLoongArch.h--------------------------------------===//
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_LOONGARCH_EMULATEINSTRUCTIONLOONGARCH_H
10#define LLDB_SOURCE_PLUGINS_INSTRUCTION_LOONGARCH_EMULATEINSTRUCTIONLOONGARCH_H
11
14#include "lldb/Utility/Log.h"
15#include "lldb/Utility/Status.h"
16#include <optional>
17
18namespace lldb_private {
19
21public:
22 static llvm::StringRef GetPluginNameStatic() { return "LoongArch"; }
23
24 static llvm::StringRef GetPluginDescriptionStatic() {
25 return "Emulate instructions for the LoongArch architecture.";
26 }
27
29 return inst_type == eInstructionTypePCModifying;
30 }
31
32 static bool SupportsThisArch(const ArchSpec &arch);
33
36
37 static void Initialize();
38
39 static void Terminate();
40
41public:
45
46 llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }
47
49 return SupportsThisInstructionType(inst_type);
50 }
51
52 bool SetTargetTriple(const ArchSpec &arch) override;
53 bool ReadInstruction() override;
54 bool EvaluateInstruction(uint32_t options) override;
55 bool TestEmulation(Stream &out_stream, ArchSpec &arch,
56 OptionValueDictionary *test_data) override;
57
58 std::optional<RegisterInfo> GetRegisterInfo(lldb::RegisterKind reg_kind,
59 uint32_t reg_num) override;
60 bool IsLoongArch64() { return m_arch_subtype == llvm::Triple::loongarch64; }
61 bool TestExecute(uint32_t inst);
62
63private:
64 struct Opcode {
65 uint32_t mask;
66 uint32_t value;
68 const char *name;
69 };
70
71 llvm::Triple::ArchType m_arch_subtype;
72 Opcode *GetOpcodeForInstruction(uint32_t inst);
73
74 bool EmulateBEQZ(uint32_t inst);
75 bool EmulateBNEZ(uint32_t inst);
76 bool EmulateBCEQZ(uint32_t inst);
77 bool EmulateBCNEZ(uint32_t inst);
78 bool EmulateJIRL(uint32_t inst);
79 bool EmulateB(uint32_t inst);
80 bool EmulateBL(uint32_t inst);
81 bool EmulateBEQ(uint32_t inst);
82 bool EmulateBNE(uint32_t inst);
83 bool EmulateBLT(uint32_t inst);
84 bool EmulateBGE(uint32_t inst);
85 bool EmulateBLTU(uint32_t inst);
86 bool EmulateBGEU(uint32_t inst);
87 bool EmulateNonJMP(uint32_t inst);
88
89 bool EmulateBEQZ64(uint32_t inst);
90 bool EmulateBNEZ64(uint32_t inst);
91 bool EmulateBCEQZ64(uint32_t inst);
92 bool EmulateBCNEZ64(uint32_t inst);
93 bool EmulateJIRL64(uint32_t inst);
94 bool EmulateB64(uint32_t inst);
95 bool EmulateBL64(uint32_t inst);
96 bool EmulateBEQ64(uint32_t inst);
97 bool EmulateBNE64(uint32_t inst);
98 bool EmulateBLT64(uint32_t inst);
99 bool EmulateBGE64(uint32_t inst);
100 bool EmulateBLTU64(uint32_t inst);
101 bool EmulateBGEU64(uint32_t inst);
102};
103
104} // namespace lldb_private
105
106#endif // LLDB_SOURCE_PLUGINS_INSTRUCTION_LOONGARCH_EMULATEINSTRUCTIONLOONGARCH_H
An architecture specification class.
Definition ArchSpec.h:31
llvm::Triple::ArchType GetMachine() const
Returns a machine family for the current architecture.
Definition ArchSpec.cpp:677
static lldb_private::EmulateInstruction * CreateInstance(const lldb_private::ArchSpec &arch, InstructionType inst_type)
bool SupportsEmulatingInstructionsOfType(InstructionType inst_type) override
bool TestEmulation(Stream &out_stream, ArchSpec &arch, OptionValueDictionary *test_data) override
std::optional< RegisterInfo > GetRegisterInfo(lldb::RegisterKind reg_kind, uint32_t reg_num) override
bool SetTargetTriple(const ArchSpec &arch) override
static bool SupportsThisInstructionType(InstructionType inst_type)
"lldb/Core/EmulateInstruction.h" A class that allows emulation of CPU opcodes.
A stream class that can stream formatted output to a file.
Definition Stream.h:28
A class that represents a running process on the host machine.
InstructionType
Instruction types.
RegisterKind
Register numbering types.
bool(EmulateInstructionLoongArch::* callback)(uint32_t opcode)