Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:43:01

0001 /*===-- llvm-c/Disassembler.h - Disassembler Public C Interface ---*- C -*-===*\
0002 |*                                                                            *|
0003 |* Part of the LLVM Project, under the Apache License v2.0 with LLVM          *|
0004 |* Exceptions.                                                                *|
0005 |* See https://llvm.org/LICENSE.txt for license information.                  *|
0006 |* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception                    *|
0007 |*                                                                            *|
0008 |*===----------------------------------------------------------------------===*|
0009 |*                                                                            *|
0010 |* This header provides a public interface to a disassembler library.         *|
0011 |* LLVM provides an implementation of this interface.                         *|
0012 |*                                                                            *|
0013 \*===----------------------------------------------------------------------===*/
0014 
0015 #ifndef LLVM_C_DISASSEMBLER_H
0016 #define LLVM_C_DISASSEMBLER_H
0017 
0018 #include "llvm-c/DisassemblerTypes.h"
0019 #include "llvm-c/ExternC.h"
0020 
0021 /**
0022  * @defgroup LLVMCDisassembler Disassembler
0023  * @ingroup LLVMC
0024  *
0025  * @{
0026  */
0027 
0028 LLVM_C_EXTERN_C_BEGIN
0029 
0030 /**
0031  * Create a disassembler for the TripleName.  Symbolic disassembly is supported
0032  * by passing a block of information in the DisInfo parameter and specifying the
0033  * TagType and callback functions as described above.  These can all be passed
0034  * as NULL.  If successful, this returns a disassembler context.  If not, it
0035  * returns NULL. This function is equivalent to calling
0036  * LLVMCreateDisasmCPUFeatures() with an empty CPU name and feature set.
0037  */
0038 LLVMDisasmContextRef LLVMCreateDisasm(const char *TripleName, void *DisInfo,
0039                                       int TagType, LLVMOpInfoCallback GetOpInfo,
0040                                       LLVMSymbolLookupCallback SymbolLookUp);
0041 
0042 /**
0043  * Create a disassembler for the TripleName and a specific CPU.  Symbolic
0044  * disassembly is supported by passing a block of information in the DisInfo
0045  * parameter and specifying the TagType and callback functions as described
0046  * above.  These can all be passed * as NULL.  If successful, this returns a
0047  * disassembler context.  If not, it returns NULL. This function is equivalent
0048  * to calling LLVMCreateDisasmCPUFeatures() with an empty feature set.
0049  */
0050 LLVMDisasmContextRef LLVMCreateDisasmCPU(const char *Triple, const char *CPU,
0051                                          void *DisInfo, int TagType,
0052                                          LLVMOpInfoCallback GetOpInfo,
0053                                          LLVMSymbolLookupCallback SymbolLookUp);
0054 
0055 /**
0056  * Create a disassembler for the TripleName, a specific CPU and specific feature
0057  * string.  Symbolic disassembly is supported by passing a block of information
0058  * in the DisInfo parameter and specifying the TagType and callback functions as
0059  * described above.  These can all be passed * as NULL.  If successful, this
0060  * returns a disassembler context.  If not, it returns NULL.
0061  */
0062 LLVMDisasmContextRef
0063 LLVMCreateDisasmCPUFeatures(const char *Triple, const char *CPU,
0064                             const char *Features, void *DisInfo, int TagType,
0065                             LLVMOpInfoCallback GetOpInfo,
0066                             LLVMSymbolLookupCallback SymbolLookUp);
0067 
0068 /**
0069  * Set the disassembler's options.  Returns 1 if it can set the Options and 0
0070  * otherwise.
0071  */
0072 int LLVMSetDisasmOptions(LLVMDisasmContextRef DC, uint64_t Options);
0073 
0074 /* The option to produce marked up assembly. */
0075 #define LLVMDisassembler_Option_UseMarkup 1
0076 /* The option to print immediates as hex. */
0077 #define LLVMDisassembler_Option_PrintImmHex 2
0078 /* The option use the other assembler printer variant */
0079 #define LLVMDisassembler_Option_AsmPrinterVariant 4
0080 /* The option to set comment on instructions */
0081 #define LLVMDisassembler_Option_SetInstrComments 8
0082 /* The option to print latency information alongside instructions */
0083 #define LLVMDisassembler_Option_PrintLatency 16
0084 /* The option to print in color */
0085 #define LLVMDisassembler_Option_Color 32
0086 
0087 /**
0088  * Dispose of a disassembler context.
0089  */
0090 void LLVMDisasmDispose(LLVMDisasmContextRef DC);
0091 
0092 /**
0093  * Disassemble a single instruction using the disassembler context specified in
0094  * the parameter DC.  The bytes of the instruction are specified in the
0095  * parameter Bytes, and contains at least BytesSize number of bytes.  The
0096  * instruction is at the address specified by the PC parameter.  If a valid
0097  * instruction can be disassembled, its string is returned indirectly in
0098  * OutString whose size is specified in the parameter OutStringSize.  This
0099  * function returns the number of bytes in the instruction or zero if there was
0100  * no valid instruction.
0101  */
0102 size_t LLVMDisasmInstruction(LLVMDisasmContextRef DC, uint8_t *Bytes,
0103                              uint64_t BytesSize, uint64_t PC,
0104                              char *OutString, size_t OutStringSize);
0105 
0106 /**
0107  * @}
0108  */
0109 
0110 LLVM_C_EXTERN_C_END
0111 
0112 #endif /* LLVM_C_DISASSEMBLER_H */