LLVM  8.0.1
Public Types | Public Member Functions | Public Attributes | Protected Attributes | List of all members
llvm::MCDisassembler Class Referenceabstract

Superclass for all disassemblers. More...

#include "llvm/MC/MCDisassembler/MCDisassembler.h"

Inheritance diagram for llvm::MCDisassembler:
Inheritance graph
[legend]
Collaboration diagram for llvm::MCDisassembler:
Collaboration graph
[legend]

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 &VStream, raw_ostream &CStream) const =0
 Returns the disassembly of a single instruction. More...
 
bool tryAddingSymbolicOperand (MCInst &Inst, int64_t Value, uint64_t Address, bool IsBranch, uint64_t Offset, 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. More...
 
MCContextgetContext () const
 
const MCSubtargetInfogetSubtargetInfo () const
 

Public Attributes

raw_ostreamCommentStream = nullptr
 

Protected Attributes

const MCSubtargetInfoSTI
 
std::unique_ptr< MCSymbolizerSymbolizer
 

Detailed Description

Superclass for all disassemblers.

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

Definition at line 27 of file MCDisassembler.h.

Member Enumeration Documentation

◆ 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 51 of file MCDisassembler.h.

Constructor & Destructor Documentation

◆ MCDisassembler()

llvm::MCDisassembler::MCDisassembler ( const MCSubtargetInfo STI,
MCContext Ctx 
)
inline

Definition at line 57 of file MCDisassembler.h.

References llvm::Address, getInstruction(), Size, and ~MCDisassembler().

◆ ~MCDisassembler()

MCDisassembler::~MCDisassembler ( )
virtualdefault

Referenced by MCDisassembler().

Member Function Documentation

◆ getContext()

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

Definition at line 104 of file MCDisassembler.h.

Referenced by llvm::AMDGPUDisassembler::getRegClassName().

◆ getInstruction()

virtual DecodeStatus llvm::MCDisassembler::getInstruction ( MCInst Instr,
uint64_t &  Size,
ArrayRef< uint8_t >  Bytes,
uint64_t  Address,
raw_ostream VStream,
raw_ostream CStream 
) const
pure virtual

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.
VStream- The stream to print warnings and diagnostic messages on.
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::AMDGPUDisassembler, llvm::LanaiDisassembler, and llvm::AArch64Disassembler.

Referenced by llvm::RuntimeDyldCheckerExprEval::evaluate(), LLVMDisasmInstruction(), and MCDisassembler().

◆ getSubtargetInfo()

const MCSubtargetInfo& llvm::MCDisassembler::getSubtargetInfo ( ) const
inline

Definition at line 106 of file MCDisassembler.h.

References STI.

Referenced by DecodeHINTInstruction(), DecodeSETPANInstruction(), and DecodeSystemPStateInstruction().

◆ 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 36 of file MCDisassembler.cpp.

References Symbolizer.

Referenced by LLVMCreateDisasmCPUFeatures().

◆ tryAddingPcLoadReferenceComment()

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

◆ tryAddingSymbolicOperand()

bool MCDisassembler::tryAddingSymbolicOperand ( MCInst Inst,
int64_t  Value,
uint64_t  Address,
bool  IsBranch,
uint64_t  Offset,
uint64_t  InstSize 
) const

Member Data Documentation

◆ CommentStream

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

◆ STI

const MCSubtargetInfo& llvm::MCDisassembler::STI
protected

◆ Symbolizer

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

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