LLVM: llvm::MCDisassembler Class Reference (original) (raw)

Superclass for all disassemblers. More...

#include "[llvm/MC/MCDisassembler/MCDisassembler.h](MCDisassembler%5F8h%5Fsource.html)"

Public Types
enum DecodeStatus { Fail = 0 , SoftFail = 1 , Success = 3 }
Ternary decode status. More...
Public Member Functions
MCDisassembler (const MCSubtargetInfo &STI, MCContext &Ctx)
virtual ~MCDisassembler ()
virtual DecodeStatus getInstruction (MCInst &Instr, uint64_t &Size, ArrayRef< uint8_t > Bytes, uint64_t Address, raw_ostream &CStream) const =0
Returns the disassembly of a single instruction.
virtual DecodeStatus getInstructionBundle (MCInst &Instr, uint64_t &Size, ArrayRef< uint8_t > Bytes, uint64_t Address, raw_ostream &CStream) const
Returns the disassembly of an instruction bundle for VLIW architectures like Hexagon.
virtual Expected< bool > onSymbolStart (SymbolInfoTy &Symbol, uint64_t &Size, ArrayRef< uint8_t > Bytes, uint64_t Address) const
Used to perform separate target specific disassembly for a particular symbol.
virtual uint64_t suggestBytesToSkip (ArrayRef< uint8_t > Bytes, uint64_t Address) const
Suggest a distance to skip in a buffer of data to find the next place to look for the start of an instruction.
bool tryAddingSymbolicOperand (MCInst &Inst, int64_t Value, uint64_t Address, bool IsBranch, uint64_t Offset, uint64_t OpSize, uint64_t InstSize) const
void tryAddingPcLoadReferenceComment (int64_t Value, uint64_t Address) const
void setSymbolizer (std::unique_ptr< MCSymbolizer > Symzer)
Set Symzer as the current symbolizer.
MCContext & getContext () const
const MCSubtargetInfo & getSubtargetInfo () const
virtual void setABIVersion (unsigned Version)
ELF-specific, set the ABI version from the object header.

Superclass for all disassemblers.

Consumes a memory region and provides an array of assembly instructions.

Definition at line 85 of file MCDisassembler.h.

DecodeStatus

Ternary decode status.

Most backends will just use Fail and Success, however some have a concept of an instruction with understandable semantics but which is architecturally incorrect. An example of this is ARM UNPREDICTABLE instructions which are disassemblable but cause undefined behaviour.

Because it makes sense to disassemble these instructions, there is a "soft fail" failure mode that indicates the MCInst& is valid but architecturally incorrect.

The enum numbers are deliberately chosen such that reduction from Success->SoftFail ->Fail can be done with a simple bitwise-AND:

LEFT & TOP = | Success Unpredictable Fail -----------—+--------------------------------— Success | Success Unpredictable Fail Unpredictable | Unpredictable Unpredictable Fail Fail | Fail Fail Fail

An easy way of encoding this is as 0b11, 0b01, 0b00 for Success, SoftFail, Fail respectively.

Enumerator
Fail
SoftFail
Success

Definition at line 109 of file MCDisassembler.h.

~MCDisassembler()

MCDisassembler::~MCDisassembler ( ) virtualdefault

getContext()

MCContext & llvm::MCDisassembler::getContext ( ) const inline

getInstruction()

Returns the disassembly of a single instruction.

Parameters

Instr - An MCInst to populate with the contents of the instruction.
Size - A value to populate with the size of the instruction, or the number of bytes consumed while attempting to decode an invalid instruction.
Address - The address, in the memory space of region, of the first byte of the instruction.
Bytes - A reference to the actual bytes of the instruction.
CStream - The stream to print comments and annotations on.

Returns

- MCDisassembler::Success if the instruction is valid, MCDisassembler::SoftFail if the instruction was disassemblable but invalid, MCDisassembler::Fail if the instruction was invalid.

Implemented in llvm::AArch64Disassembler, llvm::AMDGPUDisassembler, llvm::LanaiDisassembler, and M68kDisassembler.

References llvm::Address, and Size.

Referenced by llvm::orc::addFunctionPointerRelocationsToCurrentSymbol(), and LLVMDisasmInstruction().

getInstructionBundle()

Returns the disassembly of an instruction bundle for VLIW architectures like Hexagon.

Parameters

Instr - An MCInst to populate with the contents of the Bundle with sub-instructions encoded as Inst operands.

Definition at line 144 of file MCDisassembler.h.

References llvm::Address, Fail, and Size.

getSubtargetInfo()

Definition at line 230 of file MCDisassembler.h.

References STI.

Referenced by llvm::orc::addFunctionPointerRelocationsToCurrentSymbol(), DecodeCopMemInstruction(), DecodeCoprocessor(), DecodeForVMRSandVMSR(), DecodeGPRF16RegisterClass(), DecodeGPRF32RegisterClass(), DecodeGPRPairRegisterClass(), DecodeGPRRegisterClass(), DecodeHINTInstruction(), DecodeMSRMask(), DecoderGPRRegisterClass(), DecodeSETPANInstruction(), DecodeSRRegisterClass(), DecodeSystemPStateImm0_15Instruction(), DecodeSystemPStateImm0_1Instruction(), DecodeT2LoadImm12(), DecodeT2LoadImm8(), DecodeT2LoadLabel(), DecodeT2LoadShift(), DecodeThumbTableBranch(), decodeUImmLog2XLenOperand(), DecodeURRegisterClass(), DecodeVCVTD(), DecodeVCVTQ(), DecodeVSTRVLDR_SYSREG(), decodeZcmpRlist(), and PermitsD32().

onSymbolStart()

Used to perform separate target specific disassembly for a particular symbol.

May parse any prelude that precedes instructions after the start of a symbol, or the entire symbol. This is used for example by WebAssembly to decode preludes.

Base implementation returns false. So all targets by default decline to treat symbols separately.

Parameters

Symbol - The symbol.
Size - The number of bytes consumed.
Address - The address, in the memory space of region, of the first byte of the symbol.
Bytes - A reference to the actual bytes at the symbol location.

Returns

- True if this symbol triggered some target specific disassembly for this symbol. Size must be set with the number of bytes consumed.

Reimplemented in llvm::AMDGPUDisassembler.

Definition at line 16 of file MCDisassembler.cpp.

References llvm::Address, and Size.

setABIVersion()

virtual void llvm::MCDisassembler::setABIVersion ( unsigned Version) inlinevirtual

setSymbolizer()

void MCDisassembler::setSymbolizer ( std::unique_ptr< MCSymbolizer > Symzer )

Set Symzer as the current symbolizer.

This takes ownership of Symzer, and deletes the previously set one.

Definition at line 49 of file MCDisassembler.cpp.

References Symbolizer.

suggestBytesToSkip()

Suggest a distance to skip in a buffer of data to find the next place to look for the start of an instruction.

For example, if all instructions have a fixed alignment, this might advance to the next multiple of that alignment.

If not overridden, the default is 1.

Parameters

Address - The address, in the memory space of region, of the starting point (typically the first byte of something that did not decode as a valid instruction at all).
Bytes - A reference to the actual bytes at Address. May be needed in order to determine the width of an unrecognized instruction (e.g. in Thumb this is a simple consistent criterion that doesn't require knowing the specific instruction). The caller can pass as much data as they have available, and the function is required to make a reasonable default choice if not enough data is available to make a better one.

Returns

- A number of bytes to skip. Must always be greater than zero. May be greater than the size of Bytes.

Reimplemented in llvm::AArch64Disassembler.

Definition at line 23 of file MCDisassembler.cpp.

References llvm::Address.

tryAddingPcLoadReferenceComment()

void MCDisassembler::tryAddingPcLoadReferenceComment ( int64_t Value,
uint64_t Address ) const

tryAddingSymbolicOperand()

Definition at line 28 of file MCDisassembler.cpp.

References llvm::Address, assert(), CommentStream, llvm::Offset, and Symbolizer.

Referenced by DecodeAddSubImmShift(), DecodeAdrInstruction(), DecodeMoveImmInstruction(), DecodePCRelLabel16(), DecodePCRelLabel19(), DecodePCRelLabel9(), DecodeSymbolicOperand(), DecodeTestAndBranch(), DecodeUnconditionalBranch(), DecodeUnsignedLdStInstruction(), translateImmediate(), translateRMMemory(), tryAddingSymbolicOperand(), tryAddingSymbolicOperand(), tryAddingSymbolicOperand(), tryAddingSymbolicOperand(), and tryAddingSymbolicOperand().

CommentStream

raw_ostream* llvm::MCDisassembler::CommentStream = nullptr mutable

STI

Definition at line 213 of file MCDisassembler.h.

Referenced by llvm::AArch64Disassembler::AArch64Disassembler(), llvm::AMDGPUDisassembler::AMDGPUDisassembler(), llvm::AMDGPUDisassembler::convertEXPInst(), llvm::AMDGPUDisassembler::convertMIMGInst(), llvm::AMDGPUDisassembler::convertSDWAInst(), llvm::AMDGPUDisassembler::createRegOperand(), llvm::AMDGPUDisassembler::decodeBoolReg(), llvm::AMDGPUDisassembler::decodeCOMPUTE_PGM_RSRC1(), llvm::AMDGPUDisassembler::decodeLiteral64Constant(), llvm::AMDGPUDisassembler::decodeMandatoryLiteralConstant(), llvm::AMDGPUDisassembler::decodeNonVGPRSrcOp(), llvm::AMDGPUDisassembler::decodeSDWASrc(), llvm::AMDGPUDisassembler::decodeSDWAVopcDst(), llvm::AArch64Disassembler::getInstruction(), llvm::AMDGPUDisassembler::getInstruction(), llvm::LanaiDisassembler::getInstruction(), M68kDisassembler::getInstruction(), getSubtargetInfo(), llvm::AMDGPUDisassembler::hasArchitectedFlatScratch(), llvm::AMDGPUDisassembler::hasKernargPreload(), llvm::AMDGPUDisassembler::isGFX10(), llvm::AMDGPUDisassembler::isGFX10Plus(), llvm::AMDGPUDisassembler::isGFX11(), llvm::AMDGPUDisassembler::isGFX11Plus(), llvm::AMDGPUDisassembler::isGFX12(), llvm::AMDGPUDisassembler::isGFX1250(), llvm::AMDGPUDisassembler::isGFX12Plus(), llvm::AMDGPUDisassembler::isGFX9(), llvm::AMDGPUDisassembler::isGFX90A(), llvm::AMDGPUDisassembler::isGFX9Plus(), llvm::AMDGPUDisassembler::isVI(), llvm::LanaiDisassembler::LanaiDisassembler(), M68kDisassembler::M68kDisassembler(), MCDisassembler(), and llvm::AMDGPUDisassembler::tryDecodeInst().

Symbolizer

std::unique_ptr<MCSymbolizer> llvm::MCDisassembler::Symbolizer protected

The documentation for this class was generated from the following files: