/*===-- llvm-c/Core.h - Core Library C Interface ------------------*- C -*-===*\ |* *| |* The LLVM Compiler Infrastructure *| |* *| |* This file is distributed under the University of Illinois Open Source *| |* License. See LICENSE.TXT for details. *| |* *| |*===----------------------------------------------------------------------===*| |* *| |* This header declares the C interface to libLLVMCore.a, which implements *| |* the LLVM intermediate representation. *| |* *| |* LLVM uses a polymorphic type hierarchy which C cannot represent, therefore *| |* parameters must be passed as base types. Despite the declared types, most *| |* of the functions provided operate only on branches of the type hierarchy. *| |* The declared parameter names are descriptive and specify which type is *| |* required. Additionally, each type hierarchy is documented along with the *| |* functions that operate upon it. For more detail, refer to LLVM's C++ code. *| |* If in doubt, refer to Core.cpp, which performs paramter downcasts in the *| |* form unwrap(Param). *| |* *| |* Many exotic languages can interoperate with C code but have a harder time *| |* with C++ due to name mangling. So in addition to C, this interface enables *| |* tools written in such languages. *| |* *| |* When included into a C++ source file, also declares 'wrap' and 'unwrap' *| |* helpers to perform opaque reference<-->pointer conversions. These helpers *| |* are shorter and more tightly typed than writing the casts by hand when *| |* authoring bindings. In assert builds, they will do runtime type checking. *| |* *| \*===----------------------------------------------------------------------===*/ #ifndef LLVM_C_CORE_H #define LLVM_C_CORE_H #include "llvm/System/DataTypes.h" #ifdef __cplusplus /* Need these includes to support the LLVM 'cast' template for the C++ 'wrap' and 'unwrap' conversion functions. */ #include "llvm/Module.h" #include "llvm/Support/IRBuilder.h" extern "C" { #endif typedef int LLVMBool; /* Opaque types. */ /** * The top-level container for all LLVM global data. See the LLVMContext class. */ typedef struct LLVMOpaqueContext *LLVMContextRef; /** * The top-level container for all other LLVM Intermediate Representation (IR) * objects. See the llvm::Module class. */ typedef struct LLVMOpaqueModule *LLVMModuleRef; /** * Each value in the LLVM IR has a type, an LLVMTypeRef. See the llvm::Type * class. */ typedef struct LLVMOpaqueType *LLVMTypeRef; /** * When building recursive types using LLVMRefineType, LLVMTypeRef values may * become invalid; use LLVMTypeHandleRef to resolve this problem. See the * llvm::AbstractTypeHolder class. */ typedef struct LLVMOpaqueTypeHandle *LLVMTypeHandleRef; typedef struct LLVMOpaqueValue *LLVMValueRef; typedef struct LLVMOpaqueBasicBlock *LLVMBasicBlockRef; typedef struct LLVMOpaqueBuilder *LLVMBuilderRef; /* Interface used to provide a module to JIT or interpreter. This is now just a * synonym for llvm::Module, but we have to keep using the different type to * keep binary compatibility. */ typedef struct LLVMOpaqueModuleProvider *LLVMModuleProviderRef; /* Used to provide a module to JIT or interpreter. * See the llvm::MemoryBuffer class. */ typedef struct LLVMOpaqueMemoryBuffer *LLVMMemoryBufferRef; /** See the llvm::PassManagerBase class. */ typedef struct LLVMOpaquePassManager *LLVMPassManagerRef; /** Used to get the users and usees of a Value. See the llvm::Use class. */ typedef struct LLVMOpaqueUse *LLVMUseRef; typedef enum { LLVMZExtAttribute = 1<<0, LLVMSExtAttribute = 1<<1, LLVMNoReturnAttribute = 1<<2, LLVMInRegAttribute = 1<<3, LLVMStructRetAttribute = 1<<4, LLVMNoUnwindAttribute = 1<<5, LLVMNoAliasAttribute = 1<<6, LLVMByValAttribute = 1<<7, LLVMNestAttribute = 1<<8, LLVMReadNoneAttribute = 1<<9, LLVMReadOnlyAttribute = 1<<10, LLVMNoInlineAttribute = 1<<11, LLVMAlwaysInlineAttribute = 1<<12, LLVMOptimizeForSizeAttribute = 1<<13, LLVMStackProtectAttribute = 1<<14, LLVMStackProtectReqAttribute = 1<<15, LLVMAlignment = 31<<16, LLVMNoCaptureAttribute = 1<<21, LLVMNoRedZoneAttribute = 1<<22, LLVMNoImplicitFloatAttribute = 1<<23, LLVMNakedAttribute = 1<<24, LLVMInlineHintAttribute = 1<<25, LLVMStackAlignment = 7<<26 } LLVMAttribute; typedef enum { /* Terminator Instructions */ LLVMRet = 1, LLVMBr = 2, LLVMSwitch = 3, LLVMIndirectBr = 4, LLVMInvoke = 5, LLVMUnwind = 6, LLVMUnreachable = 7, /* Standard Binary Operators */ LLVMAdd = 8, LLVMFAdd = 9, LLVMSub = 10, LLVMFSub = 11, LLVMMul = 12, LLVMFMul = 13, LLVMUDiv = 14, LLVMSDiv = 15, LLVMFDiv = 16, LLVMURem = 17, LLVMSRem = 18, LLVMFRem = 19, /* Logical Operators */ LLVMShl = 20, LLVMLShr = 21, LLVMAShr = 22, LLVMAnd = 23, LLVMOr = 24, LLVMXor = 25, /* Memory Operators */ LLVMAlloca = 26, LLVMLoad = 27, LLVMStore = 28, LLVMGetElementPtr = 29, /* Cast Operators */ LLVMTrunc = 30, LLVMZExt = 31, LLVMSExt = 32, LLVMFPToUI = 33, LLVMFPToSI = 34, LLVMUIToFP = 35, LLVMSIToFP = 36, LLVMFPTrunc = 37, LLVMFPExt = 38, LLVMPtrToInt = 39, LLVMIntToPtr = 40, LLVMBitCast = 41, /* Other Operators */ LLVMICmp = 42, LLVMFCmp = 43, LLVMPHI = 44, LLVMCall = 45, LLVMSelect = 46, /* UserOp1 */ /* UserOp2 */ LLVMVAArg = 49, LLVMExtractElement = 50, LLVMInsertElement = 51, LLVMShuffleVector = 52, LLVMExtractValue = 53, LLVMInsertValue = 54 } LLVMOpcode; typedef enum { LLVMVoidTypeKind, /**< type with no size */ LLVMFloatTypeKind, /**< 32 bit floating point type */ LLVMDoubleTypeKind, /**< 64 bit floating point type */ LLVMX86_FP80TypeKind, /**< 80 bit floating point type (X87) */ LLVMFP128TypeKind, /**< 128 bit floating point type (112-bit mantissa)*/ LLVMPPC_FP128TypeKind, /**< 128 bit floating point type (two 64-bits) */ LLVMLabelTypeKind, /**< Labels */ LLVMIntegerTypeKind, /**< Arbitrary bit width integers */ LLVMFunctionTypeKind, /**< Functions */ LLVMStructTypeKind, /**< Structures */ LLVMArrayTypeKind, /**< Arrays */ LLVMPointerTypeKind, /**< Pointers */ LLVMOpaqueTypeKind, /**< Opaque: type with unknown structure */ LLVMVectorTypeKind, /**< SIMD 'packed' format, or other vector type */ LLVMMetadataTypeKind, /**< Metadata */ LLVMX86_MMXTypeKind /**< X86 MMX */ } LLVMTypeKind; typedef enum { LLVMExternalLinkage, /**< Externally visible function */ LLVMAvailableExternallyLinkage, LLVMLinkOnceAnyLinkage, /**< Keep one copy of function when linking (inline)*/ LLVMLinkOnceODRLinkage, /**< Same, but only replaced by something equivalent. */ LLVMWeakAnyLinkage, /**< Keep one copy of function when linking (weak) */ LLVMWeakODRLinkage, /**< Same, but only replaced by something equivalent. */ LLVMAppendingLinkage, /**< Special purpose, only applies to global arrays */ LLVMInternalLinkage, /**< Rename collisions when linking (static functions) */ LLVMPrivateLinkage, /**< Like Internal, but omit from symbol table */ LLVMDLLImportLinkage, /**< Function to be imported from DLL */ LLVMDLLExportLinkage, /**< Function to be accessible from DLL */ LLVMExternalWeakLinkage,/**< ExternalWeak linkage description */ LLVMGhostLinkage, /**< Obsolete */ LLVMCommonLinkage, /**< Tentative definitions */ LLVMLinkerPrivateLinkage, /**< Like Private, but linker removes. */ LLVMLinkerPrivateWeakLinkage, /**< Like LinkerPrivate, but is weak. */ LLVMLinkerPrivateWeakDefAutoLinkage /**< Like LinkerPrivateWeak, but possibly hidden. */ } LLVMLinkage; typedef enum { LLVMDefaultVisibility, /**< The GV is visible */ LLVMHiddenVisibility, /**< The GV is hidden */ LLVMProtectedVisibility /**< The GV is protected */ } LLVMVisibility; typedef enum { LLVMCCallConv = 0, LLVMFastCallConv = 8, LLVMColdCallConv = 9, LLVMX86StdcallCallConv = 64, LLVMX86FastcallCallConv = 65 } LLVMCallConv; typedef enum { LLVMIntEQ = 32, /**< equal */ LLVMIntNE, /**< not equal */ LLVMIntUGT, /**< unsigned greater than */ LLVMIntUGE, /**< unsigned greater or equal */ LLVMIntULT, /**< unsigned less than */ LLVMIntULE, /**< unsigned less or equal */ LLVMIntSGT, /**< signed greater than */ LLVMIntSGE, /**< signed greater or equal */ LLVMIntSLT, /**< signed less than */ LLVMIntSLE /**< signed less or equal */ } LLVMIntPredicate; typedef enum { LLVMRealPredicateFalse, /**< Always false (always folded) */ LLVMRealOEQ, /**< True if ordered and equal */ LLVMRealOGT, /**< True if ordered and greater than */ LLVMRealOGE, /**< True if ordered and greater than or equal */ LLVMRealOLT, /**< True if ordered and less than */ LLVMRealOLE, /**< True if ordered and less than or equal */ LLVMRealONE, /**< True if ordered and operands are unequal */ LLVMRealORD, /**< True if ordered (no nans) */ LLVMRealUNO, /**< True if unordered: isnan(X) | isnan(Y) */ LLVMRealUEQ, /**< True if unordered or equal */ LLVMRealUGT, /**< True if unordered or greater than */ LLVMRealUGE, /**< True if unordered, greater than, or equal */ LLVMRealULT, /**< True if unordered or less than */ LLVMRealULE, /**< True if unordered, less than, or equal */ LLVMRealUNE, /**< True if unordered or not equal */ LLVMRealPredicateTrue /**< Always true (always folded) */ } LLVMRealPredicate; /*===-- Error handling ----------------------------------------------------===*/ void LLVMDisposeMessage(char *Message); /*===-- Contexts ----------------------------------------------------------===*/ /* Create and destroy contexts. */ LLVMContextRef LLVMContextCreate(void); LLVMContextRef LLVMGetGlobalContext(void); void LLVMContextDispose(LLVMContextRef C); unsigned LLVMGetMDKindIDInContext(LLVMContextRef C, const char* Name, unsigned SLen); unsigned LLVMGetMDKindID(const char* Name, unsigned SLen); /*===-- Modules -----------------------------------------------------------===*/ /* Create and destroy modules. */ /** See llvm::Module::Module. */ LLVMModuleRef LLVMModuleCreateWithName(const char *ModuleID); LLVMModuleRef LLVMModuleCreateWithNameInContext(const char *ModuleID, LLVMContextRef C); /** See llvm::Module::~Module. */ void LLVMDisposeModule(LLVMModuleRef M); /** Data layout. See Module::getDataLayout. */ const char *LLVMGetDataLayout(LLVMModuleRef M); void LLVMSetDataLayout(LLVMModuleRef M, const char *Triple); /** Target triple. See Module::getTargetTriple. */ const char *LLVMGetTarget(LLVMModuleRef M); void LLVMSetTarget(LLVMModuleRef M, const char *Triple); /** See Module::addTypeName. */ LLVMBool LLVMAddTypeName(LLVMModuleRef M, const char *Name, LLVMTypeRef Ty); void LLVMDeleteTypeName(LLVMModuleRef M, const char *Name); LLVMTypeRef LLVMGetTypeByName(LLVMModuleRef M, const char *Name); /** See Module::dump. */ void LLVMDumpModule(LLVMModuleRef M); /** See Module::setModuleInlineAsm. */ void LLVMSetModuleInlineAsm(LLVMModuleRef M, const char *Asm); /*===-- Types -------------------------------------------------------------===*/ /* LLVM types conform to the following hierarchy: * * types: * integer type * real type * function type * sequence types: * array type * pointer type * vector type * void type * label type * opaque type */ /** See llvm::LLVMTypeKind::getTypeID. */ LLVMTypeKind LLVMGetTypeKind(LLVMTypeRef Ty); /** See llvm::LLVMType::getContext. */ LLVMContextRef LLVMGetTypeContext(LLVMTypeRef Ty); /* Operations on integer types */ LLVMTypeRef LLVMInt1TypeInContext(LLVMContextRef C); LLVMTypeRef LLVMInt8TypeInContext(LLVMContextRef C); LLVMTypeRef LLVMInt16TypeInContext(LLVMContextRef C); LLVMTypeRef LLVMInt32TypeInContext(LLVMContextRef C); LLVMTypeRef LLVMInt64TypeInContext(LLVMContextRef C); LLVMTypeRef LLVMIntTypeInContext(LLVMContextRef C, unsigned NumBits); LLVMTypeRef LLVMInt1Type(void); LLVMTypeRef LLVMInt8Type(void); LLVMTypeRef LLVMInt16Type(void); LLVMTypeRef LLVMInt32Type(void); LLVMTypeRef LLVMInt64Type(void); LLVMTypeRef LLVMIntType(unsigned NumBits); unsigned LLVMGetIntTypeWidth(LLVMTypeRef IntegerTy); /* Operations on real types */ LLVMTypeRef LLVMFloatTypeInContext(LLVMContextRef C); LLVMTypeRef LLVMDoubleTypeInContext(LLVMContextRef C); LLVMTypeRef LLVMX86FP80TypeInContext(LLVMContextRef C); LLVMTypeRef LLVMFP128TypeInContext(LLVMContextRef C); LLVMTypeRef LLVMPPCFP128TypeInContext(LLVMContextRef C); LLVMTypeRef LLVMFloatType(void); LLVMTypeRef LLVMDoubleType(void); LLVMTypeRef LLVMX86FP80Type(void); LLVMTypeRef LLVMFP128Type(void); LLVMTypeRef LLVMPPCFP128Type(void); /* Operations on function types */ LLVMTypeRef LLVMFunctionType(LLVMTypeRef ReturnType, LLVMTypeRef *ParamTypes, unsigned ParamCount, LLVMBool IsVarArg); LLVMBool LLVMIsFunctionVarArg(LLVMTypeRef FunctionTy); LLVMTypeRef LLVMGetReturnType(LLVMTypeRef FunctionTy); unsigned LLVMCountParamTypes(LLVMTypeRef FunctionTy); void LLVMGetParamTypes(LLVMTypeRef FunctionTy, LLVMTypeRef *Dest); /* Operations on struct types */ LLVMTypeRef LLVMStructTypeInContext(LLVMContextRef C, LLVMTypeRef *ElementTypes, unsigned ElementCount, LLVMBool Packed); LLVMTypeRef LLVMStructType(LLVMTypeRef *ElementTypes, unsigned ElementCount, LLVMBool Packed); unsigned LLVMCountStructElementTypes(LLVMTypeRef StructTy); void LLVMGetStructElementTypes(LLVMTypeRef StructTy, LLVMTypeRef *Dest); LLVMBool LLVMIsPackedStruct(LLVMTypeRef StructTy); /* Operations on array, pointer, and vector types (sequence types) */ LLVMTypeRef LLVMArrayType(LLVMTypeRef ElementType, unsigned ElementCount); LLVMTypeRef LLVMPointerType(LLVMTypeRef ElementType, unsigned AddressSpace); LLVMTypeRef LLVMVectorType(LLVMTypeRef ElementType, unsigned ElementCount); LLVMTypeRef LLVMGetElementType(LLVMTypeRef Ty); unsigned LLVMGetArrayLength(LLVMTypeRef ArrayTy); unsigned LLVMGetPointerAddressSpace(LLVMTypeRef PointerTy); unsigned LLVMGetVectorSize(LLVMTypeRef VectorTy); /* Operations on other types */ LLVMTypeRef LLVMVoidTypeInContext(LLVMContextRef C); LLVMTypeRef LLVMLabelTypeInContext(LLVMContextRef C); LLVMTypeRef LLVMOpaqueTypeInContext(LLVMContextRef C); LLVMTypeRef LLVMX86MMXTypeInContext(LLVMContextRef C); LLVMTypeRef LLVMVoidType(void); LLVMTypeRef LLVMLabelType(void); LLVMTypeRef LLVMOpaqueType(void); LLVMTypeRef LLVMX86MMXType(void); /* Operations on type handles */ LLVMTypeHandleRef LLVMCreateTypeHandle(LLVMTypeRef PotentiallyAbstractTy); void LLVMRefineType(LLVMTypeRef AbstractTy, LLVMTypeRef ConcreteTy); LLVMTypeRef LLVMResolveTypeHandle(LLVMTypeHandleRef TypeHandle); void LLVMDisposeTypeHandle(LLVMTypeHandleRef TypeHandle); /*===-- Values ------------------------------------------------------------===*/ /* The bulk of LLVM's object model consists of values, which comprise a very * rich type hierarchy. */ #define LLVM_FOR_EACH_VALUE_SUBCLASS(macro) \ macro(Argument) \ macro(BasicBlock) \ macro(InlineAsm) \ macro(User) \ macro(Constant) \ macro(ConstantAggregateZero) \ macro(ConstantArray) \ macro(ConstantExpr) \ macro(ConstantFP) \ macro(ConstantInt) \ macro(ConstantPointerNull) \ macro(ConstantStruct) \ macro(ConstantVector) \ macro(GlobalValue) \ macro(Function) \ macro(GlobalAlias) \ macro(GlobalVariable) \ macro(UndefValue) \ macro(Instruction) \ macro(BinaryOperator) \ macro(CallInst) \ macro(IntrinsicInst) \ macro(DbgInfoIntrinsic) \ macro(DbgDeclareInst) \ macro(EHSelectorInst) \ macro(MemIntrinsic) \ macro(MemCpyInst) \ macro(MemMoveInst) \ macro(MemSetInst) \ macro(CmpInst) \ macro(FCmpInst) \ macro(ICmpInst) \ macro(ExtractElementInst) \ macro(GetElementPtrInst) \ macro(InsertElementInst) \ macro(InsertValueInst) \ macro(PHINode) \ macro(SelectInst) \ macro(ShuffleVectorInst) \ macro(StoreInst) \ macro(TerminatorInst) \ macro(BranchInst) \ macro(InvokeInst) \ macro(ReturnInst) \ macro(SwitchInst) \ macro(UnreachableInst) \ macro(UnwindInst) \ macro(UnaryInstruction) \ macro(AllocaInst) \ macro(CastInst) \ macro(BitCastInst) \ macro(FPExtInst) \ macro(FPToSIInst) \ macro(FPToUIInst) \ macro(FPTruncInst) \ macro(IntToPtrInst) \ macro(PtrToIntInst) \ macro(SExtInst) \ macro(SIToFPInst) \ macro(TruncInst) \ macro(UIToFPInst) \ macro(ZExtInst) \ macro(ExtractValueInst) \ macro(LoadInst) \ macro(VAArgInst) /* Operations on all values */ LLVMTypeRef LLVMTypeOf(LLVMValueRef Val); const char *LLVMGetValueName(LLVMValueRef Val); void LLVMSetValueName(LLVMValueRef Val, const char *Name); void LLVMDumpValue(LLVMValueRef Val); void LLVMReplaceAllUsesWith(LLVMValueRef OldVal, LLVMValueRef NewVal); int LLVMHasMetadata(LLVMValueRef Val); LLVMValueRef LLVMGetMetadata(LLVMValueRef Val, unsigned KindID); void LLVMSetMetadata(LLVMValueRef Val, unsigned KindID, LLVMValueRef Node); /* Conversion functions. Return the input value if it is an instance of the specified class, otherwise NULL. See llvm::dyn_cast_or_null<>. */ #define LLVM_DECLARE_VALUE_CAST(name) \ LLVMValueRef LLVMIsA##name(LLVMValueRef Val); LLVM_FOR_EACH_VALUE_SUBCLASS(LLVM_DECLARE_VALUE_CAST) /* Operations on Uses */ LLVMUseRef LLVMGetFirstUse(LLVMValueRef Val); LLVMUseRef LLVMGetNextUse(LLVMUseRef U); LLVMValueRef LLVMGetUser(LLVMUseRef U); LLVMValueRef LLVMGetUsedValue(LLVMUseRef U); /* Operations on Users */ LLVMValueRef LLVMGetOperand(LLVMValueRef Val, unsigned Index); void LLVMSetOperand(LLVMValueRef User, unsigned Index, LLVMValueRef Val); int LLVMGetNumOperands(LLVMValueRef Val); /* Operations on constants of any type */ LLVMValueRef LLVMConstNull(LLVMTypeRef Ty); /* all zeroes */ LLVMValueRef LLVMConstAllOnes(LLVMTypeRef Ty); /* only for int/vector */ LLVMValueRef LLVMGetUndef(LLVMTypeRef Ty); LLVMBool LLVMIsConstant(LLVMValueRef Val); LLVMBool LLVMIsNull(LLVMValueRef Val); LLVMBool LLVMIsUndef(LLVMValueRef Val); LLVMValueRef LLVMConstPointerNull(LLVMTypeRef Ty); /* Operations on metadata */ LLVMValueRef LLVMMDStringInContext(LLVMContextRef C, const char *Str, unsigned SLen); LLVMValueRef LLVMMDString(const char *Str, unsigned SLen); LLVMValueRef LLVMMDNodeInContext(LLVMContextRef C, LLVMValueRef *Vals, unsigned Count); LLVMValueRef LLVMMDNode(LLVMValueRef *Vals, unsigned Count); /* Operations on scalar constants */ LLVMValueRef LLVMConstInt(LLVMTypeRef IntTy, unsigned long long N, LLVMBool SignExtend); LLVMValueRef LLVMConstIntOfString(LLVMTypeRef IntTy, const char *Text, uint8_t Radix); LLVMValueRef LLVMConstIntOfStringAndSize(LLVMTypeRef IntTy, const char *Text, unsigned SLen, uint8_t Radix); LLVMValueRef LLVMConstReal(LLVMTypeRef RealTy, double N); LLVMValueRef LLVMConstRealOfString(LLVMTypeRef RealTy, const char *Text); LLVMValueRef LLVMConstRealOfStringAndSize(LLVMTypeRef RealTy, const char *Text, unsigned SLen); unsigned long long LLVMConstIntGetZExtValue(LLVMValueRef ConstantVal); long long LLVMConstIntGetSExtValue(LLVMValueRef ConstantVal); /* Operations on composite constants */ LLVMValueRef LLVMConstStringInContext(LLVMContextRef C, const char *Str, unsigned Length, LLVMBool DontNullTerminate); LLVMValueRef LLVMConstStructInContext(LLVMContextRef C, LLVMValueRef *ConstantVals, unsigned Count, LLVMBool Packed); LLVMValueRef LLVMConstString(const char *Str, unsigned Length, LLVMBool DontNullTerminate); LLVMValueRef LLVMConstArray(LLVMTypeRef ElementTy, LLVMValueRef *ConstantVals, unsigned Length); LLVMValueRef LLVMConstStruct(LLVMValueRef *ConstantVals, unsigned Count, LLVMBool Packed); LLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals, unsigned Size); /* Constant expressions */ LLVMOpcode LLVMGetConstOpcode(LLVMValueRef ConstantVal); LLVMValueRef LLVMAlignOf(LLVMTypeRef Ty); LLVMValueRef LLVMSizeOf(LLVMTypeRef Ty); LLVMValueRef LLVMConstNeg(LLVMValueRef ConstantVal); LLVMValueRef LLVMConstNSWNeg(LLVMValueRef ConstantVal); LLVMValueRef LLVMConstNUWNeg(LLVMValueRef ConstantVal); LLVMValueRef LLVMConstFNeg(LLVMValueRef ConstantVal); LLVMValueRef LLVMConstNot(LLVMValueRef ConstantVal); LLVMValueRef LLVMConstAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); LLVMValueRef LLVMConstNSWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); LLVMValueRef LLVMConstNUWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); LLVMValueRef LLVMConstFAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); LLVMValueRef LLVMConstSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); LLVMValueRef LLVMConstNSWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); LLVMValueRef LLVMConstNUWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); LLVMValueRef LLVMConstFSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); LLVMValueRef LLVMConstMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); LLVMValueRef LLVMConstNSWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); LLVMValueRef LLVMConstNUWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); LLVMValueRef LLVMConstFMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); LLVMValueRef LLVMConstUDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); LLVMValueRef LLVMConstSDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); LLVMValueRef LLVMConstExactSDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); LLVMValueRef LLVMConstFDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); LLVMValueRef LLVMConstURem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); LLVMValueRef LLVMConstSRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); LLVMValueRef LLVMConstFRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); LLVMValueRef LLVMConstAnd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); LLVMValueRef LLVMConstOr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); LLVMValueRef LLVMConstXor(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); LLVMValueRef LLVMConstICmp(LLVMIntPredicate Predicate, LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); LLVMValueRef LLVMConstFCmp(LLVMRealPredicate Predicate, LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); LLVMValueRef LLVMConstShl(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); LLVMValueRef LLVMConstLShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); LLVMValueRef LLVMConstAShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); LLVMValueRef LLVMConstGEP(LLVMValueRef ConstantVal, LLVMValueRef *ConstantIndices, unsigned NumIndices); LLVMValueRef LLVMConstInBoundsGEP(LLVMValueRef ConstantVal, LLVMValueRef *ConstantIndices, unsigned NumIndices); LLVMValueRef LLVMConstTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType); LLVMValueRef LLVMConstSExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType); LLVMValueRef LLVMConstZExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType); LLVMValueRef LLVMConstFPTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType); LLVMValueRef LLVMConstFPExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType); LLVMValueRef LLVMConstUIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType); LLVMValueRef LLVMConstSIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType); LLVMValueRef LLVMConstFPToUI(LLVMValueRef ConstantVal, LLVMTypeRef ToType); LLVMValueRef LLVMConstFPToSI(LLVMValueRef ConstantVal, LLVMTypeRef ToType); LLVMValueRef LLVMConstPtrToInt(LLVMValueRef ConstantVal, LLVMTypeRef ToType); LLVMValueRef LLVMConstIntToPtr(LLVMValueRef ConstantVal, LLVMTypeRef ToType); LLVMValueRef LLVMConstBitCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType); LLVMValueRef LLVMConstZExtOrBitCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType); LLVMValueRef LLVMConstSExtOrBitCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType); LLVMValueRef LLVMConstTruncOrBitCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType); LLVMValueRef LLVMConstPointerCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType); LLVMValueRef LLVMConstIntCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType, LLVMBool isSigned); LLVMValueRef LLVMConstFPCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType); LLVMValueRef LLVMConstSelect(LLVMValueRef ConstantCondition, LLVMValueRef ConstantIfTrue, LLVMValueRef ConstantIfFalse); LLVMValueRef LLVMConstExtractElement(LLVMValueRef VectorConstant, LLVMValueRef IndexConstant); LLVMValueRef LLVMConstInsertElement(LLVMValueRef VectorConstant, LLVMValueRef ElementValueConstant, LLVMValueRef IndexConstant); LLVMValueRef LLVMConstShuffleVector(LLVMValueRef VectorAConstant, LLVMValueRef VectorBConstant, LLVMValueRef MaskConstant); LLVMValueRef LLVMConstExtractValue(LLVMValueRef AggConstant, unsigned *IdxList, unsigned NumIdx); LLVMValueRef LLVMConstInsertValue(LLVMValueRef AggConstant, LLVMValueRef ElementValueConstant, unsigned *IdxList, unsigned NumIdx); LLVMValueRef LLVMConstInlineAsm(LLVMTypeRef Ty, const char *AsmString, const char *Constraints, LLVMBool HasSideEffects, LLVMBool IsAlignStack); LLVMValueRef LLVMBlockAddress(LLVMValueRef F, LLVMBasicBlockRef BB); /* Operations on global variables, functions, and aliases (globals) */ LLVMModuleRef LLVMGetGlobalParent(LLVMValueRef Global); LLVMBool LLVMIsDeclaration(LLVMValueRef Global); LLVMLinkage LLVMGetLinkage(LLVMValueRef Global); void LLVMSetLinkage(LLVMValueRef Global, LLVMLinkage Linkage); const char *LLVMGetSection(LLVMValueRef Global); void LLVMSetSection(LLVMValueRef Global, const char *Section); LLVMVisibility LLVMGetVisibility(LLVMValueRef Global); void LLVMSetVisibility(LLVMValueRef Global, LLVMVisibility Viz); unsigned LLVMGetAlignment(LLVMValueRef Global); void LLVMSetAlignment(LLVMValueRef Global, unsigned Bytes); /* Operations on global variables */ LLVMValueRef LLVMAddGlobal(LLVMModuleRef M, LLVMTypeRef Ty, const char *Name); LLVMValueRef LLVMAddGlobalInAddressSpace(LLVMModuleRef M, LLVMTypeRef Ty, const char *Name, unsigned AddressSpace); LLVMValueRef LLVMGetNamedGlobal(LLVMModuleRef M, const char *Name); LLVMValueRef LLVMGetFirstGlobal(LLVMModuleRef M); LLVMValueRef LLVMGetLastGlobal(LLVMModuleRef M); LLVMValueRef LLVMGetNextGlobal(LLVMValueRef GlobalVar); LLVMValueRef LLVMGetPreviousGlobal(LLVMValueRef GlobalVar); void LLVMDeleteGlobal(LLVMValueRef GlobalVar); LLVMValueRef LLVMGetInitializer(LLVMValueRef GlobalVar); void LLVMSetInitializer(LLVMValueRef GlobalVar, LLVMValueRef ConstantVal); LLVMBool LLVMIsThreadLocal(LLVMValueRef GlobalVar); void LLVMSetThreadLocal(LLVMValueRef GlobalVar, LLVMBool IsThreadLocal); LLVMBool LLVMIsGlobalConstant(LLVMValueRef GlobalVar); void LLVMSetGlobalConstant(LLVMValueRef GlobalVar, LLVMBool IsConstant); /* Operations on aliases */ LLVMValueRef LLVMAddAlias(LLVMModuleRef M, LLVMTypeRef Ty, LLVMValueRef Aliasee, const char *Name); /* Operations on functions */ LLVMValueRef LLVMAddFunction(LLVMModuleRef M, const char *Name, LLVMTypeRef FunctionTy); LLVMValueRef LLVMGetNamedFunction(LLVMModuleRef M, const char *Name); LLVMValueRef LLVMGetFirstFunction(LLVMModuleRef M); LLVMValueRef LLVMGetLastFunction(LLVMModuleRef M); LLVMValueRef LLVMGetNextFunction(LLVMValueRef Fn); LLVMValueRef LLVMGetPreviousFunction(LLVMValueRef Fn); void LLVMDeleteFunction(LLVMValueRef Fn); unsigned LLVMGetIntrinsicID(LLVMValueRef Fn); unsigned LLVMGetFunctionCallConv(LLVMValueRef Fn); void LLVMSetFunctionCallConv(LLVMValueRef Fn, unsigned CC); const char *LLVMGetGC(LLVMValueRef Fn); void LLVMSetGC(LLVMValueRef Fn, const char *Name); void LLVMAddFunctionAttr(LLVMValueRef Fn, LLVMAttribute PA); LLVMAttribute LLVMGetFunctionAttr(LLVMValueRef Fn); void LLVMRemoveFunctionAttr(LLVMValueRef Fn, LLVMAttribute PA); /* Operations on parameters */ unsigned LLVMCountParams(LLVMValueRef Fn); void LLVMGetParams(LLVMValueRef Fn, LLVMValueRef *Params); LLVMValueRef LLVMGetParam(LLVMValueRef Fn, unsigned Index); LLVMValueRef LLVMGetParamParent(LLVMValueRef Inst); LLVMValueRef LLVMGetFirstParam(LLVMValueRef Fn); LLVMValueRef LLVMGetLastParam(LLVMValueRef Fn); LLVMValueRef LLVMGetNextParam(LLVMValueRef Arg); LLVMValueRef LLVMGetPreviousParam(LLVMValueRef Arg); void LLVMAddAttribute(LLVMValueRef Arg, LLVMAttribute PA); void LLVMRemoveAttribute(LLVMValueRef Arg, LLVMAttribute PA); LLVMAttribute LLVMGetAttribute(LLVMValueRef Arg); void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned align); /* Operations on basic blocks */ LLVMValueRef LLVMBasicBlockAsValue(LLVMBasicBlockRef BB); LLVMBool LLVMValueIsBasicBlock(LLVMValueRef Val); LLVMBasicBlockRef LLVMValueAsBasicBlock(LLVMValueRef Val); LLVMValueRef LLVMGetBasicBlockParent(LLVMBasicBlockRef BB); unsigned LLVMCountBasicBlocks(LLVMValueRef Fn); void LLVMGetBasicBlocks(LLVMValueRef Fn, LLVMBasicBlockRef *BasicBlocks); LLVMBasicBlockRef LLVMGetFirstBasicBlock(LLVMValueRef Fn); LLVMBasicBlockRef LLVMGetLastBasicBlock(LLVMValueRef Fn); LLVMBasicBlockRef LLVMGetNextBasicBlock(LLVMBasicBlockRef BB); LLVMBasicBlockRef LLVMGetPreviousBasicBlock(LLVMBasicBlockRef BB); LLVMBasicBlockRef LLVMGetEntryBasicBlock(LLVMValueRef Fn); LLVMBasicBlockRef LLVMAppendBasicBlockInContext(LLVMContextRef C, LLVMValueRef Fn, const char *Name); LLVMBasicBlockRef LLVMInsertBasicBlockInContext(LLVMContextRef C, LLVMBasicBlockRef BB, const char *Name); LLVMBasicBlockRef LLVMAppendBasicBlock(LLVMValueRef Fn, const char *Name); LLVMBasicBlockRef LLVMInsertBasicBlock(LLVMBasicBlockRef InsertBeforeBB, const char *Name); void LLVMDeleteBasicBlock(LLVMBasicBlockRef BB); void LLVMMoveBasicBlockBefore(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos); void LLVMMoveBasicBlockAfter(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos); /* Operations on instructions */ LLVMBasicBlockRef LLVMGetInstructionParent(LLVMValueRef Inst); LLVMValueRef LLVMGetFirstInstruction(LLVMBasicBlockRef BB); LLVMValueRef LLVMGetLastInstruction(LLVMBasicBlockRef BB); LLVMValueRef LLVMGetNextInstruction(LLVMValueRef Inst); LLVMValueRef LLVMGetPreviousInstruction(LLVMValueRef Inst); /* Operations on call sites */ void LLVMSetInstructionCallConv(LLVMValueRef Instr, unsigned CC); unsigned LLVMGetInstructionCallConv(LLVMValueRef Instr); void LLVMAddInstrAttribute(LLVMValueRef Instr, unsigned index, LLVMAttribute); void LLVMRemoveInstrAttribute(LLVMValueRef Instr, unsigned index, LLVMAttribute); void LLVMSetInstrParamAlignment(LLVMValueRef Instr, unsigned index, unsigned align); /* Operations on call instructions (only) */ LLVMBool LLVMIsTailCall(LLVMValueRef CallInst); void LLVMSetTailCall(LLVMValueRef CallInst, LLVMBool IsTailCall); /* Operations on phi nodes */ void LLVMAddIncoming(LLVMValueRef PhiNode, LLVMValueRef *IncomingValues, LLVMBasicBlockRef *IncomingBlocks, unsigned Count); unsigned LLVMCountIncoming(LLVMValueRef PhiNode); LLVMValueRef LLVMGetIncomingValue(LLVMValueRef PhiNode, unsigned Index); LLVMBasicBlockRef LLVMGetIncomingBlock(LLVMValueRef PhiNode, unsigned Index); /*===-- Instruction builders ----------------------------------------------===*/ /* An instruction builder represents a point within a basic block, and is the * exclusive means of building instructions using the C interface. */ LLVMBuilderRef LLVMCreateBuilderInContext(LLVMContextRef C); LLVMBuilderRef LLVMCreateBuilder(void); void LLVMPositionBuilder(LLVMBuilderRef Builder, LLVMBasicBlockRef Block, LLVMValueRef Instr); void LLVMPositionBuilderBefore(LLVMBuilderRef Builder, LLVMValueRef Instr); void LLVMPositionBuilderAtEnd(LLVMBuilderRef Builder, LLVMBasicBlockRef Block); LLVMBasicBlockRef LLVMGetInsertBlock(LLVMBuilderRef Builder); void LLVMClearInsertionPosition(LLVMBuilderRef Builder); void LLVMInsertIntoBuilder(LLVMBuilderRef Builder, LLVMValueRef Instr); void LLVMInsertIntoBuilderWithName(LLVMBuilderRef Builder, LLVMValueRef Instr, const char *Name); void LLVMDisposeBuilder(LLVMBuilderRef Builder); /* Metadata */ void LLVMSetCurrentDebugLocation(LLVMBuilderRef Builder, LLVMValueRef L); LLVMValueRef LLVMGetCurrentDebugLocation(LLVMBuilderRef Builder); void LLVMSetInstDebugLocation(LLVMBuilderRef Builder, LLVMValueRef Inst); /* Terminators */ LLVMValueRef LLVMBuildRetVoid(LLVMBuilderRef); LLVMValueRef LLVMBuildRet(LLVMBuilderRef, LLVMValueRef V); LLVMValueRef LLVMBuildAggregateRet(LLVMBuilderRef, LLVMValueRef *RetVals, unsigned N); LLVMValueRef LLVMBuildBr(LLVMBuilderRef, LLVMBasicBlockRef Dest); LLVMValueRef LLVMBuildCondBr(LLVMBuilderRef, LLVMValueRef If, LLVMBasicBlockRef Then, LLVMBasicBlockRef Else); LLVMValueRef LLVMBuildSwitch(LLVMBuilderRef, LLVMValueRef V, LLVMBasicBlockRef Else, unsigned NumCases); LLVMValueRef LLVMBuildIndirectBr(LLVMBuilderRef B, LLVMValueRef Addr, unsigned NumDests); LLVMValueRef LLVMBuildInvoke(LLVMBuilderRef, LLVMValueRef Fn, LLVMValueRef *Args, unsigned NumArgs, LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch, const char *Name); LLVMValueRef LLVMBuildUnwind(LLVMBuilderRef); LLVMValueRef LLVMBuildUnreachable(LLVMBuilderRef); /* Add a case to the switch instruction */ void LLVMAddCase(LLVMValueRef Switch, LLVMValueRef OnVal, LLVMBasicBlockRef Dest); /* Add a destination to the indirectbr instruction */ void LLVMAddDestination(LLVMValueRef IndirectBr, LLVMBasicBlockRef Dest); /* Arithmetic */ LLVMValueRef LLVMBuildAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name); LLVMValueRef LLVMBuildNSWAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name); LLVMValueRef LLVMBuildNUWAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name); LLVMValueRef LLVMBuildFAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name); LLVMValueRef LLVMBuildSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name); LLVMValueRef LLVMBuildNSWSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name); LLVMValueRef LLVMBuildNUWSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name); LLVMValueRef LLVMBuildFSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name); LLVMValueRef LLVMBuildMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name); LLVMValueRef LLVMBuildNSWMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name); LLVMValueRef LLVMBuildNUWMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name); LLVMValueRef LLVMBuildFMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name); LLVMValueRef LLVMBuildUDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name); LLVMValueRef LLVMBuildSDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name); LLVMValueRef LLVMBuildExactSDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name); LLVMValueRef LLVMBuildFDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name); LLVMValueRef LLVMBuildURem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name); LLVMValueRef LLVMBuildSRem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name); LLVMValueRef LLVMBuildFRem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name); LLVMValueRef LLVMBuildShl(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name); LLVMValueRef LLVMBuildLShr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name); LLVMValueRef LLVMBuildAShr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name); LLVMValueRef LLVMBuildAnd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name); LLVMValueRef LLVMBuildOr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name); LLVMValueRef LLVMBuildXor(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name); LLVMValueRef LLVMBuildBinOp(LLVMBuilderRef B, LLVMOpcode Op, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name); LLVMValueRef LLVMBuildNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name); LLVMValueRef LLVMBuildNSWNeg(LLVMBuilderRef B, LLVMValueRef V, const char *Name); LLVMValueRef LLVMBuildNUWNeg(LLVMBuilderRef B, LLVMValueRef V, const char *Name); LLVMValueRef LLVMBuildFNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name); LLVMValueRef LLVMBuildNot(LLVMBuilderRef, LLVMValueRef V, const char *Name); /* Memory */ LLVMValueRef LLVMBuildMalloc(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name); LLVMValueRef LLVMBuildArrayMalloc(LLVMBuilderRef, LLVMTypeRef Ty, LLVMValueRef Val, const char *Name); LLVMValueRef LLVMBuildAlloca(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name); LLVMValueRef LLVMBuildArrayAlloca(LLVMBuilderRef, LLVMTypeRef Ty, LLVMValueRef Val, const char *Name); LLVMValueRef LLVMBuildFree(LLVMBuilderRef, LLVMValueRef PointerVal); LLVMValueRef LLVMBuildLoad(LLVMBuilderRef, LLVMValueRef PointerVal, const char *Name); LLVMValueRef LLVMBuildStore(LLVMBuilderRef, LLVMValueRef Val, LLVMValueRef Ptr); LLVMValueRef LLVMBuildGEP(LLVMBuilderRef B, LLVMValueRef Pointer, LLVMValueRef *Indices, unsigned NumIndices, const char *Name); LLVMValueRef LLVMBuildInBoundsGEP(LLVMBuilderRef B, LLVMValueRef Pointer, LLVMValueRef *Indices, unsigned NumIndices, const char *Name); LLVMValueRef LLVMBuildStructGEP(LLVMBuilderRef B, LLVMValueRef Pointer, unsigned Idx, const char *Name); LLVMValueRef LLVMBuildGlobalString(LLVMBuilderRef B, const char *Str, const char *Name); LLVMValueRef LLVMBuildGlobalStringPtr(LLVMBuilderRef B, const char *Str, const char *Name); /* Casts */ LLVMValueRef LLVMBuildTrunc(LLVMBuilderRef, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name); LLVMValueRef LLVMBuildZExt(LLVMBuilderRef, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name); LLVMValueRef LLVMBuildSExt(LLVMBuilderRef, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name); LLVMValueRef LLVMBuildFPToUI(LLVMBuilderRef, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name); LLVMValueRef LLVMBuildFPToSI(LLVMBuilderRef, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name); LLVMValueRef LLVMBuildUIToFP(LLVMBuilderRef, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name); LLVMValueRef LLVMBuildSIToFP(LLVMBuilderRef, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name); LLVMValueRef LLVMBuildFPTrunc(LLVMBuilderRef, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name); LLVMValueRef LLVMBuildFPExt(LLVMBuilderRef, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name); LLVMValueRef LLVMBuildPtrToInt(LLVMBuilderRef, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name); LLVMValueRef LLVMBuildIntToPtr(LLVMBuilderRef, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name); LLVMValueRef LLVMBuildBitCast(LLVMBuilderRef, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name); LLVMValueRef LLVMBuildZExtOrBitCast(LLVMBuilderRef, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name); LLVMValueRef LLVMBuildSExtOrBitCast(LLVMBuilderRef, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name); LLVMValueRef LLVMBuildTruncOrBitCast(LLVMBuilderRef, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name); LLVMValueRef LLVMBuildCast(LLVMBuilderRef B, LLVMOpcode Op, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name); LLVMValueRef LLVMBuildPointerCast(LLVMBuilderRef, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name); LLVMValueRef LLVMBuildIntCast(LLVMBuilderRef, LLVMValueRef Val, /*Signed cast!*/ LLVMTypeRef DestTy, const char *Name); LLVMValueRef LLVMBuildFPCast(LLVMBuilderRef, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name); /* Comparisons */ LLVMValueRef LLVMBuildICmp(LLVMBuilderRef, LLVMIntPredicate Op, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name); LLVMValueRef LLVMBuildFCmp(LLVMBuilderRef, LLVMRealPredicate Op, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name); /* Miscellaneous instructions */ LLVMValueRef LLVMBuildPhi(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name); LLVMValueRef LLVMBuildCall(LLVMBuilderRef, LLVMValueRef Fn, LLVMValueRef *Args, unsigned NumArgs, const char *Name); LLVMValueRef LLVMBuildSelect(LLVMBuilderRef, LLVMValueRef If, LLVMValueRef Then, LLVMValueRef Else, const char *Name); LLVMValueRef LLVMBuildVAArg(LLVMBuilderRef, LLVMValueRef List, LLVMTypeRef Ty, const char *Name); LLVMValueRef LLVMBuildExtractElement(LLVMBuilderRef, LLVMValueRef VecVal, LLVMValueRef Index, const char *Name); LLVMValueRef LLVMBuildInsertElement(LLVMBuilderRef, LLVMValueRef VecVal, LLVMValueRef EltVal, LLVMValueRef Index, const char *Name); LLVMValueRef LLVMBuildShuffleVector(LLVMBuilderRef, LLVMValueRef V1, LLVMValueRef V2, LLVMValueRef Mask, const char *Name); LLVMValueRef LLVMBuildExtractValue(LLVMBuilderRef, LLVMValueRef AggVal, unsigned Index, const char *Name); LLVMValueRef LLVMBuildInsertValue(LLVMBuilderRef, LLVMValueRef AggVal, LLVMValueRef EltVal, unsigned Index, const char *Name); LLVMValueRef LLVMBuildIsNull(LLVMBuilderRef, LLVMValueRef Val, const char *Name); LLVMValueRef LLVMBuildIsNotNull(LLVMBuilderRef, LLVMValueRef Val, const char *Name); LLVMValueRef LLVMBuildPtrDiff(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name); /*===-- Module providers --------------------------------------------------===*/ /* Changes the type of M so it can be passed to FunctionPassManagers and the * JIT. They take ModuleProviders for historical reasons. */ LLVMModuleProviderRef LLVMCreateModuleProviderForExistingModule(LLVMModuleRef M); /* Destroys the module M. */ void LLVMDisposeModuleProvider(LLVMModuleProviderRef M); /*===-- Memory buffers ----------------------------------------------------===*/ LLVMBool LLVMCreateMemoryBufferWithContentsOfFile(const char *Path, LLVMMemoryBufferRef *OutMemBuf, char **OutMessage); LLVMBool LLVMCreateMemoryBufferWithSTDIN(LLVMMemoryBufferRef *OutMemBuf, char **OutMessage); void LLVMDisposeMemoryBuffer(LLVMMemoryBufferRef MemBuf); /*===-- Pass Managers -----------------------------------------------------===*/ /** Constructs a new whole-module pass pipeline. This type of pipeline is suitable for link-time optimization and whole-module transformations. See llvm::PassManager::PassManager. */ LLVMPassManagerRef LLVMCreatePassManager(void); /** Constructs a new function-by-function pass pipeline over the module provider. It does not take ownership of the module provider. This type of pipeline is suitable for code generation and JIT compilation tasks. See llvm::FunctionPassManager::FunctionPassManager. */ LLVMPassManagerRef LLVMCreateFunctionPassManagerForModule(LLVMModuleRef M); /** Deprecated: Use LLVMCreateFunctionPassManagerForModule instead. */ LLVMPassManagerRef LLVMCreateFunctionPassManager(LLVMModuleProviderRef MP); /** Initializes, executes on the provided module, and finalizes all of the passes scheduled in the pass manager. Returns 1 if any of the passes modified the module, 0 otherwise. See llvm::PassManager::run(Module&). */ LLVMBool LLVMRunPassManager(LLVMPassManagerRef PM, LLVMModuleRef M); /** Initializes all of the function passes scheduled in the function pass manager. Returns 1 if any of the passes modified the module, 0 otherwise. See llvm::FunctionPassManager::doInitialization. */ LLVMBool LLVMInitializeFunctionPassManager(LLVMPassManagerRef FPM); /** Executes all of the function passes scheduled in the function pass manager on the provided function. Returns 1 if any of the passes modified the function, false otherwise. See llvm::FunctionPassManager::run(Function&). */ LLVMBool LLVMRunFunctionPassManager(LLVMPassManagerRef FPM, LLVMValueRef F); /** Finalizes all of the function passes scheduled in in the function pass manager. Returns 1 if any of the passes modified the module, 0 otherwise. See llvm::FunctionPassManager::doFinalization. */ LLVMBool LLVMFinalizeFunctionPassManager(LLVMPassManagerRef FPM); /** Frees the memory of a pass pipeline. For function pipelines, does not free the module provider. See llvm::PassManagerBase::~PassManagerBase. */ void LLVMDisposePassManager(LLVMPassManagerRef PM); #ifdef __cplusplus } namespace llvm { class MemoryBuffer; class PassManagerBase; #define DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref) \ inline ty *unwrap(ref P) { \ return reinterpret_cast(P); \ } \ \ inline ref wrap(const ty *P) { \ return reinterpret_cast(const_cast(P)); \ } #define DEFINE_ISA_CONVERSION_FUNCTIONS(ty, ref) \ DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref) \ \ template \ inline T *unwrap(ref P) { \ return cast(unwrap(P)); \ } #define DEFINE_STDCXX_CONVERSION_FUNCTIONS(ty, ref) \ DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref) \ \ template \ inline T *unwrap(ref P) { \ T *Q = (T*)unwrap(P); \ assert(Q && "Invalid cast!"); \ return Q; \ } DEFINE_ISA_CONVERSION_FUNCTIONS (Type, LLVMTypeRef ) DEFINE_ISA_CONVERSION_FUNCTIONS (Value, LLVMValueRef ) DEFINE_SIMPLE_CONVERSION_FUNCTIONS(Module, LLVMModuleRef ) DEFINE_SIMPLE_CONVERSION_FUNCTIONS(BasicBlock, LLVMBasicBlockRef ) DEFINE_SIMPLE_CONVERSION_FUNCTIONS(IRBuilder<>, LLVMBuilderRef ) DEFINE_SIMPLE_CONVERSION_FUNCTIONS(PATypeHolder, LLVMTypeHandleRef ) DEFINE_SIMPLE_CONVERSION_FUNCTIONS(MemoryBuffer, LLVMMemoryBufferRef ) DEFINE_SIMPLE_CONVERSION_FUNCTIONS(LLVMContext, LLVMContextRef ) DEFINE_SIMPLE_CONVERSION_FUNCTIONS(Use, LLVMUseRef ) DEFINE_STDCXX_CONVERSION_FUNCTIONS(PassManagerBase, LLVMPassManagerRef ) /* LLVMModuleProviderRef exists for historical reasons, but now just holds a * Module. */ inline Module *unwrap(LLVMModuleProviderRef MP) { return reinterpret_cast(MP); } #undef DEFINE_STDCXX_CONVERSION_FUNCTIONS #undef DEFINE_ISA_CONVERSION_FUNCTIONS #undef DEFINE_SIMPLE_CONVERSION_FUNCTIONS /* Specialized opaque context conversions. */ inline LLVMContext **unwrap(LLVMContextRef* Tys) { return reinterpret_cast(Tys); } inline LLVMContextRef *wrap(const LLVMContext **Tys) { return reinterpret_cast(const_cast(Tys)); } /* Specialized opaque type conversions. */ inline Type **unwrap(LLVMTypeRef* Tys) { return reinterpret_cast(Tys); } inline LLVMTypeRef *wrap(const Type **Tys) { return reinterpret_cast(const_cast(Tys)); } /* Specialized opaque value conversions. */ inline Value **unwrap(LLVMValueRef *Vals) { return reinterpret_cast(Vals); } template inline T **unwrap(LLVMValueRef *Vals, unsigned Length) { #if DEBUG for (LLVMValueRef *I = Vals, *E = Vals + Length; I != E; ++I) cast(*I); #endif return reinterpret_cast(Vals); } inline LLVMValueRef *wrap(const Value **Vals) { return reinterpret_cast(const_cast(Vals)); } } #endif /* !defined(__cplusplus) */ #endif /* !defined(LLVM_C_CORE_H) */