LLVM 22.0.0git
Target.h
Go to the documentation of this file.
1/*===-- llvm-c/Target.h - Target Lib C Iface --------------------*- 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/*===----------------------------------------------------------------------===*/
9/* */
10/* This header declares the C interface to libLLVMTarget.a, which */
11/* implements target information. */
12/* */
13/* Many exotic languages can interoperate with C code but have a harder time */
14/* with C++ due to name mangling. So in addition to C, this interface enables */
15/* tools written in such languages. */
16/* */
17/*===----------------------------------------------------------------------===*/
18
19#ifndef LLVM_C_TARGET_H
20#define LLVM_C_TARGET_H
21
22#include "llvm-c/Deprecated.h"
23#include "llvm-c/ExternC.h"
24#include "llvm-c/Types.h"
25#include "llvm-c/Visibility.h"
26#include "llvm/Config/llvm-config.h"
27
29
30/**
31 * @defgroup LLVMCTarget Target information
32 * @ingroup LLVMC
33 *
34 * @{
35 */
36
38
39typedef struct LLVMOpaqueTargetData *LLVMTargetDataRef;
40typedef struct LLVMOpaqueTargetLibraryInfotData *LLVMTargetLibraryInfoRef;
41
42/* Declare all of the target-initialization functions that are available. */
43#define LLVM_TARGET(TargetName) \
44 LLVM_C_ABI void LLVMInitialize##TargetName##TargetInfo(void);
45#include "llvm/Config/Targets.def"
46#undef LLVM_TARGET /* Explicit undef to make SWIG happier */
47
48#define LLVM_TARGET(TargetName) \
49 LLVM_C_ABI void LLVMInitialize##TargetName##Target(void);
50#include "llvm/Config/Targets.def"
51#undef LLVM_TARGET /* Explicit undef to make SWIG happier */
52
53#define LLVM_TARGET(TargetName) \
54 LLVM_C_ABI void LLVMInitialize##TargetName##TargetMC(void);
55#include "llvm/Config/Targets.def"
56#undef LLVM_TARGET /* Explicit undef to make SWIG happier */
57
58/* Declare all of the available assembly printer initialization functions. */
59#define LLVM_ASM_PRINTER(TargetName) \
60 LLVM_C_ABI void LLVMInitialize##TargetName##AsmPrinter(void);
61#include "llvm/Config/AsmPrinters.def"
62#undef LLVM_ASM_PRINTER /* Explicit undef to make SWIG happier */
63
64/* Declare all of the available assembly parser initialization functions. */
65#define LLVM_ASM_PARSER(TargetName) \
66 LLVM_C_ABI void LLVMInitialize##TargetName##AsmParser(void);
67#include "llvm/Config/AsmParsers.def"
68#undef LLVM_ASM_PARSER /* Explicit undef to make SWIG happier */
69
70/* Declare all of the available disassembler initialization functions. */
71#define LLVM_DISASSEMBLER(TargetName) \
72 LLVM_C_ABI void LLVMInitialize##TargetName##Disassembler(void);
73#include "llvm/Config/Disassemblers.def"
74#undef LLVM_DISASSEMBLER /* Explicit undef to make SWIG happier */
75
76/** LLVMInitializeAllTargetInfos - The main program should call this function if
77 it wants access to all available targets that LLVM is configured to
78 support. */
79static inline void LLVMInitializeAllTargetInfos(void) {
80#define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##TargetInfo();
81#include "llvm/Config/Targets.def"
82#undef LLVM_TARGET /* Explicit undef to make SWIG happier */
83}
84
85/** LLVMInitializeAllTargets - The main program should call this function if it
86 wants to link in all available targets that LLVM is configured to
87 support. */
88static inline void LLVMInitializeAllTargets(void) {
89#define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##Target();
90#include "llvm/Config/Targets.def"
91#undef LLVM_TARGET /* Explicit undef to make SWIG happier */
92}
93
94/** LLVMInitializeAllTargetMCs - The main program should call this function if
95 it wants access to all available target MC that LLVM is configured to
96 support. */
97static inline void LLVMInitializeAllTargetMCs(void) {
98#define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##TargetMC();
99#include "llvm/Config/Targets.def"
100#undef LLVM_TARGET /* Explicit undef to make SWIG happier */
101}
102
103/** LLVMInitializeAllAsmPrinters - The main program should call this function if
104 it wants all asm printers that LLVM is configured to support, to make them
105 available via the TargetRegistry. */
106static inline void LLVMInitializeAllAsmPrinters(void) {
107#define LLVM_ASM_PRINTER(TargetName) LLVMInitialize##TargetName##AsmPrinter();
108#include "llvm/Config/AsmPrinters.def"
109#undef LLVM_ASM_PRINTER /* Explicit undef to make SWIG happier */
110}
111
112/** LLVMInitializeAllAsmParsers - The main program should call this function if
113 it wants all asm parsers that LLVM is configured to support, to make them
114 available via the TargetRegistry. */
115static inline void LLVMInitializeAllAsmParsers(void) {
116#define LLVM_ASM_PARSER(TargetName) LLVMInitialize##TargetName##AsmParser();
117#include "llvm/Config/AsmParsers.def"
118#undef LLVM_ASM_PARSER /* Explicit undef to make SWIG happier */
119}
120
121/** LLVMInitializeAllDisassemblers - The main program should call this function
122 if it wants all disassemblers that LLVM is configured to support, to make
123 them available via the TargetRegistry. */
124static inline void LLVMInitializeAllDisassemblers(void) {
125#define LLVM_DISASSEMBLER(TargetName) \
126 LLVMInitialize##TargetName##Disassembler();
127#include "llvm/Config/Disassemblers.def"
128#undef LLVM_DISASSEMBLER /* Explicit undef to make SWIG happier */
129}
130
131/** LLVMInitializeNativeTarget - The main program should call this function to
132 initialize the native target corresponding to the host. This is useful
133 for JIT applications to ensure that the target gets linked in correctly. */
135 /* If we have a native target, initialize it to ensure it is linked in. */
136#ifdef LLVM_NATIVE_TARGET
137 LLVM_NATIVE_TARGETINFO();
138 LLVM_NATIVE_TARGET();
139 LLVM_NATIVE_TARGETMC();
140 return 0;
141#else
142 return 1;
143#endif
144}
145
146/** LLVMInitializeNativeTargetAsmParser - The main program should call this
147 function to initialize the parser for the native target corresponding to the
148 host. */
150#ifdef LLVM_NATIVE_ASMPARSER
151 LLVM_NATIVE_ASMPARSER();
152 return 0;
153#else
154 return 1;
155#endif
156}
157
158/** LLVMInitializeNativeTargetAsmPrinter - The main program should call this
159 function to initialize the printer for the native target corresponding to
160 the host. */
162#ifdef LLVM_NATIVE_ASMPRINTER
163 LLVM_NATIVE_ASMPRINTER();
164 return 0;
165#else
166 return 1;
167#endif
168}
169
170/** LLVMInitializeNativeTargetDisassembler - The main program should call this
171 function to initialize the disassembler for the native target corresponding
172 to the host. */
174#ifdef LLVM_NATIVE_DISASSEMBLER
175 LLVM_NATIVE_DISASSEMBLER();
176 return 0;
177#else
178 return 1;
179#endif
180}
181
182/*===-- Target Data -------------------------------------------------------===*/
183
184/**
185 * Obtain the data layout for a module.
186 *
187 * @see Module::getDataLayout()
188 */
190
191/**
192 * Set the data layout for a module.
193 *
194 * @see Module::setDataLayout()
195 */
197
198/** Creates target data from a target layout string.
199 See the constructor llvm::DataLayout::DataLayout. */
201
202/** Deallocates a TargetData.
203 See the destructor llvm::DataLayout::~DataLayout. */
205
206/** Adds target library information to a pass manager. This does not take
207 ownership of the target library info.
208 See the method llvm::PassManagerBase::add. */
211
212/** Converts target data to a target layout string. The string must be disposed
213 with LLVMDisposeMessage.
214 See the constructor llvm::DataLayout::DataLayout. */
216
217/** Returns the byte order of a target, either LLVMBigEndian or
218 LLVMLittleEndian.
219 See the method llvm::DataLayout::isLittleEndian. */
221
222/** Returns the pointer size in bytes for a target.
223 See the method llvm::DataLayout::getPointerSize. */
225
226/** Returns the pointer size in bytes for a target for a specified
227 address space.
228 See the method llvm::DataLayout::getPointerSize. */
229LLVM_C_ABI unsigned LLVMPointerSizeForAS(LLVMTargetDataRef TD, unsigned AS);
230
231/** Returns the integer type that is the same size as a pointer on a target.
232 See the method llvm::DataLayout::getIntPtrType. */
235 "Use of the global context is deprecated, use "
236 "LLVMIntPtrTypeInContext instead");
237
238/** Returns the integer type that is the same size as a pointer on a target.
239 This version allows the address space to be specified.
240 See the method llvm::DataLayout::getIntPtrType. */
243 "Use of the global context is deprecated, use LLVMIntPtrTypeForASInContext "
244 "instead");
245
246/** Returns the integer type that is the same size as a pointer on a target.
247 See the method llvm::DataLayout::getIntPtrType. */
250
251/** Returns the integer type that is the same size as a pointer on a target.
252 This version allows the address space to be specified.
253 See the method llvm::DataLayout::getIntPtrType. */
256 unsigned AS);
257
258/** Computes the size of a type in bits for a target.
259 See the method llvm::DataLayout::getTypeSizeInBits. */
261 LLVMTypeRef Ty);
262
263/** Computes the storage size of a type in bytes for a target.
264 See the method llvm::DataLayout::getTypeStoreSize. */
266 LLVMTypeRef Ty);
267
268/** Computes the ABI size of a type in bytes for a target.
269 See the method llvm::DataLayout::getTypeAllocSize. */
271 LLVMTypeRef Ty);
272
273/** Computes the ABI alignment of a type in bytes for a target.
274 See the method llvm::DataLayout::getTypeABISize. */
276 LLVMTypeRef Ty);
277
278/** Computes the call frame alignment of a type in bytes for a target.
279 See the method llvm::DataLayout::getTypeABISize. */
281 LLVMTypeRef Ty);
282
283/** Computes the preferred alignment of a type in bytes for a target.
284 See the method llvm::DataLayout::getTypeABISize. */
286 LLVMTypeRef Ty);
287
288/** Computes the preferred alignment of a global variable in bytes for a target.
289 See the method llvm::DataLayout::getPreferredAlignment. */
291 LLVMValueRef GlobalVar);
292
293/** Computes the structure element that contains the byte offset for a target.
294 See the method llvm::StructLayout::getElementContainingOffset. */
296 LLVMTypeRef StructTy,
297 unsigned long long Offset);
298
299/** Computes the byte offset of the indexed struct element for a target.
300 See the method llvm::StructLayout::getElementContainingOffset. */
302 LLVMTypeRef StructTy,
303 unsigned Element);
304
305/**
306 * @}
307 */
308
310
311#endif
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
#define LLVM_ATTRIBUTE_C_DEPRECATED(decl, message)
Definition Deprecated.h:34
#define LLVM_C_EXTERN_C_BEGIN
Definition ExternC.h:35
#define LLVM_C_EXTERN_C_END
Definition ExternC.h:36
LLVMTypeRef LLVMIntPtrType(LLVMTargetDataRef TD)
Definition Target.cpp:79
LLVMTypeRef LLVMIntPtrTypeForAS(LLVMTargetDataRef TD, unsigned AS)
Definition Target.cpp:83
#define LLVM_C_ABI
LLVM_C_ABI is the export/visibility macro used to mark symbols declared in llvm-c as exported when bu...
Definition Visibility.h:40
struct LLVMOpaqueValue * LLVMValueRef
Represents an individual value in LLVM IR.
Definition Types.h:75
int LLVMBool
Definition Types.h:28
struct LLVMOpaquePassManager * LLVMPassManagerRef
Definition Types.h:127
struct LLVMOpaqueContext * LLVMContextRef
The top-level container for all LLVM global data.
Definition Types.h:53
struct LLVMOpaqueType * LLVMTypeRef
Each value in the LLVM IR has a type, an LLVMTypeRef.
Definition Types.h:68
struct LLVMOpaqueModule * LLVMModuleRef
The top-level container for all other LLVM Intermediate Representation (IR) objects.
Definition Types.h:61
static LLVMBool LLVMInitializeNativeAsmParser(void)
LLVMInitializeNativeTargetAsmParser - The main program should call this function to initialize the pa...
Definition Target.h:149
LLVM_C_ABI LLVMTargetDataRef LLVMGetModuleDataLayout(LLVMModuleRef M)
Obtain the data layout for a module.
Definition Target.cpp:41
LLVM_C_ABI LLVMTargetDataRef LLVMCreateTargetData(const char *StringRep)
Creates target data from a target layout string.
Definition Target.cpp:49
LLVM_C_ABI unsigned LLVMPreferredAlignmentOfType(LLVMTargetDataRef TD, LLVMTypeRef Ty)
Computes the preferred alignment of a type in bytes for a target.
Definition Target.cpp:116
LLVM_C_ABI unsigned LLVMCallFrameAlignmentOfType(LLVMTargetDataRef TD, LLVMTypeRef Ty)
Computes the call frame alignment of a type in bytes for a target.
Definition Target.cpp:112
LLVM_C_ABI unsigned long long LLVMOffsetOfElement(LLVMTargetDataRef TD, LLVMTypeRef StructTy, unsigned Element)
Computes the byte offset of the indexed struct element for a target.
Definition Target.cpp:133
LLVM_C_ABI void LLVMDisposeTargetData(LLVMTargetDataRef TD)
Deallocates a TargetData.
Definition Target.cpp:53
LLVM_C_ABI void LLVMAddTargetLibraryInfo(LLVMTargetLibraryInfoRef TLI, LLVMPassManagerRef PM)
Adds target library information to a pass manager.
Definition Target.cpp:57
LLVM_C_ABI enum LLVMByteOrdering LLVMByteOrder(LLVMTargetDataRef TD)
Returns the byte order of a target, either LLVMBigEndian or LLVMLittleEndian.
Definition Target.cpp:67
LLVM_C_ABI unsigned LLVMPreferredAlignmentOfGlobal(LLVMTargetDataRef TD, LLVMValueRef GlobalVar)
Computes the preferred alignment of a global variable in bytes for a target.
Definition Target.cpp:120
LLVM_C_ABI unsigned long long LLVMStoreSizeOfType(LLVMTargetDataRef TD, LLVMTypeRef Ty)
Computes the storage size of a type in bytes for a target.
Definition Target.cpp:100
static void LLVMInitializeAllTargetInfos(void)
LLVMInitializeAllTargetInfos - The main program should call this function if it wants access to all a...
Definition Target.h:79
LLVMByteOrdering
Definition Target.h:37
LLVM_C_ABI unsigned long long LLVMABISizeOfType(LLVMTargetDataRef TD, LLVMTypeRef Ty)
Computes the ABI size of a type in bytes for a target.
Definition Target.cpp:104
LLVM_C_ABI unsigned LLVMPointerSizeForAS(LLVMTargetDataRef TD, unsigned AS)
Returns the pointer size in bytes for a target for a specified address space.
Definition Target.cpp:75
LLVM_C_ABI unsigned LLVMABIAlignmentOfType(LLVMTargetDataRef TD, LLVMTypeRef Ty)
Computes the ABI alignment of a type in bytes for a target.
Definition Target.cpp:108
LLVM_C_ABI unsigned LLVMElementAtOffset(LLVMTargetDataRef TD, LLVMTypeRef StructTy, unsigned long long Offset)
Computes the structure element that contains the byte offset for a target.
Definition Target.cpp:127
LLVM_C_ABI LLVMTypeRef LLVMIntPtrTypeInContext(LLVMContextRef C, LLVMTargetDataRef TD)
Returns the integer type that is the same size as a pointer on a target.
Definition Target.cpp:88
static LLVMBool LLVMInitializeNativeAsmPrinter(void)
LLVMInitializeNativeTargetAsmPrinter - The main program should call this function to initialize the p...
Definition Target.h:161
static LLVMBool LLVMInitializeNativeDisassembler(void)
LLVMInitializeNativeTargetDisassembler - The main program should call this function to initialize the...
Definition Target.h:173
static void LLVMInitializeAllTargetMCs(void)
LLVMInitializeAllTargetMCs - The main program should call this function if it wants access to all ava...
Definition Target.h:97
LLVM_C_ABI char * LLVMCopyStringRepOfTargetData(LLVMTargetDataRef TD)
Converts target data to a target layout string.
Definition Target.cpp:62
LLVM_C_ABI unsigned LLVMPointerSize(LLVMTargetDataRef TD)
Returns the pointer size in bytes for a target.
Definition Target.cpp:71
LLVM_C_ABI LLVMTypeRef LLVMIntPtrTypeForASInContext(LLVMContextRef C, LLVMTargetDataRef TD, unsigned AS)
Returns the integer type that is the same size as a pointer on a target.
Definition Target.cpp:92
struct LLVMOpaqueTargetLibraryInfotData * LLVMTargetLibraryInfoRef
Definition Target.h:40
static void LLVMInitializeAllAsmParsers(void)
LLVMInitializeAllAsmParsers - The main program should call this function if it wants all asm parsers ...
Definition Target.h:115
LLVM_C_ABI void LLVMSetModuleDataLayout(LLVMModuleRef M, LLVMTargetDataRef DL)
Set the data layout for a module.
Definition Target.cpp:45
static LLVMBool LLVMInitializeNativeTarget(void)
LLVMInitializeNativeTarget - The main program should call this function to initialize the native targ...
Definition Target.h:134
LLVM_C_ABI unsigned long long LLVMSizeOfTypeInBits(LLVMTargetDataRef TD, LLVMTypeRef Ty)
Computes the size of a type in bits for a target.
Definition Target.cpp:96
static void LLVMInitializeAllTargets(void)
LLVMInitializeAllTargets - The main program should call this function if it wants to link in all avai...
Definition Target.h:88
struct LLVMOpaqueTargetData * LLVMTargetDataRef
Definition Target.h:39
static void LLVMInitializeAllAsmPrinters(void)
LLVMInitializeAllAsmPrinters - The main program should call this function if it wants all asm printer...
Definition Target.h:106
static void LLVMInitializeAllDisassemblers(void)
LLVMInitializeAllDisassemblers - The main program should call this function if it wants all disassemb...
Definition Target.h:124
@ LLVMBigEndian
Definition Target.h:37
@ LLVMLittleEndian
Definition Target.h:37