Path: blob/main/contrib/llvm-project/lldb/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.h
39654 views
//===-- EmulateInstructionMIPS64.h ------------------------------*- C++ -*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#ifndef LLDB_SOURCE_PLUGINS_INSTRUCTION_MIPS64_EMULATEINSTRUCTIONMIPS64_H9#define LLDB_SOURCE_PLUGINS_INSTRUCTION_MIPS64_EMULATEINSTRUCTIONMIPS64_H1011#include "lldb/Core/EmulateInstruction.h"12#include "lldb/Interpreter/OptionValue.h"13#include "lldb/Utility/Status.h"14#include <optional>1516namespace llvm {17class MCDisassembler;18class MCSubtargetInfo;19class MCRegisterInfo;20class MCAsmInfo;21class MCContext;22class MCInstrInfo;23class MCInst;24} // namespace llvm2526class EmulateInstructionMIPS64 : public lldb_private::EmulateInstruction {27public:28EmulateInstructionMIPS64(const lldb_private::ArchSpec &arch);2930static void Initialize();3132static void Terminate();3334static llvm::StringRef GetPluginNameStatic() { return "mips64"; }3536static llvm::StringRef GetPluginDescriptionStatic();3738static lldb_private::EmulateInstruction *39CreateInstance(const lldb_private::ArchSpec &arch,40lldb_private::InstructionType inst_type);4142static bool SupportsEmulatingInstructionsOfTypeStatic(43lldb_private::InstructionType inst_type) {44switch (inst_type) {45case lldb_private::eInstructionTypeAny:46case lldb_private::eInstructionTypePrologueEpilogue:47case lldb_private::eInstructionTypePCModifying:48return true;4950case lldb_private::eInstructionTypeAll:51return false;52}53return false;54}5556llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }5758bool SetTargetTriple(const lldb_private::ArchSpec &arch) override;5960bool SupportsEmulatingInstructionsOfType(61lldb_private::InstructionType inst_type) override {62return SupportsEmulatingInstructionsOfTypeStatic(inst_type);63}6465bool ReadInstruction() override;6667bool EvaluateInstruction(uint32_t evaluate_options) override;6869bool TestEmulation(lldb_private::Stream &out_stream,70lldb_private::ArchSpec &arch,71lldb_private::OptionValueDictionary *test_data) override {72return false;73}7475std::optional<lldb_private::RegisterInfo>76GetRegisterInfo(lldb::RegisterKind reg_kind, uint32_t reg_num) override;7778bool79CreateFunctionEntryUnwind(lldb_private::UnwindPlan &unwind_plan) override;8081protected:82typedef struct {83const char *op_name;84bool (EmulateInstructionMIPS64::*callback)(llvm::MCInst &insn);85const char *insn_name;86} MipsOpcode;8788static MipsOpcode *GetOpcodeForInstruction(llvm::StringRef op_name);8990bool Emulate_DADDiu(llvm::MCInst &insn);9192bool Emulate_DSUBU_DADDU(llvm::MCInst &insn);9394bool Emulate_LUI(llvm::MCInst &insn);9596bool Emulate_SD(llvm::MCInst &insn);9798bool Emulate_LD(llvm::MCInst &insn);99100bool Emulate_LDST_Imm(llvm::MCInst &insn);101102bool Emulate_LDST_Reg(llvm::MCInst &insn);103104bool Emulate_BXX_3ops(llvm::MCInst &insn);105106bool Emulate_BXX_3ops_C(llvm::MCInst &insn);107108bool Emulate_BXX_2ops(llvm::MCInst &insn);109110bool Emulate_BXX_2ops_C(llvm::MCInst &insn);111112bool Emulate_Bcond_Link_C(llvm::MCInst &insn);113114bool Emulate_Bcond_Link(llvm::MCInst &insn);115116bool Emulate_FP_branch(llvm::MCInst &insn);117118bool Emulate_3D_branch(llvm::MCInst &insn);119120bool Emulate_BAL(llvm::MCInst &insn);121122bool Emulate_BALC(llvm::MCInst &insn);123124bool Emulate_BC(llvm::MCInst &insn);125126bool Emulate_J(llvm::MCInst &insn);127128bool Emulate_JAL(llvm::MCInst &insn);129130bool Emulate_JALR(llvm::MCInst &insn);131132bool Emulate_JIALC(llvm::MCInst &insn);133134bool Emulate_JIC(llvm::MCInst &insn);135136bool Emulate_JR(llvm::MCInst &insn);137138bool Emulate_BC1EQZ(llvm::MCInst &insn);139140bool Emulate_BC1NEZ(llvm::MCInst &insn);141142bool Emulate_BNZB(llvm::MCInst &insn);143144bool Emulate_BNZH(llvm::MCInst &insn);145146bool Emulate_BNZW(llvm::MCInst &insn);147148bool Emulate_BNZD(llvm::MCInst &insn);149150bool Emulate_BZB(llvm::MCInst &insn);151152bool Emulate_BZH(llvm::MCInst &insn);153154bool Emulate_BZW(llvm::MCInst &insn);155156bool Emulate_BZD(llvm::MCInst &insn);157158bool Emulate_MSA_Branch_DF(llvm::MCInst &insn, int element_byte_size,159bool bnz);160161bool Emulate_BNZV(llvm::MCInst &insn);162163bool Emulate_BZV(llvm::MCInst &insn);164165bool Emulate_MSA_Branch_V(llvm::MCInst &insn, bool bnz);166167bool nonvolatile_reg_p(uint64_t regnum);168169const char *GetRegisterName(unsigned reg_num, bool alternate_name);170171private:172std::unique_ptr<llvm::MCDisassembler> m_disasm;173std::unique_ptr<llvm::MCSubtargetInfo> m_subtype_info;174std::unique_ptr<llvm::MCRegisterInfo> m_reg_info;175std::unique_ptr<llvm::MCAsmInfo> m_asm_info;176std::unique_ptr<llvm::MCContext> m_context;177std::unique_ptr<llvm::MCInstrInfo> m_insn_info;178};179180#endif // LLDB_SOURCE_PLUGINS_INSTRUCTION_MIPS64_EMULATEINSTRUCTIONMIPS64_H181182183