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