revert a hunk of r82018 that wasn't supposed to go in yet.
[llvm/avr.git] / include / llvm-c / Core.h
blob40696e0aceb159790f142a963310c7f0e4afc347
1 /*===-- llvm-c/Core.h - Core Library 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 declares the C interface to libLLVMCore.a, which implements *|
11 |* the LLVM intermediate representation. *|
12 |* *|
13 |* LLVM uses a polymorphic type hierarchy which C cannot represent, therefore *|
14 |* parameters must be passed as base types. Despite the declared types, most *|
15 |* of the functions provided operate only on branches of the type hierarchy. *|
16 |* The declared parameter names are descriptive and specify which type is *|
17 |* required. Additionally, each type hierarchy is documented along with the *|
18 |* functions that operate upon it. For more detail, refer to LLVM's C++ code. *|
19 |* If in doubt, refer to Core.cpp, which performs paramter downcasts in the *|
20 |* form unwrap<RequiredType>(Param). *|
21 |* *|
22 |* Many exotic languages can interoperate with C code but have a harder time *|
23 |* with C++ due to name mangling. So in addition to C, this interface enables *|
24 |* tools written in such languages. *|
25 |* *|
26 |* When included into a C++ source file, also declares 'wrap' and 'unwrap' *|
27 |* helpers to perform opaque reference<-->pointer conversions. These helpers *|
28 |* are shorter and more tightly typed than writing the casts by hand when *|
29 |* authoring bindings. In assert builds, they will do runtime type checking. *|
30 |* *|
31 \*===----------------------------------------------------------------------===*/
33 #ifndef LLVM_C_CORE_H
34 #define LLVM_C_CORE_H
36 #include "llvm/Support/DataTypes.h"
38 #ifdef __cplusplus
40 /* Need these includes to support the LLVM 'cast' template for the C++ 'wrap'
41 and 'unwrap' conversion functions. */
42 #include "llvm/Module.h"
43 #include "llvm/Support/IRBuilder.h"
45 extern "C" {
46 #endif
49 /* Opaque types. */
51 /**
52 * The top-level container for all LLVM global data. See the LLVMContext class.
54 typedef struct LLVMOpaqueContext *LLVMContextRef;
56 /**
57 * The top-level container for all other LLVM Intermediate Representation (IR)
58 * objects. See the llvm::Module class.
60 typedef struct LLVMOpaqueModule *LLVMModuleRef;
62 /**
63 * Each value in the LLVM IR has a type, an LLVMTypeRef. See the llvm::Type
64 * class.
66 typedef struct LLVMOpaqueType *LLVMTypeRef;
68 /**
69 * When building recursive types using LLVMRefineType, LLVMTypeRef values may
70 * become invalid; use LLVMTypeHandleRef to resolve this problem. See the
71 * llvm::AbstractTypeHolder class.
73 typedef struct LLVMOpaqueTypeHandle *LLVMTypeHandleRef;
75 typedef struct LLVMOpaqueValue *LLVMValueRef;
76 typedef struct LLVMOpaqueBasicBlock *LLVMBasicBlockRef;
77 typedef struct LLVMOpaqueBuilder *LLVMBuilderRef;
79 /* Used to provide a module to JIT or interpreter.
80 * See the llvm::ModuleProvider class.
82 typedef struct LLVMOpaqueModuleProvider *LLVMModuleProviderRef;
84 /* Used to provide a module to JIT or interpreter.
85 * See the llvm::MemoryBuffer class.
87 typedef struct LLVMOpaqueMemoryBuffer *LLVMMemoryBufferRef;
89 /** See the llvm::PassManagerBase class. */
90 typedef struct LLVMOpaquePassManager *LLVMPassManagerRef;
92 typedef enum {
93 LLVMZExtAttribute = 1<<0,
94 LLVMSExtAttribute = 1<<1,
95 LLVMNoReturnAttribute = 1<<2,
96 LLVMInRegAttribute = 1<<3,
97 LLVMStructRetAttribute = 1<<4,
98 LLVMNoUnwindAttribute = 1<<5,
99 LLVMNoAliasAttribute = 1<<6,
100 LLVMByValAttribute = 1<<7,
101 LLVMNestAttribute = 1<<8,
102 LLVMReadNoneAttribute = 1<<9,
103 LLVMReadOnlyAttribute = 1<<10,
104 LLVMNoInlineAttribute = 1<<11,
105 LLVMAlwaysInlineAttribute = 1<<12,
106 LLVMOptimizeForSizeAttribute = 1<<13,
107 LLVMStackProtectAttribute = 1<<14,
108 LLVMStackProtectReqAttribute = 1<<15,
109 LLVMNoCaptureAttribute = 1<<21,
110 LLVMNoRedZoneAttribute = 1<<22,
111 LLVMNoImplicitFloatAttribute = 1<<23,
112 LLVMNakedAttribute = 1<<24,
113 LLVMInlineHintAttribute = 1<<25
114 } LLVMAttribute;
116 typedef enum {
117 LLVMVoidTypeKind, /**< type with no size */
118 LLVMFloatTypeKind, /**< 32 bit floating point type */
119 LLVMDoubleTypeKind, /**< 64 bit floating point type */
120 LLVMX86_FP80TypeKind, /**< 80 bit floating point type (X87) */
121 LLVMFP128TypeKind, /**< 128 bit floating point type (112-bit mantissa)*/
122 LLVMPPC_FP128TypeKind, /**< 128 bit floating point type (two 64-bits) */
123 LLVMLabelTypeKind, /**< Labels */
124 LLVMIntegerTypeKind, /**< Arbitrary bit width integers */
125 LLVMFunctionTypeKind, /**< Functions */
126 LLVMStructTypeKind, /**< Structures */
127 LLVMArrayTypeKind, /**< Arrays */
128 LLVMPointerTypeKind, /**< Pointers */
129 LLVMOpaqueTypeKind, /**< Opaque: type with unknown structure */
130 LLVMVectorTypeKind, /**< SIMD 'packed' format, or other vector type */
131 LLVMMetadataTypeKind /**< Metadata */
132 } LLVMTypeKind;
134 typedef enum {
135 LLVMExternalLinkage, /**< Externally visible function */
136 LLVMAvailableExternallyLinkage,
137 LLVMLinkOnceAnyLinkage, /**< Keep one copy of function when linking (inline)*/
138 LLVMLinkOnceODRLinkage, /**< Same, but only replaced by something
139 equivalent. */
140 LLVMWeakAnyLinkage, /**< Keep one copy of function when linking (weak) */
141 LLVMWeakODRLinkage, /**< Same, but only replaced by something
142 equivalent. */
143 LLVMAppendingLinkage, /**< Special purpose, only applies to global arrays */
144 LLVMInternalLinkage, /**< Rename collisions when linking (static
145 functions) */
146 LLVMPrivateLinkage, /**< Like Internal, but omit from symbol table */
147 LLVMDLLImportLinkage, /**< Function to be imported from DLL */
148 LLVMDLLExportLinkage, /**< Function to be accessible from DLL */
149 LLVMExternalWeakLinkage,/**< ExternalWeak linkage description */
150 LLVMGhostLinkage, /**< Stand-in functions for streaming fns from
151 bitcode */
152 LLVMCommonLinkage, /**< Tentative definitions */
153 LLVMLinkerPrivateLinkage /**< Like Private, but linker removes. */
154 } LLVMLinkage;
156 typedef enum {
157 LLVMDefaultVisibility, /**< The GV is visible */
158 LLVMHiddenVisibility, /**< The GV is hidden */
159 LLVMProtectedVisibility /**< The GV is protected */
160 } LLVMVisibility;
162 typedef enum {
163 LLVMCCallConv = 0,
164 LLVMFastCallConv = 8,
165 LLVMColdCallConv = 9,
166 LLVMX86StdcallCallConv = 64,
167 LLVMX86FastcallCallConv = 65
168 } LLVMCallConv;
170 typedef enum {
171 LLVMIntEQ = 32, /**< equal */
172 LLVMIntNE, /**< not equal */
173 LLVMIntUGT, /**< unsigned greater than */
174 LLVMIntUGE, /**< unsigned greater or equal */
175 LLVMIntULT, /**< unsigned less than */
176 LLVMIntULE, /**< unsigned less or equal */
177 LLVMIntSGT, /**< signed greater than */
178 LLVMIntSGE, /**< signed greater or equal */
179 LLVMIntSLT, /**< signed less than */
180 LLVMIntSLE /**< signed less or equal */
181 } LLVMIntPredicate;
183 typedef enum {
184 LLVMRealPredicateFalse, /**< Always false (always folded) */
185 LLVMRealOEQ, /**< True if ordered and equal */
186 LLVMRealOGT, /**< True if ordered and greater than */
187 LLVMRealOGE, /**< True if ordered and greater than or equal */
188 LLVMRealOLT, /**< True if ordered and less than */
189 LLVMRealOLE, /**< True if ordered and less than or equal */
190 LLVMRealONE, /**< True if ordered and operands are unequal */
191 LLVMRealORD, /**< True if ordered (no nans) */
192 LLVMRealUNO, /**< True if unordered: isnan(X) | isnan(Y) */
193 LLVMRealUEQ, /**< True if unordered or equal */
194 LLVMRealUGT, /**< True if unordered or greater than */
195 LLVMRealUGE, /**< True if unordered, greater than, or equal */
196 LLVMRealULT, /**< True if unordered or less than */
197 LLVMRealULE, /**< True if unordered, less than, or equal */
198 LLVMRealUNE, /**< True if unordered or not equal */
199 LLVMRealPredicateTrue /**< Always true (always folded) */
200 } LLVMRealPredicate;
203 /*===-- Error handling ----------------------------------------------------===*/
205 void LLVMDisposeMessage(char *Message);
208 /*===-- Modules -----------------------------------------------------------===*/
210 /* Create and destroy contexts. */
211 LLVMContextRef LLVMContextCreate(void);
212 LLVMContextRef LLVMGetGlobalContext(void);
213 void LLVMContextDispose(LLVMContextRef C);
215 /* Create and destroy modules. */
216 /** See llvm::Module::Module. */
217 LLVMModuleRef LLVMModuleCreateWithName(const char *ModuleID);
218 LLVMModuleRef LLVMModuleCreateWithNameInContext(const char *ModuleID,
219 LLVMContextRef C);
221 /** See llvm::Module::~Module. */
222 void LLVMDisposeModule(LLVMModuleRef M);
224 /** Data layout. See Module::getDataLayout. */
225 const char *LLVMGetDataLayout(LLVMModuleRef M);
226 void LLVMSetDataLayout(LLVMModuleRef M, const char *Triple);
228 /** Target triple. See Module::getTargetTriple. */
229 const char *LLVMGetTarget(LLVMModuleRef M);
230 void LLVMSetTarget(LLVMModuleRef M, const char *Triple);
232 /** See Module::addTypeName. */
233 int LLVMAddTypeName(LLVMModuleRef M, const char *Name, LLVMTypeRef Ty);
234 void LLVMDeleteTypeName(LLVMModuleRef M, const char *Name);
235 LLVMTypeRef LLVMGetTypeByName(LLVMModuleRef M, const char *Name);
237 /** See Module::dump. */
238 void LLVMDumpModule(LLVMModuleRef M);
241 /*===-- Types -------------------------------------------------------------===*/
243 /* LLVM types conform to the following hierarchy:
245 * types:
246 * integer type
247 * real type
248 * function type
249 * sequence types:
250 * array type
251 * pointer type
252 * vector type
253 * void type
254 * label type
255 * opaque type
258 /** See llvm::LLVMTypeKind::getTypeID. */
259 LLVMTypeKind LLVMGetTypeKind(LLVMTypeRef Ty);
261 /** See llvm::LLVMType::getContext. */
262 LLVMContextRef LLVMGetTypeContext(LLVMTypeRef Ty);
264 /* Operations on integer types */
265 LLVMTypeRef LLVMInt1TypeInContext(LLVMContextRef C);
266 LLVMTypeRef LLVMInt8TypeInContext(LLVMContextRef C);
267 LLVMTypeRef LLVMInt16TypeInContext(LLVMContextRef C);
268 LLVMTypeRef LLVMInt32TypeInContext(LLVMContextRef C);
269 LLVMTypeRef LLVMInt64TypeInContext(LLVMContextRef C);
270 LLVMTypeRef LLVMIntTypeInContext(LLVMContextRef C, unsigned NumBits);
272 LLVMTypeRef LLVMInt1Type(void);
273 LLVMTypeRef LLVMInt8Type(void);
274 LLVMTypeRef LLVMInt16Type(void);
275 LLVMTypeRef LLVMInt32Type(void);
276 LLVMTypeRef LLVMInt64Type(void);
277 LLVMTypeRef LLVMIntType(unsigned NumBits);
278 unsigned LLVMGetIntTypeWidth(LLVMTypeRef IntegerTy);
280 /* Operations on real types */
281 LLVMTypeRef LLVMFloatTypeInContext(LLVMContextRef C);
282 LLVMTypeRef LLVMDoubleTypeInContext(LLVMContextRef C);
283 LLVMTypeRef LLVMX86FP80TypeInContext(LLVMContextRef C);
284 LLVMTypeRef LLVMFP128TypeInContext(LLVMContextRef C);
285 LLVMTypeRef LLVMPPCFP128TypeInContext(LLVMContextRef C);
287 LLVMTypeRef LLVMFloatType(void);
288 LLVMTypeRef LLVMDoubleType(void);
289 LLVMTypeRef LLVMX86FP80Type(void);
290 LLVMTypeRef LLVMFP128Type(void);
291 LLVMTypeRef LLVMPPCFP128Type(void);
293 /* Operations on function types */
294 LLVMTypeRef LLVMFunctionType(LLVMTypeRef ReturnType,
295 LLVMTypeRef *ParamTypes, unsigned ParamCount,
296 int IsVarArg);
297 int LLVMIsFunctionVarArg(LLVMTypeRef FunctionTy);
298 LLVMTypeRef LLVMGetReturnType(LLVMTypeRef FunctionTy);
299 unsigned LLVMCountParamTypes(LLVMTypeRef FunctionTy);
300 void LLVMGetParamTypes(LLVMTypeRef FunctionTy, LLVMTypeRef *Dest);
302 /* Operations on struct types */
303 LLVMTypeRef LLVMStructTypeInContext(LLVMContextRef C, LLVMTypeRef *ElementTypes,
304 unsigned ElementCount, int Packed);
305 LLVMTypeRef LLVMStructType(LLVMTypeRef *ElementTypes, unsigned ElementCount,
306 int Packed);
307 unsigned LLVMCountStructElementTypes(LLVMTypeRef StructTy);
308 void LLVMGetStructElementTypes(LLVMTypeRef StructTy, LLVMTypeRef *Dest);
309 int LLVMIsPackedStruct(LLVMTypeRef StructTy);
311 /* Operations on array, pointer, and vector types (sequence types) */
312 LLVMTypeRef LLVMArrayType(LLVMTypeRef ElementType, unsigned ElementCount);
313 LLVMTypeRef LLVMPointerType(LLVMTypeRef ElementType, unsigned AddressSpace);
314 LLVMTypeRef LLVMVectorType(LLVMTypeRef ElementType, unsigned ElementCount);
316 LLVMTypeRef LLVMGetElementType(LLVMTypeRef Ty);
317 unsigned LLVMGetArrayLength(LLVMTypeRef ArrayTy);
318 unsigned LLVMGetPointerAddressSpace(LLVMTypeRef PointerTy);
319 unsigned LLVMGetVectorSize(LLVMTypeRef VectorTy);
321 /* Operations on other types */
322 LLVMTypeRef LLVMVoidTypeInContext(LLVMContextRef C);
323 LLVMTypeRef LLVMLabelTypeInContext(LLVMContextRef C);
324 LLVMTypeRef LLVMOpaqueTypeInContext(LLVMContextRef C);
326 LLVMTypeRef LLVMVoidType(void);
327 LLVMTypeRef LLVMLabelType(void);
328 LLVMTypeRef LLVMOpaqueType(void);
330 /* Operations on type handles */
331 LLVMTypeHandleRef LLVMCreateTypeHandle(LLVMTypeRef PotentiallyAbstractTy);
332 void LLVMRefineType(LLVMTypeRef AbstractTy, LLVMTypeRef ConcreteTy);
333 LLVMTypeRef LLVMResolveTypeHandle(LLVMTypeHandleRef TypeHandle);
334 void LLVMDisposeTypeHandle(LLVMTypeHandleRef TypeHandle);
337 /*===-- Values ------------------------------------------------------------===*/
339 /* The bulk of LLVM's object model consists of values, which comprise a very
340 * rich type hierarchy.
343 #define LLVM_FOR_EACH_VALUE_SUBCLASS(macro) \
344 macro(Argument) \
345 macro(BasicBlock) \
346 macro(InlineAsm) \
347 macro(User) \
348 macro(Constant) \
349 macro(ConstantAggregateZero) \
350 macro(ConstantArray) \
351 macro(ConstantExpr) \
352 macro(ConstantFP) \
353 macro(ConstantInt) \
354 macro(ConstantPointerNull) \
355 macro(ConstantStruct) \
356 macro(ConstantVector) \
357 macro(GlobalValue) \
358 macro(Function) \
359 macro(GlobalAlias) \
360 macro(GlobalVariable) \
361 macro(UndefValue) \
362 macro(Instruction) \
363 macro(BinaryOperator) \
364 macro(CallInst) \
365 macro(IntrinsicInst) \
366 macro(DbgInfoIntrinsic) \
367 macro(DbgDeclareInst) \
368 macro(DbgFuncStartInst) \
369 macro(DbgRegionEndInst) \
370 macro(DbgRegionStartInst) \
371 macro(DbgStopPointInst) \
372 macro(EHSelectorInst) \
373 macro(MemIntrinsic) \
374 macro(MemCpyInst) \
375 macro(MemMoveInst) \
376 macro(MemSetInst) \
377 macro(CmpInst) \
378 macro(FCmpInst) \
379 macro(ICmpInst) \
380 macro(ExtractElementInst) \
381 macro(GetElementPtrInst) \
382 macro(InsertElementInst) \
383 macro(InsertValueInst) \
384 macro(PHINode) \
385 macro(SelectInst) \
386 macro(ShuffleVectorInst) \
387 macro(StoreInst) \
388 macro(TerminatorInst) \
389 macro(BranchInst) \
390 macro(InvokeInst) \
391 macro(ReturnInst) \
392 macro(SwitchInst) \
393 macro(UnreachableInst) \
394 macro(UnwindInst) \
395 macro(UnaryInstruction) \
396 macro(AllocationInst) \
397 macro(AllocaInst) \
398 macro(MallocInst) \
399 macro(CastInst) \
400 macro(BitCastInst) \
401 macro(FPExtInst) \
402 macro(FPToSIInst) \
403 macro(FPToUIInst) \
404 macro(FPTruncInst) \
405 macro(IntToPtrInst) \
406 macro(PtrToIntInst) \
407 macro(SExtInst) \
408 macro(SIToFPInst) \
409 macro(TruncInst) \
410 macro(UIToFPInst) \
411 macro(ZExtInst) \
412 macro(ExtractValueInst) \
413 macro(FreeInst) \
414 macro(LoadInst) \
415 macro(VAArgInst)
417 /* Operations on all values */
418 LLVMTypeRef LLVMTypeOf(LLVMValueRef Val);
419 const char *LLVMGetValueName(LLVMValueRef Val);
420 void LLVMSetValueName(LLVMValueRef Val, const char *Name);
421 void LLVMDumpValue(LLVMValueRef Val);
423 /* Conversion functions. Return the input value if it is an instance of the
424 specified class, otherwise NULL. See llvm::dyn_cast_or_null<>. */
425 #define LLVM_DECLARE_VALUE_CAST(name) \
426 LLVMValueRef LLVMIsA##name(LLVMValueRef Val);
427 LLVM_FOR_EACH_VALUE_SUBCLASS(LLVM_DECLARE_VALUE_CAST)
429 /* Operations on constants of any type */
430 LLVMValueRef LLVMConstNull(LLVMTypeRef Ty); /* all zeroes */
431 LLVMValueRef LLVMConstAllOnes(LLVMTypeRef Ty); /* only for int/vector */
432 LLVMValueRef LLVMGetUndef(LLVMTypeRef Ty);
433 int LLVMIsConstant(LLVMValueRef Val);
434 int LLVMIsNull(LLVMValueRef Val);
435 int LLVMIsUndef(LLVMValueRef Val);
436 LLVMValueRef LLVMConstPointerNull(LLVMTypeRef Ty);
438 /* Operations on scalar constants */
439 LLVMValueRef LLVMConstInt(LLVMTypeRef IntTy, unsigned long long N,
440 int SignExtend);
441 LLVMValueRef LLVMConstIntOfString(LLVMTypeRef IntTy, const char *Text,
442 uint8_t Radix);
443 LLVMValueRef LLVMConstIntOfStringAndSize(LLVMTypeRef IntTy, const char *Text,
444 unsigned SLen, uint8_t Radix);
445 LLVMValueRef LLVMConstReal(LLVMTypeRef RealTy, double N);
446 LLVMValueRef LLVMConstRealOfString(LLVMTypeRef RealTy, const char *Text);
447 LLVMValueRef LLVMConstRealOfStringAndSize(LLVMTypeRef RealTy, const char *Text,
448 unsigned SLen);
451 /* Operations on composite constants */
452 LLVMValueRef LLVMConstStringInContext(LLVMContextRef C, const char *Str,
453 unsigned Length, int DontNullTerminate);
454 LLVMValueRef LLVMConstStructInContext(LLVMContextRef C,
455 LLVMValueRef *ConstantVals,
456 unsigned Count, int Packed);
458 LLVMValueRef LLVMConstString(const char *Str, unsigned Length,
459 int DontNullTerminate);
460 LLVMValueRef LLVMConstArray(LLVMTypeRef ElementTy,
461 LLVMValueRef *ConstantVals, unsigned Length);
462 LLVMValueRef LLVMConstStruct(LLVMValueRef *ConstantVals, unsigned Count,
463 int Packed);
464 LLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals, unsigned Size);
466 /* Constant expressions */
467 LLVMValueRef LLVMAlignOf(LLVMTypeRef Ty);
468 LLVMValueRef LLVMSizeOf(LLVMTypeRef Ty);
469 LLVMValueRef LLVMConstNeg(LLVMValueRef ConstantVal);
470 LLVMValueRef LLVMConstFNeg(LLVMValueRef ConstantVal);
471 LLVMValueRef LLVMConstNot(LLVMValueRef ConstantVal);
472 LLVMValueRef LLVMConstAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
473 LLVMValueRef LLVMConstNSWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
474 LLVMValueRef LLVMConstFAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
475 LLVMValueRef LLVMConstSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
476 LLVMValueRef LLVMConstFSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
477 LLVMValueRef LLVMConstMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
478 LLVMValueRef LLVMConstFMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
479 LLVMValueRef LLVMConstUDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
480 LLVMValueRef LLVMConstSDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
481 LLVMValueRef LLVMConstExactSDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
482 LLVMValueRef LLVMConstFDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
483 LLVMValueRef LLVMConstURem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
484 LLVMValueRef LLVMConstSRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
485 LLVMValueRef LLVMConstFRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
486 LLVMValueRef LLVMConstAnd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
487 LLVMValueRef LLVMConstOr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
488 LLVMValueRef LLVMConstXor(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
489 LLVMValueRef LLVMConstICmp(LLVMIntPredicate Predicate,
490 LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
491 LLVMValueRef LLVMConstFCmp(LLVMRealPredicate Predicate,
492 LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
493 LLVMValueRef LLVMConstShl(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
494 LLVMValueRef LLVMConstLShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
495 LLVMValueRef LLVMConstAShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
496 LLVMValueRef LLVMConstGEP(LLVMValueRef ConstantVal,
497 LLVMValueRef *ConstantIndices, unsigned NumIndices);
498 LLVMValueRef LLVMConstInBoundsGEP(LLVMValueRef ConstantVal,
499 LLVMValueRef *ConstantIndices,
500 unsigned NumIndices);
501 LLVMValueRef LLVMConstTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
502 LLVMValueRef LLVMConstSExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
503 LLVMValueRef LLVMConstZExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
504 LLVMValueRef LLVMConstFPTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
505 LLVMValueRef LLVMConstFPExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
506 LLVMValueRef LLVMConstUIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
507 LLVMValueRef LLVMConstSIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
508 LLVMValueRef LLVMConstFPToUI(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
509 LLVMValueRef LLVMConstFPToSI(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
510 LLVMValueRef LLVMConstPtrToInt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
511 LLVMValueRef LLVMConstIntToPtr(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
512 LLVMValueRef LLVMConstBitCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
513 LLVMValueRef LLVMConstZExtOrBitCast(LLVMValueRef ConstantVal,
514 LLVMTypeRef ToType);
515 LLVMValueRef LLVMConstSExtOrBitCast(LLVMValueRef ConstantVal,
516 LLVMTypeRef ToType);
517 LLVMValueRef LLVMConstTruncOrBitCast(LLVMValueRef ConstantVal,
518 LLVMTypeRef ToType);
519 LLVMValueRef LLVMConstPointerCast(LLVMValueRef ConstantVal,
520 LLVMTypeRef ToType);
521 LLVMValueRef LLVMConstIntCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType,
522 unsigned isSigned);
523 LLVMValueRef LLVMConstFPCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
524 LLVMValueRef LLVMConstSelect(LLVMValueRef ConstantCondition,
525 LLVMValueRef ConstantIfTrue,
526 LLVMValueRef ConstantIfFalse);
527 LLVMValueRef LLVMConstExtractElement(LLVMValueRef VectorConstant,
528 LLVMValueRef IndexConstant);
529 LLVMValueRef LLVMConstInsertElement(LLVMValueRef VectorConstant,
530 LLVMValueRef ElementValueConstant,
531 LLVMValueRef IndexConstant);
532 LLVMValueRef LLVMConstShuffleVector(LLVMValueRef VectorAConstant,
533 LLVMValueRef VectorBConstant,
534 LLVMValueRef MaskConstant);
535 LLVMValueRef LLVMConstExtractValue(LLVMValueRef AggConstant, unsigned *IdxList,
536 unsigned NumIdx);
537 LLVMValueRef LLVMConstInsertValue(LLVMValueRef AggConstant,
538 LLVMValueRef ElementValueConstant,
539 unsigned *IdxList, unsigned NumIdx);
540 LLVMValueRef LLVMConstInlineAsm(LLVMTypeRef Ty,
541 const char *AsmString, const char *Constraints,
542 int HasSideEffects);
544 /* Operations on global variables, functions, and aliases (globals) */
545 LLVMModuleRef LLVMGetGlobalParent(LLVMValueRef Global);
546 int LLVMIsDeclaration(LLVMValueRef Global);
547 LLVMLinkage LLVMGetLinkage(LLVMValueRef Global);
548 void LLVMSetLinkage(LLVMValueRef Global, LLVMLinkage Linkage);
549 const char *LLVMGetSection(LLVMValueRef Global);
550 void LLVMSetSection(LLVMValueRef Global, const char *Section);
551 LLVMVisibility LLVMGetVisibility(LLVMValueRef Global);
552 void LLVMSetVisibility(LLVMValueRef Global, LLVMVisibility Viz);
553 unsigned LLVMGetAlignment(LLVMValueRef Global);
554 void LLVMSetAlignment(LLVMValueRef Global, unsigned Bytes);
556 /* Operations on global variables */
557 LLVMValueRef LLVMAddGlobal(LLVMModuleRef M, LLVMTypeRef Ty, const char *Name);
558 LLVMValueRef LLVMGetNamedGlobal(LLVMModuleRef M, const char *Name);
559 LLVMValueRef LLVMGetFirstGlobal(LLVMModuleRef M);
560 LLVMValueRef LLVMGetLastGlobal(LLVMModuleRef M);
561 LLVMValueRef LLVMGetNextGlobal(LLVMValueRef GlobalVar);
562 LLVMValueRef LLVMGetPreviousGlobal(LLVMValueRef GlobalVar);
563 void LLVMDeleteGlobal(LLVMValueRef GlobalVar);
564 LLVMValueRef LLVMGetInitializer(LLVMValueRef GlobalVar);
565 void LLVMSetInitializer(LLVMValueRef GlobalVar, LLVMValueRef ConstantVal);
566 int LLVMIsThreadLocal(LLVMValueRef GlobalVar);
567 void LLVMSetThreadLocal(LLVMValueRef GlobalVar, int IsThreadLocal);
568 int LLVMIsGlobalConstant(LLVMValueRef GlobalVar);
569 void LLVMSetGlobalConstant(LLVMValueRef GlobalVar, int IsConstant);
571 /* Operations on aliases */
572 LLVMValueRef LLVMAddAlias(LLVMModuleRef M, LLVMTypeRef Ty, LLVMValueRef Aliasee,
573 const char *Name);
575 /* Operations on functions */
576 LLVMValueRef LLVMAddFunction(LLVMModuleRef M, const char *Name,
577 LLVMTypeRef FunctionTy);
578 LLVMValueRef LLVMGetNamedFunction(LLVMModuleRef M, const char *Name);
579 LLVMValueRef LLVMGetFirstFunction(LLVMModuleRef M);
580 LLVMValueRef LLVMGetLastFunction(LLVMModuleRef M);
581 LLVMValueRef LLVMGetNextFunction(LLVMValueRef Fn);
582 LLVMValueRef LLVMGetPreviousFunction(LLVMValueRef Fn);
583 void LLVMDeleteFunction(LLVMValueRef Fn);
584 unsigned LLVMGetIntrinsicID(LLVMValueRef Fn);
585 unsigned LLVMGetFunctionCallConv(LLVMValueRef Fn);
586 void LLVMSetFunctionCallConv(LLVMValueRef Fn, unsigned CC);
587 const char *LLVMGetGC(LLVMValueRef Fn);
588 void LLVMSetGC(LLVMValueRef Fn, const char *Name);
589 void LLVMAddFunctionAttr(LLVMValueRef Fn, LLVMAttribute PA);
590 void LLVMRemoveFunctionAttr(LLVMValueRef Fn, LLVMAttribute PA);
592 /* Operations on parameters */
593 unsigned LLVMCountParams(LLVMValueRef Fn);
594 void LLVMGetParams(LLVMValueRef Fn, LLVMValueRef *Params);
595 LLVMValueRef LLVMGetParam(LLVMValueRef Fn, unsigned Index);
596 LLVMValueRef LLVMGetParamParent(LLVMValueRef Inst);
597 LLVMValueRef LLVMGetFirstParam(LLVMValueRef Fn);
598 LLVMValueRef LLVMGetLastParam(LLVMValueRef Fn);
599 LLVMValueRef LLVMGetNextParam(LLVMValueRef Arg);
600 LLVMValueRef LLVMGetPreviousParam(LLVMValueRef Arg);
601 void LLVMAddAttribute(LLVMValueRef Arg, LLVMAttribute PA);
602 void LLVMRemoveAttribute(LLVMValueRef Arg, LLVMAttribute PA);
603 void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned align);
605 /* Operations on basic blocks */
606 LLVMValueRef LLVMBasicBlockAsValue(LLVMBasicBlockRef BB);
607 int LLVMValueIsBasicBlock(LLVMValueRef Val);
608 LLVMBasicBlockRef LLVMValueAsBasicBlock(LLVMValueRef Val);
609 LLVMValueRef LLVMGetBasicBlockParent(LLVMBasicBlockRef BB);
610 unsigned LLVMCountBasicBlocks(LLVMValueRef Fn);
611 void LLVMGetBasicBlocks(LLVMValueRef Fn, LLVMBasicBlockRef *BasicBlocks);
612 LLVMBasicBlockRef LLVMGetFirstBasicBlock(LLVMValueRef Fn);
613 LLVMBasicBlockRef LLVMGetLastBasicBlock(LLVMValueRef Fn);
614 LLVMBasicBlockRef LLVMGetNextBasicBlock(LLVMBasicBlockRef BB);
615 LLVMBasicBlockRef LLVMGetPreviousBasicBlock(LLVMBasicBlockRef BB);
616 LLVMBasicBlockRef LLVMGetEntryBasicBlock(LLVMValueRef Fn);
618 LLVMBasicBlockRef LLVMAppendBasicBlockInContext(LLVMContextRef C,
619 LLVMValueRef Fn,
620 const char *Name);
621 LLVMBasicBlockRef LLVMInsertBasicBlockInContext(LLVMContextRef C,
622 LLVMBasicBlockRef BB,
623 const char *Name);
625 LLVMBasicBlockRef LLVMAppendBasicBlock(LLVMValueRef Fn, const char *Name);
626 LLVMBasicBlockRef LLVMInsertBasicBlock(LLVMBasicBlockRef InsertBeforeBB,
627 const char *Name);
628 void LLVMDeleteBasicBlock(LLVMBasicBlockRef BB);
630 /* Operations on instructions */
631 LLVMBasicBlockRef LLVMGetInstructionParent(LLVMValueRef Inst);
632 LLVMValueRef LLVMGetFirstInstruction(LLVMBasicBlockRef BB);
633 LLVMValueRef LLVMGetLastInstruction(LLVMBasicBlockRef BB);
634 LLVMValueRef LLVMGetNextInstruction(LLVMValueRef Inst);
635 LLVMValueRef LLVMGetPreviousInstruction(LLVMValueRef Inst);
637 /* Operations on call sites */
638 void LLVMSetInstructionCallConv(LLVMValueRef Instr, unsigned CC);
639 unsigned LLVMGetInstructionCallConv(LLVMValueRef Instr);
640 void LLVMAddInstrAttribute(LLVMValueRef Instr, unsigned index, LLVMAttribute);
641 void LLVMRemoveInstrAttribute(LLVMValueRef Instr, unsigned index,
642 LLVMAttribute);
643 void LLVMSetInstrParamAlignment(LLVMValueRef Instr, unsigned index,
644 unsigned align);
646 /* Operations on call instructions (only) */
647 int LLVMIsTailCall(LLVMValueRef CallInst);
648 void LLVMSetTailCall(LLVMValueRef CallInst, int IsTailCall);
650 /* Operations on phi nodes */
651 void LLVMAddIncoming(LLVMValueRef PhiNode, LLVMValueRef *IncomingValues,
652 LLVMBasicBlockRef *IncomingBlocks, unsigned Count);
653 unsigned LLVMCountIncoming(LLVMValueRef PhiNode);
654 LLVMValueRef LLVMGetIncomingValue(LLVMValueRef PhiNode, unsigned Index);
655 LLVMBasicBlockRef LLVMGetIncomingBlock(LLVMValueRef PhiNode, unsigned Index);
657 /*===-- Instruction builders ----------------------------------------------===*/
659 /* An instruction builder represents a point within a basic block, and is the
660 * exclusive means of building instructions using the C interface.
663 LLVMBuilderRef LLVMCreateBuilderInContext(LLVMContextRef C);
664 LLVMBuilderRef LLVMCreateBuilder(void);
665 void LLVMPositionBuilder(LLVMBuilderRef Builder, LLVMBasicBlockRef Block,
666 LLVMValueRef Instr);
667 void LLVMPositionBuilderBefore(LLVMBuilderRef Builder, LLVMValueRef Instr);
668 void LLVMPositionBuilderAtEnd(LLVMBuilderRef Builder, LLVMBasicBlockRef Block);
669 LLVMBasicBlockRef LLVMGetInsertBlock(LLVMBuilderRef Builder);
670 void LLVMClearInsertionPosition(LLVMBuilderRef Builder);
671 void LLVMInsertIntoBuilder(LLVMBuilderRef Builder, LLVMValueRef Instr);
672 void LLVMInsertIntoBuilderWithName(LLVMBuilderRef Builder, LLVMValueRef Instr,
673 const char *Name);
674 void LLVMDisposeBuilder(LLVMBuilderRef Builder);
676 /* Terminators */
677 LLVMValueRef LLVMBuildRetVoid(LLVMBuilderRef);
678 LLVMValueRef LLVMBuildRet(LLVMBuilderRef, LLVMValueRef V);
679 LLVMValueRef LLVMBuildAggregateRet(LLVMBuilderRef, LLVMValueRef *RetVals,
680 unsigned N);
681 LLVMValueRef LLVMBuildBr(LLVMBuilderRef, LLVMBasicBlockRef Dest);
682 LLVMValueRef LLVMBuildCondBr(LLVMBuilderRef, LLVMValueRef If,
683 LLVMBasicBlockRef Then, LLVMBasicBlockRef Else);
684 LLVMValueRef LLVMBuildSwitch(LLVMBuilderRef, LLVMValueRef V,
685 LLVMBasicBlockRef Else, unsigned NumCases);
686 LLVMValueRef LLVMBuildInvoke(LLVMBuilderRef, LLVMValueRef Fn,
687 LLVMValueRef *Args, unsigned NumArgs,
688 LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch,
689 const char *Name);
690 LLVMValueRef LLVMBuildUnwind(LLVMBuilderRef);
691 LLVMValueRef LLVMBuildUnreachable(LLVMBuilderRef);
693 /* Add a case to the switch instruction */
694 void LLVMAddCase(LLVMValueRef Switch, LLVMValueRef OnVal,
695 LLVMBasicBlockRef Dest);
697 /* Arithmetic */
698 LLVMValueRef LLVMBuildAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
699 const char *Name);
700 LLVMValueRef LLVMBuildNSWAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
701 const char *Name);
702 LLVMValueRef LLVMBuildFAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
703 const char *Name);
704 LLVMValueRef LLVMBuildSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
705 const char *Name);
706 LLVMValueRef LLVMBuildFSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
707 const char *Name);
708 LLVMValueRef LLVMBuildMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
709 const char *Name);
710 LLVMValueRef LLVMBuildFMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
711 const char *Name);
712 LLVMValueRef LLVMBuildUDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
713 const char *Name);
714 LLVMValueRef LLVMBuildSDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
715 const char *Name);
716 LLVMValueRef LLVMBuildExactSDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
717 const char *Name);
718 LLVMValueRef LLVMBuildFDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
719 const char *Name);
720 LLVMValueRef LLVMBuildURem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
721 const char *Name);
722 LLVMValueRef LLVMBuildSRem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
723 const char *Name);
724 LLVMValueRef LLVMBuildFRem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
725 const char *Name);
726 LLVMValueRef LLVMBuildShl(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
727 const char *Name);
728 LLVMValueRef LLVMBuildLShr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
729 const char *Name);
730 LLVMValueRef LLVMBuildAShr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
731 const char *Name);
732 LLVMValueRef LLVMBuildAnd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
733 const char *Name);
734 LLVMValueRef LLVMBuildOr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
735 const char *Name);
736 LLVMValueRef LLVMBuildXor(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
737 const char *Name);
738 LLVMValueRef LLVMBuildNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name);
739 LLVMValueRef LLVMBuildNot(LLVMBuilderRef, LLVMValueRef V, const char *Name);
741 /* Memory */
742 LLVMValueRef LLVMBuildMalloc(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
743 LLVMValueRef LLVMBuildArrayMalloc(LLVMBuilderRef, LLVMTypeRef Ty,
744 LLVMValueRef Val, const char *Name);
745 LLVMValueRef LLVMBuildAlloca(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
746 LLVMValueRef LLVMBuildArrayAlloca(LLVMBuilderRef, LLVMTypeRef Ty,
747 LLVMValueRef Val, const char *Name);
748 LLVMValueRef LLVMBuildFree(LLVMBuilderRef, LLVMValueRef PointerVal);
749 LLVMValueRef LLVMBuildLoad(LLVMBuilderRef, LLVMValueRef PointerVal,
750 const char *Name);
751 LLVMValueRef LLVMBuildStore(LLVMBuilderRef, LLVMValueRef Val, LLVMValueRef Ptr);
752 LLVMValueRef LLVMBuildGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
753 LLVMValueRef *Indices, unsigned NumIndices,
754 const char *Name);
755 LLVMValueRef LLVMBuildInBoundsGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
756 LLVMValueRef *Indices, unsigned NumIndices,
757 const char *Name);
758 LLVMValueRef LLVMBuildStructGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
759 unsigned Idx, const char *Name);
760 LLVMValueRef LLVMBuildGlobalString(LLVMBuilderRef B, const char *Str,
761 const char *Name);
762 LLVMValueRef LLVMBuildGlobalStringPtr(LLVMBuilderRef B, const char *Str,
763 const char *Name);
765 /* Casts */
766 LLVMValueRef LLVMBuildTrunc(LLVMBuilderRef, LLVMValueRef Val,
767 LLVMTypeRef DestTy, const char *Name);
768 LLVMValueRef LLVMBuildZExt(LLVMBuilderRef, LLVMValueRef Val,
769 LLVMTypeRef DestTy, const char *Name);
770 LLVMValueRef LLVMBuildSExt(LLVMBuilderRef, LLVMValueRef Val,
771 LLVMTypeRef DestTy, const char *Name);
772 LLVMValueRef LLVMBuildFPToUI(LLVMBuilderRef, LLVMValueRef Val,
773 LLVMTypeRef DestTy, const char *Name);
774 LLVMValueRef LLVMBuildFPToSI(LLVMBuilderRef, LLVMValueRef Val,
775 LLVMTypeRef DestTy, const char *Name);
776 LLVMValueRef LLVMBuildUIToFP(LLVMBuilderRef, LLVMValueRef Val,
777 LLVMTypeRef DestTy, const char *Name);
778 LLVMValueRef LLVMBuildSIToFP(LLVMBuilderRef, LLVMValueRef Val,
779 LLVMTypeRef DestTy, const char *Name);
780 LLVMValueRef LLVMBuildFPTrunc(LLVMBuilderRef, LLVMValueRef Val,
781 LLVMTypeRef DestTy, const char *Name);
782 LLVMValueRef LLVMBuildFPExt(LLVMBuilderRef, LLVMValueRef Val,
783 LLVMTypeRef DestTy, const char *Name);
784 LLVMValueRef LLVMBuildPtrToInt(LLVMBuilderRef, LLVMValueRef Val,
785 LLVMTypeRef DestTy, const char *Name);
786 LLVMValueRef LLVMBuildIntToPtr(LLVMBuilderRef, LLVMValueRef Val,
787 LLVMTypeRef DestTy, const char *Name);
788 LLVMValueRef LLVMBuildBitCast(LLVMBuilderRef, LLVMValueRef Val,
789 LLVMTypeRef DestTy, const char *Name);
790 LLVMValueRef LLVMBuildZExtOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
791 LLVMTypeRef DestTy, const char *Name);
792 LLVMValueRef LLVMBuildSExtOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
793 LLVMTypeRef DestTy, const char *Name);
794 LLVMValueRef LLVMBuildTruncOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
795 LLVMTypeRef DestTy, const char *Name);
796 LLVMValueRef LLVMBuildPointerCast(LLVMBuilderRef, LLVMValueRef Val,
797 LLVMTypeRef DestTy, const char *Name);
798 LLVMValueRef LLVMBuildIntCast(LLVMBuilderRef, LLVMValueRef Val,
799 LLVMTypeRef DestTy, const char *Name);
800 LLVMValueRef LLVMBuildFPCast(LLVMBuilderRef, LLVMValueRef Val,
801 LLVMTypeRef DestTy, const char *Name);
803 /* Comparisons */
804 LLVMValueRef LLVMBuildICmp(LLVMBuilderRef, LLVMIntPredicate Op,
805 LLVMValueRef LHS, LLVMValueRef RHS,
806 const char *Name);
807 LLVMValueRef LLVMBuildFCmp(LLVMBuilderRef, LLVMRealPredicate Op,
808 LLVMValueRef LHS, LLVMValueRef RHS,
809 const char *Name);
811 /* Miscellaneous instructions */
812 LLVMValueRef LLVMBuildPhi(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
813 LLVMValueRef LLVMBuildCall(LLVMBuilderRef, LLVMValueRef Fn,
814 LLVMValueRef *Args, unsigned NumArgs,
815 const char *Name);
816 LLVMValueRef LLVMBuildSelect(LLVMBuilderRef, LLVMValueRef If,
817 LLVMValueRef Then, LLVMValueRef Else,
818 const char *Name);
819 LLVMValueRef LLVMBuildVAArg(LLVMBuilderRef, LLVMValueRef List, LLVMTypeRef Ty,
820 const char *Name);
821 LLVMValueRef LLVMBuildExtractElement(LLVMBuilderRef, LLVMValueRef VecVal,
822 LLVMValueRef Index, const char *Name);
823 LLVMValueRef LLVMBuildInsertElement(LLVMBuilderRef, LLVMValueRef VecVal,
824 LLVMValueRef EltVal, LLVMValueRef Index,
825 const char *Name);
826 LLVMValueRef LLVMBuildShuffleVector(LLVMBuilderRef, LLVMValueRef V1,
827 LLVMValueRef V2, LLVMValueRef Mask,
828 const char *Name);
829 LLVMValueRef LLVMBuildExtractValue(LLVMBuilderRef, LLVMValueRef AggVal,
830 unsigned Index, const char *Name);
831 LLVMValueRef LLVMBuildInsertValue(LLVMBuilderRef, LLVMValueRef AggVal,
832 LLVMValueRef EltVal, unsigned Index,
833 const char *Name);
835 LLVMValueRef LLVMBuildIsNull(LLVMBuilderRef, LLVMValueRef Val,
836 const char *Name);
837 LLVMValueRef LLVMBuildIsNotNull(LLVMBuilderRef, LLVMValueRef Val,
838 const char *Name);
839 LLVMValueRef LLVMBuildPtrDiff(LLVMBuilderRef, LLVMValueRef LHS,
840 LLVMValueRef RHS, const char *Name);
843 /*===-- Module providers --------------------------------------------------===*/
845 /* Encapsulates the module M in a module provider, taking ownership of the
846 * module.
847 * See the constructor llvm::ExistingModuleProvider::ExistingModuleProvider.
849 LLVMModuleProviderRef
850 LLVMCreateModuleProviderForExistingModule(LLVMModuleRef M);
852 /* Destroys the module provider MP as well as the contained module.
853 * See the destructor llvm::ModuleProvider::~ModuleProvider.
855 void LLVMDisposeModuleProvider(LLVMModuleProviderRef MP);
858 /*===-- Memory buffers ----------------------------------------------------===*/
860 int LLVMCreateMemoryBufferWithContentsOfFile(const char *Path,
861 LLVMMemoryBufferRef *OutMemBuf,
862 char **OutMessage);
863 int LLVMCreateMemoryBufferWithSTDIN(LLVMMemoryBufferRef *OutMemBuf,
864 char **OutMessage);
865 void LLVMDisposeMemoryBuffer(LLVMMemoryBufferRef MemBuf);
868 /*===-- Pass Managers -----------------------------------------------------===*/
870 /** Constructs a new whole-module pass pipeline. This type of pipeline is
871 suitable for link-time optimization and whole-module transformations.
872 See llvm::PassManager::PassManager. */
873 LLVMPassManagerRef LLVMCreatePassManager(void);
875 /** Constructs a new function-by-function pass pipeline over the module
876 provider. It does not take ownership of the module provider. This type of
877 pipeline is suitable for code generation and JIT compilation tasks.
878 See llvm::FunctionPassManager::FunctionPassManager. */
879 LLVMPassManagerRef LLVMCreateFunctionPassManager(LLVMModuleProviderRef MP);
881 /** Initializes, executes on the provided module, and finalizes all of the
882 passes scheduled in the pass manager. Returns 1 if any of the passes
883 modified the module, 0 otherwise. See llvm::PassManager::run(Module&). */
884 int LLVMRunPassManager(LLVMPassManagerRef PM, LLVMModuleRef M);
886 /** Initializes all of the function passes scheduled in the function pass
887 manager. Returns 1 if any of the passes modified the module, 0 otherwise.
888 See llvm::FunctionPassManager::doInitialization. */
889 int LLVMInitializeFunctionPassManager(LLVMPassManagerRef FPM);
891 /** Executes all of the function passes scheduled in the function pass manager
892 on the provided function. Returns 1 if any of the passes modified the
893 function, false otherwise.
894 See llvm::FunctionPassManager::run(Function&). */
895 int LLVMRunFunctionPassManager(LLVMPassManagerRef FPM, LLVMValueRef F);
897 /** Finalizes all of the function passes scheduled in in the function pass
898 manager. Returns 1 if any of the passes modified the module, 0 otherwise.
899 See llvm::FunctionPassManager::doFinalization. */
900 int LLVMFinalizeFunctionPassManager(LLVMPassManagerRef FPM);
902 /** Frees the memory of a pass pipeline. For function pipelines, does not free
903 the module provider.
904 See llvm::PassManagerBase::~PassManagerBase. */
905 void LLVMDisposePassManager(LLVMPassManagerRef PM);
908 #ifdef __cplusplus
911 namespace llvm {
912 class ModuleProvider;
913 class MemoryBuffer;
914 class PassManagerBase;
916 #define DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref) \
917 inline ty *unwrap(ref P) { \
918 return reinterpret_cast<ty*>(P); \
921 inline ref wrap(const ty *P) { \
922 return reinterpret_cast<ref>(const_cast<ty*>(P)); \
925 #define DEFINE_ISA_CONVERSION_FUNCTIONS(ty, ref) \
926 DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref) \
928 template<typename T> \
929 inline T *unwrap(ref P) { \
930 return cast<T>(unwrap(P)); \
933 #define DEFINE_STDCXX_CONVERSION_FUNCTIONS(ty, ref) \
934 DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref) \
936 template<typename T> \
937 inline T *unwrap(ref P) { \
938 T *Q = dynamic_cast<T*>(unwrap(P)); \
939 assert(Q && "Invalid cast!"); \
940 return Q; \
943 DEFINE_ISA_CONVERSION_FUNCTIONS (Type, LLVMTypeRef )
944 DEFINE_ISA_CONVERSION_FUNCTIONS (Value, LLVMValueRef )
945 DEFINE_SIMPLE_CONVERSION_FUNCTIONS(Module, LLVMModuleRef )
946 DEFINE_SIMPLE_CONVERSION_FUNCTIONS(BasicBlock, LLVMBasicBlockRef )
947 DEFINE_SIMPLE_CONVERSION_FUNCTIONS(IRBuilder<>, LLVMBuilderRef )
948 DEFINE_SIMPLE_CONVERSION_FUNCTIONS(PATypeHolder, LLVMTypeHandleRef )
949 DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ModuleProvider, LLVMModuleProviderRef)
950 DEFINE_SIMPLE_CONVERSION_FUNCTIONS(MemoryBuffer, LLVMMemoryBufferRef )
951 DEFINE_SIMPLE_CONVERSION_FUNCTIONS(LLVMContext, LLVMContextRef )
952 DEFINE_STDCXX_CONVERSION_FUNCTIONS(PassManagerBase, LLVMPassManagerRef )
954 #undef DEFINE_STDCXX_CONVERSION_FUNCTIONS
955 #undef DEFINE_ISA_CONVERSION_FUNCTIONS
956 #undef DEFINE_SIMPLE_CONVERSION_FUNCTIONS
958 /* Specialized opaque context conversions.
960 inline LLVMContext **unwrap(LLVMContextRef* Tys) {
961 return reinterpret_cast<LLVMContext**>(Tys);
964 inline LLVMContextRef *wrap(const LLVMContext **Tys) {
965 return reinterpret_cast<LLVMContextRef*>(const_cast<LLVMContext**>(Tys));
968 /* Specialized opaque type conversions.
970 inline Type **unwrap(LLVMTypeRef* Tys) {
971 return reinterpret_cast<Type**>(Tys);
974 inline LLVMTypeRef *wrap(const Type **Tys) {
975 return reinterpret_cast<LLVMTypeRef*>(const_cast<Type**>(Tys));
978 /* Specialized opaque value conversions.
980 inline Value **unwrap(LLVMValueRef *Vals) {
981 return reinterpret_cast<Value**>(Vals);
984 template<typename T>
985 inline T **unwrap(LLVMValueRef *Vals, unsigned Length) {
986 #if DEBUG
987 for (LLVMValueRef *I = Vals, *E = Vals + Length; I != E; ++I)
988 cast<T>(*I);
989 #endif
990 return reinterpret_cast<T**>(Vals);
993 inline LLVMValueRef *wrap(const Value **Vals) {
994 return reinterpret_cast<LLVMValueRef*>(const_cast<Value**>(Vals));
998 #endif /* !defined(__cplusplus) */
1000 #endif /* !defined(LLVM_C_CORE_H) */