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))
 
  112    if (new_pc == old_pc && !
WritePC(old_pc + inst_size))
 
 
  126  bool success = 
false;
 
 
  136std::optional<RegisterInfo>
 
  138                                             uint32_t reg_index) {
 
  160      llvm_unreachable(
"unsupported register");
 
  166  const uint32_t length =
 
  171  return array[reg_index];
 
 
  263  bool success = 
false;
 
  264  uint32_t rj = 
Bits32(inst, 9, 5);
 
  271  uint32_t offs21 = 
Bits32(inst, 25, 10) + (
Bits32(inst, 4, 0) << 16);
 
  276    uint64_t next_pc = 
pc + llvm::SignExtend64<23>(offs21 << 2);
 
 
  286  bool success = 
false;
 
  287  uint32_t rj = 
Bits32(inst, 9, 5);
 
  294  uint32_t offs21 = 
Bits32(inst, 25, 10) + (
Bits32(inst, 4, 0) << 16);
 
  299    uint64_t next_pc = 
pc + llvm::SignExtend64<23>(offs21 << 2);
 
 
  309  bool success = 
false;
 
  317  uint32_t offs21 = 
Bits32(inst, 25, 10) + (
Bits32(inst, 4, 0) << 16);
 
  323    uint64_t next_pc = 
pc + llvm::SignExtend64<23>(offs21 << 2);
 
 
  334  bool success = 
false;
 
  342  uint32_t offs21 = 
Bits32(inst, 25, 10) + (
Bits32(inst, 4, 0) << 16);
 
  348    uint64_t next_pc = 
pc + llvm::SignExtend64<23>(offs21 << 2);
 
 
  359  uint32_t rj = 
Bits32(inst, 9, 5);
 
  360  uint32_t rd = 
Bits32(inst, 4, 0);
 
  361  bool success = 
false;
 
  374  uint64_t next_pc = rj_val + llvm::SignExtend64<18>(
Bits32(inst, 25, 10) << 2);
 
 
  386  uint32_t offs26 = 
Bits32(inst, 25, 10) + (
Bits32(inst, 9, 0) << 16);
 
  387  uint64_t next_pc = 
pc + llvm::SignExtend64<28>(offs26 << 2);
 
 
  403  uint32_t offs26 = 
Bits32(inst, 25, 10) + (
Bits32(inst, 9, 0) << 16);
 
  404  uint64_t next_pc = 
pc + llvm::SignExtend64<28>(offs26 << 2);
 
 
  412  bool success = 
false;
 
  413  uint32_t rj = 
Bits32(inst, 9, 5);
 
  414  uint32_t rd = 
Bits32(inst, 4, 0);
 
  427  if (rj_val == rd_val) {
 
  428    uint64_t next_pc = 
pc + llvm::SignExtend64<18>(
Bits32(inst, 25, 10) << 2);
 
 
  438  bool success = 
false;
 
  439  uint32_t rj = 
Bits32(inst, 9, 5);
 
  440  uint32_t rd = 
Bits32(inst, 4, 0);
 
  453  if (rj_val != rd_val) {
 
  454    uint64_t next_pc = 
pc + llvm::SignExtend64<18>(
Bits32(inst, 25, 10) << 2);
 
 
  464  bool success = 
false;
 
  465  uint32_t rj = 
Bits32(inst, 9, 5);
 
  466  uint32_t rd = 
Bits32(inst, 4, 0);
 
  481  if (rj_val < rd_val) {
 
  482    uint64_t next_pc = 
pc + llvm::SignExtend64<18>(
Bits32(inst, 25, 10) << 2);
 
 
  492  bool success = 
false;
 
  493  uint32_t rj = 
Bits32(inst, 9, 5);
 
  494  uint32_t rd = 
Bits32(inst, 4, 0);
 
  509  if (rj_val >= rd_val) {
 
  510    uint64_t next_pc = 
pc + llvm::SignExtend64<18>(
Bits32(inst, 25, 10) << 2);
 
 
  520  bool success = 
false;
 
  521  uint32_t rj = 
Bits32(inst, 9, 5);
 
  522  uint32_t rd = 
Bits32(inst, 4, 0);
 
  535  if (rj_val < rd_val) {
 
  536    uint64_t next_pc = 
pc + llvm::SignExtend64<18>(
Bits32(inst, 25, 10) << 2);
 
 
  546  bool success = 
false;
 
  547  uint32_t rj = 
Bits32(inst, 9, 5);
 
  548  uint32_t rd = 
Bits32(inst, 4, 0);
 
  561  if (rj_val >= rd_val) {
 
  562    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)
EmulateInstructionLoongArch(const ArchSpec &arch)
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()
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
std::optional< lldb::addr_t > ReadPC()
bool WriteRegisterUnsigned(const Context &context, const RegisterInfo ®_info, uint64_t reg_value)
bool WritePC(lldb::addr_t addr)
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),...