|
LLVM
10.0.0
|
Superclass for all disassemblers. More...
#include "llvm/MC/MCDisassembler/MCDisassembler.h"
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. More... | |
| virtual DecodeStatus | onSymbolStart (StringRef Name, uint64_t &Size, ArrayRef< uint8_t > Bytes, uint64_t Address, raw_ostream &CStream) const |
| May parse any prelude that precedes instructions after the start of a symbol. 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... | |
| MCContext & | getContext () const |
| const MCSubtargetInfo & | getSubtargetInfo () const |
Public Attributes | |
| raw_ostream * | CommentStream = nullptr |
Protected Attributes | |
| const MCSubtargetInfo & | STI |
| std::unique_ptr< MCSymbolizer > | Symbolizer |
Superclass for all disassemblers.
Consumes a memory region and provides an array of assembly instructions.
Definition at line 27 of file MCDisassembler.h.
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.
|
inline |
Definition at line 57 of file MCDisassembler.h.
References llvm::Address, getInstruction(), Name, onSymbolStart(), Size, and ~MCDisassembler().
|
virtualdefault |
Referenced by MCDisassembler().
|
inline |
Definition at line 117 of file MCDisassembler.h.
Referenced by llvm::AMDGPUDisassembler::getRegClassName().
|
pure virtual |
Returns the disassembly of a single instruction.
| 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. |
Implemented in llvm::AMDGPUDisassembler, llvm::LanaiDisassembler, and llvm::AArch64Disassembler.
Referenced by llvm::RuntimeDyldCheckerExprEval::evaluate(), LLVMDisasmInstruction(), and MCDisassembler().
|
inline |
Definition at line 119 of file MCDisassembler.h.
References STI.
Referenced by DecodeHINTInstruction(), DecodeSETPANInstruction(), and DecodeSystemPStateInstruction().
|
virtual |
May parse any prelude that precedes instructions after the start of a symbol.
Needed for some targets, e.g. WebAssembly.
| Name | - The name of 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. |
| CStream | - The stream to print comments and annotations on. |
Definition at line 20 of file MCDisassembler.cpp.
References Success.
Referenced by MCDisassembler().
| 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 43 of file MCDisassembler.cpp.
References Symbolizer.
| void MCDisassembler::tryAddingPcLoadReferenceComment | ( | int64_t | Value, |
| uint64_t | Address | ||
| ) | const |
Definition at line 37 of file MCDisassembler.cpp.
References CommentStream, and Symbolizer.
Referenced by llvm::AMDGPUSymbolizer::AMDGPUSymbolizer(), and tryAddingPcLoadReferenceComment().
| bool MCDisassembler::tryAddingSymbolicOperand | ( | MCInst & | Inst, |
| int64_t | Value, | ||
| uint64_t | Address, | ||
| bool | IsBranch, | ||
| uint64_t | Offset, | ||
| uint64_t | InstSize | ||
| ) | const |
Definition at line 27 of file MCDisassembler.cpp.
References CommentStream, and Symbolizer.
Referenced by llvm::AMDGPUSymbolizer::AMDGPUSymbolizer(), DecodeAddSubImmShift(), DecodeAdrInstruction(), decodeBranch(), DecodePCRelLabel19(), DecodeTestAndBranch(), DecodeUnconditionalBranch(), DecodeUnsignedLdStInstruction(), and tryAddingSymbolicOperand().
|
mutable |
Definition at line 123 of file MCDisassembler.h.
Referenced by llvm::AMDGPUDisassembler::createSRegOperand(), llvm::AMDGPUDisassembler::errOperand(), llvm::AArch64Disassembler::getInstruction(), llvm::AMDGPUDisassembler::getInstruction(), tryAddingPcLoadReferenceComment(), and tryAddingSymbolicOperand().
|
protected |
Definition at line 101 of file MCDisassembler.h.
Referenced by llvm::AMDGPUDisassembler::convertMIMGInst(), llvm::AMDGPUDisassembler::convertSDWAInst(), llvm::AMDGPUDisassembler::createRegOperand(), llvm::AMDGPUDisassembler::decodeBoolReg(), llvm::AMDGPUDisassembler::decodeSDWASrc(), llvm::AMDGPUDisassembler::decodeSDWAVopcDst(), llvm::AArch64Disassembler::getInstruction(), llvm::LanaiDisassembler::getInstruction(), llvm::AMDGPUDisassembler::getInstruction(), getSubtargetInfo(), llvm::AMDGPUDisassembler::isGFX10(), llvm::AMDGPUDisassembler::isGFX9(), llvm::AMDGPUDisassembler::isVI(), and llvm::AMDGPUDisassembler::tryDecodeInst().
|
protected |
Definition at line 102 of file MCDisassembler.h.
Referenced by setSymbolizer(), tryAddingPcLoadReferenceComment(), and tryAddingSymbolicOperand().
1.8.13