Gordon Henriksen | 8b94a14 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 1 | /*===-- llvm-c/Core.h - Core Library C Interface ------------------*- C -*-===*\ |
| 2 | |* *| |
| 3 | |* The LLVM Compiler Infrastructure *| |
| 4 | |* *| |
Chris Lattner | 7ed47a1 | 2007-12-29 19:59:42 +0000 | [diff] [blame] | 5 | |* This file is distributed under the University of Illinois Open Source *| |
| 6 | |* License. See LICENSE.TXT for details. *| |
Gordon Henriksen | 8b94a14 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 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 | |* *| |
Gordon Henriksen | acd9619 | 2007-10-05 23:59:36 +0000 | [diff] [blame] | 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 | |* *| |
Gordon Henriksen | 8b94a14 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 31 | \*===----------------------------------------------------------------------===*/ |
| 32 | |
| 33 | #ifndef LLVM_C_CORE_H |
| 34 | #define LLVM_C_CORE_H |
| 35 | |
| 36 | #ifdef __cplusplus |
Gordon Henriksen | acd9619 | 2007-10-05 23:59:36 +0000 | [diff] [blame] | 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/LLVMBuilder.h" |
| 42 | |
Gordon Henriksen | 8b94a14 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 43 | extern "C" { |
| 44 | #endif |
| 45 | |
| 46 | |
| 47 | /* Opaque types. */ |
Gordon Henriksen | dc2c07a | 2007-12-30 17:46:33 +0000 | [diff] [blame] | 48 | |
| 49 | /** |
| 50 | * The top-level container for all other LLVM Intermediate Representation (IR) |
| 51 | * objects. See the llvm::Module class. |
| 52 | */ |
Gordon Henriksen | 8b94a14 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 53 | typedef struct LLVMOpaqueModule *LLVMModuleRef; |
Gordon Henriksen | dc2c07a | 2007-12-30 17:46:33 +0000 | [diff] [blame] | 54 | |
| 55 | /** |
Gordon Henriksen | bbf1c51 | 2008-03-07 19:13:06 +0000 | [diff] [blame] | 56 | * Each value in the LLVM IR has a type, an LLVMTypeRef. See the llvm::Type |
| 57 | * class. |
Gordon Henriksen | dc2c07a | 2007-12-30 17:46:33 +0000 | [diff] [blame] | 58 | */ |
Gordon Henriksen | 8b94a14 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 59 | typedef struct LLVMOpaqueType *LLVMTypeRef; |
Gordon Henriksen | dc2c07a | 2007-12-30 17:46:33 +0000 | [diff] [blame] | 60 | |
| 61 | /** |
Gordon Henriksen | bbf1c51 | 2008-03-07 19:13:06 +0000 | [diff] [blame] | 62 | * When building recursive types using LLVMRefineType, LLVMTypeRef values may |
| 63 | * become invalid; use LLVMTypeHandleRef to resolve this problem. See the |
| 64 | * llvm::AbstractTypeHolder class. |
Gordon Henriksen | dc2c07a | 2007-12-30 17:46:33 +0000 | [diff] [blame] | 65 | */ |
Gordon Henriksen | 1cf08fd | 2007-10-07 00:13:35 +0000 | [diff] [blame] | 66 | typedef struct LLVMOpaqueTypeHandle *LLVMTypeHandleRef; |
Gordon Henriksen | dc2c07a | 2007-12-30 17:46:33 +0000 | [diff] [blame] | 67 | |
Gordon Henriksen | 8b94a14 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 68 | typedef struct LLVMOpaqueValue *LLVMValueRef; |
Gordon Henriksen | 46abf91 | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 69 | typedef struct LLVMOpaqueBasicBlock *LLVMBasicBlockRef; |
| 70 | typedef struct LLVMOpaqueBuilder *LLVMBuilderRef; |
Gordon Henriksen | da1435f | 2007-12-19 22:30:40 +0000 | [diff] [blame] | 71 | |
| 72 | /* Used to provide a module to JIT or interpreter. |
| 73 | * See the llvm::ModuleProvider class. |
| 74 | */ |
Gordon Henriksen | 1ae6135 | 2007-12-12 01:04:30 +0000 | [diff] [blame] | 75 | typedef struct LLVMOpaqueModuleProvider *LLVMModuleProviderRef; |
Gordon Henriksen | 8b94a14 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 76 | |
Gordon Henriksen | da1435f | 2007-12-19 22:30:40 +0000 | [diff] [blame] | 77 | /* Used to provide a module to JIT or interpreter. |
| 78 | * See the llvm::MemoryBuffer class. |
| 79 | */ |
| 80 | typedef struct LLVMOpaqueMemoryBuffer *LLVMMemoryBufferRef; |
| 81 | |
Gordon Henriksen | 8b94a14 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 82 | typedef enum { |
Gordon Henriksen | dc2c07a | 2007-12-30 17:46:33 +0000 | [diff] [blame] | 83 | LLVMVoidTypeKind, /**< type with no size */ |
| 84 | LLVMFloatTypeKind, /**< 32 bit floating point type */ |
| 85 | LLVMDoubleTypeKind, /**< 64 bit floating point type */ |
| 86 | LLVMX86_FP80TypeKind, /**< 80 bit floating point type (X87) */ |
| 87 | LLVMFP128TypeKind, /**< 128 bit floating point type (112-bit mantissa)*/ |
| 88 | LLVMPPC_FP128TypeKind, /**< 128 bit floating point type (two 64-bits) */ |
| 89 | LLVMLabelTypeKind, /**< Labels */ |
| 90 | LLVMIntegerTypeKind, /**< Arbitrary bit width integers */ |
| 91 | LLVMFunctionTypeKind, /**< Functions */ |
| 92 | LLVMStructTypeKind, /**< Structures */ |
| 93 | LLVMArrayTypeKind, /**< Arrays */ |
| 94 | LLVMPointerTypeKind, /**< Pointers */ |
| 95 | LLVMOpaqueTypeKind, /**< Opaque: type with unknown structure */ |
| 96 | LLVMVectorTypeKind /**< SIMD 'packed' format, or other vector type */ |
Gordon Henriksen | 8b94a14 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 97 | } LLVMTypeKind; |
| 98 | |
| 99 | typedef enum { |
Gordon Henriksen | dc2c07a | 2007-12-30 17:46:33 +0000 | [diff] [blame] | 100 | LLVMExternalLinkage, /**< Externally visible function */ |
| 101 | LLVMLinkOnceLinkage, /**< Keep one copy of function when linking (inline)*/ |
| 102 | LLVMWeakLinkage, /**< Keep one copy of function when linking (weak) */ |
| 103 | LLVMAppendingLinkage, /**< Special purpose, only applies to global arrays */ |
| 104 | LLVMInternalLinkage, /**< Rename collisions when linking (static |
| 105 | functions) */ |
| 106 | LLVMDLLImportLinkage, /**< Function to be imported from DLL */ |
| 107 | LLVMDLLExportLinkage, /**< Function to be accessible from DLL */ |
| 108 | LLVMExternalWeakLinkage,/**< ExternalWeak linkage description */ |
| 109 | LLVMGhostLinkage /**< Stand-in functions for streaming fns from |
| 110 | bitcode */ |
Gordon Henriksen | 8b94a14 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 111 | } LLVMLinkage; |
| 112 | |
| 113 | typedef enum { |
Gordon Henriksen | dc2c07a | 2007-12-30 17:46:33 +0000 | [diff] [blame] | 114 | LLVMDefaultVisibility, /**< The GV is visible */ |
| 115 | LLVMHiddenVisibility, /**< The GV is hidden */ |
| 116 | LLVMProtectedVisibility /**< The GV is protected */ |
Gordon Henriksen | 8b94a14 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 117 | } LLVMVisibility; |
| 118 | |
Gordon Henriksen | 46abf91 | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 119 | typedef enum { |
| 120 | LLVMCCallConv = 0, |
| 121 | LLVMFastCallConv = 8, |
| 122 | LLVMColdCallConv = 9, |
| 123 | LLVMX86StdcallCallConv = 64, |
| 124 | LLVMX86FastcallCallConv = 65 |
| 125 | } LLVMCallConv; |
| 126 | |
| 127 | typedef enum { |
Gordon Henriksen | dc2c07a | 2007-12-30 17:46:33 +0000 | [diff] [blame] | 128 | LLVMIntEQ = 32, /**< equal */ |
| 129 | LLVMIntNE, /**< not equal */ |
| 130 | LLVMIntUGT, /**< unsigned greater than */ |
| 131 | LLVMIntUGE, /**< unsigned greater or equal */ |
| 132 | LLVMIntULT, /**< unsigned less than */ |
| 133 | LLVMIntULE, /**< unsigned less or equal */ |
| 134 | LLVMIntSGT, /**< signed greater than */ |
| 135 | LLVMIntSGE, /**< signed greater or equal */ |
| 136 | LLVMIntSLT, /**< signed less than */ |
| 137 | LLVMIntSLE /**< signed less or equal */ |
Gordon Henriksen | 46abf91 | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 138 | } LLVMIntPredicate; |
| 139 | |
| 140 | typedef enum { |
Gordon Henriksen | dc2c07a | 2007-12-30 17:46:33 +0000 | [diff] [blame] | 141 | LLVMRealPredicateFalse, /**< Always false (always folded) */ |
| 142 | LLVMRealOEQ, /**< True if ordered and equal */ |
| 143 | LLVMRealOGT, /**< True if ordered and greater than */ |
| 144 | LLVMRealOGE, /**< True if ordered and greater than or equal */ |
| 145 | LLVMRealOLT, /**< True if ordered and less than */ |
| 146 | LLVMRealOLE, /**< True if ordered and less than or equal */ |
| 147 | LLVMRealONE, /**< True if ordered and operands are unequal */ |
| 148 | LLVMRealORD, /**< True if ordered (no nans) */ |
| 149 | LLVMRealUNO, /**< True if unordered: isnan(X) | isnan(Y) */ |
| 150 | LLVMRealUEQ, /**< True if unordered or equal */ |
| 151 | LLVMRealUGT, /**< True if unordered or greater than */ |
| 152 | LLVMRealUGE, /**< True if unordered, greater than, or equal */ |
| 153 | LLVMRealULT, /**< True if unordered or less than */ |
| 154 | LLVMRealULE, /**< True if unordered, less than, or equal */ |
| 155 | LLVMRealUNE, /**< True if unordered or not equal */ |
| 156 | LLVMRealPredicateTrue /**< Always true (always folded) */ |
Gordon Henriksen | 46abf91 | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 157 | } LLVMRealPredicate; |
| 158 | |
Gordon Henriksen | 8b94a14 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 159 | |
Gordon Henriksen | da1435f | 2007-12-19 22:30:40 +0000 | [diff] [blame] | 160 | /*===-- Error handling ----------------------------------------------------===*/ |
| 161 | |
| 162 | void LLVMDisposeMessage(char *Message); |
| 163 | |
| 164 | |
Gordon Henriksen | 8b94a14 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 165 | /*===-- Modules -----------------------------------------------------------===*/ |
| 166 | |
| 167 | /* Create and destroy modules. */ |
Gordon Henriksen | bbf1c51 | 2008-03-07 19:13:06 +0000 | [diff] [blame] | 168 | /** See llvm::Module::Module. */ |
Gordon Henriksen | 8b94a14 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 169 | LLVMModuleRef LLVMModuleCreateWithName(const char *ModuleID); |
Gordon Henriksen | bbf1c51 | 2008-03-07 19:13:06 +0000 | [diff] [blame] | 170 | |
| 171 | /** See llvm::Module::~Module. */ |
Gordon Henriksen | 8b94a14 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 172 | void LLVMDisposeModule(LLVMModuleRef M); |
| 173 | |
Gordon Henriksen | bbf1c51 | 2008-03-07 19:13:06 +0000 | [diff] [blame] | 174 | /** Data layout. See Module::getDataLayout. */ |
Gordon Henriksen | a353ffa | 2007-12-27 20:13:47 +0000 | [diff] [blame] | 175 | const char *LLVMGetDataLayout(LLVMModuleRef M); |
| 176 | void LLVMSetDataLayout(LLVMModuleRef M, const char *Triple); |
| 177 | |
Gordon Henriksen | bbf1c51 | 2008-03-07 19:13:06 +0000 | [diff] [blame] | 178 | /** Target triple. See Module::getTargetTriple. */ |
Gordon Henriksen | a353ffa | 2007-12-27 20:13:47 +0000 | [diff] [blame] | 179 | const char *LLVMGetTarget(LLVMModuleRef M); |
| 180 | void LLVMSetTarget(LLVMModuleRef M, const char *Triple); |
| 181 | |
Gordon Henriksen | bbf1c51 | 2008-03-07 19:13:06 +0000 | [diff] [blame] | 182 | /** See Module::addTypeName. */ |
Gordon Henriksen | 8b94a14 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 183 | int LLVMAddTypeName(LLVMModuleRef M, const char *Name, LLVMTypeRef Ty); |
Gordon Henriksen | 46abf91 | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 184 | void LLVMDeleteTypeName(LLVMModuleRef M, const char *Name); |
Gordon Henriksen | 8b94a14 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 185 | |
Gordon Henriksen | af59b10 | 2008-03-14 23:58:56 +0000 | [diff] [blame^] | 186 | /** See Module::dump. */ |
| 187 | void LLVMDumpModule(LLVMModuleRef M); |
| 188 | |
Gordon Henriksen | 8b94a14 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 189 | |
Gordon Henriksen | 46abf91 | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 190 | /*===-- Types -------------------------------------------------------------===*/ |
Gordon Henriksen | 8b94a14 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 191 | |
| 192 | /* LLVM types conform to the following hierarchy: |
| 193 | * |
| 194 | * types: |
| 195 | * integer type |
| 196 | * real type |
| 197 | * function type |
| 198 | * sequence types: |
| 199 | * array type |
| 200 | * pointer type |
| 201 | * vector type |
| 202 | * void type |
| 203 | * label type |
| 204 | * opaque type |
| 205 | */ |
| 206 | |
Gordon Henriksen | bbf1c51 | 2008-03-07 19:13:06 +0000 | [diff] [blame] | 207 | /** See llvm::LLVMTypeKind::getTypeID. */ |
Gordon Henriksen | 8b94a14 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 208 | LLVMTypeKind LLVMGetTypeKind(LLVMTypeRef Ty); |
Gordon Henriksen | bbf1c51 | 2008-03-07 19:13:06 +0000 | [diff] [blame] | 209 | |
| 210 | /** See llvm::DerivedType::refineAbstractTypeTo. */ |
Gordon Henriksen | 8b94a14 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 211 | void LLVMRefineAbstractType(LLVMTypeRef AbstractType, LLVMTypeRef ConcreteType); |
| 212 | |
| 213 | /* Operations on integer types */ |
| 214 | LLVMTypeRef LLVMInt1Type(); |
| 215 | LLVMTypeRef LLVMInt8Type(); |
| 216 | LLVMTypeRef LLVMInt16Type(); |
| 217 | LLVMTypeRef LLVMInt32Type(); |
| 218 | LLVMTypeRef LLVMInt64Type(); |
Gordon Henriksen | 81a7881 | 2007-10-06 16:05:20 +0000 | [diff] [blame] | 219 | LLVMTypeRef LLVMIntType(unsigned NumBits); |
Gordon Henriksen | 46abf91 | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 220 | unsigned LLVMGetIntTypeWidth(LLVMTypeRef IntegerTy); |
Gordon Henriksen | 8b94a14 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 221 | |
| 222 | /* Operations on real types */ |
| 223 | LLVMTypeRef LLVMFloatType(); |
| 224 | LLVMTypeRef LLVMDoubleType(); |
| 225 | LLVMTypeRef LLVMX86FP80Type(); |
| 226 | LLVMTypeRef LLVMFP128Type(); |
| 227 | LLVMTypeRef LLVMPPCFP128Type(); |
| 228 | |
| 229 | /* Operations on function types */ |
Gordon Henriksen | 81a7881 | 2007-10-06 16:05:20 +0000 | [diff] [blame] | 230 | LLVMTypeRef LLVMFunctionType(LLVMTypeRef ReturnType, |
| 231 | LLVMTypeRef *ParamTypes, unsigned ParamCount, |
| 232 | int IsVarArg); |
Gordon Henriksen | 8b94a14 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 233 | int LLVMIsFunctionVarArg(LLVMTypeRef FunctionTy); |
Gordon Henriksen | 46abf91 | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 234 | LLVMTypeRef LLVMGetReturnType(LLVMTypeRef FunctionTy); |
| 235 | unsigned LLVMCountParamTypes(LLVMTypeRef FunctionTy); |
| 236 | void LLVMGetParamTypes(LLVMTypeRef FunctionTy, LLVMTypeRef *Dest); |
Gordon Henriksen | 8b94a14 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 237 | |
| 238 | /* Operations on struct types */ |
Gordon Henriksen | 81a7881 | 2007-10-06 16:05:20 +0000 | [diff] [blame] | 239 | LLVMTypeRef LLVMStructType(LLVMTypeRef *ElementTypes, unsigned ElementCount, |
| 240 | int Packed); |
Gordon Henriksen | 46abf91 | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 241 | unsigned LLVMCountStructElementTypes(LLVMTypeRef StructTy); |
Gordon Henriksen | 8b94a14 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 242 | void LLVMGetStructElementTypes(LLVMTypeRef StructTy, LLVMTypeRef *Dest); |
| 243 | int LLVMIsPackedStruct(LLVMTypeRef StructTy); |
| 244 | |
| 245 | /* Operations on array, pointer, and vector types (sequence types) */ |
Gordon Henriksen | 81a7881 | 2007-10-06 16:05:20 +0000 | [diff] [blame] | 246 | LLVMTypeRef LLVMArrayType(LLVMTypeRef ElementType, unsigned ElementCount); |
Gordon Henriksen | 57cebee | 2007-12-17 16:08:32 +0000 | [diff] [blame] | 247 | LLVMTypeRef LLVMPointerType(LLVMTypeRef ElementType, unsigned AddressSpace); |
Gordon Henriksen | 81a7881 | 2007-10-06 16:05:20 +0000 | [diff] [blame] | 248 | LLVMTypeRef LLVMVectorType(LLVMTypeRef ElementType, unsigned ElementCount); |
Gordon Henriksen | 8b94a14 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 249 | |
| 250 | LLVMTypeRef LLVMGetElementType(LLVMTypeRef Ty); |
| 251 | unsigned LLVMGetArrayLength(LLVMTypeRef ArrayTy); |
Gordon Henriksen | 57cebee | 2007-12-17 16:08:32 +0000 | [diff] [blame] | 252 | unsigned LLVMGetPointerAddressSpace(LLVMTypeRef PointerTy); |
Gordon Henriksen | 8b94a14 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 253 | unsigned LLVMGetVectorSize(LLVMTypeRef VectorTy); |
| 254 | |
| 255 | /* Operations on other types */ |
| 256 | LLVMTypeRef LLVMVoidType(); |
| 257 | LLVMTypeRef LLVMLabelType(); |
Gordon Henriksen | 81a7881 | 2007-10-06 16:05:20 +0000 | [diff] [blame] | 258 | LLVMTypeRef LLVMOpaqueType(); |
Gordon Henriksen | 8b94a14 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 259 | |
Gordon Henriksen | 1cf08fd | 2007-10-07 00:13:35 +0000 | [diff] [blame] | 260 | /* Operations on type handles */ |
| 261 | LLVMTypeHandleRef LLVMCreateTypeHandle(LLVMTypeRef PotentiallyAbstractTy); |
| 262 | void LLVMRefineType(LLVMTypeRef AbstractTy, LLVMTypeRef ConcreteTy); |
| 263 | LLVMTypeRef LLVMResolveTypeHandle(LLVMTypeHandleRef TypeHandle); |
| 264 | void LLVMDisposeTypeHandle(LLVMTypeHandleRef TypeHandle); |
| 265 | |
Gordon Henriksen | 8b94a14 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 266 | |
| 267 | /*===-- Values ------------------------------------------------------------===*/ |
| 268 | |
| 269 | /* The bulk of LLVM's object model consists of values, which comprise a very |
| 270 | * rich type hierarchy. |
| 271 | * |
| 272 | * values: |
| 273 | * constants: |
| 274 | * scalar constants |
| 275 | * composite contants |
| 276 | * globals: |
| 277 | * global variable |
| 278 | * function |
| 279 | * alias |
Gordon Henriksen | 46abf91 | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 280 | * basic blocks |
Gordon Henriksen | 8b94a14 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 281 | */ |
| 282 | |
| 283 | /* Operations on all values */ |
Gordon Henriksen | 46abf91 | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 284 | LLVMTypeRef LLVMTypeOf(LLVMValueRef Val); |
Gordon Henriksen | 8b94a14 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 285 | const char *LLVMGetValueName(LLVMValueRef Val); |
| 286 | void LLVMSetValueName(LLVMValueRef Val, const char *Name); |
Gordon Henriksen | 88cc699 | 2007-10-06 00:08:49 +0000 | [diff] [blame] | 287 | void LLVMDumpValue(LLVMValueRef Val); |
Gordon Henriksen | 8b94a14 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 288 | |
| 289 | /* Operations on constants of any type */ |
Gordon Henriksen | e3b989d | 2007-10-06 15:11:06 +0000 | [diff] [blame] | 290 | LLVMValueRef LLVMConstNull(LLVMTypeRef Ty); /* all zeroes */ |
| 291 | LLVMValueRef LLVMConstAllOnes(LLVMTypeRef Ty); /* only for int/vector */ |
Gordon Henriksen | 8b94a14 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 292 | LLVMValueRef LLVMGetUndef(LLVMTypeRef Ty); |
Gordon Henriksen | 344be5f | 2007-09-18 18:07:51 +0000 | [diff] [blame] | 293 | int LLVMIsConstant(LLVMValueRef Val); |
Gordon Henriksen | 8b94a14 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 294 | int LLVMIsNull(LLVMValueRef Val); |
Gordon Henriksen | 344be5f | 2007-09-18 18:07:51 +0000 | [diff] [blame] | 295 | int LLVMIsUndef(LLVMValueRef Val); |
Gordon Henriksen | 8b94a14 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 296 | |
| 297 | /* Operations on scalar constants */ |
Gordon Henriksen | e3b989d | 2007-10-06 15:11:06 +0000 | [diff] [blame] | 298 | LLVMValueRef LLVMConstInt(LLVMTypeRef IntTy, unsigned long long N, |
| 299 | int SignExtend); |
| 300 | LLVMValueRef LLVMConstReal(LLVMTypeRef RealTy, double N); |
Gordon Henriksen | e62a8a3 | 2008-02-02 01:07:50 +0000 | [diff] [blame] | 301 | LLVMValueRef LLVMConstRealOfString(LLVMTypeRef RealTy, const char *Text); |
Gordon Henriksen | 8b94a14 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 302 | |
| 303 | /* Operations on composite constants */ |
Gordon Henriksen | e3b989d | 2007-10-06 15:11:06 +0000 | [diff] [blame] | 304 | LLVMValueRef LLVMConstString(const char *Str, unsigned Length, |
| 305 | int DontNullTerminate); |
| 306 | LLVMValueRef LLVMConstArray(LLVMTypeRef ArrayTy, |
| 307 | LLVMValueRef *ConstantVals, unsigned Length); |
| 308 | LLVMValueRef LLVMConstStruct(LLVMValueRef *ConstantVals, unsigned Count, |
| 309 | int packed); |
| 310 | LLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals, unsigned Size); |
Gordon Henriksen | 8b94a14 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 311 | |
Gordon Henriksen | 4647569 | 2007-10-06 14:29:36 +0000 | [diff] [blame] | 312 | /* Constant expressions */ |
| 313 | LLVMValueRef LLVMSizeOf(LLVMTypeRef Ty); |
| 314 | LLVMValueRef LLVMConstNeg(LLVMValueRef ConstantVal); |
| 315 | LLVMValueRef LLVMConstNot(LLVMValueRef ConstantVal); |
| 316 | LLVMValueRef LLVMConstAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); |
| 317 | LLVMValueRef LLVMConstSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); |
| 318 | LLVMValueRef LLVMConstMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); |
| 319 | LLVMValueRef LLVMConstUDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); |
| 320 | LLVMValueRef LLVMConstSDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); |
| 321 | LLVMValueRef LLVMConstFDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); |
| 322 | LLVMValueRef LLVMConstURem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); |
| 323 | LLVMValueRef LLVMConstSRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); |
| 324 | LLVMValueRef LLVMConstFRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); |
| 325 | LLVMValueRef LLVMConstAnd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); |
| 326 | LLVMValueRef LLVMConstOr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); |
| 327 | LLVMValueRef LLVMConstXor(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); |
| 328 | LLVMValueRef LLVMConstICmp(LLVMIntPredicate Predicate, |
| 329 | LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); |
| 330 | LLVMValueRef LLVMConstFCmp(LLVMRealPredicate Predicate, |
| 331 | LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); |
| 332 | LLVMValueRef LLVMConstShl(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); |
| 333 | LLVMValueRef LLVMConstLShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); |
| 334 | LLVMValueRef LLVMConstAShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); |
| 335 | LLVMValueRef LLVMConstGEP(LLVMValueRef ConstantVal, |
| 336 | LLVMValueRef *ConstantIndices, unsigned NumIndices); |
| 337 | LLVMValueRef LLVMConstTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType); |
| 338 | LLVMValueRef LLVMConstSExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType); |
| 339 | LLVMValueRef LLVMConstZExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType); |
| 340 | LLVMValueRef LLVMConstFPTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType); |
| 341 | LLVMValueRef LLVMConstFPExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType); |
| 342 | LLVMValueRef LLVMConstUIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType); |
| 343 | LLVMValueRef LLVMConstSIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType); |
| 344 | LLVMValueRef LLVMConstFPToUI(LLVMValueRef ConstantVal, LLVMTypeRef ToType); |
| 345 | LLVMValueRef LLVMConstFPToSI(LLVMValueRef ConstantVal, LLVMTypeRef ToType); |
| 346 | LLVMValueRef LLVMConstPtrToInt(LLVMValueRef ConstantVal, LLVMTypeRef ToType); |
| 347 | LLVMValueRef LLVMConstIntToPtr(LLVMValueRef ConstantVal, LLVMTypeRef ToType); |
| 348 | LLVMValueRef LLVMConstBitCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType); |
| 349 | LLVMValueRef LLVMConstSelect(LLVMValueRef ConstantCondition, |
| 350 | LLVMValueRef ConstantIfTrue, |
| 351 | LLVMValueRef ConstantIfFalse); |
| 352 | LLVMValueRef LLVMConstExtractElement(LLVMValueRef VectorConstant, |
| 353 | LLVMValueRef IndexConstant); |
| 354 | LLVMValueRef LLVMConstInsertElement(LLVMValueRef VectorConstant, |
| 355 | LLVMValueRef ElementValueConstant, |
| 356 | LLVMValueRef IndexConstant); |
| 357 | LLVMValueRef LLVMConstShuffleVector(LLVMValueRef VectorAConstant, |
| 358 | LLVMValueRef VectorBConstant, |
| 359 | LLVMValueRef MaskConstant); |
| 360 | |
Gordon Henriksen | 8b94a14 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 361 | /* Operations on global variables, functions, and aliases (globals) */ |
| 362 | int LLVMIsDeclaration(LLVMValueRef Global); |
| 363 | LLVMLinkage LLVMGetLinkage(LLVMValueRef Global); |
| 364 | void LLVMSetLinkage(LLVMValueRef Global, LLVMLinkage Linkage); |
| 365 | const char *LLVMGetSection(LLVMValueRef Global); |
| 366 | void LLVMSetSection(LLVMValueRef Global, const char *Section); |
| 367 | LLVMVisibility LLVMGetVisibility(LLVMValueRef Global); |
| 368 | void LLVMSetVisibility(LLVMValueRef Global, LLVMVisibility Viz); |
| 369 | unsigned LLVMGetAlignment(LLVMValueRef Global); |
| 370 | void LLVMSetAlignment(LLVMValueRef Global, unsigned Bytes); |
| 371 | |
| 372 | /* Operations on global variables */ |
| 373 | LLVMValueRef LLVMAddGlobal(LLVMModuleRef M, LLVMTypeRef Ty, const char *Name); |
Gordon Henriksen | 6d6203d | 2007-10-08 03:45:09 +0000 | [diff] [blame] | 374 | LLVMValueRef LLVMGetNamedGlobal(LLVMModuleRef M, const char *Name); |
Gordon Henriksen | 8b94a14 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 375 | void LLVMDeleteGlobal(LLVMValueRef GlobalVar); |
| 376 | int LLVMHasInitializer(LLVMValueRef GlobalVar); |
| 377 | LLVMValueRef LLVMGetInitializer(LLVMValueRef GlobalVar); |
| 378 | void LLVMSetInitializer(LLVMValueRef GlobalVar, LLVMValueRef ConstantVal); |
| 379 | int LLVMIsThreadLocal(LLVMValueRef GlobalVar); |
| 380 | void LLVMSetThreadLocal(LLVMValueRef GlobalVar, int IsThreadLocal); |
Gordon Henriksen | c84c16b | 2007-10-07 17:31:42 +0000 | [diff] [blame] | 381 | int LLVMIsGlobalConstant(LLVMValueRef GlobalVar); |
| 382 | void LLVMSetGlobalConstant(LLVMValueRef GlobalVar, int IsConstant); |
Gordon Henriksen | 8b94a14 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 383 | |
Gordon Henriksen | 46abf91 | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 384 | /* Operations on functions */ |
| 385 | LLVMValueRef LLVMAddFunction(LLVMModuleRef M, const char *Name, |
| 386 | LLVMTypeRef FunctionTy); |
Gordon Henriksen | 6d6203d | 2007-10-08 03:45:09 +0000 | [diff] [blame] | 387 | LLVMValueRef LLVMGetNamedFunction(LLVMModuleRef M, const char *Name); |
Gordon Henriksen | 46abf91 | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 388 | void LLVMDeleteFunction(LLVMValueRef Fn); |
| 389 | unsigned LLVMCountParams(LLVMValueRef Fn); |
| 390 | void LLVMGetParams(LLVMValueRef Fn, LLVMValueRef *Params); |
| 391 | LLVMValueRef LLVMGetParam(LLVMValueRef Fn, unsigned Index); |
| 392 | unsigned LLVMGetIntrinsicID(LLVMValueRef Fn); |
| 393 | unsigned LLVMGetFunctionCallConv(LLVMValueRef Fn); |
| 394 | void LLVMSetFunctionCallConv(LLVMValueRef Fn, unsigned CC); |
Gordon Henriksen | 80a75bf | 2007-12-10 03:18:06 +0000 | [diff] [blame] | 395 | const char *LLVMGetCollector(LLVMValueRef Fn); |
| 396 | void LLVMSetCollector(LLVMValueRef Fn, const char *Coll); |
Gordon Henriksen | 46abf91 | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 397 | |
| 398 | /* Operations on basic blocks */ |
| 399 | LLVMValueRef LLVMBasicBlockAsValue(LLVMBasicBlockRef Bb); |
| 400 | int LLVMValueIsBasicBlock(LLVMValueRef Val); |
| 401 | LLVMBasicBlockRef LLVMValueAsBasicBlock(LLVMValueRef Val); |
| 402 | unsigned LLVMCountBasicBlocks(LLVMValueRef Fn); |
| 403 | void LLVMGetBasicBlocks(LLVMValueRef Fn, LLVMBasicBlockRef *BasicBlocks); |
| 404 | LLVMBasicBlockRef LLVMGetEntryBasicBlock(LLVMValueRef Fn); |
| 405 | LLVMBasicBlockRef LLVMAppendBasicBlock(LLVMValueRef Fn, const char *Name); |
| 406 | LLVMBasicBlockRef LLVMInsertBasicBlock(LLVMBasicBlockRef InsertBeforeBB, |
| 407 | const char *Name); |
| 408 | void LLVMDeleteBasicBlock(LLVMBasicBlockRef BB); |
| 409 | |
Gordon Henriksen | cc0928f | 2007-12-29 20:45:00 +0000 | [diff] [blame] | 410 | /* Operations on call sites */ |
| 411 | void LLVMSetInstructionCallConv(LLVMValueRef Instr, unsigned CC); |
| 412 | unsigned LLVMGetInstructionCallConv(LLVMValueRef Instr); |
| 413 | |
Gordon Henriksen | 2618a6c | 2007-10-08 18:14:39 +0000 | [diff] [blame] | 414 | /* Operations on phi nodes */ |
| 415 | void LLVMAddIncoming(LLVMValueRef PhiNode, LLVMValueRef *IncomingValues, |
| 416 | LLVMBasicBlockRef *IncomingBlocks, unsigned Count); |
| 417 | unsigned LLVMCountIncoming(LLVMValueRef PhiNode); |
| 418 | LLVMValueRef LLVMGetIncomingValue(LLVMValueRef PhiNode, unsigned Index); |
| 419 | LLVMBasicBlockRef LLVMGetIncomingBlock(LLVMValueRef PhiNode, unsigned Index); |
Gordon Henriksen | 46abf91 | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 420 | |
| 421 | /*===-- Instruction builders ----------------------------------------------===*/ |
| 422 | |
| 423 | /* An instruction builder represents a point within a basic block, and is the |
| 424 | * exclusive means of building instructions using the C interface. |
| 425 | */ |
| 426 | |
| 427 | LLVMBuilderRef LLVMCreateBuilder(); |
| 428 | void LLVMPositionBuilderBefore(LLVMBuilderRef Builder, LLVMValueRef Instr); |
| 429 | void LLVMPositionBuilderAtEnd(LLVMBuilderRef Builder, LLVMBasicBlockRef Block); |
| 430 | void LLVMDisposeBuilder(LLVMBuilderRef Builder); |
| 431 | |
| 432 | /* Terminators */ |
| 433 | LLVMValueRef LLVMBuildRetVoid(LLVMBuilderRef); |
| 434 | LLVMValueRef LLVMBuildRet(LLVMBuilderRef, LLVMValueRef V); |
| 435 | LLVMValueRef LLVMBuildBr(LLVMBuilderRef, LLVMBasicBlockRef Dest); |
| 436 | LLVMValueRef LLVMBuildCondBr(LLVMBuilderRef, LLVMValueRef If, |
| 437 | LLVMBasicBlockRef Then, LLVMBasicBlockRef Else); |
| 438 | LLVMValueRef LLVMBuildSwitch(LLVMBuilderRef, LLVMValueRef V, |
| 439 | LLVMBasicBlockRef Else, unsigned NumCases); |
| 440 | LLVMValueRef LLVMBuildInvoke(LLVMBuilderRef, LLVMValueRef Fn, |
| 441 | LLVMValueRef *Args, unsigned NumArgs, |
| 442 | LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch, |
| 443 | const char *Name); |
| 444 | LLVMValueRef LLVMBuildUnwind(LLVMBuilderRef); |
| 445 | LLVMValueRef LLVMBuildUnreachable(LLVMBuilderRef); |
| 446 | |
Gordon Henriksen | ab477cc | 2008-01-01 05:50:53 +0000 | [diff] [blame] | 447 | /* Add a case to the switch instruction */ |
| 448 | void LLVMAddCase(LLVMValueRef Switch, LLVMValueRef OnVal, |
| 449 | LLVMBasicBlockRef Dest); |
| 450 | |
Gordon Henriksen | 46abf91 | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 451 | /* Arithmetic */ |
| 452 | LLVMValueRef LLVMBuildAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, |
| 453 | const char *Name); |
| 454 | LLVMValueRef LLVMBuildSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, |
| 455 | const char *Name); |
| 456 | LLVMValueRef LLVMBuildMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, |
| 457 | const char *Name); |
| 458 | LLVMValueRef LLVMBuildUDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, |
| 459 | const char *Name); |
| 460 | LLVMValueRef LLVMBuildSDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, |
| 461 | const char *Name); |
| 462 | LLVMValueRef LLVMBuildFDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, |
| 463 | const char *Name); |
| 464 | LLVMValueRef LLVMBuildURem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, |
| 465 | const char *Name); |
| 466 | LLVMValueRef LLVMBuildSRem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, |
| 467 | const char *Name); |
| 468 | LLVMValueRef LLVMBuildFRem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, |
| 469 | const char *Name); |
| 470 | LLVMValueRef LLVMBuildShl(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, |
| 471 | const char *Name); |
| 472 | LLVMValueRef LLVMBuildLShr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, |
| 473 | const char *Name); |
| 474 | LLVMValueRef LLVMBuildAShr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, |
| 475 | const char *Name); |
| 476 | LLVMValueRef LLVMBuildAnd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, |
| 477 | const char *Name); |
| 478 | LLVMValueRef LLVMBuildOr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, |
| 479 | const char *Name); |
| 480 | LLVMValueRef LLVMBuildXor(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, |
| 481 | const char *Name); |
| 482 | LLVMValueRef LLVMBuildNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name); |
| 483 | LLVMValueRef LLVMBuildNot(LLVMBuilderRef, LLVMValueRef V, const char *Name); |
| 484 | |
| 485 | /* Memory */ |
| 486 | LLVMValueRef LLVMBuildMalloc(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name); |
| 487 | LLVMValueRef LLVMBuildArrayMalloc(LLVMBuilderRef, LLVMTypeRef Ty, |
| 488 | LLVMValueRef Val, const char *Name); |
| 489 | LLVMValueRef LLVMBuildAlloca(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name); |
| 490 | LLVMValueRef LLVMBuildArrayAlloca(LLVMBuilderRef, LLVMTypeRef Ty, |
| 491 | LLVMValueRef Val, const char *Name); |
| 492 | LLVMValueRef LLVMBuildFree(LLVMBuilderRef, LLVMValueRef PointerVal); |
| 493 | LLVMValueRef LLVMBuildLoad(LLVMBuilderRef, LLVMValueRef PointerVal, |
| 494 | const char *Name); |
| 495 | LLVMValueRef LLVMBuildStore(LLVMBuilderRef, LLVMValueRef Val, LLVMValueRef Ptr); |
| 496 | LLVMValueRef LLVMBuildGEP(LLVMBuilderRef B, LLVMValueRef Pointer, |
| 497 | LLVMValueRef *Indices, unsigned NumIndices, |
| 498 | const char *Name); |
| 499 | |
| 500 | /* Casts */ |
| 501 | LLVMValueRef LLVMBuildTrunc(LLVMBuilderRef, LLVMValueRef Val, |
| 502 | LLVMTypeRef DestTy, const char *Name); |
| 503 | LLVMValueRef LLVMBuildZExt(LLVMBuilderRef, LLVMValueRef Val, |
| 504 | LLVMTypeRef DestTy, const char *Name); |
| 505 | LLVMValueRef LLVMBuildSExt(LLVMBuilderRef, LLVMValueRef Val, |
| 506 | LLVMTypeRef DestTy, const char *Name); |
| 507 | LLVMValueRef LLVMBuildFPToUI(LLVMBuilderRef, LLVMValueRef Val, |
| 508 | LLVMTypeRef DestTy, const char *Name); |
| 509 | LLVMValueRef LLVMBuildFPToSI(LLVMBuilderRef, LLVMValueRef Val, |
| 510 | LLVMTypeRef DestTy, const char *Name); |
| 511 | LLVMValueRef LLVMBuildUIToFP(LLVMBuilderRef, LLVMValueRef Val, |
| 512 | LLVMTypeRef DestTy, const char *Name); |
| 513 | LLVMValueRef LLVMBuildSIToFP(LLVMBuilderRef, LLVMValueRef Val, |
| 514 | LLVMTypeRef DestTy, const char *Name); |
| 515 | LLVMValueRef LLVMBuildFPTrunc(LLVMBuilderRef, LLVMValueRef Val, |
| 516 | LLVMTypeRef DestTy, const char *Name); |
| 517 | LLVMValueRef LLVMBuildFPExt(LLVMBuilderRef, LLVMValueRef Val, |
| 518 | LLVMTypeRef DestTy, const char *Name); |
| 519 | LLVMValueRef LLVMBuildPtrToInt(LLVMBuilderRef, LLVMValueRef Val, |
| 520 | LLVMTypeRef DestTy, const char *Name); |
| 521 | LLVMValueRef LLVMBuildIntToPtr(LLVMBuilderRef, LLVMValueRef Val, |
| 522 | LLVMTypeRef DestTy, const char *Name); |
| 523 | LLVMValueRef LLVMBuildBitCast(LLVMBuilderRef, LLVMValueRef Val, |
| 524 | LLVMTypeRef DestTy, const char *Name); |
| 525 | |
| 526 | /* Comparisons */ |
| 527 | LLVMValueRef LLVMBuildICmp(LLVMBuilderRef, LLVMIntPredicate Op, |
| 528 | LLVMValueRef LHS, LLVMValueRef RHS, |
| 529 | const char *Name); |
| 530 | LLVMValueRef LLVMBuildFCmp(LLVMBuilderRef, LLVMRealPredicate Op, |
| 531 | LLVMValueRef LHS, LLVMValueRef RHS, |
| 532 | const char *Name); |
| 533 | |
| 534 | /* Miscellaneous instructions */ |
| 535 | LLVMValueRef LLVMBuildPhi(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name); |
| 536 | LLVMValueRef LLVMBuildCall(LLVMBuilderRef, LLVMValueRef Fn, |
| 537 | LLVMValueRef *Args, unsigned NumArgs, |
| 538 | const char *Name); |
| 539 | LLVMValueRef LLVMBuildSelect(LLVMBuilderRef, LLVMValueRef If, |
| 540 | LLVMValueRef Then, LLVMValueRef Else, |
| 541 | const char *Name); |
| 542 | LLVMValueRef LLVMBuildVAArg(LLVMBuilderRef, LLVMValueRef List, LLVMTypeRef Ty, |
| 543 | const char *Name); |
| 544 | LLVMValueRef LLVMBuildExtractElement(LLVMBuilderRef, LLVMValueRef VecVal, |
| 545 | LLVMValueRef Index, const char *Name); |
| 546 | LLVMValueRef LLVMBuildInsertElement(LLVMBuilderRef, LLVMValueRef VecVal, |
| 547 | LLVMValueRef EltVal, LLVMValueRef Index, |
| 548 | const char *Name); |
| 549 | LLVMValueRef LLVMBuildShuffleVector(LLVMBuilderRef, LLVMValueRef V1, |
| 550 | LLVMValueRef V2, LLVMValueRef Mask, |
| 551 | const char *Name); |
Gordon Henriksen | 8b94a14 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 552 | |
Gordon Henriksen | da1435f | 2007-12-19 22:30:40 +0000 | [diff] [blame] | 553 | |
Gordon Henriksen | 1ae6135 | 2007-12-12 01:04:30 +0000 | [diff] [blame] | 554 | /*===-- Module providers --------------------------------------------------===*/ |
| 555 | |
| 556 | /* Encapsulates the module M in a module provider, taking ownership of the |
| 557 | * module. |
| 558 | * See the constructor llvm::ExistingModuleProvider::ExistingModuleProvider. |
| 559 | */ |
| 560 | LLVMModuleProviderRef |
| 561 | LLVMCreateModuleProviderForExistingModule(LLVMModuleRef M); |
| 562 | |
| 563 | /* Destroys the module provider MP as well as the contained module. |
| 564 | * See the destructor llvm::ModuleProvider::~ModuleProvider. |
| 565 | */ |
| 566 | void LLVMDisposeModuleProvider(LLVMModuleProviderRef MP); |
| 567 | |
Gordon Henriksen | da1435f | 2007-12-19 22:30:40 +0000 | [diff] [blame] | 568 | |
| 569 | /*===-- Memory buffers ----------------------------------------------------===*/ |
| 570 | |
| 571 | int LLVMCreateMemoryBufferWithContentsOfFile(const char *Path, |
| 572 | LLVMMemoryBufferRef *OutMemBuf, |
| 573 | char **OutMessage); |
| 574 | int LLVMCreateMemoryBufferWithSTDIN(LLVMMemoryBufferRef *OutMemBuf, |
| 575 | char **OutMessage); |
| 576 | void LLVMDisposeMemoryBuffer(LLVMMemoryBufferRef MemBuf); |
| 577 | |
Gordon Henriksen | 8b94a14 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 578 | #ifdef __cplusplus |
| 579 | } |
Gordon Henriksen | 8b94a14 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 580 | |
Gordon Henriksen | acd9619 | 2007-10-05 23:59:36 +0000 | [diff] [blame] | 581 | namespace llvm { |
Gordon Henriksen | 1ae6135 | 2007-12-12 01:04:30 +0000 | [diff] [blame] | 582 | class ModuleProvider; |
Gordon Henriksen | da1435f | 2007-12-19 22:30:40 +0000 | [diff] [blame] | 583 | class MemoryBuffer; |
Gordon Henriksen | 1ae6135 | 2007-12-12 01:04:30 +0000 | [diff] [blame] | 584 | |
Gordon Henriksen | da1435f | 2007-12-19 22:30:40 +0000 | [diff] [blame] | 585 | #define DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref) \ |
| 586 | inline ty *unwrap(ref P) { \ |
| 587 | return reinterpret_cast<ty*>(P); \ |
| 588 | } \ |
| 589 | \ |
| 590 | inline ref wrap(const ty *P) { \ |
| 591 | return reinterpret_cast<ref>(const_cast<ty*>(P)); \ |
| 592 | } |
Gordon Henriksen | acd9619 | 2007-10-05 23:59:36 +0000 | [diff] [blame] | 593 | |
Gordon Henriksen | 1d2e49c | 2007-12-27 18:25:59 +0000 | [diff] [blame] | 594 | DEFINE_SIMPLE_CONVERSION_FUNCTIONS(Type, LLVMTypeRef ) |
| 595 | DEFINE_SIMPLE_CONVERSION_FUNCTIONS(Value, LLVMValueRef ) |
| 596 | DEFINE_SIMPLE_CONVERSION_FUNCTIONS(Module, LLVMModuleRef ) |
| 597 | DEFINE_SIMPLE_CONVERSION_FUNCTIONS(BasicBlock, LLVMBasicBlockRef ) |
| 598 | DEFINE_SIMPLE_CONVERSION_FUNCTIONS(LLVMFoldingBuilder, LLVMBuilderRef ) |
| 599 | DEFINE_SIMPLE_CONVERSION_FUNCTIONS(PATypeHolder, LLVMTypeHandleRef ) |
| 600 | DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ModuleProvider, LLVMModuleProviderRef) |
| 601 | DEFINE_SIMPLE_CONVERSION_FUNCTIONS(MemoryBuffer, LLVMMemoryBufferRef ) |
Gordon Henriksen | acd9619 | 2007-10-05 23:59:36 +0000 | [diff] [blame] | 602 | |
Gordon Henriksen | da1435f | 2007-12-19 22:30:40 +0000 | [diff] [blame] | 603 | #undef DEFINE_SIMPLE_CONVERSION_FUNCTIONS |
Gordon Henriksen | acd9619 | 2007-10-05 23:59:36 +0000 | [diff] [blame] | 604 | |
Gordon Henriksen | da1435f | 2007-12-19 22:30:40 +0000 | [diff] [blame] | 605 | /* Specialized opaque type conversions. |
| 606 | */ |
Gordon Henriksen | acd9619 | 2007-10-05 23:59:36 +0000 | [diff] [blame] | 607 | template<typename T> |
| 608 | inline T *unwrap(LLVMTypeRef Ty) { |
| 609 | return cast<T>(unwrap(Ty)); |
| 610 | } |
| 611 | |
| 612 | inline Type **unwrap(LLVMTypeRef* Tys) { |
| 613 | return reinterpret_cast<Type**>(Tys); |
| 614 | } |
| 615 | |
Gordon Henriksen | acd9619 | 2007-10-05 23:59:36 +0000 | [diff] [blame] | 616 | inline LLVMTypeRef *wrap(const Type **Tys) { |
| 617 | return reinterpret_cast<LLVMTypeRef*>(const_cast<Type**>(Tys)); |
| 618 | } |
| 619 | |
Gordon Henriksen | da1435f | 2007-12-19 22:30:40 +0000 | [diff] [blame] | 620 | /* Specialized opaque value conversions. |
Gordon Henriksen | acd9619 | 2007-10-05 23:59:36 +0000 | [diff] [blame] | 621 | */ |
Gordon Henriksen | acd9619 | 2007-10-05 23:59:36 +0000 | [diff] [blame] | 622 | template<typename T> |
| 623 | inline T *unwrap(LLVMValueRef Val) { |
| 624 | return cast<T>(unwrap(Val)); |
| 625 | } |
| 626 | |
| 627 | inline Value **unwrap(LLVMValueRef *Vals) { |
| 628 | return reinterpret_cast<Value**>(Vals); |
| 629 | } |
| 630 | |
| 631 | template<typename T> |
| 632 | inline T **unwrap(LLVMValueRef *Vals, unsigned Length) { |
| 633 | #if DEBUG |
| 634 | for (LLVMValueRef *I = Vals, E = Vals + Length; I != E; ++I) |
| 635 | cast<T>(*I); |
| 636 | #endif |
| 637 | return reinterpret_cast<T**>(Vals); |
| 638 | } |
| 639 | |
Gordon Henriksen | acd9619 | 2007-10-05 23:59:36 +0000 | [diff] [blame] | 640 | inline LLVMValueRef *wrap(const Value **Vals) { |
| 641 | return reinterpret_cast<LLVMValueRef*>(const_cast<Value**>(Vals)); |
| 642 | } |
Gordon Henriksen | acd9619 | 2007-10-05 23:59:36 +0000 | [diff] [blame] | 643 | } |
| 644 | |
| 645 | #endif /* !defined(__cplusplus) */ |
| 646 | |
| 647 | #endif /* !defined(LLVM_C_CORE_H) */ |