brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.9 KiB · c533679 Raw
112 lines · c
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_H16#define LLVM_C_DISASSEMBLER_H17 18#include "llvm-c/DisassemblerTypes.h"19#include "llvm-c/ExternC.h"20#include "llvm-c/Visibility.h"21 22/**23 * @defgroup LLVMCDisassembler Disassembler24 * @ingroup LLVMC25 *26 * @{27 */28 29LLVM_C_EXTERN_C_BEGIN30 31/**32 * Create a disassembler for the TripleName.  Symbolic disassembly is supported33 * by passing a block of information in the DisInfo parameter and specifying the34 * TagType and callback functions as described above.  These can all be passed35 * as NULL.  If successful, this returns a disassembler context.  If not, it36 * returns NULL. This function is equivalent to calling37 * LLVMCreateDisasmCPUFeatures() with an empty CPU name and feature set.38 */39LLVM_C_ABI LLVMDisasmContextRef LLVMCreateDisasm(40    const char *TripleName, void *DisInfo, int TagType,41    LLVMOpInfoCallback GetOpInfo, LLVMSymbolLookupCallback SymbolLookUp);42 43/**44 * Create a disassembler for the TripleName and a specific CPU.  Symbolic45 * disassembly is supported by passing a block of information in the DisInfo46 * parameter and specifying the TagType and callback functions as described47 * above.  These can all be passed * as NULL.  If successful, this returns a48 * disassembler context.  If not, it returns NULL. This function is equivalent49 * to calling LLVMCreateDisasmCPUFeatures() with an empty feature set.50 */51LLVM_C_ABI LLVMDisasmContextRef LLVMCreateDisasmCPU(52    const char *Triple, const char *CPU, void *DisInfo, int TagType,53    LLVMOpInfoCallback GetOpInfo, LLVMSymbolLookupCallback SymbolLookUp);54 55/**56 * Create a disassembler for the TripleName, a specific CPU and specific feature57 * string.  Symbolic disassembly is supported by passing a block of information58 * in the DisInfo parameter and specifying the TagType and callback functions as59 * described above.  These can all be passed * as NULL.  If successful, this60 * returns a disassembler context.  If not, it returns NULL.61 */62LLVM_C_ABI LLVMDisasmContextRef LLVMCreateDisasmCPUFeatures(63    const char *Triple, const char *CPU, const char *Features, void *DisInfo,64    int TagType, LLVMOpInfoCallback GetOpInfo,65    LLVMSymbolLookupCallback SymbolLookUp);66 67/**68 * Set the disassembler's options.  Returns 1 if it can set the Options and 069 * otherwise.70 */71LLVM_C_ABI int LLVMSetDisasmOptions(LLVMDisasmContextRef DC, uint64_t Options);72 73/* The option to produce marked up assembly. */74#define LLVMDisassembler_Option_UseMarkup 175/* The option to print immediates as hex. */76#define LLVMDisassembler_Option_PrintImmHex 277/* The option use the other assembler printer variant */78#define LLVMDisassembler_Option_AsmPrinterVariant 479/* The option to set comment on instructions */80#define LLVMDisassembler_Option_SetInstrComments 881/* The option to print latency information alongside instructions */82#define LLVMDisassembler_Option_PrintLatency 1683/* The option to print in color */84#define LLVMDisassembler_Option_Color 3285 86/**87 * Dispose of a disassembler context.88 */89LLVM_C_ABI void LLVMDisasmDispose(LLVMDisasmContextRef DC);90 91/**92 * Disassemble a single instruction using the disassembler context specified in93 * the parameter DC.  The bytes of the instruction are specified in the94 * parameter Bytes, and contains at least BytesSize number of bytes.  The95 * instruction is at the address specified by the PC parameter.  If a valid96 * instruction can be disassembled, its string is returned indirectly in97 * OutString whose size is specified in the parameter OutStringSize.  This98 * function returns the number of bytes in the instruction or zero if there was99 * no valid instruction.100 */101LLVM_C_ABI size_t LLVMDisasmInstruction(LLVMDisasmContextRef DC, uint8_t *Bytes,102                                        uint64_t BytesSize, uint64_t PC,103                                        char *OutString, size_t OutStringSize);104 105/**106 * @}107 */108 109LLVM_C_EXTERN_C_END110 111#endif /* LLVM_C_DISASSEMBLER_H */112