Gordon Henriksen | 76a0374 | 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 | |* *| |
| 5 | |* This file was developed by Gordon Henriksen and is distributed under the *| |
| 6 | |* University of Illinois Open Source 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 | |* *| |
Gordon Henriksen | 7330acd | 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 | 76a0374 | 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 | 7330acd | 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 | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 43 | extern "C" { |
| 44 | #endif |
| 45 | |
| 46 | |
| 47 | /* Opaque types. */ |
| 48 | typedef struct LLVMOpaqueModule *LLVMModuleRef; |
| 49 | typedef struct LLVMOpaqueType *LLVMTypeRef; |
| 50 | typedef struct LLVMOpaqueValue *LLVMValueRef; |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 51 | typedef struct LLVMOpaqueBasicBlock *LLVMBasicBlockRef; |
| 52 | typedef struct LLVMOpaqueBuilder *LLVMBuilderRef; |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 53 | |
| 54 | typedef enum { |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 55 | LLVMVoidTypeKind, /* type with no size */ |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 56 | LLVMFloatTypeKind, /* 32 bit floating point type */ |
| 57 | LLVMDoubleTypeKind, /* 64 bit floating point type */ |
| 58 | LLVMX86_FP80TypeKind, /* 80 bit floating point type (X87) */ |
| 59 | LLVMFP128TypeKind, /* 128 bit floating point type (112-bit mantissa) */ |
| 60 | LLVMPPC_FP128TypeKind, /* 128 bit floating point type (two 64-bits) */ |
| 61 | LLVMLabelTypeKind, /* Labels */ |
| 62 | LLVMIntegerTypeKind, /* Arbitrary bit width integers */ |
| 63 | LLVMFunctionTypeKind, /* Functions */ |
| 64 | LLVMStructTypeKind, /* Structures */ |
| 65 | LLVMArrayTypeKind, /* Arrays */ |
| 66 | LLVMPointerTypeKind, /* Pointers */ |
| 67 | LLVMOpaqueTypeKind, /* Opaque: type with unknown structure */ |
| 68 | LLVMVectorTypeKind /* SIMD 'packed' format, or other vector type */ |
| 69 | } LLVMTypeKind; |
| 70 | |
| 71 | typedef enum { |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 72 | LLVMExternalLinkage, /* Externally visible function */ |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 73 | LLVMLinkOnceLinkage, /* Keep one copy of function when linking (inline) */ |
| 74 | LLVMWeakLinkage, /* Keep one copy of function when linking (weak) */ |
| 75 | LLVMAppendingLinkage, /* Special purpose, only applies to global arrays */ |
| 76 | LLVMInternalLinkage, /* Rename collisions when linking (static functions)*/ |
| 77 | LLVMDLLImportLinkage, /* Function to be imported from DLL */ |
| 78 | LLVMDLLExportLinkage, /* Function to be accessible from DLL */ |
| 79 | LLVMExternalWeakLinkage,/* ExternalWeak linkage description */ |
| 80 | LLVMGhostLinkage /* Stand-in functions for streaming fns from bitcode*/ |
| 81 | } LLVMLinkage; |
| 82 | |
| 83 | typedef enum { |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 84 | LLVMDefaultVisibility, /* The GV is visible */ |
| 85 | LLVMHiddenVisibility, /* The GV is hidden */ |
| 86 | LLVMProtectedVisibility /* The GV is protected */ |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 87 | } LLVMVisibility; |
| 88 | |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 89 | typedef enum { |
| 90 | LLVMCCallConv = 0, |
| 91 | LLVMFastCallConv = 8, |
| 92 | LLVMColdCallConv = 9, |
| 93 | LLVMX86StdcallCallConv = 64, |
| 94 | LLVMX86FastcallCallConv = 65 |
| 95 | } LLVMCallConv; |
| 96 | |
| 97 | typedef enum { |
| 98 | LLVMIntEQ = 32, /* equal */ |
| 99 | LLVMIntNE, /* not equal */ |
| 100 | LLVMIntUGT, /* unsigned greater than */ |
| 101 | LLVMIntUGE, /* unsigned greater or equal */ |
| 102 | LLVMIntULT, /* unsigned less than */ |
| 103 | LLVMIntULE, /* unsigned less or equal */ |
| 104 | LLVMIntSGT, /* signed greater than */ |
| 105 | LLVMIntSGE, /* signed greater or equal */ |
| 106 | LLVMIntSLT, /* signed less than */ |
| 107 | LLVMIntSLE /* signed less or equal */ |
| 108 | } LLVMIntPredicate; |
| 109 | |
| 110 | typedef enum { |
| 111 | LLVMRealPredicateFalse, /* Always false (always folded) */ |
| 112 | LLVMRealOEQ, /* True if ordered and equal */ |
| 113 | LLVMRealOGT, /* True if ordered and greater than */ |
| 114 | LLVMRealOGE, /* True if ordered and greater than or equal */ |
| 115 | LLVMRealOLT, /* True if ordered and less than */ |
| 116 | LLVMRealOLE, /* True if ordered and less than or equal */ |
| 117 | LLVMRealONE, /* True if ordered and operands are unequal */ |
| 118 | LLVMRealORD, /* True if ordered (no nans) */ |
| 119 | LLVMRealUNO, /* True if unordered: isnan(X) | isnan(Y) */ |
| 120 | LLVMRealUEQ, /* True if unordered or equal */ |
| 121 | LLVMRealUGT, /* True if unordered or greater than */ |
| 122 | LLVMRealUGE, /* True if unordered, greater than, or equal */ |
| 123 | LLVMRealULT, /* True if unordered or less than */ |
| 124 | LLVMRealULE, /* True if unordered, less than, or equal */ |
| 125 | LLVMRealUNE, /* True if unordered or not equal */ |
| 126 | LLVMRealPredicateTrue /* Always true (always folded) */ |
| 127 | } LLVMRealPredicate; |
| 128 | |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 129 | |
| 130 | /*===-- Modules -----------------------------------------------------------===*/ |
| 131 | |
| 132 | /* Create and destroy modules. */ |
| 133 | LLVMModuleRef LLVMModuleCreateWithName(const char *ModuleID); |
| 134 | void LLVMDisposeModule(LLVMModuleRef M); |
| 135 | |
| 136 | /* Same as Module::addTypeName. */ |
| 137 | int LLVMAddTypeName(LLVMModuleRef M, const char *Name, LLVMTypeRef Ty); |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 138 | void LLVMDeleteTypeName(LLVMModuleRef M, const char *Name); |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 139 | |
| 140 | |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 141 | /*===-- Types -------------------------------------------------------------===*/ |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 142 | |
| 143 | /* LLVM types conform to the following hierarchy: |
| 144 | * |
| 145 | * types: |
| 146 | * integer type |
| 147 | * real type |
| 148 | * function type |
| 149 | * sequence types: |
| 150 | * array type |
| 151 | * pointer type |
| 152 | * vector type |
| 153 | * void type |
| 154 | * label type |
| 155 | * opaque type |
| 156 | */ |
| 157 | |
| 158 | LLVMTypeKind LLVMGetTypeKind(LLVMTypeRef Ty); |
| 159 | void LLVMRefineAbstractType(LLVMTypeRef AbstractType, LLVMTypeRef ConcreteType); |
| 160 | |
| 161 | /* Operations on integer types */ |
| 162 | LLVMTypeRef LLVMInt1Type(); |
| 163 | LLVMTypeRef LLVMInt8Type(); |
| 164 | LLVMTypeRef LLVMInt16Type(); |
| 165 | LLVMTypeRef LLVMInt32Type(); |
| 166 | LLVMTypeRef LLVMInt64Type(); |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 167 | LLVMTypeRef LLVMCreateIntType(unsigned NumBits); |
| 168 | unsigned LLVMGetIntTypeWidth(LLVMTypeRef IntegerTy); |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 169 | |
| 170 | /* Operations on real types */ |
| 171 | LLVMTypeRef LLVMFloatType(); |
| 172 | LLVMTypeRef LLVMDoubleType(); |
| 173 | LLVMTypeRef LLVMX86FP80Type(); |
| 174 | LLVMTypeRef LLVMFP128Type(); |
| 175 | LLVMTypeRef LLVMPPCFP128Type(); |
| 176 | |
| 177 | /* Operations on function types */ |
| 178 | LLVMTypeRef LLVMCreateFunctionType(LLVMTypeRef ReturnType, |
| 179 | LLVMTypeRef *ParamTypes, unsigned ParamCount, |
| 180 | int IsVarArg); |
| 181 | int LLVMIsFunctionVarArg(LLVMTypeRef FunctionTy); |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 182 | LLVMTypeRef LLVMGetReturnType(LLVMTypeRef FunctionTy); |
| 183 | unsigned LLVMCountParamTypes(LLVMTypeRef FunctionTy); |
| 184 | void LLVMGetParamTypes(LLVMTypeRef FunctionTy, LLVMTypeRef *Dest); |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 185 | |
| 186 | /* Operations on struct types */ |
| 187 | LLVMTypeRef LLVMCreateStructType(LLVMTypeRef *ElementTypes, |
| 188 | unsigned ElementCount, int Packed); |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 189 | unsigned LLVMCountStructElementTypes(LLVMTypeRef StructTy); |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 190 | void LLVMGetStructElementTypes(LLVMTypeRef StructTy, LLVMTypeRef *Dest); |
| 191 | int LLVMIsPackedStruct(LLVMTypeRef StructTy); |
| 192 | |
| 193 | /* Operations on array, pointer, and vector types (sequence types) */ |
| 194 | LLVMTypeRef LLVMCreateArrayType(LLVMTypeRef ElementType, unsigned ElementCount); |
| 195 | LLVMTypeRef LLVMCreatePointerType(LLVMTypeRef ElementType); |
| 196 | LLVMTypeRef LLVMCreateVectorType(LLVMTypeRef ElementType,unsigned ElementCount); |
| 197 | |
| 198 | LLVMTypeRef LLVMGetElementType(LLVMTypeRef Ty); |
| 199 | unsigned LLVMGetArrayLength(LLVMTypeRef ArrayTy); |
| 200 | unsigned LLVMGetVectorSize(LLVMTypeRef VectorTy); |
| 201 | |
| 202 | /* Operations on other types */ |
| 203 | LLVMTypeRef LLVMVoidType(); |
| 204 | LLVMTypeRef LLVMLabelType(); |
| 205 | LLVMTypeRef LLVMCreateOpaqueType(); |
| 206 | |
| 207 | |
| 208 | /*===-- Values ------------------------------------------------------------===*/ |
| 209 | |
| 210 | /* The bulk of LLVM's object model consists of values, which comprise a very |
| 211 | * rich type hierarchy. |
| 212 | * |
| 213 | * values: |
| 214 | * constants: |
| 215 | * scalar constants |
| 216 | * composite contants |
| 217 | * globals: |
| 218 | * global variable |
| 219 | * function |
| 220 | * alias |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 221 | * basic blocks |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 222 | */ |
| 223 | |
| 224 | /* Operations on all values */ |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 225 | LLVMTypeRef LLVMTypeOf(LLVMValueRef Val); |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 226 | const char *LLVMGetValueName(LLVMValueRef Val); |
| 227 | void LLVMSetValueName(LLVMValueRef Val, const char *Name); |
Gordon Henriksen | 1d0d24c | 2007-10-06 00:08:49 +0000 | [diff] [blame^] | 228 | void LLVMDumpValue(LLVMValueRef Val); |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 229 | |
| 230 | /* Operations on constants of any type */ |
| 231 | LLVMValueRef LLVMGetNull(LLVMTypeRef Ty); /* all zeroes */ |
| 232 | LLVMValueRef LLVMGetAllOnes(LLVMTypeRef Ty); /* only for int/vector */ |
| 233 | LLVMValueRef LLVMGetUndef(LLVMTypeRef Ty); |
Gordon Henriksen | dc88c06 | 2007-09-18 18:07:51 +0000 | [diff] [blame] | 234 | int LLVMIsConstant(LLVMValueRef Val); |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 235 | int LLVMIsNull(LLVMValueRef Val); |
Gordon Henriksen | dc88c06 | 2007-09-18 18:07:51 +0000 | [diff] [blame] | 236 | int LLVMIsUndef(LLVMValueRef Val); |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 237 | |
| 238 | /* Operations on scalar constants */ |
| 239 | LLVMValueRef LLVMGetIntConstant(LLVMTypeRef IntTy, unsigned long long N, |
| 240 | int SignExtend); |
| 241 | LLVMValueRef LLVMGetRealConstant(LLVMTypeRef RealTy, double N); |
| 242 | |
| 243 | /* Operations on composite constants */ |
| 244 | LLVMValueRef LLVMGetStringConstant(const char *Str, unsigned Length, |
| 245 | int DontNullTerminate); |
| 246 | LLVMValueRef LLVMGetArrayConstant(LLVMTypeRef ArrayTy, |
| 247 | LLVMValueRef *ConstantVals, unsigned Length); |
| 248 | LLVMValueRef LLVMGetStructConstant(LLVMValueRef *ConstantVals, unsigned Count, |
| 249 | int packed); |
| 250 | LLVMValueRef LLVMGetVectorConstant(LLVMValueRef *ScalarConstantVals, |
| 251 | unsigned Size); |
| 252 | |
| 253 | /* Operations on global variables, functions, and aliases (globals) */ |
| 254 | int LLVMIsDeclaration(LLVMValueRef Global); |
| 255 | LLVMLinkage LLVMGetLinkage(LLVMValueRef Global); |
| 256 | void LLVMSetLinkage(LLVMValueRef Global, LLVMLinkage Linkage); |
| 257 | const char *LLVMGetSection(LLVMValueRef Global); |
| 258 | void LLVMSetSection(LLVMValueRef Global, const char *Section); |
| 259 | LLVMVisibility LLVMGetVisibility(LLVMValueRef Global); |
| 260 | void LLVMSetVisibility(LLVMValueRef Global, LLVMVisibility Viz); |
| 261 | unsigned LLVMGetAlignment(LLVMValueRef Global); |
| 262 | void LLVMSetAlignment(LLVMValueRef Global, unsigned Bytes); |
| 263 | |
| 264 | /* Operations on global variables */ |
| 265 | LLVMValueRef LLVMAddGlobal(LLVMModuleRef M, LLVMTypeRef Ty, const char *Name); |
| 266 | void LLVMDeleteGlobal(LLVMValueRef GlobalVar); |
| 267 | int LLVMHasInitializer(LLVMValueRef GlobalVar); |
| 268 | LLVMValueRef LLVMGetInitializer(LLVMValueRef GlobalVar); |
| 269 | void LLVMSetInitializer(LLVMValueRef GlobalVar, LLVMValueRef ConstantVal); |
| 270 | int LLVMIsThreadLocal(LLVMValueRef GlobalVar); |
| 271 | void LLVMSetThreadLocal(LLVMValueRef GlobalVar, int IsThreadLocal); |
| 272 | |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 273 | /* Operations on functions */ |
| 274 | LLVMValueRef LLVMAddFunction(LLVMModuleRef M, const char *Name, |
| 275 | LLVMTypeRef FunctionTy); |
| 276 | void LLVMDeleteFunction(LLVMValueRef Fn); |
| 277 | unsigned LLVMCountParams(LLVMValueRef Fn); |
| 278 | void LLVMGetParams(LLVMValueRef Fn, LLVMValueRef *Params); |
| 279 | LLVMValueRef LLVMGetParam(LLVMValueRef Fn, unsigned Index); |
| 280 | unsigned LLVMGetIntrinsicID(LLVMValueRef Fn); |
| 281 | unsigned LLVMGetFunctionCallConv(LLVMValueRef Fn); |
| 282 | void LLVMSetFunctionCallConv(LLVMValueRef Fn, unsigned CC); |
| 283 | |
| 284 | /* Operations on basic blocks */ |
| 285 | LLVMValueRef LLVMBasicBlockAsValue(LLVMBasicBlockRef Bb); |
| 286 | int LLVMValueIsBasicBlock(LLVMValueRef Val); |
| 287 | LLVMBasicBlockRef LLVMValueAsBasicBlock(LLVMValueRef Val); |
| 288 | unsigned LLVMCountBasicBlocks(LLVMValueRef Fn); |
| 289 | void LLVMGetBasicBlocks(LLVMValueRef Fn, LLVMBasicBlockRef *BasicBlocks); |
| 290 | LLVMBasicBlockRef LLVMGetEntryBasicBlock(LLVMValueRef Fn); |
| 291 | LLVMBasicBlockRef LLVMAppendBasicBlock(LLVMValueRef Fn, const char *Name); |
| 292 | LLVMBasicBlockRef LLVMInsertBasicBlock(LLVMBasicBlockRef InsertBeforeBB, |
| 293 | const char *Name); |
| 294 | void LLVMDeleteBasicBlock(LLVMBasicBlockRef BB); |
| 295 | |
| 296 | |
| 297 | /*===-- Instruction builders ----------------------------------------------===*/ |
| 298 | |
| 299 | /* An instruction builder represents a point within a basic block, and is the |
| 300 | * exclusive means of building instructions using the C interface. |
| 301 | */ |
| 302 | |
| 303 | LLVMBuilderRef LLVMCreateBuilder(); |
| 304 | void LLVMPositionBuilderBefore(LLVMBuilderRef Builder, LLVMValueRef Instr); |
| 305 | void LLVMPositionBuilderAtEnd(LLVMBuilderRef Builder, LLVMBasicBlockRef Block); |
| 306 | void LLVMDisposeBuilder(LLVMBuilderRef Builder); |
| 307 | |
| 308 | /* Terminators */ |
| 309 | LLVMValueRef LLVMBuildRetVoid(LLVMBuilderRef); |
| 310 | LLVMValueRef LLVMBuildRet(LLVMBuilderRef, LLVMValueRef V); |
| 311 | LLVMValueRef LLVMBuildBr(LLVMBuilderRef, LLVMBasicBlockRef Dest); |
| 312 | LLVMValueRef LLVMBuildCondBr(LLVMBuilderRef, LLVMValueRef If, |
| 313 | LLVMBasicBlockRef Then, LLVMBasicBlockRef Else); |
| 314 | LLVMValueRef LLVMBuildSwitch(LLVMBuilderRef, LLVMValueRef V, |
| 315 | LLVMBasicBlockRef Else, unsigned NumCases); |
| 316 | LLVMValueRef LLVMBuildInvoke(LLVMBuilderRef, LLVMValueRef Fn, |
| 317 | LLVMValueRef *Args, unsigned NumArgs, |
| 318 | LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch, |
| 319 | const char *Name); |
| 320 | LLVMValueRef LLVMBuildUnwind(LLVMBuilderRef); |
| 321 | LLVMValueRef LLVMBuildUnreachable(LLVMBuilderRef); |
| 322 | |
| 323 | /* Arithmetic */ |
| 324 | LLVMValueRef LLVMBuildAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, |
| 325 | const char *Name); |
| 326 | LLVMValueRef LLVMBuildSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, |
| 327 | const char *Name); |
| 328 | LLVMValueRef LLVMBuildMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, |
| 329 | const char *Name); |
| 330 | LLVMValueRef LLVMBuildUDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, |
| 331 | const char *Name); |
| 332 | LLVMValueRef LLVMBuildSDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, |
| 333 | const char *Name); |
| 334 | LLVMValueRef LLVMBuildFDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, |
| 335 | const char *Name); |
| 336 | LLVMValueRef LLVMBuildURem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, |
| 337 | const char *Name); |
| 338 | LLVMValueRef LLVMBuildSRem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, |
| 339 | const char *Name); |
| 340 | LLVMValueRef LLVMBuildFRem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, |
| 341 | const char *Name); |
| 342 | LLVMValueRef LLVMBuildShl(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, |
| 343 | const char *Name); |
| 344 | LLVMValueRef LLVMBuildLShr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, |
| 345 | const char *Name); |
| 346 | LLVMValueRef LLVMBuildAShr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, |
| 347 | const char *Name); |
| 348 | LLVMValueRef LLVMBuildAnd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, |
| 349 | const char *Name); |
| 350 | LLVMValueRef LLVMBuildOr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, |
| 351 | const char *Name); |
| 352 | LLVMValueRef LLVMBuildXor(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, |
| 353 | const char *Name); |
| 354 | LLVMValueRef LLVMBuildNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name); |
| 355 | LLVMValueRef LLVMBuildNot(LLVMBuilderRef, LLVMValueRef V, const char *Name); |
| 356 | |
| 357 | /* Memory */ |
| 358 | LLVMValueRef LLVMBuildMalloc(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name); |
| 359 | LLVMValueRef LLVMBuildArrayMalloc(LLVMBuilderRef, LLVMTypeRef Ty, |
| 360 | LLVMValueRef Val, const char *Name); |
| 361 | LLVMValueRef LLVMBuildAlloca(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name); |
| 362 | LLVMValueRef LLVMBuildArrayAlloca(LLVMBuilderRef, LLVMTypeRef Ty, |
| 363 | LLVMValueRef Val, const char *Name); |
| 364 | LLVMValueRef LLVMBuildFree(LLVMBuilderRef, LLVMValueRef PointerVal); |
| 365 | LLVMValueRef LLVMBuildLoad(LLVMBuilderRef, LLVMValueRef PointerVal, |
| 366 | const char *Name); |
| 367 | LLVMValueRef LLVMBuildStore(LLVMBuilderRef, LLVMValueRef Val, LLVMValueRef Ptr); |
| 368 | LLVMValueRef LLVMBuildGEP(LLVMBuilderRef B, LLVMValueRef Pointer, |
| 369 | LLVMValueRef *Indices, unsigned NumIndices, |
| 370 | const char *Name); |
| 371 | |
| 372 | /* Casts */ |
| 373 | LLVMValueRef LLVMBuildTrunc(LLVMBuilderRef, LLVMValueRef Val, |
| 374 | LLVMTypeRef DestTy, const char *Name); |
| 375 | LLVMValueRef LLVMBuildZExt(LLVMBuilderRef, LLVMValueRef Val, |
| 376 | LLVMTypeRef DestTy, const char *Name); |
| 377 | LLVMValueRef LLVMBuildSExt(LLVMBuilderRef, LLVMValueRef Val, |
| 378 | LLVMTypeRef DestTy, const char *Name); |
| 379 | LLVMValueRef LLVMBuildFPToUI(LLVMBuilderRef, LLVMValueRef Val, |
| 380 | LLVMTypeRef DestTy, const char *Name); |
| 381 | LLVMValueRef LLVMBuildFPToSI(LLVMBuilderRef, LLVMValueRef Val, |
| 382 | LLVMTypeRef DestTy, const char *Name); |
| 383 | LLVMValueRef LLVMBuildUIToFP(LLVMBuilderRef, LLVMValueRef Val, |
| 384 | LLVMTypeRef DestTy, const char *Name); |
| 385 | LLVMValueRef LLVMBuildSIToFP(LLVMBuilderRef, LLVMValueRef Val, |
| 386 | LLVMTypeRef DestTy, const char *Name); |
| 387 | LLVMValueRef LLVMBuildFPTrunc(LLVMBuilderRef, LLVMValueRef Val, |
| 388 | LLVMTypeRef DestTy, const char *Name); |
| 389 | LLVMValueRef LLVMBuildFPExt(LLVMBuilderRef, LLVMValueRef Val, |
| 390 | LLVMTypeRef DestTy, const char *Name); |
| 391 | LLVMValueRef LLVMBuildPtrToInt(LLVMBuilderRef, LLVMValueRef Val, |
| 392 | LLVMTypeRef DestTy, const char *Name); |
| 393 | LLVMValueRef LLVMBuildIntToPtr(LLVMBuilderRef, LLVMValueRef Val, |
| 394 | LLVMTypeRef DestTy, const char *Name); |
| 395 | LLVMValueRef LLVMBuildBitCast(LLVMBuilderRef, LLVMValueRef Val, |
| 396 | LLVMTypeRef DestTy, const char *Name); |
| 397 | |
| 398 | /* Comparisons */ |
| 399 | LLVMValueRef LLVMBuildICmp(LLVMBuilderRef, LLVMIntPredicate Op, |
| 400 | LLVMValueRef LHS, LLVMValueRef RHS, |
| 401 | const char *Name); |
| 402 | LLVMValueRef LLVMBuildFCmp(LLVMBuilderRef, LLVMRealPredicate Op, |
| 403 | LLVMValueRef LHS, LLVMValueRef RHS, |
| 404 | const char *Name); |
| 405 | |
| 406 | /* Miscellaneous instructions */ |
| 407 | LLVMValueRef LLVMBuildPhi(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name); |
| 408 | LLVMValueRef LLVMBuildCall(LLVMBuilderRef, LLVMValueRef Fn, |
| 409 | LLVMValueRef *Args, unsigned NumArgs, |
| 410 | const char *Name); |
| 411 | LLVMValueRef LLVMBuildSelect(LLVMBuilderRef, LLVMValueRef If, |
| 412 | LLVMValueRef Then, LLVMValueRef Else, |
| 413 | const char *Name); |
| 414 | LLVMValueRef LLVMBuildVAArg(LLVMBuilderRef, LLVMValueRef List, LLVMTypeRef Ty, |
| 415 | const char *Name); |
| 416 | LLVMValueRef LLVMBuildExtractElement(LLVMBuilderRef, LLVMValueRef VecVal, |
| 417 | LLVMValueRef Index, const char *Name); |
| 418 | LLVMValueRef LLVMBuildInsertElement(LLVMBuilderRef, LLVMValueRef VecVal, |
| 419 | LLVMValueRef EltVal, LLVMValueRef Index, |
| 420 | const char *Name); |
| 421 | LLVMValueRef LLVMBuildShuffleVector(LLVMBuilderRef, LLVMValueRef V1, |
| 422 | LLVMValueRef V2, LLVMValueRef Mask, |
| 423 | const char *Name); |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 424 | |
| 425 | #ifdef __cplusplus |
| 426 | } |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 427 | |
Gordon Henriksen | 7330acd | 2007-10-05 23:59:36 +0000 | [diff] [blame] | 428 | namespace llvm { |
| 429 | /* Opaque module conversions |
| 430 | */ |
| 431 | inline Module *unwrap(LLVMModuleRef M) { |
| 432 | return reinterpret_cast<Module*>(M); |
| 433 | } |
| 434 | |
| 435 | inline LLVMModuleRef wrap(Module *M) { |
| 436 | return reinterpret_cast<LLVMModuleRef>(M); |
| 437 | } |
| 438 | |
| 439 | /* Opaque type conversions |
| 440 | */ |
| 441 | inline Type *unwrap(LLVMTypeRef Ty) { |
| 442 | return reinterpret_cast<Type*>(Ty); |
| 443 | } |
| 444 | |
| 445 | template<typename T> |
| 446 | inline T *unwrap(LLVMTypeRef Ty) { |
| 447 | return cast<T>(unwrap(Ty)); |
| 448 | } |
| 449 | |
| 450 | inline Type **unwrap(LLVMTypeRef* Tys) { |
| 451 | return reinterpret_cast<Type**>(Tys); |
| 452 | } |
| 453 | |
| 454 | inline LLVMTypeRef wrap(const Type *Ty) { |
| 455 | return reinterpret_cast<LLVMTypeRef>(const_cast<Type*>(Ty)); |
| 456 | } |
| 457 | |
| 458 | inline LLVMTypeRef *wrap(const Type **Tys) { |
| 459 | return reinterpret_cast<LLVMTypeRef*>(const_cast<Type**>(Tys)); |
| 460 | } |
| 461 | |
| 462 | /* Opaque value conversions |
| 463 | */ |
| 464 | inline Value *unwrap(LLVMValueRef Val) { |
| 465 | return reinterpret_cast<Value*>(Val); |
| 466 | } |
| 467 | |
| 468 | template<typename T> |
| 469 | inline T *unwrap(LLVMValueRef Val) { |
| 470 | return cast<T>(unwrap(Val)); |
| 471 | } |
| 472 | |
| 473 | inline Value **unwrap(LLVMValueRef *Vals) { |
| 474 | return reinterpret_cast<Value**>(Vals); |
| 475 | } |
| 476 | |
| 477 | template<typename T> |
| 478 | inline T **unwrap(LLVMValueRef *Vals, unsigned Length) { |
| 479 | #if DEBUG |
| 480 | for (LLVMValueRef *I = Vals, E = Vals + Length; I != E; ++I) |
| 481 | cast<T>(*I); |
| 482 | #endif |
| 483 | return reinterpret_cast<T**>(Vals); |
| 484 | } |
| 485 | |
| 486 | inline LLVMValueRef wrap(const Value *Val) { |
| 487 | return reinterpret_cast<LLVMValueRef>(const_cast<Value*>(Val)); |
| 488 | } |
| 489 | |
| 490 | inline LLVMValueRef *wrap(const Value **Vals) { |
| 491 | return reinterpret_cast<LLVMValueRef*>(const_cast<Value**>(Vals)); |
| 492 | } |
| 493 | |
| 494 | /* Basic block conversions |
| 495 | */ |
| 496 | inline BasicBlock *unwrap(LLVMBasicBlockRef BBRef) { |
| 497 | return reinterpret_cast<BasicBlock*>(BBRef); |
| 498 | } |
| 499 | |
| 500 | inline LLVMBasicBlockRef wrap(const BasicBlock *BB) { |
| 501 | return reinterpret_cast<LLVMBasicBlockRef>(const_cast<BasicBlock*>(BB)); |
| 502 | } |
| 503 | |
| 504 | /* Opaque builder conversions. |
| 505 | */ |
| 506 | inline LLVMBuilder *unwrap(LLVMBuilderRef B) { |
| 507 | return reinterpret_cast<LLVMBuilder*>(B); |
| 508 | } |
| 509 | |
| 510 | inline LLVMBuilderRef wrap(LLVMBuilder *B) { |
| 511 | return reinterpret_cast<LLVMBuilderRef>(B); |
| 512 | } |
| 513 | } |
| 514 | |
| 515 | #endif /* !defined(__cplusplus) */ |
| 516 | |
| 517 | #endif /* !defined(LLVM_C_CORE_H) */ |