1 /*===-- llvm-c/Disassembler.h - Disassembler Public C Interface ---*- C -*-===*\
3 |* The LLVM Compiler Infrastructure *|
5 |* This file is distributed under the University of Illinois Open Source *|
6 |* License. See LICENSE.TXT for details. *|
8 |*===----------------------------------------------------------------------===*|
10 |* This header provides public interface to a disassembler library. *|
11 |* LLVM provides an implementation of this interface. *|
13 \*===----------------------------------------------------------------------===*/
15 #ifndef LLVM_C_DISASSEMBLER_H
16 #define LLVM_C_DISASSEMBLER_H 1
22 * An opaque reference to a disassembler context.
24 typedef void *LLVMDisasmContextRef;
27 * The type for the operand information call back function. This is called to
28 * get the symbolic information for an operand of an instruction. Typically
29 * this is from the relocation information, symbol table, etc. That block of
30 * information is saved when the disassembler context is created and passed to
31 * the call back in the DisInfo parameter. The instruction containing operand
32 * is at the PC parameter. For some instruction sets, there can be more than
33 * one operand with symbolic information. To determine the symbolic operand
34 * infomation for each operand, the bytes for the specific operand in the
35 * instruction are specified by the Offset parameter and its byte widith is the
36 * size parameter. For instructions sets with fixed widths and one symbolic
37 * operand per instruction, the Offset parameter will be zero and Size parameter
38 * will be the instruction width. The information is returned in TagBuf and is
39 * Triple specific with its specific information defined by the value of
40 * TagType for that Triple. If symbolic information is returned the function
41 * returns 1 else it returns 0.
43 typedef int (*LLVMOpInfoCallback)(void *DisInfo,
51 * The type for the symbol lookup function. This may be called by the
52 * disassembler for such things like adding a comment for a PC plus a constant
53 * offset load instruction to use a symbol name instead of a load address value.
54 * It is passed the block information is saved when the disassembler context is
55 * created and a value of a symbol to look up. If no symbol is found NULL is
58 typedef const char *(*LLVMSymbolLookupCallback)(void *DisInfo,
59 uint64_t SymbolValue);
63 #endif /* !defined(__cplusplus) */
66 * Create a disassembler for the TripleName. Symbolic disassembly is supported
67 * by passing a block of information in the DisInfo parameter and specifing the
68 * TagType and call back functions as described above. These can all be passed
69 * as NULL. If successfull this returns a disassembler context if not it
72 extern LLVMDisasmContextRef
73 LLVMCreateDisasm(const char *TripleName,
76 LLVMOpInfoCallback GetOpInfo,
77 LLVMSymbolLookupCallback SymbolLookUp);
80 * Dispose of a disassembler context.
83 LLVMDisasmDispose(LLVMDisasmContextRef DC);
86 * Disassmble a single instruction using the disassembler context specified in
87 * the parameter DC. The bytes of the instuction are specified in the parameter
88 * Bytes, and contains at least BytesSize number of bytes. The instruction is
89 * at the address specified by the PC parameter. If a valid instruction can be
90 * disassembled its string is returned indirectly in OutString which whos size
91 * is specified in the parameter OutStringSize. This function returns the
92 * number of bytes in the instruction or zero if there was no valid instruction.
95 LLVMDisasmInstruction(LLVMDisasmContextRef DC,
100 size_t OutStringSize);
104 #endif /* !defined(__cplusplus) */
106 #endif /* !defined(LLVM_C_DISASSEMBLER_H) */