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