25#include "llvm/ADT/STLExtras.h"
26#include "llvm/Support/MathExtras.h"
48 "jirl rd, rj, offs16"},
54 "beq rj, rd, offs16"},
56 "bne rj, rd, offs16"},
58 "blt rj, rd, offs16"},
60 "bge rj, rd, offs16"},
62 "bltu rj, rd, offs16"},
64 "bgeu rj, rd, offs16"},
67 static const size_t num_loongarch_opcodes = std::size(g_opcodes);
69 for (
size_t i = 0; i < num_loongarch_opcodes; ++i)
70 if ((g_opcodes[i].mask & inst) == g_opcodes[i].value)
80 if (!(this->*opcode_data->
callback)(inst))
86 uint32_t inst_size =
m_opcode.GetByteSize();
87 uint32_t inst =
m_opcode.GetOpcode32();
88 bool increase_pc = options & eEmulateInstructionOptionAutoAdvancePC;
103 if (!(this->*opcode_data->
callback)(inst))
111 if (new_pc == old_pc && !
WritePC(old_pc + inst_size))
118 bool success =
false;
147std::optional<RegisterInfo>
149 uint32_t reg_index) {
171 llvm_unreachable(
"unsupported register");
177 const uint32_t length =
182 return array[reg_index];
274 bool success =
false;
275 uint32_t rj =
Bits32(inst, 9, 5);
279 uint32_t offs21 =
Bits32(inst, 25, 10) + (
Bits32(inst, 4, 0) << 16);
284 uint64_t next_pc =
pc + llvm::SignExtend64<23>(offs21 << 2);
294 bool success =
false;
295 uint32_t rj =
Bits32(inst, 9, 5);
299 uint32_t offs21 =
Bits32(inst, 25, 10) + (
Bits32(inst, 4, 0) << 16);
304 uint64_t next_pc =
pc + llvm::SignExtend64<23>(offs21 << 2);
314 bool success =
false;
319 uint32_t offs21 =
Bits32(inst, 25, 10) + (
Bits32(inst, 4, 0) << 16);
325 uint64_t next_pc =
pc + llvm::SignExtend64<23>(offs21 << 2);
336 bool success =
false;
341 uint32_t offs21 =
Bits32(inst, 25, 10) + (
Bits32(inst, 4, 0) << 16);
347 uint64_t next_pc =
pc + llvm::SignExtend64<23>(offs21 << 2);
358 uint32_t rj =
Bits32(inst, 9, 5);
359 uint32_t rd =
Bits32(inst, 4, 0);
360 bool success =
false;
370 uint64_t next_pc = rj_val + llvm::SignExtend64<18>(
Bits32(inst, 25, 10) << 2);
377 bool success =
false;
381 uint32_t offs26 =
Bits32(inst, 25, 10) + (
Bits32(inst, 9, 0) << 16);
382 uint64_t next_pc =
pc + llvm::SignExtend64<28>(offs26 << 2);
390 bool success =
false;
397 uint32_t offs26 =
Bits32(inst, 25, 10) + (
Bits32(inst, 9, 0) << 16);
398 uint64_t next_pc =
pc + llvm::SignExtend64<28>(offs26 << 2);
406 bool success =
false;
407 uint32_t rj =
Bits32(inst, 9, 5);
408 uint32_t rd =
Bits32(inst, 4, 0);
418 if (rj_val == rd_val) {
419 uint64_t next_pc =
pc + llvm::SignExtend64<18>(
Bits32(inst, 25, 10) << 2);
429 bool success =
false;
430 uint32_t rj =
Bits32(inst, 9, 5);
431 uint32_t rd =
Bits32(inst, 4, 0);
441 if (rj_val != rd_val) {
442 uint64_t next_pc =
pc + llvm::SignExtend64<18>(
Bits32(inst, 25, 10) << 2);
452 bool success =
false;
453 uint32_t rj =
Bits32(inst, 9, 5);
454 uint32_t rd =
Bits32(inst, 4, 0);
466 if (rj_val < rd_val) {
467 uint64_t next_pc =
pc + llvm::SignExtend64<18>(
Bits32(inst, 25, 10) << 2);
477 bool success =
false;
478 uint32_t rj =
Bits32(inst, 9, 5);
479 uint32_t rd =
Bits32(inst, 4, 0);
491 if (rj_val >= rd_val) {
492 uint64_t next_pc =
pc + llvm::SignExtend64<18>(
Bits32(inst, 25, 10) << 2);
502 bool success =
false;
503 uint32_t rj =
Bits32(inst, 9, 5);
504 uint32_t rd =
Bits32(inst, 4, 0);
514 if (rj_val < rd_val) {
515 uint64_t next_pc =
pc + llvm::SignExtend64<18>(
Bits32(inst, 25, 10) << 2);
525 bool success =
false;
526 uint32_t rj =
Bits32(inst, 9, 5);
527 uint32_t rd =
Bits32(inst, 4, 0);
537 if (rj_val >= rd_val) {
538 uint64_t next_pc =
pc + llvm::SignExtend64<18>(
Bits32(inst, 25, 10) << 2);
#define LLDB_PLUGIN_DEFINE_ADV(ClassName, PluginName)
static const lldb_private::RegisterInfo * GetRegisterInfoPtr(const lldb_private::ArchSpec &target_arch)
static uint32_t GetRegisterInfoCount(const lldb_private::ArchSpec &target_arch)
An architecture specification class.
llvm::Triple & GetTriple()
Architecture triple accessor.
bool EmulateBEQ(uint32_t inst)
static lldb_private::EmulateInstruction * CreateInstance(const lldb_private::ArchSpec &arch, InstructionType inst_type)
bool EmulateBGEU64(uint32_t inst)
bool EmulateBCNEZ(uint32_t inst)
bool EmulateBL64(uint32_t inst)
Opcode * GetOpcodeForInstruction(uint32_t inst)
bool EvaluateInstruction(uint32_t options) override
bool EmulateBLTU(uint32_t inst)
bool EmulateJIRL(uint32_t inst)
bool EmulateBLT(uint32_t inst)
bool EmulateBGEU(uint32_t inst)
bool EmulateBLTU64(uint32_t inst)
bool EmulateBLT64(uint32_t inst)
bool TestEmulation(Stream &out_stream, ArchSpec &arch, OptionValueDictionary *test_data) override
bool EmulateJIRL64(uint32_t inst)
bool TestExecute(uint32_t inst)
bool EmulateB(uint32_t inst)
static bool SupportsThisArch(const ArchSpec &arch)
bool WritePC(lldb::addr_t pc)
bool EmulateBCNEZ64(uint32_t inst)
std::optional< RegisterInfo > GetRegisterInfo(lldb::RegisterKind reg_kind, uint32_t reg_num) override
bool EmulateBCEQZ(uint32_t inst)
static llvm::StringRef GetPluginNameStatic()
lldb::addr_t ReadPC(bool *success)
bool SetTargetTriple(const ArchSpec &arch) override
bool EmulateBNE(uint32_t inst)
bool EmulateB64(uint32_t inst)
bool EmulateBL(uint32_t inst)
bool EmulateBCEQZ64(uint32_t inst)
bool EmulateBGE64(uint32_t inst)
bool EmulateNonJMP(uint32_t inst)
static llvm::StringRef GetPluginDescriptionStatic()
bool ReadInstruction() override
bool EmulateBNEZ64(uint32_t inst)
bool EmulateBGE(uint32_t inst)
bool EmulateBEQZ(uint32_t inst)
bool EmulateBEQZ64(uint32_t inst)
static bool SupportsThisInstructionType(InstructionType inst_type)
bool EmulateBNE64(uint32_t inst)
bool EmulateBNEZ(uint32_t inst)
bool EmulateBEQ64(uint32_t inst)
"lldb/Core/EmulateInstruction.h" A class that allows emulation of CPU opcodes.
lldb::ByteOrder GetByteOrder() const
bool WriteRegisterUnsigned(const Context &context, const RegisterInfo ®_info, uint64_t reg_value)
uint64_t ReadMemoryUnsigned(const Context &context, lldb::addr_t addr, size_t byte_size, uint64_t fail_value, bool *success_ptr)
uint64_t ReadRegisterUnsigned(const RegisterInfo ®_info, uint64_t fail_value, bool *success_ptr)
static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description, ABICreateInstance create_callback)
static bool UnregisterPlugin(ABICreateInstance create_callback)
A stream class that can stream formatted output to a file.
#define LLDB_REGNUM_GENERIC_RA
#define LLDB_REGNUM_GENERIC_SP
#define LLDB_INVALID_ADDRESS
#define LLDB_REGNUM_GENERIC_PC
#define LLDB_REGNUM_GENERIC_FP
A class that represents a running process on the host machine.
InstructionType
Instruction types.
static uint32_t Bits32(const uint32_t bits, const uint32_t msbit, const uint32_t lsbit)
RegisterKind
Register numbering types.
@ eRegisterKindGeneric
insn ptr reg, stack ptr reg, etc not specific to any particular target
@ eRegisterKindLLDB
lldb's internal register numbers
bool(EmulateInstructionLoongArch::* callback)(uint32_t opcode)
Every register is described in detail including its name, alternate name (optional),...