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