diff options
author | rumpf_a@web.de <> | 2010-01-03 12:31:21 +0100 |
---|---|---|
committer | rumpf_a@web.de <> | 2010-01-03 12:31:21 +0100 |
commit | a58a2f3823c33104992dc0e4129fa53e66a18f44 (patch) | |
tree | af97f1c6634d7ef2d4468c70607c20731e6c1512 /llvm | |
parent | 2169fd63bdf9caf539ca7ca5b661ee703206500c (diff) | |
download | Nim-a58a2f3823c33104992dc0e4129fa53e66a18f44.tar.gz |
better subscript overloading
Diffstat (limited to 'llvm')
-rwxr-xr-x | llvm/llvm.h | 1418 | ||||
-rw-r--r-- | llvm/llvm.nim | 1452 | ||||
-rwxr-xr-x | llvm/llvm.pas | 1034 | ||||
-rw-r--r-- | llvm/llvm_orig.nim | 1569 |
4 files changed, 5473 insertions, 0 deletions
diff --git a/llvm/llvm.h b/llvm/llvm.h new file mode 100755 index 000000000..a873b44eb --- /dev/null +++ b/llvm/llvm.h @@ -0,0 +1,1418 @@ +/* Core.h */ +/* 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; + +/* Used to provide a module to JIT or interpreter. + * See the llvm::ModuleProvider class. + */ +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 iterate through the uses of a Value, allowing access to all Values + * that use this Value. See the llvm::Use and llvm::value_use_iterator classes. + */ +typedef struct LLVMOpaqueUseIterator *LLVMUseIteratorRef; + +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, + LLVMNoCaptureAttribute = 1<<21, + LLVMNoRedZoneAttribute = 1<<22, + LLVMNoImplicitFloatAttribute = 1<<23, + LLVMNakedAttribute = 1<<24, + LLVMInlineHintAttribute = 1<<25 +} LLVMAttribute; + +typedef enum { + LLVMRet = 1, + LLVMBr = 2, + LLVMSwitch = 3, + LLVMInvoke = 4, + LLVMUnwind = 5, + LLVMUnreachable = 6, + LLVMAdd = 7, + LLVMFAdd = 8, + LLVMSub = 9, + LLVMFSub = 10, + LLVMMul = 11, + LLVMFMul = 12, + LLVMUDiv = 13, + LLVMSDiv = 14, + LLVMFDiv = 15, + LLVMURem = 16, + LLVMSRem = 17, + LLVMFRem = 18, + LLVMShl = 19, + LLVMLShr = 20, + LLVMAShr = 21, + LLVMAnd = 22, + LLVMOr = 23, + LLVMXor = 24, + LLVMMalloc = 25, + LLVMFree = 26, + LLVMAlloca = 27, + LLVMLoad = 28, + LLVMStore = 29, + LLVMGetElementPtr = 30, + LLVMTrunk = 31, + LLVMZExt = 32, + LLVMSExt = 33, + LLVMFPToUI = 34, + LLVMFPToSI = 35, + LLVMUIToFP = 36, + LLVMSIToFP = 37, + LLVMFPTrunc = 38, + LLVMFPExt = 39, + LLVMPtrToInt = 40, + LLVMIntToPtr = 41, + LLVMBitCast = 42, + LLVMICmp = 43, + LLVMFCmp = 44, + LLVMPHI = 45, + LLVMCall = 46, + LLVMSelect = 47, + LLVMVAArg = 50, + LLVMExtractElement = 51, + LLVMInsertElement = 52, + LLVMShuffleVector = 53, + LLVMExtractValue = 54, + LLVMInsertValue = 55 +} 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 */ +} 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, /**< Stand-in functions for streaming fns from + bitcode */ + LLVMCommonLinkage, /**< Tentative definitions */ + LLVMLinkerPrivateLinkage /**< Like Private, but linker removes. */ +} 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); + + +/*===-- Modules -----------------------------------------------------------===*/ + +/* Create and destroy contexts. */ +LLVMContextRef LLVMContextCreate(void); +LLVMContextRef LLVMGetGlobalContext(void); +void LLVMContextDispose(LLVMContextRef C); + +/* 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. */ +int 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); + + +/*===-- 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, + int IsVarArg); +int 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, int Packed); +LLVMTypeRef LLVMStructType(LLVMTypeRef *ElementTypes, unsigned ElementCount, + int Packed); +unsigned LLVMCountStructElementTypes(LLVMTypeRef StructTy); +void LLVMGetStructElementTypes(LLVMTypeRef StructTy, LLVMTypeRef *Dest); +int 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 LLVMVoidType(void); +LLVMTypeRef LLVMLabelType(void); +LLVMTypeRef LLVMOpaqueType(void); + +/* Operations on type handles */ +LLVMTypeHandleRef LLVMCreateTypeHandle(LLVMTypeRef PotentiallyAbstractTy); +void LLVMRefineType(LLVMTypeRef AbstractTy, LLVMTypeRef ConcreteTy); +LLVMTypeRef LLVMResolveTypeHandle(LLVMTypeHandleRef TypeHandle); +void LLVMDisposeTypeHandle(LLVMTypeHandleRef TypeHandle); + + + +/* 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); + +/* Conversion functions. Return the input value if it is an instance of the + specified class, otherwise NULL. See llvm::dyn_cast_or_null<>. */ +LLVMValueRef LLVMIsAArgument(LLVMValueRef Val); +LLVMValueRef LLVMIsABasicBlock(LLVMValueRef Val); +LLVMValueRef LLVMIsAInlineAsm(LLVMValueRef Val); +LLVMValueRef LLVMIsAUser(LLVMValueRef Val); +LLVMValueRef LLVMIsAConstant(LLVMValueRef Val); +LLVMValueRef LLVMIsAConstantAggregateZero(LLVMValueRef Val); +LLVMValueRef LLVMIsAConstantArray(LLVMValueRef Val); +LLVMValueRef LLVMIsAConstantExpr(LLVMValueRef Val); +LLVMValueRef LLVMIsAConstantFP(LLVMValueRef Val); +LLVMValueRef LLVMIsAConstantInt(LLVMValueRef Val); +LLVMValueRef LLVMIsAConstantPointerNull(LLVMValueRef Val); +LLVMValueRef LLVMIsAConstantStruct(LLVMValueRef Val); +LLVMValueRef LLVMIsAConstantVector(LLVMValueRef Val); +LLVMValueRef LLVMIsAGlobalValue(LLVMValueRef Val); +LLVMValueRef LLVMIsAFunction(LLVMValueRef Val); +LLVMValueRef LLVMIsAGlobalAlias(LLVMValueRef Val); +LLVMValueRef LLVMIsAGlobalVariable(LLVMValueRef Val); +LLVMValueRef LLVMIsAUndefValue(LLVMValueRef Val); +LLVMValueRef LLVMIsAInstruction(LLVMValueRef Val); +LLVMValueRef LLVMIsABinaryOperator(LLVMValueRef Val); +LLVMValueRef LLVMIsACallInst(LLVMValueRef Val); +LLVMValueRef LLVMIsAIntrinsicInst(LLVMValueRef Val); +LLVMValueRef LLVMIsADbgInfoIntrinsic(LLVMValueRef Val); +LLVMValueRef LLVMIsADbgDeclareInst(LLVMValueRef Val); +LLVMValueRef LLVMIsADbgFuncStartInst(LLVMValueRef Val); +LLVMValueRef LLVMIsADbgRegionEndInst(LLVMValueRef Val); +LLVMValueRef LLVMIsADbgRegionStartInst(LLVMValueRef Val); +LLVMValueRef LLVMIsADbgStopPointInst(LLVMValueRef Val); +LLVMValueRef LLVMIsAEHSelectorInst(LLVMValueRef Val); +LLVMValueRef LLVMIsAMemIntrinsic(LLVMValueRef Val); +LLVMValueRef LLVMIsAMemCpyInst(LLVMValueRef Val); +LLVMValueRef LLVMIsAMemMoveInst(LLVMValueRef Val); +LLVMValueRef LLVMIsAMemSetInst(LLVMValueRef Val); +LLVMValueRef LLVMIsACmpInst(LLVMValueRef Val); +LLVMValueRef LLVMIsAFCmpInst(LLVMValueRef Val); +LLVMValueRef LLVMIsAICmpInst(LLVMValueRef Val); +LLVMValueRef LLVMIsAExtractElementInst(LLVMValueRef Val); +LLVMValueRef LLVMIsAGetElementPtrInst(LLVMValueRef Val); +LLVMValueRef LLVMIsAInsertElementInst(LLVMValueRef Val); +LLVMValueRef LLVMIsAInsertValueInst(LLVMValueRef Val); +LLVMValueRef LLVMIsAPHINode(LLVMValueRef Val); +LLVMValueRef LLVMIsASelectInst(LLVMValueRef Val); +LLVMValueRef LLVMIsAShuffleVectorInst(LLVMValueRef Val); +LLVMValueRef LLVMIsAStoreInst(LLVMValueRef Val); +LLVMValueRef LLVMIsATerminatorInst(LLVMValueRef Val); +LLVMValueRef LLVMIsABranchInst(LLVMValueRef Val); +LLVMValueRef LLVMIsAInvokeInst(LLVMValueRef Val); +LLVMValueRef LLVMIsAReturnInst(LLVMValueRef Val); +LLVMValueRef LLVMIsASwitchInst(LLVMValueRef Val); +LLVMValueRef LLVMIsAUnreachableInst(LLVMValueRef Val); +LLVMValueRef LLVMIsAUnwindInst(LLVMValueRef Val); +LLVMValueRef LLVMIsAUnaryInstruction(LLVMValueRef Val); +LLVMValueRef LLVMIsAAllocationInst(LLVMValueRef Val); +LLVMValueRef LLVMIsAAllocaInst(LLVMValueRef Val); +LLVMValueRef LLVMIsACastInst(LLVMValueRef Val); +LLVMValueRef LLVMIsABitCastInst(LLVMValueRef Val); +LLVMValueRef LLVMIsAFPExtInst(LLVMValueRef Val); +LLVMValueRef LLVMIsAFPToSIInst(LLVMValueRef Val); +LLVMValueRef LLVMIsAFPToUIInst(LLVMValueRef Val); +LLVMValueRef LLVMIsAFPTruncInst(LLVMValueRef Val); +LLVMValueRef LLVMIsAIntToPtrInst(LLVMValueRef Val); +LLVMValueRef LLVMIsAPtrToIntInst(LLVMValueRef Val); +LLVMValueRef LLVMIsASExtInst(LLVMValueRef Val); +LLVMValueRef LLVMIsASIToFPInst(LLVMValueRef Val); +LLVMValueRef LLVMIsATruncInst(LLVMValueRef Val); +LLVMValueRef LLVMIsAUIToFPInst(LLVMValueRef Val); +LLVMValueRef LLVMIsAZExtInst(LLVMValueRef Val); +LLVMValueRef LLVMIsAExtractValueInst(LLVMValueRef Val); +LLVMValueRef LLVMIsAFreeInst(LLVMValueRef Val); +LLVMValueRef LLVMIsALoadInst(LLVMValueRef Val); +LLVMValueRef LLVMIsAVAArgInst(LLVMValueRef Val); + + +/* Operations on Uses */ +LLVMUseIteratorRef LLVMGetFirstUse(LLVMValueRef Val); +LLVMUseIteratorRef LLVMGetNextUse(LLVMUseIteratorRef U); +LLVMValueRef LLVMGetUser(LLVMUseIteratorRef U); +LLVMValueRef LLVMGetUsedValue(LLVMUseIteratorRef U); + +/* Operations on Users */ +LLVMValueRef LLVMGetOperand(LLVMValueRef Val, unsigned Index); + +/* Operations on constants of any type */ +LLVMValueRef LLVMConstNull(LLVMTypeRef Ty); /* all zeroes */ +LLVMValueRef LLVMConstAllOnes(LLVMTypeRef Ty); /* only for int/vector */ +LLVMValueRef LLVMGetUndef(LLVMTypeRef Ty); +int LLVMIsConstant(LLVMValueRef Val); +int LLVMIsNull(LLVMValueRef Val); +int LLVMIsUndef(LLVMValueRef Val); +LLVMValueRef LLVMConstPointerNull(LLVMTypeRef Ty); + +/* Operations on scalar constants */ +LLVMValueRef LLVMConstInt(LLVMTypeRef IntTy, unsigned long long N, + int 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, int DontNullTerminate); +LLVMValueRef LLVMConstStructInContext(LLVMContextRef C, + LLVMValueRef *ConstantVals, + unsigned Count, int Packed); + +LLVMValueRef LLVMConstString(const char *Str, unsigned Length, + int DontNullTerminate); +LLVMValueRef LLVMConstArray(LLVMTypeRef ElementTy, + LLVMValueRef *ConstantVals, unsigned Length); +LLVMValueRef LLVMConstStruct(LLVMValueRef *ConstantVals, unsigned Count, + int 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 LLVMConstFNeg(LLVMValueRef ConstantVal); +LLVMValueRef LLVMConstNot(LLVMValueRef ConstantVal); +LLVMValueRef LLVMConstAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); +LLVMValueRef LLVMConstNSWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); +LLVMValueRef LLVMConstFAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); +LLVMValueRef LLVMConstSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); +LLVMValueRef LLVMConstFSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); +LLVMValueRef LLVMConstMul(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, + unsigned 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, + int HasSideEffects); + +/* Operations on global variables, functions, and aliases (globals) */ +LLVMModuleRef LLVMGetGlobalParent(LLVMValueRef Global); +int 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 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); +int LLVMIsThreadLocal(LLVMValueRef GlobalVar); +void LLVMSetThreadLocal(LLVMValueRef GlobalVar, int IsThreadLocal); +int LLVMIsGlobalConstant(LLVMValueRef GlobalVar); +void LLVMSetGlobalConstant(LLVMValueRef GlobalVar, int 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); +int 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); + +/* 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) */ +int LLVMIsTailCall(LLVMValueRef CallInst); +void LLVMSetTailCall(LLVMValueRef CallInst, int 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); + +/* 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 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); + +/* Arithmetic */ +LLVMValueRef LLVMBuildAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, + const char *Name); +LLVMValueRef LLVMBuildNSWAdd(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 LLVMBuildFSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, + const char *Name); +LLVMValueRef LLVMBuildMul(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 LLVMBuildNeg(LLVMBuilderRef, 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 LLVMBuildPointerCast(LLVMBuilderRef, LLVMValueRef Val, + LLVMTypeRef DestTy, const char *Name); +LLVMValueRef LLVMBuildIntCast(LLVMBuilderRef, LLVMValueRef Val, + 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 --------------------------------------------------===*/ + +/* Encapsulates the module M in a module provider, taking ownership of the + * module. + * See the constructor llvm::ExistingModuleProvider::ExistingModuleProvider. + */ +LLVMModuleProviderRef +LLVMCreateModuleProviderForExistingModule(LLVMModuleRef M); + +/* Destroys the module provider MP as well as the contained module. + * See the destructor llvm::ModuleProvider::~ModuleProvider. + */ +void LLVMDisposeModuleProvider(LLVMModuleProviderRef MP); + + +/*===-- Memory buffers ----------------------------------------------------===*/ + +int LLVMCreateMemoryBufferWithContentsOfFile(const char *Path, + LLVMMemoryBufferRef *OutMemBuf, + char **OutMessage); +int 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 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&). */ +int 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. */ +int 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&). */ +int 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. */ +int 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); + + + +/* Analysis.h */ + +typedef enum { + LLVMAbortProcessAction, /* verifier will print to stderr and abort() */ + LLVMPrintMessageAction, /* verifier will print to stderr and return 1 */ + LLVMReturnStatusAction /* verifier will just return 1 */ +} LLVMVerifierFailureAction; + + +/* Verifies that a module is valid, taking the specified action if not. + Optionally returns a human-readable description of any invalid constructs. + OutMessage must be disposed with LLVMDisposeMessage. */ +int LLVMVerifyModule(LLVMModuleRef M, LLVMVerifierFailureAction Action, + char **OutMessage); + +/* Verifies that a single function is valid, taking the specified action. Useful + for debugging. */ +int LLVMVerifyFunction(LLVMValueRef Fn, LLVMVerifierFailureAction Action); + +/* Open up a ghostview window that displays the CFG of the current function. + Useful for debugging. */ +void LLVMViewFunctionCFG(LLVMValueRef Fn); +void LLVMViewFunctionCFGOnly(LLVMValueRef Fn); + +/* BitReader.h */ + +/* Builds a module from the bitcode in the specified memory buffer, returning a + reference to the module via the OutModule parameter. Returns 0 on success. + Optionally returns a human-readable error message via OutMessage. */ +int LLVMParseBitcode(LLVMMemoryBufferRef MemBuf, + LLVMModuleRef *OutModule, char **OutMessage); + +int LLVMParseBitcodeInContext(LLVMContextRef ContextRef, + LLVMMemoryBufferRef MemBuf, + LLVMModuleRef *OutModule, char **OutMessage); + +/* Reads a module from the specified path, returning via the OutMP parameter + a module provider which performs lazy deserialization. Returns 0 on success. + Optionally returns a human-readable error message via OutMessage. */ +int LLVMGetBitcodeModuleProvider(LLVMMemoryBufferRef MemBuf, + LLVMModuleProviderRef *OutMP, + char **OutMessage); + +int LLVMGetBitcodeModuleProviderInContext(LLVMContextRef ContextRef, + LLVMMemoryBufferRef MemBuf, + LLVMModuleProviderRef *OutMP, + char **OutMessage); + +/* BitWriter.h */ + +/*===-- Operations on modules ---------------------------------------------===*/ + +/* Writes a module to an open file descriptor. Returns 0 on success. + Closes the Handle. Use dup first if this is not what you want. */ +int LLVMWriteBitcodeToFileHandle(LLVMModuleRef M, int Handle); + +/* Writes a module to the specified path. Returns 0 on success. */ +int LLVMWriteBitcodeToFile(LLVMModuleRef M, const char *Path); + + +/* Target.h */ + +#define LLVMBigEndian 0 +#define LLVMLittleEndian 1 +typedef int LLVMByteOrdering; + +typedef struct LLVMOpaqueTargetData *LLVMTargetDataRef; +typedef struct LLVMStructLayout *LLVMStructLayoutRef; + +/*===-- Target Data -------------------------------------------------------===*/ + +/** Creates target data from a target layout string. + See the constructor llvm::TargetData::TargetData. */ +LLVMTargetDataRef LLVMCreateTargetData(const char *StringRep); + +/** Adds target data information to a pass manager. This does not take ownership + of the target data. + See the method llvm::PassManagerBase::add. */ +void LLVMAddTargetData(LLVMTargetDataRef, LLVMPassManagerRef); + +/** Converts target data to a target layout string. The string must be disposed + with LLVMDisposeMessage. + See the constructor llvm::TargetData::TargetData. */ +char *LLVMCopyStringRepOfTargetData(LLVMTargetDataRef); + +/** Returns the byte order of a target, either LLVMBigEndian or + LLVMLittleEndian. + See the method llvm::TargetData::isLittleEndian. */ +LLVMByteOrdering LLVMByteOrder(LLVMTargetDataRef); + +/** Returns the pointer size in bytes for a target. + See the method llvm::TargetData::getPointerSize. */ +unsigned LLVMPointerSize(LLVMTargetDataRef); + +/** Returns the integer type that is the same size as a pointer on a target. + See the method llvm::TargetData::getIntPtrType. */ +LLVMTypeRef LLVMIntPtrType(LLVMTargetDataRef); + +/** Computes the size of a type in bytes for a target. + See the method llvm::TargetData::getTypeSizeInBits. */ +unsigned long long LLVMSizeOfTypeInBits(LLVMTargetDataRef, LLVMTypeRef); + +/** Computes the storage size of a type in bytes for a target. + See the method llvm::TargetData::getTypeStoreSize. */ +unsigned long long LLVMStoreSizeOfType(LLVMTargetDataRef, LLVMTypeRef); + +/** Computes the ABI size of a type in bytes for a target. + See the method llvm::TargetData::getTypeAllocSize. */ +unsigned long long LLVMABISizeOfType(LLVMTargetDataRef, LLVMTypeRef); + +/** Computes the ABI alignment of a type in bytes for a target. + See the method llvm::TargetData::getTypeABISize. */ +unsigned LLVMABIAlignmentOfType(LLVMTargetDataRef, LLVMTypeRef); + +/** Computes the call frame alignment of a type in bytes for a target. + See the method llvm::TargetData::getTypeABISize. */ +unsigned LLVMCallFrameAlignmentOfType(LLVMTargetDataRef, LLVMTypeRef); + +/** Computes the preferred alignment of a type in bytes for a target. + See the method llvm::TargetData::getTypeABISize. */ +unsigned LLVMPreferredAlignmentOfType(LLVMTargetDataRef, LLVMTypeRef); + +/** Computes the preferred alignment of a global variable in bytes for a target. + See the method llvm::TargetData::getPreferredAlignment. */ +unsigned LLVMPreferredAlignmentOfGlobal(LLVMTargetDataRef, + LLVMValueRef GlobalVar); + +/** Computes the structure element that contains the byte offset for a target. + See the method llvm::StructLayout::getElementContainingOffset. */ +unsigned LLVMElementAtOffset(LLVMTargetDataRef, LLVMTypeRef StructTy, + unsigned long long Offset); + +/** Computes the byte offset of the indexed struct element for a target. + See the method llvm::StructLayout::getElementContainingOffset. */ +unsigned long long LLVMOffsetOfElement(LLVMTargetDataRef, LLVMTypeRef StructTy, + unsigned Element); + +/** Struct layouts are speculatively cached. If a TargetDataRef is alive when + types are being refined and removed, this method must be called whenever a + struct type is removed to avoid a dangling pointer in this cache. + See the method llvm::TargetData::InvalidateStructLayoutInfo. */ +void LLVMInvalidateStructLayout(LLVMTargetDataRef, LLVMTypeRef StructTy); + +/** Deallocates a TargetData. + See the destructor llvm::TargetData::~TargetData. */ +void LLVMDisposeTargetData(LLVMTargetDataRef); + + +/* ExecutionEngine.h */ +void LLVMLinkInJIT(void); +void LLVMLinkInInterpreter(void); + +typedef struct LLVMOpaqueGenericValue *LLVMGenericValueRef; +typedef struct LLVMOpaqueExecutionEngine *LLVMExecutionEngineRef; + +/*===-- Operations on generic values --------------------------------------===*/ + +LLVMGenericValueRef LLVMCreateGenericValueOfInt(LLVMTypeRef Ty, + unsigned long long N, + int IsSigned); + +LLVMGenericValueRef LLVMCreateGenericValueOfPointer(void *P); + +LLVMGenericValueRef LLVMCreateGenericValueOfFloat(LLVMTypeRef Ty, double N); + +unsigned LLVMGenericValueIntWidth(LLVMGenericValueRef GenValRef); + +unsigned long long LLVMGenericValueToInt(LLVMGenericValueRef GenVal, + int IsSigned); + +void *LLVMGenericValueToPointer(LLVMGenericValueRef GenVal); + +double LLVMGenericValueToFloat(LLVMTypeRef TyRef, LLVMGenericValueRef GenVal); + +void LLVMDisposeGenericValue(LLVMGenericValueRef GenVal); + +/*===-- Operations on execution engines -----------------------------------===*/ + +int LLVMCreateExecutionEngine(LLVMExecutionEngineRef *OutEE, + LLVMModuleProviderRef MP, + char **OutError); + +int LLVMCreateInterpreter(LLVMExecutionEngineRef *OutInterp, + LLVMModuleProviderRef MP, + char **OutError); + +int LLVMCreateJITCompiler(LLVMExecutionEngineRef *OutJIT, + LLVMModuleProviderRef MP, + unsigned OptLevel, + char **OutError); + +void LLVMDisposeExecutionEngine(LLVMExecutionEngineRef EE); + +void LLVMRunStaticConstructors(LLVMExecutionEngineRef EE); + +void LLVMRunStaticDestructors(LLVMExecutionEngineRef EE); + +int LLVMRunFunctionAsMain(LLVMExecutionEngineRef EE, LLVMValueRef F, + unsigned ArgC, const char * const *ArgV, + const char * const *EnvP); + +LLVMGenericValueRef LLVMRunFunction(LLVMExecutionEngineRef EE, LLVMValueRef F, + unsigned NumArgs, + LLVMGenericValueRef *Args); + +void LLVMFreeMachineCodeForFunction(LLVMExecutionEngineRef EE, LLVMValueRef F); + +void LLVMAddModuleProvider(LLVMExecutionEngineRef EE, LLVMModuleProviderRef MP); + +int LLVMRemoveModuleProvider(LLVMExecutionEngineRef EE, + LLVMModuleProviderRef MP, + LLVMModuleRef *OutMod, char **OutError); + +int LLVMFindFunction(LLVMExecutionEngineRef EE, const char *Name, + LLVMValueRef *OutFn); + +LLVMTargetDataRef LLVMGetExecutionEngineTargetData(LLVMExecutionEngineRef EE); + +void LLVMAddGlobalMapping(LLVMExecutionEngineRef EE, LLVMValueRef Global, + void* Addr); + +void *LLVMGetPointerToGlobal(LLVMExecutionEngineRef EE, LLVMValueRef Global); + + +/* LinkTimeOptimizer.h */ +/// This provides a dummy type for pointers to the LTO object. +typedef void* llvm_lto_t; + +/// This provides a C-visible enumerator to manage status codes. +/// This should map exactly onto the C++ enumerator LTOStatus. +typedef enum llvm_lto_status { + LLVM_LTO_UNKNOWN, + LLVM_LTO_OPT_SUCCESS, + LLVM_LTO_READ_SUCCESS, + LLVM_LTO_READ_FAILURE, + LLVM_LTO_WRITE_FAILURE, + LLVM_LTO_NO_TARGET, + LLVM_LTO_NO_WORK, + LLVM_LTO_MODULE_MERGE_FAILURE, + LLVM_LTO_ASM_FAILURE, + + // Added C-specific error codes + LLVM_LTO_NULL_OBJECT +} llvm_lto_status_t; + +/// This provides C interface to initialize link time optimizer. This allows +/// linker to use dlopen() interface to dynamically load LinkTimeOptimizer. +/// extern "C" helps, because dlopen() interface uses name to find the symbol. +extern llvm_lto_t llvm_create_optimizer(void); +extern void llvm_destroy_optimizer(llvm_lto_t lto); + +extern llvm_lto_status_t llvm_read_object_file + (llvm_lto_t lto, const char* input_filename); +extern llvm_lto_status_t llvm_optimize_modules + (llvm_lto_t lto, const char* output_filename); + +/* lto.h */ + +#define LTO_API_VERSION 3 + +typedef enum { + LTO_SYMBOL_ALIGNMENT_MASK = 0x0000001F, /* log2 of alignment */ + LTO_SYMBOL_PERMISSIONS_MASK = 0x000000E0, + LTO_SYMBOL_PERMISSIONS_CODE = 0x000000A0, + LTO_SYMBOL_PERMISSIONS_DATA = 0x000000C0, + LTO_SYMBOL_PERMISSIONS_RODATA = 0x00000080, + LTO_SYMBOL_DEFINITION_MASK = 0x00000700, + LTO_SYMBOL_DEFINITION_REGULAR = 0x00000100, + LTO_SYMBOL_DEFINITION_TENTATIVE = 0x00000200, + LTO_SYMBOL_DEFINITION_WEAK = 0x00000300, + LTO_SYMBOL_DEFINITION_UNDEFINED = 0x00000400, + LTO_SYMBOL_DEFINITION_WEAKUNDEF = 0x00000500, + LTO_SYMBOL_SCOPE_MASK = 0x00003800, + LTO_SYMBOL_SCOPE_INTERNAL = 0x00000800, + LTO_SYMBOL_SCOPE_HIDDEN = 0x00001000, + LTO_SYMBOL_SCOPE_PROTECTED = 0x00002000, + LTO_SYMBOL_SCOPE_DEFAULT = 0x00001800 +} lto_symbol_attributes; + +typedef enum { + LTO_DEBUG_MODEL_NONE = 0, + LTO_DEBUG_MODEL_DWARF = 1 +} lto_debug_model; + +typedef enum { + LTO_CODEGEN_PIC_MODEL_STATIC = 0, + LTO_CODEGEN_PIC_MODEL_DYNAMIC = 1, + LTO_CODEGEN_PIC_MODEL_DYNAMIC_NO_PIC = 2 +} lto_codegen_model; + + +/** opaque reference to a loaded object module */ +typedef struct LTOModule* lto_module_t; + +/** opaque reference to a code generator */ +typedef struct LTOCodeGenerator* lto_code_gen_t; + +/** + * Returns a printable string. + */ +extern const char* +lto_get_version(void); + + +/** + * Returns the last error string or NULL if last operation was sucessful. + */ +extern const char* +lto_get_error_message(void); + +/** + * Checks if a file is a loadable object file. + */ +extern bool +lto_module_is_object_file(const char* path); + + +/** + * Checks if a file is a loadable object compiled for requested target. + */ +extern bool +lto_module_is_object_file_for_target(const char* path, + const char* target_triple_prefix); + + +/** + * Checks if a buffer is a loadable object file. + */ +extern bool +lto_module_is_object_file_in_memory(const void* mem, size_t length); + + +/** + * Checks if a buffer is a loadable object compiled for requested target. + */ +extern bool +lto_module_is_object_file_in_memory_for_target(const void* mem, size_t length, + const char* target_triple_prefix); + + +/** + * Loads an object file from disk. + * Returns NULL on error (check lto_get_error_message() for details). + */ +extern lto_module_t +lto_module_create(const char* path); + + +/** + * Loads an object file from memory. + * Returns NULL on error (check lto_get_error_message() for details). + */ +extern lto_module_t +lto_module_create_from_memory(const void* mem, size_t length); + + +/** + * Frees all memory internally allocated by the module. + * Upon return the lto_module_t is no longer valid. + */ +extern void +lto_module_dispose(lto_module_t mod); + + +/** + * Returns triple string which the object module was compiled under. + */ +extern const char* +lto_module_get_target_triple(lto_module_t mod); + + +/** + * Returns the number of symbols in the object module. + */ +extern unsigned int +lto_module_get_num_symbols(lto_module_t mod); + + +/** + * Returns the name of the ith symbol in the object module. + */ +extern const char* +lto_module_get_symbol_name(lto_module_t mod, unsigned int index); + + +/** + * Returns the attributes of the ith symbol in the object module. + */ +extern lto_symbol_attributes +lto_module_get_symbol_attribute(lto_module_t mod, unsigned int index); + + +/** + * Instantiates a code generator. + * Returns NULL on error (check lto_get_error_message() for details). + */ +extern lto_code_gen_t +lto_codegen_create(void); + + +/** + * Frees all code generator and all memory it internally allocated. + * Upon return the lto_code_gen_t is no longer valid. + */ +extern void +lto_codegen_dispose(lto_code_gen_t); + + + +/** + * Add an object module to the set of modules for which code will be generated. + * Returns true on error (check lto_get_error_message() for details). + */ +extern bool +lto_codegen_add_module(lto_code_gen_t cg, lto_module_t mod); + + + +/** + * Sets if debug info should be generated. + * Returns true on error (check lto_get_error_message() for details). + */ +extern bool +lto_codegen_set_debug_model(lto_code_gen_t cg, lto_debug_model); + + +/** + * Sets which PIC code model to generated. + * Returns true on error (check lto_get_error_message() for details). + */ +extern bool +lto_codegen_set_pic_model(lto_code_gen_t cg, lto_codegen_model); + + +/** + * Sets the location of the "gcc" to run. If not set, libLTO will search for + * "gcc" on the path. + */ +extern void +lto_codegen_set_gcc_path(lto_code_gen_t cg, const char* path); + + +/** + * Sets the location of the assembler tool to run. If not set, libLTO + * will use gcc to invoke the assembler. + */ +extern void +lto_codegen_set_assembler_path(lto_code_gen_t cg, const char* path); + + +/** + * Adds to a list of all global symbols that must exist in the final + * generated code. If a function is not listed, it might be + * inlined into every usage and optimized away. + */ +extern void +lto_codegen_add_must_preserve_symbol(lto_code_gen_t cg, const char* symbol); + + +/** + * Writes a new object file at the specified path that contains the + * merged contents of all modules added so far. + * Returns true on error (check lto_get_error_message() for details). + */ +extern bool +lto_codegen_write_merged_modules(lto_code_gen_t cg, const char* path); + + +/** + * Generates code for all added modules into one native object file. + * On sucess returns a pointer to a generated mach-o/ELF buffer and + * length set to the buffer size. The buffer is owned by the + * lto_code_gen_t and will be freed when lto_codegen_dispose() + * is called, or lto_codegen_compile() is called again. + * On failure, returns NULL (check lto_get_error_message() for details). + */ +extern const void* +lto_codegen_compile(lto_code_gen_t cg, size_t* length); + + +/** + * Sets options to help debug codegen bugs. + */ +extern void +lto_codegen_debug_options(lto_code_gen_t cg, const char *); + + + + diff --git a/llvm/llvm.nim b/llvm/llvm.nim new file mode 100644 index 000000000..d010457f8 --- /dev/null +++ b/llvm/llvm.nim @@ -0,0 +1,1452 @@ +const + libname* = "llvm.dll" #Setup as you need + +type + OpaqueContext {.pure.} = object + OpaqueModule {.pure.} = object + TOpaqueType {.pure.} = object + OpaqueTypeHandle {.pure.} = object + OpaqueValue {.pure.} = object + OpaqueBasicBlock {.pure.} = object + OpaqueBuilder {.pure.} = object + OpaqueModuleProvider {.pure.} = object + OpaqueMemoryBuffer {.pure.} = object + OpaquePassManager {.pure.} = object + OpaqueUseIterator {.pure.} = object + + ContextRef* = OpaqueContext + ModuleRef* = OpaqueModule + TypeRef* = TOpaqueType + TypeHandleRef* = OpaqueTypeHandle + ValueRef* = OpaqueValue + BasicBlockRef* = OpaqueBasicBlock + BuilderRef* = OpaqueBuilder + ModuleProviderRef* = OpaqueModuleProvider + MemoryBufferRef* = OpaqueMemoryBuffer + PassManagerRef* = OpaquePassManager + UseIteratorRef* = OpaqueUseIterator + Attribute* = enum + ZExtAttribute = 1 shl 0, SExtAttribute = 1 shl 1, + NoReturnAttribute = 1 shl 2, InRegAttribute = 1 shl 3, + StructRetAttribute = 1 shl 4, NoUnwindAttribute = 1 shl 5, + NoAliasAttribute = 1 shl 6, ByValAttribute = 1 shl 7, + NestAttribute = 1 shl 8, ReadNoneAttribute = 1 shl 9, + ReadOnlyAttribute = 1 shl 10, NoInlineAttribute = 1 shl 11, + AlwaysInlineAttribute = 1 shl 12, OptimizeForSizeAttribute = 1 shl 13, + StackProtectAttribute = 1 shl 14, StackProtectReqAttribute = 1 shl 15, + NoCaptureAttribute = 1 shl 21, NoRedZoneAttribute = 1 shl 22, + NoImplicitFloatAttribute = 1 shl 23, NakedAttribute = 1 shl 24, + InlineHintAttribute = 1 shl 25 + Opcode* = enum + opcRet = 1, opcBr = 2, opcSwitch = 3, opcInvoke = 4, opcUnwind = 5, + opcUnreachable = 6, + opcAdd = 7, opcFAdd = 8, opcSub = 9, opcFSub = 10, opcMul = 11, + opcFMul = 12, opcUDiv = 13, + opcSDiv = 14, opcFDiv = 15, opcURem = 16, opcSRem = 17, opcFRem = 18, + opcShl = 19, + opcLShr = 20, opcAShr = 21, opcAnd = 22, opcOr = 23, opcXor = 24, + opcMalloc = 25, opcFree = 26, opcAlloca = 27, + opcLoad = 28, opcStore = 29, + opcGetElementPtr = 30, opcTrunk = 31, opcZExt = 32, opcSExt = 33, + opcFPToUI = 34, opcFPToSI = 35, opcUIToFP = 36, opcSIToFP = 37, + opcFPTrunc = 38, opcFPExt = 39, opcPtrToInt = 40, opcIntToPtr = 41, + opcBitCast = 42, opcICmp = 43, + opcFCmp = 44, opcPHI = 45, opcCall = 46, opcSelect = 47, opcVAArg = 50, + opcExtractElement = 51, opcInsertElement = 52, opcShuffleVector = 53, + opcExtractValue = 54, opcInsertValue = 55 + TypeKind* = enum + VoidTypeKind, FloatTypeKind, DoubleTypeKind, X86_FP80TypeKind, + FP128TypeKind, PPC_FP128TypeKind, LabelTypeKind, IntegerTypeKind, + FunctionTypeKind, StructTypeKind, ArrayTypeKind, PointerTypeKind, + OpaqueTypeKind, VectorTypeKind, MetadataTypeKind + TLinkage* = enum + ExternalLinkage, ## Externally visible function + AvailableExternallyLinkage, ## Keep one copy of function when linking (inline) + LinkOnceAnyLinkage, ## Same, but only replaced by something equivalent. + LinkOnceODRLinkage, ## Keep one copy of function when linking (weak) + WeakAnyLinkage, ## Same, but only replaced by something equivalent. + WeakODRLinkage, ## Special purpose, only applies to global arrays + AppendingLinkage, ## Rename collisions when linking (static functions) + InternalLinkage, ## + PrivateLinkage, ## Like Internal, but omit from symbol table + DLLImportLinkage, ## Function to be imported from DLL + DLLExportLinkage, ## Function to be accessible from DLL + ExternalWeakLinkage, ## ExternalWeak linkage description + GhostLinkage, ## Stand-in functions for streaming fns from bitcode + CommonLinkage, ## Tentative definitions + LinkerPrivateLinkage ## Like Private, but linker removes. + TVisibility* = enum + DefaultVisibility, + HiddenVisibility, + ProtectedVisibility + TCallConv* = enum + CCallConv = 0, FastCallConv = 8, ColdCallConv = 9, X86StdcallCallConv = 64, + X86FastcallCallConv = 65 + IntPredicate* = enum + IntEQ = 32, IntNE, IntUGT, IntUGE, IntULT, IntULE, IntSGT, IntSGE, IntSLT, + IntSLE + RealPredicate* = enum + RealPredicateFalse, RealOEQ, RealOGT, RealOGE, RealOLT, RealOLE, RealONE, + RealORD, RealUNO, RealUEQ, RealUGT, RealUGE, RealULT, RealULE, RealUNE, + RealPredicateTrue + +#===-- Error handling ----------------------------------------------------=== + +proc DisposeMessage*(Message: cstring){.cdecl, dynlib: libname, + importc: "LLVMDisposeMessage".} + +#===-- Modules -----------------------------------------------------------=== +# Create and destroy contexts. +proc ContextCreate*(): ContextRef{.cdecl, dynlib: libname, + importc: "LLVMContextCreate".} +proc GetGlobalContext*(): ContextRef{.cdecl, dynlib: libname, + importc: "LLVMGetGlobalContext".} +proc ContextDispose*(C: ContextRef){.cdecl, dynlib: libname, + importc: "LLVMContextDispose".} + # Create and destroy modules. + # See llvm::Module::Module. +proc ModuleCreateWithName*(ModuleID: cstring): ModuleRef{.cdecl, + dynlib: libname, importc: "LLVMModuleCreateWithName".} +proc ModuleCreateWithNameInContext*(ModuleID: cstring, C: ContextRef): ModuleRef{. + cdecl, dynlib: libname, importc: "LLVMModuleCreateWithNameInContext".} + # See llvm::Module::~Module. +proc DisposeModule*(M: ModuleRef){.cdecl, dynlib: libname, + importc: "LLVMDisposeModule".} + # Data layout. See Module::getDataLayout. +proc GetDataLayout*(M: ModuleRef): cstring{.cdecl, dynlib: libname, + importc: "LLVMGetDataLayout".} +proc SetDataLayout*(M: ModuleRef, Triple: cstring){.cdecl, dynlib: libname, + importc: "LLVMSetDataLayout".} + # Target triple. See Module::getTargetTriple. +proc GetTarget*(M: ModuleRef): cstring{.cdecl, dynlib: libname, + importc: "LLVMGetTarget".} +proc SetTarget*(M: ModuleRef, Triple: cstring){.cdecl, dynlib: libname, + importc: "LLVMSetTarget".} + # See Module::addTypeName. +proc AddTypeName*(M: ModuleRef, Name: cstring, Ty: TypeRef): int32{.cdecl, + dynlib: libname, importc: "LLVMAddTypeName".} +proc DeleteTypeName*(M: ModuleRef, Name: cstring){.cdecl, dynlib: libname, + importc: "LLVMDeleteTypeName".} +proc GetTypeByName*(M: ModuleRef, Name: cstring): TypeRef{.cdecl, + dynlib: libname, importc: "LLVMGetTypeByName".} + # See Module::dump. +proc DumpModule*(M: ModuleRef){.cdecl, dynlib: libname, + importc: "LLVMDumpModule".} + #===-- 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. +proc GetTypeKind*(Ty: TypeRef): TypeKind{.cdecl, dynlib: libname, + importc: "LLVMGetTypeKind".} + # See llvm::LLVMType::getContext. +proc GetTypeContext*(Ty: TypeRef): ContextRef{.cdecl, dynlib: libname, + importc: "LLVMGetTypeContext".} + # Operations on integer types +proc Int1TypeInContext*(C: ContextRef): TypeRef{.cdecl, dynlib: libname, + importc: "LLVMInt1TypeInContext".} +proc Int8TypeInContext*(C: ContextRef): TypeRef{.cdecl, dynlib: libname, + importc: "LLVMInt8TypeInContext".} +proc Int16TypeInContext*(C: ContextRef): TypeRef{.cdecl, dynlib: libname, + importc: "LLVMInt16TypeInContext".} +proc Int32TypeInContext*(C: ContextRef): TypeRef{.cdecl, dynlib: libname, + importc: "LLVMInt32TypeInContext".} +proc Int64TypeInContext*(C: ContextRef): TypeRef{.cdecl, dynlib: libname, + importc: "LLVMInt64TypeInContext".} +proc IntTypeInContext*(C: ContextRef, NumBits: int32): TypeRef{.cdecl, + dynlib: libname, importc: "LLVMIntTypeInContext".} +proc Int1Type*(): TypeRef{.cdecl, dynlib: libname, importc: "LLVMInt1Type".} +proc Int8Type*(): TypeRef{.cdecl, dynlib: libname, importc: "LLVMInt8Type".} +proc Int16Type*(): TypeRef{.cdecl, dynlib: libname, importc: "LLVMInt16Type".} +proc Int32Type*(): TypeRef{.cdecl, dynlib: libname, importc: "LLVMInt32Type".} +proc Int64Type*(): TypeRef{.cdecl, dynlib: libname, importc: "LLVMInt64Type".} +proc IntType*(NumBits: int32): TypeRef{.cdecl, dynlib: libname, + importc: "LLVMIntType".} +proc GetIntTypeWidth*(IntegerTy: TypeRef): int32{.cdecl, dynlib: libname, + importc: "LLVMGetIntTypeWidth".} + # Operations on real types +proc FloatTypeInContext*(C: ContextRef): TypeRef{.cdecl, dynlib: libname, + importc: "LLVMFloatTypeInContext".} +proc DoubleTypeInContext*(C: ContextRef): TypeRef{.cdecl, dynlib: libname, + importc: "LLVMDoubleTypeInContext".} +proc X86FP80TypeInContext*(C: ContextRef): TypeRef{.cdecl, dynlib: libname, + importc: "LLVMX86FP80TypeInContext".} +proc FP128TypeInContext*(C: ContextRef): TypeRef{.cdecl, dynlib: libname, + importc: "LLVMFP128TypeInContext".} +proc PPCFP128TypeInContext*(C: ContextRef): TypeRef{.cdecl, dynlib: libname, + importc: "LLVMPPCFP128TypeInContext".} +proc FloatType*(): TypeRef{.cdecl, dynlib: libname, importc: "LLVMFloatType".} +proc DoubleType*(): TypeRef{.cdecl, dynlib: libname, importc: "LLVMDoubleType".} +proc X86FP80Type*(): TypeRef{.cdecl, dynlib: libname, importc: "LLVMX86FP80Type".} +proc FP128Type*(): TypeRef{.cdecl, dynlib: libname, importc: "LLVMFP128Type".} +proc PPCFP128Type*(): TypeRef{.cdecl, dynlib: libname, + importc: "LLVMPPCFP128Type".} + # Operations on function types +proc FunctionType*(ReturnType: TypeRef, ParamTypes: ptr TypeRef, + ParamCount: int32, IsVarArg: int32): TypeRef {. + cdecl, dynlib: libname, importc: "LLVMFunctionType".} +proc IsFunctionVarArg*(FunctionTy: TypeRef): int32{.cdecl, dynlib: libname, + importc: "LLVMIsFunctionVarArg".} +proc GetReturnType*(FunctionTy: TypeRef): TypeRef{.cdecl, dynlib: libname, + importc: "LLVMGetReturnType".} +proc CountParamTypes*(FunctionTy: TypeRef): int32{.cdecl, dynlib: libname, + importc: "LLVMCountParamTypes".} +proc GetParamTypes*(FunctionTy: TypeRef, Dest: ptr TypeRef){.cdecl, + dynlib: libname, importc: "LLVMGetParamTypes".} + # Operations on struct types +proc StructTypeInContext*(C: ContextRef, ElementTypes: ptr TypeRef, + ElementCount: int32, isPacked: int32): TypeRef{.cdecl, + dynlib: libname, importc: "LLVMStructTypeInContext".} +proc StructType*(ElementTypes: ptr TypeRef, ElementCount: int32, isPacked: int32): TypeRef{. + cdecl, dynlib: libname, importc: "LLVMStructType".} +proc CountStructElementTypes*(StructTy: TypeRef): int32{.cdecl, dynlib: libname, + importc: "LLVMCountStructElementTypes".} +proc GetStructElementTypes*(StructTy: TypeRef, Dest: ptr TypeRef){.cdecl, + dynlib: libname, importc: "LLVMGetStructElementTypes".} +proc IsPackedStruct*(StructTy: TypeRef): int32{.cdecl, dynlib: libname, + importc: "LLVMIsPackedStruct".} + # Operations on array, pointer, and vector types (sequence types) +proc ArrayType*(ElementType: TypeRef, ElementCount: int32): TypeRef{.cdecl, + dynlib: libname, importc: "LLVMArrayType".} +proc PointerType*(ElementType: TypeRef, AddressSpace: int32): TypeRef{.cdecl, + dynlib: libname, importc: "LLVMPointerType".} +proc VectorType*(ElementType: TypeRef, ElementCount: int32): TypeRef{.cdecl, + dynlib: libname, importc: "LLVMVectorType".} +proc GetElementType*(Ty: TypeRef): TypeRef{.cdecl, dynlib: libname, + importc: "LLVMGetElementType".} +proc GetArrayLength*(ArrayTy: TypeRef): int32{.cdecl, dynlib: libname, + importc: "LLVMGetArrayLength".} +proc GetPointerAddressSpace*(PointerTy: TypeRef): int32{.cdecl, dynlib: libname, + importc: "LLVMGetPointerAddressSpace".} +proc GetVectorSize*(VectorTy: TypeRef): int32{.cdecl, dynlib: libname, + importc: "LLVMGetVectorSize".} + # Operations on other types +proc VoidTypeInContext*(C: ContextRef): TypeRef{.cdecl, dynlib: libname, + importc: "LLVMVoidTypeInContext".} +proc LabelTypeInContext*(C: ContextRef): TypeRef{.cdecl, dynlib: libname, + importc: "LLVMLabelTypeInContext".} +proc OpaqueTypeInContext*(C: ContextRef): TypeRef{.cdecl, dynlib: libname, + importc: "LLVMOpaqueTypeInContext".} +proc VoidType*(): TypeRef{.cdecl, dynlib: libname, importc: "LLVMVoidType".} +proc LabelType*(): TypeRef{.cdecl, dynlib: libname, importc: "LLVMLabelType".} +proc OpaqueType*(): TypeRef{.cdecl, dynlib: libname, importc: "LLVMOpaqueType".} + # Operations on type handles +proc CreateTypeHandle*(PotentiallyAbstractTy: TypeRef): TypeHandleRef{.cdecl, + dynlib: libname, importc: "LLVMCreateTypeHandle".} +proc RefineType*(AbstractTy: TypeRef, ConcreteTy: TypeRef){.cdecl, + dynlib: libname, importc: "LLVMRefineType".} +proc ResolveTypeHandle*(TypeHandle: TypeHandleRef): TypeRef{.cdecl, + dynlib: libname, importc: "LLVMResolveTypeHandle".} +proc DisposeTypeHandle*(TypeHandle: TypeHandleRef){.cdecl, dynlib: libname, + importc: "LLVMDisposeTypeHandle".} + # Operations on all values +proc TypeOf*(Val: ValueRef): TypeRef{.cdecl, dynlib: libname, + importc: "LLVMTypeOf".} +proc GetValueName*(Val: ValueRef): cstring{.cdecl, dynlib: libname, + importc: "LLVMGetValueName".} +proc SetValueName*(Val: ValueRef, Name: cstring){.cdecl, dynlib: libname, + importc: "LLVMSetValueName".} +proc DumpValue*(Val: ValueRef){.cdecl, dynlib: libname, importc: "LLVMDumpValue".} +proc ReplaceAllUsesWith*(OldVal: ValueRef, NewVal: ValueRef){.cdecl, + dynlib: libname, importc: "LLVMReplaceAllUsesWith".} + # Conversion functions. Return the input value if it is an instance of the + # specified class, otherwise NULL. See llvm::dyn_cast_or_null<>. +proc IsAArgument*(Val: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsAArgument".} +proc IsABasicBlock*(Val: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsABasicBlock".} +proc IsAInlineAsm*(Val: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsAInlineAsm".} +proc IsAUser*(Val: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsAUser".} +proc IsAConstant*(Val: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsAConstant".} +proc IsAConstantAggregateZero*(Val: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsAConstantAggregateZero".} +proc IsAConstantArray*(Val: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsAConstantArray".} +proc IsAConstantExpr*(Val: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsAConstantExpr".} +proc IsAConstantFP*(Val: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsAConstantFP".} +proc IsAConstantInt*(Val: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsAConstantInt".} +proc IsAConstantPointerNull*(Val: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsAConstantPointerNull".} +proc IsAConstantStruct*(Val: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsAConstantStruct".} +proc IsAConstantVector*(Val: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsAConstantVector".} +proc IsAGlobalValue*(Val: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsAGlobalValue".} +proc IsAFunction*(Val: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsAFunction".} +proc IsAGlobalAlias*(Val: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsAGlobalAlias".} +proc IsAGlobalVariable*(Val: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsAGlobalVariable".} +proc IsAUndefValue*(Val: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsAUndefValue".} +proc IsAInstruction*(Val: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsAInstruction".} +proc IsABinaryOperator*(Val: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsABinaryOperator".} +proc IsACallInst*(Val: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsACallInst".} +proc IsAIntrinsicInst*(Val: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsAIntrinsicInst".} +proc IsADbgInfoIntrinsic*(Val: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsADbgInfoIntrinsic".} +proc IsADbgDeclareInst*(Val: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsADbgDeclareInst".} +proc IsADbgFuncStartInst*(Val: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsADbgFuncStartInst".} +proc IsADbgRegionEndInst*(Val: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsADbgRegionEndInst".} +proc IsADbgRegionStartInst*(Val: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsADbgRegionStartInst".} +proc IsADbgStopPointInst*(Val: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsADbgStopPointInst".} +proc IsAEHSelectorInst*(Val: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsAEHSelectorInst".} +proc IsAMemIntrinsic*(Val: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsAMemIntrinsic".} +proc IsAMemCpyInst*(Val: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsAMemCpyInst".} +proc IsAMemMoveInst*(Val: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsAMemMoveInst".} +proc IsAMemSetInst*(Val: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsAMemSetInst".} +proc IsACmpInst*(Val: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsACmpInst".} +proc IsAFCmpInst*(Val: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsAFCmpInst".} +proc IsAICmpInst*(Val: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsAICmpInst".} +proc IsAExtractElementInst*(Val: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsAExtractElementInst".} +proc IsAGetElementPtrInst*(Val: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsAGetElementPtrInst".} +proc IsAInsertElementInst*(Val: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsAInsertElementInst".} +proc IsAInsertValueInst*(Val: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsAInsertValueInst".} +proc IsAPHINode*(Val: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsAPHINode".} +proc IsASelectInst*(Val: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsASelectInst".} +proc IsAShuffleVectorInst*(Val: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsAShuffleVectorInst".} +proc IsAStoreInst*(Val: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsAStoreInst".} +proc IsATerminatorInst*(Val: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsATerminatorInst".} +proc IsABranchInst*(Val: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsABranchInst".} +proc IsAInvokeInst*(Val: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsAInvokeInst".} +proc IsAReturnInst*(Val: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsAReturnInst".} +proc IsASwitchInst*(Val: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsASwitchInst".} +proc IsAUnreachableInst*(Val: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsAUnreachableInst".} +proc IsAUnwindInst*(Val: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsAUnwindInst".} +proc IsAUnaryInstruction*(Val: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsAUnaryInstruction".} +proc IsAAllocationInst*(Val: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsAAllocationInst".} +proc IsAAllocaInst*(Val: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsAAllocaInst".} +proc IsACastInst*(Val: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsACastInst".} +proc IsABitCastInst*(Val: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsABitCastInst".} +proc IsAFPExtInst*(Val: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsAFPExtInst".} +proc IsAFPToSIInst*(Val: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsAFPToSIInst".} +proc IsAFPToUIInst*(Val: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsAFPToUIInst".} +proc IsAFPTruncInst*(Val: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsAFPTruncInst".} +proc IsAIntToPtrInst*(Val: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsAIntToPtrInst".} +proc IsAPtrToIntInst*(Val: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsAPtrToIntInst".} +proc IsASExtInst*(Val: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsASExtInst".} +proc IsASIToFPInst*(Val: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsASIToFPInst".} +proc IsATruncInst*(Val: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsATruncInst".} +proc IsAUIToFPInst*(Val: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsAUIToFPInst".} +proc IsAZExtInst*(Val: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsAZExtInst".} +proc IsAExtractValueInst*(Val: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsAExtractValueInst".} +proc IsAFreeInst*(Val: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsAFreeInst".} +proc IsALoadInst*(Val: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsALoadInst".} +proc IsAVAArgInst*(Val: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsAVAArgInst".} + # Operations on Uses +proc GetFirstUse*(Val: ValueRef): UseIteratorRef{.cdecl, dynlib: libname, + importc: "LLVMGetFirstUse".} +proc GetNextUse*(U: UseIteratorRef): UseIteratorRef{.cdecl, dynlib: libname, + importc: "LLVMGetNextUse".} +proc GetUser*(U: UseIteratorRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMGetUser".} +proc GetUsedValue*(U: UseIteratorRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMGetUsedValue".} + # Operations on Users +proc GetOperand*(Val: ValueRef, Index: int32): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMGetOperand".} + # Operations on constants of any type +proc ConstNull*(Ty: TypeRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMConstNull".} + # all zeroes +proc ConstAllOnes*(Ty: TypeRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMConstAllOnes".} + # only for int/vector +proc GetUndef*(Ty: TypeRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMGetUndef".} +proc IsConstant*(Val: ValueRef): int32{.cdecl, dynlib: libname, + importc: "LLVMIsConstant".} +proc IsNull*(Val: ValueRef): int32{.cdecl, dynlib: libname, + importc: "LLVMIsNull".} +proc IsUndef*(Val: ValueRef): int32{.cdecl, dynlib: libname, + importc: "LLVMIsUndef".} +proc ConstPointerNull*(Ty: TypeRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMConstPointerNull".} + # Operations on scalar constants +proc ConstInt*(IntTy: TypeRef, N: int64, SignExtend: int32): ValueRef{.cdecl, + dynlib: libname, importc: "LLVMConstInt".} +proc ConstIntOfString*(IntTy: TypeRef, Text: cstring, Radix: byte): ValueRef{. + cdecl, dynlib: libname, importc: "LLVMConstIntOfString".} +proc ConstIntOfStringAndSize*(IntTy: TypeRef, Text: cstring, SLen: int32, + Radix: byte): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMConstIntOfStringAndSize".} +proc ConstReal*(RealTy: TypeRef, N: float64): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMConstReal".} +proc ConstRealOfString*(RealTy: TypeRef, Text: cstring): ValueRef{.cdecl, + dynlib: libname, importc: "LLVMConstRealOfString".} +proc ConstRealOfStringAndSize*(RealTy: TypeRef, Text: cstring, SLen: int32): ValueRef{. + cdecl, dynlib: libname, importc: "LLVMConstRealOfStringAndSize".} +proc ConstIntGetZExtValue*(ConstantVal: ValueRef): int64{.cdecl, + dynlib: libname, importc: "LLVMConstIntGetZExtValue".} +proc ConstIntGetSExtValue*(ConstantVal: ValueRef): int64{.cdecl, + dynlib: libname, importc: "LLVMConstIntGetSExtValue".} + # Operations on composite constants +proc ConstStringInContext*(C: ContextRef, Str: cstring, len: int32, + DontNullTerminate: int32): ValueRef{.cdecl, + dynlib: libname, importc: "LLVMConstStringInContext".} +proc ConstStructInContext*(C: ContextRef, ConstantVals: ptr ValueRef, + Count: int32, + isPacked: int32): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMConstStructInContext".} +proc ConstString*(Str: cstring, len: int32, DontNullTerminate: int32): ValueRef{. + cdecl, dynlib: libname, importc: "LLVMConstString".} +proc ConstArray*(ElementTy: TypeRef, ConstantVals: ptr ValueRef, len: int32): ValueRef{. + cdecl, dynlib: libname, importc: "LLVMConstArray".} +proc ConstStruct*(ConstantVals: ptr ValueRef, Count: int32, isPacked: int32): ValueRef{. + cdecl, dynlib: libname, importc: "LLVMConstStruct".} +proc ConstVector*(ScalarConstantVals: ptr ValueRef, Size: int32): ValueRef{.cdecl, + dynlib: libname, importc: "LLVMConstVector".} + # Constant expressions +proc GetConstOpcode*(ConstantVal: ValueRef): Opcode{.cdecl, dynlib: libname, + importc: "LLVMGetConstOpcode".} +proc AlignOf*(Ty: TypeRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMAlignOf".} +proc SizeOf*(Ty: TypeRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMSizeOf".} +proc ConstNeg*(ConstantVal: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMConstNeg".} +proc ConstFNeg*(ConstantVal: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMConstFNeg".} +proc ConstNot*(ConstantVal: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMConstNot".} +proc ConstAdd*(LHSConstant: ValueRef, RHSConstant: ValueRef): ValueRef{.cdecl, + dynlib: libname, importc: "LLVMConstAdd".} +proc ConstNSWAdd*(LHSConstant: ValueRef, RHSConstant: ValueRef): ValueRef{. + cdecl, dynlib: libname, importc: "LLVMConstNSWAdd".} +proc ConstFAdd*(LHSConstant: ValueRef, RHSConstant: ValueRef): ValueRef{.cdecl, + dynlib: libname, importc: "LLVMConstFAdd".} +proc ConstSub*(LHSConstant: ValueRef, RHSConstant: ValueRef): ValueRef{.cdecl, + dynlib: libname, importc: "LLVMConstSub".} +proc ConstFSub*(LHSConstant: ValueRef, RHSConstant: ValueRef): ValueRef{.cdecl, + dynlib: libname, importc: "LLVMConstFSub".} +proc ConstMul*(LHSConstant: ValueRef, RHSConstant: ValueRef): ValueRef{.cdecl, + dynlib: libname, importc: "LLVMConstMul".} +proc ConstFMul*(LHSConstant: ValueRef, RHSConstant: ValueRef): ValueRef{.cdecl, + dynlib: libname, importc: "LLVMConstFMul".} +proc ConstUDiv*(LHSConstant: ValueRef, RHSConstant: ValueRef): ValueRef{.cdecl, + dynlib: libname, importc: "LLVMConstUDiv".} +proc ConstSDiv*(LHSConstant: ValueRef, RHSConstant: ValueRef): ValueRef{.cdecl, + dynlib: libname, importc: "LLVMConstSDiv".} +proc ConstExactSDiv*(LHSConstant: ValueRef, RHSConstant: ValueRef): ValueRef{. + cdecl, dynlib: libname, importc: "LLVMConstExactSDiv".} +proc ConstFDiv*(LHSConstant: ValueRef, RHSConstant: ValueRef): ValueRef{.cdecl, + dynlib: libname, importc: "LLVMConstFDiv".} +proc ConstURem*(LHSConstant: ValueRef, RHSConstant: ValueRef): ValueRef{.cdecl, + dynlib: libname, importc: "LLVMConstURem".} +proc ConstSRem*(LHSConstant: ValueRef, RHSConstant: ValueRef): ValueRef{.cdecl, + dynlib: libname, importc: "LLVMConstSRem".} +proc ConstFRem*(LHSConstant: ValueRef, RHSConstant: ValueRef): ValueRef{.cdecl, + dynlib: libname, importc: "LLVMConstFRem".} +proc ConstAnd*(LHSConstant: ValueRef, RHSConstant: ValueRef): ValueRef{.cdecl, + dynlib: libname, importc: "LLVMConstAnd".} +proc ConstOr*(LHSConstant: ValueRef, RHSConstant: ValueRef): ValueRef{.cdecl, + dynlib: libname, importc: "LLVMConstOr".} +proc ConstXor*(LHSConstant: ValueRef, RHSConstant: ValueRef): ValueRef{.cdecl, + dynlib: libname, importc: "LLVMConstXor".} +proc ConstICmp*(Predicate: IntPredicate, LHSConstant: ValueRef, + RHSConstant: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMConstICmp".} +proc ConstFCmp*(Predicate: RealPredicate, LHSConstant: ValueRef, + RHSConstant: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMConstFCmp".} +proc ConstShl*(LHSConstant: ValueRef, RHSConstant: ValueRef): ValueRef{.cdecl, + dynlib: libname, importc: "LLVMConstShl".} +proc ConstLShr*(LHSConstant: ValueRef, RHSConstant: ValueRef): ValueRef{.cdecl, + dynlib: libname, importc: "LLVMConstLShr".} +proc ConstAShr*(LHSConstant: ValueRef, RHSConstant: ValueRef): ValueRef{.cdecl, + dynlib: libname, importc: "LLVMConstAShr".} +proc ConstGEP*(ConstantVal: ValueRef, ConstantIndices: ptr ValueRef, + NumIndices: int32): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMConstGEP".} +proc ConstInBoundsGEP*(ConstantVal: ValueRef, ConstantIndices: ptr ValueRef, + NumIndices: int32): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMConstInBoundsGEP".} +proc ConstTrunc*(ConstantVal: ValueRef, ToType: TypeRef): ValueRef{.cdecl, + dynlib: libname, importc: "LLVMConstTrunc".} +proc ConstSExt*(ConstantVal: ValueRef, ToType: TypeRef): ValueRef{.cdecl, + dynlib: libname, importc: "LLVMConstSExt".} +proc ConstZExt*(ConstantVal: ValueRef, ToType: TypeRef): ValueRef{.cdecl, + dynlib: libname, importc: "LLVMConstZExt".} +proc ConstFPTrunc*(ConstantVal: ValueRef, ToType: TypeRef): ValueRef{.cdecl, + dynlib: libname, importc: "LLVMConstFPTrunc".} +proc ConstFPExt*(ConstantVal: ValueRef, ToType: TypeRef): ValueRef{.cdecl, + dynlib: libname, importc: "LLVMConstFPExt".} +proc ConstUIToFP*(ConstantVal: ValueRef, ToType: TypeRef): ValueRef{.cdecl, + dynlib: libname, importc: "LLVMConstUIToFP".} +proc ConstSIToFP*(ConstantVal: ValueRef, ToType: TypeRef): ValueRef{.cdecl, + dynlib: libname, importc: "LLVMConstSIToFP".} +proc ConstFPToUI*(ConstantVal: ValueRef, ToType: TypeRef): ValueRef{.cdecl, + dynlib: libname, importc: "LLVMConstFPToUI".} +proc ConstFPToSI*(ConstantVal: ValueRef, ToType: TypeRef): ValueRef{.cdecl, + dynlib: libname, importc: "LLVMConstFPToSI".} +proc ConstPtrToInt*(ConstantVal: ValueRef, ToType: TypeRef): ValueRef{.cdecl, + dynlib: libname, importc: "LLVMConstPtrToInt".} +proc ConstIntToPtr*(ConstantVal: ValueRef, ToType: TypeRef): ValueRef{.cdecl, + dynlib: libname, importc: "LLVMConstIntToPtr".} +proc ConstBitCast*(ConstantVal: ValueRef, ToType: TypeRef): ValueRef{.cdecl, + dynlib: libname, importc: "LLVMConstBitCast".} +proc ConstZExtOrBitCast*(ConstantVal: ValueRef, ToType: TypeRef): ValueRef{. + cdecl, dynlib: libname, importc: "LLVMConstZExtOrBitCast".} +proc ConstSExtOrBitCast*(ConstantVal: ValueRef, ToType: TypeRef): ValueRef{. + cdecl, dynlib: libname, importc: "LLVMConstSExtOrBitCast".} +proc ConstTruncOrBitCast*(ConstantVal: ValueRef, ToType: TypeRef): ValueRef{. + cdecl, dynlib: libname, importc: "LLVMConstTruncOrBitCast".} +proc ConstPointerCast*(ConstantVal: ValueRef, ToType: TypeRef): ValueRef{.cdecl, + dynlib: libname, importc: "LLVMConstPointerCast".} +proc ConstIntCast*(ConstantVal: ValueRef, ToType: TypeRef, isSigned: int32): ValueRef{. + cdecl, dynlib: libname, importc: "LLVMConstIntCast".} +proc ConstFPCast*(ConstantVal: ValueRef, ToType: TypeRef): ValueRef{.cdecl, + dynlib: libname, importc: "LLVMConstFPCast".} +proc ConstSelect*(ConstantCondition: ValueRef, ConstantIfTrue: ValueRef, + ConstantIfFalse: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMConstSelect".} +proc ConstExtractElement*(VectorConstant: ValueRef, IndexConstant: ValueRef): ValueRef{. + cdecl, dynlib: libname, importc: "LLVMConstExtractElement".} +proc ConstInsertElement*(VectorConstant: ValueRef, + ElementValueConstant: ValueRef, IndexConstant: ValueRef): ValueRef{. + cdecl, dynlib: libname, importc: "LLVMConstInsertElement".} +proc ConstShuffleVector*(VectorAConstant: ValueRef, VectorBConstant: ValueRef, + MaskConstant: ValueRef): ValueRef{.cdecl, + dynlib: libname, importc: "LLVMConstShuffleVector".} +proc ConstExtractValue*(AggConstant: ValueRef, IdxList: ptr int32, NumIdx: int32): ValueRef{. + cdecl, dynlib: libname, importc: "LLVMConstExtractValue".} +proc ConstInsertValue*(AggConstant: ValueRef, ElementValueConstant: ValueRef, + IdxList: ptr int32, NumIdx: int32): ValueRef{.cdecl, + dynlib: libname, importc: "LLVMConstInsertValue".} +proc ConstInlineAsm*(Ty: TypeRef, AsmString: cstring, Constraints: cstring, + HasSideEffects: int32): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMConstInlineAsm".} + # Operations on global variables, functions, and aliases (globals) +proc GetGlobalParent*(Global: ValueRef): ModuleRef{.cdecl, dynlib: libname, + importc: "LLVMGetGlobalParent".} +proc IsDeclaration*(Global: ValueRef): int32{.cdecl, dynlib: libname, + importc: "LLVMIsDeclaration".} +proc GetLinkage*(Global: ValueRef): TLinkage{.cdecl, dynlib: libname, + importc: "LLVMGetLinkage".} +proc SetLinkage*(Global: ValueRef, Linkage: TLinkage){.cdecl, dynlib: libname, + importc: "LLVMSetLinkage".} +proc GetSection*(Global: ValueRef): cstring{.cdecl, dynlib: libname, + importc: "LLVMGetSection".} +proc SetSection*(Global: ValueRef, Section: cstring){.cdecl, dynlib: libname, + importc: "LLVMSetSection".} +proc GetVisibility*(Global: ValueRef): TVisibility{.cdecl, dynlib: libname, + importc: "LLVMGetVisibility".} +proc SetVisibility*(Global: ValueRef, Viz: TVisibility){.cdecl, dynlib: libname, + importc: "LLVMSetVisibility".} +proc GetAlignment*(Global: ValueRef): int32{.cdecl, dynlib: libname, + importc: "LLVMGetAlignment".} +proc SetAlignment*(Global: ValueRef, Bytes: int32){.cdecl, dynlib: libname, + importc: "LLVMSetAlignment".} + # Operations on global variables +proc AddGlobal*(M: ModuleRef, Ty: TypeRef, Name: cstring): ValueRef{.cdecl, + dynlib: libname, importc: "LLVMAddGlobal".} +proc GetNamedGlobal*(M: ModuleRef, Name: cstring): ValueRef{.cdecl, + dynlib: libname, importc: "LLVMGetNamedGlobal".} +proc GetFirstGlobal*(M: ModuleRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMGetFirstGlobal".} +proc GetLastGlobal*(M: ModuleRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMGetLastGlobal".} +proc GetNextGlobal*(GlobalVar: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMGetNextGlobal".} +proc GetPreviousGlobal*(GlobalVar: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMGetPreviousGlobal".} +proc DeleteGlobal*(GlobalVar: ValueRef){.cdecl, dynlib: libname, + importc: "LLVMDeleteGlobal".} +proc GetInitializer*(GlobalVar: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMGetInitializer".} +proc SetInitializer*(GlobalVar: ValueRef, ConstantVal: ValueRef){.cdecl, + dynlib: libname, importc: "LLVMSetInitializer".} +proc IsThreadLocal*(GlobalVar: ValueRef): int32{.cdecl, dynlib: libname, + importc: "LLVMIsThreadLocal".} +proc SetThreadLocal*(GlobalVar: ValueRef, IsThreadLocal: int32){.cdecl, + dynlib: libname, importc: "LLVMSetThreadLocal".} +proc IsGlobalConstant*(GlobalVar: ValueRef): int32{.cdecl, dynlib: libname, + importc: "LLVMIsGlobalConstant".} +proc SetGlobalConstant*(GlobalVar: ValueRef, IsConstant: int32){.cdecl, + dynlib: libname, importc: "LLVMSetGlobalConstant".} + # Operations on aliases +proc AddAlias*(M: ModuleRef, Ty: TypeRef, Aliasee: ValueRef, Name: cstring): ValueRef{. + cdecl, dynlib: libname, importc: "LLVMAddAlias".} + # Operations on functions +proc AddFunction*(M: ModuleRef, Name: cstring, FunctionTy: TypeRef): ValueRef{. + cdecl, dynlib: libname, importc: "LLVMAddFunction".} +proc GetNamedFunction*(M: ModuleRef, Name: cstring): ValueRef{.cdecl, + dynlib: libname, importc: "LLVMGetNamedFunction".} +proc GetFirstFunction*(M: ModuleRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMGetFirstFunction".} +proc GetLastFunction*(M: ModuleRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMGetLastFunction".} +proc GetNextFunction*(Fn: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMGetNextFunction".} +proc GetPreviousFunction*(Fn: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMGetPreviousFunction".} +proc DeleteFunction*(Fn: ValueRef){.cdecl, dynlib: libname, + importc: "LLVMDeleteFunction".} +proc GetIntrinsicID*(Fn: ValueRef): int32{.cdecl, dynlib: libname, + importc: "LLVMGetIntrinsicID".} +proc GetFunctionCallConv*(Fn: ValueRef): int32{.cdecl, dynlib: libname, + importc: "LLVMGetFunctionCallConv".} +proc SetFunctionCallConv*(Fn: ValueRef, CC: int32){.cdecl, dynlib: libname, + importc: "LLVMSetFunctionCallConv".} +proc GetGC*(Fn: ValueRef): cstring{.cdecl, dynlib: libname, importc: "LLVMGetGC".} +proc SetGC*(Fn: ValueRef, Name: cstring){.cdecl, dynlib: libname, + importc: "LLVMSetGC".} +proc AddFunctionAttr*(Fn: ValueRef, PA: Attribute){.cdecl, dynlib: libname, + importc: "LLVMAddFunctionAttr".} +proc GetFunctionAttr*(Fn: ValueRef): Attribute{.cdecl, dynlib: libname, + importc: "LLVMGetFunctionAttr".} +proc RemoveFunctionAttr*(Fn: ValueRef, PA: Attribute){.cdecl, dynlib: libname, + importc: "LLVMRemoveFunctionAttr".} + # Operations on parameters +proc CountParams*(Fn: ValueRef): int32{.cdecl, dynlib: libname, + importc: "LLVMCountParams".} +proc GetParams*(Fn: ValueRef, Params: ptr ValueRef){.cdecl, dynlib: libname, + importc: "LLVMGetParams".} +proc GetParam*(Fn: ValueRef, Index: int32): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMGetParam".} +proc GetParamParent*(Inst: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMGetParamParent".} +proc GetFirstParam*(Fn: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMGetFirstParam".} +proc GetLastParam*(Fn: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMGetLastParam".} +proc GetNextParam*(Arg: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMGetNextParam".} +proc GetPreviousParam*(Arg: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMGetPreviousParam".} +proc AddAttribute*(Arg: ValueRef, PA: Attribute){.cdecl, dynlib: libname, + importc: "LLVMAddAttribute".} +proc RemoveAttribute*(Arg: ValueRef, PA: Attribute){.cdecl, dynlib: libname, + importc: "LLVMRemoveAttribute".} +proc GetAttribute*(Arg: ValueRef): Attribute{.cdecl, dynlib: libname, + importc: "LLVMGetAttribute".} +proc SetParamAlignment*(Arg: ValueRef, align: int32){.cdecl, dynlib: libname, + importc: "LLVMSetParamAlignment".} + # Operations on basic blocks +proc BasicBlockAsValue*(BB: BasicBlockRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMBasicBlockAsValue".} +proc ValueIsBasicBlock*(Val: ValueRef): int32{.cdecl, dynlib: libname, + importc: "LLVMValueIsBasicBlock".} +proc ValueAsBasicBlock*(Val: ValueRef): BasicBlockRef{.cdecl, dynlib: libname, + importc: "LLVMValueAsBasicBlock".} +proc GetBasicBlockParent*(BB: BasicBlockRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMGetBasicBlockParent".} +proc CountBasicBlocks*(Fn: ValueRef): int32{.cdecl, dynlib: libname, + importc: "LLVMCountBasicBlocks".} +proc GetBasicBlocks*(Fn: ValueRef, BasicBlocks: ptr BasicBlockRef){.cdecl, + dynlib: libname, importc: "LLVMGetBasicBlocks".} +proc GetFirstBasicBlock*(Fn: ValueRef): BasicBlockRef{.cdecl, dynlib: libname, + importc: "LLVMGetFirstBasicBlock".} +proc GetLastBasicBlock*(Fn: ValueRef): BasicBlockRef{.cdecl, dynlib: libname, + importc: "LLVMGetLastBasicBlock".} +proc GetNextBasicBlock*(BB: BasicBlockRef): BasicBlockRef{.cdecl, + dynlib: libname, importc: "LLVMGetNextBasicBlock".} +proc GetPreviousBasicBlock*(BB: BasicBlockRef): BasicBlockRef{.cdecl, + dynlib: libname, importc: "LLVMGetPreviousBasicBlock".} +proc GetEntryBasicBlock*(Fn: ValueRef): BasicBlockRef{.cdecl, dynlib: libname, + importc: "LLVMGetEntryBasicBlock".} +proc AppendBasicBlockInContext*(C: ContextRef, Fn: ValueRef, Name: cstring): BasicBlockRef{. + cdecl, dynlib: libname, importc: "LLVMAppendBasicBlockInContext".} +proc InsertBasicBlockInContext*(C: ContextRef, BB: BasicBlockRef, Name: cstring): BasicBlockRef{. + cdecl, dynlib: libname, importc: "LLVMInsertBasicBlockInContext".} +proc AppendBasicBlock*(Fn: ValueRef, Name: cstring): BasicBlockRef{.cdecl, + dynlib: libname, importc: "LLVMAppendBasicBlock".} +proc InsertBasicBlock*(InsertBeforeBB: BasicBlockRef, Name: cstring): BasicBlockRef{. + cdecl, dynlib: libname, importc: "LLVMInsertBasicBlock".} +proc DeleteBasicBlock*(BB: BasicBlockRef){.cdecl, dynlib: libname, + importc: "LLVMDeleteBasicBlock".} + # Operations on instructions +proc GetInstructionParent*(Inst: ValueRef): BasicBlockRef{.cdecl, + dynlib: libname, importc: "LLVMGetInstructionParent".} +proc GetFirstInstruction*(BB: BasicBlockRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMGetFirstInstruction".} +proc GetLastInstruction*(BB: BasicBlockRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMGetLastInstruction".} +proc GetNextInstruction*(Inst: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMGetNextInstruction".} +proc GetPreviousInstruction*(Inst: ValueRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMGetPreviousInstruction".} + # Operations on call sites +proc SetInstructionCallConv*(Instr: ValueRef, CC: int32){.cdecl, + dynlib: libname, importc: "LLVMSetInstructionCallConv".} +proc GetInstructionCallConv*(Instr: ValueRef): int32{.cdecl, dynlib: libname, + importc: "LLVMGetInstructionCallConv".} +proc AddInstrAttribute*(Instr: ValueRef, index: int32, para3: Attribute){.cdecl, + dynlib: libname, importc: "LLVMAddInstrAttribute".} +proc RemoveInstrAttribute*(Instr: ValueRef, index: int32, para3: Attribute){. + cdecl, dynlib: libname, importc: "LLVMRemoveInstrAttribute".} +proc SetInstrParamAlignment*(Instr: ValueRef, index: int32, align: int32){. + cdecl, dynlib: libname, importc: "LLVMSetInstrParamAlignment".} + # Operations on call instructions (only) +proc IsTailCall*(CallInst: ValueRef): int32{.cdecl, dynlib: libname, + importc: "LLVMIsTailCall".} +proc SetTailCall*(CallInst: ValueRef, IsTailCall: int32){.cdecl, + dynlib: libname, importc: "LLVMSetTailCall".} + # Operations on phi nodes +proc AddIncoming*(PhiNode: ValueRef, IncomingValues: ptr ValueRef, + IncomingBlocks: ptr BasicBlockRef, Count: int32){.cdecl, + dynlib: libname, importc: "LLVMAddIncoming".} +proc CountIncoming*(PhiNode: ValueRef): int32{.cdecl, dynlib: libname, + importc: "LLVMCountIncoming".} +proc GetIncomingValue*(PhiNode: ValueRef, Index: int32): ValueRef{.cdecl, + dynlib: libname, importc: "LLVMGetIncomingValue".} +proc GetIncomingBlock*(PhiNode: ValueRef, Index: int32): BasicBlockRef{.cdecl, + dynlib: libname, importc: "LLVMGetIncomingBlock".} + #===-- Instruction builders ----------------------------------------------=== + # An instruction builder represents a point within a basic block, and is the + # * exclusive means of building instructions using the C interface. + # +proc CreateBuilderInContext*(C: ContextRef): BuilderRef{.cdecl, dynlib: libname, + importc: "LLVMCreateBuilderInContext".} +proc CreateBuilder*(): BuilderRef{.cdecl, dynlib: libname, + importc: "LLVMCreateBuilder".} +proc PositionBuilder*(Builder: BuilderRef, theBlock: BasicBlockRef, + Instr: ValueRef){.cdecl, dynlib: libname, + importc: "LLVMPositionBuilder".} +proc PositionBuilderBefore*(Builder: BuilderRef, Instr: ValueRef){.cdecl, + dynlib: libname, importc: "LLVMPositionBuilderBefore".} +proc PositionBuilderAtEnd*(Builder: BuilderRef, theBlock: BasicBlockRef){.cdecl, + dynlib: libname, importc: "LLVMPositionBuilderAtEnd".} +proc GetInsertBlock*(Builder: BuilderRef): BasicBlockRef{.cdecl, + dynlib: libname, importc: "LLVMGetInsertBlock".} +proc ClearInsertionPosition*(Builder: BuilderRef){.cdecl, dynlib: libname, + importc: "LLVMClearInsertionPosition".} +proc InsertIntoBuilder*(Builder: BuilderRef, Instr: ValueRef){.cdecl, + dynlib: libname, importc: "LLVMInsertIntoBuilder".} +proc InsertIntoBuilderWithName*(Builder: BuilderRef, Instr: ValueRef, + Name: cstring){.cdecl, dynlib: libname, + importc: "LLVMInsertIntoBuilderWithName".} +proc DisposeBuilder*(Builder: BuilderRef){.cdecl, dynlib: libname, + importc: "LLVMDisposeBuilder".} + # Terminators +proc BuildRetVoid*(para1: BuilderRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMBuildRetVoid".} +proc BuildRet*(para1: BuilderRef, V: ValueRef): ValueRef{.cdecl, + dynlib: libname, importc: "LLVMBuildRet".} +proc BuildAggregateRet*(para1: BuilderRef, RetVals: ptr ValueRef, N: int32): ValueRef{. + cdecl, dynlib: libname, importc: "LLVMBuildAggregateRet".} +proc BuildBr*(para1: BuilderRef, Dest: BasicBlockRef): ValueRef{.cdecl, + dynlib: libname, importc: "LLVMBuildBr".} +proc BuildCondBr*(para1: BuilderRef, Cond: ValueRef, ThenBranch: BasicBlockRef, + ElseBranch: BasicBlockRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMBuildCondBr".} +proc BuildSwitch*(para1: BuilderRef, V: ValueRef, ElseBranch: BasicBlockRef, + NumCases: int32): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMBuildSwitch".} +proc BuildInvoke*(para1: BuilderRef, Fn: ValueRef, Args: ptr ValueRef, + NumArgs: int32, ThenBranch: BasicBlockRef, + Catch: BasicBlockRef, Name: cstring): ValueRef{.cdecl, + dynlib: libname, importc: "LLVMBuildInvoke".} +proc BuildUnwind*(para1: BuilderRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMBuildUnwind".} +proc BuildUnreachable*(para1: BuilderRef): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMBuildUnreachable".} + # Add a case to the switch instruction +proc AddCase*(Switch: ValueRef, OnVal: ValueRef, Dest: BasicBlockRef){.cdecl, + dynlib: libname, importc: "LLVMAddCase".} + # Arithmetic +proc BuildAdd*(para1: BuilderRef, LHS: ValueRef, RHS: ValueRef, Name: cstring): ValueRef{. + cdecl, dynlib: libname, importc: "LLVMBuildAdd".} +proc BuildNSWAdd*(para1: BuilderRef, LHS: ValueRef, RHS: ValueRef, Name: cstring): ValueRef{. + cdecl, dynlib: libname, importc: "LLVMBuildNSWAdd".} +proc BuildFAdd*(para1: BuilderRef, LHS: ValueRef, RHS: ValueRef, Name: cstring): ValueRef{. + cdecl, dynlib: libname, importc: "LLVMBuildFAdd".} +proc BuildSub*(para1: BuilderRef, LHS: ValueRef, RHS: ValueRef, Name: cstring): ValueRef{. + cdecl, dynlib: libname, importc: "LLVMBuildSub".} +proc BuildFSub*(para1: BuilderRef, LHS: ValueRef, RHS: ValueRef, Name: cstring): ValueRef{. + cdecl, dynlib: libname, importc: "LLVMBuildFSub".} +proc BuildMul*(para1: BuilderRef, LHS: ValueRef, RHS: ValueRef, Name: cstring): ValueRef{. + cdecl, dynlib: libname, importc: "LLVMBuildMul".} +proc BuildFMul*(para1: BuilderRef, LHS: ValueRef, RHS: ValueRef, Name: cstring): ValueRef{. + cdecl, dynlib: libname, importc: "LLVMBuildFMul".} +proc BuildUDiv*(para1: BuilderRef, LHS: ValueRef, RHS: ValueRef, Name: cstring): ValueRef{. + cdecl, dynlib: libname, importc: "LLVMBuildUDiv".} +proc BuildSDiv*(para1: BuilderRef, LHS: ValueRef, RHS: ValueRef, Name: cstring): ValueRef{. + cdecl, dynlib: libname, importc: "LLVMBuildSDiv".} +proc BuildExactSDiv*(para1: BuilderRef, LHS: ValueRef, RHS: ValueRef, + Name: cstring): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMBuildExactSDiv".} +proc BuildFDiv*(para1: BuilderRef, LHS: ValueRef, RHS: ValueRef, Name: cstring): ValueRef{. + cdecl, dynlib: libname, importc: "LLVMBuildFDiv".} +proc BuildURem*(para1: BuilderRef, LHS: ValueRef, RHS: ValueRef, Name: cstring): ValueRef{. + cdecl, dynlib: libname, importc: "LLVMBuildURem".} +proc BuildSRem*(para1: BuilderRef, LHS: ValueRef, RHS: ValueRef, Name: cstring): ValueRef{. + cdecl, dynlib: libname, importc: "LLVMBuildSRem".} +proc BuildFRem*(para1: BuilderRef, LHS: ValueRef, RHS: ValueRef, Name: cstring): ValueRef{. + cdecl, dynlib: libname, importc: "LLVMBuildFRem".} +proc BuildShl*(para1: BuilderRef, LHS: ValueRef, RHS: ValueRef, Name: cstring): ValueRef{. + cdecl, dynlib: libname, importc: "LLVMBuildShl".} +proc BuildLShr*(para1: BuilderRef, LHS: ValueRef, RHS: ValueRef, Name: cstring): ValueRef{. + cdecl, dynlib: libname, importc: "LLVMBuildLShr".} +proc BuildAShr*(para1: BuilderRef, LHS: ValueRef, RHS: ValueRef, Name: cstring): ValueRef{. + cdecl, dynlib: libname, importc: "LLVMBuildAShr".} +proc BuildAnd*(para1: BuilderRef, LHS: ValueRef, RHS: ValueRef, Name: cstring): ValueRef{. + cdecl, dynlib: libname, importc: "LLVMBuildAnd".} +proc BuildOr*(para1: BuilderRef, LHS: ValueRef, RHS: ValueRef, Name: cstring): ValueRef{. + cdecl, dynlib: libname, importc: "LLVMBuildOr".} +proc BuildXor*(para1: BuilderRef, LHS: ValueRef, RHS: ValueRef, Name: cstring): ValueRef{. + cdecl, dynlib: libname, importc: "LLVMBuildXor".} +proc BuildNeg*(para1: BuilderRef, V: ValueRef, Name: cstring): ValueRef{.cdecl, + dynlib: libname, importc: "LLVMBuildNeg".} +proc BuildFNeg*(para1: BuilderRef, V: ValueRef, Name: cstring): ValueRef{.cdecl, + dynlib: libname, importc: "LLVMBuildFNeg".} +proc BuildNot*(para1: BuilderRef, V: ValueRef, Name: cstring): ValueRef{.cdecl, + dynlib: libname, importc: "LLVMBuildNot".} + # Memory +proc BuildMalloc*(para1: BuilderRef, Ty: TypeRef, Name: cstring): ValueRef{. + cdecl, dynlib: libname, importc: "LLVMBuildMalloc".} +proc BuildArrayMalloc*(para1: BuilderRef, Ty: TypeRef, Val: ValueRef, + Name: cstring): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMBuildArrayMalloc".} +proc BuildAlloca*(para1: BuilderRef, Ty: TypeRef, Name: cstring): ValueRef{. + cdecl, dynlib: libname, importc: "LLVMBuildAlloca".} +proc BuildArrayAlloca*(para1: BuilderRef, Ty: TypeRef, Val: ValueRef, + Name: cstring): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMBuildArrayAlloca".} +proc BuildFree*(para1: BuilderRef, PointerVal: ValueRef): ValueRef{.cdecl, + dynlib: libname, importc: "LLVMBuildFree".} +proc BuildLoad*(para1: BuilderRef, PointerVal: ValueRef, Name: cstring): ValueRef{. + cdecl, dynlib: libname, importc: "LLVMBuildLoad".} +proc BuildStore*(para1: BuilderRef, Val: ValueRef, thePtr: ValueRef): ValueRef{. + cdecl, dynlib: libname, importc: "LLVMBuildStore".} +proc BuildGEP*(B: BuilderRef, Pointer: ValueRef, Indices: ptr ValueRef, + NumIndices: int32, Name: cstring): ValueRef{.cdecl, + dynlib: libname, importc: "LLVMBuildGEP".} +proc BuildInBoundsGEP*(B: BuilderRef, Pointer: ValueRef, Indices: ptr ValueRef, + NumIndices: int32, Name: cstring): ValueRef{.cdecl, + dynlib: libname, importc: "LLVMBuildInBoundsGEP".} +proc BuildStructGEP*(B: BuilderRef, Pointer: ValueRef, Idx: int32, Name: cstring): ValueRef{. + cdecl, dynlib: libname, importc: "LLVMBuildStructGEP".} +proc BuildGlobalString*(B: BuilderRef, Str: cstring, Name: cstring): ValueRef{. + cdecl, dynlib: libname, importc: "LLVMBuildGlobalString".} +proc BuildGlobalStringPtr*(B: BuilderRef, Str: cstring, Name: cstring): ValueRef{. + cdecl, dynlib: libname, importc: "LLVMBuildGlobalStringPtr".} + # Casts +proc BuildTrunc*(para1: BuilderRef, Val: ValueRef, DestTy: TypeRef, + Name: cstring): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMBuildTrunc".} +proc BuildZExt*(para1: BuilderRef, Val: ValueRef, DestTy: TypeRef, Name: cstring): ValueRef{. + cdecl, dynlib: libname, importc: "LLVMBuildZExt".} +proc BuildSExt*(para1: BuilderRef, Val: ValueRef, DestTy: TypeRef, Name: cstring): ValueRef{. + cdecl, dynlib: libname, importc: "LLVMBuildSExt".} +proc BuildFPToUI*(para1: BuilderRef, Val: ValueRef, DestTy: TypeRef, + Name: cstring): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMBuildFPToUI".} +proc BuildFPToSI*(para1: BuilderRef, Val: ValueRef, DestTy: TypeRef, + Name: cstring): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMBuildFPToSI".} +proc BuildUIToFP*(para1: BuilderRef, Val: ValueRef, DestTy: TypeRef, + Name: cstring): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMBuildUIToFP".} +proc BuildSIToFP*(para1: BuilderRef, Val: ValueRef, DestTy: TypeRef, + Name: cstring): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMBuildSIToFP".} +proc BuildFPTrunc*(para1: BuilderRef, Val: ValueRef, DestTy: TypeRef, + Name: cstring): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMBuildFPTrunc".} +proc BuildFPExt*(para1: BuilderRef, Val: ValueRef, DestTy: TypeRef, + Name: cstring): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMBuildFPExt".} +proc BuildPtrToInt*(para1: BuilderRef, Val: ValueRef, DestTy: TypeRef, + Name: cstring): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMBuildPtrToInt".} +proc BuildIntToPtr*(para1: BuilderRef, Val: ValueRef, DestTy: TypeRef, + Name: cstring): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMBuildIntToPtr".} +proc BuildBitCast*(para1: BuilderRef, Val: ValueRef, DestTy: TypeRef, + Name: cstring): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMBuildBitCast".} +proc BuildZExtOrBitCast*(para1: BuilderRef, Val: ValueRef, DestTy: TypeRef, + Name: cstring): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMBuildZExtOrBitCast".} +proc BuildSExtOrBitCast*(para1: BuilderRef, Val: ValueRef, DestTy: TypeRef, + Name: cstring): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMBuildSExtOrBitCast".} +proc BuildTruncOrBitCast*(para1: BuilderRef, Val: ValueRef, DestTy: TypeRef, + Name: cstring): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMBuildTruncOrBitCast".} +proc BuildPointerCast*(para1: BuilderRef, Val: ValueRef, DestTy: TypeRef, + Name: cstring): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMBuildPointerCast".} +proc BuildIntCast*(para1: BuilderRef, Val: ValueRef, DestTy: TypeRef, + Name: cstring): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMBuildIntCast".} +proc BuildFPCast*(para1: BuilderRef, Val: ValueRef, DestTy: TypeRef, + Name: cstring): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMBuildFPCast".} + # Comparisons +proc BuildICmp*(para1: BuilderRef, Op: IntPredicate, LHS: ValueRef, + RHS: ValueRef, Name: cstring): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMBuildICmp".} +proc BuildFCmp*(para1: BuilderRef, Op: RealPredicate, LHS: ValueRef, + RHS: ValueRef, Name: cstring): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMBuildFCmp".} + # Miscellaneous instructions +proc BuildPhi*(para1: BuilderRef, Ty: TypeRef, Name: cstring): ValueRef{.cdecl, + dynlib: libname, importc: "LLVMBuildPhi".} +proc BuildCall*(para1: BuilderRef, Fn: ValueRef, Args: ptr ValueRef, + NumArgs: int32, Name: cstring): ValueRef{.cdecl, + dynlib: libname, importc: "LLVMBuildCall".} +proc BuildSelect*(para1: BuilderRef, Cond: ValueRef, ThenBranch: ValueRef, + ElseBranch: ValueRef, Name: cstring): ValueRef{.cdecl, + dynlib: libname, importc: "LLVMBuildSelect".} +proc BuildVAArg*(para1: BuilderRef, List: ValueRef, Ty: TypeRef, Name: cstring): ValueRef{. + cdecl, dynlib: libname, importc: "LLVMBuildVAArg".} +proc BuildExtractElement*(para1: BuilderRef, VecVal: ValueRef, Index: ValueRef, + Name: cstring): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMBuildExtractElement".} +proc BuildInsertElement*(para1: BuilderRef, VecVal: ValueRef, EltVal: ValueRef, + Index: ValueRef, Name: cstring): ValueRef{.cdecl, + dynlib: libname, importc: "LLVMBuildInsertElement".} +proc BuildShuffleVector*(para1: BuilderRef, V1: ValueRef, V2: ValueRef, + Mask: ValueRef, Name: cstring): ValueRef{.cdecl, + dynlib: libname, importc: "LLVMBuildShuffleVector".} +proc BuildExtractValue*(para1: BuilderRef, AggVal: ValueRef, Index: int32, + Name: cstring): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMBuildExtractValue".} +proc BuildInsertValue*(para1: BuilderRef, AggVal: ValueRef, EltVal: ValueRef, + Index: int32, Name: cstring): ValueRef{.cdecl, + dynlib: libname, importc: "LLVMBuildInsertValue".} +proc BuildIsNull*(para1: BuilderRef, Val: ValueRef, Name: cstring): ValueRef{. + cdecl, dynlib: libname, importc: "LLVMBuildIsNull".} +proc BuildIsNotNull*(para1: BuilderRef, Val: ValueRef, Name: cstring): ValueRef{. + cdecl, dynlib: libname, importc: "LLVMBuildIsNotNull".} +proc BuildPtrDiff*(para1: BuilderRef, LHS: ValueRef, RHS: ValueRef, + Name: cstring): ValueRef{.cdecl, dynlib: libname, + importc: "LLVMBuildPtrDiff".} + #===-- Module providers --------------------------------------------------=== + # Encapsulates the module M in a module provider, taking ownership of the + # module. + # See the constructor llvm::ExistingModuleProvider::ExistingModuleProvider. + # +proc CreateModuleProviderForExistingModule*(M: ModuleRef): ModuleProviderRef{. + cdecl, dynlib: libname, importc: "LLVMCreateModuleProviderForExistingModule".} + # Destroys the module provider MP as well as the contained module. + # See the destructor llvm::ModuleProvider::~ModuleProvider. + # +proc DisposeModuleProvider*(MP: ModuleProviderRef){.cdecl, dynlib: libname, + importc: "LLVMDisposeModuleProvider".} + #===-- Memory buffers ----------------------------------------------------=== +proc CreateMemoryBufferWithContentsOfFile*(Path: cstring, + OutMemBuf: ptr MemoryBufferRef, OutMessage: var cstring): int32{.cdecl, + dynlib: libname, importc: "LLVMCreateMemoryBufferWithContentsOfFile".} +proc CreateMemoryBufferWithSTDIN*(OutMemBuf: ptr MemoryBufferRef, + OutMessage: var cstring): int32{.cdecl, + dynlib: libname, importc: "LLVMCreateMemoryBufferWithSTDIN".} +proc DisposeMemoryBuffer*(MemBuf: MemoryBufferRef){.cdecl, dynlib: libname, + importc: "LLVMDisposeMemoryBuffer".} + #===-- 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. +proc CreatePassManager*(): PassManagerRef{.cdecl, dynlib: libname, + importc: "LLVMCreatePassManager".} + # 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. +proc CreateFunctionPassManager*(MP: ModuleProviderRef): PassManagerRef{.cdecl, + dynlib: libname, importc: "LLVMCreateFunctionPassManager".} + # 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&). +proc RunPassManager*(PM: PassManagerRef, M: ModuleRef): int32{.cdecl, + dynlib: libname, importc: "LLVMRunPassManager".} + # 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. +proc InitializeFunctionPassManager*(FPM: PassManagerRef): int32{.cdecl, + dynlib: libname, importc: "LLVMInitializeFunctionPassManager".} + # 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&). +proc RunFunctionPassManager*(FPM: PassManagerRef, F: ValueRef): int32{.cdecl, + dynlib: libname, importc: "LLVMRunFunctionPassManager".} + # 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. +proc FinalizeFunctionPassManager*(FPM: PassManagerRef): int32{.cdecl, + dynlib: libname, importc: "LLVMFinalizeFunctionPassManager".} + # Frees the memory of a pass pipeline. For function pipelines, does not free + # the module provider. + # See llvm::PassManagerBase::~PassManagerBase. +proc DisposePassManager*(PM: PassManagerRef){.cdecl, dynlib: libname, + importc: "LLVMDisposePassManager".} + # Analysis.h + # verifier will print to stderr and abort() + # verifier will print to stderr and return 1 + # verifier will just return 1 +type + VerifierFailureAction* = enum # Verifies that a module is valid, taking the specified action if not. + # Optionally returns a human-readable description of any invalid constructs. + # OutMessage must be disposed with LLVMDisposeMessage. + AbortProcessAction, PrintMessageAction, ReturnStatusAction + +proc VerifyModule*(M: ModuleRef, Action: VerifierFailureAction, + OutMessage: var cstring): int32{.cdecl, dynlib: libname, + importc: "LLVMVerifyModule".} + # Verifies that a single function is valid, taking the specified action. Useful + # for debugging. +proc VerifyFunction*(Fn: ValueRef, Action: VerifierFailureAction): int32{.cdecl, + dynlib: libname, importc: "LLVMVerifyFunction".} + # Open up a ghostview window that displays the CFG of the current function. + # Useful for debugging. +proc ViewFunctionCFG*(Fn: ValueRef){.cdecl, dynlib: libname, + importc: "LLVMViewFunctionCFG".} +proc ViewFunctionCFGOnly*(Fn: ValueRef){.cdecl, dynlib: libname, + importc: "LLVMViewFunctionCFGOnly".} + # BitReader.h + # Builds a module from the bitcode in the specified memory buffer, returning a + # reference to the module via the OutModule parameter. Returns 0 on success. + # Optionally returns a human-readable error message via OutMessage. +proc ParseBitcode*(MemBuf: MemoryBufferRef, OutModule: var ModuleRef, + OutMessage: var cstring): int32{.cdecl, dynlib: libname, + importc: "LLVMParseBitcode".} +proc ParseBitcodeInContext*(ContextRef: ContextRef, MemBuf: MemoryBufferRef, + OutModule: var ModuleRef, OutMessage: var cstring): int32{. + cdecl, dynlib: libname, importc: "LLVMParseBitcodeInContext".} + # Reads a module from the specified path, returning via the OutMP parameter + # a module provider which performs lazy deserialization. Returns 0 on success. + # Optionally returns a human-readable error message via OutMessage. +proc GetBitcodeModuleProvider*(MemBuf: MemoryBufferRef, + OutMP: var ModuleProviderRef, + OutMessage: var cstring): int32{. + cdecl, dynlib: libname, importc: "LLVMGetBitcodeModuleProvider".} +proc GetBitcodeModuleProviderInContext*(ContextRef: ContextRef, + MemBuf: MemoryBufferRef, + OutMP: var ModuleProviderRef, + OutMessage: var cstring): int32{.cdecl, + dynlib: libname, importc: "LLVMGetBitcodeModuleProviderInContext".} + # BitWriter.h + #===-- Operations on modules ---------------------------------------------=== + # Writes a module to an open file descriptor. Returns 0 on success. + # Closes the Handle. Use dup first if this is not what you want. +proc WriteBitcodeToFileHandle*(M: ModuleRef, Handle: int32): int32{.cdecl, + dynlib: libname, importc: "LLVMWriteBitcodeToFileHandle".} + # Writes a module to the specified path. Returns 0 on success. +proc WriteBitcodeToFile*(M: ModuleRef, Path: cstring): int32{.cdecl, + dynlib: libname, importc: "LLVMWriteBitcodeToFile".} + # Target.h +const + BigEndian* = 0 + LittleEndian* = 1 + +type + ByteOrdering* = int32 + OpaqueTargetData {.pure} = object + StructLayout {.pure} = object + TargetDataRef* = ref OpaqueTargetData + StructLayoutRef* = ref StructLayout + + +#===-- Target Data -------------------------------------------------------=== +# Creates target data from a target layout string. +# See the constructor llvm::TargetData::TargetData. + +proc CreateTargetData*(StringRep: cstring): TargetDataRef{.cdecl, + dynlib: libname, importc: "LLVMCreateTargetData".} + # Adds target data information to a pass manager. This does not take ownership + # of the target data. + # See the method llvm::PassManagerBase::add. +proc AddTargetData*(para1: TargetDataRef, para2: PassManagerRef){.cdecl, + dynlib: libname, importc: "LLVMAddTargetData".} + # Converts target data to a target layout string. The string must be disposed + # with LLVMDisposeMessage. + # See the constructor llvm::TargetData::TargetData. +proc CopyStringRepOfTargetData*(para1: TargetDataRef): cstring{.cdecl, + dynlib: libname, importc: "LLVMCopyStringRepOfTargetData".} + # Returns the byte order of a target, either LLVMBigEndian or + # LLVMLittleEndian. + # See the method llvm::TargetData::isLittleEndian. +proc ByteOrder*(para1: TargetDataRef): ByteOrdering{.cdecl, dynlib: libname, + importc: "LLVMByteOrder".} + # Returns the pointer size in bytes for a target. + # See the method llvm::TargetData::getPointerSize. +proc PointerSize*(para1: TargetDataRef): int32{.cdecl, dynlib: libname, + importc: "LLVMPointerSize".} + # Returns the integer type that is the same size as a pointer on a target. + # See the method llvm::TargetData::getIntPtrType. +proc IntPtrType*(para1: TargetDataRef): TypeRef{.cdecl, dynlib: libname, + importc: "LLVMIntPtrType".} + # Computes the size of a type in bytes for a target. + # See the method llvm::TargetData::getTypeSizeInBits. +proc SizeOfTypeInBits*(para1: TargetDataRef, para2: TypeRef): int64{.cdecl, + dynlib: libname, importc: "LLVMSizeOfTypeInBits".} + # Computes the storage size of a type in bytes for a target. + # See the method llvm::TargetData::getTypeStoreSize. +proc StoreSizeOfType*(para1: TargetDataRef, para2: TypeRef): int64{.cdecl, + dynlib: libname, importc: "LLVMStoreSizeOfType".} + # Computes the ABI size of a type in bytes for a target. + # See the method llvm::TargetData::getTypeAllocSize. +proc ABISizeOfType*(para1: TargetDataRef, para2: TypeRef): int64{.cdecl, + dynlib: libname, importc: "LLVMABISizeOfType".} + # Computes the ABI alignment of a type in bytes for a target. + # See the method llvm::TargetData::getTypeABISize. +proc ABIAlignmentOfType*(para1: TargetDataRef, para2: TypeRef): int32{.cdecl, + dynlib: libname, importc: "LLVMABIAlignmentOfType".} + # Computes the call frame alignment of a type in bytes for a target. + # See the method llvm::TargetData::getTypeABISize. +proc CallFrameAlignmentOfType*(para1: TargetDataRef, para2: TypeRef): int32{. + cdecl, dynlib: libname, importc: "LLVMCallFrameAlignmentOfType".} + # Computes the preferred alignment of a type in bytes for a target. + # See the method llvm::TargetData::getTypeABISize. +proc PreferredAlignmentOfType*(para1: TargetDataRef, para2: TypeRef): int32{. + cdecl, dynlib: libname, importc: "LLVMPreferredAlignmentOfType".} + # Computes the preferred alignment of a global variable in bytes for a target. + # See the method llvm::TargetData::getPreferredAlignment. +proc PreferredAlignmentOfGlobal*(para1: TargetDataRef, GlobalVar: ValueRef): int32{. + cdecl, dynlib: libname, importc: "LLVMPreferredAlignmentOfGlobal".} + # Computes the structure element that contains the byte offset for a target. + # See the method llvm::StructLayout::getElementContainingOffset. +proc ElementAtOffset*(para1: TargetDataRef, StructTy: TypeRef, Offset: int64): int32{. + cdecl, dynlib: libname, importc: "LLVMElementAtOffset".} + # Computes the byte offset of the indexed struct element for a target. + # See the method llvm::StructLayout::getElementContainingOffset. +proc OffsetOfElement*(para1: TargetDataRef, StructTy: TypeRef, Element: int32): int64{. + cdecl, dynlib: libname, importc: "LLVMOffsetOfElement".} + # Struct layouts are speculatively cached. If a TargetDataRef is alive when + # types are being refined and removed, this method must be called whenever a + # struct type is removed to avoid a dangling pointer in this cache. + # See the method llvm::TargetData::InvalidateStructLayoutInfo. +proc InvalidateStructLayout*(para1: TargetDataRef, StructTy: TypeRef){.cdecl, + dynlib: libname, importc: "LLVMInvalidateStructLayout".} + # Deallocates a TargetData. + # See the destructor llvm::TargetData::~TargetData. +proc DisposeTargetData*(para1: TargetDataRef){.cdecl, dynlib: libname, + importc: "LLVMDisposeTargetData".} + # ExecutionEngine.h +proc LinkInJIT*(){.cdecl, dynlib: libname, importc: "LLVMLinkInJIT".} +proc LinkInInterpreter*(){.cdecl, dynlib: libname, + importc: "LLVMLinkInInterpreter".} +type + OpaqueGenericValue {.pure} = object + OpaqueExecutionEngine {.pure} = object + GenericValueRef* = OpaqueGenericValue + ExecutionEngineRef* = OpaqueExecutionEngine + +#===-- Operations on generic values --------------------------------------=== + +proc CreateGenericValueOfInt*(Ty: TypeRef, N: int64, IsSigned: int32): GenericValueRef{. + cdecl, dynlib: libname, importc: "LLVMCreateGenericValueOfInt".} +proc CreateGenericValueOfPointer*(P: pointer): GenericValueRef{.cdecl, + dynlib: libname, importc: "LLVMCreateGenericValueOfPointer".} +proc CreateGenericValueOfFloat*(Ty: TypeRef, N: float64): GenericValueRef{. + cdecl, dynlib: libname, importc: "LLVMCreateGenericValueOfFloat".} +proc GenericValueIntWidth*(GenValRef: GenericValueRef): int32{.cdecl, + dynlib: libname, importc: "LLVMGenericValueIntWidth".} +proc GenericValueToInt*(GenVal: GenericValueRef, IsSigned: int32): int64{.cdecl, + dynlib: libname, importc: "LLVMGenericValueToInt".} +proc GenericValueToPointer*(GenVal: GenericValueRef): pointer{.cdecl, + dynlib: libname, importc: "LLVMGenericValueToPointer".} +proc GenericValueToFloat*(TyRef: TypeRef, GenVal: GenericValueRef): float64{. + cdecl, dynlib: libname, importc: "LLVMGenericValueToFloat".} +proc DisposeGenericValue*(GenVal: GenericValueRef){.cdecl, dynlib: libname, + importc: "LLVMDisposeGenericValue".} + +#===-- Operations on execution engines -----------------------------------=== +proc CreateExecutionEngine*(OutEE: var ExecutionEngineRef, MP: ModuleProviderRef, + OutError: var cstring): int32{.cdecl, dynlib: libname, + importc: "LLVMCreateExecutionEngine".} +proc CreateInterpreter*(OutInterp: var ExecutionEngineRef, MP: ModuleProviderRef, + OutError: var cstring): int32{.cdecl, dynlib: libname, + importc: "LLVMCreateInterpreter".} +proc CreateJITCompiler*(OutJIT: var ExecutionEngineRef, MP: ModuleProviderRef, + OptLevel: int32, OutError: var cstring): int32{.cdecl, + dynlib: libname, importc: "LLVMCreateJITCompiler".} +proc DisposeExecutionEngine*(EE: ExecutionEngineRef){.cdecl, dynlib: libname, + importc: "LLVMDisposeExecutionEngine".} +proc RunStaticConstructors*(EE: ExecutionEngineRef){.cdecl, dynlib: libname, + importc: "LLVMRunStaticConstructors".} +proc RunStaticDestructors*(EE: ExecutionEngineRef){.cdecl, dynlib: libname, + importc: "LLVMRunStaticDestructors".} + +proc RunFunctionAsMain*(EE: ExecutionEngineRef, F: ValueRef, ArgC: int32, + ArgV: cstringArray, EnvP: cstringArray): int32{.cdecl, + dynlib: libname, importc: "LLVMRunFunctionAsMain".} +proc RunFunction*(EE: ExecutionEngineRef, F: ValueRef, NumArgs: int32, + Args: ptr GenericValueRef): GenericValueRef{.cdecl, + dynlib: libname, importc: "LLVMRunFunction".} +proc FreeMachineCodeForFunction*(EE: ExecutionEngineRef, F: ValueRef){.cdecl, + dynlib: libname, importc: "LLVMFreeMachineCodeForFunction".} +proc AddModuleProvider*(EE: ExecutionEngineRef, MP: ModuleProviderRef){.cdecl, + dynlib: libname, importc: "LLVMAddModuleProvider".} +proc RemoveModuleProvider*(EE: ExecutionEngineRef, MP: ModuleProviderRef, + OutMod: var ModuleRef, OutError: var cstring): int32{.cdecl, + dynlib: libname, importc: "LLVMRemoveModuleProvider".} +proc FindFunction*(EE: ExecutionEngineRef, Name: cstring, OutFn: var ValueRef): int32{. + cdecl, dynlib: libname, importc: "LLVMFindFunction".} +proc GetExecutionEngineTargetData*(EE: ExecutionEngineRef): TargetDataRef{. + cdecl, dynlib: libname, importc: "LLVMGetExecutionEngineTargetData".} +proc AddGlobalMapping*(EE: ExecutionEngineRef, Global: ValueRef, + theAddr: pointer){.cdecl, dynlib: libname, + importc: "LLVMAddGlobalMapping".} +proc GetPointerToGlobal*(EE: ExecutionEngineRef, Global: ValueRef): pointer{. + cdecl, dynlib: libname, importc: "LLVMGetPointerToGlobal".} + +# LinkTimeOptimizer.h +# This provides a dummy type for pointers to the LTO object. +type + lto_t* = pointer + lto_status* = enum + LTO_UNKNOWN, LTO_OPT_SUCCESS, LTO_READ_SUCCESS, LTO_READ_FAILURE, + LTO_WRITE_FAILURE, LTO_NO_TARGET, LTO_NO_WORK, LTO_MODULE_MERGE_FAILURE, + LTO_ASM_FAILURE, LTO_NULL_OBJECT + lto_status_t* = lto_status + # This provides C interface to initialize link time optimizer. This allows + # linker to use dlopen() interface to dynamically load LinkTimeOptimizer. + # extern "C" helps, because dlopen() interface uses name to find the symbol. + +proc create_optimizer*(): lto_t{.cdecl, dynlib: libname, + importc: "llvm_create_optimizer".} +proc destroy_optimizer*(lto: lto_t){.cdecl, dynlib: libname, + importc: "llvm_destroy_optimizer".} +proc read_object_file*(lto: lto_t, input_filename: cstring): lto_status_t{. + cdecl, dynlib: libname, importc: "llvm_read_object_file".} +proc optimize_modules*(lto: lto_t, output_filename: cstring): lto_status_t{. + cdecl, dynlib: libname, importc: "llvm_optimize_modules".} + +# lto.h +const + LTO_API_VERSION* = 3 # log2 of alignment + +type + lto_symbol_attributes* = enum + SYMBOL_ALIGNMENT_MASK = 0x0000001F, + SYMBOL_PERMISSIONS_RODATA = 0x00000080, + SYMBOL_PERMISSIONS_CODE = 0x000000A0, + SYMBOL_PERMISSIONS_DATA = 0x000000C0, + SYMBOL_PERMISSIONS_MASK = 0x000000E0, + + SYMBOL_DEFINITION_REGULAR = 0x00000100, + SYMBOL_DEFINITION_TENTATIVE = 0x00000200, + SYMBOL_DEFINITION_WEAK = 0x00000300, + SYMBOL_DEFINITION_UNDEFINED = 0x00000400, + SYMBOL_DEFINITION_WEAKUNDEF = 0x00000500, + SYMBOL_DEFINITION_MASK = 0x00000700, + SYMBOL_SCOPE_INTERNAL = 0x00000800, + + SYMBOL_SCOPE_HIDDEN = 0x00001000, + SYMBOL_SCOPE_DEFAULT = 0x00001800, + SYMBOL_SCOPE_PROTECTED = 0x00002000, + SYMBOL_SCOPE_MASK = 0x00003800, + lto_debug_model* = enum + DEBUG_MODEL_NONE = 0, DEBUG_MODEL_DWARF = 1 + lto_codegen_model* = enum + CODEGEN_PIC_MODEL_STATIC = 0, CODEGEN_PIC_MODEL_DYNAMIC = 1, + CODEGEN_PIC_MODEL_DYNAMIC_NO_PIC = 2 + + LTOModule {.pure} = object + LTOCodeGenerator {.pure} = object + lto_module_t* = ref LTOModule + lto_code_gen_t* = ref LTOCodeGenerator + +proc lto_get_version*(): cstring{.cdecl, dynlib: libname, + importc: "lto_get_version".} + # + # Returns the last error string or NULL if last operation was sucessful. + # +proc lto_get_error_message*(): cstring{.cdecl, dynlib: libname, + importc: "lto_get_error_message".} + # + # Checks if a file is a loadable object file. + # +proc lto_module_is_object_file*(path: cstring): bool{.cdecl, dynlib: libname, + importc: "lto_module_is_object_file".} + # + # Checks if a file is a loadable object compiled for requested target. + # +proc lto_module_is_object_file_for_target*(path: cstring, + target_triple_prefix: cstring): bool{.cdecl, dynlib: libname, + importc: "lto_module_is_object_file_for_target".} + # + # Checks if a buffer is a loadable object file. + # +proc lto_module_is_object_file_in_memory*(mem: pointer, len: int): bool{. + cdecl, dynlib: libname, importc: "lto_module_is_object_file_in_memory".} + # + # Checks if a buffer is a loadable object compiled for requested target. + # +proc lto_module_is_object_file_in_memory_for_target*(mem: pointer, len: int, + target_triple_prefix: cstring): bool{.cdecl, dynlib: libname, + importc: "lto_module_is_object_file_in_memory_for_target".} + # + # Loads an object file from disk. + # Returns NULL on error (check lto_get_error_message() for details). + # +proc lto_module_create*(path: cstring): lto_module_t{.cdecl, dynlib: libname, + importc: "lto_module_create".} + # + # Loads an object file from memory. + # Returns NULL on error (check lto_get_error_message() for details). + # +proc lto_module_create_from_memory*(mem: pointer, len: int): lto_module_t{. + cdecl, dynlib: libname, importc: "lto_module_create_from_memory".} + # + # Frees all memory internally allocated by the module. + # Upon return the lto_module_t is no longer valid. + # +proc lto_module_dispose*(module: lto_module_t){.cdecl, dynlib: libname, + importc: "lto_module_dispose".} + # + # Returns triple string which the object module was compiled under. + # +proc lto_module_get_target_triple*(module: lto_module_t): cstring{.cdecl, + dynlib: libname, importc: "lto_module_get_target_triple".} + # + # Returns the number of symbols in the object module. + # +proc lto_module_get_num_symbols*(module: lto_module_t): int32{.cdecl, + dynlib: libname, importc: "lto_module_get_num_symbols".} + # + # Returns the name of the ith symbol in the object module. + # +proc lto_module_get_symbol_name*(module: lto_module_t, index: int32): cstring{. + cdecl, dynlib: libname, importc: "lto_module_get_symbol_name".} + # + # Returns the attributes of the ith symbol in the object module. + # +proc lto_module_get_symbol_attribute*(module: lto_module_t, index: int32): lto_symbol_attributes{. + cdecl, dynlib: libname, importc: "lto_module_get_symbol_attribute".} + # + # Instantiates a code generator. + # Returns NULL on error (check lto_get_error_message() for details). + # +proc lto_codegen_create*(): lto_code_gen_t{.cdecl, dynlib: libname, + importc: "lto_codegen_create".} + # + # Frees all code generator and all memory it internally allocated. + # Upon return the lto_code_gen_t is no longer valid. + # +proc lto_codegen_dispose*(para1: lto_code_gen_t){.cdecl, dynlib: libname, + importc: "lto_codegen_dispose".} + # + # Add an object module to the set of modules for which code will be generated. + # Returns true on error (check lto_get_error_message() for details). + # +proc lto_codegen_add_module*(cg: lto_code_gen_t, module: lto_module_t): bool{. + cdecl, dynlib: libname, importc: "lto_codegen_add_module".} + # + # Sets if debug info should be generated. + # Returns true on error (check lto_get_error_message() for details). + # +proc lto_codegen_set_debug_model*(cg: lto_code_gen_t, para2: lto_debug_model): bool{. + cdecl, dynlib: libname, importc: "lto_codegen_set_debug_model".} + # + # Sets which PIC code model to generated. + # Returns true on error (check lto_get_error_message() for details). + # +proc lto_codegen_set_pic_model*(cg: lto_code_gen_t, para2: lto_codegen_model): bool{. + cdecl, dynlib: libname, importc: "lto_codegen_set_pic_model".} + # + # Sets the location of the "gcc" to run. If not set, libLTO will search for + # "gcc" on the path. + # +proc lto_codegen_set_gcc_path*(cg: lto_code_gen_t, path: cstring){.cdecl, + dynlib: libname, importc: "lto_codegen_set_gcc_path".} + # + # Sets the location of the assembler tool to run. If not set, libLTO + # will use gcc to invoke the assembler. + # +proc lto_codegen_set_assembler_path*(cg: lto_code_gen_t, path: cstring){.cdecl, + dynlib: libname, importc: "lto_codegen_set_assembler_path".} + # + # Adds to a list of all global symbols that must exist in the final + # generated code. If a function is not listed, it might be + # inlined into every usage and optimized away. + # +proc lto_codegen_add_must_preserve_symbol*(cg: lto_code_gen_t, symbol: cstring){. + cdecl, dynlib: libname, importc: "lto_codegen_add_must_preserve_symbol".} + # + # Writes a new object file at the specified path that contains the + # merged contents of all modules added so far. + # Returns true on error (check lto_get_error_message() for details). + # +proc lto_codegen_write_merged_modules*(cg: lto_code_gen_t, path: cstring): bool{. + cdecl, dynlib: libname, importc: "lto_codegen_write_merged_modules".} + # + # Generates code for all added modules into one native object file. + # On sucess returns a pointer to a generated mach-o/ELF buffer and + # length set to the buffer size. The buffer is owned by the + # lto_code_gen_t and will be freed when lto_codegen_dispose() + # is called, or lto_codegen_compile() is called again. + # On failure, returns NULL (check lto_get_error_message() for details). + # +proc lto_codegen_compile*(cg: lto_code_gen_t, len: var int): pointer{.cdecl, + dynlib: libname, importc: "lto_codegen_compile".} + # + # Sets options to help debug codegen bugs. + # +proc lto_codegen_debug_options*(cg: lto_code_gen_t, para2: cstring){.cdecl, + dynlib: libname, importc: "lto_codegen_debug_options".} diff --git a/llvm/llvm.pas b/llvm/llvm.pas new file mode 100755 index 000000000..ad1398b83 --- /dev/null +++ b/llvm/llvm.pas @@ -0,0 +1,1034 @@ +unit llvm; + +interface + +const + libname=''; {Setup as you need} + +type + Pdword = ^dword; + PLLVMBasicBlockRef = ^LLVMBasicBlockRef; + PLLVMExecutionEngineRef = ^LLVMExecutionEngineRef; + PLLVMGenericValueRef = ^LLVMGenericValueRef; + PLLVMMemoryBufferRef = ^LLVMMemoryBufferRef; + PLLVMModuleProviderRef = ^LLVMModuleProviderRef; + PLLVMModuleRef = ^LLVMModuleRef; + PLLVMTypeRef = ^LLVMTypeRef; + PLLVMValueRef = ^LLVMValueRef; + +{ Core.h } +{ Opaque types. } +{* + * The top-level container for all LLVM global data. See the LLVMContext class. + } +type + + LLVMContextRef = LLVMOpaqueContext; +{* + * The top-level container for all other LLVM Intermediate Representation (IR) + * objects. See the llvm::Module class. + } + + LLVMModuleRef = LLVMOpaqueModule; +{* + * Each value in the LLVM IR has a type, an LLVMTypeRef. See the llvm::Type + * class. + } + + LLVMTypeRef = LLVMOpaqueType; +{* + * When building recursive types using LLVMRefineType, LLVMTypeRef values may + * become invalid; use LLVMTypeHandleRef to resolve this problem. See the + * llvm::AbstractTypeHolder class. + } + + LLVMTypeHandleRef = LLVMOpaqueTypeHandle; + + LLVMValueRef = LLVMOpaqueValue; + + LLVMBasicBlockRef = LLVMOpaqueBasicBlock; + + LLVMBuilderRef = LLVMOpaqueBuilder; +{ Used to provide a module to JIT or interpreter. + * See the llvm::ModuleProvider class. + } + + LLVMModuleProviderRef = LLVMOpaqueModuleProvider; +{ Used to provide a module to JIT or interpreter. + * See the llvm::MemoryBuffer class. + } + + LLVMMemoryBufferRef = LLVMOpaqueMemoryBuffer; +{* See the llvm::PassManagerBase class. } + + LLVMPassManagerRef = LLVMOpaquePassManager; +{* + * Used to iterate through the uses of a Value, allowing access to all Values + * that use this Value. See the llvm::Use and llvm::value_use_iterator classes. + } + + LLVMUseIteratorRef = LLVMOpaqueUseIterator; + + LLVMAttribute = (LLVMZExtAttribute := 1 shl 0,LLVMSExtAttribute := 1 shl 1, + LLVMNoReturnAttribute := 1 shl 2,LLVMInRegAttribute := 1 shl 3, + LLVMStructRetAttribute := 1 shl 4,LLVMNoUnwindAttribute := 1 shl 5, + LLVMNoAliasAttribute := 1 shl 6,LLVMByValAttribute := 1 shl 7, + LLVMNestAttribute := 1 shl 8,LLVMReadNoneAttribute := 1 shl 9, + LLVMReadOnlyAttribute := 1 shl 10,LLVMNoInlineAttribute := 1 shl 11, + LLVMAlwaysInlineAttribute := 1 shl 12,LLVMOptimizeForSizeAttribute := 1 shl 13, + LLVMStackProtectAttribute := 1 shl 14,LLVMStackProtectReqAttribute := 1 shl 15, + LLVMNoCaptureAttribute := 1 shl 21,LLVMNoRedZoneAttribute := 1 shl 22, + LLVMNoImplicitFloatAttribute := 1 shl 23,LLVMNakedAttribute := 1 shl 24, + LLVMInlineHintAttribute := 1 shl 25); + + LLVMOpcode = (LLVMRet := 1,LLVMBr := 2,LLVMSwitch := 3, + LLVMInvoke := 4,LLVMUnwind := 5,LLVMUnreachable := 6, + LLVMAdd := 7,LLVMFAdd := 8,LLVMSub := 9, + LLVMFSub := 10,LLVMMul := 11,LLVMFMul := 12, + LLVMUDiv := 13,LLVMSDiv := 14,LLVMFDiv := 15, + LLVMURem := 16,LLVMSRem := 17,LLVMFRem := 18, + LLVMShl := 19,LLVMLShr := 20,LLVMAShr := 21, + LLVMAnd := 22,LLVMOr := 23,LLVMXor := 24, + LLVMMalloc := 25,LLVMFree := 26,LLVMAlloca := 27, + LLVMLoad := 28,LLVMStore := 29,LLVMGetElementPtr := 30, + LLVMTrunk := 31,LLVMZExt := 32,LLVMSExt := 33, + LLVMFPToUI := 34,LLVMFPToSI := 35,LLVMUIToFP := 36, + LLVMSIToFP := 37,LLVMFPTrunc := 38,LLVMFPExt := 39, + LLVMPtrToInt := 40,LLVMIntToPtr := 41, + LLVMBitCast := 42,LLVMICmp := 43,LLVMFCmp := 44, + LLVMPHI := 45,LLVMCall := 46,LLVMSelect := 47, + LLVMVAArg := 50,LLVMExtractElement := 51, + LLVMInsertElement := 52,LLVMShuffleVector := 53, + LLVMExtractValue := 54,LLVMInsertValue := 55 + ); +{*< type with no size } +{*< 32 bit floating point type } +{*< 64 bit floating point type } +{*< 80 bit floating point type (X87) } +{*< 128 bit floating point type (112-bit mantissa) } +{*< 128 bit floating point type (two 64-bits) } +{*< Labels } +{*< Arbitrary bit width integers } +{*< Functions } +{*< Structures } +{*< Arrays } +{*< Pointers } +{*< Opaque: type with unknown structure } +{*< SIMD 'packed' format, or other vector type } +{*< Metadata } + + LLVMTypeKind = (LLVMVoidTypeKind,LLVMFloatTypeKind,LLVMDoubleTypeKind, + LLVMX86_FP80TypeKind,LLVMFP128TypeKind, + LLVMPPC_FP128TypeKind,LLVMLabelTypeKind, + LLVMIntegerTypeKind,LLVMFunctionTypeKind, + LLVMStructTypeKind,LLVMArrayTypeKind,LLVMPointerTypeKind, + LLVMOpaqueTypeKind,LLVMVectorTypeKind, + LLVMMetadataTypeKind); +{*< Externally visible function } +{*< Keep one copy of function when linking (inline) } +{*< Same, but only replaced by something + equivalent. } +{*< Keep one copy of function when linking (weak) } +{*< Same, but only replaced by something + equivalent. } +{*< Special purpose, only applies to global arrays } +{*< Rename collisions when linking (static + functions) } +{*< Like Internal, but omit from symbol table } +{*< Function to be imported from DLL } +{*< Function to be accessible from DLL } +{*< ExternalWeak linkage description } +{*< Stand-in functions for streaming fns from + bitcode } +{*< Tentative definitions } +{*< Like Private, but linker removes. } + + LLVMLinkage = (LLVMExternalLinkage,LLVMAvailableExternallyLinkage, + LLVMLinkOnceAnyLinkage,LLVMLinkOnceODRLinkage, + LLVMWeakAnyLinkage,LLVMWeakODRLinkage, + LLVMAppendingLinkage,LLVMInternalLinkage, + LLVMPrivateLinkage,LLVMDLLImportLinkage, + LLVMDLLExportLinkage,LLVMExternalWeakLinkage, + LLVMGhostLinkage,LLVMCommonLinkage,LLVMLinkerPrivateLinkage + ); +{*< The GV is visible } +{*< The GV is hidden } +{*< The GV is protected } + + LLVMVisibility = (LLVMDefaultVisibility,LLVMHiddenVisibility, + LLVMProtectedVisibility); + + LLVMCallConv = (LLVMCCallConv := 0,LLVMFastCallConv := 8, + LLVMColdCallConv := 9,LLVMX86StdcallCallConv := 64, + LLVMX86FastcallCallConv := 65); +{*< equal } +{*< not equal } +{*< unsigned greater than } +{*< unsigned greater or equal } +{*< unsigned less than } +{*< unsigned less or equal } +{*< signed greater than } +{*< signed greater or equal } +{*< signed less than } +{*< signed less or equal } + + LLVMIntPredicate = (LLVMIntEQ := 32,LLVMIntNE,LLVMIntUGT,LLVMIntUGE, + LLVMIntULT,LLVMIntULE,LLVMIntSGT,LLVMIntSGE, + LLVMIntSLT,LLVMIntSLE); +{*< Always false (always folded) } +{*< True if ordered and equal } +{*< True if ordered and greater than } +{*< True if ordered and greater than or equal } +{*< True if ordered and less than } +{*< True if ordered and less than or equal } +{*< True if ordered and operands are unequal } +{*< True if ordered (no nans) } +{*< True if unordered: isnan(X) | isnan(Y) } +{*< True if unordered or equal } +{*< True if unordered or greater than } +{*< True if unordered, greater than, or equal } +{*< True if unordered or less than } +{*< True if unordered, less than, or equal } +{*< True if unordered or not equal } +{*< Always true (always folded) } + + LLVMRealPredicate = (LLVMRealPredicateFalse,LLVMRealOEQ,LLVMRealOGT, + LLVMRealOGE,LLVMRealOLT,LLVMRealOLE,LLVMRealONE, + LLVMRealORD,LLVMRealUNO,LLVMRealUEQ,LLVMRealUGT, + LLVMRealUGE,LLVMRealULT,LLVMRealULE,LLVMRealUNE, + LLVMRealPredicateTrue); +{===-- Error handling ----------------------------------------------------=== } + +procedure LLVMDisposeMessage(Message:pchar);cdecl;external libname name 'LLVMDisposeMessage'; +{===-- Modules -----------------------------------------------------------=== } +{ Create and destroy contexts. } +function LLVMContextCreate:LLVMContextRef;cdecl;external libname name 'LLVMContextCreate'; +function LLVMGetGlobalContext:LLVMContextRef;cdecl;external libname name 'LLVMGetGlobalContext'; +procedure LLVMContextDispose(C:LLVMContextRef);cdecl;external libname name 'LLVMContextDispose'; +{ Create and destroy modules. }{* See llvm::Module::Module. } +function LLVMModuleCreateWithName(ModuleID:pchar):LLVMModuleRef;cdecl;external libname name 'LLVMModuleCreateWithName'; +function LLVMModuleCreateWithNameInContext(ModuleID:pchar; C:LLVMContextRef):LLVMModuleRef;cdecl;external libname name 'LLVMModuleCreateWithNameInContext'; +{* See llvm::Module::~Module. } +procedure LLVMDisposeModule(M:LLVMModuleRef);cdecl;external libname name 'LLVMDisposeModule'; +{* Data layout. See Module::getDataLayout. } +function LLVMGetDataLayout(M:LLVMModuleRef):pchar;cdecl;external libname name 'LLVMGetDataLayout'; +procedure LLVMSetDataLayout(M:LLVMModuleRef; Triple:pchar);cdecl;external libname name 'LLVMSetDataLayout'; +{* Target triple. See Module::getTargetTriple. } +function LLVMGetTarget(M:LLVMModuleRef):pchar;cdecl;external libname name 'LLVMGetTarget'; +procedure LLVMSetTarget(M:LLVMModuleRef; Triple:pchar);cdecl;external libname name 'LLVMSetTarget'; +{* See Module::addTypeName. } +function LLVMAddTypeName(M:LLVMModuleRef; Name:pchar; Ty:LLVMTypeRef):longint;cdecl;external libname name 'LLVMAddTypeName'; +procedure LLVMDeleteTypeName(M:LLVMModuleRef; Name:pchar);cdecl;external libname name 'LLVMDeleteTypeName'; +function LLVMGetTypeByName(M:LLVMModuleRef; Name:pchar):LLVMTypeRef;cdecl;external libname name 'LLVMGetTypeByName'; +{* See Module::dump. } +procedure LLVMDumpModule(M:LLVMModuleRef);cdecl;external libname name 'LLVMDumpModule'; +{===-- 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. } +function LLVMGetTypeKind(Ty:LLVMTypeRef):LLVMTypeKind;cdecl;external libname name 'LLVMGetTypeKind'; +{* See llvm::LLVMType::getContext. } +function LLVMGetTypeContext(Ty:LLVMTypeRef):LLVMContextRef;cdecl;external libname name 'LLVMGetTypeContext'; +{ Operations on integer types } +function LLVMInt1TypeInContext(C:LLVMContextRef):LLVMTypeRef;cdecl;external libname name 'LLVMInt1TypeInContext'; +function LLVMInt8TypeInContext(C:LLVMContextRef):LLVMTypeRef;cdecl;external libname name 'LLVMInt8TypeInContext'; +function LLVMInt16TypeInContext(C:LLVMContextRef):LLVMTypeRef;cdecl;external libname name 'LLVMInt16TypeInContext'; +function LLVMInt32TypeInContext(C:LLVMContextRef):LLVMTypeRef;cdecl;external libname name 'LLVMInt32TypeInContext'; +function LLVMInt64TypeInContext(C:LLVMContextRef):LLVMTypeRef;cdecl;external libname name 'LLVMInt64TypeInContext'; +function LLVMIntTypeInContext(C:LLVMContextRef; NumBits:dword):LLVMTypeRef;cdecl;external libname name 'LLVMIntTypeInContext'; +function LLVMInt1Type:LLVMTypeRef;cdecl;external libname name 'LLVMInt1Type'; +function LLVMInt8Type:LLVMTypeRef;cdecl;external libname name 'LLVMInt8Type'; +function LLVMInt16Type:LLVMTypeRef;cdecl;external libname name 'LLVMInt16Type'; +function LLVMInt32Type:LLVMTypeRef;cdecl;external libname name 'LLVMInt32Type'; +function LLVMInt64Type:LLVMTypeRef;cdecl;external libname name 'LLVMInt64Type'; +function LLVMIntType(NumBits:dword):LLVMTypeRef;cdecl;external libname name 'LLVMIntType'; +function LLVMGetIntTypeWidth(IntegerTy:LLVMTypeRef):dword;cdecl;external libname name 'LLVMGetIntTypeWidth'; +{ Operations on real types } +function LLVMFloatTypeInContext(C:LLVMContextRef):LLVMTypeRef;cdecl;external libname name 'LLVMFloatTypeInContext'; +function LLVMDoubleTypeInContext(C:LLVMContextRef):LLVMTypeRef;cdecl;external libname name 'LLVMDoubleTypeInContext'; +function LLVMX86FP80TypeInContext(C:LLVMContextRef):LLVMTypeRef;cdecl;external libname name 'LLVMX86FP80TypeInContext'; +function LLVMFP128TypeInContext(C:LLVMContextRef):LLVMTypeRef;cdecl;external libname name 'LLVMFP128TypeInContext'; +function LLVMPPCFP128TypeInContext(C:LLVMContextRef):LLVMTypeRef;cdecl;external libname name 'LLVMPPCFP128TypeInContext'; +function LLVMFloatType:LLVMTypeRef;cdecl;external libname name 'LLVMFloatType'; +function LLVMDoubleType:LLVMTypeRef;cdecl;external libname name 'LLVMDoubleType'; +function LLVMX86FP80Type:LLVMTypeRef;cdecl;external libname name 'LLVMX86FP80Type'; +function LLVMFP128Type:LLVMTypeRef;cdecl;external libname name 'LLVMFP128Type'; +function LLVMPPCFP128Type:LLVMTypeRef;cdecl;external libname name 'LLVMPPCFP128Type'; +{ Operations on function types } +function LLVMFunctionType(ReturnType:LLVMTypeRef; ParamTypes:pLLVMTypeRef; ParamCount:dword; IsVarArg:longint):LLVMTypeRef;cdecl;external libname name 'LLVMFunctionType'; +function LLVMIsFunctionVarArg(FunctionTy:LLVMTypeRef):longint;cdecl;external libname name 'LLVMIsFunctionVarArg'; +function LLVMGetReturnType(FunctionTy:LLVMTypeRef):LLVMTypeRef;cdecl;external libname name 'LLVMGetReturnType'; +function LLVMCountParamTypes(FunctionTy:LLVMTypeRef):dword;cdecl;external libname name 'LLVMCountParamTypes'; +procedure LLVMGetParamTypes(FunctionTy:LLVMTypeRef; Dest:pLLVMTypeRef);cdecl;external libname name 'LLVMGetParamTypes'; +{ Operations on struct types } +function LLVMStructTypeInContext(C:LLVMContextRef; ElementTypes:pLLVMTypeRef; + ElementCount:dword; + isPacked:longint):LLVMTypeRef;cdecl;external libname name 'LLVMStructTypeInContext'; +function LLVMStructType(ElementTypes:pLLVMTypeRef; ElementCount:dword; + isPacked:longint):LLVMTypeRef;cdecl;external libname name 'LLVMStructType'; +function LLVMCountStructElementTypes(StructTy:LLVMTypeRef):dword;cdecl;external libname name 'LLVMCountStructElementTypes'; +procedure LLVMGetStructElementTypes(StructTy:LLVMTypeRef; Dest:pLLVMTypeRef);cdecl;external libname name 'LLVMGetStructElementTypes'; +function LLVMIsPackedStruct(StructTy:LLVMTypeRef):longint;cdecl;external libname name 'LLVMIsPackedStruct'; +{ Operations on array, pointer, and vector types (sequence types) } +function LLVMArrayType(ElementType:LLVMTypeRef; ElementCount:dword):LLVMTypeRef;cdecl;external libname name 'LLVMArrayType'; +function LLVMPointerType(ElementType:LLVMTypeRef; AddressSpace:dword):LLVMTypeRef;cdecl;external libname name 'LLVMPointerType'; +function LLVMVectorType(ElementType:LLVMTypeRef; ElementCount:dword):LLVMTypeRef;cdecl;external libname name 'LLVMVectorType'; +function LLVMGetElementType(Ty:LLVMTypeRef):LLVMTypeRef;cdecl;external libname name 'LLVMGetElementType'; +function LLVMGetArrayLength(ArrayTy:LLVMTypeRef):dword;cdecl;external libname name 'LLVMGetArrayLength'; +function LLVMGetPointerAddressSpace(PointerTy:LLVMTypeRef):dword;cdecl;external libname name 'LLVMGetPointerAddressSpace'; +function LLVMGetVectorSize(VectorTy:LLVMTypeRef):dword;cdecl;external libname name 'LLVMGetVectorSize'; +{ Operations on other types } +function LLVMVoidTypeInContext(C:LLVMContextRef):LLVMTypeRef;cdecl;external libname name 'LLVMVoidTypeInContext'; +function LLVMLabelTypeInContext(C:LLVMContextRef):LLVMTypeRef;cdecl;external libname name 'LLVMLabelTypeInContext'; +function LLVMOpaqueTypeInContext(C:LLVMContextRef):LLVMTypeRef;cdecl;external libname name 'LLVMOpaqueTypeInContext'; +function LLVMVoidType:LLVMTypeRef;cdecl;external libname name 'LLVMVoidType'; +function LLVMLabelType:LLVMTypeRef;cdecl;external libname name 'LLVMLabelType'; +function LLVMOpaqueType:LLVMTypeRef;cdecl;external libname name 'LLVMOpaqueType'; +{ Operations on type handles } +function LLVMCreateTypeHandle(PotentiallyAbstractTy:LLVMTypeRef):LLVMTypeHandleRef;cdecl;external libname name 'LLVMCreateTypeHandle'; +procedure LLVMRefineType(AbstractTy:LLVMTypeRef; ConcreteTy:LLVMTypeRef);cdecl;external libname name 'LLVMRefineType'; +function LLVMResolveTypeHandle(TypeHandle:LLVMTypeHandleRef):LLVMTypeRef;cdecl;external libname name 'LLVMResolveTypeHandle'; +procedure LLVMDisposeTypeHandle(TypeHandle:LLVMTypeHandleRef);cdecl;external libname name 'LLVMDisposeTypeHandle'; +{ Operations on all values } +function LLVMTypeOf(Val:LLVMValueRef):LLVMTypeRef;cdecl;external libname name 'LLVMTypeOf'; +function LLVMGetValueName(Val:LLVMValueRef):pchar;cdecl;external libname name 'LLVMGetValueName'; +procedure LLVMSetValueName(Val:LLVMValueRef; Name:pchar);cdecl;external libname name 'LLVMSetValueName'; +procedure LLVMDumpValue(Val:LLVMValueRef);cdecl;external libname name 'LLVMDumpValue'; +procedure LLVMReplaceAllUsesWith(OldVal:LLVMValueRef; NewVal:LLVMValueRef);cdecl;external libname name 'LLVMReplaceAllUsesWith'; +{ Conversion functions. Return the input value if it is an instance of the + specified class, otherwise NULL. See llvm::dyn_cast_or_null<>. } +function LLVMIsAArgument(Val:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMIsAArgument'; +function LLVMIsABasicBlock(Val:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMIsABasicBlock'; +function LLVMIsAInlineAsm(Val:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMIsAInlineAsm'; +function LLVMIsAUser(Val:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMIsAUser'; +function LLVMIsAConstant(Val:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMIsAConstant'; +function LLVMIsAConstantAggregateZero(Val:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMIsAConstantAggregateZero'; +function LLVMIsAConstantArray(Val:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMIsAConstantArray'; +function LLVMIsAConstantExpr(Val:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMIsAConstantExpr'; +function LLVMIsAConstantFP(Val:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMIsAConstantFP'; +function LLVMIsAConstantInt(Val:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMIsAConstantInt'; +function LLVMIsAConstantPointerNull(Val:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMIsAConstantPointerNull'; +function LLVMIsAConstantStruct(Val:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMIsAConstantStruct'; +function LLVMIsAConstantVector(Val:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMIsAConstantVector'; +function LLVMIsAGlobalValue(Val:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMIsAGlobalValue'; +function LLVMIsAFunction(Val:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMIsAFunction'; +function LLVMIsAGlobalAlias(Val:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMIsAGlobalAlias'; +function LLVMIsAGlobalVariable(Val:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMIsAGlobalVariable'; +function LLVMIsAUndefValue(Val:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMIsAUndefValue'; +function LLVMIsAInstruction(Val:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMIsAInstruction'; +function LLVMIsABinaryOperator(Val:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMIsABinaryOperator'; +function LLVMIsACallInst(Val:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMIsACallInst'; +function LLVMIsAIntrinsicInst(Val:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMIsAIntrinsicInst'; +function LLVMIsADbgInfoIntrinsic(Val:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMIsADbgInfoIntrinsic'; +function LLVMIsADbgDeclareInst(Val:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMIsADbgDeclareInst'; +function LLVMIsADbgFuncStartInst(Val:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMIsADbgFuncStartInst'; +function LLVMIsADbgRegionEndInst(Val:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMIsADbgRegionEndInst'; +function LLVMIsADbgRegionStartInst(Val:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMIsADbgRegionStartInst'; +function LLVMIsADbgStopPointInst(Val:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMIsADbgStopPointInst'; +function LLVMIsAEHSelectorInst(Val:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMIsAEHSelectorInst'; +function LLVMIsAMemIntrinsic(Val:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMIsAMemIntrinsic'; +function LLVMIsAMemCpyInst(Val:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMIsAMemCpyInst'; +function LLVMIsAMemMoveInst(Val:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMIsAMemMoveInst'; +function LLVMIsAMemSetInst(Val:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMIsAMemSetInst'; +function LLVMIsACmpInst(Val:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMIsACmpInst'; +function LLVMIsAFCmpInst(Val:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMIsAFCmpInst'; +function LLVMIsAICmpInst(Val:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMIsAICmpInst'; +function LLVMIsAExtractElementInst(Val:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMIsAExtractElementInst'; +function LLVMIsAGetElementPtrInst(Val:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMIsAGetElementPtrInst'; +function LLVMIsAInsertElementInst(Val:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMIsAInsertElementInst'; +function LLVMIsAInsertValueInst(Val:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMIsAInsertValueInst'; +function LLVMIsAPHINode(Val:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMIsAPHINode'; +function LLVMIsASelectInst(Val:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMIsASelectInst'; +function LLVMIsAShuffleVectorInst(Val:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMIsAShuffleVectorInst'; +function LLVMIsAStoreInst(Val:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMIsAStoreInst'; +function LLVMIsATerminatorInst(Val:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMIsATerminatorInst'; +function LLVMIsABranchInst(Val:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMIsABranchInst'; +function LLVMIsAInvokeInst(Val:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMIsAInvokeInst'; +function LLVMIsAReturnInst(Val:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMIsAReturnInst'; +function LLVMIsASwitchInst(Val:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMIsASwitchInst'; +function LLVMIsAUnreachableInst(Val:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMIsAUnreachableInst'; +function LLVMIsAUnwindInst(Val:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMIsAUnwindInst'; +function LLVMIsAUnaryInstruction(Val:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMIsAUnaryInstruction'; +function LLVMIsAAllocationInst(Val:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMIsAAllocationInst'; +function LLVMIsAAllocaInst(Val:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMIsAAllocaInst'; +function LLVMIsACastInst(Val:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMIsACastInst'; +function LLVMIsABitCastInst(Val:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMIsABitCastInst'; +function LLVMIsAFPExtInst(Val:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMIsAFPExtInst'; +function LLVMIsAFPToSIInst(Val:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMIsAFPToSIInst'; +function LLVMIsAFPToUIInst(Val:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMIsAFPToUIInst'; +function LLVMIsAFPTruncInst(Val:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMIsAFPTruncInst'; +function LLVMIsAIntToPtrInst(Val:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMIsAIntToPtrInst'; +function LLVMIsAPtrToIntInst(Val:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMIsAPtrToIntInst'; +function LLVMIsASExtInst(Val:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMIsASExtInst'; +function LLVMIsASIToFPInst(Val:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMIsASIToFPInst'; +function LLVMIsATruncInst(Val:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMIsATruncInst'; +function LLVMIsAUIToFPInst(Val:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMIsAUIToFPInst'; +function LLVMIsAZExtInst(Val:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMIsAZExtInst'; +function LLVMIsAExtractValueInst(Val:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMIsAExtractValueInst'; +function LLVMIsAFreeInst(Val:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMIsAFreeInst'; +function LLVMIsALoadInst(Val:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMIsALoadInst'; +function LLVMIsAVAArgInst(Val:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMIsAVAArgInst'; +{ Operations on Uses } +function LLVMGetFirstUse(Val:LLVMValueRef):LLVMUseIteratorRef;cdecl;external libname name 'LLVMGetFirstUse'; +function LLVMGetNextUse(U:LLVMUseIteratorRef):LLVMUseIteratorRef;cdecl;external libname name 'LLVMGetNextUse'; +function LLVMGetUser(U:LLVMUseIteratorRef):LLVMValueRef;cdecl;external libname name 'LLVMGetUser'; +function LLVMGetUsedValue(U:LLVMUseIteratorRef):LLVMValueRef;cdecl;external libname name 'LLVMGetUsedValue'; +{ Operations on Users } +function LLVMGetOperand(Val:LLVMValueRef; Index:dword):LLVMValueRef;cdecl;external libname name 'LLVMGetOperand'; +{ Operations on constants of any type } +function LLVMConstNull(Ty:LLVMTypeRef):LLVMValueRef;cdecl;external libname name 'LLVMConstNull'; +{ all zeroes } +function LLVMConstAllOnes(Ty:LLVMTypeRef):LLVMValueRef;cdecl;external libname name 'LLVMConstAllOnes'; +{ only for int/vector } +function LLVMGetUndef(Ty:LLVMTypeRef):LLVMValueRef;cdecl;external libname name 'LLVMGetUndef'; +function LLVMIsConstant(Val:LLVMValueRef):longint;cdecl;external libname name 'LLVMIsConstant'; +function LLVMIsNull(Val:LLVMValueRef):longint;cdecl;external libname name 'LLVMIsNull'; +function LLVMIsUndef(Val:LLVMValueRef):longint;cdecl;external libname name 'LLVMIsUndef'; +function LLVMConstPointerNull(Ty:LLVMTypeRef):LLVMValueRef;cdecl;external libname name 'LLVMConstPointerNull'; +{ Operations on scalar constants } +function LLVMConstInt(IntTy:LLVMTypeRef; N:qword; SignExtend:longint):LLVMValueRef;cdecl;external libname name 'LLVMConstInt'; +function LLVMConstIntOfString(IntTy:LLVMTypeRef; Text:pchar; Radix:uint8_t):LLVMValueRef;cdecl;external libname name 'LLVMConstIntOfString'; +function LLVMConstIntOfStringAndSize(IntTy:LLVMTypeRef; Text:pchar; SLen:dword; Radix:uint8_t):LLVMValueRef;cdecl;external libname name 'LLVMConstIntOfStringAndSize'; +function LLVMConstReal(RealTy:LLVMTypeRef; N:double):LLVMValueRef;cdecl;external libname name 'LLVMConstReal'; +function LLVMConstRealOfString(RealTy:LLVMTypeRef; Text:pchar):LLVMValueRef;cdecl;external libname name 'LLVMConstRealOfString'; +function LLVMConstRealOfStringAndSize(RealTy:LLVMTypeRef; Text:pchar; SLen:dword):LLVMValueRef;cdecl;external libname name 'LLVMConstRealOfStringAndSize'; +function LLVMConstIntGetZExtValue(ConstantVal:LLVMValueRef):qword;cdecl;external libname name 'LLVMConstIntGetZExtValue'; +function LLVMConstIntGetSExtValue(ConstantVal:LLVMValueRef):int64;cdecl;external libname name 'LLVMConstIntGetSExtValue'; +{ Operations on composite constants } +function LLVMConstStringInContext(C:LLVMContextRef; Str:pchar; Length:dword; DontNullTerminate:longint):LLVMValueRef;cdecl;external libname name 'LLVMConstStringInContext'; +function LLVMConstStructInContext(C:LLVMContextRef; + ConstantVals:pLLVMValueRef; Count:dword; isPacked:longint):LLVMValueRef;cdecl;external libname name 'LLVMConstStructInContext'; +function LLVMConstString(Str:pchar; Length:dword; DontNullTerminate:longint):LLVMValueRef;cdecl;external libname name 'LLVMConstString'; +function LLVMConstArray(ElementTy:LLVMTypeRef; ConstantVals:pLLVMValueRef; Length:dword):LLVMValueRef;cdecl;external libname name 'LLVMConstArray'; +function LLVMConstStruct(ConstantVals:pLLVMValueRef; Count:dword; isPacked:longint):LLVMValueRef;cdecl;external libname name 'LLVMConstStruct'; +function LLVMConstVector(ScalarConstantVals:pLLVMValueRef; Size:dword):LLVMValueRef;cdecl;external libname name 'LLVMConstVector'; +{ Constant expressions } +function LLVMGetConstOpcode(ConstantVal:LLVMValueRef):LLVMOpcode;cdecl;external libname name 'LLVMGetConstOpcode'; +function LLVMAlignOf(Ty:LLVMTypeRef):LLVMValueRef;cdecl;external libname name 'LLVMAlignOf'; +function LLVMSizeOf(Ty:LLVMTypeRef):LLVMValueRef;cdecl;external libname name 'LLVMSizeOf'; +function LLVMConstNeg(ConstantVal:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMConstNeg'; +function LLVMConstFNeg(ConstantVal:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMConstFNeg'; +function LLVMConstNot(ConstantVal:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMConstNot'; +function LLVMConstAdd(LHSConstant:LLVMValueRef; RHSConstant:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMConstAdd'; +function LLVMConstNSWAdd(LHSConstant:LLVMValueRef; RHSConstant:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMConstNSWAdd'; +function LLVMConstFAdd(LHSConstant:LLVMValueRef; RHSConstant:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMConstFAdd'; +function LLVMConstSub(LHSConstant:LLVMValueRef; RHSConstant:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMConstSub'; +function LLVMConstFSub(LHSConstant:LLVMValueRef; RHSConstant:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMConstFSub'; +function LLVMConstMul(LHSConstant:LLVMValueRef; RHSConstant:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMConstMul'; +function LLVMConstFMul(LHSConstant:LLVMValueRef; RHSConstant:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMConstFMul'; +function LLVMConstUDiv(LHSConstant:LLVMValueRef; RHSConstant:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMConstUDiv'; +function LLVMConstSDiv(LHSConstant:LLVMValueRef; RHSConstant:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMConstSDiv'; +function LLVMConstExactSDiv(LHSConstant:LLVMValueRef; RHSConstant:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMConstExactSDiv'; +function LLVMConstFDiv(LHSConstant:LLVMValueRef; RHSConstant:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMConstFDiv'; +function LLVMConstURem(LHSConstant:LLVMValueRef; RHSConstant:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMConstURem'; +function LLVMConstSRem(LHSConstant:LLVMValueRef; RHSConstant:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMConstSRem'; +function LLVMConstFRem(LHSConstant:LLVMValueRef; RHSConstant:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMConstFRem'; +function LLVMConstAnd(LHSConstant:LLVMValueRef; RHSConstant:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMConstAnd'; +function LLVMConstOr(LHSConstant:LLVMValueRef; RHSConstant:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMConstOr'; +function LLVMConstXor(LHSConstant:LLVMValueRef; RHSConstant:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMConstXor'; +function LLVMConstICmp(Predicate:LLVMIntPredicate; LHSConstant:LLVMValueRef; RHSConstant:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMConstICmp'; +function LLVMConstFCmp(Predicate:LLVMRealPredicate; LHSConstant:LLVMValueRef; RHSConstant:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMConstFCmp'; +function LLVMConstShl(LHSConstant:LLVMValueRef; RHSConstant:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMConstShl'; +function LLVMConstLShr(LHSConstant:LLVMValueRef; RHSConstant:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMConstLShr'; +function LLVMConstAShr(LHSConstant:LLVMValueRef; RHSConstant:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMConstAShr'; +function LLVMConstGEP(ConstantVal:LLVMValueRef; ConstantIndices:pLLVMValueRef; NumIndices:dword):LLVMValueRef;cdecl;external libname name 'LLVMConstGEP'; +function LLVMConstInBoundsGEP(ConstantVal:LLVMValueRef; ConstantIndices:pLLVMValueRef; NumIndices:dword):LLVMValueRef;cdecl;external libname name 'LLVMConstInBoundsGEP'; +function LLVMConstTrunc(ConstantVal:LLVMValueRef; ToType:LLVMTypeRef):LLVMValueRef;cdecl;external libname name 'LLVMConstTrunc'; +function LLVMConstSExt(ConstantVal:LLVMValueRef; ToType:LLVMTypeRef):LLVMValueRef;cdecl;external libname name 'LLVMConstSExt'; +function LLVMConstZExt(ConstantVal:LLVMValueRef; ToType:LLVMTypeRef):LLVMValueRef;cdecl;external libname name 'LLVMConstZExt'; +function LLVMConstFPTrunc(ConstantVal:LLVMValueRef; ToType:LLVMTypeRef):LLVMValueRef;cdecl;external libname name 'LLVMConstFPTrunc'; +function LLVMConstFPExt(ConstantVal:LLVMValueRef; ToType:LLVMTypeRef):LLVMValueRef;cdecl;external libname name 'LLVMConstFPExt'; +function LLVMConstUIToFP(ConstantVal:LLVMValueRef; ToType:LLVMTypeRef):LLVMValueRef;cdecl;external libname name 'LLVMConstUIToFP'; +function LLVMConstSIToFP(ConstantVal:LLVMValueRef; ToType:LLVMTypeRef):LLVMValueRef;cdecl;external libname name 'LLVMConstSIToFP'; +function LLVMConstFPToUI(ConstantVal:LLVMValueRef; ToType:LLVMTypeRef):LLVMValueRef;cdecl;external libname name 'LLVMConstFPToUI'; +function LLVMConstFPToSI(ConstantVal:LLVMValueRef; ToType:LLVMTypeRef):LLVMValueRef;cdecl;external libname name 'LLVMConstFPToSI'; +function LLVMConstPtrToInt(ConstantVal:LLVMValueRef; ToType:LLVMTypeRef):LLVMValueRef;cdecl;external libname name 'LLVMConstPtrToInt'; +function LLVMConstIntToPtr(ConstantVal:LLVMValueRef; ToType:LLVMTypeRef):LLVMValueRef;cdecl;external libname name 'LLVMConstIntToPtr'; +function LLVMConstBitCast(ConstantVal:LLVMValueRef; ToType:LLVMTypeRef):LLVMValueRef;cdecl;external libname name 'LLVMConstBitCast'; +function LLVMConstZExtOrBitCast(ConstantVal:LLVMValueRef; ToType:LLVMTypeRef):LLVMValueRef;cdecl;external libname name 'LLVMConstZExtOrBitCast'; +function LLVMConstSExtOrBitCast(ConstantVal:LLVMValueRef; ToType:LLVMTypeRef):LLVMValueRef;cdecl;external libname name 'LLVMConstSExtOrBitCast'; +function LLVMConstTruncOrBitCast(ConstantVal:LLVMValueRef; ToType:LLVMTypeRef):LLVMValueRef;cdecl;external libname name 'LLVMConstTruncOrBitCast'; +function LLVMConstPointerCast(ConstantVal:LLVMValueRef; ToType:LLVMTypeRef):LLVMValueRef;cdecl;external libname name 'LLVMConstPointerCast'; +function LLVMConstIntCast(ConstantVal:LLVMValueRef; ToType:LLVMTypeRef; isSigned:dword):LLVMValueRef;cdecl;external libname name 'LLVMConstIntCast'; +function LLVMConstFPCast(ConstantVal:LLVMValueRef; ToType:LLVMTypeRef):LLVMValueRef;cdecl;external libname name 'LLVMConstFPCast'; +function LLVMConstSelect(ConstantCondition:LLVMValueRef; ConstantIfTrue:LLVMValueRef; ConstantIfFalse:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMConstSelect'; +function LLVMConstExtractElement(VectorConstant:LLVMValueRef; IndexConstant:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMConstExtractElement'; +function LLVMConstInsertElement(VectorConstant:LLVMValueRef; ElementValueConstant:LLVMValueRef; IndexConstant:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMConstInsertElement'; +function LLVMConstShuffleVector(VectorAConstant:LLVMValueRef; VectorBConstant:LLVMValueRef; MaskConstant:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMConstShuffleVector'; +function LLVMConstExtractValue(AggConstant:LLVMValueRef; IdxList:pdword; NumIdx:dword):LLVMValueRef;cdecl;external libname name 'LLVMConstExtractValue'; +function LLVMConstInsertValue(AggConstant:LLVMValueRef; ElementValueConstant:LLVMValueRef; IdxList:pdword; NumIdx:dword):LLVMValueRef;cdecl;external libname name 'LLVMConstInsertValue'; + +function LLVMConstInlineAsm(Ty:LLVMTypeRef; AsmString:pchar; Constraints:pchar; HasSideEffects:longint):LLVMValueRef;cdecl;external libname name 'LLVMConstInlineAsm'; +{ Operations on global variables, functions, and aliases (globals) } +function LLVMGetGlobalParent(Global:LLVMValueRef):LLVMModuleRef;cdecl;external libname name 'LLVMGetGlobalParent'; +function LLVMIsDeclaration(Global:LLVMValueRef):longint;cdecl;external libname name 'LLVMIsDeclaration'; +function LLVMGetLinkage(Global:LLVMValueRef):LLVMLinkage;cdecl;external libname name 'LLVMGetLinkage'; +procedure LLVMSetLinkage(Global:LLVMValueRef; Linkage:LLVMLinkage);cdecl;external libname name 'LLVMSetLinkage'; +function LLVMGetSection(Global:LLVMValueRef):pchar;cdecl;external libname name 'LLVMGetSection'; +procedure LLVMSetSection(Global:LLVMValueRef; Section:pchar);cdecl;external libname name 'LLVMSetSection'; +function LLVMGetVisibility(Global:LLVMValueRef):LLVMVisibility;cdecl;external libname name 'LLVMGetVisibility'; +procedure LLVMSetVisibility(Global:LLVMValueRef; Viz:LLVMVisibility);cdecl;external libname name 'LLVMSetVisibility'; +function LLVMGetAlignment(Global:LLVMValueRef):dword;cdecl;external libname name 'LLVMGetAlignment'; +procedure LLVMSetAlignment(Global:LLVMValueRef; Bytes:dword);cdecl;external libname name 'LLVMSetAlignment'; +{ Operations on global variables } + +function LLVMAddGlobal(M:LLVMModuleRef; Ty:LLVMTypeRef; Name:pchar):LLVMValueRef;cdecl;external libname name 'LLVMAddGlobal'; + +function LLVMGetNamedGlobal(M:LLVMModuleRef; Name:pchar):LLVMValueRef;cdecl;external libname name 'LLVMGetNamedGlobal'; +function LLVMGetFirstGlobal(M:LLVMModuleRef):LLVMValueRef;cdecl;external libname name 'LLVMGetFirstGlobal'; +function LLVMGetLastGlobal(M:LLVMModuleRef):LLVMValueRef;cdecl;external libname name 'LLVMGetLastGlobal'; +function LLVMGetNextGlobal(GlobalVar:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMGetNextGlobal'; +function LLVMGetPreviousGlobal(GlobalVar:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMGetPreviousGlobal'; +procedure LLVMDeleteGlobal(GlobalVar:LLVMValueRef);cdecl;external libname name 'LLVMDeleteGlobal'; +function LLVMGetInitializer(GlobalVar:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMGetInitializer'; +procedure LLVMSetInitializer(GlobalVar:LLVMValueRef; ConstantVal:LLVMValueRef);cdecl;external libname name 'LLVMSetInitializer'; +function LLVMIsThreadLocal(GlobalVar:LLVMValueRef):longint;cdecl;external libname name 'LLVMIsThreadLocal'; +procedure LLVMSetThreadLocal(GlobalVar:LLVMValueRef; IsThreadLocal:longint);cdecl;external libname name 'LLVMSetThreadLocal'; +function LLVMIsGlobalConstant(GlobalVar:LLVMValueRef):longint;cdecl;external libname name 'LLVMIsGlobalConstant'; +procedure LLVMSetGlobalConstant(GlobalVar:LLVMValueRef; IsConstant:longint);cdecl;external libname name 'LLVMSetGlobalConstant'; +{ Operations on aliases } +function LLVMAddAlias(M:LLVMModuleRef; Ty:LLVMTypeRef; Aliasee:LLVMValueRef; Name:pchar):LLVMValueRef;cdecl;external libname name 'LLVMAddAlias'; +{ Operations on functions } +function LLVMAddFunction(M:LLVMModuleRef; Name:pchar; FunctionTy:LLVMTypeRef):LLVMValueRef;cdecl;external libname name 'LLVMAddFunction'; +function LLVMGetNamedFunction(M:LLVMModuleRef; Name:pchar):LLVMValueRef;cdecl;external libname name 'LLVMGetNamedFunction'; +function LLVMGetFirstFunction(M:LLVMModuleRef):LLVMValueRef;cdecl;external libname name 'LLVMGetFirstFunction'; +function LLVMGetLastFunction(M:LLVMModuleRef):LLVMValueRef;cdecl;external libname name 'LLVMGetLastFunction'; +function LLVMGetNextFunction(Fn:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMGetNextFunction'; +function LLVMGetPreviousFunction(Fn:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMGetPreviousFunction'; +procedure LLVMDeleteFunction(Fn:LLVMValueRef);cdecl;external libname name 'LLVMDeleteFunction'; +function LLVMGetIntrinsicID(Fn:LLVMValueRef):dword;cdecl;external libname name 'LLVMGetIntrinsicID'; +function LLVMGetFunctionCallConv(Fn:LLVMValueRef):dword;cdecl;external libname name 'LLVMGetFunctionCallConv'; +procedure LLVMSetFunctionCallConv(Fn:LLVMValueRef; CC:dword);cdecl;external libname name 'LLVMSetFunctionCallConv'; +function LLVMGetGC(Fn:LLVMValueRef):pchar;cdecl;external libname name 'LLVMGetGC'; +procedure LLVMSetGC(Fn:LLVMValueRef; Name:pchar);cdecl;external libname name 'LLVMSetGC'; +procedure LLVMAddFunctionAttr(Fn:LLVMValueRef; PA:LLVMAttribute);cdecl;external libname name 'LLVMAddFunctionAttr'; +function LLVMGetFunctionAttr(Fn:LLVMValueRef):LLVMAttribute;cdecl;external libname name 'LLVMGetFunctionAttr'; +procedure LLVMRemoveFunctionAttr(Fn:LLVMValueRef; PA:LLVMAttribute);cdecl;external libname name 'LLVMRemoveFunctionAttr'; +{ Operations on parameters } +function LLVMCountParams(Fn:LLVMValueRef):dword;cdecl;external libname name 'LLVMCountParams'; +procedure LLVMGetParams(Fn:LLVMValueRef; Params:pLLVMValueRef);cdecl;external libname name 'LLVMGetParams'; +function LLVMGetParam(Fn:LLVMValueRef; Index:dword):LLVMValueRef;cdecl;external libname name 'LLVMGetParam'; +function LLVMGetParamParent(Inst:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMGetParamParent'; +function LLVMGetFirstParam(Fn:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMGetFirstParam'; +function LLVMGetLastParam(Fn:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMGetLastParam'; +function LLVMGetNextParam(Arg:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMGetNextParam'; +function LLVMGetPreviousParam(Arg:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMGetPreviousParam'; +procedure LLVMAddAttribute(Arg:LLVMValueRef; PA:LLVMAttribute);cdecl;external libname name 'LLVMAddAttribute'; +procedure LLVMRemoveAttribute(Arg:LLVMValueRef; PA:LLVMAttribute);cdecl;external libname name 'LLVMRemoveAttribute'; +function LLVMGetAttribute(Arg:LLVMValueRef):LLVMAttribute;cdecl;external libname name 'LLVMGetAttribute'; +procedure LLVMSetParamAlignment(Arg:LLVMValueRef; align:dword);cdecl;external libname name 'LLVMSetParamAlignment'; +{ Operations on basic blocks } +function LLVMBasicBlockAsValue(BB:LLVMBasicBlockRef):LLVMValueRef;cdecl;external libname name 'LLVMBasicBlockAsValue'; +function LLVMValueIsBasicBlock(Val:LLVMValueRef):longint;cdecl;external libname name 'LLVMValueIsBasicBlock'; +function LLVMValueAsBasicBlock(Val:LLVMValueRef):LLVMBasicBlockRef;cdecl;external libname name 'LLVMValueAsBasicBlock'; +function LLVMGetBasicBlockParent(BB:LLVMBasicBlockRef):LLVMValueRef;cdecl;external libname name 'LLVMGetBasicBlockParent'; +function LLVMCountBasicBlocks(Fn:LLVMValueRef):dword;cdecl;external libname name 'LLVMCountBasicBlocks'; +procedure LLVMGetBasicBlocks(Fn:LLVMValueRef; BasicBlocks:pLLVMBasicBlockRef);cdecl;external libname name 'LLVMGetBasicBlocks'; +function LLVMGetFirstBasicBlock(Fn:LLVMValueRef):LLVMBasicBlockRef;cdecl;external libname name 'LLVMGetFirstBasicBlock'; +function LLVMGetLastBasicBlock(Fn:LLVMValueRef):LLVMBasicBlockRef;cdecl;external libname name 'LLVMGetLastBasicBlock'; +function LLVMGetNextBasicBlock(BB:LLVMBasicBlockRef):LLVMBasicBlockRef;cdecl;external libname name 'LLVMGetNextBasicBlock'; +function LLVMGetPreviousBasicBlock(BB:LLVMBasicBlockRef):LLVMBasicBlockRef;cdecl;external libname name 'LLVMGetPreviousBasicBlock'; +function LLVMGetEntryBasicBlock(Fn:LLVMValueRef):LLVMBasicBlockRef;cdecl;external libname name 'LLVMGetEntryBasicBlock'; +function LLVMAppendBasicBlockInContext(C:LLVMContextRef; Fn:LLVMValueRef; Name:pchar):LLVMBasicBlockRef;cdecl;external libname name 'LLVMAppendBasicBlockInContext'; +function LLVMInsertBasicBlockInContext(C:LLVMContextRef; BB:LLVMBasicBlockRef; Name:pchar):LLVMBasicBlockRef;cdecl;external libname name 'LLVMInsertBasicBlockInContext'; +function LLVMAppendBasicBlock(Fn:LLVMValueRef; Name:pchar):LLVMBasicBlockRef;cdecl;external libname name 'LLVMAppendBasicBlock'; +function LLVMInsertBasicBlock(InsertBeforeBB:LLVMBasicBlockRef; Name:pchar):LLVMBasicBlockRef;cdecl;external libname name 'LLVMInsertBasicBlock'; +procedure LLVMDeleteBasicBlock(BB:LLVMBasicBlockRef);cdecl;external libname name 'LLVMDeleteBasicBlock'; +{ Operations on instructions } +function LLVMGetInstructionParent(Inst:LLVMValueRef):LLVMBasicBlockRef;cdecl;external libname name 'LLVMGetInstructionParent'; +function LLVMGetFirstInstruction(BB:LLVMBasicBlockRef):LLVMValueRef;cdecl;external libname name 'LLVMGetFirstInstruction'; +function LLVMGetLastInstruction(BB:LLVMBasicBlockRef):LLVMValueRef;cdecl;external libname name 'LLVMGetLastInstruction'; +function LLVMGetNextInstruction(Inst:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMGetNextInstruction'; +function LLVMGetPreviousInstruction(Inst:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMGetPreviousInstruction'; +{ Operations on call sites } +procedure LLVMSetInstructionCallConv(Instr:LLVMValueRef; CC:dword);cdecl;external libname name 'LLVMSetInstructionCallConv'; +function LLVMGetInstructionCallConv(Instr:LLVMValueRef):dword;cdecl;external libname name 'LLVMGetInstructionCallConv'; +procedure LLVMAddInstrAttribute(Instr:LLVMValueRef; index:dword; para3:LLVMAttribute);cdecl;external libname name 'LLVMAddInstrAttribute'; +procedure LLVMRemoveInstrAttribute(Instr:LLVMValueRef; index:dword; para3:LLVMAttribute);cdecl;external libname name 'LLVMRemoveInstrAttribute'; +procedure LLVMSetInstrParamAlignment(Instr:LLVMValueRef; index:dword; align:dword);cdecl;external libname name 'LLVMSetInstrParamAlignment'; +{ Operations on call instructions (only) } +function LLVMIsTailCall(CallInst:LLVMValueRef):longint;cdecl;external libname name 'LLVMIsTailCall'; +procedure LLVMSetTailCall(CallInst:LLVMValueRef; IsTailCall:longint);cdecl;external libname name 'LLVMSetTailCall'; +{ Operations on phi nodes } +procedure LLVMAddIncoming(PhiNode:LLVMValueRef; IncomingValues:pLLVMValueRef; IncomingBlocks:pLLVMBasicBlockRef; Count:dword);cdecl;external libname name 'LLVMAddIncoming'; +function LLVMCountIncoming(PhiNode:LLVMValueRef):dword;cdecl;external libname name 'LLVMCountIncoming'; +function LLVMGetIncomingValue(PhiNode:LLVMValueRef; Index:dword):LLVMValueRef;cdecl;external libname name 'LLVMGetIncomingValue'; +function LLVMGetIncomingBlock(PhiNode:LLVMValueRef; Index:dword):LLVMBasicBlockRef;cdecl;external libname name 'LLVMGetIncomingBlock'; +{===-- Instruction builders ----------------------------------------------=== } +{ An instruction builder represents a point within a basic block, and is the + * exclusive means of building instructions using the C interface. + } +function LLVMCreateBuilderInContext(C:LLVMContextRef):LLVMBuilderRef;cdecl;external libname name 'LLVMCreateBuilderInContext'; +function LLVMCreateBuilder:LLVMBuilderRef;cdecl;external libname name 'LLVMCreateBuilder'; +procedure LLVMPositionBuilder(Builder:LLVMBuilderRef; Block:LLVMBasicBlockRef; Instr:LLVMValueRef);cdecl;external libname name 'LLVMPositionBuilder'; +procedure LLVMPositionBuilderBefore(Builder:LLVMBuilderRef; Instr:LLVMValueRef);cdecl;external libname name 'LLVMPositionBuilderBefore'; +procedure LLVMPositionBuilderAtEnd(Builder:LLVMBuilderRef; Block:LLVMBasicBlockRef);cdecl;external libname name 'LLVMPositionBuilderAtEnd'; +function LLVMGetInsertBlock(Builder:LLVMBuilderRef):LLVMBasicBlockRef;cdecl;external libname name 'LLVMGetInsertBlock'; +procedure LLVMClearInsertionPosition(Builder:LLVMBuilderRef);cdecl;external libname name 'LLVMClearInsertionPosition'; +procedure LLVMInsertIntoBuilder(Builder:LLVMBuilderRef; Instr:LLVMValueRef);cdecl;external libname name 'LLVMInsertIntoBuilder'; +procedure LLVMInsertIntoBuilderWithName(Builder:LLVMBuilderRef; Instr:LLVMValueRef; Name:pchar);cdecl;external libname name 'LLVMInsertIntoBuilderWithName'; +procedure LLVMDisposeBuilder(Builder:LLVMBuilderRef);cdecl;external libname name 'LLVMDisposeBuilder'; +{ Terminators } +function LLVMBuildRetVoid(para1:LLVMBuilderRef):LLVMValueRef;cdecl;external libname name 'LLVMBuildRetVoid'; +function LLVMBuildRet(para1:LLVMBuilderRef; V:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMBuildRet'; +function LLVMBuildAggregateRet(para1:LLVMBuilderRef; RetVals:pLLVMValueRef; N:dword):LLVMValueRef;cdecl;external libname name 'LLVMBuildAggregateRet'; +function LLVMBuildBr(para1:LLVMBuilderRef; Dest:LLVMBasicBlockRef):LLVMValueRef;cdecl;external libname name 'LLVMBuildBr'; +function LLVMBuildCondBr(para1:LLVMBuilderRef; Cond:LLVMValueRef; + ThenBranch:LLVMBasicBlockRef; ElseBranch:LLVMBasicBlockRef):LLVMValueRef;cdecl;external libname name 'LLVMBuildCondBr'; +function LLVMBuildSwitch(para1:LLVMBuilderRef; V:LLVMValueRef; ElseBranch:LLVMBasicBlockRef; NumCases:dword):LLVMValueRef;cdecl;external libname name 'LLVMBuildSwitch'; +function LLVMBuildInvoke(para1:LLVMBuilderRef; Fn:LLVMValueRef; Args:pLLVMValueRef; NumArgs:dword; ThenBranch:LLVMBasicBlockRef; + Catch:LLVMBasicBlockRef; Name:pchar):LLVMValueRef;cdecl;external libname name 'LLVMBuildInvoke'; +function LLVMBuildUnwind(para1:LLVMBuilderRef):LLVMValueRef;cdecl;external libname name 'LLVMBuildUnwind'; +function LLVMBuildUnreachable(para1:LLVMBuilderRef):LLVMValueRef;cdecl;external libname name 'LLVMBuildUnreachable'; +{ Add a case to the switch instruction } +procedure LLVMAddCase(Switch:LLVMValueRef; OnVal:LLVMValueRef; Dest:LLVMBasicBlockRef);cdecl;external libname name 'LLVMAddCase'; +{ Arithmetic } +function LLVMBuildAdd(para1:LLVMBuilderRef; LHS:LLVMValueRef; RHS:LLVMValueRef; Name:pchar):LLVMValueRef;cdecl;external libname name 'LLVMBuildAdd'; +function LLVMBuildNSWAdd(para1:LLVMBuilderRef; LHS:LLVMValueRef; RHS:LLVMValueRef; Name:pchar):LLVMValueRef;cdecl;external libname name 'LLVMBuildNSWAdd'; +function LLVMBuildFAdd(para1:LLVMBuilderRef; LHS:LLVMValueRef; RHS:LLVMValueRef; Name:pchar):LLVMValueRef;cdecl;external libname name 'LLVMBuildFAdd'; +function LLVMBuildSub(para1:LLVMBuilderRef; LHS:LLVMValueRef; RHS:LLVMValueRef; Name:pchar):LLVMValueRef;cdecl;external libname name 'LLVMBuildSub'; +function LLVMBuildFSub(para1:LLVMBuilderRef; LHS:LLVMValueRef; RHS:LLVMValueRef; Name:pchar):LLVMValueRef;cdecl;external libname name 'LLVMBuildFSub'; +function LLVMBuildMul(para1:LLVMBuilderRef; LHS:LLVMValueRef; RHS:LLVMValueRef; Name:pchar):LLVMValueRef;cdecl;external libname name 'LLVMBuildMul'; +function LLVMBuildFMul(para1:LLVMBuilderRef; LHS:LLVMValueRef; RHS:LLVMValueRef; Name:pchar):LLVMValueRef;cdecl;external libname name 'LLVMBuildFMul'; +function LLVMBuildUDiv(para1:LLVMBuilderRef; LHS:LLVMValueRef; RHS:LLVMValueRef; Name:pchar):LLVMValueRef;cdecl;external libname name 'LLVMBuildUDiv'; +function LLVMBuildSDiv(para1:LLVMBuilderRef; LHS:LLVMValueRef; RHS:LLVMValueRef; Name:pchar):LLVMValueRef;cdecl;external libname name 'LLVMBuildSDiv'; +function LLVMBuildExactSDiv(para1:LLVMBuilderRef; LHS:LLVMValueRef; RHS:LLVMValueRef; Name:pchar):LLVMValueRef;cdecl;external libname name 'LLVMBuildExactSDiv'; +function LLVMBuildFDiv(para1:LLVMBuilderRef; LHS:LLVMValueRef; RHS:LLVMValueRef; Name:pchar):LLVMValueRef;cdecl;external libname name 'LLVMBuildFDiv'; +function LLVMBuildURem(para1:LLVMBuilderRef; LHS:LLVMValueRef; RHS:LLVMValueRef; Name:pchar):LLVMValueRef;cdecl;external libname name 'LLVMBuildURem'; +function LLVMBuildSRem(para1:LLVMBuilderRef; LHS:LLVMValueRef; RHS:LLVMValueRef; Name:pchar):LLVMValueRef;cdecl;external libname name 'LLVMBuildSRem'; +function LLVMBuildFRem(para1:LLVMBuilderRef; LHS:LLVMValueRef; RHS:LLVMValueRef; Name:pchar):LLVMValueRef;cdecl;external libname name 'LLVMBuildFRem'; +function LLVMBuildShl(para1:LLVMBuilderRef; LHS:LLVMValueRef; RHS:LLVMValueRef; Name:pchar):LLVMValueRef;cdecl;external libname name 'LLVMBuildShl'; +function LLVMBuildLShr(para1:LLVMBuilderRef; LHS:LLVMValueRef; RHS:LLVMValueRef; Name:pchar):LLVMValueRef;cdecl;external libname name 'LLVMBuildLShr'; +function LLVMBuildAShr(para1:LLVMBuilderRef; LHS:LLVMValueRef; RHS:LLVMValueRef; Name:pchar):LLVMValueRef;cdecl;external libname name 'LLVMBuildAShr'; +function LLVMBuildAnd(para1:LLVMBuilderRef; LHS:LLVMValueRef; RHS:LLVMValueRef; Name:pchar):LLVMValueRef;cdecl;external libname name 'LLVMBuildAnd'; +function LLVMBuildOr(para1:LLVMBuilderRef; LHS:LLVMValueRef; RHS:LLVMValueRef; Name:pchar):LLVMValueRef;cdecl;external libname name 'LLVMBuildOr'; +function LLVMBuildXor(para1:LLVMBuilderRef; LHS:LLVMValueRef; RHS:LLVMValueRef; Name:pchar):LLVMValueRef;cdecl;external libname name 'LLVMBuildXor'; +function LLVMBuildNeg(para1:LLVMBuilderRef; V:LLVMValueRef; Name:pchar):LLVMValueRef;cdecl;external libname name 'LLVMBuildNeg'; +function LLVMBuildFNeg(para1:LLVMBuilderRef; V:LLVMValueRef; Name:pchar):LLVMValueRef;cdecl;external libname name 'LLVMBuildFNeg'; +function LLVMBuildNot(para1:LLVMBuilderRef; V:LLVMValueRef; Name:pchar):LLVMValueRef;cdecl;external libname name 'LLVMBuildNot'; +{ Memory } +function LLVMBuildMalloc(para1:LLVMBuilderRef; Ty:LLVMTypeRef; Name:pchar):LLVMValueRef;cdecl;external libname name 'LLVMBuildMalloc'; +function LLVMBuildArrayMalloc(para1:LLVMBuilderRef; Ty:LLVMTypeRef; Val:LLVMValueRef; Name:pchar):LLVMValueRef;cdecl;external libname name 'LLVMBuildArrayMalloc'; +function LLVMBuildAlloca(para1:LLVMBuilderRef; Ty:LLVMTypeRef; Name:pchar):LLVMValueRef;cdecl;external libname name 'LLVMBuildAlloca'; +function LLVMBuildArrayAlloca(para1:LLVMBuilderRef; Ty:LLVMTypeRef; Val:LLVMValueRef; Name:pchar):LLVMValueRef;cdecl;external libname name 'LLVMBuildArrayAlloca'; +function LLVMBuildFree(para1:LLVMBuilderRef; PointerVal:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMBuildFree'; +function LLVMBuildLoad(para1:LLVMBuilderRef; PointerVal:LLVMValueRef; Name:pchar):LLVMValueRef;cdecl;external libname name 'LLVMBuildLoad'; +function LLVMBuildStore(para1:LLVMBuilderRef; Val:LLVMValueRef; Ptr:LLVMValueRef):LLVMValueRef;cdecl;external libname name 'LLVMBuildStore'; +function LLVMBuildGEP(B:LLVMBuilderRef; Pointer:LLVMValueRef; Indices:pLLVMValueRef; NumIndices:dword; Name:pchar):LLVMValueRef;cdecl;external libname name 'LLVMBuildGEP'; +function LLVMBuildInBoundsGEP(B:LLVMBuilderRef; Pointer:LLVMValueRef; Indices:pLLVMValueRef; NumIndices:dword; Name:pchar):LLVMValueRef;cdecl;external libname name 'LLVMBuildInBoundsGEP'; +function LLVMBuildStructGEP(B:LLVMBuilderRef; Pointer:LLVMValueRef; Idx:dword; Name:pchar):LLVMValueRef;cdecl;external libname name 'LLVMBuildStructGEP'; +function LLVMBuildGlobalString(B:LLVMBuilderRef; Str:pchar; Name:pchar):LLVMValueRef;cdecl;external libname name 'LLVMBuildGlobalString'; +function LLVMBuildGlobalStringPtr(B:LLVMBuilderRef; Str:pchar; Name:pchar):LLVMValueRef;cdecl;external libname name 'LLVMBuildGlobalStringPtr'; +{ Casts } +function LLVMBuildTrunc(para1:LLVMBuilderRef; Val:LLVMValueRef; DestTy:LLVMTypeRef; Name:pchar):LLVMValueRef;cdecl;external libname name 'LLVMBuildTrunc'; +function LLVMBuildZExt(para1:LLVMBuilderRef; Val:LLVMValueRef; DestTy:LLVMTypeRef; Name:pchar):LLVMValueRef;cdecl;external libname name 'LLVMBuildZExt'; +function LLVMBuildSExt(para1:LLVMBuilderRef; Val:LLVMValueRef; DestTy:LLVMTypeRef; Name:pchar):LLVMValueRef;cdecl;external libname name 'LLVMBuildSExt'; +function LLVMBuildFPToUI(para1:LLVMBuilderRef; Val:LLVMValueRef; DestTy:LLVMTypeRef; Name:pchar):LLVMValueRef;cdecl;external libname name 'LLVMBuildFPToUI'; +function LLVMBuildFPToSI(para1:LLVMBuilderRef; Val:LLVMValueRef; DestTy:LLVMTypeRef; Name:pchar):LLVMValueRef;cdecl;external libname name 'LLVMBuildFPToSI'; +function LLVMBuildUIToFP(para1:LLVMBuilderRef; Val:LLVMValueRef; DestTy:LLVMTypeRef; Name:pchar):LLVMValueRef;cdecl;external libname name 'LLVMBuildUIToFP'; +function LLVMBuildSIToFP(para1:LLVMBuilderRef; Val:LLVMValueRef; DestTy:LLVMTypeRef; Name:pchar):LLVMValueRef;cdecl;external libname name 'LLVMBuildSIToFP'; +function LLVMBuildFPTrunc(para1:LLVMBuilderRef; Val:LLVMValueRef; DestTy:LLVMTypeRef; Name:pchar):LLVMValueRef;cdecl;external libname name 'LLVMBuildFPTrunc'; +function LLVMBuildFPExt(para1:LLVMBuilderRef; Val:LLVMValueRef; DestTy:LLVMTypeRef; Name:pchar):LLVMValueRef;cdecl;external libname name 'LLVMBuildFPExt'; +function LLVMBuildPtrToInt(para1:LLVMBuilderRef; Val:LLVMValueRef; DestTy:LLVMTypeRef; Name:pchar):LLVMValueRef;cdecl;external libname name 'LLVMBuildPtrToInt'; +function LLVMBuildIntToPtr(para1:LLVMBuilderRef; Val:LLVMValueRef; DestTy:LLVMTypeRef; Name:pchar):LLVMValueRef;cdecl;external libname name 'LLVMBuildIntToPtr'; +function LLVMBuildBitCast(para1:LLVMBuilderRef; Val:LLVMValueRef; DestTy:LLVMTypeRef; Name:pchar):LLVMValueRef;cdecl;external libname name 'LLVMBuildBitCast'; +function LLVMBuildZExtOrBitCast(para1:LLVMBuilderRef; Val:LLVMValueRef; DestTy:LLVMTypeRef; Name:pchar):LLVMValueRef;cdecl;external libname name 'LLVMBuildZExtOrBitCast'; +function LLVMBuildSExtOrBitCast(para1:LLVMBuilderRef; Val:LLVMValueRef; DestTy:LLVMTypeRef; Name:pchar):LLVMValueRef;cdecl;external libname name 'LLVMBuildSExtOrBitCast'; +function LLVMBuildTruncOrBitCast(para1:LLVMBuilderRef; Val:LLVMValueRef; DestTy:LLVMTypeRef; Name:pchar):LLVMValueRef;cdecl;external libname name 'LLVMBuildTruncOrBitCast'; +function LLVMBuildPointerCast(para1:LLVMBuilderRef; Val:LLVMValueRef; DestTy:LLVMTypeRef; Name:pchar):LLVMValueRef;cdecl;external libname name 'LLVMBuildPointerCast'; +function LLVMBuildIntCast(para1:LLVMBuilderRef; Val:LLVMValueRef; DestTy:LLVMTypeRef; Name:pchar):LLVMValueRef;cdecl;external libname name 'LLVMBuildIntCast'; +function LLVMBuildFPCast(para1:LLVMBuilderRef; Val:LLVMValueRef; DestTy:LLVMTypeRef; Name:pchar):LLVMValueRef;cdecl;external libname name 'LLVMBuildFPCast'; +{ Comparisons } +function LLVMBuildICmp(para1:LLVMBuilderRef; Op:LLVMIntPredicate; LHS:LLVMValueRef; RHS:LLVMValueRef; Name:pchar):LLVMValueRef;cdecl;external libname name 'LLVMBuildICmp'; +function LLVMBuildFCmp(para1:LLVMBuilderRef; Op:LLVMRealPredicate; LHS:LLVMValueRef; RHS:LLVMValueRef; Name:pchar):LLVMValueRef;cdecl;external libname name 'LLVMBuildFCmp'; +{ Miscellaneous instructions } +function LLVMBuildPhi(para1:LLVMBuilderRef; Ty:LLVMTypeRef; Name:pchar):LLVMValueRef;cdecl;external libname name 'LLVMBuildPhi'; +function LLVMBuildCall(para1:LLVMBuilderRef; Fn:LLVMValueRef; Args:pLLVMValueRef; NumArgs:dword; Name:pchar):LLVMValueRef;cdecl;external libname name 'LLVMBuildCall'; +function LLVMBuildSelect(para1:LLVMBuilderRef; Cond:LLVMValueRef; ThenBranch:LLVMValueRef; ElseBranch:LLVMValueRef; Name:pchar):LLVMValueRef;cdecl;external libname name 'LLVMBuildSelect'; +function LLVMBuildVAArg(para1:LLVMBuilderRef; List:LLVMValueRef; Ty:LLVMTypeRef; Name:pchar):LLVMValueRef;cdecl;external libname name 'LLVMBuildVAArg'; +function LLVMBuildExtractElement(para1:LLVMBuilderRef; VecVal:LLVMValueRef; Index:LLVMValueRef; Name:pchar):LLVMValueRef;cdecl;external libname name 'LLVMBuildExtractElement'; +function LLVMBuildInsertElement(para1:LLVMBuilderRef; VecVal:LLVMValueRef; EltVal:LLVMValueRef; Index:LLVMValueRef; Name:pchar):LLVMValueRef;cdecl;external libname name 'LLVMBuildInsertElement'; +function LLVMBuildShuffleVector(para1:LLVMBuilderRef; V1:LLVMValueRef; V2:LLVMValueRef; Mask:LLVMValueRef; Name:pchar):LLVMValueRef;cdecl;external libname name 'LLVMBuildShuffleVector'; +function LLVMBuildExtractValue(para1:LLVMBuilderRef; AggVal:LLVMValueRef; Index:dword; Name:pchar):LLVMValueRef;cdecl;external libname name 'LLVMBuildExtractValue'; +function LLVMBuildInsertValue(para1:LLVMBuilderRef; AggVal:LLVMValueRef; EltVal:LLVMValueRef; Index:dword; Name:pchar):LLVMValueRef;cdecl;external libname name 'LLVMBuildInsertValue'; +function LLVMBuildIsNull(para1:LLVMBuilderRef; Val:LLVMValueRef; Name:pchar):LLVMValueRef;cdecl;external libname name 'LLVMBuildIsNull'; +function LLVMBuildIsNotNull(para1:LLVMBuilderRef; Val:LLVMValueRef; Name:pchar):LLVMValueRef;cdecl;external libname name 'LLVMBuildIsNotNull'; +function LLVMBuildPtrDiff(para1:LLVMBuilderRef; LHS:LLVMValueRef; RHS:LLVMValueRef; Name:pchar):LLVMValueRef;cdecl;external libname name 'LLVMBuildPtrDiff'; +{===-- Module providers --------------------------------------------------=== } +{ Encapsulates the module M in a module provider, taking ownership of the + * module. + * See the constructor llvm::ExistingModuleProvider::ExistingModuleProvider. + } +function LLVMCreateModuleProviderForExistingModule(M:LLVMModuleRef):LLVMModuleProviderRef;cdecl;external libname name 'LLVMCreateModuleProviderForExistingModule'; +{ Destroys the module provider MP as well as the contained module. + * See the destructor llvm::ModuleProvider::~ModuleProvider. + } +procedure LLVMDisposeModuleProvider(MP:LLVMModuleProviderRef);cdecl;external libname name 'LLVMDisposeModuleProvider'; +{===-- Memory buffers ----------------------------------------------------=== } +function LLVMCreateMemoryBufferWithContentsOfFile(Path:pchar; OutMemBuf:pLLVMMemoryBufferRef; OutMessage:Ppchar):longint;cdecl;external libname name 'LLVMCreateMemoryBufferWithContentsOfFile'; +function LLVMCreateMemoryBufferWithSTDIN(OutMemBuf:pLLVMMemoryBufferRef; OutMessage:Ppchar):longint;cdecl;external libname name 'LLVMCreateMemoryBufferWithSTDIN'; +procedure LLVMDisposeMemoryBuffer(MemBuf:LLVMMemoryBufferRef);cdecl;external libname name 'LLVMDisposeMemoryBuffer'; +{===-- 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. } +function LLVMCreatePassManager:LLVMPassManagerRef;cdecl;external libname name 'LLVMCreatePassManager'; +{* 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. } +function LLVMCreateFunctionPassManager(MP:LLVMModuleProviderRef):LLVMPassManagerRef;cdecl;external libname name 'LLVMCreateFunctionPassManager'; +{* 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&). } +function LLVMRunPassManager(PM:LLVMPassManagerRef; M:LLVMModuleRef):longint;cdecl;external libname name 'LLVMRunPassManager'; +{* 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. } +function LLVMInitializeFunctionPassManager(FPM:LLVMPassManagerRef):longint;cdecl;external libname name 'LLVMInitializeFunctionPassManager'; +{* 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&). } +function LLVMRunFunctionPassManager(FPM:LLVMPassManagerRef; F:LLVMValueRef):longint;cdecl;external libname name 'LLVMRunFunctionPassManager'; +{* 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. } +function LLVMFinalizeFunctionPassManager(FPM:LLVMPassManagerRef):longint;cdecl;external libname name 'LLVMFinalizeFunctionPassManager'; +{* Frees the memory of a pass pipeline. For function pipelines, does not free + the module provider. + See llvm::PassManagerBase::~PassManagerBase. } +procedure LLVMDisposePassManager(PM:LLVMPassManagerRef);cdecl;external libname name 'LLVMDisposePassManager'; +{ Analysis.h } +{ verifier will print to stderr and abort() } +{ verifier will print to stderr and return 1 } +{ verifier will just return 1 } +type + + LLVMVerifierFailureAction = (LLVMAbortProcessAction,LLVMPrintMessageAction, + LLVMReturnStatusAction); +{ Verifies that a module is valid, taking the specified action if not. + Optionally returns a human-readable description of any invalid constructs. + OutMessage must be disposed with LLVMDisposeMessage. } + +function LLVMVerifyModule(M:LLVMModuleRef; Action:LLVMVerifierFailureAction; OutMessage:Ppchar):longint;cdecl;external libname name 'LLVMVerifyModule'; +{ Verifies that a single function is valid, taking the specified action. Useful + for debugging. } +function LLVMVerifyFunction(Fn:LLVMValueRef; Action:LLVMVerifierFailureAction):longint;cdecl;external libname name 'LLVMVerifyFunction'; +{ Open up a ghostview window that displays the CFG of the current function. + Useful for debugging. } +procedure LLVMViewFunctionCFG(Fn:LLVMValueRef);cdecl;external libname name 'LLVMViewFunctionCFG'; +procedure LLVMViewFunctionCFGOnly(Fn:LLVMValueRef);cdecl;external libname name 'LLVMViewFunctionCFGOnly'; +{ BitReader.h } +{ Builds a module from the bitcode in the specified memory buffer, returning a + reference to the module via the OutModule parameter. Returns 0 on success. + Optionally returns a human-readable error message via OutMessage. }function LLVMParseBitcode(MemBuf:LLVMMemoryBufferRef; OutModule:pLLVMModuleRef; OutMessage:Ppchar):longint;cdecl;external libname name 'LLVMParseBitcode'; +function LLVMParseBitcodeInContext(ContextRef:LLVMContextRef; MemBuf:LLVMMemoryBufferRef; OutModule:pLLVMModuleRef; OutMessage:Ppchar):longint;cdecl;external libname name 'LLVMParseBitcodeInContext'; +{ Reads a module from the specified path, returning via the OutMP parameter + a module provider which performs lazy deserialization. Returns 0 on success. + Optionally returns a human-readable error message via OutMessage. }function LLVMGetBitcodeModuleProvider(MemBuf:LLVMMemoryBufferRef; OutMP:pLLVMModuleProviderRef; OutMessage:Ppchar):longint;cdecl;external libname name 'LLVMGetBitcodeModuleProvider'; +function LLVMGetBitcodeModuleProviderInContext(ContextRef:LLVMContextRef; MemBuf:LLVMMemoryBufferRef; OutMP:pLLVMModuleProviderRef; OutMessage:Ppchar):longint;cdecl;external libname name 'LLVMGetBitcodeModuleProviderInContext'; +{ BitWriter.h } +{===-- Operations on modules ---------------------------------------------=== } +{ Writes a module to an open file descriptor. Returns 0 on success. + Closes the Handle. Use dup first if this is not what you want. }function LLVMWriteBitcodeToFileHandle(M:LLVMModuleRef; Handle:longint):longint;cdecl;external libname name 'LLVMWriteBitcodeToFileHandle'; +{ Writes a module to the specified path. Returns 0 on success. }function LLVMWriteBitcodeToFile(M:LLVMModuleRef; Path:pchar):longint;cdecl;external libname name 'LLVMWriteBitcodeToFile'; +{ Target.h } + +const + LLVMBigEndian = 0; + LLVMLittleEndian = 1; +type + + LLVMByteOrdering = longint; + + LLVMTargetDataRef = LLVMOpaqueTargetData; + + LLVMStructLayoutRef = LLVMStructLayout; +{===-- Target Data -------------------------------------------------------=== } +{* Creates target data from a target layout string. + See the constructor llvm::TargetData::TargetData. } + +function LLVMCreateTargetData(StringRep:pchar):LLVMTargetDataRef;cdecl;external libname name 'LLVMCreateTargetData'; +{* Adds target data information to a pass manager. This does not take ownership + of the target data. + See the method llvm::PassManagerBase::add. } +procedure LLVMAddTargetData(para1:LLVMTargetDataRef; para2:LLVMPassManagerRef);cdecl;external libname name 'LLVMAddTargetData'; +{* Converts target data to a target layout string. The string must be disposed + with LLVMDisposeMessage. + See the constructor llvm::TargetData::TargetData. } +function LLVMCopyStringRepOfTargetData(para1:LLVMTargetDataRef):pchar;cdecl;external libname name 'LLVMCopyStringRepOfTargetData'; +{* Returns the byte order of a target, either LLVMBigEndian or + LLVMLittleEndian. + See the method llvm::TargetData::isLittleEndian. } +function LLVMByteOrder(para1:LLVMTargetDataRef):LLVMByteOrdering;cdecl;external libname name 'LLVMByteOrder'; +{* Returns the pointer size in bytes for a target. + See the method llvm::TargetData::getPointerSize. } +function LLVMPointerSize(para1:LLVMTargetDataRef):dword;cdecl;external libname name 'LLVMPointerSize'; +{* Returns the integer type that is the same size as a pointer on a target. + See the method llvm::TargetData::getIntPtrType. } +function LLVMIntPtrType(para1:LLVMTargetDataRef):LLVMTypeRef;cdecl;external libname name 'LLVMIntPtrType'; +{* Computes the size of a type in bytes for a target. + See the method llvm::TargetData::getTypeSizeInBits. } +function LLVMSizeOfTypeInBits(para1:LLVMTargetDataRef; para2:LLVMTypeRef):qword;cdecl;external libname name 'LLVMSizeOfTypeInBits'; +{* Computes the storage size of a type in bytes for a target. + See the method llvm::TargetData::getTypeStoreSize. } +function LLVMStoreSizeOfType(para1:LLVMTargetDataRef; para2:LLVMTypeRef):qword;cdecl;external libname name 'LLVMStoreSizeOfType'; +{* Computes the ABI size of a type in bytes for a target. + See the method llvm::TargetData::getTypeAllocSize. } +function LLVMABISizeOfType(para1:LLVMTargetDataRef; para2:LLVMTypeRef):qword;cdecl;external libname name 'LLVMABISizeOfType'; +{* Computes the ABI alignment of a type in bytes for a target. + See the method llvm::TargetData::getTypeABISize. } +function LLVMABIAlignmentOfType(para1:LLVMTargetDataRef; para2:LLVMTypeRef):dword;cdecl;external libname name 'LLVMABIAlignmentOfType'; +{* Computes the call frame alignment of a type in bytes for a target. + See the method llvm::TargetData::getTypeABISize. } +function LLVMCallFrameAlignmentOfType(para1:LLVMTargetDataRef; para2:LLVMTypeRef):dword;cdecl;external libname name 'LLVMCallFrameAlignmentOfType'; +{* Computes the preferred alignment of a type in bytes for a target. + See the method llvm::TargetData::getTypeABISize. } +function LLVMPreferredAlignmentOfType(para1:LLVMTargetDataRef; para2:LLVMTypeRef):dword;cdecl;external libname name 'LLVMPreferredAlignmentOfType'; +{* Computes the preferred alignment of a global variable in bytes for a target. + See the method llvm::TargetData::getPreferredAlignment. } +function LLVMPreferredAlignmentOfGlobal(para1:LLVMTargetDataRef; GlobalVar:LLVMValueRef):dword;cdecl;external libname name 'LLVMPreferredAlignmentOfGlobal'; +{* Computes the structure element that contains the byte offset for a target. + See the method llvm::StructLayout::getElementContainingOffset. } +function LLVMElementAtOffset(para1:LLVMTargetDataRef; StructTy:LLVMTypeRef; Offset:qword):dword;cdecl;external libname name 'LLVMElementAtOffset'; +{* Computes the byte offset of the indexed struct element for a target. + See the method llvm::StructLayout::getElementContainingOffset. } +function LLVMOffsetOfElement(para1:LLVMTargetDataRef; StructTy:LLVMTypeRef; Element:dword):qword;cdecl;external libname name 'LLVMOffsetOfElement'; +{* Struct layouts are speculatively cached. If a TargetDataRef is alive when + types are being refined and removed, this method must be called whenever a + struct type is removed to avoid a dangling pointer in this cache. + See the method llvm::TargetData::InvalidateStructLayoutInfo. } +procedure LLVMInvalidateStructLayout(para1:LLVMTargetDataRef; StructTy:LLVMTypeRef);cdecl;external libname name 'LLVMInvalidateStructLayout'; +{* Deallocates a TargetData. + See the destructor llvm::TargetData::~TargetData. } +procedure LLVMDisposeTargetData(para1:LLVMTargetDataRef);cdecl;external libname name 'LLVMDisposeTargetData'; +{ ExecutionEngine.h } +procedure LLVMLinkInJIT;cdecl;external libname name 'LLVMLinkInJIT'; +procedure LLVMLinkInInterpreter;cdecl;external libname name 'LLVMLinkInInterpreter'; +type + + LLVMGenericValueRef = LLVMOpaqueGenericValue; + + LLVMExecutionEngineRef = LLVMOpaqueExecutionEngine; +{===-- Operations on generic values --------------------------------------=== } + +function LLVMCreateGenericValueOfInt(Ty:LLVMTypeRef; N:qword; IsSigned:longint):LLVMGenericValueRef;cdecl;external libname name 'LLVMCreateGenericValueOfInt'; +function LLVMCreateGenericValueOfPointer(P:pointer):LLVMGenericValueRef;cdecl;external libname name 'LLVMCreateGenericValueOfPointer'; +function LLVMCreateGenericValueOfFloat(Ty:LLVMTypeRef; N:double):LLVMGenericValueRef;cdecl;external libname name 'LLVMCreateGenericValueOfFloat'; +function LLVMGenericValueIntWidth(GenValRef:LLVMGenericValueRef):dword;cdecl;external libname name 'LLVMGenericValueIntWidth'; +function LLVMGenericValueToInt(GenVal:LLVMGenericValueRef; IsSigned:longint):qword;cdecl;external libname name 'LLVMGenericValueToInt'; +function LLVMGenericValueToPointer(GenVal:LLVMGenericValueRef):pointer;cdecl;external libname name 'LLVMGenericValueToPointer'; +function LLVMGenericValueToFloat(TyRef:LLVMTypeRef; GenVal:LLVMGenericValueRef):double;cdecl;external libname name 'LLVMGenericValueToFloat'; +procedure LLVMDisposeGenericValue(GenVal:LLVMGenericValueRef);cdecl;external libname name 'LLVMDisposeGenericValue'; +{===-- Operations on execution engines -----------------------------------=== } +function LLVMCreateExecutionEngine(OutEE:pLLVMExecutionEngineRef; MP:LLVMModuleProviderRef; OutError:Ppchar):longint;cdecl;external libname name 'LLVMCreateExecutionEngine'; +function LLVMCreateInterpreter(OutInterp:pLLVMExecutionEngineRef; MP:LLVMModuleProviderRef; OutError:Ppchar):longint;cdecl;external libname name 'LLVMCreateInterpreter'; +function LLVMCreateJITCompiler(OutJIT:pLLVMExecutionEngineRef; MP:LLVMModuleProviderRef; OptLevel:dword; OutError:Ppchar):longint;cdecl;external libname name 'LLVMCreateJITCompiler'; +procedure LLVMDisposeExecutionEngine(EE:LLVMExecutionEngineRef);cdecl;external libname name 'LLVMDisposeExecutionEngine'; +procedure LLVMRunStaticConstructors(EE:LLVMExecutionEngineRef);cdecl;external libname name 'LLVMRunStaticConstructors'; +procedure LLVMRunStaticDestructors(EE:LLVMExecutionEngineRef);cdecl;external libname name 'LLVMRunStaticDestructors'; +(* Const before declarator ignored *) +(* Const before declarator ignored *) +function LLVMRunFunctionAsMain(EE:LLVMExecutionEngineRef; F:LLVMValueRef; ArgC:dword; ArgV:Ppchar; EnvP:Ppchar):longint;cdecl;external libname name 'LLVMRunFunctionAsMain'; +function LLVMRunFunction(EE:LLVMExecutionEngineRef; F:LLVMValueRef; NumArgs:dword; Args:pLLVMGenericValueRef):LLVMGenericValueRef;cdecl;external libname name 'LLVMRunFunction'; +procedure LLVMFreeMachineCodeForFunction(EE:LLVMExecutionEngineRef; F:LLVMValueRef);cdecl;external libname name 'LLVMFreeMachineCodeForFunction'; +procedure LLVMAddModuleProvider(EE:LLVMExecutionEngineRef; MP:LLVMModuleProviderRef);cdecl;external libname name 'LLVMAddModuleProvider'; +function LLVMRemoveModuleProvider(EE:LLVMExecutionEngineRef; MP:LLVMModuleProviderRef; OutMod:pLLVMModuleRef; OutError:Ppchar):longint;cdecl;external libname name 'LLVMRemoveModuleProvider'; +function LLVMFindFunction(EE:LLVMExecutionEngineRef; Name:pchar; OutFn:pLLVMValueRef):longint;cdecl;external libname name 'LLVMFindFunction'; +function LLVMGetExecutionEngineTargetData(EE:LLVMExecutionEngineRef):LLVMTargetDataRef;cdecl;external libname name 'LLVMGetExecutionEngineTargetData'; +procedure LLVMAddGlobalMapping(EE:LLVMExecutionEngineRef; Global:LLVMValueRef; Addr:pointer);cdecl;external libname name 'LLVMAddGlobalMapping'; +function LLVMGetPointerToGlobal(EE:LLVMExecutionEngineRef; Global:LLVMValueRef):pointer;cdecl;external libname name 'LLVMGetPointerToGlobal'; +{ LinkTimeOptimizer.h } +{/ This provides a dummy type for pointers to the LTO object. } +type + + llvm_lto_t = pointer; +{/ This provides a C-visible enumerator to manage status codes. } +{/ This should map exactly onto the C++ enumerator LTOStatus. } +{ Added C-specific error codes } + + llvm_lto_status = (LLVM_LTO_UNKNOWN,LLVM_LTO_OPT_SUCCESS, + LLVM_LTO_READ_SUCCESS,LLVM_LTO_READ_FAILURE, + LLVM_LTO_WRITE_FAILURE,LLVM_LTO_NO_TARGET, + LLVM_LTO_NO_WORK,LLVM_LTO_MODULE_MERGE_FAILURE, + LLVM_LTO_ASM_FAILURE,LLVM_LTO_NULL_OBJECT + ); + llvm_lto_status_t = llvm_lto_status; +{/ This provides C interface to initialize link time optimizer. This allows } +{/ linker to use dlopen() interface to dynamically load LinkTimeOptimizer. } +{/ extern "C" helps, because dlopen() interface uses name to find the symbol. } + +function llvm_create_optimizer:llvm_lto_t;cdecl;external libname name 'llvm_create_optimizer'; +procedure llvm_destroy_optimizer(lto:llvm_lto_t);cdecl;external libname name 'llvm_destroy_optimizer'; +function llvm_read_object_file(lto:llvm_lto_t; input_filename:pchar):llvm_lto_status_t;cdecl;external libname name 'llvm_read_object_file'; +function llvm_optimize_modules(lto:llvm_lto_t; output_filename:pchar):llvm_lto_status_t;cdecl;external libname name 'llvm_optimize_modules'; +{ lto.h } + +const + LTO_API_VERSION = 3; +{ log2 of alignment } +type + + lto_symbol_attributes = (LTO_SYMBOL_ALIGNMENT_MASK := $0000001F,LTO_SYMBOL_PERMISSIONS_MASK := $000000E0, + LTO_SYMBOL_PERMISSIONS_CODE := $000000A0,LTO_SYMBOL_PERMISSIONS_DATA := $000000C0, + LTO_SYMBOL_PERMISSIONS_RODATA := $00000080,LTO_SYMBOL_DEFINITION_MASK := $00000700, + LTO_SYMBOL_DEFINITION_REGULAR := $00000100,LTO_SYMBOL_DEFINITION_TENTATIVE := $00000200, + LTO_SYMBOL_DEFINITION_WEAK := $00000300,LTO_SYMBOL_DEFINITION_UNDEFINED := $00000400, + LTO_SYMBOL_DEFINITION_WEAKUNDEF := $00000500, + LTO_SYMBOL_SCOPE_MASK := $00003800,LTO_SYMBOL_SCOPE_INTERNAL := $00000800, + LTO_SYMBOL_SCOPE_HIDDEN := $00001000,LTO_SYMBOL_SCOPE_PROTECTED := $00002000, + LTO_SYMBOL_SCOPE_DEFAULT := $00001800); + + lto_debug_model = (LTO_DEBUG_MODEL_NONE := 0,LTO_DEBUG_MODEL_DWARF := 1 + ); + + lto_codegen_model = (LTO_CODEGEN_PIC_MODEL_STATIC := 0,LTO_CODEGEN_PIC_MODEL_DYNAMIC := 1, + LTO_CODEGEN_PIC_MODEL_DYNAMIC_NO_PIC := 2 + ); +{* opaque reference to a loaded object module } + + lto_module_t = LTOModule; +{* opaque reference to a code generator } + + lto_code_gen_t = LTOCodeGenerator; +{* + * Returns a printable string. + } + +function lto_get_version:pchar;cdecl;external libname name 'lto_get_version'; +{* + * Returns the last error string or NULL if last operation was sucessful. + } +function lto_get_error_message:pchar;cdecl;external libname name 'lto_get_error_message'; +{* + * Checks if a file is a loadable object file. + } +function lto_module_is_object_file(path:pchar):bool;cdecl;external libname name 'lto_module_is_object_file'; +{* + * Checks if a file is a loadable object compiled for requested target. + } +function lto_module_is_object_file_for_target(path:pchar; target_triple_prefix:pchar):bool;cdecl;external libname name 'lto_module_is_object_file_for_target'; +{* + * Checks if a buffer is a loadable object file. + } +function lto_module_is_object_file_in_memory(mem:pointer; length:size_t):bool;cdecl;external libname name 'lto_module_is_object_file_in_memory'; +{* + * Checks if a buffer is a loadable object compiled for requested target. + } +function lto_module_is_object_file_in_memory_for_target(mem:pointer; length:size_t; target_triple_prefix:pchar):bool;cdecl;external libname name 'lto_module_is_object_file_in_memory_for_target'; +{* + * Loads an object file from disk. + * Returns NULL on error (check lto_get_error_message() for details). + } +function lto_module_create(path:pchar):lto_module_t;cdecl;external libname name 'lto_module_create'; +{* + * Loads an object file from memory. + * Returns NULL on error (check lto_get_error_message() for details). + } +function lto_module_create_from_memory(mem:pointer; length:size_t):lto_module_t;cdecl;external libname name 'lto_module_create_from_memory'; +{* + * Frees all memory internally allocated by the module. + * Upon return the lto_module_t is no longer valid. + } +procedure lto_module_dispose(module:lto_module_t);cdecl;external libname name 'lto_module_dispose'; +{* + * Returns triple string which the object module was compiled under. + } +function lto_module_get_target_triple(module:lto_module_t):pchar;cdecl;external libname name 'lto_module_get_target_triple'; +{* + * Returns the number of symbols in the object module. + } +function lto_module_get_num_symbols(module:lto_module_t):dword;cdecl;external libname name 'lto_module_get_num_symbols'; +{* + * Returns the name of the ith symbol in the object module. + } +function lto_module_get_symbol_name(module:lto_module_t; index:dword):pchar;cdecl;external libname name 'lto_module_get_symbol_name'; +{* + * Returns the attributes of the ith symbol in the object module. + } +function lto_module_get_symbol_attribute(module:lto_module_t; index:dword):lto_symbol_attributes;cdecl;external libname name 'lto_module_get_symbol_attribute'; +{* + * Instantiates a code generator. + * Returns NULL on error (check lto_get_error_message() for details). + } +function lto_codegen_create:lto_code_gen_t;cdecl;external libname name 'lto_codegen_create'; +{* + * Frees all code generator and all memory it internally allocated. + * Upon return the lto_code_gen_t is no longer valid. + } +procedure lto_codegen_dispose(para1:lto_code_gen_t);cdecl;external libname name 'lto_codegen_dispose'; +{* + * Add an object module to the set of modules for which code will be generated. + * Returns true on error (check lto_get_error_message() for details). + } +function lto_codegen_add_module(cg:lto_code_gen_t; module:lto_module_t):bool;cdecl;external libname name 'lto_codegen_add_module'; +{* + * Sets if debug info should be generated. + * Returns true on error (check lto_get_error_message() for details). + } +function lto_codegen_set_debug_model(cg:lto_code_gen_t; para2:lto_debug_model):bool;cdecl;external libname name 'lto_codegen_set_debug_model'; +{* + * Sets which PIC code model to generated. + * Returns true on error (check lto_get_error_message() for details). + } +function lto_codegen_set_pic_model(cg:lto_code_gen_t; + para2: lto_codegen_model): bool; +cdecl;external libname name 'lto_codegen_set_pic_model'; +{* + * Sets the location of the "gcc" to run. If not set, libLTO will search for + * "gcc" on the path. + } +procedure lto_codegen_set_gcc_path(cg:lto_code_gen_t; path:pchar); +cdecl;external libname name 'lto_codegen_set_gcc_path'; +{* + * Sets the location of the assembler tool to run. If not set, libLTO + * will use gcc to invoke the assembler. + } +procedure lto_codegen_set_assembler_path(cg:lto_code_gen_t; path:pchar); +cdecl;external libname name 'lto_codegen_set_assembler_path'; +{* + * Adds to a list of all global symbols that must exist in the final + * generated code. If a function is not listed, it might be + * inlined into every usage and optimized away. + } +procedure lto_codegen_add_must_preserve_symbol(cg:lto_code_gen_t; symbol:pchar); +cdecl;external libname name 'lto_codegen_add_must_preserve_symbol'; +{* + * Writes a new object file at the specified path that contains the + * merged contents of all modules added so far. + * Returns true on error (check lto_get_error_message() for details). + } +function lto_codegen_write_merged_modules(cg:lto_code_gen_t; path:pchar):bool; +cdecl;external libname name 'lto_codegen_write_merged_modules'; +{* + * Generates code for all added modules into one native object file. + * On sucess returns a pointer to a generated mach-o/ELF buffer and + * length set to the buffer size. The buffer is owned by the + * lto_code_gen_t and will be freed when lto_codegen_dispose() + * is called, or lto_codegen_compile() is called again. + * On failure, returns NULL (check lto_get_error_message() for details). + } +function lto_codegen_compile(cg:lto_code_gen_t; var length: int): pointer; +cdecl; external libname name 'lto_codegen_compile'; +{* + * Sets options to help debug codegen bugs. + } +procedure lto_codegen_debug_options(cg: lto_code_gen_t; para2: Pchar); +cdecl;external libname name 'lto_codegen_debug_options'; + +implementation + +end. diff --git a/llvm/llvm_orig.nim b/llvm/llvm_orig.nim new file mode 100644 index 000000000..8e09f9c68 --- /dev/null +++ b/llvm/llvm_orig.nim @@ -0,0 +1,1569 @@ + +const + libname* = "" #Setup as you need + +type + PLLVMBasicBlockRef* = ptr LLVMBasicBlockRef + PLLVMExecutionEngineRef* = ptr LLVMExecutionEngineRef + PLLVMGenericValueRef* = ptr LLVMGenericValueRef + PLLVMMemoryBufferRef* = ptr LLVMMemoryBufferRef + PLLVMModuleProviderRef* = ptr LLVMModuleProviderRef + PLLVMModuleRef* = ptr LLVMModuleRef + PLLVMTypeRef* = ptr LLVMTypeRef + PLLVMValueRef* = ptr LLVMValueRef # Core.h + # Opaque types. + #* + # * The top-level container for all LLVM global data. See the LLVMContext class. + # + +type + LLVMContextRef* = LLVMOpaqueContext #* + # * The top-level container for all other LLVM Intermediate Representation (IR) + # * objects. See the llvm::Module class. + # + LLVMModuleRef* = LLVMOpaqueModule #* + # * Each value in the LLVM IR has a type, an LLVMTypeRef. See the llvm::Type + # * class. + # + LLVMTypeRef* = LLVMOpaqueType #* + # * When building recursive types using LLVMRefineType, LLVMTypeRef values may + # * become invalid; use LLVMTypeHandleRef to resolve this problem. See the + # * llvm::AbstractTypeHolder class. + # + LLVMTypeHandleRef* = LLVMOpaqueTypeHandle + LLVMValueRef* = LLVMOpaqueValue + LLVMBasicBlockRef* = LLVMOpaqueBasicBlock + LLVMBuilderRef* = LLVMOpaqueBuilder # Used to provide a module to JIT or interpreter. + # * See the llvm::ModuleProvider class. + # + LLVMModuleProviderRef* = LLVMOpaqueModuleProvider # Used to provide a module to JIT or interpreter. + # * See the llvm::MemoryBuffer class. + # + LLVMMemoryBufferRef* = LLVMOpaqueMemoryBuffer #* See the llvm::PassManagerBase class. + LLVMPassManagerRef* = LLVMOpaquePassManager #* + # * Used to iterate through the uses of a Value, allowing access to all Values + # * that use this Value. See the llvm::Use and llvm::value_use_iterator classes. + # + LLVMUseIteratorRef* = LLVMOpaqueUseIterator + LLVMAttribute* = enum + LLVMZExtAttribute = 1 shl 0, LLVMSExtAttribute = 1 shl 1, + LLVMNoReturnAttribute = 1 shl 2, LLVMInRegAttribute = 1 shl 3, + LLVMStructRetAttribute = 1 shl 4, LLVMNoUnwindAttribute = 1 shl 5, + LLVMNoAliasAttribute = 1 shl 6, LLVMByValAttribute = 1 shl 7, + LLVMNestAttribute = 1 shl 8, LLVMReadNoneAttribute = 1 shl 9, + LLVMReadOnlyAttribute = 1 shl 10, LLVMNoInlineAttribute = 1 shl 11, + LLVMAlwaysInlineAttribute = 1 shl 12, + LLVMOptimizeForSizeAttribute = 1 shl 13, + LLVMStackProtectAttribute = 1 shl 14, + LLVMStackProtectReqAttribute = 1 shl 15, LLVMNoCaptureAttribute = 1 shl + 21, LLVMNoRedZoneAttribute = 1 shl 22, + LLVMNoImplicitFloatAttribute = 1 shl 23, LLVMNakedAttribute = 1 shl 24, + LLVMInlineHintAttribute = 1 shl 25 + LLVMOpcode* = enum #*< type with no size + #*< 32 bit floating point type + #*< 64 bit floating point type + #*< 80 bit floating point type (X87) + #*< 128 bit floating point type (112-bit mantissa) + #*< 128 bit floating point type (two 64-bits) + #*< Labels + #*< Arbitrary bit width integers + #*< Functions + #*< Structures + #*< Arrays + #*< Pointers + #*< Opaque: type with unknown structure + #*< SIMD 'packed' format, or other vector type + #*< Metadata + LLVMRet = 1, LLVMBr = 2, LLVMSwitch = 3, LLVMInvoke = 4, LLVMUnwind = 5, + LLVMUnreachable = 6, LLVMAdd = 7, LLVMFAdd = 8, LLVMSub = 9, LLVMFSub = 10, + LLVMMul = 11, LLVMFMul = 12, LLVMUDiv = 13, LLVMSDiv = 14, LLVMFDiv = 15, + LLVMURem = 16, LLVMSRem = 17, LLVMFRem = 18, LLVMShl = 19, LLVMLShr = 20, + LLVMAShr = 21, LLVMAnd = 22, LLVMOr = 23, LLVMXor = 24, LLVMMalloc = 25, + LLVMFree = 26, LLVMAlloca = 27, LLVMLoad = 28, LLVMStore = 29, + LLVMGetElementPtr = 30, LLVMTrunk = 31, LLVMZExt = 32, LLVMSExt = 33, + LLVMFPToUI = 34, LLVMFPToSI = 35, LLVMUIToFP = 36, LLVMSIToFP = 37, + LLVMFPTrunc = 38, LLVMFPExt = 39, LLVMPtrToInt = 40, LLVMIntToPtr = 41, + LLVMBitCast = 42, LLVMICmp = 43, LLVMFCmp = 44, LLVMPHI = 45, LLVMCall = 46, + LLVMSelect = 47, LLVMVAArg = 50, LLVMExtractElement = 51, + LLVMInsertElement = 52, LLVMShuffleVector = 53, LLVMExtractValue = 54, + LLVMInsertValue = 55 + LLVMTypeKind* = enum #*< Externally visible function + #*< Keep one copy of function when linking (inline) + #*< Same, but only replaced by something + # equivalent. + #*< Keep one copy of function when linking (weak) + #*< Same, but only replaced by something + # equivalent. + #*< Special purpose, only applies to global arrays + #*< Rename collisions when linking (static + # functions) + #*< Like Internal, but omit from symbol table + #*< Function to be imported from DLL + #*< Function to be accessible from DLL + #*< ExternalWeak linkage description + #*< Stand-in functions for streaming fns from + # bitcode + #*< Tentative definitions + #*< Like Private, but linker removes. + LLVMVoidTypeKind, LLVMFloatTypeKind, LLVMDoubleTypeKind, + LLVMX86_FP80TypeKind, LLVMFP128TypeKind, LLVMPPC_FP128TypeKind, + LLVMLabelTypeKind, LLVMIntegerTypeKind, LLVMFunctionTypeKind, + LLVMStructTypeKind, LLVMArrayTypeKind, LLVMPointerTypeKind, + LLVMOpaqueTypeKind, LLVMVectorTypeKind, LLVMMetadataTypeKind + LLVMLinkage* = enum #*< The GV is visible + #*< The GV is hidden + #*< The GV is protected + LLVMExternalLinkage, LLVMAvailableExternallyLinkage, LLVMLinkOnceAnyLinkage, + LLVMLinkOnceODRLinkage, LLVMWeakAnyLinkage, LLVMWeakODRLinkage, + LLVMAppendingLinkage, LLVMInternalLinkage, LLVMPrivateLinkage, + LLVMDLLImportLinkage, LLVMDLLExportLinkage, LLVMExternalWeakLinkage, + LLVMGhostLinkage, LLVMCommonLinkage, LLVMLinkerPrivateLinkage + LLVMVisibility* = enum + LLVMDefaultVisibility, LLVMHiddenVisibility, LLVMProtectedVisibility + LLVMCallConv* = enum #*< equal + #*< not equal + #*< unsigned greater than + #*< unsigned greater or equal + #*< unsigned less than + #*< unsigned less or equal + #*< signed greater than + #*< signed greater or equal + #*< signed less than + #*< signed less or equal + LLVMCCallConv = 0, LLVMFastCallConv = 8, LLVMColdCallConv = 9, + LLVMX86StdcallCallConv = 64, LLVMX86FastcallCallConv = 65 + LLVMIntPredicate* = enum #*< Always false (always folded) + #*< True if ordered and equal + #*< True if ordered and greater than + #*< True if ordered and greater than or equal + #*< True if ordered and less than + #*< True if ordered and less than or equal + #*< True if ordered and operands are unequal + #*< True if ordered (no nans) + #*< True if unordered: isnan(X) | isnan(Y) + #*< True if unordered or equal + #*< True if unordered or greater than + #*< True if unordered, greater than, or equal + #*< True if unordered or less than + #*< True if unordered, less than, or equal + #*< True if unordered or not equal + #*< Always true (always folded) + LLVMIntEQ = 32, LLVMIntNE, LLVMIntUGT, LLVMIntUGE, LLVMIntULT, LLVMIntULE, + LLVMIntSGT, LLVMIntSGE, LLVMIntSLT, LLVMIntSLE + LLVMRealPredicate* = enum #===-- Error handling ----------------------------------------------------=== + LLVMRealPredicateFalse, LLVMRealOEQ, LLVMRealOGT, LLVMRealOGE, LLVMRealOLT, + LLVMRealOLE, LLVMRealONE, LLVMRealORD, LLVMRealUNO, LLVMRealUEQ, + LLVMRealUGT, LLVMRealUGE, LLVMRealULT, LLVMRealULE, LLVMRealUNE, + LLVMRealPredicateTrue + +proc LLVMDisposeMessage*(Message: cstring){.cdecl, dynlib: libname, + importc: "LLVMDisposeMessage".} + #===-- Modules -----------------------------------------------------------=== + # Create and destroy contexts. +proc LLVMContextCreate*(): LLVMContextRef{.cdecl, dynlib: libname, + importc: "LLVMContextCreate".} +proc LLVMGetGlobalContext*(): LLVMContextRef{.cdecl, dynlib: libname, + importc: "LLVMGetGlobalContext".} +proc LLVMContextDispose*(C: LLVMContextRef){.cdecl, dynlib: libname, + importc: "LLVMContextDispose".} + # Create and destroy modules. + #* See llvm::Module::Module. +proc LLVMModuleCreateWithName*(ModuleID: cstring): LLVMModuleRef{.cdecl, + dynlib: libname, importc: "LLVMModuleCreateWithName".} +proc LLVMModuleCreateWithNameInContext*(ModuleID: cstring, C: LLVMContextRef): LLVMModuleRef{. + cdecl, dynlib: libname, importc: "LLVMModuleCreateWithNameInContext".} + #* See llvm::Module::~Module. +proc LLVMDisposeModule*(M: LLVMModuleRef){.cdecl, dynlib: libname, + importc: "LLVMDisposeModule".} + #* Data layout. See Module::getDataLayout. +proc LLVMGetDataLayout*(M: LLVMModuleRef): cstring{.cdecl, dynlib: libname, + importc: "LLVMGetDataLayout".} +proc LLVMSetDataLayout*(M: LLVMModuleRef, Triple: cstring){.cdecl, + dynlib: libname, importc: "LLVMSetDataLayout".} + #* Target triple. See Module::getTargetTriple. +proc LLVMGetTarget*(M: LLVMModuleRef): cstring{.cdecl, dynlib: libname, + importc: "LLVMGetTarget".} +proc LLVMSetTarget*(M: LLVMModuleRef, Triple: cstring){.cdecl, dynlib: libname, + importc: "LLVMSetTarget".} + #* See Module::addTypeName. +proc LLVMAddTypeName*(M: LLVMModuleRef, Name: cstring, Ty: LLVMTypeRef): int32{. + cdecl, dynlib: libname, importc: "LLVMAddTypeName".} +proc LLVMDeleteTypeName*(M: LLVMModuleRef, Name: cstring){.cdecl, + dynlib: libname, importc: "LLVMDeleteTypeName".} +proc LLVMGetTypeByName*(M: LLVMModuleRef, Name: cstring): LLVMTypeRef{.cdecl, + dynlib: libname, importc: "LLVMGetTypeByName".} + #* See Module::dump. +proc LLVMDumpModule*(M: LLVMModuleRef){.cdecl, dynlib: libname, + importc: "LLVMDumpModule".} + #===-- 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. +proc LLVMGetTypeKind*(Ty: LLVMTypeRef): LLVMTypeKind{.cdecl, dynlib: libname, + importc: "LLVMGetTypeKind".} + #* See llvm::LLVMType::getContext. +proc LLVMGetTypeContext*(Ty: LLVMTypeRef): LLVMContextRef{.cdecl, + dynlib: libname, importc: "LLVMGetTypeContext".} + # Operations on integer types +proc LLVMInt1TypeInContext*(C: LLVMContextRef): LLVMTypeRef{.cdecl, + dynlib: libname, importc: "LLVMInt1TypeInContext".} +proc LLVMInt8TypeInContext*(C: LLVMContextRef): LLVMTypeRef{.cdecl, + dynlib: libname, importc: "LLVMInt8TypeInContext".} +proc LLVMInt16TypeInContext*(C: LLVMContextRef): LLVMTypeRef{.cdecl, + dynlib: libname, importc: "LLVMInt16TypeInContext".} +proc LLVMInt32TypeInContext*(C: LLVMContextRef): LLVMTypeRef{.cdecl, + dynlib: libname, importc: "LLVMInt32TypeInContext".} +proc LLVMInt64TypeInContext*(C: LLVMContextRef): LLVMTypeRef{.cdecl, + dynlib: libname, importc: "LLVMInt64TypeInContext".} +proc LLVMIntTypeInContext*(C: LLVMContextRef, NumBits: dword): LLVMTypeRef{. + cdecl, dynlib: libname, importc: "LLVMIntTypeInContext".} +proc LLVMInt1Type*(): LLVMTypeRef{.cdecl, dynlib: libname, + importc: "LLVMInt1Type".} +proc LLVMInt8Type*(): LLVMTypeRef{.cdecl, dynlib: libname, + importc: "LLVMInt8Type".} +proc LLVMInt16Type*(): LLVMTypeRef{.cdecl, dynlib: libname, + importc: "LLVMInt16Type".} +proc LLVMInt32Type*(): LLVMTypeRef{.cdecl, dynlib: libname, + importc: "LLVMInt32Type".} +proc LLVMInt64Type*(): LLVMTypeRef{.cdecl, dynlib: libname, + importc: "LLVMInt64Type".} +proc LLVMIntType*(NumBits: dword): LLVMTypeRef{.cdecl, dynlib: libname, + importc: "LLVMIntType".} +proc LLVMGetIntTypeWidth*(IntegerTy: LLVMTypeRef): dword{.cdecl, + dynlib: libname, importc: "LLVMGetIntTypeWidth".} + # Operations on real types +proc LLVMFloatTypeInContext*(C: LLVMContextRef): LLVMTypeRef{.cdecl, + dynlib: libname, importc: "LLVMFloatTypeInContext".} +proc LLVMDoubleTypeInContext*(C: LLVMContextRef): LLVMTypeRef{.cdecl, + dynlib: libname, importc: "LLVMDoubleTypeInContext".} +proc LLVMX86FP80TypeInContext*(C: LLVMContextRef): LLVMTypeRef{.cdecl, + dynlib: libname, importc: "LLVMX86FP80TypeInContext".} +proc LLVMFP128TypeInContext*(C: LLVMContextRef): LLVMTypeRef{.cdecl, + dynlib: libname, importc: "LLVMFP128TypeInContext".} +proc LLVMPPCFP128TypeInContext*(C: LLVMContextRef): LLVMTypeRef{.cdecl, + dynlib: libname, importc: "LLVMPPCFP128TypeInContext".} +proc LLVMFloatType*(): LLVMTypeRef{.cdecl, dynlib: libname, + importc: "LLVMFloatType".} +proc LLVMDoubleType*(): LLVMTypeRef{.cdecl, dynlib: libname, + importc: "LLVMDoubleType".} +proc LLVMX86FP80Type*(): LLVMTypeRef{.cdecl, dynlib: libname, + importc: "LLVMX86FP80Type".} +proc LLVMFP128Type*(): LLVMTypeRef{.cdecl, dynlib: libname, + importc: "LLVMFP128Type".} +proc LLVMPPCFP128Type*(): LLVMTypeRef{.cdecl, dynlib: libname, + importc: "LLVMPPCFP128Type".} + # Operations on function types +proc LLVMFunctionType*(ReturnType: LLVMTypeRef, ParamTypes: pLLVMTypeRef, + ParamCount: dword, IsVarArg: int32): LLVMTypeRef{.cdecl, + dynlib: libname, importc: "LLVMFunctionType".} +proc LLVMIsFunctionVarArg*(FunctionTy: LLVMTypeRef): int32{.cdecl, + dynlib: libname, importc: "LLVMIsFunctionVarArg".} +proc LLVMGetReturnType*(FunctionTy: LLVMTypeRef): LLVMTypeRef{.cdecl, + dynlib: libname, importc: "LLVMGetReturnType".} +proc LLVMCountParamTypes*(FunctionTy: LLVMTypeRef): dword{.cdecl, + dynlib: libname, importc: "LLVMCountParamTypes".} +proc LLVMGetParamTypes*(FunctionTy: LLVMTypeRef, Dest: pLLVMTypeRef){.cdecl, + dynlib: libname, importc: "LLVMGetParamTypes".} + # Operations on struct types +proc LLVMStructTypeInContext*(C: LLVMContextRef, ElementTypes: pLLVMTypeRef, + ElementCount: dword, isPacked: int32): LLVMTypeRef{. + cdecl, dynlib: libname, importc: "LLVMStructTypeInContext".} +proc LLVMStructType*(ElementTypes: pLLVMTypeRef, ElementCount: dword, + isPacked: int32): LLVMTypeRef{.cdecl, dynlib: libname, + importc: "LLVMStructType".} +proc LLVMCountStructElementTypes*(StructTy: LLVMTypeRef): dword{.cdecl, + dynlib: libname, importc: "LLVMCountStructElementTypes".} +proc LLVMGetStructElementTypes*(StructTy: LLVMTypeRef, Dest: pLLVMTypeRef){. + cdecl, dynlib: libname, importc: "LLVMGetStructElementTypes".} +proc LLVMIsPackedStruct*(StructTy: LLVMTypeRef): int32{.cdecl, dynlib: libname, + importc: "LLVMIsPackedStruct".} + # Operations on array, pointer, and vector types (sequence types) +proc LLVMArrayType*(ElementType: LLVMTypeRef, ElementCount: dword): LLVMTypeRef{. + cdecl, dynlib: libname, importc: "LLVMArrayType".} +proc LLVMPointerType*(ElementType: LLVMTypeRef, AddressSpace: dword): LLVMTypeRef{. + cdecl, dynlib: libname, importc: "LLVMPointerType".} +proc LLVMVectorType*(ElementType: LLVMTypeRef, ElementCount: dword): LLVMTypeRef{. + cdecl, dynlib: libname, importc: "LLVMVectorType".} +proc LLVMGetElementType*(Ty: LLVMTypeRef): LLVMTypeRef{.cdecl, dynlib: libname, + importc: "LLVMGetElementType".} +proc LLVMGetArrayLength*(ArrayTy: LLVMTypeRef): dword{.cdecl, dynlib: libname, + importc: "LLVMGetArrayLength".} +proc LLVMGetPointerAddressSpace*(PointerTy: LLVMTypeRef): dword{.cdecl, + dynlib: libname, importc: "LLVMGetPointerAddressSpace".} +proc LLVMGetVectorSize*(VectorTy: LLVMTypeRef): dword{.cdecl, dynlib: libname, + importc: "LLVMGetVectorSize".} + # Operations on other types +proc LLVMVoidTypeInContext*(C: LLVMContextRef): LLVMTypeRef{.cdecl, + dynlib: libname, importc: "LLVMVoidTypeInContext".} +proc LLVMLabelTypeInContext*(C: LLVMContextRef): LLVMTypeRef{.cdecl, + dynlib: libname, importc: "LLVMLabelTypeInContext".} +proc LLVMOpaqueTypeInContext*(C: LLVMContextRef): LLVMTypeRef{.cdecl, + dynlib: libname, importc: "LLVMOpaqueTypeInContext".} +proc LLVMVoidType*(): LLVMTypeRef{.cdecl, dynlib: libname, + importc: "LLVMVoidType".} +proc LLVMLabelType*(): LLVMTypeRef{.cdecl, dynlib: libname, + importc: "LLVMLabelType".} +proc LLVMOpaqueType*(): LLVMTypeRef{.cdecl, dynlib: libname, + importc: "LLVMOpaqueType".} + # Operations on type handles +proc LLVMCreateTypeHandle*(PotentiallyAbstractTy: LLVMTypeRef): LLVMTypeHandleRef{. + cdecl, dynlib: libname, importc: "LLVMCreateTypeHandle".} +proc LLVMRefineType*(AbstractTy: LLVMTypeRef, ConcreteTy: LLVMTypeRef){.cdecl, + dynlib: libname, importc: "LLVMRefineType".} +proc LLVMResolveTypeHandle*(TypeHandle: LLVMTypeHandleRef): LLVMTypeRef{.cdecl, + dynlib: libname, importc: "LLVMResolveTypeHandle".} +proc LLVMDisposeTypeHandle*(TypeHandle: LLVMTypeHandleRef){.cdecl, + dynlib: libname, importc: "LLVMDisposeTypeHandle".} + # Operations on all values +proc LLVMTypeOf*(Val: LLVMValueRef): LLVMTypeRef{.cdecl, dynlib: libname, + importc: "LLVMTypeOf".} +proc LLVMGetValueName*(Val: LLVMValueRef): cstring{.cdecl, dynlib: libname, + importc: "LLVMGetValueName".} +proc LLVMSetValueName*(Val: LLVMValueRef, Name: cstring){.cdecl, + dynlib: libname, importc: "LLVMSetValueName".} +proc LLVMDumpValue*(Val: LLVMValueRef){.cdecl, dynlib: libname, + importc: "LLVMDumpValue".} +proc LLVMReplaceAllUsesWith*(OldVal: LLVMValueRef, NewVal: LLVMValueRef){.cdecl, + dynlib: libname, importc: "LLVMReplaceAllUsesWith".} + # Conversion functions. Return the input value if it is an instance of the + # specified class, otherwise NULL. See llvm::dyn_cast_or_null<>. +proc LLVMIsAArgument*(Val: LLVMValueRef): LLVMValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsAArgument".} +proc LLVMIsABasicBlock*(Val: LLVMValueRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMIsABasicBlock".} +proc LLVMIsAInlineAsm*(Val: LLVMValueRef): LLVMValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsAInlineAsm".} +proc LLVMIsAUser*(Val: LLVMValueRef): LLVMValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsAUser".} +proc LLVMIsAConstant*(Val: LLVMValueRef): LLVMValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsAConstant".} +proc LLVMIsAConstantAggregateZero*(Val: LLVMValueRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMIsAConstantAggregateZero".} +proc LLVMIsAConstantArray*(Val: LLVMValueRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMIsAConstantArray".} +proc LLVMIsAConstantExpr*(Val: LLVMValueRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMIsAConstantExpr".} +proc LLVMIsAConstantFP*(Val: LLVMValueRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMIsAConstantFP".} +proc LLVMIsAConstantInt*(Val: LLVMValueRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMIsAConstantInt".} +proc LLVMIsAConstantPointerNull*(Val: LLVMValueRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMIsAConstantPointerNull".} +proc LLVMIsAConstantStruct*(Val: LLVMValueRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMIsAConstantStruct".} +proc LLVMIsAConstantVector*(Val: LLVMValueRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMIsAConstantVector".} +proc LLVMIsAGlobalValue*(Val: LLVMValueRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMIsAGlobalValue".} +proc LLVMIsAFunction*(Val: LLVMValueRef): LLVMValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsAFunction".} +proc LLVMIsAGlobalAlias*(Val: LLVMValueRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMIsAGlobalAlias".} +proc LLVMIsAGlobalVariable*(Val: LLVMValueRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMIsAGlobalVariable".} +proc LLVMIsAUndefValue*(Val: LLVMValueRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMIsAUndefValue".} +proc LLVMIsAInstruction*(Val: LLVMValueRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMIsAInstruction".} +proc LLVMIsABinaryOperator*(Val: LLVMValueRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMIsABinaryOperator".} +proc LLVMIsACallInst*(Val: LLVMValueRef): LLVMValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsACallInst".} +proc LLVMIsAIntrinsicInst*(Val: LLVMValueRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMIsAIntrinsicInst".} +proc LLVMIsADbgInfoIntrinsic*(Val: LLVMValueRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMIsADbgInfoIntrinsic".} +proc LLVMIsADbgDeclareInst*(Val: LLVMValueRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMIsADbgDeclareInst".} +proc LLVMIsADbgFuncStartInst*(Val: LLVMValueRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMIsADbgFuncStartInst".} +proc LLVMIsADbgRegionEndInst*(Val: LLVMValueRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMIsADbgRegionEndInst".} +proc LLVMIsADbgRegionStartInst*(Val: LLVMValueRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMIsADbgRegionStartInst".} +proc LLVMIsADbgStopPointInst*(Val: LLVMValueRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMIsADbgStopPointInst".} +proc LLVMIsAEHSelectorInst*(Val: LLVMValueRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMIsAEHSelectorInst".} +proc LLVMIsAMemIntrinsic*(Val: LLVMValueRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMIsAMemIntrinsic".} +proc LLVMIsAMemCpyInst*(Val: LLVMValueRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMIsAMemCpyInst".} +proc LLVMIsAMemMoveInst*(Val: LLVMValueRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMIsAMemMoveInst".} +proc LLVMIsAMemSetInst*(Val: LLVMValueRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMIsAMemSetInst".} +proc LLVMIsACmpInst*(Val: LLVMValueRef): LLVMValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsACmpInst".} +proc LLVMIsAFCmpInst*(Val: LLVMValueRef): LLVMValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsAFCmpInst".} +proc LLVMIsAICmpInst*(Val: LLVMValueRef): LLVMValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsAICmpInst".} +proc LLVMIsAExtractElementInst*(Val: LLVMValueRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMIsAExtractElementInst".} +proc LLVMIsAGetElementPtrInst*(Val: LLVMValueRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMIsAGetElementPtrInst".} +proc LLVMIsAInsertElementInst*(Val: LLVMValueRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMIsAInsertElementInst".} +proc LLVMIsAInsertValueInst*(Val: LLVMValueRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMIsAInsertValueInst".} +proc LLVMIsAPHINode*(Val: LLVMValueRef): LLVMValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsAPHINode".} +proc LLVMIsASelectInst*(Val: LLVMValueRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMIsASelectInst".} +proc LLVMIsAShuffleVectorInst*(Val: LLVMValueRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMIsAShuffleVectorInst".} +proc LLVMIsAStoreInst*(Val: LLVMValueRef): LLVMValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsAStoreInst".} +proc LLVMIsATerminatorInst*(Val: LLVMValueRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMIsATerminatorInst".} +proc LLVMIsABranchInst*(Val: LLVMValueRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMIsABranchInst".} +proc LLVMIsAInvokeInst*(Val: LLVMValueRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMIsAInvokeInst".} +proc LLVMIsAReturnInst*(Val: LLVMValueRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMIsAReturnInst".} +proc LLVMIsASwitchInst*(Val: LLVMValueRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMIsASwitchInst".} +proc LLVMIsAUnreachableInst*(Val: LLVMValueRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMIsAUnreachableInst".} +proc LLVMIsAUnwindInst*(Val: LLVMValueRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMIsAUnwindInst".} +proc LLVMIsAUnaryInstruction*(Val: LLVMValueRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMIsAUnaryInstruction".} +proc LLVMIsAAllocationInst*(Val: LLVMValueRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMIsAAllocationInst".} +proc LLVMIsAAllocaInst*(Val: LLVMValueRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMIsAAllocaInst".} +proc LLVMIsACastInst*(Val: LLVMValueRef): LLVMValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsACastInst".} +proc LLVMIsABitCastInst*(Val: LLVMValueRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMIsABitCastInst".} +proc LLVMIsAFPExtInst*(Val: LLVMValueRef): LLVMValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsAFPExtInst".} +proc LLVMIsAFPToSIInst*(Val: LLVMValueRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMIsAFPToSIInst".} +proc LLVMIsAFPToUIInst*(Val: LLVMValueRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMIsAFPToUIInst".} +proc LLVMIsAFPTruncInst*(Val: LLVMValueRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMIsAFPTruncInst".} +proc LLVMIsAIntToPtrInst*(Val: LLVMValueRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMIsAIntToPtrInst".} +proc LLVMIsAPtrToIntInst*(Val: LLVMValueRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMIsAPtrToIntInst".} +proc LLVMIsASExtInst*(Val: LLVMValueRef): LLVMValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsASExtInst".} +proc LLVMIsASIToFPInst*(Val: LLVMValueRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMIsASIToFPInst".} +proc LLVMIsATruncInst*(Val: LLVMValueRef): LLVMValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsATruncInst".} +proc LLVMIsAUIToFPInst*(Val: LLVMValueRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMIsAUIToFPInst".} +proc LLVMIsAZExtInst*(Val: LLVMValueRef): LLVMValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsAZExtInst".} +proc LLVMIsAExtractValueInst*(Val: LLVMValueRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMIsAExtractValueInst".} +proc LLVMIsAFreeInst*(Val: LLVMValueRef): LLVMValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsAFreeInst".} +proc LLVMIsALoadInst*(Val: LLVMValueRef): LLVMValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsALoadInst".} +proc LLVMIsAVAArgInst*(Val: LLVMValueRef): LLVMValueRef{.cdecl, dynlib: libname, + importc: "LLVMIsAVAArgInst".} + # Operations on Uses +proc LLVMGetFirstUse*(Val: LLVMValueRef): LLVMUseIteratorRef{.cdecl, + dynlib: libname, importc: "LLVMGetFirstUse".} +proc LLVMGetNextUse*(U: LLVMUseIteratorRef): LLVMUseIteratorRef{.cdecl, + dynlib: libname, importc: "LLVMGetNextUse".} +proc LLVMGetUser*(U: LLVMUseIteratorRef): LLVMValueRef{.cdecl, dynlib: libname, + importc: "LLVMGetUser".} +proc LLVMGetUsedValue*(U: LLVMUseIteratorRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMGetUsedValue".} + # Operations on Users +proc LLVMGetOperand*(Val: LLVMValueRef, Index: dword): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMGetOperand".} + # Operations on constants of any type +proc LLVMConstNull*(Ty: LLVMTypeRef): LLVMValueRef{.cdecl, dynlib: libname, + importc: "LLVMConstNull".} + # all zeroes +proc LLVMConstAllOnes*(Ty: LLVMTypeRef): LLVMValueRef{.cdecl, dynlib: libname, + importc: "LLVMConstAllOnes".} + # only for int/vector +proc LLVMGetUndef*(Ty: LLVMTypeRef): LLVMValueRef{.cdecl, dynlib: libname, + importc: "LLVMGetUndef".} +proc LLVMIsConstant*(Val: LLVMValueRef): int32{.cdecl, dynlib: libname, + importc: "LLVMIsConstant".} +proc LLVMIsNull*(Val: LLVMValueRef): int32{.cdecl, dynlib: libname, + importc: "LLVMIsNull".} +proc LLVMIsUndef*(Val: LLVMValueRef): int32{.cdecl, dynlib: libname, + importc: "LLVMIsUndef".} +proc LLVMConstPointerNull*(Ty: LLVMTypeRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMConstPointerNull".} + # Operations on scalar constants +proc LLVMConstInt*(IntTy: LLVMTypeRef, N: qword, SignExtend: int32): LLVMValueRef{. + cdecl, dynlib: libname, importc: "LLVMConstInt".} +proc LLVMConstIntOfString*(IntTy: LLVMTypeRef, Text: cstring, Radix: uint8_t): LLVMValueRef{. + cdecl, dynlib: libname, importc: "LLVMConstIntOfString".} +proc LLVMConstIntOfStringAndSize*(IntTy: LLVMTypeRef, Text: cstring, + SLen: dword, Radix: uint8_t): LLVMValueRef{. + cdecl, dynlib: libname, importc: "LLVMConstIntOfStringAndSize".} +proc LLVMConstReal*(RealTy: LLVMTypeRef, N: float64): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMConstReal".} +proc LLVMConstRealOfString*(RealTy: LLVMTypeRef, Text: cstring): LLVMValueRef{. + cdecl, dynlib: libname, importc: "LLVMConstRealOfString".} +proc LLVMConstRealOfStringAndSize*(RealTy: LLVMTypeRef, Text: cstring, + SLen: dword): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMConstRealOfStringAndSize".} +proc LLVMConstIntGetZExtValue*(ConstantVal: LLVMValueRef): qword{.cdecl, + dynlib: libname, importc: "LLVMConstIntGetZExtValue".} +proc LLVMConstIntGetSExtValue*(ConstantVal: LLVMValueRef): int64{.cdecl, + dynlib: libname, importc: "LLVMConstIntGetSExtValue".} + # Operations on composite constants +proc LLVMConstStringInContext*(C: LLVMContextRef, Str: cstring, len: dword, + DontNullTerminate: int32): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMConstStringInContext".} +proc LLVMConstStructInContext*(C: LLVMContextRef, ConstantVals: pLLVMValueRef, + Count: dword, isPacked: int32): LLVMValueRef{. + cdecl, dynlib: libname, importc: "LLVMConstStructInContext".} +proc LLVMConstString*(Str: cstring, len: dword, DontNullTerminate: int32): LLVMValueRef{. + cdecl, dynlib: libname, importc: "LLVMConstString".} +proc LLVMConstArray*(ElementTy: LLVMTypeRef, ConstantVals: pLLVMValueRef, + len: dword): LLVMValueRef{.cdecl, dynlib: libname, + importc: "LLVMConstArray".} +proc LLVMConstStruct*(ConstantVals: pLLVMValueRef, Count: dword, isPacked: int32): LLVMValueRef{. + cdecl, dynlib: libname, importc: "LLVMConstStruct".} +proc LLVMConstVector*(ScalarConstantVals: pLLVMValueRef, Size: dword): LLVMValueRef{. + cdecl, dynlib: libname, importc: "LLVMConstVector".} + # Constant expressions +proc LLVMGetConstOpcode*(ConstantVal: LLVMValueRef): LLVMOpcode{.cdecl, + dynlib: libname, importc: "LLVMGetConstOpcode".} +proc LLVMAlignOf*(Ty: LLVMTypeRef): LLVMValueRef{.cdecl, dynlib: libname, + importc: "LLVMAlignOf".} +proc LLVMSizeOf*(Ty: LLVMTypeRef): LLVMValueRef{.cdecl, dynlib: libname, + importc: "LLVMSizeOf".} +proc LLVMConstNeg*(ConstantVal: LLVMValueRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMConstNeg".} +proc LLVMConstFNeg*(ConstantVal: LLVMValueRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMConstFNeg".} +proc LLVMConstNot*(ConstantVal: LLVMValueRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMConstNot".} +proc LLVMConstAdd*(LHSConstant: LLVMValueRef, RHSConstant: LLVMValueRef): LLVMValueRef{. + cdecl, dynlib: libname, importc: "LLVMConstAdd".} +proc LLVMConstNSWAdd*(LHSConstant: LLVMValueRef, RHSConstant: LLVMValueRef): LLVMValueRef{. + cdecl, dynlib: libname, importc: "LLVMConstNSWAdd".} +proc LLVMConstFAdd*(LHSConstant: LLVMValueRef, RHSConstant: LLVMValueRef): LLVMValueRef{. + cdecl, dynlib: libname, importc: "LLVMConstFAdd".} +proc LLVMConstSub*(LHSConstant: LLVMValueRef, RHSConstant: LLVMValueRef): LLVMValueRef{. + cdecl, dynlib: libname, importc: "LLVMConstSub".} +proc LLVMConstFSub*(LHSConstant: LLVMValueRef, RHSConstant: LLVMValueRef): LLVMValueRef{. + cdecl, dynlib: libname, importc: "LLVMConstFSub".} +proc LLVMConstMul*(LHSConstant: LLVMValueRef, RHSConstant: LLVMValueRef): LLVMValueRef{. + cdecl, dynlib: libname, importc: "LLVMConstMul".} +proc LLVMConstFMul*(LHSConstant: LLVMValueRef, RHSConstant: LLVMValueRef): LLVMValueRef{. + cdecl, dynlib: libname, importc: "LLVMConstFMul".} +proc LLVMConstUDiv*(LHSConstant: LLVMValueRef, RHSConstant: LLVMValueRef): LLVMValueRef{. + cdecl, dynlib: libname, importc: "LLVMConstUDiv".} +proc LLVMConstSDiv*(LHSConstant: LLVMValueRef, RHSConstant: LLVMValueRef): LLVMValueRef{. + cdecl, dynlib: libname, importc: "LLVMConstSDiv".} +proc LLVMConstExactSDiv*(LHSConstant: LLVMValueRef, RHSConstant: LLVMValueRef): LLVMValueRef{. + cdecl, dynlib: libname, importc: "LLVMConstExactSDiv".} +proc LLVMConstFDiv*(LHSConstant: LLVMValueRef, RHSConstant: LLVMValueRef): LLVMValueRef{. + cdecl, dynlib: libname, importc: "LLVMConstFDiv".} +proc LLVMConstURem*(LHSConstant: LLVMValueRef, RHSConstant: LLVMValueRef): LLVMValueRef{. + cdecl, dynlib: libname, importc: "LLVMConstURem".} +proc LLVMConstSRem*(LHSConstant: LLVMValueRef, RHSConstant: LLVMValueRef): LLVMValueRef{. + cdecl, dynlib: libname, importc: "LLVMConstSRem".} +proc LLVMConstFRem*(LHSConstant: LLVMValueRef, RHSConstant: LLVMValueRef): LLVMValueRef{. + cdecl, dynlib: libname, importc: "LLVMConstFRem".} +proc LLVMConstAnd*(LHSConstant: LLVMValueRef, RHSConstant: LLVMValueRef): LLVMValueRef{. + cdecl, dynlib: libname, importc: "LLVMConstAnd".} +proc LLVMConstOr*(LHSConstant: LLVMValueRef, RHSConstant: LLVMValueRef): LLVMValueRef{. + cdecl, dynlib: libname, importc: "LLVMConstOr".} +proc LLVMConstXor*(LHSConstant: LLVMValueRef, RHSConstant: LLVMValueRef): LLVMValueRef{. + cdecl, dynlib: libname, importc: "LLVMConstXor".} +proc LLVMConstICmp*(Predicate: LLVMIntPredicate, LHSConstant: LLVMValueRef, + RHSConstant: LLVMValueRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMConstICmp".} +proc LLVMConstFCmp*(Predicate: LLVMRealPredicate, LHSConstant: LLVMValueRef, + RHSConstant: LLVMValueRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMConstFCmp".} +proc LLVMConstShl*(LHSConstant: LLVMValueRef, RHSConstant: LLVMValueRef): LLVMValueRef{. + cdecl, dynlib: libname, importc: "LLVMConstShl".} +proc LLVMConstLShr*(LHSConstant: LLVMValueRef, RHSConstant: LLVMValueRef): LLVMValueRef{. + cdecl, dynlib: libname, importc: "LLVMConstLShr".} +proc LLVMConstAShr*(LHSConstant: LLVMValueRef, RHSConstant: LLVMValueRef): LLVMValueRef{. + cdecl, dynlib: libname, importc: "LLVMConstAShr".} +proc LLVMConstGEP*(ConstantVal: LLVMValueRef, ConstantIndices: pLLVMValueRef, + NumIndices: dword): LLVMValueRef{.cdecl, dynlib: libname, + importc: "LLVMConstGEP".} +proc LLVMConstInBoundsGEP*(ConstantVal: LLVMValueRef, + ConstantIndices: pLLVMValueRef, NumIndices: dword): LLVMValueRef{. + cdecl, dynlib: libname, importc: "LLVMConstInBoundsGEP".} +proc LLVMConstTrunc*(ConstantVal: LLVMValueRef, ToType: LLVMTypeRef): LLVMValueRef{. + cdecl, dynlib: libname, importc: "LLVMConstTrunc".} +proc LLVMConstSExt*(ConstantVal: LLVMValueRef, ToType: LLVMTypeRef): LLVMValueRef{. + cdecl, dynlib: libname, importc: "LLVMConstSExt".} +proc LLVMConstZExt*(ConstantVal: LLVMValueRef, ToType: LLVMTypeRef): LLVMValueRef{. + cdecl, dynlib: libname, importc: "LLVMConstZExt".} +proc LLVMConstFPTrunc*(ConstantVal: LLVMValueRef, ToType: LLVMTypeRef): LLVMValueRef{. + cdecl, dynlib: libname, importc: "LLVMConstFPTrunc".} +proc LLVMConstFPExt*(ConstantVal: LLVMValueRef, ToType: LLVMTypeRef): LLVMValueRef{. + cdecl, dynlib: libname, importc: "LLVMConstFPExt".} +proc LLVMConstUIToFP*(ConstantVal: LLVMValueRef, ToType: LLVMTypeRef): LLVMValueRef{. + cdecl, dynlib: libname, importc: "LLVMConstUIToFP".} +proc LLVMConstSIToFP*(ConstantVal: LLVMValueRef, ToType: LLVMTypeRef): LLVMValueRef{. + cdecl, dynlib: libname, importc: "LLVMConstSIToFP".} +proc LLVMConstFPToUI*(ConstantVal: LLVMValueRef, ToType: LLVMTypeRef): LLVMValueRef{. + cdecl, dynlib: libname, importc: "LLVMConstFPToUI".} +proc LLVMConstFPToSI*(ConstantVal: LLVMValueRef, ToType: LLVMTypeRef): LLVMValueRef{. + cdecl, dynlib: libname, importc: "LLVMConstFPToSI".} +proc LLVMConstPtrToInt*(ConstantVal: LLVMValueRef, ToType: LLVMTypeRef): LLVMValueRef{. + cdecl, dynlib: libname, importc: "LLVMConstPtrToInt".} +proc LLVMConstIntToPtr*(ConstantVal: LLVMValueRef, ToType: LLVMTypeRef): LLVMValueRef{. + cdecl, dynlib: libname, importc: "LLVMConstIntToPtr".} +proc LLVMConstBitCast*(ConstantVal: LLVMValueRef, ToType: LLVMTypeRef): LLVMValueRef{. + cdecl, dynlib: libname, importc: "LLVMConstBitCast".} +proc LLVMConstZExtOrBitCast*(ConstantVal: LLVMValueRef, ToType: LLVMTypeRef): LLVMValueRef{. + cdecl, dynlib: libname, importc: "LLVMConstZExtOrBitCast".} +proc LLVMConstSExtOrBitCast*(ConstantVal: LLVMValueRef, ToType: LLVMTypeRef): LLVMValueRef{. + cdecl, dynlib: libname, importc: "LLVMConstSExtOrBitCast".} +proc LLVMConstTruncOrBitCast*(ConstantVal: LLVMValueRef, ToType: LLVMTypeRef): LLVMValueRef{. + cdecl, dynlib: libname, importc: "LLVMConstTruncOrBitCast".} +proc LLVMConstPointerCast*(ConstantVal: LLVMValueRef, ToType: LLVMTypeRef): LLVMValueRef{. + cdecl, dynlib: libname, importc: "LLVMConstPointerCast".} +proc LLVMConstIntCast*(ConstantVal: LLVMValueRef, ToType: LLVMTypeRef, + isSigned: dword): LLVMValueRef{.cdecl, dynlib: libname, + importc: "LLVMConstIntCast".} +proc LLVMConstFPCast*(ConstantVal: LLVMValueRef, ToType: LLVMTypeRef): LLVMValueRef{. + cdecl, dynlib: libname, importc: "LLVMConstFPCast".} +proc LLVMConstSelect*(ConstantCondition: LLVMValueRef, + ConstantIfTrue: LLVMValueRef, + ConstantIfFalse: LLVMValueRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMConstSelect".} +proc LLVMConstExtractElement*(VectorConstant: LLVMValueRef, + IndexConstant: LLVMValueRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMConstExtractElement".} +proc LLVMConstInsertElement*(VectorConstant: LLVMValueRef, + ElementValueConstant: LLVMValueRef, + IndexConstant: LLVMValueRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMConstInsertElement".} +proc LLVMConstShuffleVector*(VectorAConstant: LLVMValueRef, + VectorBConstant: LLVMValueRef, + MaskConstant: LLVMValueRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMConstShuffleVector".} +proc LLVMConstExtractValue*(AggConstant: LLVMValueRef, IdxList: pdword, + NumIdx: dword): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMConstExtractValue".} +proc LLVMConstInsertValue*(AggConstant: LLVMValueRef, + ElementValueConstant: LLVMValueRef, IdxList: pdword, + NumIdx: dword): LLVMValueRef{.cdecl, dynlib: libname, + importc: "LLVMConstInsertValue".} +proc LLVMConstInlineAsm*(Ty: LLVMTypeRef, AsmString: cstring, + Constraints: cstring, HasSideEffects: int32): LLVMValueRef{. + cdecl, dynlib: libname, importc: "LLVMConstInlineAsm".} + # Operations on global variables, functions, and aliases (globals) +proc LLVMGetGlobalParent*(Global: LLVMValueRef): LLVMModuleRef{.cdecl, + dynlib: libname, importc: "LLVMGetGlobalParent".} +proc LLVMIsDeclaration*(Global: LLVMValueRef): int32{.cdecl, dynlib: libname, + importc: "LLVMIsDeclaration".} +proc LLVMGetLinkage*(Global: LLVMValueRef): LLVMLinkage{.cdecl, dynlib: libname, + importc: "LLVMGetLinkage".} +proc LLVMSetLinkage*(Global: LLVMValueRef, Linkage: LLVMLinkage){.cdecl, + dynlib: libname, importc: "LLVMSetLinkage".} +proc LLVMGetSection*(Global: LLVMValueRef): cstring{.cdecl, dynlib: libname, + importc: "LLVMGetSection".} +proc LLVMSetSection*(Global: LLVMValueRef, Section: cstring){.cdecl, + dynlib: libname, importc: "LLVMSetSection".} +proc LLVMGetVisibility*(Global: LLVMValueRef): LLVMVisibility{.cdecl, + dynlib: libname, importc: "LLVMGetVisibility".} +proc LLVMSetVisibility*(Global: LLVMValueRef, Viz: LLVMVisibility){.cdecl, + dynlib: libname, importc: "LLVMSetVisibility".} +proc LLVMGetAlignment*(Global: LLVMValueRef): dword{.cdecl, dynlib: libname, + importc: "LLVMGetAlignment".} +proc LLVMSetAlignment*(Global: LLVMValueRef, Bytes: dword){.cdecl, + dynlib: libname, importc: "LLVMSetAlignment".} + # Operations on global variables +proc LLVMAddGlobal*(M: LLVMModuleRef, Ty: LLVMTypeRef, Name: cstring): LLVMValueRef{. + cdecl, dynlib: libname, importc: "LLVMAddGlobal".} +proc LLVMGetNamedGlobal*(M: LLVMModuleRef, Name: cstring): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMGetNamedGlobal".} +proc LLVMGetFirstGlobal*(M: LLVMModuleRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMGetFirstGlobal".} +proc LLVMGetLastGlobal*(M: LLVMModuleRef): LLVMValueRef{.cdecl, dynlib: libname, + importc: "LLVMGetLastGlobal".} +proc LLVMGetNextGlobal*(GlobalVar: LLVMValueRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMGetNextGlobal".} +proc LLVMGetPreviousGlobal*(GlobalVar: LLVMValueRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMGetPreviousGlobal".} +proc LLVMDeleteGlobal*(GlobalVar: LLVMValueRef){.cdecl, dynlib: libname, + importc: "LLVMDeleteGlobal".} +proc LLVMGetInitializer*(GlobalVar: LLVMValueRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMGetInitializer".} +proc LLVMSetInitializer*(GlobalVar: LLVMValueRef, ConstantVal: LLVMValueRef){. + cdecl, dynlib: libname, importc: "LLVMSetInitializer".} +proc LLVMIsThreadLocal*(GlobalVar: LLVMValueRef): int32{.cdecl, dynlib: libname, + importc: "LLVMIsThreadLocal".} +proc LLVMSetThreadLocal*(GlobalVar: LLVMValueRef, IsThreadLocal: int32){.cdecl, + dynlib: libname, importc: "LLVMSetThreadLocal".} +proc LLVMIsGlobalConstant*(GlobalVar: LLVMValueRef): int32{.cdecl, + dynlib: libname, importc: "LLVMIsGlobalConstant".} +proc LLVMSetGlobalConstant*(GlobalVar: LLVMValueRef, IsConstant: int32){.cdecl, + dynlib: libname, importc: "LLVMSetGlobalConstant".} + # Operations on aliases +proc LLVMAddAlias*(M: LLVMModuleRef, Ty: LLVMTypeRef, Aliasee: LLVMValueRef, + Name: cstring): LLVMValueRef{.cdecl, dynlib: libname, + importc: "LLVMAddAlias".} + # Operations on functions +proc LLVMAddFunction*(M: LLVMModuleRef, Name: cstring, FunctionTy: LLVMTypeRef): LLVMValueRef{. + cdecl, dynlib: libname, importc: "LLVMAddFunction".} +proc LLVMGetNamedFunction*(M: LLVMModuleRef, Name: cstring): LLVMValueRef{. + cdecl, dynlib: libname, importc: "LLVMGetNamedFunction".} +proc LLVMGetFirstFunction*(M: LLVMModuleRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMGetFirstFunction".} +proc LLVMGetLastFunction*(M: LLVMModuleRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMGetLastFunction".} +proc LLVMGetNextFunction*(Fn: LLVMValueRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMGetNextFunction".} +proc LLVMGetPreviousFunction*(Fn: LLVMValueRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMGetPreviousFunction".} +proc LLVMDeleteFunction*(Fn: LLVMValueRef){.cdecl, dynlib: libname, + importc: "LLVMDeleteFunction".} +proc LLVMGetIntrinsicID*(Fn: LLVMValueRef): dword{.cdecl, dynlib: libname, + importc: "LLVMGetIntrinsicID".} +proc LLVMGetFunctionCallConv*(Fn: LLVMValueRef): dword{.cdecl, dynlib: libname, + importc: "LLVMGetFunctionCallConv".} +proc LLVMSetFunctionCallConv*(Fn: LLVMValueRef, CC: dword){.cdecl, + dynlib: libname, importc: "LLVMSetFunctionCallConv".} +proc LLVMGetGC*(Fn: LLVMValueRef): cstring{.cdecl, dynlib: libname, + importc: "LLVMGetGC".} +proc LLVMSetGC*(Fn: LLVMValueRef, Name: cstring){.cdecl, dynlib: libname, + importc: "LLVMSetGC".} +proc LLVMAddFunctionAttr*(Fn: LLVMValueRef, PA: LLVMAttribute){.cdecl, + dynlib: libname, importc: "LLVMAddFunctionAttr".} +proc LLVMGetFunctionAttr*(Fn: LLVMValueRef): LLVMAttribute{.cdecl, + dynlib: libname, importc: "LLVMGetFunctionAttr".} +proc LLVMRemoveFunctionAttr*(Fn: LLVMValueRef, PA: LLVMAttribute){.cdecl, + dynlib: libname, importc: "LLVMRemoveFunctionAttr".} + # Operations on parameters +proc LLVMCountParams*(Fn: LLVMValueRef): dword{.cdecl, dynlib: libname, + importc: "LLVMCountParams".} +proc LLVMGetParams*(Fn: LLVMValueRef, Params: pLLVMValueRef){.cdecl, + dynlib: libname, importc: "LLVMGetParams".} +proc LLVMGetParam*(Fn: LLVMValueRef, Index: dword): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMGetParam".} +proc LLVMGetParamParent*(Inst: LLVMValueRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMGetParamParent".} +proc LLVMGetFirstParam*(Fn: LLVMValueRef): LLVMValueRef{.cdecl, dynlib: libname, + importc: "LLVMGetFirstParam".} +proc LLVMGetLastParam*(Fn: LLVMValueRef): LLVMValueRef{.cdecl, dynlib: libname, + importc: "LLVMGetLastParam".} +proc LLVMGetNextParam*(Arg: LLVMValueRef): LLVMValueRef{.cdecl, dynlib: libname, + importc: "LLVMGetNextParam".} +proc LLVMGetPreviousParam*(Arg: LLVMValueRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMGetPreviousParam".} +proc LLVMAddAttribute*(Arg: LLVMValueRef, PA: LLVMAttribute){.cdecl, + dynlib: libname, importc: "LLVMAddAttribute".} +proc LLVMRemoveAttribute*(Arg: LLVMValueRef, PA: LLVMAttribute){.cdecl, + dynlib: libname, importc: "LLVMRemoveAttribute".} +proc LLVMGetAttribute*(Arg: LLVMValueRef): LLVMAttribute{.cdecl, + dynlib: libname, importc: "LLVMGetAttribute".} +proc LLVMSetParamAlignment*(Arg: LLVMValueRef, align: dword){.cdecl, + dynlib: libname, importc: "LLVMSetParamAlignment".} + # Operations on basic blocks +proc LLVMBasicBlockAsValue*(BB: LLVMBasicBlockRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMBasicBlockAsValue".} +proc LLVMValueIsBasicBlock*(Val: LLVMValueRef): int32{.cdecl, dynlib: libname, + importc: "LLVMValueIsBasicBlock".} +proc LLVMValueAsBasicBlock*(Val: LLVMValueRef): LLVMBasicBlockRef{.cdecl, + dynlib: libname, importc: "LLVMValueAsBasicBlock".} +proc LLVMGetBasicBlockParent*(BB: LLVMBasicBlockRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMGetBasicBlockParent".} +proc LLVMCountBasicBlocks*(Fn: LLVMValueRef): dword{.cdecl, dynlib: libname, + importc: "LLVMCountBasicBlocks".} +proc LLVMGetBasicBlocks*(Fn: LLVMValueRef, BasicBlocks: pLLVMBasicBlockRef){. + cdecl, dynlib: libname, importc: "LLVMGetBasicBlocks".} +proc LLVMGetFirstBasicBlock*(Fn: LLVMValueRef): LLVMBasicBlockRef{.cdecl, + dynlib: libname, importc: "LLVMGetFirstBasicBlock".} +proc LLVMGetLastBasicBlock*(Fn: LLVMValueRef): LLVMBasicBlockRef{.cdecl, + dynlib: libname, importc: "LLVMGetLastBasicBlock".} +proc LLVMGetNextBasicBlock*(BB: LLVMBasicBlockRef): LLVMBasicBlockRef{.cdecl, + dynlib: libname, importc: "LLVMGetNextBasicBlock".} +proc LLVMGetPreviousBasicBlock*(BB: LLVMBasicBlockRef): LLVMBasicBlockRef{. + cdecl, dynlib: libname, importc: "LLVMGetPreviousBasicBlock".} +proc LLVMGetEntryBasicBlock*(Fn: LLVMValueRef): LLVMBasicBlockRef{.cdecl, + dynlib: libname, importc: "LLVMGetEntryBasicBlock".} +proc LLVMAppendBasicBlockInContext*(C: LLVMContextRef, Fn: LLVMValueRef, + Name: cstring): LLVMBasicBlockRef{.cdecl, + dynlib: libname, importc: "LLVMAppendBasicBlockInContext".} +proc LLVMInsertBasicBlockInContext*(C: LLVMContextRef, BB: LLVMBasicBlockRef, + Name: cstring): LLVMBasicBlockRef{.cdecl, + dynlib: libname, importc: "LLVMInsertBasicBlockInContext".} +proc LLVMAppendBasicBlock*(Fn: LLVMValueRef, Name: cstring): LLVMBasicBlockRef{. + cdecl, dynlib: libname, importc: "LLVMAppendBasicBlock".} +proc LLVMInsertBasicBlock*(InsertBeforeBB: LLVMBasicBlockRef, Name: cstring): LLVMBasicBlockRef{. + cdecl, dynlib: libname, importc: "LLVMInsertBasicBlock".} +proc LLVMDeleteBasicBlock*(BB: LLVMBasicBlockRef){.cdecl, dynlib: libname, + importc: "LLVMDeleteBasicBlock".} + # Operations on instructions +proc LLVMGetInstructionParent*(Inst: LLVMValueRef): LLVMBasicBlockRef{.cdecl, + dynlib: libname, importc: "LLVMGetInstructionParent".} +proc LLVMGetFirstInstruction*(BB: LLVMBasicBlockRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMGetFirstInstruction".} +proc LLVMGetLastInstruction*(BB: LLVMBasicBlockRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMGetLastInstruction".} +proc LLVMGetNextInstruction*(Inst: LLVMValueRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMGetNextInstruction".} +proc LLVMGetPreviousInstruction*(Inst: LLVMValueRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMGetPreviousInstruction".} + # Operations on call sites +proc LLVMSetInstructionCallConv*(Instr: LLVMValueRef, CC: dword){.cdecl, + dynlib: libname, importc: "LLVMSetInstructionCallConv".} +proc LLVMGetInstructionCallConv*(Instr: LLVMValueRef): dword{.cdecl, + dynlib: libname, importc: "LLVMGetInstructionCallConv".} +proc LLVMAddInstrAttribute*(Instr: LLVMValueRef, index: dword, + para3: LLVMAttribute){.cdecl, dynlib: libname, + importc: "LLVMAddInstrAttribute".} +proc LLVMRemoveInstrAttribute*(Instr: LLVMValueRef, index: dword, + para3: LLVMAttribute){.cdecl, dynlib: libname, + importc: "LLVMRemoveInstrAttribute".} +proc LLVMSetInstrParamAlignment*(Instr: LLVMValueRef, index: dword, align: dword){. + cdecl, dynlib: libname, importc: "LLVMSetInstrParamAlignment".} + # Operations on call instructions (only) +proc LLVMIsTailCall*(CallInst: LLVMValueRef): int32{.cdecl, dynlib: libname, + importc: "LLVMIsTailCall".} +proc LLVMSetTailCall*(CallInst: LLVMValueRef, IsTailCall: int32){.cdecl, + dynlib: libname, importc: "LLVMSetTailCall".} + # Operations on phi nodes +proc LLVMAddIncoming*(PhiNode: LLVMValueRef, IncomingValues: pLLVMValueRef, + IncomingBlocks: pLLVMBasicBlockRef, Count: dword){.cdecl, + dynlib: libname, importc: "LLVMAddIncoming".} +proc LLVMCountIncoming*(PhiNode: LLVMValueRef): dword{.cdecl, dynlib: libname, + importc: "LLVMCountIncoming".} +proc LLVMGetIncomingValue*(PhiNode: LLVMValueRef, Index: dword): LLVMValueRef{. + cdecl, dynlib: libname, importc: "LLVMGetIncomingValue".} +proc LLVMGetIncomingBlock*(PhiNode: LLVMValueRef, Index: dword): LLVMBasicBlockRef{. + cdecl, dynlib: libname, importc: "LLVMGetIncomingBlock".} + #===-- Instruction builders ----------------------------------------------=== + # An instruction builder represents a point within a basic block, and is the + # * exclusive means of building instructions using the C interface. + # +proc LLVMCreateBuilderInContext*(C: LLVMContextRef): LLVMBuilderRef{.cdecl, + dynlib: libname, importc: "LLVMCreateBuilderInContext".} +proc LLVMCreateBuilder*(): LLVMBuilderRef{.cdecl, dynlib: libname, + importc: "LLVMCreateBuilder".} +proc LLVMPositionBuilder*(Builder: LLVMBuilderRef, theBlock: LLVMBasicBlockRef, + Instr: LLVMValueRef){.cdecl, dynlib: libname, + importc: "LLVMPositionBuilder".} +proc LLVMPositionBuilderBefore*(Builder: LLVMBuilderRef, Instr: LLVMValueRef){. + cdecl, dynlib: libname, importc: "LLVMPositionBuilderBefore".} +proc LLVMPositionBuilderAtEnd*(Builder: LLVMBuilderRef, theBlock: LLVMBasicBlockRef){. + cdecl, dynlib: libname, importc: "LLVMPositionBuilderAtEnd".} +proc LLVMGetInsertBlock*(Builder: LLVMBuilderRef): LLVMBasicBlockRef{.cdecl, + dynlib: libname, importc: "LLVMGetInsertBlock".} +proc LLVMClearInsertionPosition*(Builder: LLVMBuilderRef){.cdecl, + dynlib: libname, importc: "LLVMClearInsertionPosition".} +proc LLVMInsertIntoBuilder*(Builder: LLVMBuilderRef, Instr: LLVMValueRef){. + cdecl, dynlib: libname, importc: "LLVMInsertIntoBuilder".} +proc LLVMInsertIntoBuilderWithName*(Builder: LLVMBuilderRef, + Instr: LLVMValueRef, Name: cstring){.cdecl, + dynlib: libname, importc: "LLVMInsertIntoBuilderWithName".} +proc LLVMDisposeBuilder*(Builder: LLVMBuilderRef){.cdecl, dynlib: libname, + importc: "LLVMDisposeBuilder".} + # Terminators +proc LLVMBuildRetVoid*(para1: LLVMBuilderRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMBuildRetVoid".} +proc LLVMBuildRet*(para1: LLVMBuilderRef, V: LLVMValueRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMBuildRet".} +proc LLVMBuildAggregateRet*(para1: LLVMBuilderRef, RetVals: pLLVMValueRef, + N: dword): LLVMValueRef{.cdecl, dynlib: libname, + importc: "LLVMBuildAggregateRet".} +proc LLVMBuildBr*(para1: LLVMBuilderRef, Dest: LLVMBasicBlockRef): LLVMValueRef{. + cdecl, dynlib: libname, importc: "LLVMBuildBr".} +proc LLVMBuildCondBr*(para1: LLVMBuilderRef, Cond: LLVMValueRef, + ThenBranch: LLVMBasicBlockRef, + ElseBranch: LLVMBasicBlockRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMBuildCondBr".} +proc LLVMBuildSwitch*(para1: LLVMBuilderRef, V: LLVMValueRef, + ElseBranch: LLVMBasicBlockRef, NumCases: dword): LLVMValueRef{. + cdecl, dynlib: libname, importc: "LLVMBuildSwitch".} +proc LLVMBuildInvoke*(para1: LLVMBuilderRef, Fn: LLVMValueRef, + Args: pLLVMValueRef, NumArgs: dword, + ThenBranch: LLVMBasicBlockRef, Catch: LLVMBasicBlockRef, + Name: cstring): LLVMValueRef{.cdecl, dynlib: libname, + importc: "LLVMBuildInvoke".} +proc LLVMBuildUnwind*(para1: LLVMBuilderRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMBuildUnwind".} +proc LLVMBuildUnreachable*(para1: LLVMBuilderRef): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMBuildUnreachable".} + # Add a case to the switch instruction +proc LLVMAddCase*(Switch: LLVMValueRef, OnVal: LLVMValueRef, + Dest: LLVMBasicBlockRef){.cdecl, dynlib: libname, + importc: "LLVMAddCase".} + # Arithmetic +proc LLVMBuildAdd*(para1: LLVMBuilderRef, LHS: LLVMValueRef, RHS: LLVMValueRef, + Name: cstring): LLVMValueRef{.cdecl, dynlib: libname, + importc: "LLVMBuildAdd".} +proc LLVMBuildNSWAdd*(para1: LLVMBuilderRef, LHS: LLVMValueRef, + RHS: LLVMValueRef, Name: cstring): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMBuildNSWAdd".} +proc LLVMBuildFAdd*(para1: LLVMBuilderRef, LHS: LLVMValueRef, RHS: LLVMValueRef, + Name: cstring): LLVMValueRef{.cdecl, dynlib: libname, + importc: "LLVMBuildFAdd".} +proc LLVMBuildSub*(para1: LLVMBuilderRef, LHS: LLVMValueRef, RHS: LLVMValueRef, + Name: cstring): LLVMValueRef{.cdecl, dynlib: libname, + importc: "LLVMBuildSub".} +proc LLVMBuildFSub*(para1: LLVMBuilderRef, LHS: LLVMValueRef, RHS: LLVMValueRef, + Name: cstring): LLVMValueRef{.cdecl, dynlib: libname, + importc: "LLVMBuildFSub".} +proc LLVMBuildMul*(para1: LLVMBuilderRef, LHS: LLVMValueRef, RHS: LLVMValueRef, + Name: cstring): LLVMValueRef{.cdecl, dynlib: libname, + importc: "LLVMBuildMul".} +proc LLVMBuildFMul*(para1: LLVMBuilderRef, LHS: LLVMValueRef, RHS: LLVMValueRef, + Name: cstring): LLVMValueRef{.cdecl, dynlib: libname, + importc: "LLVMBuildFMul".} +proc LLVMBuildUDiv*(para1: LLVMBuilderRef, LHS: LLVMValueRef, RHS: LLVMValueRef, + Name: cstring): LLVMValueRef{.cdecl, dynlib: libname, + importc: "LLVMBuildUDiv".} +proc LLVMBuildSDiv*(para1: LLVMBuilderRef, LHS: LLVMValueRef, RHS: LLVMValueRef, + Name: cstring): LLVMValueRef{.cdecl, dynlib: libname, + importc: "LLVMBuildSDiv".} +proc LLVMBuildExactSDiv*(para1: LLVMBuilderRef, LHS: LLVMValueRef, + RHS: LLVMValueRef, Name: cstring): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMBuildExactSDiv".} +proc LLVMBuildFDiv*(para1: LLVMBuilderRef, LHS: LLVMValueRef, RHS: LLVMValueRef, + Name: cstring): LLVMValueRef{.cdecl, dynlib: libname, + importc: "LLVMBuildFDiv".} +proc LLVMBuildURem*(para1: LLVMBuilderRef, LHS: LLVMValueRef, RHS: LLVMValueRef, + Name: cstring): LLVMValueRef{.cdecl, dynlib: libname, + importc: "LLVMBuildURem".} +proc LLVMBuildSRem*(para1: LLVMBuilderRef, LHS: LLVMValueRef, RHS: LLVMValueRef, + Name: cstring): LLVMValueRef{.cdecl, dynlib: libname, + importc: "LLVMBuildSRem".} +proc LLVMBuildFRem*(para1: LLVMBuilderRef, LHS: LLVMValueRef, RHS: LLVMValueRef, + Name: cstring): LLVMValueRef{.cdecl, dynlib: libname, + importc: "LLVMBuildFRem".} +proc LLVMBuildShl*(para1: LLVMBuilderRef, LHS: LLVMValueRef, RHS: LLVMValueRef, + Name: cstring): LLVMValueRef{.cdecl, dynlib: libname, + importc: "LLVMBuildShl".} +proc LLVMBuildLShr*(para1: LLVMBuilderRef, LHS: LLVMValueRef, RHS: LLVMValueRef, + Name: cstring): LLVMValueRef{.cdecl, dynlib: libname, + importc: "LLVMBuildLShr".} +proc LLVMBuildAShr*(para1: LLVMBuilderRef, LHS: LLVMValueRef, RHS: LLVMValueRef, + Name: cstring): LLVMValueRef{.cdecl, dynlib: libname, + importc: "LLVMBuildAShr".} +proc LLVMBuildAnd*(para1: LLVMBuilderRef, LHS: LLVMValueRef, RHS: LLVMValueRef, + Name: cstring): LLVMValueRef{.cdecl, dynlib: libname, + importc: "LLVMBuildAnd".} +proc LLVMBuildOr*(para1: LLVMBuilderRef, LHS: LLVMValueRef, RHS: LLVMValueRef, + Name: cstring): LLVMValueRef{.cdecl, dynlib: libname, + importc: "LLVMBuildOr".} +proc LLVMBuildXor*(para1: LLVMBuilderRef, LHS: LLVMValueRef, RHS: LLVMValueRef, + Name: cstring): LLVMValueRef{.cdecl, dynlib: libname, + importc: "LLVMBuildXor".} +proc LLVMBuildNeg*(para1: LLVMBuilderRef, V: LLVMValueRef, Name: cstring): LLVMValueRef{. + cdecl, dynlib: libname, importc: "LLVMBuildNeg".} +proc LLVMBuildFNeg*(para1: LLVMBuilderRef, V: LLVMValueRef, Name: cstring): LLVMValueRef{. + cdecl, dynlib: libname, importc: "LLVMBuildFNeg".} +proc LLVMBuildNot*(para1: LLVMBuilderRef, V: LLVMValueRef, Name: cstring): LLVMValueRef{. + cdecl, dynlib: libname, importc: "LLVMBuildNot".} + # Memory +proc LLVMBuildMalloc*(para1: LLVMBuilderRef, Ty: LLVMTypeRef, Name: cstring): LLVMValueRef{. + cdecl, dynlib: libname, importc: "LLVMBuildMalloc".} +proc LLVMBuildArrayMalloc*(para1: LLVMBuilderRef, Ty: LLVMTypeRef, + Val: LLVMValueRef, Name: cstring): LLVMValueRef{. + cdecl, dynlib: libname, importc: "LLVMBuildArrayMalloc".} +proc LLVMBuildAlloca*(para1: LLVMBuilderRef, Ty: LLVMTypeRef, Name: cstring): LLVMValueRef{. + cdecl, dynlib: libname, importc: "LLVMBuildAlloca".} +proc LLVMBuildArrayAlloca*(para1: LLVMBuilderRef, Ty: LLVMTypeRef, + Val: LLVMValueRef, Name: cstring): LLVMValueRef{. + cdecl, dynlib: libname, importc: "LLVMBuildArrayAlloca".} +proc LLVMBuildFree*(para1: LLVMBuilderRef, PointerVal: LLVMValueRef): LLVMValueRef{. + cdecl, dynlib: libname, importc: "LLVMBuildFree".} +proc LLVMBuildLoad*(para1: LLVMBuilderRef, PointerVal: LLVMValueRef, + Name: cstring): LLVMValueRef{.cdecl, dynlib: libname, + importc: "LLVMBuildLoad".} +proc LLVMBuildStore*(para1: LLVMBuilderRef, Val: LLVMValueRef, + thePtr: LLVMValueRef): LLVMValueRef{. + cdecl, dynlib: libname, importc: "LLVMBuildStore".} +proc LLVMBuildGEP*(B: LLVMBuilderRef, Pointer: LLVMValueRef, + Indices: pLLVMValueRef, NumIndices: dword, Name: cstring): LLVMValueRef{. + cdecl, dynlib: libname, importc: "LLVMBuildGEP".} +proc LLVMBuildInBoundsGEP*(B: LLVMBuilderRef, Pointer: LLVMValueRef, + Indices: pLLVMValueRef, NumIndices: dword, + Name: cstring): LLVMValueRef{.cdecl, dynlib: libname, + importc: "LLVMBuildInBoundsGEP".} +proc LLVMBuildStructGEP*(B: LLVMBuilderRef, Pointer: LLVMValueRef, Idx: dword, + Name: cstring): LLVMValueRef{.cdecl, dynlib: libname, + importc: "LLVMBuildStructGEP".} +proc LLVMBuildGlobalString*(B: LLVMBuilderRef, Str: cstring, Name: cstring): LLVMValueRef{. + cdecl, dynlib: libname, importc: "LLVMBuildGlobalString".} +proc LLVMBuildGlobalStringPtr*(B: LLVMBuilderRef, Str: cstring, Name: cstring): LLVMValueRef{. + cdecl, dynlib: libname, importc: "LLVMBuildGlobalStringPtr".} + # Casts +proc LLVMBuildTrunc*(para1: LLVMBuilderRef, Val: LLVMValueRef, + DestTy: LLVMTypeRef, Name: cstring): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMBuildTrunc".} +proc LLVMBuildZExt*(para1: LLVMBuilderRef, Val: LLVMValueRef, + DestTy: LLVMTypeRef, Name: cstring): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMBuildZExt".} +proc LLVMBuildSExt*(para1: LLVMBuilderRef, Val: LLVMValueRef, + DestTy: LLVMTypeRef, Name: cstring): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMBuildSExt".} +proc LLVMBuildFPToUI*(para1: LLVMBuilderRef, Val: LLVMValueRef, + DestTy: LLVMTypeRef, Name: cstring): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMBuildFPToUI".} +proc LLVMBuildFPToSI*(para1: LLVMBuilderRef, Val: LLVMValueRef, + DestTy: LLVMTypeRef, Name: cstring): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMBuildFPToSI".} +proc LLVMBuildUIToFP*(para1: LLVMBuilderRef, Val: LLVMValueRef, + DestTy: LLVMTypeRef, Name: cstring): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMBuildUIToFP".} +proc LLVMBuildSIToFP*(para1: LLVMBuilderRef, Val: LLVMValueRef, + DestTy: LLVMTypeRef, Name: cstring): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMBuildSIToFP".} +proc LLVMBuildFPTrunc*(para1: LLVMBuilderRef, Val: LLVMValueRef, + DestTy: LLVMTypeRef, Name: cstring): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMBuildFPTrunc".} +proc LLVMBuildFPExt*(para1: LLVMBuilderRef, Val: LLVMValueRef, + DestTy: LLVMTypeRef, Name: cstring): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMBuildFPExt".} +proc LLVMBuildPtrToInt*(para1: LLVMBuilderRef, Val: LLVMValueRef, + DestTy: LLVMTypeRef, Name: cstring): LLVMValueRef{. + cdecl, dynlib: libname, importc: "LLVMBuildPtrToInt".} +proc LLVMBuildIntToPtr*(para1: LLVMBuilderRef, Val: LLVMValueRef, + DestTy: LLVMTypeRef, Name: cstring): LLVMValueRef{. + cdecl, dynlib: libname, importc: "LLVMBuildIntToPtr".} +proc LLVMBuildBitCast*(para1: LLVMBuilderRef, Val: LLVMValueRef, + DestTy: LLVMTypeRef, Name: cstring): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMBuildBitCast".} +proc LLVMBuildZExtOrBitCast*(para1: LLVMBuilderRef, Val: LLVMValueRef, + DestTy: LLVMTypeRef, Name: cstring): LLVMValueRef{. + cdecl, dynlib: libname, importc: "LLVMBuildZExtOrBitCast".} +proc LLVMBuildSExtOrBitCast*(para1: LLVMBuilderRef, Val: LLVMValueRef, + DestTy: LLVMTypeRef, Name: cstring): LLVMValueRef{. + cdecl, dynlib: libname, importc: "LLVMBuildSExtOrBitCast".} +proc LLVMBuildTruncOrBitCast*(para1: LLVMBuilderRef, Val: LLVMValueRef, + DestTy: LLVMTypeRef, Name: cstring): LLVMValueRef{. + cdecl, dynlib: libname, importc: "LLVMBuildTruncOrBitCast".} +proc LLVMBuildPointerCast*(para1: LLVMBuilderRef, Val: LLVMValueRef, + DestTy: LLVMTypeRef, Name: cstring): LLVMValueRef{. + cdecl, dynlib: libname, importc: "LLVMBuildPointerCast".} +proc LLVMBuildIntCast*(para1: LLVMBuilderRef, Val: LLVMValueRef, + DestTy: LLVMTypeRef, Name: cstring): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMBuildIntCast".} +proc LLVMBuildFPCast*(para1: LLVMBuilderRef, Val: LLVMValueRef, + DestTy: LLVMTypeRef, Name: cstring): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMBuildFPCast".} + # Comparisons +proc LLVMBuildICmp*(para1: LLVMBuilderRef, Op: LLVMIntPredicate, + LHS: LLVMValueRef, RHS: LLVMValueRef, Name: cstring): LLVMValueRef{. + cdecl, dynlib: libname, importc: "LLVMBuildICmp".} +proc LLVMBuildFCmp*(para1: LLVMBuilderRef, Op: LLVMRealPredicate, + LHS: LLVMValueRef, RHS: LLVMValueRef, Name: cstring): LLVMValueRef{. + cdecl, dynlib: libname, importc: "LLVMBuildFCmp".} + # Miscellaneous instructions +proc LLVMBuildPhi*(para1: LLVMBuilderRef, Ty: LLVMTypeRef, Name: cstring): LLVMValueRef{. + cdecl, dynlib: libname, importc: "LLVMBuildPhi".} +proc LLVMBuildCall*(para1: LLVMBuilderRef, Fn: LLVMValueRef, + Args: pLLVMValueRef, NumArgs: dword, Name: cstring): LLVMValueRef{. + cdecl, dynlib: libname, importc: "LLVMBuildCall".} +proc LLVMBuildSelect*(para1: LLVMBuilderRef, Cond: LLVMValueRef, + ThenBranch: LLVMValueRef, ElseBranch: LLVMValueRef, + Name: cstring): LLVMValueRef{.cdecl, dynlib: libname, + importc: "LLVMBuildSelect".} +proc LLVMBuildVAArg*(para1: LLVMBuilderRef, List: LLVMValueRef, Ty: LLVMTypeRef, + Name: cstring): LLVMValueRef{.cdecl, dynlib: libname, + importc: "LLVMBuildVAArg".} +proc LLVMBuildExtractElement*(para1: LLVMBuilderRef, VecVal: LLVMValueRef, + Index: LLVMValueRef, Name: cstring): LLVMValueRef{. + cdecl, dynlib: libname, importc: "LLVMBuildExtractElement".} +proc LLVMBuildInsertElement*(para1: LLVMBuilderRef, VecVal: LLVMValueRef, + EltVal: LLVMValueRef, Index: LLVMValueRef, + Name: cstring): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMBuildInsertElement".} +proc LLVMBuildShuffleVector*(para1: LLVMBuilderRef, V1: LLVMValueRef, + V2: LLVMValueRef, Mask: LLVMValueRef, Name: cstring): LLVMValueRef{. + cdecl, dynlib: libname, importc: "LLVMBuildShuffleVector".} +proc LLVMBuildExtractValue*(para1: LLVMBuilderRef, AggVal: LLVMValueRef, + Index: dword, Name: cstring): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMBuildExtractValue".} +proc LLVMBuildInsertValue*(para1: LLVMBuilderRef, AggVal: LLVMValueRef, + EltVal: LLVMValueRef, Index: dword, Name: cstring): LLVMValueRef{. + cdecl, dynlib: libname, importc: "LLVMBuildInsertValue".} +proc LLVMBuildIsNull*(para1: LLVMBuilderRef, Val: LLVMValueRef, Name: cstring): LLVMValueRef{. + cdecl, dynlib: libname, importc: "LLVMBuildIsNull".} +proc LLVMBuildIsNotNull*(para1: LLVMBuilderRef, Val: LLVMValueRef, Name: cstring): LLVMValueRef{. + cdecl, dynlib: libname, importc: "LLVMBuildIsNotNull".} +proc LLVMBuildPtrDiff*(para1: LLVMBuilderRef, LHS: LLVMValueRef, + RHS: LLVMValueRef, Name: cstring): LLVMValueRef{.cdecl, + dynlib: libname, importc: "LLVMBuildPtrDiff".} + #===-- Module providers --------------------------------------------------=== + # Encapsulates the module M in a module provider, taking ownership of the + # * module. + # * See the constructor llvm::ExistingModuleProvider::ExistingModuleProvider. + # +proc LLVMCreateModuleProviderForExistingModule*(M: LLVMModuleRef): LLVMModuleProviderRef{. + cdecl, dynlib: libname, importc: "LLVMCreateModuleProviderForExistingModule".} + # Destroys the module provider MP as well as the contained module. + # * See the destructor llvm::ModuleProvider::~ModuleProvider. + # +proc LLVMDisposeModuleProvider*(MP: LLVMModuleProviderRef){.cdecl, + dynlib: libname, importc: "LLVMDisposeModuleProvider".} + #===-- Memory buffers ----------------------------------------------------=== +proc LLVMCreateMemoryBufferWithContentsOfFile*(Path: cstring, + OutMemBuf: pLLVMMemoryBufferRef, OutMessage: Ppchar): int32{.cdecl, + dynlib: libname, importc: "LLVMCreateMemoryBufferWithContentsOfFile".} +proc LLVMCreateMemoryBufferWithSTDIN*(OutMemBuf: pLLVMMemoryBufferRef, + OutMessage: Ppchar): int32{.cdecl, + dynlib: libname, importc: "LLVMCreateMemoryBufferWithSTDIN".} +proc LLVMDisposeMemoryBuffer*(MemBuf: LLVMMemoryBufferRef){.cdecl, + dynlib: libname, importc: "LLVMDisposeMemoryBuffer".} + #===-- 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. +proc LLVMCreatePassManager*(): LLVMPassManagerRef{.cdecl, dynlib: libname, + importc: "LLVMCreatePassManager".} + #* 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. +proc LLVMCreateFunctionPassManager*(MP: LLVMModuleProviderRef): LLVMPassManagerRef{. + cdecl, dynlib: libname, importc: "LLVMCreateFunctionPassManager".} + #* 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&). +proc LLVMRunPassManager*(PM: LLVMPassManagerRef, M: LLVMModuleRef): int32{. + cdecl, dynlib: libname, importc: "LLVMRunPassManager".} + #* 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. +proc LLVMInitializeFunctionPassManager*(FPM: LLVMPassManagerRef): int32{.cdecl, + dynlib: libname, importc: "LLVMInitializeFunctionPassManager".} + #* 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&). +proc LLVMRunFunctionPassManager*(FPM: LLVMPassManagerRef, F: LLVMValueRef): int32{. + cdecl, dynlib: libname, importc: "LLVMRunFunctionPassManager".} + #* 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. +proc LLVMFinalizeFunctionPassManager*(FPM: LLVMPassManagerRef): int32{.cdecl, + dynlib: libname, importc: "LLVMFinalizeFunctionPassManager".} + #* Frees the memory of a pass pipeline. For function pipelines, does not free + # the module provider. + # See llvm::PassManagerBase::~PassManagerBase. +proc LLVMDisposePassManager*(PM: LLVMPassManagerRef){.cdecl, dynlib: libname, + importc: "LLVMDisposePassManager".} + # Analysis.h + # verifier will print to stderr and abort() + # verifier will print to stderr and return 1 + # verifier will just return 1 +type + LLVMVerifierFailureAction* = enum # Verifies that a module is valid, taking the specified action if not. + # Optionally returns a human-readable description of any invalid constructs. + # OutMessage must be disposed with LLVMDisposeMessage. + LLVMAbortProcessAction, LLVMPrintMessageAction, LLVMReturnStatusAction + +proc LLVMVerifyModule*(M: LLVMModuleRef, Action: LLVMVerifierFailureAction, + OutMessage: Ppchar): int32{.cdecl, dynlib: libname, + importc: "LLVMVerifyModule".} + # Verifies that a single function is valid, taking the specified action. Useful + # for debugging. +proc LLVMVerifyFunction*(Fn: LLVMValueRef, Action: LLVMVerifierFailureAction): int32{. + cdecl, dynlib: libname, importc: "LLVMVerifyFunction".} + # Open up a ghostview window that displays the CFG of the current function. + # Useful for debugging. +proc LLVMViewFunctionCFG*(Fn: LLVMValueRef){.cdecl, dynlib: libname, + importc: "LLVMViewFunctionCFG".} +proc LLVMViewFunctionCFGOnly*(Fn: LLVMValueRef){.cdecl, dynlib: libname, + importc: "LLVMViewFunctionCFGOnly".} + # BitReader.h + # Builds a module from the bitcode in the specified memory buffer, returning a + # reference to the module via the OutModule parameter. Returns 0 on success. + # Optionally returns a human-readable error message via OutMessage. +proc LLVMParseBitcode*(MemBuf: LLVMMemoryBufferRef, OutModule: pLLVMModuleRef, + OutMessage: Ppchar): int32{.cdecl, dynlib: libname, + importc: "LLVMParseBitcode".} +proc LLVMParseBitcodeInContext*(ContextRef: LLVMContextRef, + MemBuf: LLVMMemoryBufferRef, + OutModule: pLLVMModuleRef, OutMessage: Ppchar): int32{. + cdecl, dynlib: libname, importc: "LLVMParseBitcodeInContext".} + # Reads a module from the specified path, returning via the OutMP parameter + # a module provider which performs lazy deserialization. Returns 0 on success. + # Optionally returns a human-readable error message via OutMessage. +proc LLVMGetBitcodeModuleProvider*(MemBuf: LLVMMemoryBufferRef, + OutMP: pLLVMModuleProviderRef, + OutMessage: Ppchar): int32{.cdecl, + dynlib: libname, importc: "LLVMGetBitcodeModuleProvider".} +proc LLVMGetBitcodeModuleProviderInContext*(ContextRef: LLVMContextRef, + MemBuf: LLVMMemoryBufferRef, OutMP: pLLVMModuleProviderRef, + OutMessage: Ppchar): int32{.cdecl, dynlib: libname, importc: "LLVMGetBitcodeModuleProviderInContext".} + # BitWriter.h + #===-- Operations on modules ---------------------------------------------=== + # Writes a module to an open file descriptor. Returns 0 on success. + # Closes the Handle. Use dup first if this is not what you want. +proc LLVMWriteBitcodeToFileHandle*(M: LLVMModuleRef, Handle: int32): int32{. + cdecl, dynlib: libname, importc: "LLVMWriteBitcodeToFileHandle".} + # Writes a module to the specified path. Returns 0 on success. +proc LLVMWriteBitcodeToFile*(M: LLVMModuleRef, Path: cstring): int32{.cdecl, + dynlib: libname, importc: "LLVMWriteBitcodeToFile".} + # Target.h +const + LLVMBigEndian* = 0 + LLVMLittleEndian* = 1 + +type + LLVMByteOrdering* = int32 + LLVMTargetDataRef* = LLVMOpaqueTargetData + LLVMStructLayoutRef* = LLVMStructLayout #===-- Target Data -------------------------------------------------------=== + #* Creates target data from a target layout string. + # See the constructor llvm::TargetData::TargetData. + +proc LLVMCreateTargetData*(StringRep: cstring): LLVMTargetDataRef{.cdecl, + dynlib: libname, importc: "LLVMCreateTargetData".} + #* Adds target data information to a pass manager. This does not take ownership + # of the target data. + # See the method llvm::PassManagerBase::add. +proc LLVMAddTargetData*(para1: LLVMTargetDataRef, para2: LLVMPassManagerRef){. + cdecl, dynlib: libname, importc: "LLVMAddTargetData".} + #* Converts target data to a target layout string. The string must be disposed + # with LLVMDisposeMessage. + # See the constructor llvm::TargetData::TargetData. +proc LLVMCopyStringRepOfTargetData*(para1: LLVMTargetDataRef): cstring{.cdecl, + dynlib: libname, importc: "LLVMCopyStringRepOfTargetData".} + #* Returns the byte order of a target, either LLVMBigEndian or + # LLVMLittleEndian. + # See the method llvm::TargetData::isLittleEndian. +proc LLVMByteOrder*(para1: LLVMTargetDataRef): LLVMByteOrdering{.cdecl, + dynlib: libname, importc: "LLVMByteOrder".} + #* Returns the pointer size in bytes for a target. + # See the method llvm::TargetData::getPointerSize. +proc LLVMPointerSize*(para1: LLVMTargetDataRef): dword{.cdecl, dynlib: libname, + importc: "LLVMPointerSize".} + #* Returns the integer type that is the same size as a pointer on a target. + # See the method llvm::TargetData::getIntPtrType. +proc LLVMIntPtrType*(para1: LLVMTargetDataRef): LLVMTypeRef{.cdecl, + dynlib: libname, importc: "LLVMIntPtrType".} + #* Computes the size of a type in bytes for a target. + # See the method llvm::TargetData::getTypeSizeInBits. +proc LLVMSizeOfTypeInBits*(para1: LLVMTargetDataRef, para2: LLVMTypeRef): qword{. + cdecl, dynlib: libname, importc: "LLVMSizeOfTypeInBits".} + #* Computes the storage size of a type in bytes for a target. + # See the method llvm::TargetData::getTypeStoreSize. +proc LLVMStoreSizeOfType*(para1: LLVMTargetDataRef, para2: LLVMTypeRef): qword{. + cdecl, dynlib: libname, importc: "LLVMStoreSizeOfType".} + #* Computes the ABI size of a type in bytes for a target. + # See the method llvm::TargetData::getTypeAllocSize. +proc LLVMABISizeOfType*(para1: LLVMTargetDataRef, para2: LLVMTypeRef): qword{. + cdecl, dynlib: libname, importc: "LLVMABISizeOfType".} + #* Computes the ABI alignment of a type in bytes for a target. + # See the method llvm::TargetData::getTypeABISize. +proc LLVMABIAlignmentOfType*(para1: LLVMTargetDataRef, para2: LLVMTypeRef): dword{. + cdecl, dynlib: libname, importc: "LLVMABIAlignmentOfType".} + #* Computes the call frame alignment of a type in bytes for a target. + # See the method llvm::TargetData::getTypeABISize. +proc LLVMCallFrameAlignmentOfType*(para1: LLVMTargetDataRef, para2: LLVMTypeRef): dword{. + cdecl, dynlib: libname, importc: "LLVMCallFrameAlignmentOfType".} + #* Computes the preferred alignment of a type in bytes for a target. + # See the method llvm::TargetData::getTypeABISize. +proc LLVMPreferredAlignmentOfType*(para1: LLVMTargetDataRef, para2: LLVMTypeRef): dword{. + cdecl, dynlib: libname, importc: "LLVMPreferredAlignmentOfType".} + #* Computes the preferred alignment of a global variable in bytes for a target. + # See the method llvm::TargetData::getPreferredAlignment. +proc LLVMPreferredAlignmentOfGlobal*(para1: LLVMTargetDataRef, + GlobalVar: LLVMValueRef): dword{.cdecl, + dynlib: libname, importc: "LLVMPreferredAlignmentOfGlobal".} + #* Computes the structure element that contains the byte offset for a target. + # See the method llvm::StructLayout::getElementContainingOffset. +proc LLVMElementAtOffset*(para1: LLVMTargetDataRef, StructTy: LLVMTypeRef, + Offset: qword): dword{.cdecl, dynlib: libname, + importc: "LLVMElementAtOffset".} + #* Computes the byte offset of the indexed struct element for a target. + # See the method llvm::StructLayout::getElementContainingOffset. +proc LLVMOffsetOfElement*(para1: LLVMTargetDataRef, StructTy: LLVMTypeRef, + Element: dword): qword{.cdecl, dynlib: libname, + importc: "LLVMOffsetOfElement".} + #* Struct layouts are speculatively cached. If a TargetDataRef is alive when + # types are being refined and removed, this method must be called whenever a + # struct type is removed to avoid a dangling pointer in this cache. + # See the method llvm::TargetData::InvalidateStructLayoutInfo. +proc LLVMInvalidateStructLayout*(para1: LLVMTargetDataRef, StructTy: LLVMTypeRef){. + cdecl, dynlib: libname, importc: "LLVMInvalidateStructLayout".} + #* Deallocates a TargetData. + # See the destructor llvm::TargetData::~TargetData. +proc LLVMDisposeTargetData*(para1: LLVMTargetDataRef){.cdecl, dynlib: libname, + importc: "LLVMDisposeTargetData".} + # ExecutionEngine.h +proc LLVMLinkInJIT*(){.cdecl, dynlib: libname, importc: "LLVMLinkInJIT".} +proc LLVMLinkInInterpreter*(){.cdecl, dynlib: libname, + importc: "LLVMLinkInInterpreter".} +type + LLVMGenericValueRef* = LLVMOpaqueGenericValue + LLVMExecutionEngineRef* = LLVMOpaqueExecutionEngine #===-- Operations on generic values --------------------------------------=== + +proc LLVMCreateGenericValueOfInt*(Ty: LLVMTypeRef, N: qword, IsSigned: int32): LLVMGenericValueRef{. + cdecl, dynlib: libname, importc: "LLVMCreateGenericValueOfInt".} +proc LLVMCreateGenericValueOfPointer*(P: pointer): LLVMGenericValueRef{.cdecl, + dynlib: libname, importc: "LLVMCreateGenericValueOfPointer".} +proc LLVMCreateGenericValueOfFloat*(Ty: LLVMTypeRef, N: float64): LLVMGenericValueRef{. + cdecl, dynlib: libname, importc: "LLVMCreateGenericValueOfFloat".} +proc LLVMGenericValueIntWidth*(GenValRef: LLVMGenericValueRef): dword{.cdecl, + dynlib: libname, importc: "LLVMGenericValueIntWidth".} +proc LLVMGenericValueToInt*(GenVal: LLVMGenericValueRef, IsSigned: int32): qword{. + cdecl, dynlib: libname, importc: "LLVMGenericValueToInt".} +proc LLVMGenericValueToPointer*(GenVal: LLVMGenericValueRef): pointer{.cdecl, + dynlib: libname, importc: "LLVMGenericValueToPointer".} +proc LLVMGenericValueToFloat*(TyRef: LLVMTypeRef, GenVal: LLVMGenericValueRef): float64{. + cdecl, dynlib: libname, importc: "LLVMGenericValueToFloat".} +proc LLVMDisposeGenericValue*(GenVal: LLVMGenericValueRef){.cdecl, + dynlib: libname, importc: "LLVMDisposeGenericValue".} + #===-- Operations on execution engines -----------------------------------=== +proc LLVMCreateExecutionEngine*(OutEE: pLLVMExecutionEngineRef, + MP: LLVMModuleProviderRef, OutError: Ppchar): int32{. + cdecl, dynlib: libname, importc: "LLVMCreateExecutionEngine".} +proc LLVMCreateInterpreter*(OutInterp: pLLVMExecutionEngineRef, + MP: LLVMModuleProviderRef, OutError: Ppchar): int32{. + cdecl, dynlib: libname, importc: "LLVMCreateInterpreter".} +proc LLVMCreateJITCompiler*(OutJIT: pLLVMExecutionEngineRef, + MP: LLVMModuleProviderRef, OptLevel: dword, + OutError: Ppchar): int32{.cdecl, dynlib: libname, + importc: "LLVMCreateJITCompiler".} +proc LLVMDisposeExecutionEngine*(EE: LLVMExecutionEngineRef){.cdecl, + dynlib: libname, importc: "LLVMDisposeExecutionEngine".} +proc LLVMRunStaticConstructors*(EE: LLVMExecutionEngineRef){.cdecl, + dynlib: libname, importc: "LLVMRunStaticConstructors".} +proc LLVMRunStaticDestructors*(EE: LLVMExecutionEngineRef){.cdecl, + dynlib: libname, importc: "LLVMRunStaticDestructors".} + # Const before declarator ignored + # Const before declarator ignored +proc LLVMRunFunctionAsMain*(EE: LLVMExecutionEngineRef, F: LLVMValueRef, + ArgC: dword, ArgV: Ppchar, EnvP: Ppchar): int32{. + cdecl, dynlib: libname, importc: "LLVMRunFunctionAsMain".} +proc LLVMRunFunction*(EE: LLVMExecutionEngineRef, F: LLVMValueRef, + NumArgs: dword, Args: pLLVMGenericValueRef): LLVMGenericValueRef{. + cdecl, dynlib: libname, importc: "LLVMRunFunction".} +proc LLVMFreeMachineCodeForFunction*(EE: LLVMExecutionEngineRef, F: LLVMValueRef){. + cdecl, dynlib: libname, importc: "LLVMFreeMachineCodeForFunction".} +proc LLVMAddModuleProvider*(EE: LLVMExecutionEngineRef, + MP: LLVMModuleProviderRef){.cdecl, dynlib: libname, + importc: "LLVMAddModuleProvider".} +proc LLVMRemoveModuleProvider*(EE: LLVMExecutionEngineRef, + MP: LLVMModuleProviderRef, + OutMod: pLLVMModuleRef, OutError: Ppchar): int32{. + cdecl, dynlib: libname, importc: "LLVMRemoveModuleProvider".} +proc LLVMFindFunction*(EE: LLVMExecutionEngineRef, Name: cstring, + OutFn: pLLVMValueRef): int32{.cdecl, dynlib: libname, + importc: "LLVMFindFunction".} +proc LLVMGetExecutionEngineTargetData*(EE: LLVMExecutionEngineRef): LLVMTargetDataRef{. + cdecl, dynlib: libname, importc: "LLVMGetExecutionEngineTargetData".} +proc LLVMAddGlobalMapping*(EE: LLVMExecutionEngineRef, Global: LLVMValueRef, + theAddr: pointer){.cdecl, dynlib: libname, + importc: "LLVMAddGlobalMapping".} +proc LLVMGetPointerToGlobal*(EE: LLVMExecutionEngineRef, Global: LLVMValueRef): pointer{. + cdecl, dynlib: libname, importc: "LLVMGetPointerToGlobal".} + # LinkTimeOptimizer.h + #/ This provides a dummy type for pointers to the LTO object. +type + llvm_lto_t* = pointer #/ This provides a C-visible enumerator to manage status codes. + #/ This should map exactly onto the C++ enumerator LTOStatus. + # Added C-specific error codes + llvm_lto_status* = enum + LLVM_LTO_UNKNOWN, LLVM_LTO_OPT_SUCCESS, LLVM_LTO_READ_SUCCESS, + LLVM_LTO_READ_FAILURE, LLVM_LTO_WRITE_FAILURE, LLVM_LTO_NO_TARGET, + LLVM_LTO_NO_WORK, LLVM_LTO_MODULE_MERGE_FAILURE, LLVM_LTO_ASM_FAILURE, + LLVM_LTO_NULL_OBJECT + llvm_lto_status_t* = llvm_lto_status #/ This provides C interface to initialize link time optimizer. This allows + #/ linker to use dlopen() interface to dynamically load LinkTimeOptimizer. + #/ extern "C" helps, because dlopen() interface uses name to find the symbol. + +proc llvm_create_optimizer*(): llvm_lto_t{.cdecl, dynlib: libname, + importc: "llvm_create_optimizer".} +proc llvm_destroy_optimizer*(lto: llvm_lto_t){.cdecl, dynlib: libname, + importc: "llvm_destroy_optimizer".} +proc llvm_read_object_file*(lto: llvm_lto_t, input_filename: cstring): llvm_lto_status_t{. + cdecl, dynlib: libname, importc: "llvm_read_object_file".} +proc llvm_optimize_modules*(lto: llvm_lto_t, output_filename: cstring): llvm_lto_status_t{. + cdecl, dynlib: libname, importc: "llvm_optimize_modules".} + # lto.h +const + LTO_API_VERSION* = 3 # log2 of alignment + +type + lto_symbol_attributes* = enum + LTO_SYMBOL_ALIGNMENT_MASK = 0x0000001F, + LTO_SYMBOL_PERMISSIONS_MASK = 0x000000E0, + LTO_SYMBOL_PERMISSIONS_CODE = 0x000000A0, + LTO_SYMBOL_PERMISSIONS_DATA = 0x000000C0, + LTO_SYMBOL_PERMISSIONS_RODATA = 0x00000080, + LTO_SYMBOL_DEFINITION_MASK = 0x00000700, + LTO_SYMBOL_DEFINITION_REGULAR = 0x00000100, + LTO_SYMBOL_DEFINITION_TENTATIVE = 0x00000200, + LTO_SYMBOL_DEFINITION_WEAK = 0x00000300, + LTO_SYMBOL_DEFINITION_UNDEFINED = 0x00000400, + LTO_SYMBOL_DEFINITION_WEAKUNDEF = 0x00000500, + LTO_SYMBOL_SCOPE_MASK = 0x00003800, LTO_SYMBOL_SCOPE_INTERNAL = 0x00000800, + LTO_SYMBOL_SCOPE_HIDDEN = 0x00001000, + LTO_SYMBOL_SCOPE_PROTECTED = 0x00002000, + LTO_SYMBOL_SCOPE_DEFAULT = 0x00001800 + lto_debug_model* = enum + LTO_DEBUG_MODEL_NONE = 0, LTO_DEBUG_MODEL_DWARF = 1 + lto_codegen_model* = enum #* opaque reference to a loaded object module + LTO_CODEGEN_PIC_MODEL_STATIC = 0, LTO_CODEGEN_PIC_MODEL_DYNAMIC = 1, + LTO_CODEGEN_PIC_MODEL_DYNAMIC_NO_PIC = 2 + lto_module_t* = LTOModule #* opaque reference to a code generator + lto_code_gen_t* = LTOCodeGenerator #* + # * Returns a printable string. + # + +proc lto_get_version*(): cstring{.cdecl, dynlib: libname, + importc: "lto_get_version".} + #* + # * Returns the last error string or NULL if last operation was sucessful. + # +proc lto_get_error_message*(): cstring{.cdecl, dynlib: libname, + importc: "lto_get_error_message".} + #* + # * Checks if a file is a loadable object file. + # +proc lto_module_is_object_file*(path: cstring): bool{.cdecl, dynlib: libname, + importc: "lto_module_is_object_file".} + #* + # * Checks if a file is a loadable object compiled for requested target. + # +proc lto_module_is_object_file_for_target*(path: cstring, + target_triple_prefix: cstring): bool{.cdecl, dynlib: libname, + importc: "lto_module_is_object_file_for_target".} + #* + # * Checks if a buffer is a loadable object file. + # +proc lto_module_is_object_file_in_memory*(mem: pointer, len: size_t): bool{. + cdecl, dynlib: libname, importc: "lto_module_is_object_file_in_memory".} + #* + # * Checks if a buffer is a loadable object compiled for requested target. + # +proc lto_module_is_object_file_in_memory_for_target*(mem: pointer, len: size_t, + target_triple_prefix: cstring): bool{.cdecl, dynlib: libname, + importc: "lto_module_is_object_file_in_memory_for_target".} + #* + # * Loads an object file from disk. + # * Returns NULL on error (check lto_get_error_message() for details). + # +proc lto_module_create*(path: cstring): lto_module_t{.cdecl, dynlib: libname, + importc: "lto_module_create".} + #* + # * Loads an object file from memory. + # * Returns NULL on error (check lto_get_error_message() for details). + # +proc lto_module_create_from_memory*(mem: pointer, len: size_t): lto_module_t{. + cdecl, dynlib: libname, importc: "lto_module_create_from_memory".} + #* + # * Frees all memory internally allocated by the module. + # * Upon return the lto_module_t is no longer valid. + # +proc lto_module_dispose*(module: lto_module_t){.cdecl, dynlib: libname, + importc: "lto_module_dispose".} + #* + # * Returns triple string which the object module was compiled under. + # +proc lto_module_get_target_triple*(module: lto_module_t): cstring{.cdecl, + dynlib: libname, importc: "lto_module_get_target_triple".} + #* + # * Returns the number of symbols in the object module. + # +proc lto_module_get_num_symbols*(module: lto_module_t): dword{.cdecl, + dynlib: libname, importc: "lto_module_get_num_symbols".} + #* + # * Returns the name of the ith symbol in the object module. + # +proc lto_module_get_symbol_name*(module: lto_module_t, index: dword): cstring{. + cdecl, dynlib: libname, importc: "lto_module_get_symbol_name".} + #* + # * Returns the attributes of the ith symbol in the object module. + # +proc lto_module_get_symbol_attribute*(module: lto_module_t, index: dword): lto_symbol_attributes{. + cdecl, dynlib: libname, importc: "lto_module_get_symbol_attribute".} + #* + # * Instantiates a code generator. + # * Returns NULL on error (check lto_get_error_message() for details). + # +proc lto_codegen_create*(): lto_code_gen_t{.cdecl, dynlib: libname, + importc: "lto_codegen_create".} + #* + # * Frees all code generator and all memory it internally allocated. + # * Upon return the lto_code_gen_t is no longer valid. + # +proc lto_codegen_dispose*(para1: lto_code_gen_t){.cdecl, dynlib: libname, + importc: "lto_codegen_dispose".} + #* + # * Add an object module to the set of modules for which code will be generated. + # * Returns true on error (check lto_get_error_message() for details). + # +proc lto_codegen_add_module*(cg: lto_code_gen_t, module: lto_module_t): bool{. + cdecl, dynlib: libname, importc: "lto_codegen_add_module".} + #* + # * Sets if debug info should be generated. + # * Returns true on error (check lto_get_error_message() for details). + # +proc lto_codegen_set_debug_model*(cg: lto_code_gen_t, para2: lto_debug_model): bool{. + cdecl, dynlib: libname, importc: "lto_codegen_set_debug_model".} + #* + # * Sets which PIC code model to generated. + # * Returns true on error (check lto_get_error_message() for details). + # +proc lto_codegen_set_pic_model*(cg: lto_code_gen_t, para2: lto_codegen_model): bool{. + cdecl, dynlib: libname, importc: "lto_codegen_set_pic_model".} + #* + # * Sets the location of the "gcc" to run. If not set, libLTO will search for + # * "gcc" on the path. + # +proc lto_codegen_set_gcc_path*(cg: lto_code_gen_t, path: cstring){.cdecl, + dynlib: libname, importc: "lto_codegen_set_gcc_path".} + #* + # * Sets the location of the assembler tool to run. If not set, libLTO + # * will use gcc to invoke the assembler. + # +proc lto_codegen_set_assembler_path*(cg: lto_code_gen_t, path: cstring){.cdecl, + dynlib: libname, importc: "lto_codegen_set_assembler_path".} + #* + # * Adds to a list of all global symbols that must exist in the final + # * generated code. If a function is not listed, it might be + # * inlined into every usage and optimized away. + # +proc lto_codegen_add_must_preserve_symbol*(cg: lto_code_gen_t, symbol: cstring){. + cdecl, dynlib: libname, importc: "lto_codegen_add_must_preserve_symbol".} + #* + # * Writes a new object file at the specified path that contains the + # * merged contents of all modules added so far. + # * Returns true on error (check lto_get_error_message() for details). + # +proc lto_codegen_write_merged_modules*(cg: lto_code_gen_t, path: cstring): bool{. + cdecl, dynlib: libname, importc: "lto_codegen_write_merged_modules".} + #* + # * Generates code for all added modules into one native object file. + # * On sucess returns a pointer to a generated mach-o/ELF buffer and + # * length set to the buffer size. The buffer is owned by the + # * lto_code_gen_t and will be freed when lto_codegen_dispose() + # * is called, or lto_codegen_compile() is called again. + # * On failure, returns NULL (check lto_get_error_message() for details). + # +proc lto_codegen_compile*(cg: lto_code_gen_t, len: var int): pointer{.cdecl, + dynlib: libname, importc: "lto_codegen_compile".} + #* + # * Sets options to help debug codegen bugs. + # +proc lto_codegen_debug_options*(cg: lto_code_gen_t, para2: cstring){.cdecl, + dynlib: libname, importc: "lto_codegen_debug_options".} +# implementation |