LLVM 20.0.0git
Disassembler.h
Go to the documentation of this file.
1/*===-- llvm-c/Disassembler.h - Disassembler Public C Interface ---*- C -*-===*\
2|* *|
3|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *|
4|* Exceptions. *|
5|* See https://llvm.org/LICENSE.txt for license information. *|
6|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *|
7|* *|
8|*===----------------------------------------------------------------------===*|
9|* *|
10|* This header provides a public interface to a disassembler library. *|
11|* LLVM provides an implementation of this interface. *|
12|* *|
13\*===----------------------------------------------------------------------===*/
14
15#ifndef LLVM_C_DISASSEMBLER_H
16#define LLVM_C_DISASSEMBLER_H
17
19#include "llvm-c/ExternC.h"
20
21/**
22 * @defgroup LLVMCDisassembler Disassembler
23 * @ingroup LLVMC
24 *
25 * @{
26 */
27
29
30/**
31 * Create a disassembler for the TripleName. Symbolic disassembly is supported
32 * by passing a block of information in the DisInfo parameter and specifying the
33 * TagType and callback functions as described above. These can all be passed
34 * as NULL. If successful, this returns a disassembler context. If not, it
35 * returns NULL. This function is equivalent to calling
36 * LLVMCreateDisasmCPUFeatures() with an empty CPU name and feature set.
37 */
38LLVMDisasmContextRef LLVMCreateDisasm(const char *TripleName, void *DisInfo,
39 int TagType, LLVMOpInfoCallback GetOpInfo,
40 LLVMSymbolLookupCallback SymbolLookUp);
41
42/**
43 * Create a disassembler for the TripleName and a specific CPU. Symbolic
44 * disassembly is supported by passing a block of information in the DisInfo
45 * parameter and specifying the TagType and callback functions as described
46 * above. These can all be passed * as NULL. If successful, this returns a
47 * disassembler context. If not, it returns NULL. This function is equivalent
48 * to calling LLVMCreateDisasmCPUFeatures() with an empty feature set.
49 */
50LLVMDisasmContextRef LLVMCreateDisasmCPU(const char *Triple, const char *CPU,
51 void *DisInfo, int TagType,
52 LLVMOpInfoCallback GetOpInfo,
53 LLVMSymbolLookupCallback SymbolLookUp);
54
55/**
56 * Create a disassembler for the TripleName, a specific CPU and specific feature
57 * string. Symbolic disassembly is supported by passing a block of information
58 * in the DisInfo parameter and specifying the TagType and callback functions as
59 * described above. These can all be passed * as NULL. If successful, this
60 * returns a disassembler context. If not, it returns NULL.
61 */
63LLVMCreateDisasmCPUFeatures(const char *Triple, const char *CPU,
64 const char *Features, void *DisInfo, int TagType,
65 LLVMOpInfoCallback GetOpInfo,
66 LLVMSymbolLookupCallback SymbolLookUp);
67
68/**
69 * Set the disassembler's options. Returns 1 if it can set the Options and 0
70 * otherwise.
71 */
73
74/* The option to produce marked up assembly. */
75#define LLVMDisassembler_Option_UseMarkup 1
76/* The option to print immediates as hex. */
77#define LLVMDisassembler_Option_PrintImmHex 2
78/* The option use the other assembler printer variant */
79#define LLVMDisassembler_Option_AsmPrinterVariant 4
80/* The option to set comment on instructions */
81#define LLVMDisassembler_Option_SetInstrComments 8
82/* The option to print latency information alongside instructions */
83#define LLVMDisassembler_Option_PrintLatency 16
84/* The option to print in color */
85#define LLVMDisassembler_Option_Color 32
86
87/**
88 * Dispose of a disassembler context.
89 */
91
92/**
93 * Disassemble a single instruction using the disassembler context specified in
94 * the parameter DC. The bytes of the instruction are specified in the
95 * parameter Bytes, and contains at least BytesSize number of bytes. The
96 * instruction is at the address specified by the PC parameter. If a valid
97 * instruction can be disassembled, its string is returned indirectly in
98 * OutString whose size is specified in the parameter OutStringSize. This
99 * function returns the number of bytes in the instruction or zero if there was
100 * no valid instruction.
101 */
103 uint64_t BytesSize, uint64_t PC,
104 char *OutString, size_t OutStringSize);
105
106/**
107 * @}
108 */
109
111
112#endif /* LLVM_C_DISASSEMBLER_H */
#define LLVM_C_EXTERN_C_BEGIN
Definition: ExternC.h:35
#define LLVM_C_EXTERN_C_END
Definition: ExternC.h:36
static LVOptions Options
Definition: LVOptions.cpp:25
const char *(* LLVMSymbolLookupCallback)(void *DisInfo, uint64_t ReferenceValue, uint64_t *ReferenceType, uint64_t ReferencePC, const char **ReferenceName)
The type for the symbol lookup function.
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.
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.
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.
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.
LLVM_C_EXTERN_C_BEGIN LLVMDisasmContextRef LLVMCreateDisasm(const char *TripleName, void *DisInfo, int TagType, LLVMOpInfoCallback GetOpInfo, LLVMSymbolLookupCallback SymbolLookUp)
Create a disassembler for the TripleName.
int LLVMSetDisasmOptions(LLVMDisasmContextRef DC, uint64_t Options)
Set the disassembler's options.
void * LLVMDisasmContextRef
An opaque reference to a disassembler context.