2011-03-28 20:25:07 +02:00
|
|
|
/*===-- llvm-c/Disassembler.h - Disassembler Public C Interface ---*- C -*-===*\
|
|
|
|
|* *|
|
2019-01-19 09:50:56 +01:00
|
|
|
|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *|
|
|
|
|
|* Exceptions. *|
|
|
|
|
|* See https://llvm.org/LICENSE.txt for license information. *|
|
|
|
|
|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *|
|
2011-03-28 20:25:07 +02:00
|
|
|
|* *|
|
|
|
|
|*===----------------------------------------------------------------------===*|
|
|
|
|
|* *|
|
2011-05-22 06:44:48 +02:00
|
|
|
|* This header provides a public interface to a disassembler library. *|
|
2011-03-28 20:25:07 +02:00
|
|
|
|* LLVM provides an implementation of this interface. *|
|
|
|
|
|* *|
|
|
|
|
\*===----------------------------------------------------------------------===*/
|
|
|
|
|
|
|
|
#ifndef LLVM_C_DISASSEMBLER_H
|
2011-05-22 06:44:48 +02:00
|
|
|
#define LLVM_C_DISASSEMBLER_H
|
2011-03-28 20:25:07 +02:00
|
|
|
|
2018-03-29 02:29:44 +02:00
|
|
|
#include "llvm-c/DisassemblerTypes.h"
|
2019-11-14 22:57:57 +01:00
|
|
|
#include "llvm-c/ExternC.h"
|
2011-03-28 20:25:07 +02:00
|
|
|
|
2012-03-21 04:54:29 +01:00
|
|
|
/**
|
|
|
|
* @defgroup LLVMCDisassembler Disassembler
|
|
|
|
* @ingroup LLVMC
|
|
|
|
*
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2019-11-14 22:57:57 +01:00
|
|
|
LLVM_C_EXTERN_C_BEGIN
|
2011-03-28 20:25:07 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a disassembler for the TripleName. Symbolic disassembly is supported
|
2011-05-22 06:44:48 +02:00
|
|
|
* 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
|
2014-09-30 18:31:40 +02:00
|
|
|
* returns NULL. This function is equivalent to calling
|
|
|
|
* LLVMCreateDisasmCPUFeatures() with an empty CPU name and feature set.
|
2011-03-28 20:25:07 +02:00
|
|
|
*/
|
2011-05-22 06:44:48 +02:00
|
|
|
LLVMDisasmContextRef LLVMCreateDisasm(const char *TripleName, void *DisInfo,
|
|
|
|
int TagType, LLVMOpInfoCallback GetOpInfo,
|
|
|
|
LLVMSymbolLookupCallback SymbolLookUp);
|
2011-03-28 20:25:07 +02:00
|
|
|
|
2012-12-08 00:53:27 +01:00
|
|
|
/**
|
|
|
|
* 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
|
2014-09-30 18:31:40 +02:00
|
|
|
* disassembler context. If not, it returns NULL. This function is equivalent
|
|
|
|
* to calling LLVMCreateDisasmCPUFeatures() with an empty feature set.
|
2012-12-08 00:53:27 +01:00
|
|
|
*/
|
|
|
|
LLVMDisasmContextRef LLVMCreateDisasmCPU(const char *Triple, const char *CPU,
|
|
|
|
void *DisInfo, int TagType,
|
|
|
|
LLVMOpInfoCallback GetOpInfo,
|
|
|
|
LLVMSymbolLookupCallback SymbolLookUp);
|
|
|
|
|
2014-09-30 18:31:40 +02:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
LLVMDisasmContextRef
|
|
|
|
LLVMCreateDisasmCPUFeatures(const char *Triple, const char *CPU,
|
|
|
|
const char *Features, void *DisInfo, int TagType,
|
|
|
|
LLVMOpInfoCallback GetOpInfo,
|
|
|
|
LLVMSymbolLookupCallback SymbolLookUp);
|
|
|
|
|
2012-10-23 00:31:46 +02:00
|
|
|
/**
|
|
|
|
* Set the disassembler's options. Returns 1 if it can set the Options and 0
|
|
|
|
* otherwise.
|
|
|
|
*/
|
|
|
|
int LLVMSetDisasmOptions(LLVMDisasmContextRef DC, uint64_t Options);
|
|
|
|
|
|
|
|
/* The option to produce marked up assembly. */
|
|
|
|
#define LLVMDisassembler_Option_UseMarkup 1
|
2012-12-05 19:13:19 +01:00
|
|
|
/* The option to print immediates as hex. */
|
|
|
|
#define LLVMDisassembler_Option_PrintImmHex 2
|
2012-12-19 00:47:28 +01:00
|
|
|
/* The option use the other assembler printer variant */
|
|
|
|
#define LLVMDisassembler_Option_AsmPrinterVariant 4
|
2013-10-02 00:14:56 +02:00
|
|
|
/* The option to set comment on instructions */
|
|
|
|
#define LLVMDisassembler_Option_SetInstrComments 8
|
2013-10-03 00:07:57 +02:00
|
|
|
/* The option to print latency information alongside instructions */
|
|
|
|
#define LLVMDisassembler_Option_PrintLatency 16
|
2012-10-23 00:31:46 +02:00
|
|
|
|
2011-03-28 20:25:07 +02:00
|
|
|
/**
|
|
|
|
* Dispose of a disassembler context.
|
|
|
|
*/
|
2011-05-22 06:44:48 +02:00
|
|
|
void LLVMDisasmDispose(LLVMDisasmContextRef DC);
|
2011-03-28 20:25:07 +02:00
|
|
|
|
|
|
|
/**
|
2011-05-22 06:44:48 +02:00
|
|
|
* 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.
|
2011-03-28 20:25:07 +02:00
|
|
|
*/
|
2011-05-22 06:44:48 +02:00
|
|
|
size_t LLVMDisasmInstruction(LLVMDisasmContextRef DC, uint8_t *Bytes,
|
|
|
|
uint64_t BytesSize, uint64_t PC,
|
|
|
|
char *OutString, size_t OutStringSize);
|
2011-03-28 20:25:07 +02:00
|
|
|
|
2012-03-21 04:54:29 +01:00
|
|
|
/**
|
|
|
|
* @}
|
|
|
|
*/
|
|
|
|
|
2019-11-14 22:57:57 +01:00
|
|
|
LLVM_C_EXTERN_C_END
|
2011-03-28 20:25:07 +02:00
|
|
|
|
2016-03-28 19:40:08 +02:00
|
|
|
#endif /* LLVM_C_DISASSEMBLER_H */
|