Path: blob/main/contrib/llvm-project/lldb/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.h
39646 views
//===-- EmulateInstructionMIPS.h ------------------------------------*- C++1//-*-===//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-exception6//7//===----------------------------------------------------------------------===//89#ifndef LLDB_SOURCE_PLUGINS_INSTRUCTION_MIPS_EMULATEINSTRUCTIONMIPS_H10#define LLDB_SOURCE_PLUGINS_INSTRUCTION_MIPS_EMULATEINSTRUCTIONMIPS_H1112namespace llvm {13class MCDisassembler;14class MCSubtargetInfo;15class MCRegisterInfo;16class MCAsmInfo;17class MCContext;18class MCInstrInfo;19class MCInst;20}2122namespace lldb_private {23class OptionValueDictionary;24}2526#include "lldb/Core/EmulateInstruction.h"27#include "lldb/Utility/Status.h"28#include <optional>2930class EmulateInstructionMIPS : public lldb_private::EmulateInstruction {31public:32static void Initialize();3334static void Terminate();3536static llvm::StringRef GetPluginNameStatic() { return "mips32"; }3738static llvm::StringRef GetPluginDescriptionStatic();3940static lldb_private::EmulateInstruction *41CreateInstance(const lldb_private::ArchSpec &arch,42lldb_private::InstructionType inst_type);4344static bool SupportsEmulatingInstructionsOfTypeStatic(45lldb_private::InstructionType inst_type) {46switch (inst_type) {47case lldb_private::eInstructionTypeAny:48case lldb_private::eInstructionTypePrologueEpilogue:49case lldb_private::eInstructionTypePCModifying:50return true;5152case lldb_private::eInstructionTypeAll:53return false;54}55return false;56}5758llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }5960bool SetTargetTriple(const lldb_private::ArchSpec &arch) override;6162EmulateInstructionMIPS(const lldb_private::ArchSpec &arch);6364bool SupportsEmulatingInstructionsOfType(65lldb_private::InstructionType inst_type) override {66return SupportsEmulatingInstructionsOfTypeStatic(inst_type);67}6869bool ReadInstruction() override;7071bool EvaluateInstruction(uint32_t evaluate_options) override;7273bool SetInstruction(const lldb_private::Opcode &insn_opcode,74const lldb_private::Address &inst_addr,75lldb_private::Target *target) override;7677bool TestEmulation(lldb_private::Stream &out_stream,78lldb_private::ArchSpec &arch,79lldb_private::OptionValueDictionary *test_data) override {80return false;81}8283std::optional<lldb_private::RegisterInfo>84GetRegisterInfo(lldb::RegisterKind reg_kind, uint32_t reg_num) override;8586bool87CreateFunctionEntryUnwind(lldb_private::UnwindPlan &unwind_plan) override;8889protected:90typedef struct {91const char *op_name;92bool (EmulateInstructionMIPS::*callback)(llvm::MCInst &insn);93const char *insn_name;94} MipsOpcode;9596static MipsOpcode *GetOpcodeForInstruction(llvm::StringRef name);9798uint32_t GetSizeOfInstruction(lldb_private::DataExtractor &data,99uint64_t inst_addr);100101bool Emulate_ADDiu(llvm::MCInst &insn);102103bool Emulate_SUBU_ADDU(llvm::MCInst &insn);104105bool Emulate_LUI(llvm::MCInst &insn);106107bool Emulate_SW(llvm::MCInst &insn);108109bool Emulate_LW(llvm::MCInst &insn);110111bool Emulate_ADDIUSP(llvm::MCInst &insn);112113bool Emulate_ADDIUS5(llvm::MCInst &insn);114115bool Emulate_SWSP(llvm::MCInst &insn);116117bool Emulate_SWM16_32(llvm::MCInst &insn);118119bool Emulate_LWSP(llvm::MCInst &insn);120121bool Emulate_LWM16_32(llvm::MCInst &insn);122123bool Emulate_JRADDIUSP(llvm::MCInst &insn);124125bool Emulate_LDST_Imm(llvm::MCInst &insn);126127bool Emulate_LDST_Reg(llvm::MCInst &insn);128129bool Emulate_BXX_3ops(llvm::MCInst &insn);130131bool Emulate_BXX_3ops_C(llvm::MCInst &insn);132133bool Emulate_BXX_2ops(llvm::MCInst &insn);134135bool Emulate_BXX_2ops_C(llvm::MCInst &insn);136137bool Emulate_Bcond_Link_C(llvm::MCInst &insn);138139bool Emulate_Bcond_Link(llvm::MCInst &insn);140141bool Emulate_FP_branch(llvm::MCInst &insn);142143bool Emulate_3D_branch(llvm::MCInst &insn);144145bool Emulate_BAL(llvm::MCInst &insn);146147bool Emulate_BALC(llvm::MCInst &insn);148149bool Emulate_BC(llvm::MCInst &insn);150151bool Emulate_J(llvm::MCInst &insn);152153bool Emulate_JAL(llvm::MCInst &insn);154155bool Emulate_JALR(llvm::MCInst &insn);156157bool Emulate_JIALC(llvm::MCInst &insn);158159bool Emulate_JIC(llvm::MCInst &insn);160161bool Emulate_JR(llvm::MCInst &insn);162163bool Emulate_BC1EQZ(llvm::MCInst &insn);164165bool Emulate_BC1NEZ(llvm::MCInst &insn);166167bool Emulate_BNZB(llvm::MCInst &insn);168169bool Emulate_BNZH(llvm::MCInst &insn);170171bool Emulate_BNZW(llvm::MCInst &insn);172173bool Emulate_BNZD(llvm::MCInst &insn);174175bool Emulate_BZB(llvm::MCInst &insn);176177bool Emulate_BZH(llvm::MCInst &insn);178179bool Emulate_BZW(llvm::MCInst &insn);180181bool Emulate_BZD(llvm::MCInst &insn);182183bool Emulate_MSA_Branch_DF(llvm::MCInst &insn, int element_byte_size,184bool bnz);185186bool Emulate_BNZV(llvm::MCInst &insn);187188bool Emulate_BZV(llvm::MCInst &insn);189190bool Emulate_MSA_Branch_V(llvm::MCInst &insn, bool bnz);191192bool Emulate_B16_MM(llvm::MCInst &insn);193194bool Emulate_Branch_MM(llvm::MCInst &insn);195196bool Emulate_JALRx16_MM(llvm::MCInst &insn);197198bool Emulate_JALx(llvm::MCInst &insn);199200bool Emulate_JALRS(llvm::MCInst &insn);201202bool nonvolatile_reg_p(uint32_t regnum);203204const char *GetRegisterName(unsigned reg_num, bool alternate_name);205206private:207std::unique_ptr<llvm::MCDisassembler> m_disasm;208std::unique_ptr<llvm::MCDisassembler> m_alt_disasm;209std::unique_ptr<llvm::MCSubtargetInfo> m_subtype_info;210std::unique_ptr<llvm::MCSubtargetInfo> m_alt_subtype_info;211std::unique_ptr<llvm::MCRegisterInfo> m_reg_info;212std::unique_ptr<llvm::MCAsmInfo> m_asm_info;213std::unique_ptr<llvm::MCContext> m_context;214std::unique_ptr<llvm::MCInstrInfo> m_insn_info;215uint32_t m_next_inst_size;216bool m_use_alt_disaasm;217};218219#endif // LLDB_SOURCE_PLUGINS_INSTRUCTION_MIPS_EMULATEINSTRUCTIONMIPS_H220221222