Add CreateLifetimeStart and CreateLifetimeEnd to the IRBuilder, with plans to
[llvm/stm8.git] / include / llvm-c / Disassembler.h
blob9f10973404b7941eb48d446f89056ae03d0ea9b1
1 /*===-- llvm-c/Disassembler.h - Disassembler Public C Interface ---*- C -*-===*\
2 |* *|
3 |* The LLVM Compiler Infrastructure *|
4 |* *|
5 |* This file is distributed under the University of Illinois Open Source *|
6 |* License. See LICENSE.TXT for details. *|
7 |* *|
8 |*===----------------------------------------------------------------------===*|
9 |* *|
10 |* This header provides public interface to a disassembler library. *|
11 |* LLVM provides an implementation of this interface. *|
12 |* *|
13 \*===----------------------------------------------------------------------===*/
15 #ifndef LLVM_C_DISASSEMBLER_H
16 #define LLVM_C_DISASSEMBLER_H 1
18 #include <stddef.h>
19 #include "llvm/Support/DataTypes.h"
21 /**
22 * An opaque reference to a disassembler context.
24 typedef void *LLVMDisasmContextRef;
26 /**
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 * information 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,
44 uint64_t PC,
45 uint64_t Offset,
46 uint64_t Size,
47 int TagType,
48 void *TagBuf);
50 /**
51 * The initial support in LLVM MC for the most general form of a relocatable
52 * expression is "AddSymbol - SubtractSymbol + Offset". For some Darwin targets
53 * this full form is encoded in the relocation information so that AddSymbol and
54 * SubtractSymbol can be link edited independent of each other. Many other
55 * platforms only allow a relocatable expression of the form AddSymbol + Offset
56 * to be encoded.
58 * The LLVMOpInfoCallback() for the TagType value of 1 uses the struct
59 * LLVMOpInfo1. The value of the relocatable expression for the operand,
60 * including any PC adjustment, is passed in to the call back in the Value
61 * field. The symbolic information about the operand is returned using all
62 * the fields of the structure with the Offset of the relocatable expression
63 * returned in the Value field. It is possible that some symbols in the
64 * relocatable expression were assembly temporary symbols, for example
65 * "Ldata - LpicBase + constant", and only the Values of the symbols without
66 * symbol names are present in the relocation information. The VariantKind
67 * type is one of the Target specific #defines below and is used to print
68 * operands like "_foo@GOT", ":lower16:_foo", etc.
70 struct LLVMOpInfoSymbol1 {
71 uint64_t Present; /* 1 if this symbol is present */
72 char *Name; /* symbol name if not NULL */
73 uint64_t Value; /* symbol value if name is NULL */
75 struct LLVMOpInfo1 {
76 struct LLVMOpInfoSymbol1 AddSymbol;
77 struct LLVMOpInfoSymbol1 SubtractSymbol;
78 uint64_t Value;
79 uint64_t VariantKind;
82 /**
83 * The operand VariantKinds for symbolic disassembly.
85 #define LLVMDisassembler_VariantKind_None 0 /* all targets */
87 /**
88 * The ARM target VariantKinds.
90 #define LLVMDisassembler_VariantKind_ARM_HI16 1 /* :upper16: */
91 #define LLVMDisassembler_VariantKind_ARM_LO16 2 /* :lower16: */
93 /**
94 * The type for the symbol lookup function. This may be called by the
95 * disassembler for such things like adding a comment for a PC plus a constant
96 * offset load instruction to use a symbol name instead of a load address value.
97 * It is passed the block information is saved when the disassembler context is
98 * created and a value of a symbol to look up. If no symbol is found NULL is
99 * to be returned.
101 typedef const char *(*LLVMSymbolLookupCallback)(void *DisInfo,
102 uint64_t SymbolValue);
104 #ifdef __cplusplus
105 extern "C" {
106 #endif /* !defined(__cplusplus) */
109 * Create a disassembler for the TripleName. Symbolic disassembly is supported
110 * by passing a block of information in the DisInfo parameter and specifing the
111 * TagType and call back functions as described above. These can all be passed
112 * as NULL. If successful this returns a disassembler context if not it
113 * returns NULL.
115 extern LLVMDisasmContextRef
116 LLVMCreateDisasm(const char *TripleName,
117 void *DisInfo,
118 int TagType,
119 LLVMOpInfoCallback GetOpInfo,
120 LLVMSymbolLookupCallback SymbolLookUp);
123 * Dispose of a disassembler context.
125 extern void
126 LLVMDisasmDispose(LLVMDisasmContextRef DC);
129 * Disassmble a single instruction using the disassembler context specified in
130 * the parameter DC. The bytes of the instruction are specified in the parameter
131 * Bytes, and contains at least BytesSize number of bytes. The instruction is
132 * at the address specified by the PC parameter. If a valid instruction can be
133 * disassembled its string is returned indirectly in OutString which whos size
134 * is specified in the parameter OutStringSize. This function returns the
135 * number of bytes in the instruction or zero if there was no valid instruction.
137 extern size_t
138 LLVMDisasmInstruction(LLVMDisasmContextRef DC,
139 uint8_t *Bytes,
140 uint64_t BytesSize,
141 uint64_t PC,
142 char *OutString,
143 size_t OutStringSize);
145 #ifdef __cplusplus
147 #endif /* !defined(__cplusplus) */
149 #endif /* !defined(LLVM_C_DISASSEMBLER_H) */