2#ifndef ROSE_BinaryAnalysis_Disassembler_Mips_H
3#define ROSE_BinaryAnalysis_Disassembler_Mips_H
4#include <featureTests.h>
5#ifdef ROSE_ENABLE_BINARY_ANALYSIS
6#include <Rose/BinaryAnalysis/Disassembler/Base.h>
8#include <Rose/BinaryAnalysis/Architecture/BasicTypes.h>
9#include <Rose/BinaryAnalysis/ByteOrder.h>
10#include <Rose/BinaryAnalysis/InstructionEnumsMips.h>
12#include <SageBuilderAsm.h>
15namespace BinaryAnalysis {
16namespace Disassembler {
54 virtual size_t nDelaySlots(MipsInstructionKind);
66 enum Architecture { Release1, Release2, Release3, Micro };
67 Decoder(Architecture arch,
unsigned match,
unsigned mask): arch(arch), match(match), mask(mask) {}
Virtual base class for instruction disassemblers.
Exception thrown by the disassemblers.
Interface for disassembling a single instruction.
MIPS32 instruction decoder.
SgAsmRegisterReferenceExpression * makeHwRegister(unsigned regnum) const
Create a new register reference for a hardware register.
SgAsmMipsInstruction * makeInstruction(rose_addr_t insn_va, MipsInstructionKind, SgAsmExpression *arg1=NULL, SgAsmExpression *arg2=NULL, SgAsmExpression *arg3=NULL, SgAsmExpression *arg4=NULL) const
Create a new instruction.
void insert_idis(Decoder *, bool replace=false)
Insert an instruction-specific disassembler.
std::vector< Decoder * > idis_table
Table of instruction-specific disassemblers.
SgAsmRegisterReferenceExpression * makeFpccRegister(rose_addr_t insn_va, unsigned cc) const
Create a new floating point condition flag register reference expression.
SgAsmType * makeType(MipsDataFormat) const
Create a ROSE type form a MIPS data format.
SgAsmBinaryAdd * makeRegisterIndexed(rose_addr_t insn_va, unsigned base_gprnum, unsigned index_gprnum) const
Build a register index expression.
static Ptr instance(const Architecture::BaseConstPtr &)
Allocating constructor for MIPS decoder.
SgAsmRegisterReferenceExpression * makeCp2Register(unsigned regnum) const
Create a new register reference for Coprocessor 2.
SgAsmIntegerValueExpression * makeImmediate8(unsigned value, size_t bit_offset, size_t nbits) const
Create a new 8-bit value expression from an 8-bit value.
SgAsmMemoryReferenceExpression * makeMemoryReference(SgAsmExpression *addr, SgAsmType *type) const
Build a memory reference expression.
SgAsmIntegerValueExpression * makeBranchTargetAbsolute(rose_addr_t insn_va, unsigned insn_index, size_t bit_offset, size_t nbits) const
Create a 32-bit branch address from an instruction index value.
SgAsmRegisterReferenceExpression * makeFpRegister(rose_addr_t insn_va, unsigned regnum, MipsDataFormat) const
Create a new floating point register reference expression.
SgAsmRegisterReferenceExpression * makeRegister(rose_addr_t insn_va, unsigned regnum) const
Create a new general purpose register reference expression.
virtual Base::Ptr clone() const override
Creates a new copy of a disassembler.
SgAsmRegisterReferenceExpression * makeCp0Register(rose_addr_t insn_va, unsigned regnum, unsigned sel) const
Create a new register reference for Coprocessor 0.
Decoder * find_idis(rose_addr_t insn_va, unsigned insn_bits) const
Find an instruction-specific disassembler.
SgAsmRegisterReferenceExpression * makeShadowRegister(rose_addr_t insn_va, unsigned regnum) const
Create a new register reference for a shadow GPR.
SgAsmIntegerValueExpression * makeBranchTargetRelative(rose_addr_t insn_va, unsigned offset16, size_t bit_offset, size_t nbits) const
Create a 32-bit PC-relative branch target address from a 16-bit offset.
virtual SgAsmInstruction * makeUnknownInstruction(const Exception &) override
Makes an unknown instruction from an exception.
SgAsmIntegerValueExpression * makeImmediate32(unsigned value, size_t bit_offset, size_t nbits) const
Create a new 32-bit value expression from a 32-bit value.
SgAsmBinaryAdd * makeRegisterOffset(rose_addr_t insn_va, unsigned gprnum, unsigned offset16) const
Build an expression for an offset from a register.
SgAsmRegisterReferenceExpression * makeCp2ccRegister(unsigned cc) const
Create a new register reference for a COP2 condition code.
virtual SgAsmInstruction * disassembleOne(const MemoryMap::Ptr &, rose_addr_t start_va, AddressSet *successors=NULL) override
This is the lowest level disassembly function and is implemented in the architecture-specific subclas...
SgAsmMipsInstruction * disassemble_insn(Address insn_va, unsigned insn_bits, const std::vector< uint8_t > &bytes) const
Disassemble a single instruction.
SgAsmIntegerValueExpression * makeImmediate16(unsigned value, size_t bit_offset, size_t nbits) const
Create a new 16-bit value expression from a 16-bit value.
Reference-counting intrusive smart pointer.
Expression that adds two operands.
Base class for expressions.
Base class for machine instructions.
Base class for integer values.
Reference to memory locations.
Represents one MIPS machine instruction.
Base class for references to a machine register.
Base class for binary types.
std::shared_ptr< const Base > BaseConstPtr
Reference counted pointer for Architecture::Base.
std::uint64_t Address
Address.