LLVM API Documentation
00001 /*===-- llvm-c/Core.h - Core Library C Interface ------------------*- C -*-===*\ 00002 |* *| 00003 |* The LLVM Compiler Infrastructure *| 00004 |* *| 00005 |* This file is distributed under the University of Illinois Open Source *| 00006 |* License. See LICENSE.TXT for details. *| 00007 |* *| 00008 |*===----------------------------------------------------------------------===*| 00009 |* *| 00010 |* This header declares the C interface to libLLVMCore.a, which implements *| 00011 |* the LLVM intermediate representation. *| 00012 |* *| 00013 |* LLVM uses a polymorphic type hierarchy which C cannot represent, therefore *| 00014 |* parameters must be passed as base types. Despite the declared types, most *| 00015 |* of the functions provided operate only on branches of the type hierarchy. *| 00016 |* The declared parameter names are descriptive and specify which type is *| 00017 |* required. Additionally, each type hierarchy is documented along with the *| 00018 |* functions that operate upon it. For more detail, refer to LLVM's C++ code. *| 00019 |* If in doubt, refer to Core.cpp, which performs paramter downcasts in the *| 00020 |* form unwrap<RequiredType>(Param). *| 00021 |* *| 00022 |* Many exotic languages can interoperate with C code but have a harder time *| 00023 |* with C++ due to name mangling. So in addition to C, this interface enables *| 00024 |* tools written in such languages. *| 00025 |* *| 00026 |* When included into a C++ source file, also declares 'wrap' and 'unwrap' *| 00027 |* helpers to perform opaque reference<-->pointer conversions. These helpers *| 00028 |* are shorter and more tightly typed than writing the casts by hand when *| 00029 |* authoring bindings. In assert builds, they will do runtime type checking. *| 00030 |* *| 00031 \*===----------------------------------------------------------------------===*/ 00032 00033 #ifndef LLVM_C_CORE_H 00034 #define LLVM_C_CORE_H 00035 00036 #ifdef __cplusplus 00037 00038 /* Need these includes to support the LLVM 'cast' template for the C++ 'wrap' 00039 and 'unwrap' conversion functions. */ 00040 #include "llvm/Module.h" 00041 #include "llvm/Support/IRBuilder.h" 00042 00043 extern "C" { 00044 #endif 00045 00046 00047 /* Opaque types. */ 00048 00049 /** 00050 * The top-level container for all other LLVM Intermediate Representation (IR) 00051 * objects. See the llvm::Module class. 00052 */ 00053 typedef struct LLVMOpaqueModule *LLVMModuleRef; 00054 00055 /** 00056 * Each value in the LLVM IR has a type, an LLVMTypeRef. See the llvm::Type 00057 * class. 00058 */ 00059 typedef struct LLVMOpaqueType *LLVMTypeRef; 00060 00061 /** 00062 * When building recursive types using LLVMRefineType, LLVMTypeRef values may 00063 * become invalid; use LLVMTypeHandleRef to resolve this problem. See the 00064 * llvm::AbstractTypeHolder class. 00065 */ 00066 typedef struct LLVMOpaqueTypeHandle *LLVMTypeHandleRef; 00067 00068 typedef struct LLVMOpaqueValue *LLVMValueRef; 00069 typedef struct LLVMOpaqueBasicBlock *LLVMBasicBlockRef; 00070 typedef struct LLVMOpaqueBuilder *LLVMBuilderRef; 00071 00072 /* Used to provide a module to JIT or interpreter. 00073 * See the llvm::ModuleProvider class. 00074 */ 00075 typedef struct LLVMOpaqueModuleProvider *LLVMModuleProviderRef; 00076 00077 /* Used to provide a module to JIT or interpreter. 00078 * See the llvm::MemoryBuffer class. 00079 */ 00080 typedef struct LLVMOpaqueMemoryBuffer *LLVMMemoryBufferRef; 00081 00082 /** See the llvm::PassManagerBase class. */ 00083 typedef struct LLVMOpaquePassManager *LLVMPassManagerRef; 00084 00085 typedef enum { 00086 LLVMZExtAttribute = 1<<0, 00087 LLVMSExtAttribute = 1<<1, 00088 LLVMNoReturnAttribute = 1<<2, 00089 LLVMInRegAttribute = 1<<3, 00090 LLVMStructRetAttribute = 1<<4, 00091 LLVMNoUnwindAttribute = 1<<5, 00092 LLVMNoAliasAttribute = 1<<6, 00093 LLVMByValAttribute = 1<<7, 00094 LLVMNestAttribute = 1<<8, 00095 LLVMReadNoneAttribute = 1<<9, 00096 LLVMReadOnlyAttribute = 1<<10 00097 } LLVMAttribute; 00098 00099 typedef enum { 00100 LLVMVoidTypeKind, /**< type with no size */ 00101 LLVMFloatTypeKind, /**< 32 bit floating point type */ 00102 LLVMDoubleTypeKind, /**< 64 bit floating point type */ 00103 LLVMX86_FP80TypeKind, /**< 80 bit floating point type (X87) */ 00104 LLVMFP128TypeKind, /**< 128 bit floating point type (112-bit mantissa)*/ 00105 LLVMPPC_FP128TypeKind, /**< 128 bit floating point type (two 64-bits) */ 00106 LLVMLabelTypeKind, /**< Labels */ 00107 LLVMIntegerTypeKind, /**< Arbitrary bit width integers */ 00108 LLVMFunctionTypeKind, /**< Functions */ 00109 LLVMStructTypeKind, /**< Structures */ 00110 LLVMArrayTypeKind, /**< Arrays */ 00111 LLVMPointerTypeKind, /**< Pointers */ 00112 LLVMOpaqueTypeKind, /**< Opaque: type with unknown structure */ 00113 LLVMVectorTypeKind /**< SIMD 'packed' format, or other vector type */ 00114 } LLVMTypeKind; 00115 00116 typedef enum { 00117 LLVMExternalLinkage, /**< Externally visible function */ 00118 LLVMLinkOnceLinkage, /**< Keep one copy of function when linking (inline)*/ 00119 LLVMWeakLinkage, /**< Keep one copy of function when linking (weak) */ 00120 LLVMAppendingLinkage, /**< Special purpose, only applies to global arrays */ 00121 LLVMInternalLinkage, /**< Rename collisions when linking (static 00122 functions) */ 00123 LLVMDLLImportLinkage, /**< Function to be imported from DLL */ 00124 LLVMDLLExportLinkage, /**< Function to be accessible from DLL */ 00125 LLVMExternalWeakLinkage,/**< ExternalWeak linkage description */ 00126 LLVMGhostLinkage /**< Stand-in functions for streaming fns from 00127 bitcode */ 00128 } LLVMLinkage; 00129 00130 typedef enum { 00131 LLVMDefaultVisibility, /**< The GV is visible */ 00132 LLVMHiddenVisibility, /**< The GV is hidden */ 00133 LLVMProtectedVisibility /**< The GV is protected */ 00134 } LLVMVisibility; 00135 00136 typedef enum { 00137 LLVMCCallConv = 0, 00138 LLVMFastCallConv = 8, 00139 LLVMColdCallConv = 9, 00140 LLVMX86StdcallCallConv = 64, 00141 LLVMX86FastcallCallConv = 65 00142 } LLVMCallConv; 00143 00144 typedef enum { 00145 LLVMIntEQ = 32, /**< equal */ 00146 LLVMIntNE, /**< not equal */ 00147 LLVMIntUGT, /**< unsigned greater than */ 00148 LLVMIntUGE, /**< unsigned greater or equal */ 00149 LLVMIntULT, /**< unsigned less than */ 00150 LLVMIntULE, /**< unsigned less or equal */ 00151 LLVMIntSGT, /**< signed greater than */ 00152 LLVMIntSGE, /**< signed greater or equal */ 00153 LLVMIntSLT, /**< signed less than */ 00154 LLVMIntSLE /**< signed less or equal */ 00155 } LLVMIntPredicate; 00156 00157 typedef enum { 00158 LLVMRealPredicateFalse, /**< Always false (always folded) */ 00159 LLVMRealOEQ, /**< True if ordered and equal */ 00160 LLVMRealOGT, /**< True if ordered and greater than */ 00161 LLVMRealOGE, /**< True if ordered and greater than or equal */ 00162 LLVMRealOLT, /**< True if ordered and less than */ 00163 LLVMRealOLE, /**< True if ordered and less than or equal */ 00164 LLVMRealONE, /**< True if ordered and operands are unequal */ 00165 LLVMRealORD, /**< True if ordered (no nans) */ 00166 LLVMRealUNO, /**< True if unordered: isnan(X) | isnan(Y) */ 00167 LLVMRealUEQ, /**< True if unordered or equal */ 00168 LLVMRealUGT, /**< True if unordered or greater than */ 00169 LLVMRealUGE, /**< True if unordered, greater than, or equal */ 00170 LLVMRealULT, /**< True if unordered or less than */ 00171 LLVMRealULE, /**< True if unordered, less than, or equal */ 00172 LLVMRealUNE, /**< True if unordered or not equal */ 00173 LLVMRealPredicateTrue /**< Always true (always folded) */ 00174 } LLVMRealPredicate; 00175 00176 00177 /*===-- Error handling ----------------------------------------------------===*/ 00178 00179 void LLVMDisposeMessage(char *Message); 00180 00181 00182 /*===-- Modules -----------------------------------------------------------===*/ 00183 00184 /* Create and destroy modules. */ 00185 /** See llvm::Module::Module. */ 00186 LLVMModuleRef LLVMModuleCreateWithName(const char *ModuleID); 00187 00188 /** See llvm::Module::~Module. */ 00189 void LLVMDisposeModule(LLVMModuleRef M); 00190 00191 /** Data layout. See Module::getDataLayout. */ 00192 const char *LLVMGetDataLayout(LLVMModuleRef M); 00193 void LLVMSetDataLayout(LLVMModuleRef M, const char *Triple); 00194 00195 /** Target triple. See Module::getTargetTriple. */ 00196 const char *LLVMGetTarget(LLVMModuleRef M); 00197 void LLVMSetTarget(LLVMModuleRef M, const char *Triple); 00198 00199 /** See Module::addTypeName. */ 00200 int LLVMAddTypeName(LLVMModuleRef M, const char *Name, LLVMTypeRef Ty); 00201 void LLVMDeleteTypeName(LLVMModuleRef M, const char *Name); 00202 00203 /** See Module::dump. */ 00204 void LLVMDumpModule(LLVMModuleRef M); 00205 00206 00207 /*===-- Types -------------------------------------------------------------===*/ 00208 00209 /* LLVM types conform to the following hierarchy: 00210 * 00211 * types: 00212 * integer type 00213 * real type 00214 * function type 00215 * sequence types: 00216 * array type 00217 * pointer type 00218 * vector type 00219 * void type 00220 * label type 00221 * opaque type 00222 */ 00223 00224 /** See llvm::LLVMTypeKind::getTypeID. */ 00225 LLVMTypeKind LLVMGetTypeKind(LLVMTypeRef Ty); 00226 00227 /* Operations on integer types */ 00228 LLVMTypeRef LLVMInt1Type(void); 00229 LLVMTypeRef LLVMInt8Type(void); 00230 LLVMTypeRef LLVMInt16Type(void); 00231 LLVMTypeRef LLVMInt32Type(void); 00232 LLVMTypeRef LLVMInt64Type(void); 00233 LLVMTypeRef LLVMIntType(unsigned NumBits); 00234 unsigned LLVMGetIntTypeWidth(LLVMTypeRef IntegerTy); 00235 00236 /* Operations on real types */ 00237 LLVMTypeRef LLVMFloatType(void); 00238 LLVMTypeRef LLVMDoubleType(void); 00239 LLVMTypeRef LLVMX86FP80Type(void); 00240 LLVMTypeRef LLVMFP128Type(void); 00241 LLVMTypeRef LLVMPPCFP128Type(void); 00242 00243 /* Operations on function types */ 00244 LLVMTypeRef LLVMFunctionType(LLVMTypeRef ReturnType, 00245 LLVMTypeRef *ParamTypes, unsigned ParamCount, 00246 int IsVarArg); 00247 int LLVMIsFunctionVarArg(LLVMTypeRef FunctionTy); 00248 LLVMTypeRef LLVMGetReturnType(LLVMTypeRef FunctionTy); 00249 unsigned LLVMCountParamTypes(LLVMTypeRef FunctionTy); 00250 void LLVMGetParamTypes(LLVMTypeRef FunctionTy, LLVMTypeRef *Dest); 00251 00252 /* Operations on struct types */ 00253 LLVMTypeRef LLVMStructType(LLVMTypeRef *ElementTypes, unsigned ElementCount, 00254 int Packed); 00255 unsigned LLVMCountStructElementTypes(LLVMTypeRef StructTy); 00256 void LLVMGetStructElementTypes(LLVMTypeRef StructTy, LLVMTypeRef *Dest); 00257 int LLVMIsPackedStruct(LLVMTypeRef StructTy); 00258 00259 /* Operations on array, pointer, and vector types (sequence types) */ 00260 LLVMTypeRef LLVMArrayType(LLVMTypeRef ElementType, unsigned ElementCount); 00261 LLVMTypeRef LLVMPointerType(LLVMTypeRef ElementType, unsigned AddressSpace); 00262 LLVMTypeRef LLVMVectorType(LLVMTypeRef ElementType, unsigned ElementCount); 00263 00264 LLVMTypeRef LLVMGetElementType(LLVMTypeRef Ty); 00265 unsigned LLVMGetArrayLength(LLVMTypeRef ArrayTy); 00266 unsigned LLVMGetPointerAddressSpace(LLVMTypeRef PointerTy); 00267 unsigned LLVMGetVectorSize(LLVMTypeRef VectorTy); 00268 00269 /* Operations on other types */ 00270 LLVMTypeRef LLVMVoidType(void); 00271 LLVMTypeRef LLVMLabelType(void); 00272 LLVMTypeRef LLVMOpaqueType(void); 00273 00274 /* Operations on type handles */ 00275 LLVMTypeHandleRef LLVMCreateTypeHandle(LLVMTypeRef PotentiallyAbstractTy); 00276 void LLVMRefineType(LLVMTypeRef AbstractTy, LLVMTypeRef ConcreteTy); 00277 LLVMTypeRef LLVMResolveTypeHandle(LLVMTypeHandleRef TypeHandle); 00278 void LLVMDisposeTypeHandle(LLVMTypeHandleRef TypeHandle); 00279 00280 00281 /*===-- Values ------------------------------------------------------------===*/ 00282 00283 /* The bulk of LLVM's object model consists of values, which comprise a very 00284 * rich type hierarchy. 00285 */ 00286 00287 #define LLVM_FOR_EACH_VALUE_SUBCLASS(macro) \ 00288 macro(Argument) \ 00289 macro(BasicBlock) \ 00290 macro(InlineAsm) \ 00291 macro(User) \ 00292 macro(Constant) \ 00293 macro(ConstantAggregateZero) \ 00294 macro(ConstantArray) \ 00295 macro(ConstantExpr) \ 00296 macro(ConstantFP) \ 00297 macro(ConstantInt) \ 00298 macro(ConstantPointerNull) \ 00299 macro(ConstantStruct) \ 00300 macro(ConstantVector) \ 00301 macro(GlobalValue) \ 00302 macro(Function) \ 00303 macro(GlobalAlias) \ 00304 macro(GlobalVariable) \ 00305 macro(UndefValue) \ 00306 macro(Instruction) \ 00307 macro(BinaryOperator) \ 00308 macro(CallInst) \ 00309 macro(IntrinsicInst) \ 00310 macro(DbgInfoIntrinsic) \ 00311 macro(DbgDeclareInst) \ 00312 macro(DbgFuncStartInst) \ 00313 macro(DbgRegionEndInst) \ 00314 macro(DbgRegionStartInst) \ 00315 macro(DbgStopPointInst) \ 00316 macro(EHSelectorInst) \ 00317 macro(MemIntrinsic) \ 00318 macro(MemCpyInst) \ 00319 macro(MemMoveInst) \ 00320 macro(MemSetInst) \ 00321 macro(CmpInst) \ 00322 macro(FCmpInst) \ 00323 macro(ICmpInst) \ 00324 macro(VFCmpInst) \ 00325 macro(VICmpInst) \ 00326 macro(ExtractElementInst) \ 00327 macro(GetElementPtrInst) \ 00328 macro(InsertElementInst) \ 00329 macro(InsertValueInst) \ 00330 macro(PHINode) \ 00331 macro(SelectInst) \ 00332 macro(ShuffleVectorInst) \ 00333 macro(StoreInst) \ 00334 macro(TerminatorInst) \ 00335 macro(BranchInst) \ 00336 macro(InvokeInst) \ 00337 macro(ReturnInst) \ 00338 macro(SwitchInst) \ 00339 macro(UnreachableInst) \ 00340 macro(UnwindInst) \ 00341 macro(UnaryInstruction) \ 00342 macro(AllocationInst) \ 00343 macro(AllocaInst) \ 00344 macro(MallocInst) \ 00345 macro(CastInst) \ 00346 macro(BitCastInst) \ 00347 macro(FPExtInst) \ 00348 macro(FPToSIInst) \ 00349 macro(FPToUIInst) \ 00350 macro(FPTruncInst) \ 00351 macro(IntToPtrInst) \ 00352 macro(PtrToIntInst) \ 00353 macro(SExtInst) \ 00354 macro(SIToFPInst) \ 00355 macro(TruncInst) \ 00356 macro(UIToFPInst) \ 00357 macro(ZExtInst) \ 00358 macro(ExtractValueInst) \ 00359 macro(FreeInst) \ 00360 macro(LoadInst) \ 00361 macro(VAArgInst) 00362 00363 /* Operations on all values */ 00364 LLVMTypeRef LLVMTypeOf(LLVMValueRef Val); 00365 const char *LLVMGetValueName(LLVMValueRef Val); 00366 void LLVMSetValueName(LLVMValueRef Val, const char *Name); 00367 void LLVMDumpValue(LLVMValueRef Val); 00368 00369 /* Conversion functions. Return the input value if it is an instance of the 00370 specified class, otherwise NULL. See llvm::dyn_cast_or_null<>. */ 00371 #define LLVM_DECLARE_VALUE_CAST(name) \ 00372 LLVMValueRef LLVMIsA##name(LLVMValueRef Val); 00373 LLVM_FOR_EACH_VALUE_SUBCLASS(LLVM_DECLARE_VALUE_CAST) 00374 00375 /* Operations on constants of any type */ 00376 LLVMValueRef LLVMConstNull(LLVMTypeRef Ty); /* all zeroes */ 00377 LLVMValueRef LLVMConstAllOnes(LLVMTypeRef Ty); /* only for int/vector */ 00378 LLVMValueRef LLVMGetUndef(LLVMTypeRef Ty); 00379 int LLVMIsConstant(LLVMValueRef Val); 00380 int LLVMIsNull(LLVMValueRef Val); 00381 int LLVMIsUndef(LLVMValueRef Val); 00382 00383 /* Operations on scalar constants */ 00384 LLVMValueRef LLVMConstInt(LLVMTypeRef IntTy, unsigned long long N, 00385 int SignExtend); 00386 LLVMValueRef LLVMConstReal(LLVMTypeRef RealTy, double N); 00387 LLVMValueRef LLVMConstRealOfString(LLVMTypeRef RealTy, const char *Text); 00388 00389 /* Operations on composite constants */ 00390 LLVMValueRef LLVMConstString(const char *Str, unsigned Length, 00391 int DontNullTerminate); 00392 LLVMValueRef LLVMConstArray(LLVMTypeRef ElementTy, 00393 LLVMValueRef *ConstantVals, unsigned Length); 00394 LLVMValueRef LLVMConstStruct(LLVMValueRef *ConstantVals, unsigned Count, 00395 int packed); 00396 LLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals, unsigned Size); 00397 00398 /* Constant expressions */ 00399 LLVMValueRef LLVMSizeOf(LLVMTypeRef Ty); 00400 LLVMValueRef LLVMConstNeg(LLVMValueRef ConstantVal); 00401 LLVMValueRef LLVMConstNot(LLVMValueRef ConstantVal); 00402 LLVMValueRef LLVMConstAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); 00403 LLVMValueRef LLVMConstSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); 00404 LLVMValueRef LLVMConstMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); 00405 LLVMValueRef LLVMConstUDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); 00406 LLVMValueRef LLVMConstSDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); 00407 LLVMValueRef LLVMConstFDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); 00408 LLVMValueRef LLVMConstURem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); 00409 LLVMValueRef LLVMConstSRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); 00410 LLVMValueRef LLVMConstFRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); 00411 LLVMValueRef LLVMConstAnd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); 00412 LLVMValueRef LLVMConstOr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); 00413 LLVMValueRef LLVMConstXor(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); 00414 LLVMValueRef LLVMConstICmp(LLVMIntPredicate Predicate, 00415 LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); 00416 LLVMValueRef LLVMConstFCmp(LLVMRealPredicate Predicate, 00417 LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); 00418 LLVMValueRef LLVMConstShl(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); 00419 LLVMValueRef LLVMConstLShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); 00420 LLVMValueRef LLVMConstAShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); 00421 LLVMValueRef LLVMConstGEP(LLVMValueRef ConstantVal, 00422 LLVMValueRef *ConstantIndices, unsigned NumIndices); 00423 LLVMValueRef LLVMConstTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType); 00424 LLVMValueRef LLVMConstSExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType); 00425 LLVMValueRef LLVMConstZExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType); 00426 LLVMValueRef LLVMConstFPTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType); 00427 LLVMValueRef LLVMConstFPExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType); 00428 LLVMValueRef LLVMConstUIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType); 00429 LLVMValueRef LLVMConstSIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType); 00430 LLVMValueRef LLVMConstFPToUI(LLVMValueRef ConstantVal, LLVMTypeRef ToType); 00431 LLVMValueRef LLVMConstFPToSI(LLVMValueRef ConstantVal, LLVMTypeRef ToType); 00432 LLVMValueRef LLVMConstPtrToInt(LLVMValueRef ConstantVal, LLVMTypeRef ToType); 00433 LLVMValueRef LLVMConstIntToPtr(LLVMValueRef ConstantVal, LLVMTypeRef ToType); 00434 LLVMValueRef LLVMConstBitCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType); 00435 LLVMValueRef LLVMConstSelect(LLVMValueRef ConstantCondition, 00436 LLVMValueRef ConstantIfTrue, 00437 LLVMValueRef ConstantIfFalse); 00438 LLVMValueRef LLVMConstExtractElement(LLVMValueRef VectorConstant, 00439 LLVMValueRef IndexConstant); 00440 LLVMValueRef LLVMConstInsertElement(LLVMValueRef VectorConstant, 00441 LLVMValueRef ElementValueConstant, 00442 LLVMValueRef IndexConstant); 00443 LLVMValueRef LLVMConstShuffleVector(LLVMValueRef VectorAConstant, 00444 LLVMValueRef VectorBConstant, 00445 LLVMValueRef MaskConstant); 00446 LLVMValueRef LLVMConstExtractValue(LLVMValueRef AggConstant, unsigned *IdxList, 00447 unsigned NumIdx); 00448 LLVMValueRef LLVMConstInsertValue(LLVMValueRef AggConstant, 00449 LLVMValueRef ElementValueConstant, 00450 unsigned *IdxList, unsigned NumIdx); 00451 LLVMValueRef LLVMConstInlineAsm(LLVMTypeRef Ty, 00452 const char *AsmString, const char *Constraints, 00453 int HasSideEffects); 00454 00455 /* Operations on global variables, functions, and aliases (globals) */ 00456 LLVMModuleRef LLVMGetGlobalParent(LLVMValueRef Global); 00457 int LLVMIsDeclaration(LLVMValueRef Global); 00458 LLVMLinkage LLVMGetLinkage(LLVMValueRef Global); 00459 void LLVMSetLinkage(LLVMValueRef Global, LLVMLinkage Linkage); 00460 const char *LLVMGetSection(LLVMValueRef Global); 00461 void LLVMSetSection(LLVMValueRef Global, const char *Section); 00462 LLVMVisibility LLVMGetVisibility(LLVMValueRef Global); 00463 void LLVMSetVisibility(LLVMValueRef Global, LLVMVisibility Viz); 00464 unsigned LLVMGetAlignment(LLVMValueRef Global); 00465 void LLVMSetAlignment(LLVMValueRef Global, unsigned Bytes); 00466 00467 /* Operations on global variables */ 00468 LLVMValueRef LLVMAddGlobal(LLVMModuleRef M, LLVMTypeRef Ty, const char *Name); 00469 LLVMValueRef LLVMGetNamedGlobal(LLVMModuleRef M, const char *Name); 00470 LLVMValueRef LLVMGetFirstGlobal(LLVMModuleRef M); 00471 LLVMValueRef LLVMGetLastGlobal(LLVMModuleRef M); 00472 LLVMValueRef LLVMGetNextGlobal(LLVMValueRef GlobalVar); 00473 LLVMValueRef LLVMGetPreviousGlobal(LLVMValueRef GlobalVar); 00474 void LLVMDeleteGlobal(LLVMValueRef GlobalVar); 00475 LLVMValueRef LLVMGetInitializer(LLVMValueRef GlobalVar); 00476 void LLVMSetInitializer(LLVMValueRef GlobalVar, LLVMValueRef ConstantVal); 00477 int LLVMIsThreadLocal(LLVMValueRef GlobalVar); 00478 void LLVMSetThreadLocal(LLVMValueRef GlobalVar, int IsThreadLocal); 00479 int LLVMIsGlobalConstant(LLVMValueRef GlobalVar); 00480 void LLVMSetGlobalConstant(LLVMValueRef GlobalVar, int IsConstant); 00481 00482 /* Operations on aliases */ 00483 LLVMValueRef LLVMAddAlias(LLVMModuleRef M, LLVMTypeRef Ty, LLVMValueRef Aliasee, 00484 const char *Name); 00485 00486 /* Operations on functions */ 00487 LLVMValueRef LLVMAddFunction(LLVMModuleRef M, const char *Name, 00488 LLVMTypeRef FunctionTy); 00489 LLVMValueRef LLVMGetNamedFunction(LLVMModuleRef M, const char *Name); 00490 LLVMValueRef LLVMGetFirstFunction(LLVMModuleRef M); 00491 LLVMValueRef LLVMGetLastFunction(LLVMModuleRef M); 00492 LLVMValueRef LLVMGetNextFunction(LLVMValueRef Fn); 00493 LLVMValueRef LLVMGetPreviousFunction(LLVMValueRef Fn); 00494 void LLVMDeleteFunction(LLVMValueRef Fn); 00495 unsigned LLVMGetIntrinsicID(LLVMValueRef Fn); 00496 unsigned LLVMGetFunctionCallConv(LLVMValueRef Fn); 00497 void LLVMSetFunctionCallConv(LLVMValueRef Fn, unsigned CC); 00498 const char *LLVMGetGC(LLVMValueRef Fn); 00499 void LLVMSetGC(LLVMValueRef Fn, const char *Name); 00500 00501 /* Operations on parameters */ 00502 unsigned LLVMCountParams(LLVMValueRef Fn); 00503 void LLVMGetParams(LLVMValueRef Fn, LLVMValueRef *Params); 00504 LLVMValueRef LLVMGetParam(LLVMValueRef Fn, unsigned Index); 00505 LLVMValueRef LLVMGetParamParent(LLVMValueRef Inst); 00506 LLVMValueRef LLVMGetFirstParam(LLVMValueRef Fn); 00507 LLVMValueRef LLVMGetLastParam(LLVMValueRef Fn); 00508 LLVMValueRef LLVMGetNextParam(LLVMValueRef Arg); 00509 LLVMValueRef LLVMGetPreviousParam(LLVMValueRef Arg); 00510 void LLVMAddAttribute(LLVMValueRef Arg, LLVMAttribute PA); 00511 void LLVMRemoveAttribute(LLVMValueRef Arg, LLVMAttribute PA); 00512 void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned align); 00513 00514 /* Operations on basic blocks */ 00515 LLVMValueRef LLVMBasicBlockAsValue(LLVMBasicBlockRef BB); 00516 int LLVMValueIsBasicBlock(LLVMValueRef Val); 00517 LLVMBasicBlockRef LLVMValueAsBasicBlock(LLVMValueRef Val); 00518 LLVMValueRef LLVMGetBasicBlockParent(LLVMBasicBlockRef BB); 00519 unsigned LLVMCountBasicBlocks(LLVMValueRef Fn); 00520 void LLVMGetBasicBlocks(LLVMValueRef Fn, LLVMBasicBlockRef *BasicBlocks); 00521 LLVMBasicBlockRef LLVMGetFirstBasicBlock(LLVMValueRef Fn); 00522 LLVMBasicBlockRef LLVMGetLastBasicBlock(LLVMValueRef Fn); 00523 LLVMBasicBlockRef LLVMGetNextBasicBlock(LLVMBasicBlockRef BB); 00524 LLVMBasicBlockRef LLVMGetPreviousBasicBlock(LLVMBasicBlockRef BB); 00525 LLVMBasicBlockRef LLVMGetEntryBasicBlock(LLVMValueRef Fn); 00526 LLVMBasicBlockRef LLVMAppendBasicBlock(LLVMValueRef Fn, const char *Name); 00527 LLVMBasicBlockRef LLVMInsertBasicBlock(LLVMBasicBlockRef InsertBeforeBB, 00528 const char *Name); 00529 void LLVMDeleteBasicBlock(LLVMBasicBlockRef BB); 00530 00531 /* Operations on instructions */ 00532 LLVMBasicBlockRef LLVMGetInstructionParent(LLVMValueRef Inst); 00533 LLVMValueRef LLVMGetFirstInstruction(LLVMBasicBlockRef BB); 00534 LLVMValueRef LLVMGetLastInstruction(LLVMBasicBlockRef BB); 00535 LLVMValueRef LLVMGetNextInstruction(LLVMValueRef Inst); 00536 LLVMValueRef LLVMGetPreviousInstruction(LLVMValueRef Inst); 00537 00538 /* Operations on call sites */ 00539 void LLVMSetInstructionCallConv(LLVMValueRef Instr, unsigned CC); 00540 unsigned LLVMGetInstructionCallConv(LLVMValueRef Instr); 00541 void LLVMAddInstrAttribute(LLVMValueRef Instr, unsigned index, LLVMAttribute); 00542 void LLVMRemoveInstrAttribute(LLVMValueRef Instr, unsigned index, 00543 LLVMAttribute); 00544 void LLVMSetInstrParamAlignment(LLVMValueRef Instr, unsigned index, 00545 unsigned align); 00546 00547 /* Operations on call instructions (only) */ 00548 int LLVMIsTailCall(LLVMValueRef CallInst); 00549 void LLVMSetTailCall(LLVMValueRef CallInst, int IsTailCall); 00550 00551 /* Operations on phi nodes */ 00552 void LLVMAddIncoming(LLVMValueRef PhiNode, LLVMValueRef *IncomingValues, 00553 LLVMBasicBlockRef *IncomingBlocks, unsigned Count); 00554 unsigned LLVMCountIncoming(LLVMValueRef PhiNode); 00555 LLVMValueRef LLVMGetIncomingValue(LLVMValueRef PhiNode, unsigned Index); 00556 LLVMBasicBlockRef LLVMGetIncomingBlock(LLVMValueRef PhiNode, unsigned Index); 00557 00558 /*===-- Instruction builders ----------------------------------------------===*/ 00559 00560 /* An instruction builder represents a point within a basic block, and is the 00561 * exclusive means of building instructions using the C interface. 00562 */ 00563 00564 LLVMBuilderRef LLVMCreateBuilder(void); 00565 void LLVMPositionBuilder(LLVMBuilderRef Builder, LLVMBasicBlockRef Block, 00566 LLVMValueRef Instr); 00567 void LLVMPositionBuilderBefore(LLVMBuilderRef Builder, LLVMValueRef Instr); 00568 void LLVMPositionBuilderAtEnd(LLVMBuilderRef Builder, LLVMBasicBlockRef Block); 00569 LLVMBasicBlockRef LLVMGetInsertBlock(LLVMBuilderRef Builder); 00570 void LLVMClearInsertionPosition(LLVMBuilderRef Builder); 00571 void LLVMInsertIntoBuilder(LLVMBuilderRef Builder, LLVMValueRef Instr); 00572 void LLVMDisposeBuilder(LLVMBuilderRef Builder); 00573 00574 /* Terminators */ 00575 LLVMValueRef LLVMBuildRetVoid(LLVMBuilderRef); 00576 LLVMValueRef LLVMBuildRet(LLVMBuilderRef, LLVMValueRef V); 00577 LLVMValueRef LLVMBuildBr(LLVMBuilderRef, LLVMBasicBlockRef Dest); 00578 LLVMValueRef LLVMBuildCondBr(LLVMBuilderRef, LLVMValueRef If, 00579 LLVMBasicBlockRef Then, LLVMBasicBlockRef Else); 00580 LLVMValueRef LLVMBuildSwitch(LLVMBuilderRef, LLVMValueRef V, 00581 LLVMBasicBlockRef Else, unsigned NumCases); 00582 LLVMValueRef LLVMBuildInvoke(LLVMBuilderRef, LLVMValueRef Fn, 00583 LLVMValueRef *Args, unsigned NumArgs, 00584 LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch, 00585 const char *Name); 00586 LLVMValueRef LLVMBuildUnwind(LLVMBuilderRef); 00587 LLVMValueRef LLVMBuildUnreachable(LLVMBuilderRef); 00588 00589 /* Add a case to the switch instruction */ 00590 void LLVMAddCase(LLVMValueRef Switch, LLVMValueRef OnVal, 00591 LLVMBasicBlockRef Dest); 00592 00593 /* Arithmetic */ 00594 LLVMValueRef LLVMBuildAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, 00595 const char *Name); 00596 LLVMValueRef LLVMBuildSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, 00597 const char *Name); 00598 LLVMValueRef LLVMBuildMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, 00599 const char *Name); 00600 LLVMValueRef LLVMBuildUDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, 00601 const char *Name); 00602 LLVMValueRef LLVMBuildSDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, 00603 const char *Name); 00604 LLVMValueRef LLVMBuildFDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, 00605 const char *Name); 00606 LLVMValueRef LLVMBuildURem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, 00607 const char *Name); 00608 LLVMValueRef LLVMBuildSRem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, 00609 const char *Name); 00610 LLVMValueRef LLVMBuildFRem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, 00611 const char *Name); 00612 LLVMValueRef LLVMBuildShl(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, 00613 const char *Name); 00614 LLVMValueRef LLVMBuildLShr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, 00615 const char *Name); 00616 LLVMValueRef LLVMBuildAShr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, 00617 const char *Name); 00618 LLVMValueRef LLVMBuildAnd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, 00619 const char *Name); 00620 LLVMValueRef LLVMBuildOr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, 00621 const char *Name); 00622 LLVMValueRef LLVMBuildXor(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, 00623 const char *Name); 00624 LLVMValueRef LLVMBuildNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name); 00625 LLVMValueRef LLVMBuildNot(LLVMBuilderRef, LLVMValueRef V, const char *Name); 00626 00627 /* Memory */ 00628 LLVMValueRef LLVMBuildMalloc(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name); 00629 LLVMValueRef LLVMBuildArrayMalloc(LLVMBuilderRef, LLVMTypeRef Ty, 00630 LLVMValueRef Val, const char *Name); 00631 LLVMValueRef LLVMBuildAlloca(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name); 00632 LLVMValueRef LLVMBuildArrayAlloca(LLVMBuilderRef, LLVMTypeRef Ty, 00633 LLVMValueRef Val, const char *Name); 00634 LLVMValueRef LLVMBuildFree(LLVMBuilderRef, LLVMValueRef PointerVal); 00635 LLVMValueRef LLVMBuildLoad(LLVMBuilderRef, LLVMValueRef PointerVal, 00636 const char *Name); 00637 LLVMValueRef LLVMBuildStore(LLVMBuilderRef, LLVMValueRef Val, LLVMValueRef Ptr); 00638 LLVMValueRef LLVMBuildGEP(LLVMBuilderRef B, LLVMValueRef Pointer, 00639 LLVMValueRef *Indices, unsigned NumIndices, 00640 const char *Name); 00641 00642 /* Casts */ 00643 LLVMValueRef LLVMBuildTrunc(LLVMBuilderRef, LLVMValueRef Val, 00644 LLVMTypeRef DestTy, const char *Name); 00645 LLVMValueRef LLVMBuildZExt(LLVMBuilderRef, LLVMValueRef Val, 00646 LLVMTypeRef DestTy, const char *Name); 00647 LLVMValueRef LLVMBuildSExt(LLVMBuilderRef, LLVMValueRef Val, 00648 LLVMTypeRef DestTy, const char *Name); 00649 LLVMValueRef LLVMBuildFPToUI(LLVMBuilderRef, LLVMValueRef Val, 00650 LLVMTypeRef DestTy, const char *Name); 00651 LLVMValueRef LLVMBuildFPToSI(LLVMBuilderRef, LLVMValueRef Val, 00652 LLVMTypeRef DestTy, const char *Name); 00653 LLVMValueRef LLVMBuildUIToFP(LLVMBuilderRef, LLVMValueRef Val, 00654 LLVMTypeRef DestTy, const char *Name); 00655 LLVMValueRef LLVMBuildSIToFP(LLVMBuilderRef, LLVMValueRef Val, 00656 LLVMTypeRef DestTy, const char *Name); 00657 LLVMValueRef LLVMBuildFPTrunc(LLVMBuilderRef, LLVMValueRef Val, 00658 LLVMTypeRef DestTy, const char *Name); 00659 LLVMValueRef LLVMBuildFPExt(LLVMBuilderRef, LLVMValueRef Val, 00660 LLVMTypeRef DestTy, const char *Name); 00661 LLVMValueRef LLVMBuildPtrToInt(LLVMBuilderRef, LLVMValueRef Val, 00662 LLVMTypeRef DestTy, const char *Name); 00663 LLVMValueRef LLVMBuildIntToPtr(LLVMBuilderRef, LLVMValueRef Val, 00664 LLVMTypeRef DestTy, const char *Name); 00665 LLVMValueRef LLVMBuildBitCast(LLVMBuilderRef, LLVMValueRef Val, 00666 LLVMTypeRef DestTy, const char *Name); 00667 00668 /* Comparisons */ 00669 LLVMValueRef LLVMBuildICmp(LLVMBuilderRef, LLVMIntPredicate Op, 00670 LLVMValueRef LHS, LLVMValueRef RHS, 00671 const char *Name); 00672 LLVMValueRef LLVMBuildFCmp(LLVMBuilderRef, LLVMRealPredicate Op, 00673 LLVMValueRef LHS, LLVMValueRef RHS, 00674 const char *Name); 00675 00676 /* Miscellaneous instructions */ 00677 LLVMValueRef LLVMBuildPhi(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name); 00678 LLVMValueRef LLVMBuildCall(LLVMBuilderRef, LLVMValueRef Fn, 00679 LLVMValueRef *Args, unsigned NumArgs, 00680 const char *Name); 00681 LLVMValueRef LLVMBuildSelect(LLVMBuilderRef, LLVMValueRef If, 00682 LLVMValueRef Then, LLVMValueRef Else, 00683 const char *Name); 00684 LLVMValueRef LLVMBuildVAArg(LLVMBuilderRef, LLVMValueRef List, LLVMTypeRef Ty, 00685 const char *Name); 00686 LLVMValueRef LLVMBuildExtractElement(LLVMBuilderRef, LLVMValueRef VecVal, 00687 LLVMValueRef Index, const char *Name); 00688 LLVMValueRef LLVMBuildInsertElement(LLVMBuilderRef, LLVMValueRef VecVal, 00689 LLVMValueRef EltVal, LLVMValueRef Index, 00690 const char *Name); 00691 LLVMValueRef LLVMBuildShuffleVector(LLVMBuilderRef, LLVMValueRef V1, 00692 LLVMValueRef V2, LLVMValueRef Mask, 00693 const char *Name); 00694 LLVMValueRef LLVMBuildExtractValue(LLVMBuilderRef, LLVMValueRef AggVal, 00695 unsigned Index, const char *Name); 00696 LLVMValueRef LLVMBuildInsertValue(LLVMBuilderRef, LLVMValueRef AggVal, 00697 LLVMValueRef EltVal, unsigned Index, 00698 const char *Name); 00699 00700 00701 /*===-- Module providers --------------------------------------------------===*/ 00702 00703 /* Encapsulates the module M in a module provider, taking ownership of the 00704 * module. 00705 * See the constructor llvm::ExistingModuleProvider::ExistingModuleProvider. 00706 */ 00707 LLVMModuleProviderRef 00708 LLVMCreateModuleProviderForExistingModule(LLVMModuleRef M); 00709 00710 /* Destroys the module provider MP as well as the contained module. 00711 * See the destructor llvm::ModuleProvider::~ModuleProvider. 00712 */ 00713 void LLVMDisposeModuleProvider(LLVMModuleProviderRef MP); 00714 00715 00716 /*===-- Memory buffers ----------------------------------------------------===*/ 00717 00718 int LLVMCreateMemoryBufferWithContentsOfFile(const char *Path, 00719 LLVMMemoryBufferRef *OutMemBuf, 00720 char **OutMessage); 00721 int LLVMCreateMemoryBufferWithSTDIN(LLVMMemoryBufferRef *OutMemBuf, 00722 char **OutMessage); 00723 void LLVMDisposeMemoryBuffer(LLVMMemoryBufferRef MemBuf); 00724 00725 00726 /*===-- Pass Managers -----------------------------------------------------===*/ 00727 00728 /** Constructs a new whole-module pass pipeline. This type of pipeline is 00729 suitable for link-time optimization and whole-module transformations. 00730 See llvm::PassManager::PassManager. */ 00731 LLVMPassManagerRef LLVMCreatePassManager(void); 00732 00733 /** Constructs a new function-by-function pass pipeline over the module 00734 provider. It does not take ownership of the module provider. This type of 00735 pipeline is suitable for code generation and JIT compilation tasks. 00736 See llvm::FunctionPassManager::FunctionPassManager. */ 00737 LLVMPassManagerRef LLVMCreateFunctionPassManager(LLVMModuleProviderRef MP); 00738 00739 /** Initializes, executes on the provided module, and finalizes all of the 00740 passes scheduled in the pass manager. Returns 1 if any of the passes 00741 modified the module, 0 otherwise. See llvm::PassManager::run(Module&). */ 00742 int LLVMRunPassManager(LLVMPassManagerRef PM, LLVMModuleRef M); 00743 00744 /** Initializes all of the function passes scheduled in the function pass 00745 manager. Returns 1 if any of the passes modified the module, 0 otherwise. 00746 See llvm::FunctionPassManager::doInitialization. */ 00747 int LLVMInitializeFunctionPassManager(LLVMPassManagerRef FPM); 00748 00749 /** Executes all of the function passes scheduled in the function pass manager 00750 on the provided function. Returns 1 if any of the passes modified the 00751 function, false otherwise. 00752 See llvm::FunctionPassManager::run(Function&). */ 00753 int LLVMRunFunctionPassManager(LLVMPassManagerRef FPM, LLVMValueRef F); 00754 00755 /** Finalizes all of the function passes scheduled in in the function pass 00756 manager. Returns 1 if any of the passes modified the module, 0 otherwise. 00757 See llvm::FunctionPassManager::doFinalization. */ 00758 int LLVMFinalizeFunctionPassManager(LLVMPassManagerRef FPM); 00759 00760 /** Frees the memory of a pass pipeline. For function pipelines, does not free 00761 the module provider. 00762 See llvm::PassManagerBase::~PassManagerBase. */ 00763 void LLVMDisposePassManager(LLVMPassManagerRef PM); 00764 00765 00766 #ifdef __cplusplus 00767 } 00768 00769 namespace llvm { 00770 class ModuleProvider; 00771 class MemoryBuffer; 00772 class PassManagerBase; 00773 00774 #define DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref) \ 00775 inline ty *unwrap(ref P) { \ 00776 return reinterpret_cast<ty*>(P); \ 00777 } \ 00778 \ 00779 inline ref wrap(const ty *P) { \ 00780 return reinterpret_cast<ref>(const_cast<ty*>(P)); \ 00781 } 00782 00783 #define DEFINE_ISA_CONVERSION_FUNCTIONS(ty, ref) \ 00784 DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref) \ 00785 \ 00786 template<typename T> \ 00787 inline T *unwrap(ref P) { \ 00788 return cast<T>(unwrap(P)); \ 00789 } 00790 00791 #define DEFINE_STDCXX_CONVERSION_FUNCTIONS(ty, ref) \ 00792 DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref) \ 00793 \ 00794 template<typename T> \ 00795 inline T *unwrap(ref P) { \ 00796 T *Q = dynamic_cast<T*>(unwrap(P)); \ 00797 assert(Q && "Invalid cast!"); \ 00798 return Q; \ 00799 } 00800 00801 DEFINE_ISA_CONVERSION_FUNCTIONS (Type, LLVMTypeRef ) 00802 DEFINE_ISA_CONVERSION_FUNCTIONS (Value, LLVMValueRef ) 00803 DEFINE_SIMPLE_CONVERSION_FUNCTIONS(Module, LLVMModuleRef ) 00804 DEFINE_SIMPLE_CONVERSION_FUNCTIONS(BasicBlock, LLVMBasicBlockRef ) 00805 DEFINE_SIMPLE_CONVERSION_FUNCTIONS(IRBuilder<>, LLVMBuilderRef ) 00806 DEFINE_SIMPLE_CONVERSION_FUNCTIONS(PATypeHolder, LLVMTypeHandleRef ) 00807 DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ModuleProvider, LLVMModuleProviderRef) 00808 DEFINE_SIMPLE_CONVERSION_FUNCTIONS(MemoryBuffer, LLVMMemoryBufferRef ) 00809 DEFINE_STDCXX_CONVERSION_FUNCTIONS(PassManagerBase, LLVMPassManagerRef ) 00810 00811 #undef DEFINE_STDCXX_CONVERSION_FUNCTIONS 00812 #undef DEFINE_ISA_CONVERSION_FUNCTIONS 00813 #undef DEFINE_SIMPLE_CONVERSION_FUNCTIONS 00814 00815 /* Specialized opaque type conversions. 00816 */ 00817 inline Type **unwrap(LLVMTypeRef* Tys) { 00818 return reinterpret_cast<Type**>(Tys); 00819 } 00820 00821 inline LLVMTypeRef *wrap(const Type **Tys) { 00822 return reinterpret_cast<LLVMTypeRef*>(const_cast<Type**>(Tys)); 00823 } 00824 00825 /* Specialized opaque value conversions. 00826 */ 00827 inline Value **unwrap(LLVMValueRef *Vals) { 00828 return reinterpret_cast<Value**>(Vals); 00829 } 00830 00831 template<typename T> 00832 inline T **unwrap(LLVMValueRef *Vals, unsigned Length) { 00833 #if DEBUG 00834 for (LLVMValueRef *I = Vals, E = Vals + Length; I != E; ++I) 00835 cast<T>(*I); 00836 #endif 00837 return reinterpret_cast<T**>(Vals); 00838 } 00839 00840 inline LLVMValueRef *wrap(const Value **Vals) { 00841 return reinterpret_cast<LLVMValueRef*>(const_cast<Value**>(Vals)); 00842 } 00843 } 00844 00845 #endif /* !defined(__cplusplus) */ 00846 00847 #endif /* !defined(LLVM_C_CORE_H) */
This web site is hosted by the Computer Science Department at the University of Illinois at Urbana-Champaign.