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