LLVM 20.0.0git
Classes | Macros | Typedefs | Functions
Collaboration diagram for Disassembler:

Classes

struct  LLVMOpInfoSymbol1
 The initial support in LLVM MC for the most general form of a relocatable expression is "AddSymbol - SubtractSymbol + Offset". More...
 
struct  LLVMOpInfo1
 

Macros

#define LLVMDisassembler_Option_UseMarkup   1
 
#define LLVMDisassembler_Option_PrintImmHex   2
 
#define LLVMDisassembler_Option_AsmPrinterVariant   4
 
#define LLVMDisassembler_Option_SetInstrComments   8
 
#define LLVMDisassembler_Option_PrintLatency   16
 
#define LLVMDisassembler_VariantKind_None   0 /* all targets */
 The operand VariantKinds for symbolic disassembly.
 
#define LLVMDisassembler_VariantKind_ARM_HI16   1 /* :upper16: */
 The ARM target VariantKinds.
 
#define LLVMDisassembler_VariantKind_ARM_LO16   2 /* :lower16: */
 
#define LLVMDisassembler_VariantKind_ARM64_PAGE   1 /* @page */
 The ARM64 target VariantKinds.
 
#define LLVMDisassembler_VariantKind_ARM64_PAGEOFF   2 /* @pageoff */
 
#define LLVMDisassembler_VariantKind_ARM64_GOTPAGE   3 /* @gotpage */
 
#define LLVMDisassembler_VariantKind_ARM64_GOTPAGEOFF   4 /* @gotpageoff */
 
#define LLVMDisassembler_VariantKind_ARM64_TLVP   5 /* @tvlppage */
 
#define LLVMDisassembler_VariantKind_ARM64_TLVOFF   6 /* @tvlppageoff */
 
#define LLVMDisassembler_ReferenceType_InOut_None   0
 The reference types on input and output.
 
#define LLVMDisassembler_ReferenceType_In_Branch   1
 
#define LLVMDisassembler_ReferenceType_In_PCrel_Load   2
 
#define LLVMDisassembler_ReferenceType_In_ARM64_ADRP   0x100000001
 
#define LLVMDisassembler_ReferenceType_In_ARM64_ADDXri   0x100000002
 
#define LLVMDisassembler_ReferenceType_In_ARM64_LDRXui   0x100000003
 
#define LLVMDisassembler_ReferenceType_In_ARM64_LDRXl   0x100000004
 
#define LLVMDisassembler_ReferenceType_In_ARM64_ADR   0x100000005
 
#define LLVMDisassembler_ReferenceType_Out_SymbolStub   1
 
#define LLVMDisassembler_ReferenceType_Out_LitPool_SymAddr   2
 
#define LLVMDisassembler_ReferenceType_Out_LitPool_CstrAddr   3
 
#define LLVMDisassembler_ReferenceType_Out_Objc_CFString_Ref   4
 
#define LLVMDisassembler_ReferenceType_Out_Objc_Message   5
 
#define LLVMDisassembler_ReferenceType_Out_Objc_Message_Ref   6
 
#define LLVMDisassembler_ReferenceType_Out_Objc_Selector_Ref   7
 
#define LLVMDisassembler_ReferenceType_Out_Objc_Class_Ref   8
 
#define LLVMDisassembler_ReferenceType_DeMangled_Name   9
 

Typedefs

typedef void * LLVMDisasmContextRef
 An opaque reference to a disassembler context.
 
typedef int(* LLVMOpInfoCallback) (void *DisInfo, uint64_t PC, uint64_t Offset, uint64_t OpSize, uint64_t InstSize, int TagType, void *TagBuf)
 The type for the operand information call back function.
 
typedef const char *(* LLVMSymbolLookupCallback) (void *DisInfo, uint64_t ReferenceValue, uint64_t *ReferenceType, uint64_t ReferencePC, const char **ReferenceName)
 The type for the symbol lookup function.
 

Functions

LLVM_C_EXTERN_C_BEGIN LLVMDisasmContextRef LLVMCreateDisasm (const char *TripleName, void *DisInfo, int TagType, LLVMOpInfoCallback GetOpInfo, LLVMSymbolLookupCallback SymbolLookUp)
 Create a disassembler for the TripleName.
 
LLVMDisasmContextRef LLVMCreateDisasmCPU (const char *Triple, const char *CPU, void *DisInfo, int TagType, LLVMOpInfoCallback GetOpInfo, LLVMSymbolLookupCallback SymbolLookUp)
 Create a disassembler for the TripleName and a specific CPU.
 
LLVMDisasmContextRef LLVMCreateDisasmCPUFeatures (const char *Triple, const char *CPU, const char *Features, void *DisInfo, int TagType, LLVMOpInfoCallback GetOpInfo, LLVMSymbolLookupCallback SymbolLookUp)
 Create a disassembler for the TripleName, a specific CPU and specific feature string.
 
int LLVMSetDisasmOptions (LLVMDisasmContextRef DC, uint64_t Options)
 Set the disassembler's options.
 
void LLVMDisasmDispose (LLVMDisasmContextRef DC)
 Dispose of a disassembler context.
 
size_t LLVMDisasmInstruction (LLVMDisasmContextRef DC, uint8_t *Bytes, uint64_t BytesSize, uint64_t PC, char *OutString, size_t OutStringSize)
 Disassemble a single instruction using the disassembler context specified in the parameter DC.
 

Detailed Description

Macro Definition Documentation

◆ LLVMDisassembler_Option_AsmPrinterVariant

#define LLVMDisassembler_Option_AsmPrinterVariant   4

Definition at line 79 of file Disassembler.h.

◆ LLVMDisassembler_Option_PrintImmHex

#define LLVMDisassembler_Option_PrintImmHex   2

Definition at line 77 of file Disassembler.h.

◆ LLVMDisassembler_Option_PrintLatency

#define LLVMDisassembler_Option_PrintLatency   16

Definition at line 83 of file Disassembler.h.

◆ LLVMDisassembler_Option_SetInstrComments

#define LLVMDisassembler_Option_SetInstrComments   8

Definition at line 81 of file Disassembler.h.

◆ LLVMDisassembler_Option_UseMarkup

#define LLVMDisassembler_Option_UseMarkup   1

Definition at line 75 of file Disassembler.h.

◆ LLVMDisassembler_ReferenceType_DeMangled_Name

#define LLVMDisassembler_ReferenceType_DeMangled_Name   9

Definition at line 164 of file DisassemblerTypes.h.

◆ LLVMDisassembler_ReferenceType_In_ARM64_ADDXri

#define LLVMDisassembler_ReferenceType_In_ARM64_ADDXri   0x100000002

Definition at line 137 of file DisassemblerTypes.h.

◆ LLVMDisassembler_ReferenceType_In_ARM64_ADR

#define LLVMDisassembler_ReferenceType_In_ARM64_ADR   0x100000005

Definition at line 143 of file DisassemblerTypes.h.

◆ LLVMDisassembler_ReferenceType_In_ARM64_ADRP

#define LLVMDisassembler_ReferenceType_In_ARM64_ADRP   0x100000001

Definition at line 135 of file DisassemblerTypes.h.

◆ LLVMDisassembler_ReferenceType_In_ARM64_LDRXl

#define LLVMDisassembler_ReferenceType_In_ARM64_LDRXl   0x100000004

Definition at line 141 of file DisassemblerTypes.h.

◆ LLVMDisassembler_ReferenceType_In_ARM64_LDRXui

#define LLVMDisassembler_ReferenceType_In_ARM64_LDRXui   0x100000003

Definition at line 139 of file DisassemblerTypes.h.

◆ LLVMDisassembler_ReferenceType_In_Branch

#define LLVMDisassembler_ReferenceType_In_Branch   1

Definition at line 130 of file DisassemblerTypes.h.

◆ LLVMDisassembler_ReferenceType_In_PCrel_Load

#define LLVMDisassembler_ReferenceType_In_PCrel_Load   2

Definition at line 132 of file DisassemblerTypes.h.

◆ LLVMDisassembler_ReferenceType_InOut_None

#define LLVMDisassembler_ReferenceType_InOut_None   0

The reference types on input and output.

Definition at line 127 of file DisassemblerTypes.h.

◆ LLVMDisassembler_ReferenceType_Out_LitPool_CstrAddr

#define LLVMDisassembler_ReferenceType_Out_LitPool_CstrAddr   3

Definition at line 150 of file DisassemblerTypes.h.

◆ LLVMDisassembler_ReferenceType_Out_LitPool_SymAddr

#define LLVMDisassembler_ReferenceType_Out_LitPool_SymAddr   2

Definition at line 148 of file DisassemblerTypes.h.

◆ LLVMDisassembler_ReferenceType_Out_Objc_CFString_Ref

#define LLVMDisassembler_ReferenceType_Out_Objc_CFString_Ref   4

Definition at line 153 of file DisassemblerTypes.h.

◆ LLVMDisassembler_ReferenceType_Out_Objc_Class_Ref

#define LLVMDisassembler_ReferenceType_Out_Objc_Class_Ref   8

Definition at line 161 of file DisassemblerTypes.h.

◆ LLVMDisassembler_ReferenceType_Out_Objc_Message

#define LLVMDisassembler_ReferenceType_Out_Objc_Message   5

Definition at line 155 of file DisassemblerTypes.h.

◆ LLVMDisassembler_ReferenceType_Out_Objc_Message_Ref

#define LLVMDisassembler_ReferenceType_Out_Objc_Message_Ref   6

Definition at line 157 of file DisassemblerTypes.h.

◆ LLVMDisassembler_ReferenceType_Out_Objc_Selector_Ref

#define LLVMDisassembler_ReferenceType_Out_Objc_Selector_Ref   7

Definition at line 159 of file DisassemblerTypes.h.

◆ LLVMDisassembler_ReferenceType_Out_SymbolStub

#define LLVMDisassembler_ReferenceType_Out_SymbolStub   1

Definition at line 146 of file DisassemblerTypes.h.

◆ LLVMDisassembler_VariantKind_ARM64_GOTPAGE

#define LLVMDisassembler_VariantKind_ARM64_GOTPAGE   3 /* @gotpage */

Definition at line 101 of file DisassemblerTypes.h.

◆ LLVMDisassembler_VariantKind_ARM64_GOTPAGEOFF

#define LLVMDisassembler_VariantKind_ARM64_GOTPAGEOFF   4 /* @gotpageoff */

Definition at line 102 of file DisassemblerTypes.h.

◆ LLVMDisassembler_VariantKind_ARM64_PAGE

#define LLVMDisassembler_VariantKind_ARM64_PAGE   1 /* @page */

The ARM64 target VariantKinds.

Definition at line 99 of file DisassemblerTypes.h.

◆ LLVMDisassembler_VariantKind_ARM64_PAGEOFF

#define LLVMDisassembler_VariantKind_ARM64_PAGEOFF   2 /* @pageoff */

Definition at line 100 of file DisassemblerTypes.h.

◆ LLVMDisassembler_VariantKind_ARM64_TLVOFF

#define LLVMDisassembler_VariantKind_ARM64_TLVOFF   6 /* @tvlppageoff */

Definition at line 104 of file DisassemblerTypes.h.

◆ LLVMDisassembler_VariantKind_ARM64_TLVP

#define LLVMDisassembler_VariantKind_ARM64_TLVP   5 /* @tvlppage */

Definition at line 103 of file DisassemblerTypes.h.

◆ LLVMDisassembler_VariantKind_ARM_HI16

#define LLVMDisassembler_VariantKind_ARM_HI16   1 /* :upper16: */

The ARM target VariantKinds.

Definition at line 93 of file DisassemblerTypes.h.

◆ LLVMDisassembler_VariantKind_ARM_LO16

#define LLVMDisassembler_VariantKind_ARM_LO16   2 /* :lower16: */

Definition at line 94 of file DisassemblerTypes.h.

◆ LLVMDisassembler_VariantKind_None

#define LLVMDisassembler_VariantKind_None   0 /* all targets */

The operand VariantKinds for symbolic disassembly.

Definition at line 88 of file DisassemblerTypes.h.

Typedef Documentation

◆ LLVMDisasmContextRef

typedef void* LLVMDisasmContextRef

An opaque reference to a disassembler context.

Definition at line 29 of file DisassemblerTypes.h.

◆ LLVMOpInfoCallback

typedef int(* LLVMOpInfoCallback) (void *DisInfo, uint64_t PC, uint64_t Offset, uint64_t OpSize, uint64_t InstSize, int TagType, void *TagBuf)

The type for the operand information call back function.

This is called to get the symbolic information for an operand of an instruction. Typically this is from the relocation information, symbol table, etc. That block of information is saved when the disassembler context is created and passed to the call back in the DisInfo parameter. The instruction containing operand is at the PC parameter. For some instruction sets, there can be more than one operand with symbolic information. To determine the symbolic operand information for each operand, the bytes for the specific operand in the instruction are specified by the Offset parameter and its byte widith is the OpSize parameter. For instructions sets with fixed widths and one symbolic operand per instruction, the Offset parameter will be zero and InstSize parameter will be the instruction width. The information is returned in TagBuf and is Triple specific with its specific information defined by the value of TagType for that Triple. If symbolic information is returned the function * returns 1, otherwise it returns 0.

Definition at line 48 of file DisassemblerTypes.h.

◆ LLVMSymbolLookupCallback

typedef const char *(* LLVMSymbolLookupCallback) (void *DisInfo, uint64_t ReferenceValue, uint64_t *ReferenceType, uint64_t ReferencePC, const char **ReferenceName)

The type for the symbol lookup function.

This may be called by the disassembler for things like adding a comment for a PC plus a constant offset load instruction to use a symbol name instead of a load address value. It is passed the block information is saved when the disassembler context is created and the ReferenceValue to look up as a symbol. If no symbol is found for the ReferenceValue NULL is returned. The ReferenceType of the instruction is passed indirectly as is the PC of the instruction in ReferencePC. If the output reference can be determined its type is returned indirectly in ReferenceType along with ReferenceName if any, or that is set to NULL.

Definition at line 118 of file DisassemblerTypes.h.

Function Documentation

◆ LLVMCreateDisasm()

LLVM_C_EXTERN_C_BEGIN LLVMDisasmContextRef LLVMCreateDisasm ( const char TripleName,
void *  DisInfo,
int  TagType,
LLVMOpInfoCallback  GetOpInfo,
LLVMSymbolLookupCallback  SymbolLookUp 
)

Create a disassembler for the TripleName.

Symbolic disassembly is supported by passing a block of information in the DisInfo parameter and specifying the TagType and callback functions as described above. These can all be passed as NULL. If successful, this returns a disassembler context. If not, it returns NULL. This function is equivalent to calling LLVMCreateDisasmCPUFeatures() with an empty CPU name and feature set.

Definition at line 122 of file Disassembler.cpp.

References LLVMCreateDisasmCPUFeatures().

◆ LLVMCreateDisasmCPU()

LLVMDisasmContextRef LLVMCreateDisasmCPU ( const char Triple,
const char CPU,
void *  DisInfo,
int  TagType,
LLVMOpInfoCallback  GetOpInfo,
LLVMSymbolLookupCallback  SymbolLookUp 
)

Create a disassembler for the TripleName and a specific CPU.

Symbolic disassembly is supported by passing a block of information in the DisInfo parameter and specifying the TagType and callback functions as described above. These can all be passed * as NULL. If successful, this returns a disassembler context. If not, it returns NULL. This function is equivalent to calling LLVMCreateDisasmCPUFeatures() with an empty feature set.

Definition at line 115 of file Disassembler.cpp.

References LLVMCreateDisasmCPUFeatures().

◆ LLVMCreateDisasmCPUFeatures()

LLVMDisasmContextRef LLVMCreateDisasmCPUFeatures ( const char Triple,
const char CPU,
const char Features,
void *  DisInfo,
int  TagType,
LLVMOpInfoCallback  GetOpInfo,
LLVMSymbolLookupCallback  SymbolLookUp 
)

Create a disassembler for the TripleName, a specific CPU and specific feature string.

Symbolic disassembly is supported by passing a block of information in the DisInfo parameter and specifying the TagType and callback functions as described above. These can all be passed * as NULL. If successful, this returns a disassembler context. If not, it returns NULL.

Definition at line 45 of file Disassembler.cpp.

References llvm::Target::createMCAsmInfo(), llvm::Target::createMCDisassembler(), llvm::Target::createMCInstPrinter(), llvm::Target::createMCInstrInfo(), llvm::Target::createMCRegInfo(), llvm::Target::createMCRelocationInfo(), llvm::Target::createMCSubtargetInfo(), llvm::Target::createMCSymbolizer(), llvm::TargetRegistry::lookupTarget(), MRI, and llvm::LLVMDisasmContext::setCPU().

Referenced by LLVMCreateDisasm(), and LLVMCreateDisasmCPU().

◆ LLVMDisasmDispose()

void LLVMDisasmDispose ( LLVMDisasmContextRef  DC)

Dispose of a disassembler context.

Definition at line 132 of file Disassembler.cpp.

◆ LLVMDisasmInstruction()

size_t LLVMDisasmInstruction ( LLVMDisasmContextRef  DC,
uint8_t *  Bytes,
uint64_t  BytesSize,
uint64_t  PC,
char OutString,
size_t  OutStringSize 
)

Disassemble a single instruction using the disassembler context specified in the parameter DC.

The bytes of the instruction are specified in the parameter Bytes, and contains at least BytesSize number of bytes. The instruction is at the address specified by the PC parameter. If a valid instruction can be disassembled, its string is returned indirectly in OutString whose size is specified in the parameter OutStringSize. This function returns the number of bytes in the instruction or zero if there was no valid instruction.

Definition at line 253 of file Disassembler.cpp.

References assert(), llvm::SmallVectorTemplateCommon< T, typename >::data(), emitComments(), emitLatency(), llvm::MCDisassembler::Fail, llvm::LLVMDisasmContext::getDisAsm(), llvm::MCDisassembler::getInstruction(), llvm::LLVMDisasmContext::getIP(), llvm::LLVMDisasmContext::getOptions(), llvm::LLVMDisasmContext::getSubtargetInfo(), llvm_unreachable, LLVMDisassembler_Option_PrintLatency, OS, llvm::MCInstPrinter::printInst(), llvm::SmallVectorBase< Size_T >::size(), Size, llvm::MCDisassembler::SoftFail, and llvm::MCDisassembler::Success.

◆ LLVMSetDisasmOptions()

int LLVMSetDisasmOptions ( LLVMDisasmContextRef  DC,
uint64_t  Options 
)