Home | History | Annotate | Download | only in llvm-c
      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 #include "llvm/Support/DataTypes.h"
     37 
     38 #ifdef __cplusplus
     39 
     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/PassRegistry.h"
     44 #include "llvm/Support/IRBuilder.h"
     45 
     46 extern "C" {
     47 #endif
     48 
     49 
     50 typedef int LLVMBool;
     51 
     52 /* Opaque types. */
     53 
     54 /**
     55  * The top-level container for all LLVM global data.  See the LLVMContext class.
     56  */
     57 typedef struct LLVMOpaqueContext *LLVMContextRef;
     58 
     59 /**
     60  * The top-level container for all other LLVM Intermediate Representation (IR)
     61  * objects. See the llvm::Module class.
     62  */
     63 typedef struct LLVMOpaqueModule *LLVMModuleRef;
     64 
     65 /**
     66  * Each value in the LLVM IR has a type, an LLVMTypeRef. See the llvm::Type
     67  * class.
     68  */
     69 typedef struct LLVMOpaqueType *LLVMTypeRef;
     70 
     71 typedef struct LLVMOpaqueValue *LLVMValueRef;
     72 typedef struct LLVMOpaqueBasicBlock *LLVMBasicBlockRef;
     73 typedef struct LLVMOpaqueBuilder *LLVMBuilderRef;
     74 
     75 /* Interface used to provide a module to JIT or interpreter.  This is now just a
     76  * synonym for llvm::Module, but we have to keep using the different type to
     77  * keep binary compatibility.
     78  */
     79 typedef struct LLVMOpaqueModuleProvider *LLVMModuleProviderRef;
     80 
     81 /* Used to provide a module to JIT or interpreter.
     82  * See the llvm::MemoryBuffer class.
     83  */
     84 typedef struct LLVMOpaqueMemoryBuffer *LLVMMemoryBufferRef;
     85 
     86 /** See the llvm::PassManagerBase class. */
     87 typedef struct LLVMOpaquePassManager *LLVMPassManagerRef;
     88 
     89 /** See the llvm::PassRegistry class. */
     90 typedef struct LLVMOpaquePassRegistry *LLVMPassRegistryRef;
     91 
     92 /** Used to get the users and usees of a Value. See the llvm::Use class. */
     93 typedef struct LLVMOpaqueUse *LLVMUseRef;
     94 
     95 typedef enum {
     96     LLVMZExtAttribute       = 1<<0,
     97     LLVMSExtAttribute       = 1<<1,
     98     LLVMNoReturnAttribute   = 1<<2,
     99     LLVMInRegAttribute      = 1<<3,
    100     LLVMStructRetAttribute  = 1<<4,
    101     LLVMNoUnwindAttribute   = 1<<5,
    102     LLVMNoAliasAttribute    = 1<<6,
    103     LLVMByValAttribute      = 1<<7,
    104     LLVMNestAttribute       = 1<<8,
    105     LLVMReadNoneAttribute   = 1<<9,
    106     LLVMReadOnlyAttribute   = 1<<10,
    107     LLVMNoInlineAttribute   = 1<<11,
    108     LLVMAlwaysInlineAttribute    = 1<<12,
    109     LLVMOptimizeForSizeAttribute = 1<<13,
    110     LLVMStackProtectAttribute    = 1<<14,
    111     LLVMStackProtectReqAttribute = 1<<15,
    112     LLVMAlignment = 31<<16,
    113     LLVMNoCaptureAttribute  = 1<<21,
    114     LLVMNoRedZoneAttribute  = 1<<22,
    115     LLVMNoImplicitFloatAttribute = 1<<23,
    116     LLVMNakedAttribute      = 1<<24,
    117     LLVMInlineHintAttribute = 1<<25,
    118     LLVMStackAlignment = 7<<26,
    119     LLVMReturnsTwice = 1 << 29,
    120     LLVMUWTable = 1 << 30,
    121     LLVMNonLazyBind = 1 << 31
    122 } LLVMAttribute;
    123 
    124 typedef enum {
    125   /* Terminator Instructions */
    126   LLVMRet            = 1,
    127   LLVMBr             = 2,
    128   LLVMSwitch         = 3,
    129   LLVMIndirectBr     = 4,
    130   LLVMInvoke         = 5,
    131   /* removed 6 due to API changes */
    132   LLVMUnreachable    = 7,
    133 
    134   /* Standard Binary Operators */
    135   LLVMAdd            = 8,
    136   LLVMFAdd           = 9,
    137   LLVMSub            = 10,
    138   LLVMFSub           = 11,
    139   LLVMMul            = 12,
    140   LLVMFMul           = 13,
    141   LLVMUDiv           = 14,
    142   LLVMSDiv           = 15,
    143   LLVMFDiv           = 16,
    144   LLVMURem           = 17,
    145   LLVMSRem           = 18,
    146   LLVMFRem           = 19,
    147 
    148   /* Logical Operators */
    149   LLVMShl            = 20,
    150   LLVMLShr           = 21,
    151   LLVMAShr           = 22,
    152   LLVMAnd            = 23,
    153   LLVMOr             = 24,
    154   LLVMXor            = 25,
    155 
    156   /* Memory Operators */
    157   LLVMAlloca         = 26,
    158   LLVMLoad           = 27,
    159   LLVMStore          = 28,
    160   LLVMGetElementPtr  = 29,
    161 
    162   /* Cast Operators */
    163   LLVMTrunc          = 30,
    164   LLVMZExt           = 31,
    165   LLVMSExt           = 32,
    166   LLVMFPToUI         = 33,
    167   LLVMFPToSI         = 34,
    168   LLVMUIToFP         = 35,
    169   LLVMSIToFP         = 36,
    170   LLVMFPTrunc        = 37,
    171   LLVMFPExt          = 38,
    172   LLVMPtrToInt       = 39,
    173   LLVMIntToPtr       = 40,
    174   LLVMBitCast        = 41,
    175 
    176   /* Other Operators */
    177   LLVMICmp           = 42,
    178   LLVMFCmp           = 43,
    179   LLVMPHI            = 44,
    180   LLVMCall           = 45,
    181   LLVMSelect         = 46,
    182   LLVMUserOp1        = 47,
    183   LLVMUserOp2        = 48,
    184   LLVMVAArg          = 49,
    185   LLVMExtractElement = 50,
    186   LLVMInsertElement  = 51,
    187   LLVMShuffleVector  = 52,
    188   LLVMExtractValue   = 53,
    189   LLVMInsertValue    = 54,
    190 
    191   /* Atomic operators */
    192   LLVMFence          = 55,
    193   LLVMAtomicCmpXchg  = 56,
    194   LLVMAtomicRMW      = 57,
    195 
    196   /* Exception Handling Operators */
    197   LLVMResume         = 58,
    198   LLVMLandingPad     = 59,
    199   LLVMUnwind         = 60
    200 
    201 
    202 } LLVMOpcode;
    203 
    204 typedef enum {
    205   LLVMVoidTypeKind,        /**< type with no size */
    206   LLVMFloatTypeKind,       /**< 32 bit floating point type */
    207   LLVMDoubleTypeKind,      /**< 64 bit floating point type */
    208   LLVMX86_FP80TypeKind,    /**< 80 bit floating point type (X87) */
    209   LLVMFP128TypeKind,       /**< 128 bit floating point type (112-bit mantissa)*/
    210   LLVMPPC_FP128TypeKind,   /**< 128 bit floating point type (two 64-bits) */
    211   LLVMLabelTypeKind,       /**< Labels */
    212   LLVMIntegerTypeKind,     /**< Arbitrary bit width integers */
    213   LLVMFunctionTypeKind,    /**< Functions */
    214   LLVMStructTypeKind,      /**< Structures */
    215   LLVMArrayTypeKind,       /**< Arrays */
    216   LLVMPointerTypeKind,     /**< Pointers */
    217   LLVMVectorTypeKind,      /**< SIMD 'packed' format, or other vector type */
    218   LLVMMetadataTypeKind,    /**< Metadata */
    219   LLVMX86_MMXTypeKind      /**< X86 MMX */
    220 } LLVMTypeKind;
    221 
    222 typedef enum {
    223   LLVMExternalLinkage,    /**< Externally visible function */
    224   LLVMAvailableExternallyLinkage,
    225   LLVMLinkOnceAnyLinkage, /**< Keep one copy of function when linking (inline)*/
    226   LLVMLinkOnceODRLinkage, /**< Same, but only replaced by something
    227                             equivalent. */
    228   LLVMWeakAnyLinkage,     /**< Keep one copy of function when linking (weak) */
    229   LLVMWeakODRLinkage,     /**< Same, but only replaced by something
    230                             equivalent. */
    231   LLVMAppendingLinkage,   /**< Special purpose, only applies to global arrays */
    232   LLVMInternalLinkage,    /**< Rename collisions when linking (static
    233                                functions) */
    234   LLVMPrivateLinkage,     /**< Like Internal, but omit from symbol table */
    235   LLVMDLLImportLinkage,   /**< Function to be imported from DLL */
    236   LLVMDLLExportLinkage,   /**< Function to be accessible from DLL */
    237   LLVMExternalWeakLinkage,/**< ExternalWeak linkage description */
    238   LLVMGhostLinkage,       /**< Obsolete */
    239   LLVMCommonLinkage,      /**< Tentative definitions */
    240   LLVMLinkerPrivateLinkage, /**< Like Private, but linker removes. */
    241   LLVMLinkerPrivateWeakLinkage, /**< Like LinkerPrivate, but is weak. */
    242   LLVMLinkerPrivateWeakDefAutoLinkage /**< Like LinkerPrivateWeak, but possibly
    243                                            hidden. */
    244 } LLVMLinkage;
    245 
    246 typedef enum {
    247   LLVMDefaultVisibility,  /**< The GV is visible */
    248   LLVMHiddenVisibility,   /**< The GV is hidden */
    249   LLVMProtectedVisibility /**< The GV is protected */
    250 } LLVMVisibility;
    251 
    252 typedef enum {
    253   LLVMCCallConv           = 0,
    254   LLVMFastCallConv        = 8,
    255   LLVMColdCallConv        = 9,
    256   LLVMX86StdcallCallConv  = 64,
    257   LLVMX86FastcallCallConv = 65
    258 } LLVMCallConv;
    259 
    260 typedef enum {
    261   LLVMIntEQ = 32, /**< equal */
    262   LLVMIntNE,      /**< not equal */
    263   LLVMIntUGT,     /**< unsigned greater than */
    264   LLVMIntUGE,     /**< unsigned greater or equal */
    265   LLVMIntULT,     /**< unsigned less than */
    266   LLVMIntULE,     /**< unsigned less or equal */
    267   LLVMIntSGT,     /**< signed greater than */
    268   LLVMIntSGE,     /**< signed greater or equal */
    269   LLVMIntSLT,     /**< signed less than */
    270   LLVMIntSLE      /**< signed less or equal */
    271 } LLVMIntPredicate;
    272 
    273 typedef enum {
    274   LLVMRealPredicateFalse, /**< Always false (always folded) */
    275   LLVMRealOEQ,            /**< True if ordered and equal */
    276   LLVMRealOGT,            /**< True if ordered and greater than */
    277   LLVMRealOGE,            /**< True if ordered and greater than or equal */
    278   LLVMRealOLT,            /**< True if ordered and less than */
    279   LLVMRealOLE,            /**< True if ordered and less than or equal */
    280   LLVMRealONE,            /**< True if ordered and operands are unequal */
    281   LLVMRealORD,            /**< True if ordered (no nans) */
    282   LLVMRealUNO,            /**< True if unordered: isnan(X) | isnan(Y) */
    283   LLVMRealUEQ,            /**< True if unordered or equal */
    284   LLVMRealUGT,            /**< True if unordered or greater than */
    285   LLVMRealUGE,            /**< True if unordered, greater than, or equal */
    286   LLVMRealULT,            /**< True if unordered or less than */
    287   LLVMRealULE,            /**< True if unordered, less than, or equal */
    288   LLVMRealUNE,            /**< True if unordered or not equal */
    289   LLVMRealPredicateTrue   /**< Always true (always folded) */
    290 } LLVMRealPredicate;
    291 
    292 typedef enum {
    293   LLVMLandingPadCatch,    /**< A catch clause   */
    294   LLVMLandingPadFilter    /**< A filter clause  */
    295 } LLVMLandingPadClauseTy;
    296 
    297 void LLVMInitializeCore(LLVMPassRegistryRef R);
    298 
    299 
    300 /*===-- Error handling ----------------------------------------------------===*/
    301 
    302 void LLVMDisposeMessage(char *Message);
    303 
    304 
    305 /*===-- Contexts ----------------------------------------------------------===*/
    306 
    307 /* Create and destroy contexts. */
    308 LLVMContextRef LLVMContextCreate(void);
    309 LLVMContextRef LLVMGetGlobalContext(void);
    310 void LLVMContextDispose(LLVMContextRef C);
    311 
    312 unsigned LLVMGetMDKindIDInContext(LLVMContextRef C, const char* Name,
    313                                   unsigned SLen);
    314 unsigned LLVMGetMDKindID(const char* Name, unsigned SLen);
    315 
    316 /*===-- Modules -----------------------------------------------------------===*/
    317 
    318 /* Create and destroy modules. */
    319 /** See llvm::Module::Module. */
    320 LLVMModuleRef LLVMModuleCreateWithName(const char *ModuleID);
    321 LLVMModuleRef LLVMModuleCreateWithNameInContext(const char *ModuleID,
    322                                                 LLVMContextRef C);
    323 
    324 /** See llvm::Module::~Module. */
    325 void LLVMDisposeModule(LLVMModuleRef M);
    326 
    327 /** Data layout. See Module::getDataLayout. */
    328 const char *LLVMGetDataLayout(LLVMModuleRef M);
    329 void LLVMSetDataLayout(LLVMModuleRef M, const char *Triple);
    330 
    331 /** Target triple. See Module::getTargetTriple. */
    332 const char *LLVMGetTarget(LLVMModuleRef M);
    333 void LLVMSetTarget(LLVMModuleRef M, const char *Triple);
    334 
    335 /** See Module::dump. */
    336 void LLVMDumpModule(LLVMModuleRef M);
    337 
    338 /** See Module::setModuleInlineAsm. */
    339 void LLVMSetModuleInlineAsm(LLVMModuleRef M, const char *Asm);
    340 
    341 /** See Module::getContext. */
    342 LLVMContextRef LLVMGetModuleContext(LLVMModuleRef M);
    343 
    344 /*===-- Types -------------------------------------------------------------===*/
    345 
    346 /* LLVM types conform to the following hierarchy:
    347  *
    348  *   types:
    349  *     integer type
    350  *     real type
    351  *     function type
    352  *     sequence types:
    353  *       array type
    354  *       pointer type
    355  *       vector type
    356  *     void type
    357  *     label type
    358  *     opaque type
    359  */
    360 
    361 /** See llvm::LLVMTypeKind::getTypeID. */
    362 LLVMTypeKind LLVMGetTypeKind(LLVMTypeRef Ty);
    363 LLVMBool LLVMTypeIsSized(LLVMTypeRef Ty);
    364 
    365 /** See llvm::LLVMType::getContext. */
    366 LLVMContextRef LLVMGetTypeContext(LLVMTypeRef Ty);
    367 
    368 /* Operations on integer types */
    369 LLVMTypeRef LLVMInt1TypeInContext(LLVMContextRef C);
    370 LLVMTypeRef LLVMInt8TypeInContext(LLVMContextRef C);
    371 LLVMTypeRef LLVMInt16TypeInContext(LLVMContextRef C);
    372 LLVMTypeRef LLVMInt32TypeInContext(LLVMContextRef C);
    373 LLVMTypeRef LLVMInt64TypeInContext(LLVMContextRef C);
    374 LLVMTypeRef LLVMIntTypeInContext(LLVMContextRef C, unsigned NumBits);
    375 
    376 LLVMTypeRef LLVMInt1Type(void);
    377 LLVMTypeRef LLVMInt8Type(void);
    378 LLVMTypeRef LLVMInt16Type(void);
    379 LLVMTypeRef LLVMInt32Type(void);
    380 LLVMTypeRef LLVMInt64Type(void);
    381 LLVMTypeRef LLVMIntType(unsigned NumBits);
    382 unsigned LLVMGetIntTypeWidth(LLVMTypeRef IntegerTy);
    383 
    384 /* Operations on real types */
    385 LLVMTypeRef LLVMFloatTypeInContext(LLVMContextRef C);
    386 LLVMTypeRef LLVMDoubleTypeInContext(LLVMContextRef C);
    387 LLVMTypeRef LLVMX86FP80TypeInContext(LLVMContextRef C);
    388 LLVMTypeRef LLVMFP128TypeInContext(LLVMContextRef C);
    389 LLVMTypeRef LLVMPPCFP128TypeInContext(LLVMContextRef C);
    390 
    391 LLVMTypeRef LLVMFloatType(void);
    392 LLVMTypeRef LLVMDoubleType(void);
    393 LLVMTypeRef LLVMX86FP80Type(void);
    394 LLVMTypeRef LLVMFP128Type(void);
    395 LLVMTypeRef LLVMPPCFP128Type(void);
    396 
    397 /* Operations on function types */
    398 LLVMTypeRef LLVMFunctionType(LLVMTypeRef ReturnType,
    399                              LLVMTypeRef *ParamTypes, unsigned ParamCount,
    400                              LLVMBool IsVarArg);
    401 LLVMBool LLVMIsFunctionVarArg(LLVMTypeRef FunctionTy);
    402 LLVMTypeRef LLVMGetReturnType(LLVMTypeRef FunctionTy);
    403 unsigned LLVMCountParamTypes(LLVMTypeRef FunctionTy);
    404 void LLVMGetParamTypes(LLVMTypeRef FunctionTy, LLVMTypeRef *Dest);
    405 
    406 /* Operations on struct types */
    407 LLVMTypeRef LLVMStructTypeInContext(LLVMContextRef C, LLVMTypeRef *ElementTypes,
    408                                     unsigned ElementCount, LLVMBool Packed);
    409 LLVMTypeRef LLVMStructType(LLVMTypeRef *ElementTypes, unsigned ElementCount,
    410                            LLVMBool Packed);
    411 LLVMTypeRef LLVMStructCreateNamed(LLVMContextRef C, const char *Name);
    412 const char *LLVMGetStructName(LLVMTypeRef Ty);
    413 void LLVMStructSetBody(LLVMTypeRef StructTy, LLVMTypeRef *ElementTypes,
    414                        unsigned ElementCount, LLVMBool Packed);
    415 
    416 unsigned LLVMCountStructElementTypes(LLVMTypeRef StructTy);
    417 void LLVMGetStructElementTypes(LLVMTypeRef StructTy, LLVMTypeRef *Dest);
    418 LLVMBool LLVMIsPackedStruct(LLVMTypeRef StructTy);
    419 LLVMBool LLVMIsOpaqueStruct(LLVMTypeRef StructTy);
    420 
    421 LLVMTypeRef LLVMGetTypeByName(LLVMModuleRef M, const char *Name);
    422 
    423 /* Operations on array, pointer, and vector types (sequence types) */
    424 LLVMTypeRef LLVMArrayType(LLVMTypeRef ElementType, unsigned ElementCount);
    425 LLVMTypeRef LLVMPointerType(LLVMTypeRef ElementType, unsigned AddressSpace);
    426 LLVMTypeRef LLVMVectorType(LLVMTypeRef ElementType, unsigned ElementCount);
    427 
    428 LLVMTypeRef LLVMGetElementType(LLVMTypeRef Ty);
    429 unsigned LLVMGetArrayLength(LLVMTypeRef ArrayTy);
    430 unsigned LLVMGetPointerAddressSpace(LLVMTypeRef PointerTy);
    431 unsigned LLVMGetVectorSize(LLVMTypeRef VectorTy);
    432 
    433 /* Operations on other types */
    434 LLVMTypeRef LLVMVoidTypeInContext(LLVMContextRef C);
    435 LLVMTypeRef LLVMLabelTypeInContext(LLVMContextRef C);
    436 LLVMTypeRef LLVMX86MMXTypeInContext(LLVMContextRef C);
    437 
    438 LLVMTypeRef LLVMVoidType(void);
    439 LLVMTypeRef LLVMLabelType(void);
    440 LLVMTypeRef LLVMX86MMXType(void);
    441 
    442 /*===-- Values ------------------------------------------------------------===*/
    443 
    444 /* The bulk of LLVM's object model consists of values, which comprise a very
    445  * rich type hierarchy.
    446  */
    447 
    448 #define LLVM_FOR_EACH_VALUE_SUBCLASS(macro) \
    449   macro(Argument)                           \
    450   macro(BasicBlock)                         \
    451   macro(InlineAsm)                          \
    452   macro(MDNode)                             \
    453   macro(MDString)                           \
    454   macro(User)                               \
    455     macro(Constant)                         \
    456       macro(BlockAddress)                   \
    457       macro(ConstantAggregateZero)          \
    458       macro(ConstantArray)                  \
    459       macro(ConstantExpr)                   \
    460       macro(ConstantFP)                     \
    461       macro(ConstantInt)                    \
    462       macro(ConstantPointerNull)            \
    463       macro(ConstantStruct)                 \
    464       macro(ConstantVector)                 \
    465       macro(GlobalValue)                    \
    466         macro(Function)                     \
    467         macro(GlobalAlias)                  \
    468         macro(GlobalVariable)               \
    469       macro(UndefValue)                     \
    470     macro(Instruction)                      \
    471       macro(BinaryOperator)                 \
    472       macro(CallInst)                       \
    473         macro(IntrinsicInst)                \
    474           macro(DbgInfoIntrinsic)           \
    475             macro(DbgDeclareInst)           \
    476           macro(EHExceptionInst)            \
    477           macro(EHSelectorInst)             \
    478           macro(MemIntrinsic)               \
    479             macro(MemCpyInst)               \
    480             macro(MemMoveInst)              \
    481             macro(MemSetInst)               \
    482       macro(CmpInst)                        \
    483         macro(FCmpInst)                     \
    484         macro(ICmpInst)                     \
    485       macro(ExtractElementInst)             \
    486       macro(GetElementPtrInst)              \
    487       macro(InsertElementInst)              \
    488       macro(InsertValueInst)                \
    489       macro(LandingPadInst)                 \
    490       macro(PHINode)                        \
    491       macro(SelectInst)                     \
    492       macro(ShuffleVectorInst)              \
    493       macro(StoreInst)                      \
    494       macro(TerminatorInst)                 \
    495         macro(BranchInst)                   \
    496         macro(IndirectBrInst)               \
    497         macro(InvokeInst)                   \
    498         macro(ReturnInst)                   \
    499         macro(SwitchInst)                   \
    500         macro(UnreachableInst)              \
    501         macro(ResumeInst)                   \
    502     macro(UnaryInstruction)                 \
    503       macro(AllocaInst)                     \
    504       macro(CastInst)                       \
    505         macro(BitCastInst)                  \
    506         macro(FPExtInst)                    \
    507         macro(FPToSIInst)                   \
    508         macro(FPToUIInst)                   \
    509         macro(FPTruncInst)                  \
    510         macro(IntToPtrInst)                 \
    511         macro(PtrToIntInst)                 \
    512         macro(SExtInst)                     \
    513         macro(SIToFPInst)                   \
    514         macro(TruncInst)                    \
    515         macro(UIToFPInst)                   \
    516         macro(ZExtInst)                     \
    517       macro(ExtractValueInst)               \
    518       macro(LoadInst)                       \
    519       macro(VAArgInst)
    520 
    521 /* Operations on all values */
    522 LLVMTypeRef LLVMTypeOf(LLVMValueRef Val);
    523 const char *LLVMGetValueName(LLVMValueRef Val);
    524 void LLVMSetValueName(LLVMValueRef Val, const char *Name);
    525 void LLVMDumpValue(LLVMValueRef Val);
    526 void LLVMReplaceAllUsesWith(LLVMValueRef OldVal, LLVMValueRef NewVal);
    527 int LLVMHasMetadata(LLVMValueRef Val);
    528 LLVMValueRef LLVMGetMetadata(LLVMValueRef Val, unsigned KindID);
    529 void LLVMSetMetadata(LLVMValueRef Val, unsigned KindID, LLVMValueRef Node);
    530 
    531 /* Conversion functions. Return the input value if it is an instance of the
    532    specified class, otherwise NULL. See llvm::dyn_cast_or_null<>. */
    533 #define LLVM_DECLARE_VALUE_CAST(name) \
    534   LLVMValueRef LLVMIsA##name(LLVMValueRef Val);
    535 LLVM_FOR_EACH_VALUE_SUBCLASS(LLVM_DECLARE_VALUE_CAST)
    536 
    537 /* Operations on Uses */
    538 LLVMUseRef LLVMGetFirstUse(LLVMValueRef Val);
    539 LLVMUseRef LLVMGetNextUse(LLVMUseRef U);
    540 LLVMValueRef LLVMGetUser(LLVMUseRef U);
    541 LLVMValueRef LLVMGetUsedValue(LLVMUseRef U);
    542 
    543 /* Operations on Users */
    544 LLVMValueRef LLVMGetOperand(LLVMValueRef Val, unsigned Index);
    545 void LLVMSetOperand(LLVMValueRef User, unsigned Index, LLVMValueRef Val);
    546 int LLVMGetNumOperands(LLVMValueRef Val);
    547 
    548 /* Operations on constants of any type */
    549 LLVMValueRef LLVMConstNull(LLVMTypeRef Ty); /* all zeroes */
    550 LLVMValueRef LLVMConstAllOnes(LLVMTypeRef Ty); /* only for int/vector */
    551 LLVMValueRef LLVMGetUndef(LLVMTypeRef Ty);
    552 LLVMBool LLVMIsConstant(LLVMValueRef Val);
    553 LLVMBool LLVMIsNull(LLVMValueRef Val);
    554 LLVMBool LLVMIsUndef(LLVMValueRef Val);
    555 LLVMValueRef LLVMConstPointerNull(LLVMTypeRef Ty);
    556 
    557 /* Operations on metadata */
    558 LLVMValueRef LLVMMDStringInContext(LLVMContextRef C, const char *Str,
    559                                    unsigned SLen);
    560 LLVMValueRef LLVMMDString(const char *Str, unsigned SLen);
    561 LLVMValueRef LLVMMDNodeInContext(LLVMContextRef C, LLVMValueRef *Vals,
    562                                  unsigned Count);
    563 LLVMValueRef LLVMMDNode(LLVMValueRef *Vals, unsigned Count);
    564 const char  *LLVMGetMDString(LLVMValueRef V, unsigned* Len);
    565 int LLVMGetMDNodeNumOperands(LLVMValueRef V);
    566 LLVMValueRef *LLVMGetMDNodeOperand(LLVMValueRef V, unsigned i);
    567 unsigned LLVMGetNamedMetadataNumOperands(LLVMModuleRef M, const char* name);
    568 void LLVMGetNamedMetadataOperands(LLVMModuleRef M, const char* name, LLVMValueRef *Dest);
    569 
    570 /* Operations on scalar constants */
    571 LLVMValueRef LLVMConstInt(LLVMTypeRef IntTy, unsigned long long N,
    572                           LLVMBool SignExtend);
    573 LLVMValueRef LLVMConstIntOfArbitraryPrecision(LLVMTypeRef IntTy,
    574                                               unsigned NumWords,
    575                                               const uint64_t Words[]);
    576 LLVMValueRef LLVMConstIntOfString(LLVMTypeRef IntTy, const char *Text,
    577                                   uint8_t Radix);
    578 LLVMValueRef LLVMConstIntOfStringAndSize(LLVMTypeRef IntTy, const char *Text,
    579                                          unsigned SLen, uint8_t Radix);
    580 LLVMValueRef LLVMConstReal(LLVMTypeRef RealTy, double N);
    581 LLVMValueRef LLVMConstRealOfString(LLVMTypeRef RealTy, const char *Text);
    582 LLVMValueRef LLVMConstRealOfStringAndSize(LLVMTypeRef RealTy, const char *Text,
    583                                           unsigned SLen);
    584 unsigned long long LLVMConstIntGetZExtValue(LLVMValueRef ConstantVal);
    585 long long LLVMConstIntGetSExtValue(LLVMValueRef ConstantVal);
    586 
    587 
    588 /* Operations on composite constants */
    589 LLVMValueRef LLVMConstStringInContext(LLVMContextRef C, const char *Str,
    590                                       unsigned Length, LLVMBool DontNullTerminate);
    591 LLVMValueRef LLVMConstStructInContext(LLVMContextRef C,
    592                                       LLVMValueRef *ConstantVals,
    593                                       unsigned Count, LLVMBool Packed);
    594 
    595 LLVMValueRef LLVMConstString(const char *Str, unsigned Length,
    596                              LLVMBool DontNullTerminate);
    597 LLVMValueRef LLVMConstArray(LLVMTypeRef ElementTy,
    598                             LLVMValueRef *ConstantVals, unsigned Length);
    599 LLVMValueRef LLVMConstStruct(LLVMValueRef *ConstantVals, unsigned Count,
    600                              LLVMBool Packed);
    601 LLVMValueRef LLVMConstNamedStruct(LLVMTypeRef StructTy,
    602                                   LLVMValueRef *ConstantVals,
    603                                   unsigned Count);
    604 LLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals, unsigned Size);
    605 
    606 /* Constant expressions */
    607 LLVMOpcode LLVMGetConstOpcode(LLVMValueRef ConstantVal);
    608 LLVMValueRef LLVMAlignOf(LLVMTypeRef Ty);
    609 LLVMValueRef LLVMSizeOf(LLVMTypeRef Ty);
    610 LLVMValueRef LLVMConstNeg(LLVMValueRef ConstantVal);
    611 LLVMValueRef LLVMConstNSWNeg(LLVMValueRef ConstantVal);
    612 LLVMValueRef LLVMConstNUWNeg(LLVMValueRef ConstantVal);
    613 LLVMValueRef LLVMConstFNeg(LLVMValueRef ConstantVal);
    614 LLVMValueRef LLVMConstNot(LLVMValueRef ConstantVal);
    615 LLVMValueRef LLVMConstAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
    616 LLVMValueRef LLVMConstNSWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
    617 LLVMValueRef LLVMConstNUWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
    618 LLVMValueRef LLVMConstFAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
    619 LLVMValueRef LLVMConstSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
    620 LLVMValueRef LLVMConstNSWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
    621 LLVMValueRef LLVMConstNUWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
    622 LLVMValueRef LLVMConstFSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
    623 LLVMValueRef LLVMConstMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
    624 LLVMValueRef LLVMConstNSWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
    625 LLVMValueRef LLVMConstNUWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
    626 LLVMValueRef LLVMConstFMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
    627 LLVMValueRef LLVMConstUDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
    628 LLVMValueRef LLVMConstSDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
    629 LLVMValueRef LLVMConstExactSDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
    630 LLVMValueRef LLVMConstFDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
    631 LLVMValueRef LLVMConstURem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
    632 LLVMValueRef LLVMConstSRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
    633 LLVMValueRef LLVMConstFRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
    634 LLVMValueRef LLVMConstAnd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
    635 LLVMValueRef LLVMConstOr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
    636 LLVMValueRef LLVMConstXor(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
    637 LLVMValueRef LLVMConstICmp(LLVMIntPredicate Predicate,
    638                            LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
    639 LLVMValueRef LLVMConstFCmp(LLVMRealPredicate Predicate,
    640                            LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
    641 LLVMValueRef LLVMConstShl(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
    642 LLVMValueRef LLVMConstLShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
    643 LLVMValueRef LLVMConstAShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
    644 LLVMValueRef LLVMConstGEP(LLVMValueRef ConstantVal,
    645                           LLVMValueRef *ConstantIndices, unsigned NumIndices);
    646 LLVMValueRef LLVMConstInBoundsGEP(LLVMValueRef ConstantVal,
    647                                   LLVMValueRef *ConstantIndices,
    648                                   unsigned NumIndices);
    649 LLVMValueRef LLVMConstTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
    650 LLVMValueRef LLVMConstSExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
    651 LLVMValueRef LLVMConstZExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
    652 LLVMValueRef LLVMConstFPTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
    653 LLVMValueRef LLVMConstFPExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
    654 LLVMValueRef LLVMConstUIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
    655 LLVMValueRef LLVMConstSIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
    656 LLVMValueRef LLVMConstFPToUI(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
    657 LLVMValueRef LLVMConstFPToSI(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
    658 LLVMValueRef LLVMConstPtrToInt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
    659 LLVMValueRef LLVMConstIntToPtr(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
    660 LLVMValueRef LLVMConstBitCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
    661 LLVMValueRef LLVMConstZExtOrBitCast(LLVMValueRef ConstantVal,
    662                                     LLVMTypeRef ToType);
    663 LLVMValueRef LLVMConstSExtOrBitCast(LLVMValueRef ConstantVal,
    664                                     LLVMTypeRef ToType);
    665 LLVMValueRef LLVMConstTruncOrBitCast(LLVMValueRef ConstantVal,
    666                                      LLVMTypeRef ToType);
    667 LLVMValueRef LLVMConstPointerCast(LLVMValueRef ConstantVal,
    668                                   LLVMTypeRef ToType);
    669 LLVMValueRef LLVMConstIntCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType,
    670                               LLVMBool isSigned);
    671 LLVMValueRef LLVMConstFPCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
    672 LLVMValueRef LLVMConstSelect(LLVMValueRef ConstantCondition,
    673                              LLVMValueRef ConstantIfTrue,
    674                              LLVMValueRef ConstantIfFalse);
    675 LLVMValueRef LLVMConstExtractElement(LLVMValueRef VectorConstant,
    676                                      LLVMValueRef IndexConstant);
    677 LLVMValueRef LLVMConstInsertElement(LLVMValueRef VectorConstant,
    678                                     LLVMValueRef ElementValueConstant,
    679                                     LLVMValueRef IndexConstant);
    680 LLVMValueRef LLVMConstShuffleVector(LLVMValueRef VectorAConstant,
    681                                     LLVMValueRef VectorBConstant,
    682                                     LLVMValueRef MaskConstant);
    683 LLVMValueRef LLVMConstExtractValue(LLVMValueRef AggConstant, unsigned *IdxList,
    684                                    unsigned NumIdx);
    685 LLVMValueRef LLVMConstInsertValue(LLVMValueRef AggConstant,
    686                                   LLVMValueRef ElementValueConstant,
    687                                   unsigned *IdxList, unsigned NumIdx);
    688 LLVMValueRef LLVMConstInlineAsm(LLVMTypeRef Ty,
    689                                 const char *AsmString, const char *Constraints,
    690                                 LLVMBool HasSideEffects, LLVMBool IsAlignStack);
    691 LLVMValueRef LLVMBlockAddress(LLVMValueRef F, LLVMBasicBlockRef BB);
    692 
    693 /* Operations on global variables, functions, and aliases (globals) */
    694 LLVMModuleRef LLVMGetGlobalParent(LLVMValueRef Global);
    695 LLVMBool LLVMIsDeclaration(LLVMValueRef Global);
    696 LLVMLinkage LLVMGetLinkage(LLVMValueRef Global);
    697 void LLVMSetLinkage(LLVMValueRef Global, LLVMLinkage Linkage);
    698 const char *LLVMGetSection(LLVMValueRef Global);
    699 void LLVMSetSection(LLVMValueRef Global, const char *Section);
    700 LLVMVisibility LLVMGetVisibility(LLVMValueRef Global);
    701 void LLVMSetVisibility(LLVMValueRef Global, LLVMVisibility Viz);
    702 unsigned LLVMGetAlignment(LLVMValueRef Global);
    703 void LLVMSetAlignment(LLVMValueRef Global, unsigned Bytes);
    704 
    705 /* Operations on global variables */
    706 LLVMValueRef LLVMAddGlobal(LLVMModuleRef M, LLVMTypeRef Ty, const char *Name);
    707 LLVMValueRef LLVMAddGlobalInAddressSpace(LLVMModuleRef M, LLVMTypeRef Ty,
    708                                          const char *Name,
    709                                          unsigned AddressSpace);
    710 LLVMValueRef LLVMGetNamedGlobal(LLVMModuleRef M, const char *Name);
    711 LLVMValueRef LLVMGetFirstGlobal(LLVMModuleRef M);
    712 LLVMValueRef LLVMGetLastGlobal(LLVMModuleRef M);
    713 LLVMValueRef LLVMGetNextGlobal(LLVMValueRef GlobalVar);
    714 LLVMValueRef LLVMGetPreviousGlobal(LLVMValueRef GlobalVar);
    715 void LLVMDeleteGlobal(LLVMValueRef GlobalVar);
    716 LLVMValueRef LLVMGetInitializer(LLVMValueRef GlobalVar);
    717 void LLVMSetInitializer(LLVMValueRef GlobalVar, LLVMValueRef ConstantVal);
    718 LLVMBool LLVMIsThreadLocal(LLVMValueRef GlobalVar);
    719 void LLVMSetThreadLocal(LLVMValueRef GlobalVar, LLVMBool IsThreadLocal);
    720 LLVMBool LLVMIsGlobalConstant(LLVMValueRef GlobalVar);
    721 void LLVMSetGlobalConstant(LLVMValueRef GlobalVar, LLVMBool IsConstant);
    722 
    723 /* Operations on aliases */
    724 LLVMValueRef LLVMAddAlias(LLVMModuleRef M, LLVMTypeRef Ty, LLVMValueRef Aliasee,
    725                           const char *Name);
    726 
    727 /* Operations on functions */
    728 LLVMValueRef LLVMAddFunction(LLVMModuleRef M, const char *Name,
    729                              LLVMTypeRef FunctionTy);
    730 LLVMValueRef LLVMGetNamedFunction(LLVMModuleRef M, const char *Name);
    731 LLVMValueRef LLVMGetFirstFunction(LLVMModuleRef M);
    732 LLVMValueRef LLVMGetLastFunction(LLVMModuleRef M);
    733 LLVMValueRef LLVMGetNextFunction(LLVMValueRef Fn);
    734 LLVMValueRef LLVMGetPreviousFunction(LLVMValueRef Fn);
    735 void LLVMDeleteFunction(LLVMValueRef Fn);
    736 unsigned LLVMGetIntrinsicID(LLVMValueRef Fn);
    737 unsigned LLVMGetFunctionCallConv(LLVMValueRef Fn);
    738 void LLVMSetFunctionCallConv(LLVMValueRef Fn, unsigned CC);
    739 const char *LLVMGetGC(LLVMValueRef Fn);
    740 void LLVMSetGC(LLVMValueRef Fn, const char *Name);
    741 void LLVMAddFunctionAttr(LLVMValueRef Fn, LLVMAttribute PA);
    742 LLVMAttribute LLVMGetFunctionAttr(LLVMValueRef Fn);
    743 void LLVMRemoveFunctionAttr(LLVMValueRef Fn, LLVMAttribute PA);
    744 
    745 /* Operations on parameters */
    746 unsigned LLVMCountParams(LLVMValueRef Fn);
    747 void LLVMGetParams(LLVMValueRef Fn, LLVMValueRef *Params);
    748 LLVMValueRef LLVMGetParam(LLVMValueRef Fn, unsigned Index);
    749 LLVMValueRef LLVMGetParamParent(LLVMValueRef Inst);
    750 LLVMValueRef LLVMGetFirstParam(LLVMValueRef Fn);
    751 LLVMValueRef LLVMGetLastParam(LLVMValueRef Fn);
    752 LLVMValueRef LLVMGetNextParam(LLVMValueRef Arg);
    753 LLVMValueRef LLVMGetPreviousParam(LLVMValueRef Arg);
    754 void LLVMAddAttribute(LLVMValueRef Arg, LLVMAttribute PA);
    755 void LLVMRemoveAttribute(LLVMValueRef Arg, LLVMAttribute PA);
    756 LLVMAttribute LLVMGetAttribute(LLVMValueRef Arg);
    757 void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned align);
    758 
    759 /* Operations on basic blocks */
    760 LLVMValueRef LLVMBasicBlockAsValue(LLVMBasicBlockRef BB);
    761 LLVMBool LLVMValueIsBasicBlock(LLVMValueRef Val);
    762 LLVMBasicBlockRef LLVMValueAsBasicBlock(LLVMValueRef Val);
    763 LLVMValueRef LLVMGetBasicBlockParent(LLVMBasicBlockRef BB);
    764 LLVMValueRef LLVMGetBasicBlockTerminator(LLVMBasicBlockRef BB);
    765 unsigned LLVMCountBasicBlocks(LLVMValueRef Fn);
    766 void LLVMGetBasicBlocks(LLVMValueRef Fn, LLVMBasicBlockRef *BasicBlocks);
    767 LLVMBasicBlockRef LLVMGetFirstBasicBlock(LLVMValueRef Fn);
    768 LLVMBasicBlockRef LLVMGetLastBasicBlock(LLVMValueRef Fn);
    769 LLVMBasicBlockRef LLVMGetNextBasicBlock(LLVMBasicBlockRef BB);
    770 LLVMBasicBlockRef LLVMGetPreviousBasicBlock(LLVMBasicBlockRef BB);
    771 LLVMBasicBlockRef LLVMGetEntryBasicBlock(LLVMValueRef Fn);
    772 
    773 LLVMBasicBlockRef LLVMAppendBasicBlockInContext(LLVMContextRef C,
    774                                                 LLVMValueRef Fn,
    775                                                 const char *Name);
    776 LLVMBasicBlockRef LLVMInsertBasicBlockInContext(LLVMContextRef C,
    777                                                 LLVMBasicBlockRef BB,
    778                                                 const char *Name);
    779 
    780 LLVMBasicBlockRef LLVMAppendBasicBlock(LLVMValueRef Fn, const char *Name);
    781 LLVMBasicBlockRef LLVMInsertBasicBlock(LLVMBasicBlockRef InsertBeforeBB,
    782                                        const char *Name);
    783 void LLVMDeleteBasicBlock(LLVMBasicBlockRef BB);
    784 void LLVMRemoveBasicBlockFromParent(LLVMBasicBlockRef BB);
    785 
    786 void LLVMMoveBasicBlockBefore(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos);
    787 void LLVMMoveBasicBlockAfter(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos);
    788 
    789 LLVMValueRef LLVMGetFirstInstruction(LLVMBasicBlockRef BB);
    790 LLVMValueRef LLVMGetLastInstruction(LLVMBasicBlockRef BB);
    791 
    792 /* Operations on instructions */
    793 LLVMBasicBlockRef LLVMGetInstructionParent(LLVMValueRef Inst);
    794 LLVMValueRef LLVMGetNextInstruction(LLVMValueRef Inst);
    795 LLVMValueRef LLVMGetPreviousInstruction(LLVMValueRef Inst);
    796 void LLVMInstructionEraseFromParent(LLVMValueRef Inst);
    797 LLVMOpcode   LLVMGetInstructionOpcode(LLVMValueRef Inst);
    798 LLVMIntPredicate LLVMGetICmpPredicate(LLVMValueRef Inst);
    799 
    800 /* Operations on call sites */
    801 void LLVMSetInstructionCallConv(LLVMValueRef Instr, unsigned CC);
    802 unsigned LLVMGetInstructionCallConv(LLVMValueRef Instr);
    803 void LLVMAddInstrAttribute(LLVMValueRef Instr, unsigned index, LLVMAttribute);
    804 void LLVMRemoveInstrAttribute(LLVMValueRef Instr, unsigned index,
    805                               LLVMAttribute);
    806 void LLVMSetInstrParamAlignment(LLVMValueRef Instr, unsigned index,
    807                                 unsigned align);
    808 
    809 /* Operations on call instructions (only) */
    810 LLVMBool LLVMIsTailCall(LLVMValueRef CallInst);
    811 void LLVMSetTailCall(LLVMValueRef CallInst, LLVMBool IsTailCall);
    812 
    813 /* Operations on switch instructions (only) */
    814 LLVMBasicBlockRef LLVMGetSwitchDefaultDest(LLVMValueRef SwitchInstr);
    815 
    816 /* Operations on phi nodes */
    817 void LLVMAddIncoming(LLVMValueRef PhiNode, LLVMValueRef *IncomingValues,
    818                      LLVMBasicBlockRef *IncomingBlocks, unsigned Count);
    819 unsigned LLVMCountIncoming(LLVMValueRef PhiNode);
    820 LLVMValueRef LLVMGetIncomingValue(LLVMValueRef PhiNode, unsigned Index);
    821 LLVMBasicBlockRef LLVMGetIncomingBlock(LLVMValueRef PhiNode, unsigned Index);
    822 
    823 /*===-- Instruction builders ----------------------------------------------===*/
    824 
    825 /* An instruction builder represents a point within a basic block, and is the
    826  * exclusive means of building instructions using the C interface.
    827  */
    828 
    829 LLVMBuilderRef LLVMCreateBuilderInContext(LLVMContextRef C);
    830 LLVMBuilderRef LLVMCreateBuilder(void);
    831 void LLVMPositionBuilder(LLVMBuilderRef Builder, LLVMBasicBlockRef Block,
    832                          LLVMValueRef Instr);
    833 void LLVMPositionBuilderBefore(LLVMBuilderRef Builder, LLVMValueRef Instr);
    834 void LLVMPositionBuilderAtEnd(LLVMBuilderRef Builder, LLVMBasicBlockRef Block);
    835 LLVMBasicBlockRef LLVMGetInsertBlock(LLVMBuilderRef Builder);
    836 void LLVMClearInsertionPosition(LLVMBuilderRef Builder);
    837 void LLVMInsertIntoBuilder(LLVMBuilderRef Builder, LLVMValueRef Instr);
    838 void LLVMInsertIntoBuilderWithName(LLVMBuilderRef Builder, LLVMValueRef Instr,
    839                                    const char *Name);
    840 void LLVMDisposeBuilder(LLVMBuilderRef Builder);
    841 
    842 /* Metadata */
    843 void LLVMSetCurrentDebugLocation(LLVMBuilderRef Builder, LLVMValueRef L);
    844 LLVMValueRef LLVMGetCurrentDebugLocation(LLVMBuilderRef Builder);
    845 void LLVMSetInstDebugLocation(LLVMBuilderRef Builder, LLVMValueRef Inst);
    846 
    847 /* Terminators */
    848 LLVMValueRef LLVMBuildRetVoid(LLVMBuilderRef);
    849 LLVMValueRef LLVMBuildRet(LLVMBuilderRef, LLVMValueRef V);
    850 LLVMValueRef LLVMBuildAggregateRet(LLVMBuilderRef, LLVMValueRef *RetVals,
    851                                    unsigned N);
    852 LLVMValueRef LLVMBuildBr(LLVMBuilderRef, LLVMBasicBlockRef Dest);
    853 LLVMValueRef LLVMBuildCondBr(LLVMBuilderRef, LLVMValueRef If,
    854                              LLVMBasicBlockRef Then, LLVMBasicBlockRef Else);
    855 LLVMValueRef LLVMBuildSwitch(LLVMBuilderRef, LLVMValueRef V,
    856                              LLVMBasicBlockRef Else, unsigned NumCases);
    857 LLVMValueRef LLVMBuildIndirectBr(LLVMBuilderRef B, LLVMValueRef Addr,
    858                                  unsigned NumDests);
    859 LLVMValueRef LLVMBuildInvoke(LLVMBuilderRef, LLVMValueRef Fn,
    860                              LLVMValueRef *Args, unsigned NumArgs,
    861                              LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch,
    862                              const char *Name);
    863 LLVMValueRef LLVMBuildLandingPad(LLVMBuilderRef B, LLVMTypeRef Ty,
    864                                  LLVMValueRef PersFn, unsigned NumClauses,
    865                                  const char *Name);
    866 LLVMValueRef LLVMBuildResume(LLVMBuilderRef B, LLVMValueRef Exn);
    867 LLVMValueRef LLVMBuildUnreachable(LLVMBuilderRef);
    868 
    869 /* Add a case to the switch instruction */
    870 void LLVMAddCase(LLVMValueRef Switch, LLVMValueRef OnVal,
    871                  LLVMBasicBlockRef Dest);
    872 
    873 /* Add a destination to the indirectbr instruction */
    874 void LLVMAddDestination(LLVMValueRef IndirectBr, LLVMBasicBlockRef Dest);
    875 
    876 /* Add a catch or filter clause to the landingpad instruction */
    877 void LLVMAddClause(LLVMValueRef LandingPad, LLVMValueRef ClauseVal);
    878 
    879 /* Set the 'cleanup' flag in the landingpad instruction */
    880 void LLVMSetCleanup(LLVMValueRef LandingPad, LLVMBool Val);
    881 
    882 /* Arithmetic */
    883 LLVMValueRef LLVMBuildAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
    884                           const char *Name);
    885 LLVMValueRef LLVMBuildNSWAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
    886                              const char *Name);
    887 LLVMValueRef LLVMBuildNUWAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
    888                              const char *Name);
    889 LLVMValueRef LLVMBuildFAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
    890                            const char *Name);
    891 LLVMValueRef LLVMBuildSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
    892                           const char *Name);
    893 LLVMValueRef LLVMBuildNSWSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
    894                              const char *Name);
    895 LLVMValueRef LLVMBuildNUWSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
    896                              const char *Name);
    897 LLVMValueRef LLVMBuildFSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
    898                            const char *Name);
    899 LLVMValueRef LLVMBuildMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
    900                           const char *Name);
    901 LLVMValueRef LLVMBuildNSWMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
    902                              const char *Name);
    903 LLVMValueRef LLVMBuildNUWMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
    904                              const char *Name);
    905 LLVMValueRef LLVMBuildFMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
    906                            const char *Name);
    907 LLVMValueRef LLVMBuildUDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
    908                            const char *Name);
    909 LLVMValueRef LLVMBuildSDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
    910                            const char *Name);
    911 LLVMValueRef LLVMBuildExactSDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
    912                                 const char *Name);
    913 LLVMValueRef LLVMBuildFDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
    914                            const char *Name);
    915 LLVMValueRef LLVMBuildURem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
    916                            const char *Name);
    917 LLVMValueRef LLVMBuildSRem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
    918                            const char *Name);
    919 LLVMValueRef LLVMBuildFRem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
    920                            const char *Name);
    921 LLVMValueRef LLVMBuildShl(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
    922                            const char *Name);
    923 LLVMValueRef LLVMBuildLShr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
    924                            const char *Name);
    925 LLVMValueRef LLVMBuildAShr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
    926                            const char *Name);
    927 LLVMValueRef LLVMBuildAnd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
    928                           const char *Name);
    929 LLVMValueRef LLVMBuildOr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
    930                           const char *Name);
    931 LLVMValueRef LLVMBuildXor(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
    932                           const char *Name);
    933 LLVMValueRef LLVMBuildBinOp(LLVMBuilderRef B, LLVMOpcode Op,
    934                             LLVMValueRef LHS, LLVMValueRef RHS,
    935                             const char *Name);
    936 LLVMValueRef LLVMBuildNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name);
    937 LLVMValueRef LLVMBuildNSWNeg(LLVMBuilderRef B, LLVMValueRef V,
    938                              const char *Name);
    939 LLVMValueRef LLVMBuildNUWNeg(LLVMBuilderRef B, LLVMValueRef V,
    940                              const char *Name);
    941 LLVMValueRef LLVMBuildFNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name);
    942 LLVMValueRef LLVMBuildNot(LLVMBuilderRef, LLVMValueRef V, const char *Name);
    943 
    944 /* Memory */
    945 LLVMValueRef LLVMBuildMalloc(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
    946 LLVMValueRef LLVMBuildArrayMalloc(LLVMBuilderRef, LLVMTypeRef Ty,
    947                                   LLVMValueRef Val, const char *Name);
    948 LLVMValueRef LLVMBuildAlloca(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
    949 LLVMValueRef LLVMBuildArrayAlloca(LLVMBuilderRef, LLVMTypeRef Ty,
    950                                   LLVMValueRef Val, const char *Name);
    951 LLVMValueRef LLVMBuildFree(LLVMBuilderRef, LLVMValueRef PointerVal);
    952 LLVMValueRef LLVMBuildLoad(LLVMBuilderRef, LLVMValueRef PointerVal,
    953                            const char *Name);
    954 LLVMValueRef LLVMBuildStore(LLVMBuilderRef, LLVMValueRef Val, LLVMValueRef Ptr);
    955 LLVMValueRef LLVMBuildGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
    956                           LLVMValueRef *Indices, unsigned NumIndices,
    957                           const char *Name);
    958 LLVMValueRef LLVMBuildInBoundsGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
    959                                   LLVMValueRef *Indices, unsigned NumIndices,
    960                                   const char *Name);
    961 LLVMValueRef LLVMBuildStructGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
    962                                 unsigned Idx, const char *Name);
    963 LLVMValueRef LLVMBuildGlobalString(LLVMBuilderRef B, const char *Str,
    964                                    const char *Name);
    965 LLVMValueRef LLVMBuildGlobalStringPtr(LLVMBuilderRef B, const char *Str,
    966                                       const char *Name);
    967 
    968 /* Casts */
    969 LLVMValueRef LLVMBuildTrunc(LLVMBuilderRef, LLVMValueRef Val,
    970                             LLVMTypeRef DestTy, const char *Name);
    971 LLVMValueRef LLVMBuildZExt(LLVMBuilderRef, LLVMValueRef Val,
    972                            LLVMTypeRef DestTy, const char *Name);
    973 LLVMValueRef LLVMBuildSExt(LLVMBuilderRef, LLVMValueRef Val,
    974                            LLVMTypeRef DestTy, const char *Name);
    975 LLVMValueRef LLVMBuildFPToUI(LLVMBuilderRef, LLVMValueRef Val,
    976                              LLVMTypeRef DestTy, const char *Name);
    977 LLVMValueRef LLVMBuildFPToSI(LLVMBuilderRef, LLVMValueRef Val,
    978                              LLVMTypeRef DestTy, const char *Name);
    979 LLVMValueRef LLVMBuildUIToFP(LLVMBuilderRef, LLVMValueRef Val,
    980                              LLVMTypeRef DestTy, const char *Name);
    981 LLVMValueRef LLVMBuildSIToFP(LLVMBuilderRef, LLVMValueRef Val,
    982                              LLVMTypeRef DestTy, const char *Name);
    983 LLVMValueRef LLVMBuildFPTrunc(LLVMBuilderRef, LLVMValueRef Val,
    984                               LLVMTypeRef DestTy, const char *Name);
    985 LLVMValueRef LLVMBuildFPExt(LLVMBuilderRef, LLVMValueRef Val,
    986                             LLVMTypeRef DestTy, const char *Name);
    987 LLVMValueRef LLVMBuildPtrToInt(LLVMBuilderRef, LLVMValueRef Val,
    988                                LLVMTypeRef DestTy, const char *Name);
    989 LLVMValueRef LLVMBuildIntToPtr(LLVMBuilderRef, LLVMValueRef Val,
    990                                LLVMTypeRef DestTy, const char *Name);
    991 LLVMValueRef LLVMBuildBitCast(LLVMBuilderRef, LLVMValueRef Val,
    992                               LLVMTypeRef DestTy, const char *Name);
    993 LLVMValueRef LLVMBuildZExtOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
    994                                     LLVMTypeRef DestTy, const char *Name);
    995 LLVMValueRef LLVMBuildSExtOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
    996                                     LLVMTypeRef DestTy, const char *Name);
    997 LLVMValueRef LLVMBuildTruncOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
    998                                      LLVMTypeRef DestTy, const char *Name);
    999 LLVMValueRef LLVMBuildCast(LLVMBuilderRef B, LLVMOpcode Op, LLVMValueRef Val,
   1000                            LLVMTypeRef DestTy, const char *Name);
   1001 LLVMValueRef LLVMBuildPointerCast(LLVMBuilderRef, LLVMValueRef Val,
   1002                                   LLVMTypeRef DestTy, const char *Name);
   1003 LLVMValueRef LLVMBuildIntCast(LLVMBuilderRef, LLVMValueRef Val, /*Signed cast!*/
   1004                               LLVMTypeRef DestTy, const char *Name);
   1005 LLVMValueRef LLVMBuildFPCast(LLVMBuilderRef, LLVMValueRef Val,
   1006                              LLVMTypeRef DestTy, const char *Name);
   1007 
   1008 /* Comparisons */
   1009 LLVMValueRef LLVMBuildICmp(LLVMBuilderRef, LLVMIntPredicate Op,
   1010                            LLVMValueRef LHS, LLVMValueRef RHS,
   1011                            const char *Name);
   1012 LLVMValueRef LLVMBuildFCmp(LLVMBuilderRef, LLVMRealPredicate Op,
   1013                            LLVMValueRef LHS, LLVMValueRef RHS,
   1014                            const char *Name);
   1015 
   1016 /* Miscellaneous instructions */
   1017 LLVMValueRef LLVMBuildPhi(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
   1018 LLVMValueRef LLVMBuildCall(LLVMBuilderRef, LLVMValueRef Fn,
   1019                            LLVMValueRef *Args, unsigned NumArgs,
   1020                            const char *Name);
   1021 LLVMValueRef LLVMBuildSelect(LLVMBuilderRef, LLVMValueRef If,
   1022                              LLVMValueRef Then, LLVMValueRef Else,
   1023                              const char *Name);
   1024 LLVMValueRef LLVMBuildVAArg(LLVMBuilderRef, LLVMValueRef List, LLVMTypeRef Ty,
   1025                             const char *Name);
   1026 LLVMValueRef LLVMBuildExtractElement(LLVMBuilderRef, LLVMValueRef VecVal,
   1027                                      LLVMValueRef Index, const char *Name);
   1028 LLVMValueRef LLVMBuildInsertElement(LLVMBuilderRef, LLVMValueRef VecVal,
   1029                                     LLVMValueRef EltVal, LLVMValueRef Index,
   1030                                     const char *Name);
   1031 LLVMValueRef LLVMBuildShuffleVector(LLVMBuilderRef, LLVMValueRef V1,
   1032                                     LLVMValueRef V2, LLVMValueRef Mask,
   1033                                     const char *Name);
   1034 LLVMValueRef LLVMBuildExtractValue(LLVMBuilderRef, LLVMValueRef AggVal,
   1035                                    unsigned Index, const char *Name);
   1036 LLVMValueRef LLVMBuildInsertValue(LLVMBuilderRef, LLVMValueRef AggVal,
   1037                                   LLVMValueRef EltVal, unsigned Index,
   1038                                   const char *Name);
   1039 
   1040 LLVMValueRef LLVMBuildIsNull(LLVMBuilderRef, LLVMValueRef Val,
   1041                              const char *Name);
   1042 LLVMValueRef LLVMBuildIsNotNull(LLVMBuilderRef, LLVMValueRef Val,
   1043                                 const char *Name);
   1044 LLVMValueRef LLVMBuildPtrDiff(LLVMBuilderRef, LLVMValueRef LHS,
   1045                               LLVMValueRef RHS, const char *Name);
   1046 
   1047 
   1048 /*===-- Module providers --------------------------------------------------===*/
   1049 
   1050 /* Changes the type of M so it can be passed to FunctionPassManagers and the
   1051  * JIT.  They take ModuleProviders for historical reasons.
   1052  */
   1053 LLVMModuleProviderRef
   1054 LLVMCreateModuleProviderForExistingModule(LLVMModuleRef M);
   1055 
   1056 /* Destroys the module M.
   1057  */
   1058 void LLVMDisposeModuleProvider(LLVMModuleProviderRef M);
   1059 
   1060 
   1061 /*===-- Memory buffers ----------------------------------------------------===*/
   1062 
   1063 LLVMBool LLVMCreateMemoryBufferWithContentsOfFile(const char *Path,
   1064                                                   LLVMMemoryBufferRef *OutMemBuf,
   1065                                                   char **OutMessage);
   1066 LLVMBool LLVMCreateMemoryBufferWithSTDIN(LLVMMemoryBufferRef *OutMemBuf,
   1067                                          char **OutMessage);
   1068 void LLVMDisposeMemoryBuffer(LLVMMemoryBufferRef MemBuf);
   1069 
   1070 /*===-- Pass Registry -----------------------------------------------------===*/
   1071 
   1072 /** Return the global pass registry, for use with initialization functions.
   1073     See llvm::PassRegistry::getPassRegistry. */
   1074 LLVMPassRegistryRef LLVMGetGlobalPassRegistry(void);
   1075 
   1076 /*===-- Pass Managers -----------------------------------------------------===*/
   1077 
   1078 /** Constructs a new whole-module pass pipeline. This type of pipeline is
   1079     suitable for link-time optimization and whole-module transformations.
   1080     See llvm::PassManager::PassManager. */
   1081 LLVMPassManagerRef LLVMCreatePassManager(void);
   1082 
   1083 /** Constructs a new function-by-function pass pipeline over the module
   1084     provider. It does not take ownership of the module provider. This type of
   1085     pipeline is suitable for code generation and JIT compilation tasks.
   1086     See llvm::FunctionPassManager::FunctionPassManager. */
   1087 LLVMPassManagerRef LLVMCreateFunctionPassManagerForModule(LLVMModuleRef M);
   1088 
   1089 /** Deprecated: Use LLVMCreateFunctionPassManagerForModule instead. */
   1090 LLVMPassManagerRef LLVMCreateFunctionPassManager(LLVMModuleProviderRef MP);
   1091 
   1092 /** Initializes, executes on the provided module, and finalizes all of the
   1093     passes scheduled in the pass manager. Returns 1 if any of the passes
   1094     modified the module, 0 otherwise. See llvm::PassManager::run(Module&). */
   1095 LLVMBool LLVMRunPassManager(LLVMPassManagerRef PM, LLVMModuleRef M);
   1096 
   1097 /** Initializes all of the function passes scheduled in the function pass
   1098     manager. Returns 1 if any of the passes modified the module, 0 otherwise.
   1099     See llvm::FunctionPassManager::doInitialization. */
   1100 LLVMBool LLVMInitializeFunctionPassManager(LLVMPassManagerRef FPM);
   1101 
   1102 /** Executes all of the function passes scheduled in the function pass manager
   1103     on the provided function. Returns 1 if any of the passes modified the
   1104     function, false otherwise.
   1105     See llvm::FunctionPassManager::run(Function&). */
   1106 LLVMBool LLVMRunFunctionPassManager(LLVMPassManagerRef FPM, LLVMValueRef F);
   1107 
   1108 /** Finalizes all of the function passes scheduled in in the function pass
   1109     manager. Returns 1 if any of the passes modified the module, 0 otherwise.
   1110     See llvm::FunctionPassManager::doFinalization. */
   1111 LLVMBool LLVMFinalizeFunctionPassManager(LLVMPassManagerRef FPM);
   1112 
   1113 /** Frees the memory of a pass pipeline. For function pipelines, does not free
   1114     the module provider.
   1115     See llvm::PassManagerBase::~PassManagerBase. */
   1116 void LLVMDisposePassManager(LLVMPassManagerRef PM);
   1117 
   1118 
   1119 #ifdef __cplusplus
   1120 }
   1121 
   1122 namespace llvm {
   1123   class MemoryBuffer;
   1124   class PassManagerBase;
   1125 
   1126   #define DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref)   \
   1127     inline ty *unwrap(ref P) {                          \
   1128       return reinterpret_cast<ty*>(P);                  \
   1129     }                                                   \
   1130                                                         \
   1131     inline ref wrap(const ty *P) {                      \
   1132       return reinterpret_cast<ref>(const_cast<ty*>(P)); \
   1133     }
   1134 
   1135   #define DEFINE_ISA_CONVERSION_FUNCTIONS(ty, ref)  \
   1136     DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref)         \
   1137                                                         \
   1138     template<typename T>                                \
   1139     inline T *unwrap(ref P) {                           \
   1140       return cast<T>(unwrap(P));                        \
   1141     }
   1142 
   1143   #define DEFINE_STDCXX_CONVERSION_FUNCTIONS(ty, ref)   \
   1144     DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref)         \
   1145                                                         \
   1146     template<typename T>                                \
   1147     inline T *unwrap(ref P) {                           \
   1148       T *Q = (T*)unwrap(P);                             \
   1149       assert(Q && "Invalid cast!");                     \
   1150       return Q;                                         \
   1151     }
   1152 
   1153   DEFINE_ISA_CONVERSION_FUNCTIONS   (Type,               LLVMTypeRef          )
   1154   DEFINE_ISA_CONVERSION_FUNCTIONS   (Value,              LLVMValueRef         )
   1155   DEFINE_SIMPLE_CONVERSION_FUNCTIONS(Module,             LLVMModuleRef        )
   1156   DEFINE_SIMPLE_CONVERSION_FUNCTIONS(BasicBlock,         LLVMBasicBlockRef    )
   1157   DEFINE_SIMPLE_CONVERSION_FUNCTIONS(IRBuilder<>,        LLVMBuilderRef       )
   1158   DEFINE_SIMPLE_CONVERSION_FUNCTIONS(MemoryBuffer,       LLVMMemoryBufferRef  )
   1159   DEFINE_SIMPLE_CONVERSION_FUNCTIONS(LLVMContext,        LLVMContextRef       )
   1160   DEFINE_SIMPLE_CONVERSION_FUNCTIONS(Use,                LLVMUseRef           )
   1161   DEFINE_STDCXX_CONVERSION_FUNCTIONS(PassManagerBase,    LLVMPassManagerRef   )
   1162   DEFINE_STDCXX_CONVERSION_FUNCTIONS(PassRegistry,       LLVMPassRegistryRef  )
   1163   /* LLVMModuleProviderRef exists for historical reasons, but now just holds a
   1164    * Module.
   1165    */
   1166   inline Module *unwrap(LLVMModuleProviderRef MP) {
   1167     return reinterpret_cast<Module*>(MP);
   1168   }
   1169 
   1170   #undef DEFINE_STDCXX_CONVERSION_FUNCTIONS
   1171   #undef DEFINE_ISA_CONVERSION_FUNCTIONS
   1172   #undef DEFINE_SIMPLE_CONVERSION_FUNCTIONS
   1173 
   1174   /* Specialized opaque context conversions.
   1175    */
   1176   inline LLVMContext **unwrap(LLVMContextRef* Tys) {
   1177     return reinterpret_cast<LLVMContext**>(Tys);
   1178   }
   1179 
   1180   inline LLVMContextRef *wrap(const LLVMContext **Tys) {
   1181     return reinterpret_cast<LLVMContextRef*>(const_cast<LLVMContext**>(Tys));
   1182   }
   1183 
   1184   /* Specialized opaque type conversions.
   1185    */
   1186   inline Type **unwrap(LLVMTypeRef* Tys) {
   1187     return reinterpret_cast<Type**>(Tys);
   1188   }
   1189 
   1190   inline LLVMTypeRef *wrap(Type **Tys) {
   1191     return reinterpret_cast<LLVMTypeRef*>(const_cast<Type**>(Tys));
   1192   }
   1193 
   1194   /* Specialized opaque value conversions.
   1195    */
   1196   inline Value **unwrap(LLVMValueRef *Vals) {
   1197     return reinterpret_cast<Value**>(Vals);
   1198   }
   1199 
   1200   template<typename T>
   1201   inline T **unwrap(LLVMValueRef *Vals, unsigned Length) {
   1202     #if DEBUG
   1203     for (LLVMValueRef *I = Vals, *E = Vals + Length; I != E; ++I)
   1204       cast<T>(*I);
   1205     #endif
   1206     (void)Length;
   1207     return reinterpret_cast<T**>(Vals);
   1208   }
   1209 
   1210   inline LLVMValueRef *wrap(const Value **Vals) {
   1211     return reinterpret_cast<LLVMValueRef*>(const_cast<Value**>(Vals));
   1212   }
   1213 }
   1214 
   1215 #endif /* !defined(__cplusplus) */
   1216 
   1217 #endif /* !defined(LLVM_C_CORE_H) */
   1218