LLVM API Documentation

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Macros | Typedefs | Functions
Collaboration diagram for Disassembler:

Classes

struct  LLVMOpInfoSymbol1
 
struct  LLVMOpInfo1
 

Macros

#define LLVMDisassembler_VariantKind_None   0 /* all targets */
 
#define LLVMDisassembler_VariantKind_ARM_HI16   1 /* :upper16: */
 
#define LLVMDisassembler_VariantKind_ARM_LO16   2 /* :lower16: */
 
#define LLVMDisassembler_ReferenceType_InOut_None   0
 
#define LLVMDisassembler_ReferenceType_In_Branch   1
 
#define LLVMDisassembler_ReferenceType_In_PCrel_Load   2
 
#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_Option_UseMarkup   1
 
#define LLVMDisassembler_Option_PrintImmHex   2
 
#define LLVMDisassembler_Option_AsmPrinterVariant   4
 
#define LLVMDisassembler_Option_SetInstrComments   8
 
#define LLVMDisassembler_Option_PrintLatency   16
 

Typedefs

typedef void * LLVMDisasmContextRef
 
typedef int(* LLVMOpInfoCallback )(void *DisInfo, uint64_t PC, uint64_t Offset, uint64_t Size, int TagType, void *TagBuf)
 
typedef const char *(* LLVMSymbolLookupCallback )(void *DisInfo, uint64_t ReferenceValue, uint64_t *ReferenceType, uint64_t ReferencePC, const char **ReferenceName)
 

Functions

LLVMDisasmContextRef LLVMCreateDisasm (const char *TripleName, void *DisInfo, int TagType, LLVMOpInfoCallback GetOpInfo, LLVMSymbolLookupCallback SymbolLookUp)
 
LLVMDisasmContextRef LLVMCreateDisasmCPU (const char *Triple, const char *CPU, void *DisInfo, int TagType, LLVMOpInfoCallback GetOpInfo, LLVMSymbolLookupCallback SymbolLookUp)
 
int LLVMSetDisasmOptions (LLVMDisasmContextRef DC, uint64_t Options)
 
void LLVMDisasmDispose (LLVMDisasmContextRef DC)
 
size_t LLVMDisasmInstruction (LLVMDisasmContextRef DC, uint8_t *Bytes, uint64_t BytesSize, uint64_t PC, char *OutString, size_t OutStringSize)
 

Detailed Description

Macro Definition Documentation

#define LLVMDisassembler_Option_AsmPrinterVariant   4

Definition at line 183 of file include/llvm-c/Disassembler.h.

Referenced by LLVMSetDisasmOptions().

#define LLVMDisassembler_Option_PrintImmHex   2

Definition at line 181 of file include/llvm-c/Disassembler.h.

Referenced by LLVMSetDisasmOptions().

#define LLVMDisassembler_Option_PrintLatency   16

Definition at line 187 of file include/llvm-c/Disassembler.h.

Referenced by LLVMDisasmInstruction(), and LLVMSetDisasmOptions().

#define LLVMDisassembler_Option_SetInstrComments   8

Definition at line 185 of file include/llvm-c/Disassembler.h.

Referenced by LLVMSetDisasmOptions().

#define LLVMDisassembler_Option_UseMarkup   1

Definition at line 179 of file include/llvm-c/Disassembler.h.

Referenced by LLVMSetDisasmOptions().

#define LLVMDisassembler_ReferenceType_In_Branch   1
#define LLVMDisassembler_ReferenceType_In_PCrel_Load   2
#define LLVMDisassembler_ReferenceType_InOut_None   0

The reference types on input and output.

Definition at line 119 of file include/llvm-c/Disassembler.h.

Referenced by llvm::MCExternalSymbolizer::tryAddingSymbolicOperand().

#define LLVMDisassembler_ReferenceType_Out_LitPool_CstrAddr   3
#define LLVMDisassembler_ReferenceType_Out_LitPool_SymAddr   2
#define LLVMDisassembler_ReferenceType_Out_Objc_CFString_Ref   4
#define LLVMDisassembler_ReferenceType_Out_Objc_Class_Ref   8
#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_SymbolStub   1
#define LLVMDisassembler_VariantKind_ARM_HI16   1 /* :upper16: */

The ARM target VariantKinds.

Definition at line 95 of file include/llvm-c/Disassembler.h.

#define LLVMDisassembler_VariantKind_ARM_LO16   2 /* :lower16: */

Definition at line 96 of file include/llvm-c/Disassembler.h.

#define LLVMDisassembler_VariantKind_None   0 /* all targets */

The operand VariantKinds for symbolic disassembly.

Definition at line 90 of file include/llvm-c/Disassembler.h.

Referenced by llvm::MCRelocationInfo::createExprForCAPIVariantKind().

Typedef Documentation

typedef void* LLVMDisasmContextRef

An opaque reference to a disassembler context.

Definition at line 31 of file include/llvm-c/Disassembler.h.

typedef int(* LLVMOpInfoCallback)(void *DisInfo, uint64_t PC, uint64_t Offset, uint64_t Size, 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 size parameter. For instructions sets with fixed widths and one symbolic operand per instruction, the Offset parameter will be zero and Size 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 50 of file include/llvm-c/Disassembler.h.

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 110 of file include/llvm-c/Disassembler.h.

Function Documentation

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 LLVMCreateDisasmCPU() with an empty CPU name.

Definition at line 109 of file MC/MCDisassembler/Disassembler.cpp.

References 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.

Definition at line 39 of file MC/MCDisassembler/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::X86II::DC, llvm::lltok::Error, llvm::MCAsmInfo::getAssemblerDialect(), llvm::TargetRegistry::lookupTarget(), MII, MRI, llvm::LLVMDisasmContext::setCPU(), llvm::MCDisassembler::setSymbolizer(), and llvm::MCDisassembler::setupForSymbolicDisassembly().

Referenced by LLVMCreateDisasm().

void LLVMDisasmDispose ( LLVMDisasmContextRef  DC)

Dispose of a disassembler context.

Definition at line 119 of file MC/MCDisassembler/Disassembler.cpp.

References llvm::X86II::DC.

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 266 of file MC/MCDisassembler/Disassembler.cpp.

References llvm::SmallVectorTemplateCommon< T >::data(), llvm::X86II::DC, emitComments(), emitLatency(), llvm::MCDisassembler::Fail, llvm::raw_ostream::flush(), llvm::LLVMDisasmContext::getDisAsm(), llvm::MCDisassembler::getInstruction(), llvm::LLVMDisasmContext::getIP(), llvm::LLVMDisasmContext::getOptions(), llvm_unreachable, LLVMDisassembler_Option_PrintLatency, llvm::Intrinsic::memcpy, llvm::nulls(), llvm::MCInstPrinter::printInst(), llvm::SmallVectorTemplateCommon< T >::size(), llvm::MCDisassembler::SoftFail, llvm::raw_svector_ostream::str(), and llvm::MCDisassembler::Success.

int LLVMSetDisasmOptions ( LLVMDisasmContextRef  DC,
uint64_t  Options 
)