Thanks to visit codestin.com
Credit goes to llvm.org

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/ExternC.h"
23#include "llvm-c/Types.h"
24#include "llvm-c/Visibility.h"
25#include "llvm/Config/llvm-config.h"
26
28
29/**
30 * @defgroup LLVMCTarget Target information
31 * @ingroup LLVMC
32 *
33 * @{
34 */
35
37
38typedef struct LLVMOpaqueTargetData *LLVMTargetDataRef;
39typedef struct LLVMOpaqueTargetLibraryInfotData *LLVMTargetLibraryInfoRef;
40
41/* Declare all of the target-initialization functions that are available. */
42#define LLVM_TARGET(TargetName) \
43 LLVM_C_ABI void LLVMInitialize##TargetName##TargetInfo(void);
44#include "llvm/Config/Targets.def"
45#undef LLVM_TARGET /* Explicit undef to make SWIG happier */
46
47#define LLVM_TARGET(TargetName) \
48 LLVM_C_ABI void LLVMInitialize##TargetName##Target(void);
49#include "llvm/Config/Targets.def"
50#undef LLVM_TARGET /* Explicit undef to make SWIG happier */
51
52#define LLVM_TARGET(TargetName) \
53 LLVM_C_ABI void LLVMInitialize##TargetName##TargetMC(void);
54#include "llvm/Config/Targets.def"
55#undef LLVM_TARGET /* Explicit undef to make SWIG happier */
56
57/* Declare all of the available assembly printer initialization functions. */
58#define LLVM_ASM_PRINTER(TargetName) \
59 LLVM_C_ABI void LLVMInitialize##TargetName##AsmPrinter(void);
60#include "llvm/Config/AsmPrinters.def"
61#undef LLVM_ASM_PRINTER /* Explicit undef to make SWIG happier */
62
63/* Declare all of the available assembly parser initialization functions. */
64#define LLVM_ASM_PARSER(TargetName) \
65 LLVM_C_ABI void LLVMInitialize##TargetName##AsmParser(void);
66#include "llvm/Config/AsmParsers.def"
67#undef LLVM_ASM_PARSER /* Explicit undef to make SWIG happier */
68
69/* Declare all of the available disassembler initialization functions. */
70#define LLVM_DISASSEMBLER(TargetName) \
71 LLVM_C_ABI void LLVMInitialize##TargetName##Disassembler(void);
72#include "llvm/Config/Disassemblers.def"
73#undef LLVM_DISASSEMBLER /* Explicit undef to make SWIG happier */
74
75/** LLVMInitializeAllTargetInfos - The main program should call this function if
76 it wants access to all available targets that LLVM is configured to
77 support. */
78static inline void LLVMInitializeAllTargetInfos(void) {
79#define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##TargetInfo();
80#include "llvm/Config/Targets.def"
81#undef LLVM_TARGET /* Explicit undef to make SWIG happier */
82}
83
84/** LLVMInitializeAllTargets - The main program should call this function if it
85 wants to link in all available targets that LLVM is configured to
86 support. */
87static inline void LLVMInitializeAllTargets(void) {
88#define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##Target();
89#include "llvm/Config/Targets.def"
90#undef LLVM_TARGET /* Explicit undef to make SWIG happier */
91}
92
93/** LLVMInitializeAllTargetMCs - The main program should call this function if
94 it wants access to all available target MC that LLVM is configured to
95 support. */
96static inline void LLVMInitializeAllTargetMCs(void) {
97#define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##TargetMC();
98#include "llvm/Config/Targets.def"
99#undef LLVM_TARGET /* Explicit undef to make SWIG happier */
100}
101
102/** LLVMInitializeAllAsmPrinters - The main program should call this function if
103 it wants all asm printers that LLVM is configured to support, to make them
104 available via the TargetRegistry. */
105static inline void LLVMInitializeAllAsmPrinters(void) {
106#define LLVM_ASM_PRINTER(TargetName) LLVMInitialize##TargetName##AsmPrinter();
107#include "llvm/Config/AsmPrinters.def"
108#undef LLVM_ASM_PRINTER /* Explicit undef to make SWIG happier */
109}
110
111/** LLVMInitializeAllAsmParsers - The main program should call this function if
112 it wants all asm parsers that LLVM is configured to support, to make them
113 available via the TargetRegistry. */
114static inline void LLVMInitializeAllAsmParsers(void) {
115#define LLVM_ASM_PARSER(TargetName) LLVMInitialize##TargetName##AsmParser();
116#include "llvm/Config/AsmParsers.def"
117#undef LLVM_ASM_PARSER /* Explicit undef to make SWIG happier */
118}
119
120/** LLVMInitializeAllDisassemblers - The main program should call this function
121 if it wants all disassemblers that LLVM is configured to support, to make
122 them available via the TargetRegistry. */
123static inline void LLVMInitializeAllDisassemblers(void) {
124#define LLVM_DISASSEMBLER(TargetName) \
125 LLVMInitialize##TargetName##Disassembler();
126#include "llvm/Config/Disassemblers.def"
127#undef LLVM_DISASSEMBLER /* Explicit undef to make SWIG happier */
128}
129
130/** LLVMInitializeNativeTarget - The main program should call this function to
131 initialize the native target corresponding to the host. This is useful
132 for JIT applications to ensure that the target gets linked in correctly. */
134 /* If we have a native target, initialize it to ensure it is linked in. */
135#ifdef LLVM_NATIVE_TARGET
136 LLVM_NATIVE_TARGETINFO();
137 LLVM_NATIVE_TARGET();
138 LLVM_NATIVE_TARGETMC();
139 return 0;
140#else
141 return 1;
142#endif
143}
144
145/** LLVMInitializeNativeTargetAsmParser - The main program should call this
146 function to initialize the parser for the native target corresponding to the
147 host. */
149#ifdef LLVM_NATIVE_ASMPARSER
150 LLVM_NATIVE_ASMPARSER();
151 return 0;
152#else
153 return 1;
154#endif
155}
156
157/** LLVMInitializeNativeTargetAsmPrinter - The main program should call this
158 function to initialize the printer for the native target corresponding to
159 the host. */
161#ifdef LLVM_NATIVE_ASMPRINTER
162 LLVM_NATIVE_ASMPRINTER();
163 return 0;
164#else
165 return 1;
166#endif
167}
168
169/** LLVMInitializeNativeTargetDisassembler - The main program should call this
170 function to initialize the disassembler for the native target corresponding
171 to the host. */
173#ifdef LLVM_NATIVE_DISASSEMBLER
174 LLVM_NATIVE_DISASSEMBLER();
175 return 0;
176#else
177 return 1;
178#endif
179}
180
181/*===-- Target Data -------------------------------------------------------===*/
182
183/**
184 * Obtain the data layout for a module.
185 *
186 * @see Module::getDataLayout()
187 */
189
190/**
191 * Set the data layout for a module.
192 *
193 * @see Module::setDataLayout()
194 */
196
197/** Creates target data from a target layout string.
198 See the constructor llvm::DataLayout::DataLayout. */
200
201/** Deallocates a TargetData.
202 See the destructor llvm::DataLayout::~DataLayout. */
204
205/** Adds target library information to a pass manager. This does not take
206 ownership of the target library info.
207 See the method llvm::PassManagerBase::add. */
210
211/** Converts target data to a target layout string. The string must be disposed
212 with LLVMDisposeMessage.
213 See the constructor llvm::DataLayout::DataLayout. */
215
216/** Returns the byte order of a target, either LLVMBigEndian or
217 LLVMLittleEndian.
218 See the method llvm::DataLayout::isLittleEndian. */
220
221/** Returns the pointer size in bytes for a target.
222 See the method llvm::DataLayout::getPointerSize. */
224
225/** Returns the pointer size in bytes for a target for a specified
226 address space.
227 See the method llvm::DataLayout::getPointerSize. */
228LLVM_C_ABI unsigned LLVMPointerSizeForAS(LLVMTargetDataRef TD, unsigned AS);
229
230/** Returns the integer type that is the same size as a pointer on a target.
231 See the method llvm::DataLayout::getIntPtrType. */
233
234/** Returns the integer type that is the same size as a pointer on a target.
235 This version allows the address space to be specified.
236 See the method llvm::DataLayout::getIntPtrType. */
238
239/** Returns the integer type that is the same size as a pointer on a target.
240 See the method llvm::DataLayout::getIntPtrType. */
243
244/** Returns the integer type that is the same size as a pointer on a target.
245 This version allows the address space to be specified.
246 See the method llvm::DataLayout::getIntPtrType. */
249 unsigned AS);
250
251/** Computes the size of a type in bits for a target.
252 See the method llvm::DataLayout::getTypeSizeInBits. */
254 LLVMTypeRef Ty);
255
256/** Computes the storage size of a type in bytes for a target.
257 See the method llvm::DataLayout::getTypeStoreSize. */
259 LLVMTypeRef Ty);
260
261/** Computes the ABI size of a type in bytes for a target.
262 See the method llvm::DataLayout::getTypeAllocSize. */
264 LLVMTypeRef Ty);
265
266/** Computes the ABI alignment of a type in bytes for a target.
267 See the method llvm::DataLayout::getTypeABISize. */
269 LLVMTypeRef Ty);
270
271/** Computes the call frame alignment of a type in bytes for a target.
272 See the method llvm::DataLayout::getTypeABISize. */
274 LLVMTypeRef Ty);
275
276/** Computes the preferred alignment of a type in bytes for a target.
277 See the method llvm::DataLayout::getTypeABISize. */
279 LLVMTypeRef Ty);
280
281/** Computes the preferred alignment of a global variable in bytes for a target.
282 See the method llvm::DataLayout::getPreferredAlignment. */
284 LLVMValueRef GlobalVar);
285
286/** Computes the structure element that contains the byte offset for a target.
287 See the method llvm::StructLayout::getElementContainingOffset. */
289 LLVMTypeRef StructTy,
290 unsigned long long Offset);
291
292/** Computes the byte offset of the indexed struct element for a target.
293 See the method llvm::StructLayout::getElementContainingOffset. */
295 LLVMTypeRef StructTy,
296 unsigned Element);
297
298/**
299 * @}
300 */
301
303
304#endif
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
#define LLVM_C_EXTERN_C_BEGIN
Definition ExternC.h:35
#define LLVM_C_EXTERN_C_END
Definition ExternC.h:36
#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:148
LLVM_C_ABI LLVMTypeRef LLVMIntPtrTypeForAS(LLVMTargetDataRef TD, unsigned AS)
Returns the integer type that is the same size as a pointer on a target.
Definition Target.cpp:85
LLVM_C_ABI LLVMTargetDataRef LLVMGetModuleDataLayout(LLVMModuleRef M)
Obtain the data layout for a module.
Definition Target.cpp:43
LLVM_C_ABI LLVMTargetDataRef LLVMCreateTargetData(const char *StringRep)
Creates target data from a target layout string.
Definition Target.cpp:51
LLVM_C_ABI unsigned LLVMPreferredAlignmentOfType(LLVMTargetDataRef TD, LLVMTypeRef Ty)
Computes the preferred alignment of a type in bytes for a target.
Definition Target.cpp:117
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:113
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:134
LLVM_C_ABI void LLVMDisposeTargetData(LLVMTargetDataRef TD)
Deallocates a TargetData.
Definition Target.cpp:55
LLVM_C_ABI void LLVMAddTargetLibraryInfo(LLVMTargetLibraryInfoRef TLI, LLVMPassManagerRef PM)
Adds target library information to a pass manager.
Definition Target.cpp:59
LLVM_C_ABI enum LLVMByteOrdering LLVMByteOrder(LLVMTargetDataRef TD)
Returns the byte order of a target, either LLVMBigEndian or LLVMLittleEndian.
Definition Target.cpp:69
LLVM_C_ABI LLVMTypeRef LLVMIntPtrType(LLVMTargetDataRef TD)
Returns the integer type that is the same size as a pointer on a target.
Definition Target.cpp:81
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:121
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:101
static void LLVMInitializeAllTargetInfos(void)
LLVMInitializeAllTargetInfos - The main program should call this function if it wants access to all a...
Definition Target.h:78
LLVMByteOrdering
Definition Target.h:36
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:105
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:77
LLVM_C_ABI unsigned LLVMABIAlignmentOfType(LLVMTargetDataRef TD, LLVMTypeRef Ty)
Computes the ABI alignment of a type in bytes for a target.
Definition Target.cpp:109
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:128
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:89
static LLVMBool LLVMInitializeNativeAsmPrinter(void)
LLVMInitializeNativeTargetAsmPrinter - The main program should call this function to initialize the p...
Definition Target.h:160
static LLVMBool LLVMInitializeNativeDisassembler(void)
LLVMInitializeNativeTargetDisassembler - The main program should call this function to initialize the...
Definition Target.h:172
static void LLVMInitializeAllTargetMCs(void)
LLVMInitializeAllTargetMCs - The main program should call this function if it wants access to all ava...
Definition Target.h:96
LLVM_C_ABI char * LLVMCopyStringRepOfTargetData(LLVMTargetDataRef TD)
Converts target data to a target layout string.
Definition Target.cpp:64
LLVM_C_ABI unsigned LLVMPointerSize(LLVMTargetDataRef TD)
Returns the pointer size in bytes for a target.
Definition Target.cpp:73
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:93
struct LLVMOpaqueTargetLibraryInfotData * LLVMTargetLibraryInfoRef
Definition Target.h:39
static void LLVMInitializeAllAsmParsers(void)
LLVMInitializeAllAsmParsers - The main program should call this function if it wants all asm parsers ...
Definition Target.h:114
LLVM_C_ABI void LLVMSetModuleDataLayout(LLVMModuleRef M, LLVMTargetDataRef DL)
Set the data layout for a module.
Definition Target.cpp:47
static LLVMBool LLVMInitializeNativeTarget(void)
LLVMInitializeNativeTarget - The main program should call this function to initialize the native targ...
Definition Target.h:133
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:97
static void LLVMInitializeAllTargets(void)
LLVMInitializeAllTargets - The main program should call this function if it wants to link in all avai...
Definition Target.h:87
struct LLVMOpaqueTargetData * LLVMTargetDataRef
Definition Target.h:38
static void LLVMInitializeAllAsmPrinters(void)
LLVMInitializeAllAsmPrinters - The main program should call this function if it wants all asm printer...
Definition Target.h:105
static void LLVMInitializeAllDisassemblers(void)
LLVMInitializeAllDisassemblers - The main program should call this function if it wants all disassemb...
Definition Target.h:123
@ LLVMBigEndian
Definition Target.h:36
@ LLVMLittleEndian
Definition Target.h:36