[MIParser] Set RegClassOrRegBank during instruction parsing
[llvm-complete.git] / include / llvm-c / DisassemblerTypes.h
blob389e5ee454a8eecab57ff3329c202b415ee5b96b
1 /*===-- llvm-c/DisassemblerTypedefs.h -----------------------------*- 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 |*===----------------------------------------------------------------------===*/
10 #ifndef LLVM_DISASSEMBLER_TYPES_H
11 #define LLVM_DISASSEMBLER_TYPES_H
13 #include "llvm-c/DataTypes.h"
14 #ifdef __cplusplus
15 #include <cstddef>
16 #else
17 #include <stddef.h>
18 #endif
20 /**
21 * An opaque reference to a disassembler context.
23 typedef void *LLVMDisasmContextRef;
25 /**
26 * The type for the operand information call back function. This is called to
27 * get the symbolic information for an operand of an instruction. Typically
28 * this is from the relocation information, symbol table, etc. That block of
29 * information is saved when the disassembler context is created and passed to
30 * the call back in the DisInfo parameter. The instruction containing operand
31 * is at the PC parameter. For some instruction sets, there can be more than
32 * one operand with symbolic information. To determine the symbolic operand
33 * information for each operand, the bytes for the specific operand in the
34 * instruction are specified by the Offset parameter and its byte widith is the
35 * size parameter. For instructions sets with fixed widths and one symbolic
36 * operand per instruction, the Offset parameter will be zero and Size parameter
37 * will be the instruction width. The information is returned in TagBuf and is
38 * Triple specific with its specific information defined by the value of
39 * TagType for that Triple. If symbolic information is returned the function
40 * returns 1, otherwise it returns 0.
42 typedef int (*LLVMOpInfoCallback)(void *DisInfo, uint64_t PC,
43 uint64_t Offset, uint64_t Size,
44 int TagType, void *TagBuf);
46 /**
47 * The initial support in LLVM MC for the most general form of a relocatable
48 * expression is "AddSymbol - SubtractSymbol + Offset". For some Darwin targets
49 * this full form is encoded in the relocation information so that AddSymbol and
50 * SubtractSymbol can be link edited independent of each other. Many other
51 * platforms only allow a relocatable expression of the form AddSymbol + Offset
52 * to be encoded.
54 * The LLVMOpInfoCallback() for the TagType value of 1 uses the struct
55 * LLVMOpInfo1. The value of the relocatable expression for the operand,
56 * including any PC adjustment, is passed in to the call back in the Value
57 * field. The symbolic information about the operand is returned using all
58 * the fields of the structure with the Offset of the relocatable expression
59 * returned in the Value field. It is possible that some symbols in the
60 * relocatable expression were assembly temporary symbols, for example
61 * "Ldata - LpicBase + constant", and only the Values of the symbols without
62 * symbol names are present in the relocation information. The VariantKind
63 * type is one of the Target specific #defines below and is used to print
64 * operands like "_foo@GOT", ":lower16:_foo", etc.
66 struct LLVMOpInfoSymbol1 {
67 uint64_t Present; /* 1 if this symbol is present */
68 const char *Name; /* symbol name if not NULL */
69 uint64_t Value; /* symbol value if name is NULL */
72 struct LLVMOpInfo1 {
73 struct LLVMOpInfoSymbol1 AddSymbol;
74 struct LLVMOpInfoSymbol1 SubtractSymbol;
75 uint64_t Value;
76 uint64_t VariantKind;
79 /**
80 * The operand VariantKinds for symbolic disassembly.
82 #define LLVMDisassembler_VariantKind_None 0 /* all targets */
84 /**
85 * The ARM target VariantKinds.
87 #define LLVMDisassembler_VariantKind_ARM_HI16 1 /* :upper16: */
88 #define LLVMDisassembler_VariantKind_ARM_LO16 2 /* :lower16: */
90 /**
91 * The ARM64 target VariantKinds.
93 #define LLVMDisassembler_VariantKind_ARM64_PAGE 1 /* @page */
94 #define LLVMDisassembler_VariantKind_ARM64_PAGEOFF 2 /* @pageoff */
95 #define LLVMDisassembler_VariantKind_ARM64_GOTPAGE 3 /* @gotpage */
96 #define LLVMDisassembler_VariantKind_ARM64_GOTPAGEOFF 4 /* @gotpageoff */
97 #define LLVMDisassembler_VariantKind_ARM64_TLVP 5 /* @tvlppage */
98 #define LLVMDisassembler_VariantKind_ARM64_TLVOFF 6 /* @tvlppageoff */
101 * The type for the symbol lookup function. This may be called by the
102 * disassembler for things like adding a comment for a PC plus a constant
103 * offset load instruction to use a symbol name instead of a load address value.
104 * It is passed the block information is saved when the disassembler context is
105 * created and the ReferenceValue to look up as a symbol. If no symbol is found
106 * for the ReferenceValue NULL is returned. The ReferenceType of the
107 * instruction is passed indirectly as is the PC of the instruction in
108 * ReferencePC. If the output reference can be determined its type is returned
109 * indirectly in ReferenceType along with ReferenceName if any, or that is set
110 * to NULL.
112 typedef const char *(*LLVMSymbolLookupCallback)(void *DisInfo,
113 uint64_t ReferenceValue,
114 uint64_t *ReferenceType,
115 uint64_t ReferencePC,
116 const char **ReferenceName);
118 * The reference types on input and output.
120 /* No input reference type or no output reference type. */
121 #define LLVMDisassembler_ReferenceType_InOut_None 0
123 /* The input reference is from a branch instruction. */
124 #define LLVMDisassembler_ReferenceType_In_Branch 1
125 /* The input reference is from a PC relative load instruction. */
126 #define LLVMDisassembler_ReferenceType_In_PCrel_Load 2
128 /* The input reference is from an ARM64::ADRP instruction. */
129 #define LLVMDisassembler_ReferenceType_In_ARM64_ADRP 0x100000001
130 /* The input reference is from an ARM64::ADDXri instruction. */
131 #define LLVMDisassembler_ReferenceType_In_ARM64_ADDXri 0x100000002
132 /* The input reference is from an ARM64::LDRXui instruction. */
133 #define LLVMDisassembler_ReferenceType_In_ARM64_LDRXui 0x100000003
134 /* The input reference is from an ARM64::LDRXl instruction. */
135 #define LLVMDisassembler_ReferenceType_In_ARM64_LDRXl 0x100000004
136 /* The input reference is from an ARM64::ADR instruction. */
137 #define LLVMDisassembler_ReferenceType_In_ARM64_ADR 0x100000005
139 /* The output reference is to as symbol stub. */
140 #define LLVMDisassembler_ReferenceType_Out_SymbolStub 1
141 /* The output reference is to a symbol address in a literal pool. */
142 #define LLVMDisassembler_ReferenceType_Out_LitPool_SymAddr 2
143 /* The output reference is to a cstring address in a literal pool. */
144 #define LLVMDisassembler_ReferenceType_Out_LitPool_CstrAddr 3
146 /* The output reference is to a Objective-C CoreFoundation string. */
147 #define LLVMDisassembler_ReferenceType_Out_Objc_CFString_Ref 4
148 /* The output reference is to a Objective-C message. */
149 #define LLVMDisassembler_ReferenceType_Out_Objc_Message 5
150 /* The output reference is to a Objective-C message ref. */
151 #define LLVMDisassembler_ReferenceType_Out_Objc_Message_Ref 6
152 /* The output reference is to a Objective-C selector ref. */
153 #define LLVMDisassembler_ReferenceType_Out_Objc_Selector_Ref 7
154 /* The output reference is to a Objective-C class ref. */
155 #define LLVMDisassembler_ReferenceType_Out_Objc_Class_Ref 8
157 /* The output reference is to a C++ symbol name. */
158 #define LLVMDisassembler_ReferenceType_DeMangled_Name 9
160 #endif