Core.h revision 212904
1193323Sed/*===-- llvm-c/Core.h - Core Library C Interface ------------------*- C -*-===*\ 2193323Sed|* *| 3193323Sed|* The LLVM Compiler Infrastructure *| 4193323Sed|* *| 5193323Sed|* This file is distributed under the University of Illinois Open Source *| 6193323Sed|* License. See LICENSE.TXT for details. *| 7193323Sed|* *| 8193323Sed|*===----------------------------------------------------------------------===*| 9193323Sed|* *| 10193323Sed|* This header declares the C interface to libLLVMCore.a, which implements *| 11193323Sed|* the LLVM intermediate representation. *| 12193323Sed|* *| 13193323Sed|* LLVM uses a polymorphic type hierarchy which C cannot represent, therefore *| 14193323Sed|* parameters must be passed as base types. Despite the declared types, most *| 15193323Sed|* of the functions provided operate only on branches of the type hierarchy. *| 16193323Sed|* The declared parameter names are descriptive and specify which type is *| 17193323Sed|* required. Additionally, each type hierarchy is documented along with the *| 18193323Sed|* functions that operate upon it. For more detail, refer to LLVM's C++ code. *| 19193323Sed|* If in doubt, refer to Core.cpp, which performs paramter downcasts in the *| 20193323Sed|* form unwrap<RequiredType>(Param). *| 21193323Sed|* *| 22193323Sed|* Many exotic languages can interoperate with C code but have a harder time *| 23193323Sed|* with C++ due to name mangling. So in addition to C, this interface enables *| 24193323Sed|* tools written in such languages. *| 25193323Sed|* *| 26193323Sed|* When included into a C++ source file, also declares 'wrap' and 'unwrap' *| 27193323Sed|* helpers to perform opaque reference<-->pointer conversions. These helpers *| 28193323Sed|* are shorter and more tightly typed than writing the casts by hand when *| 29193323Sed|* authoring bindings. In assert builds, they will do runtime type checking. *| 30193323Sed|* *| 31193323Sed\*===----------------------------------------------------------------------===*/ 32193323Sed 33193323Sed#ifndef LLVM_C_CORE_H 34193323Sed#define LLVM_C_CORE_H 35193323Sed 36198892Srdivacky#include "llvm/System/DataTypes.h" 37198090Srdivacky 38193323Sed#ifdef __cplusplus 39193323Sed 40193323Sed/* Need these includes to support the LLVM 'cast' template for the C++ 'wrap' 41193323Sed and 'unwrap' conversion functions. */ 42193323Sed#include "llvm/Module.h" 43193323Sed#include "llvm/Support/IRBuilder.h" 44193323Sed 45193323Sedextern "C" { 46193323Sed#endif 47193323Sed 48193323Sed 49202375Srdivackytypedef int LLVMBool; 50202375Srdivacky 51193323Sed/* Opaque types. */ 52193323Sed 53193323Sed/** 54195340Sed * The top-level container for all LLVM global data. See the LLVMContext class. 55195340Sed */ 56198090Srdivackytypedef struct LLVMOpaqueContext *LLVMContextRef; 57195340Sed 58195340Sed/** 59193323Sed * The top-level container for all other LLVM Intermediate Representation (IR) 60193323Sed * objects. See the llvm::Module class. 61193323Sed */ 62193323Sedtypedef struct LLVMOpaqueModule *LLVMModuleRef; 63193323Sed 64193323Sed/** 65193323Sed * Each value in the LLVM IR has a type, an LLVMTypeRef. See the llvm::Type 66193323Sed * class. 67193323Sed */ 68193323Sedtypedef struct LLVMOpaqueType *LLVMTypeRef; 69193323Sed 70193323Sed/** 71193323Sed * When building recursive types using LLVMRefineType, LLVMTypeRef values may 72193323Sed * become invalid; use LLVMTypeHandleRef to resolve this problem. See the 73193323Sed * llvm::AbstractTypeHolder class. 74193323Sed */ 75193323Sedtypedef struct LLVMOpaqueTypeHandle *LLVMTypeHandleRef; 76193323Sed 77193323Sedtypedef struct LLVMOpaqueValue *LLVMValueRef; 78193323Sedtypedef struct LLVMOpaqueBasicBlock *LLVMBasicBlockRef; 79193323Sedtypedef struct LLVMOpaqueBuilder *LLVMBuilderRef; 80193323Sed 81203954Srdivacky/* Interface used to provide a module to JIT or interpreter. This is now just a 82203954Srdivacky * synonym for llvm::Module, but we have to keep using the different type to 83203954Srdivacky * keep binary compatibility. 84193323Sed */ 85193323Sedtypedef struct LLVMOpaqueModuleProvider *LLVMModuleProviderRef; 86193323Sed 87193323Sed/* Used to provide a module to JIT or interpreter. 88193323Sed * See the llvm::MemoryBuffer class. 89193323Sed */ 90193323Sedtypedef struct LLVMOpaqueMemoryBuffer *LLVMMemoryBufferRef; 91193323Sed 92193323Sed/** See the llvm::PassManagerBase class. */ 93193323Sedtypedef struct LLVMOpaquePassManager *LLVMPassManagerRef; 94193323Sed 95204642Srdivacky/** Used to get the users and usees of a Value. See the llvm::Use class. */ 96204642Srdivackytypedef struct LLVMOpaqueUse *LLVMUseRef; 97198090Srdivacky 98193323Sedtypedef enum { 99193323Sed LLVMZExtAttribute = 1<<0, 100193323Sed LLVMSExtAttribute = 1<<1, 101193323Sed LLVMNoReturnAttribute = 1<<2, 102193323Sed LLVMInRegAttribute = 1<<3, 103193323Sed LLVMStructRetAttribute = 1<<4, 104193323Sed LLVMNoUnwindAttribute = 1<<5, 105193323Sed LLVMNoAliasAttribute = 1<<6, 106193323Sed LLVMByValAttribute = 1<<7, 107193323Sed LLVMNestAttribute = 1<<8, 108193323Sed LLVMReadNoneAttribute = 1<<9, 109198090Srdivacky LLVMReadOnlyAttribute = 1<<10, 110198090Srdivacky LLVMNoInlineAttribute = 1<<11, 111198090Srdivacky LLVMAlwaysInlineAttribute = 1<<12, 112198090Srdivacky LLVMOptimizeForSizeAttribute = 1<<13, 113198090Srdivacky LLVMStackProtectAttribute = 1<<14, 114198090Srdivacky LLVMStackProtectReqAttribute = 1<<15, 115204792Srdivacky LLVMAlignment = 31<<16, 116198090Srdivacky LLVMNoCaptureAttribute = 1<<21, 117198090Srdivacky LLVMNoRedZoneAttribute = 1<<22, 118198090Srdivacky LLVMNoImplicitFloatAttribute = 1<<23, 119203954Srdivacky LLVMNakedAttribute = 1<<24, 120204792Srdivacky LLVMInlineHintAttribute = 1<<25, 121204792Srdivacky LLVMStackAlignment = 7<<26 122193323Sed} LLVMAttribute; 123193323Sed 124193323Sedtypedef enum { 125203954Srdivacky /* Terminator Instructions */ 126198090Srdivacky LLVMRet = 1, 127198090Srdivacky LLVMBr = 2, 128198090Srdivacky LLVMSwitch = 3, 129203954Srdivacky LLVMIndirectBr = 4, 130203954Srdivacky LLVMInvoke = 5, 131203954Srdivacky LLVMUnwind = 6, 132203954Srdivacky LLVMUnreachable = 7, 133203954Srdivacky 134203954Srdivacky /* Standard Binary Operators */ 135203954Srdivacky LLVMAdd = 8, 136203954Srdivacky LLVMFAdd = 9, 137203954Srdivacky LLVMSub = 10, 138203954Srdivacky LLVMFSub = 11, 139203954Srdivacky LLVMMul = 12, 140203954Srdivacky LLVMFMul = 13, 141203954Srdivacky LLVMUDiv = 14, 142203954Srdivacky LLVMSDiv = 15, 143203954Srdivacky LLVMFDiv = 16, 144203954Srdivacky LLVMURem = 17, 145203954Srdivacky LLVMSRem = 18, 146203954Srdivacky LLVMFRem = 19, 147203954Srdivacky 148203954Srdivacky /* Logical Operators */ 149203954Srdivacky LLVMShl = 20, 150203954Srdivacky LLVMLShr = 21, 151203954Srdivacky LLVMAShr = 22, 152203954Srdivacky LLVMAnd = 23, 153203954Srdivacky LLVMOr = 24, 154203954Srdivacky LLVMXor = 25, 155203954Srdivacky 156203954Srdivacky /* Memory Operators */ 157203954Srdivacky LLVMAlloca = 26, 158203954Srdivacky LLVMLoad = 27, 159203954Srdivacky LLVMStore = 28, 160203954Srdivacky LLVMGetElementPtr = 29, 161203954Srdivacky 162203954Srdivacky /* Cast Operators */ 163203954Srdivacky LLVMTrunc = 30, 164203954Srdivacky LLVMZExt = 31, 165203954Srdivacky LLVMSExt = 32, 166203954Srdivacky LLVMFPToUI = 33, 167203954Srdivacky LLVMFPToSI = 34, 168203954Srdivacky LLVMUIToFP = 35, 169203954Srdivacky LLVMSIToFP = 36, 170203954Srdivacky LLVMFPTrunc = 37, 171203954Srdivacky LLVMFPExt = 38, 172203954Srdivacky LLVMPtrToInt = 39, 173203954Srdivacky LLVMIntToPtr = 40, 174203954Srdivacky LLVMBitCast = 41, 175203954Srdivacky 176203954Srdivacky /* Other Operators */ 177203954Srdivacky LLVMICmp = 42, 178203954Srdivacky LLVMFCmp = 43, 179203954Srdivacky LLVMPHI = 44, 180203954Srdivacky LLVMCall = 45, 181203954Srdivacky LLVMSelect = 46, 182203954Srdivacky /* UserOp1 */ 183203954Srdivacky /* UserOp2 */ 184203954Srdivacky LLVMVAArg = 49, 185203954Srdivacky LLVMExtractElement = 50, 186203954Srdivacky LLVMInsertElement = 51, 187203954Srdivacky LLVMShuffleVector = 52, 188203954Srdivacky LLVMExtractValue = 53, 189203954Srdivacky LLVMInsertValue = 54 190198090Srdivacky} LLVMOpcode; 191198090Srdivacky 192198090Srdivackytypedef enum { 193193323Sed LLVMVoidTypeKind, /**< type with no size */ 194193323Sed LLVMFloatTypeKind, /**< 32 bit floating point type */ 195193323Sed LLVMDoubleTypeKind, /**< 64 bit floating point type */ 196193323Sed LLVMX86_FP80TypeKind, /**< 80 bit floating point type (X87) */ 197193323Sed LLVMFP128TypeKind, /**< 128 bit floating point type (112-bit mantissa)*/ 198193323Sed LLVMPPC_FP128TypeKind, /**< 128 bit floating point type (two 64-bits) */ 199193323Sed LLVMLabelTypeKind, /**< Labels */ 200193323Sed LLVMIntegerTypeKind, /**< Arbitrary bit width integers */ 201193323Sed LLVMFunctionTypeKind, /**< Functions */ 202193323Sed LLVMStructTypeKind, /**< Structures */ 203193323Sed LLVMArrayTypeKind, /**< Arrays */ 204193323Sed LLVMPointerTypeKind, /**< Pointers */ 205193323Sed LLVMOpaqueTypeKind, /**< Opaque: type with unknown structure */ 206198090Srdivacky LLVMVectorTypeKind, /**< SIMD 'packed' format, or other vector type */ 207212904Sdim LLVMMetadataTypeKind /**< Metadata */ 208193323Sed} LLVMTypeKind; 209193323Sed 210193323Sedtypedef enum { 211193323Sed LLVMExternalLinkage, /**< Externally visible function */ 212193323Sed LLVMAvailableExternallyLinkage, 213193323Sed LLVMLinkOnceAnyLinkage, /**< Keep one copy of function when linking (inline)*/ 214193323Sed LLVMLinkOnceODRLinkage, /**< Same, but only replaced by something 215193323Sed equivalent. */ 216193323Sed LLVMWeakAnyLinkage, /**< Keep one copy of function when linking (weak) */ 217193323Sed LLVMWeakODRLinkage, /**< Same, but only replaced by something 218193323Sed equivalent. */ 219193323Sed LLVMAppendingLinkage, /**< Special purpose, only applies to global arrays */ 220193323Sed LLVMInternalLinkage, /**< Rename collisions when linking (static 221193323Sed functions) */ 222193323Sed LLVMPrivateLinkage, /**< Like Internal, but omit from symbol table */ 223193323Sed LLVMDLLImportLinkage, /**< Function to be imported from DLL */ 224193323Sed LLVMDLLExportLinkage, /**< Function to be accessible from DLL */ 225193323Sed LLVMExternalWeakLinkage,/**< ExternalWeak linkage description */ 226203954Srdivacky LLVMGhostLinkage, /**< Obsolete */ 227198090Srdivacky LLVMCommonLinkage, /**< Tentative definitions */ 228210299Sed LLVMLinkerPrivateLinkage, /**< Like Private, but linker removes. */ 229212904Sdim LLVMLinkerPrivateWeakLinkage, /**< Like LinkerPrivate, but is weak. */ 230212904Sdim LLVMLinkerPrivateWeakDefAutoLinkage /**< Like LinkerPrivateWeak, but possibly 231212904Sdim hidden. */ 232193323Sed} LLVMLinkage; 233193323Sed 234193323Sedtypedef enum { 235193323Sed LLVMDefaultVisibility, /**< The GV is visible */ 236193323Sed LLVMHiddenVisibility, /**< The GV is hidden */ 237193323Sed LLVMProtectedVisibility /**< The GV is protected */ 238193323Sed} LLVMVisibility; 239193323Sed 240193323Sedtypedef enum { 241193323Sed LLVMCCallConv = 0, 242193323Sed LLVMFastCallConv = 8, 243193323Sed LLVMColdCallConv = 9, 244193323Sed LLVMX86StdcallCallConv = 64, 245193323Sed LLVMX86FastcallCallConv = 65 246193323Sed} LLVMCallConv; 247193323Sed 248193323Sedtypedef enum { 249193323Sed LLVMIntEQ = 32, /**< equal */ 250193323Sed LLVMIntNE, /**< not equal */ 251193323Sed LLVMIntUGT, /**< unsigned greater than */ 252193323Sed LLVMIntUGE, /**< unsigned greater or equal */ 253193323Sed LLVMIntULT, /**< unsigned less than */ 254193323Sed LLVMIntULE, /**< unsigned less or equal */ 255193323Sed LLVMIntSGT, /**< signed greater than */ 256193323Sed LLVMIntSGE, /**< signed greater or equal */ 257193323Sed LLVMIntSLT, /**< signed less than */ 258193323Sed LLVMIntSLE /**< signed less or equal */ 259193323Sed} LLVMIntPredicate; 260193323Sed 261193323Sedtypedef enum { 262193323Sed LLVMRealPredicateFalse, /**< Always false (always folded) */ 263193323Sed LLVMRealOEQ, /**< True if ordered and equal */ 264193323Sed LLVMRealOGT, /**< True if ordered and greater than */ 265193323Sed LLVMRealOGE, /**< True if ordered and greater than or equal */ 266193323Sed LLVMRealOLT, /**< True if ordered and less than */ 267193323Sed LLVMRealOLE, /**< True if ordered and less than or equal */ 268193323Sed LLVMRealONE, /**< True if ordered and operands are unequal */ 269193323Sed LLVMRealORD, /**< True if ordered (no nans) */ 270193323Sed LLVMRealUNO, /**< True if unordered: isnan(X) | isnan(Y) */ 271193323Sed LLVMRealUEQ, /**< True if unordered or equal */ 272193323Sed LLVMRealUGT, /**< True if unordered or greater than */ 273193323Sed LLVMRealUGE, /**< True if unordered, greater than, or equal */ 274193323Sed LLVMRealULT, /**< True if unordered or less than */ 275193323Sed LLVMRealULE, /**< True if unordered, less than, or equal */ 276193323Sed LLVMRealUNE, /**< True if unordered or not equal */ 277193323Sed LLVMRealPredicateTrue /**< Always true (always folded) */ 278193323Sed} LLVMRealPredicate; 279193323Sed 280193323Sed 281193323Sed/*===-- Error handling ----------------------------------------------------===*/ 282193323Sed 283193323Sedvoid LLVMDisposeMessage(char *Message); 284193323Sed 285193323Sed 286204642Srdivacky/*===-- Contexts ----------------------------------------------------------===*/ 287193323Sed 288195340Sed/* Create and destroy contexts. */ 289198090SrdivackyLLVMContextRef LLVMContextCreate(void); 290198090SrdivackyLLVMContextRef LLVMGetGlobalContext(void); 291195340Sedvoid LLVMContextDispose(LLVMContextRef C); 292195340Sed 293204642Srdivackyunsigned LLVMGetMDKindIDInContext(LLVMContextRef C, const char* Name, 294204642Srdivacky unsigned SLen); 295204642Srdivackyunsigned LLVMGetMDKindID(const char* Name, unsigned SLen); 296204642Srdivacky 297204642Srdivacky/*===-- Modules -----------------------------------------------------------===*/ 298204642Srdivacky 299193323Sed/* Create and destroy modules. */ 300193323Sed/** See llvm::Module::Module. */ 301193323SedLLVMModuleRef LLVMModuleCreateWithName(const char *ModuleID); 302195340SedLLVMModuleRef LLVMModuleCreateWithNameInContext(const char *ModuleID, 303195340Sed LLVMContextRef C); 304193323Sed 305193323Sed/** See llvm::Module::~Module. */ 306193323Sedvoid LLVMDisposeModule(LLVMModuleRef M); 307193323Sed 308193323Sed/** Data layout. See Module::getDataLayout. */ 309193323Sedconst char *LLVMGetDataLayout(LLVMModuleRef M); 310193323Sedvoid LLVMSetDataLayout(LLVMModuleRef M, const char *Triple); 311193323Sed 312193323Sed/** Target triple. See Module::getTargetTriple. */ 313193323Sedconst char *LLVMGetTarget(LLVMModuleRef M); 314193323Sedvoid LLVMSetTarget(LLVMModuleRef M, const char *Triple); 315193323Sed 316193323Sed/** See Module::addTypeName. */ 317202375SrdivackyLLVMBool LLVMAddTypeName(LLVMModuleRef M, const char *Name, LLVMTypeRef Ty); 318193323Sedvoid LLVMDeleteTypeName(LLVMModuleRef M, const char *Name); 319198090SrdivackyLLVMTypeRef LLVMGetTypeByName(LLVMModuleRef M, const char *Name); 320193323Sed 321193323Sed/** See Module::dump. */ 322193323Sedvoid LLVMDumpModule(LLVMModuleRef M); 323193323Sed 324207618Srdivacky/** See Module::setModuleInlineAsm. */ 325207618Srdivackyvoid LLVMSetModuleInlineAsm(LLVMModuleRef M, const char *Asm); 326193323Sed 327193323Sed/*===-- Types -------------------------------------------------------------===*/ 328193323Sed 329193323Sed/* LLVM types conform to the following hierarchy: 330193323Sed * 331193323Sed * types: 332193323Sed * integer type 333193323Sed * real type 334193323Sed * function type 335193323Sed * sequence types: 336193323Sed * array type 337193323Sed * pointer type 338193323Sed * vector type 339193323Sed * void type 340193323Sed * label type 341193323Sed * opaque type 342193323Sed */ 343193323Sed 344193323Sed/** See llvm::LLVMTypeKind::getTypeID. */ 345193323SedLLVMTypeKind LLVMGetTypeKind(LLVMTypeRef Ty); 346193323Sed 347198090Srdivacky/** See llvm::LLVMType::getContext. */ 348198090SrdivackyLLVMContextRef LLVMGetTypeContext(LLVMTypeRef Ty); 349198090Srdivacky 350193323Sed/* Operations on integer types */ 351198090SrdivackyLLVMTypeRef LLVMInt1TypeInContext(LLVMContextRef C); 352198090SrdivackyLLVMTypeRef LLVMInt8TypeInContext(LLVMContextRef C); 353198090SrdivackyLLVMTypeRef LLVMInt16TypeInContext(LLVMContextRef C); 354198090SrdivackyLLVMTypeRef LLVMInt32TypeInContext(LLVMContextRef C); 355198090SrdivackyLLVMTypeRef LLVMInt64TypeInContext(LLVMContextRef C); 356198090SrdivackyLLVMTypeRef LLVMIntTypeInContext(LLVMContextRef C, unsigned NumBits); 357198090Srdivacky 358193323SedLLVMTypeRef LLVMInt1Type(void); 359193323SedLLVMTypeRef LLVMInt8Type(void); 360193323SedLLVMTypeRef LLVMInt16Type(void); 361193323SedLLVMTypeRef LLVMInt32Type(void); 362193323SedLLVMTypeRef LLVMInt64Type(void); 363193323SedLLVMTypeRef LLVMIntType(unsigned NumBits); 364193323Sedunsigned LLVMGetIntTypeWidth(LLVMTypeRef IntegerTy); 365193323Sed 366193323Sed/* Operations on real types */ 367198090SrdivackyLLVMTypeRef LLVMFloatTypeInContext(LLVMContextRef C); 368198090SrdivackyLLVMTypeRef LLVMDoubleTypeInContext(LLVMContextRef C); 369198090SrdivackyLLVMTypeRef LLVMX86FP80TypeInContext(LLVMContextRef C); 370198090SrdivackyLLVMTypeRef LLVMFP128TypeInContext(LLVMContextRef C); 371198090SrdivackyLLVMTypeRef LLVMPPCFP128TypeInContext(LLVMContextRef C); 372198090Srdivacky 373193323SedLLVMTypeRef LLVMFloatType(void); 374193323SedLLVMTypeRef LLVMDoubleType(void); 375193323SedLLVMTypeRef LLVMX86FP80Type(void); 376193323SedLLVMTypeRef LLVMFP128Type(void); 377193323SedLLVMTypeRef LLVMPPCFP128Type(void); 378193323Sed 379193323Sed/* Operations on function types */ 380193323SedLLVMTypeRef LLVMFunctionType(LLVMTypeRef ReturnType, 381193323Sed LLVMTypeRef *ParamTypes, unsigned ParamCount, 382202375Srdivacky LLVMBool IsVarArg); 383202375SrdivackyLLVMBool LLVMIsFunctionVarArg(LLVMTypeRef FunctionTy); 384193323SedLLVMTypeRef LLVMGetReturnType(LLVMTypeRef FunctionTy); 385193323Sedunsigned LLVMCountParamTypes(LLVMTypeRef FunctionTy); 386193323Sedvoid LLVMGetParamTypes(LLVMTypeRef FunctionTy, LLVMTypeRef *Dest); 387193323Sed 388193323Sed/* Operations on struct types */ 389198090SrdivackyLLVMTypeRef LLVMStructTypeInContext(LLVMContextRef C, LLVMTypeRef *ElementTypes, 390202375Srdivacky unsigned ElementCount, LLVMBool Packed); 391193323SedLLVMTypeRef LLVMStructType(LLVMTypeRef *ElementTypes, unsigned ElementCount, 392202375Srdivacky LLVMBool Packed); 393193323Sedunsigned LLVMCountStructElementTypes(LLVMTypeRef StructTy); 394193323Sedvoid LLVMGetStructElementTypes(LLVMTypeRef StructTy, LLVMTypeRef *Dest); 395202375SrdivackyLLVMBool LLVMIsPackedStruct(LLVMTypeRef StructTy); 396193323Sed 397193323Sed/* Operations on array, pointer, and vector types (sequence types) */ 398193323SedLLVMTypeRef LLVMArrayType(LLVMTypeRef ElementType, unsigned ElementCount); 399193323SedLLVMTypeRef LLVMPointerType(LLVMTypeRef ElementType, unsigned AddressSpace); 400193323SedLLVMTypeRef LLVMVectorType(LLVMTypeRef ElementType, unsigned ElementCount); 401193323Sed 402193323SedLLVMTypeRef LLVMGetElementType(LLVMTypeRef Ty); 403193323Sedunsigned LLVMGetArrayLength(LLVMTypeRef ArrayTy); 404193323Sedunsigned LLVMGetPointerAddressSpace(LLVMTypeRef PointerTy); 405193323Sedunsigned LLVMGetVectorSize(LLVMTypeRef VectorTy); 406193323Sed 407193323Sed/* Operations on other types */ 408198090SrdivackyLLVMTypeRef LLVMVoidTypeInContext(LLVMContextRef C); 409198090SrdivackyLLVMTypeRef LLVMLabelTypeInContext(LLVMContextRef C); 410198090SrdivackyLLVMTypeRef LLVMOpaqueTypeInContext(LLVMContextRef C); 411198090Srdivacky 412193323SedLLVMTypeRef LLVMVoidType(void); 413193323SedLLVMTypeRef LLVMLabelType(void); 414193323SedLLVMTypeRef LLVMOpaqueType(void); 415193323Sed 416193323Sed/* Operations on type handles */ 417193323SedLLVMTypeHandleRef LLVMCreateTypeHandle(LLVMTypeRef PotentiallyAbstractTy); 418193323Sedvoid LLVMRefineType(LLVMTypeRef AbstractTy, LLVMTypeRef ConcreteTy); 419193323SedLLVMTypeRef LLVMResolveTypeHandle(LLVMTypeHandleRef TypeHandle); 420193323Sedvoid LLVMDisposeTypeHandle(LLVMTypeHandleRef TypeHandle); 421193323Sed 422193323Sed 423193323Sed/*===-- Values ------------------------------------------------------------===*/ 424193323Sed 425193323Sed/* The bulk of LLVM's object model consists of values, which comprise a very 426193323Sed * rich type hierarchy. 427193323Sed */ 428193323Sed 429193323Sed#define LLVM_FOR_EACH_VALUE_SUBCLASS(macro) \ 430193323Sed macro(Argument) \ 431193323Sed macro(BasicBlock) \ 432193323Sed macro(InlineAsm) \ 433193323Sed macro(User) \ 434193323Sed macro(Constant) \ 435193323Sed macro(ConstantAggregateZero) \ 436193323Sed macro(ConstantArray) \ 437193323Sed macro(ConstantExpr) \ 438193323Sed macro(ConstantFP) \ 439193323Sed macro(ConstantInt) \ 440193323Sed macro(ConstantPointerNull) \ 441193323Sed macro(ConstantStruct) \ 442193323Sed macro(ConstantVector) \ 443193323Sed macro(GlobalValue) \ 444193323Sed macro(Function) \ 445193323Sed macro(GlobalAlias) \ 446193323Sed macro(GlobalVariable) \ 447193323Sed macro(UndefValue) \ 448193323Sed macro(Instruction) \ 449193323Sed macro(BinaryOperator) \ 450193323Sed macro(CallInst) \ 451193323Sed macro(IntrinsicInst) \ 452193323Sed macro(DbgInfoIntrinsic) \ 453193323Sed macro(DbgDeclareInst) \ 454193323Sed macro(EHSelectorInst) \ 455193323Sed macro(MemIntrinsic) \ 456193323Sed macro(MemCpyInst) \ 457193323Sed macro(MemMoveInst) \ 458193323Sed macro(MemSetInst) \ 459193323Sed macro(CmpInst) \ 460193323Sed macro(FCmpInst) \ 461193323Sed macro(ICmpInst) \ 462193323Sed macro(ExtractElementInst) \ 463193323Sed macro(GetElementPtrInst) \ 464193323Sed macro(InsertElementInst) \ 465193323Sed macro(InsertValueInst) \ 466193323Sed macro(PHINode) \ 467193323Sed macro(SelectInst) \ 468193323Sed macro(ShuffleVectorInst) \ 469193323Sed macro(StoreInst) \ 470193323Sed macro(TerminatorInst) \ 471193323Sed macro(BranchInst) \ 472193323Sed macro(InvokeInst) \ 473193323Sed macro(ReturnInst) \ 474193323Sed macro(SwitchInst) \ 475193323Sed macro(UnreachableInst) \ 476193323Sed macro(UnwindInst) \ 477193323Sed macro(UnaryInstruction) \ 478198892Srdivacky macro(AllocaInst) \ 479193323Sed macro(CastInst) \ 480193323Sed macro(BitCastInst) \ 481193323Sed macro(FPExtInst) \ 482193323Sed macro(FPToSIInst) \ 483193323Sed macro(FPToUIInst) \ 484193323Sed macro(FPTruncInst) \ 485193323Sed macro(IntToPtrInst) \ 486193323Sed macro(PtrToIntInst) \ 487193323Sed macro(SExtInst) \ 488193323Sed macro(SIToFPInst) \ 489193323Sed macro(TruncInst) \ 490193323Sed macro(UIToFPInst) \ 491193323Sed macro(ZExtInst) \ 492193323Sed macro(ExtractValueInst) \ 493193323Sed macro(LoadInst) \ 494193323Sed macro(VAArgInst) 495193323Sed 496193323Sed/* Operations on all values */ 497193323SedLLVMTypeRef LLVMTypeOf(LLVMValueRef Val); 498193323Sedconst char *LLVMGetValueName(LLVMValueRef Val); 499193323Sedvoid LLVMSetValueName(LLVMValueRef Val, const char *Name); 500193323Sedvoid LLVMDumpValue(LLVMValueRef Val); 501198090Srdivackyvoid LLVMReplaceAllUsesWith(LLVMValueRef OldVal, LLVMValueRef NewVal); 502204642Srdivackyint LLVMHasMetadata(LLVMValueRef Val); 503204642SrdivackyLLVMValueRef LLVMGetMetadata(LLVMValueRef Val, unsigned KindID); 504204642Srdivackyvoid LLVMSetMetadata(LLVMValueRef Val, unsigned KindID, LLVMValueRef Node); 505193323Sed 506193323Sed/* Conversion functions. Return the input value if it is an instance of the 507193323Sed specified class, otherwise NULL. See llvm::dyn_cast_or_null<>. */ 508193323Sed#define LLVM_DECLARE_VALUE_CAST(name) \ 509193323Sed LLVMValueRef LLVMIsA##name(LLVMValueRef Val); 510193323SedLLVM_FOR_EACH_VALUE_SUBCLASS(LLVM_DECLARE_VALUE_CAST) 511193323Sed 512198090Srdivacky/* Operations on Uses */ 513204642SrdivackyLLVMUseRef LLVMGetFirstUse(LLVMValueRef Val); 514204642SrdivackyLLVMUseRef LLVMGetNextUse(LLVMUseRef U); 515204642SrdivackyLLVMValueRef LLVMGetUser(LLVMUseRef U); 516204642SrdivackyLLVMValueRef LLVMGetUsedValue(LLVMUseRef U); 517198090Srdivacky 518198090Srdivacky/* Operations on Users */ 519198090SrdivackyLLVMValueRef LLVMGetOperand(LLVMValueRef Val, unsigned Index); 520212904Sdimvoid LLVMSetOperand(LLVMValueRef User, unsigned Index, LLVMValueRef Val); 521212904Sdimint LLVMGetNumOperands(LLVMValueRef Val); 522198090Srdivacky 523193323Sed/* Operations on constants of any type */ 524193323SedLLVMValueRef LLVMConstNull(LLVMTypeRef Ty); /* all zeroes */ 525193323SedLLVMValueRef LLVMConstAllOnes(LLVMTypeRef Ty); /* only for int/vector */ 526193323SedLLVMValueRef LLVMGetUndef(LLVMTypeRef Ty); 527202375SrdivackyLLVMBool LLVMIsConstant(LLVMValueRef Val); 528202375SrdivackyLLVMBool LLVMIsNull(LLVMValueRef Val); 529202375SrdivackyLLVMBool LLVMIsUndef(LLVMValueRef Val); 530198090SrdivackyLLVMValueRef LLVMConstPointerNull(LLVMTypeRef Ty); 531193323Sed 532204642Srdivacky/* Operations on metadata */ 533204642SrdivackyLLVMValueRef LLVMMDStringInContext(LLVMContextRef C, const char *Str, 534204642Srdivacky unsigned SLen); 535204642SrdivackyLLVMValueRef LLVMMDString(const char *Str, unsigned SLen); 536204642SrdivackyLLVMValueRef LLVMMDNodeInContext(LLVMContextRef C, LLVMValueRef *Vals, 537204642Srdivacky unsigned Count); 538204642SrdivackyLLVMValueRef LLVMMDNode(LLVMValueRef *Vals, unsigned Count); 539204642Srdivacky 540193323Sed/* Operations on scalar constants */ 541193323SedLLVMValueRef LLVMConstInt(LLVMTypeRef IntTy, unsigned long long N, 542202375Srdivacky LLVMBool SignExtend); 543198090SrdivackyLLVMValueRef LLVMConstIntOfString(LLVMTypeRef IntTy, const char *Text, 544198090Srdivacky uint8_t Radix); 545198090SrdivackyLLVMValueRef LLVMConstIntOfStringAndSize(LLVMTypeRef IntTy, const char *Text, 546198090Srdivacky unsigned SLen, uint8_t Radix); 547193323SedLLVMValueRef LLVMConstReal(LLVMTypeRef RealTy, double N); 548193323SedLLVMValueRef LLVMConstRealOfString(LLVMTypeRef RealTy, const char *Text); 549198090SrdivackyLLVMValueRef LLVMConstRealOfStringAndSize(LLVMTypeRef RealTy, const char *Text, 550198090Srdivacky unsigned SLen); 551198090Srdivackyunsigned long long LLVMConstIntGetZExtValue(LLVMValueRef ConstantVal); 552198090Srdivackylong long LLVMConstIntGetSExtValue(LLVMValueRef ConstantVal); 553193323Sed 554198090Srdivacky 555193323Sed/* Operations on composite constants */ 556198090SrdivackyLLVMValueRef LLVMConstStringInContext(LLVMContextRef C, const char *Str, 557202375Srdivacky unsigned Length, LLVMBool DontNullTerminate); 558198090SrdivackyLLVMValueRef LLVMConstStructInContext(LLVMContextRef C, 559198090Srdivacky LLVMValueRef *ConstantVals, 560202375Srdivacky unsigned Count, LLVMBool Packed); 561198090Srdivacky 562193323SedLLVMValueRef LLVMConstString(const char *Str, unsigned Length, 563202375Srdivacky LLVMBool DontNullTerminate); 564193323SedLLVMValueRef LLVMConstArray(LLVMTypeRef ElementTy, 565193323Sed LLVMValueRef *ConstantVals, unsigned Length); 566193323SedLLVMValueRef LLVMConstStruct(LLVMValueRef *ConstantVals, unsigned Count, 567202375Srdivacky LLVMBool Packed); 568193323SedLLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals, unsigned Size); 569193323Sed 570193323Sed/* Constant expressions */ 571198090SrdivackyLLVMOpcode LLVMGetConstOpcode(LLVMValueRef ConstantVal); 572198090SrdivackyLLVMValueRef LLVMAlignOf(LLVMTypeRef Ty); 573193323SedLLVMValueRef LLVMSizeOf(LLVMTypeRef Ty); 574193323SedLLVMValueRef LLVMConstNeg(LLVMValueRef ConstantVal); 575204642SrdivackyLLVMValueRef LLVMConstNSWNeg(LLVMValueRef ConstantVal); 576204642SrdivackyLLVMValueRef LLVMConstNUWNeg(LLVMValueRef ConstantVal); 577198090SrdivackyLLVMValueRef LLVMConstFNeg(LLVMValueRef ConstantVal); 578193323SedLLVMValueRef LLVMConstNot(LLVMValueRef ConstantVal); 579193323SedLLVMValueRef LLVMConstAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); 580198090SrdivackyLLVMValueRef LLVMConstNSWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); 581204642SrdivackyLLVMValueRef LLVMConstNUWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); 582198090SrdivackyLLVMValueRef LLVMConstFAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); 583193323SedLLVMValueRef LLVMConstSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); 584204642SrdivackyLLVMValueRef LLVMConstNSWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); 585204642SrdivackyLLVMValueRef LLVMConstNUWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); 586198090SrdivackyLLVMValueRef LLVMConstFSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); 587193323SedLLVMValueRef LLVMConstMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); 588204642SrdivackyLLVMValueRef LLVMConstNSWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); 589204642SrdivackyLLVMValueRef LLVMConstNUWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); 590198090SrdivackyLLVMValueRef LLVMConstFMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); 591193323SedLLVMValueRef LLVMConstUDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); 592193323SedLLVMValueRef LLVMConstSDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); 593198090SrdivackyLLVMValueRef LLVMConstExactSDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); 594193323SedLLVMValueRef LLVMConstFDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); 595193323SedLLVMValueRef LLVMConstURem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); 596193323SedLLVMValueRef LLVMConstSRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); 597193323SedLLVMValueRef LLVMConstFRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); 598193323SedLLVMValueRef LLVMConstAnd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); 599193323SedLLVMValueRef LLVMConstOr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); 600193323SedLLVMValueRef LLVMConstXor(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); 601193323SedLLVMValueRef LLVMConstICmp(LLVMIntPredicate Predicate, 602193323Sed LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); 603193323SedLLVMValueRef LLVMConstFCmp(LLVMRealPredicate Predicate, 604193323Sed LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); 605193323SedLLVMValueRef LLVMConstShl(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); 606193323SedLLVMValueRef LLVMConstLShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); 607193323SedLLVMValueRef LLVMConstAShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); 608193323SedLLVMValueRef LLVMConstGEP(LLVMValueRef ConstantVal, 609193323Sed LLVMValueRef *ConstantIndices, unsigned NumIndices); 610198090SrdivackyLLVMValueRef LLVMConstInBoundsGEP(LLVMValueRef ConstantVal, 611198090Srdivacky LLVMValueRef *ConstantIndices, 612198090Srdivacky unsigned NumIndices); 613193323SedLLVMValueRef LLVMConstTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType); 614193323SedLLVMValueRef LLVMConstSExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType); 615193323SedLLVMValueRef LLVMConstZExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType); 616193323SedLLVMValueRef LLVMConstFPTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType); 617193323SedLLVMValueRef LLVMConstFPExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType); 618193323SedLLVMValueRef LLVMConstUIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType); 619193323SedLLVMValueRef LLVMConstSIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType); 620193323SedLLVMValueRef LLVMConstFPToUI(LLVMValueRef ConstantVal, LLVMTypeRef ToType); 621193323SedLLVMValueRef LLVMConstFPToSI(LLVMValueRef ConstantVal, LLVMTypeRef ToType); 622193323SedLLVMValueRef LLVMConstPtrToInt(LLVMValueRef ConstantVal, LLVMTypeRef ToType); 623193323SedLLVMValueRef LLVMConstIntToPtr(LLVMValueRef ConstantVal, LLVMTypeRef ToType); 624193323SedLLVMValueRef LLVMConstBitCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType); 625198090SrdivackyLLVMValueRef LLVMConstZExtOrBitCast(LLVMValueRef ConstantVal, 626198090Srdivacky LLVMTypeRef ToType); 627198090SrdivackyLLVMValueRef LLVMConstSExtOrBitCast(LLVMValueRef ConstantVal, 628198090Srdivacky LLVMTypeRef ToType); 629198090SrdivackyLLVMValueRef LLVMConstTruncOrBitCast(LLVMValueRef ConstantVal, 630198090Srdivacky LLVMTypeRef ToType); 631198090SrdivackyLLVMValueRef LLVMConstPointerCast(LLVMValueRef ConstantVal, 632198090Srdivacky LLVMTypeRef ToType); 633198090SrdivackyLLVMValueRef LLVMConstIntCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType, 634202375Srdivacky LLVMBool isSigned); 635198090SrdivackyLLVMValueRef LLVMConstFPCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType); 636193323SedLLVMValueRef LLVMConstSelect(LLVMValueRef ConstantCondition, 637193323Sed LLVMValueRef ConstantIfTrue, 638193323Sed LLVMValueRef ConstantIfFalse); 639193323SedLLVMValueRef LLVMConstExtractElement(LLVMValueRef VectorConstant, 640193323Sed LLVMValueRef IndexConstant); 641193323SedLLVMValueRef LLVMConstInsertElement(LLVMValueRef VectorConstant, 642193323Sed LLVMValueRef ElementValueConstant, 643193323Sed LLVMValueRef IndexConstant); 644193323SedLLVMValueRef LLVMConstShuffleVector(LLVMValueRef VectorAConstant, 645193323Sed LLVMValueRef VectorBConstant, 646193323Sed LLVMValueRef MaskConstant); 647193323SedLLVMValueRef LLVMConstExtractValue(LLVMValueRef AggConstant, unsigned *IdxList, 648193323Sed unsigned NumIdx); 649193323SedLLVMValueRef LLVMConstInsertValue(LLVMValueRef AggConstant, 650193323Sed LLVMValueRef ElementValueConstant, 651193323Sed unsigned *IdxList, unsigned NumIdx); 652202375SrdivackyLLVMValueRef LLVMConstInlineAsm(LLVMTypeRef Ty, 653193323Sed const char *AsmString, const char *Constraints, 654202375Srdivacky LLVMBool HasSideEffects, LLVMBool IsAlignStack); 655204642SrdivackyLLVMValueRef LLVMBlockAddress(LLVMValueRef F, LLVMBasicBlockRef BB); 656193323Sed 657193323Sed/* Operations on global variables, functions, and aliases (globals) */ 658193323SedLLVMModuleRef LLVMGetGlobalParent(LLVMValueRef Global); 659202375SrdivackyLLVMBool LLVMIsDeclaration(LLVMValueRef Global); 660193323SedLLVMLinkage LLVMGetLinkage(LLVMValueRef Global); 661193323Sedvoid LLVMSetLinkage(LLVMValueRef Global, LLVMLinkage Linkage); 662193323Sedconst char *LLVMGetSection(LLVMValueRef Global); 663193323Sedvoid LLVMSetSection(LLVMValueRef Global, const char *Section); 664193323SedLLVMVisibility LLVMGetVisibility(LLVMValueRef Global); 665193323Sedvoid LLVMSetVisibility(LLVMValueRef Global, LLVMVisibility Viz); 666193323Sedunsigned LLVMGetAlignment(LLVMValueRef Global); 667193323Sedvoid LLVMSetAlignment(LLVMValueRef Global, unsigned Bytes); 668193323Sed 669193323Sed/* Operations on global variables */ 670193323SedLLVMValueRef LLVMAddGlobal(LLVMModuleRef M, LLVMTypeRef Ty, const char *Name); 671204642SrdivackyLLVMValueRef LLVMAddGlobalInAddressSpace(LLVMModuleRef M, LLVMTypeRef Ty, 672204642Srdivacky const char *Name, 673204642Srdivacky unsigned AddressSpace); 674193323SedLLVMValueRef LLVMGetNamedGlobal(LLVMModuleRef M, const char *Name); 675193323SedLLVMValueRef LLVMGetFirstGlobal(LLVMModuleRef M); 676193323SedLLVMValueRef LLVMGetLastGlobal(LLVMModuleRef M); 677193323SedLLVMValueRef LLVMGetNextGlobal(LLVMValueRef GlobalVar); 678193323SedLLVMValueRef LLVMGetPreviousGlobal(LLVMValueRef GlobalVar); 679193323Sedvoid LLVMDeleteGlobal(LLVMValueRef GlobalVar); 680193323SedLLVMValueRef LLVMGetInitializer(LLVMValueRef GlobalVar); 681193323Sedvoid LLVMSetInitializer(LLVMValueRef GlobalVar, LLVMValueRef ConstantVal); 682202375SrdivackyLLVMBool LLVMIsThreadLocal(LLVMValueRef GlobalVar); 683202375Srdivackyvoid LLVMSetThreadLocal(LLVMValueRef GlobalVar, LLVMBool IsThreadLocal); 684202375SrdivackyLLVMBool LLVMIsGlobalConstant(LLVMValueRef GlobalVar); 685202375Srdivackyvoid LLVMSetGlobalConstant(LLVMValueRef GlobalVar, LLVMBool IsConstant); 686193323Sed 687193323Sed/* Operations on aliases */ 688193323SedLLVMValueRef LLVMAddAlias(LLVMModuleRef M, LLVMTypeRef Ty, LLVMValueRef Aliasee, 689193323Sed const char *Name); 690193323Sed 691193323Sed/* Operations on functions */ 692193323SedLLVMValueRef LLVMAddFunction(LLVMModuleRef M, const char *Name, 693193323Sed LLVMTypeRef FunctionTy); 694193323SedLLVMValueRef LLVMGetNamedFunction(LLVMModuleRef M, const char *Name); 695193323SedLLVMValueRef LLVMGetFirstFunction(LLVMModuleRef M); 696193323SedLLVMValueRef LLVMGetLastFunction(LLVMModuleRef M); 697193323SedLLVMValueRef LLVMGetNextFunction(LLVMValueRef Fn); 698193323SedLLVMValueRef LLVMGetPreviousFunction(LLVMValueRef Fn); 699193323Sedvoid LLVMDeleteFunction(LLVMValueRef Fn); 700193323Sedunsigned LLVMGetIntrinsicID(LLVMValueRef Fn); 701193323Sedunsigned LLVMGetFunctionCallConv(LLVMValueRef Fn); 702193323Sedvoid LLVMSetFunctionCallConv(LLVMValueRef Fn, unsigned CC); 703193323Sedconst char *LLVMGetGC(LLVMValueRef Fn); 704193323Sedvoid LLVMSetGC(LLVMValueRef Fn, const char *Name); 705193323Sedvoid LLVMAddFunctionAttr(LLVMValueRef Fn, LLVMAttribute PA); 706198090SrdivackyLLVMAttribute LLVMGetFunctionAttr(LLVMValueRef Fn); 707193323Sedvoid LLVMRemoveFunctionAttr(LLVMValueRef Fn, LLVMAttribute PA); 708193323Sed 709193323Sed/* Operations on parameters */ 710193323Sedunsigned LLVMCountParams(LLVMValueRef Fn); 711193323Sedvoid LLVMGetParams(LLVMValueRef Fn, LLVMValueRef *Params); 712193323SedLLVMValueRef LLVMGetParam(LLVMValueRef Fn, unsigned Index); 713193323SedLLVMValueRef LLVMGetParamParent(LLVMValueRef Inst); 714193323SedLLVMValueRef LLVMGetFirstParam(LLVMValueRef Fn); 715193323SedLLVMValueRef LLVMGetLastParam(LLVMValueRef Fn); 716193323SedLLVMValueRef LLVMGetNextParam(LLVMValueRef Arg); 717193323SedLLVMValueRef LLVMGetPreviousParam(LLVMValueRef Arg); 718193323Sedvoid LLVMAddAttribute(LLVMValueRef Arg, LLVMAttribute PA); 719193323Sedvoid LLVMRemoveAttribute(LLVMValueRef Arg, LLVMAttribute PA); 720198090SrdivackyLLVMAttribute LLVMGetAttribute(LLVMValueRef Arg); 721193323Sedvoid LLVMSetParamAlignment(LLVMValueRef Arg, unsigned align); 722193323Sed 723193323Sed/* Operations on basic blocks */ 724193323SedLLVMValueRef LLVMBasicBlockAsValue(LLVMBasicBlockRef BB); 725202375SrdivackyLLVMBool LLVMValueIsBasicBlock(LLVMValueRef Val); 726193323SedLLVMBasicBlockRef LLVMValueAsBasicBlock(LLVMValueRef Val); 727193323SedLLVMValueRef LLVMGetBasicBlockParent(LLVMBasicBlockRef BB); 728193323Sedunsigned LLVMCountBasicBlocks(LLVMValueRef Fn); 729193323Sedvoid LLVMGetBasicBlocks(LLVMValueRef Fn, LLVMBasicBlockRef *BasicBlocks); 730193323SedLLVMBasicBlockRef LLVMGetFirstBasicBlock(LLVMValueRef Fn); 731193323SedLLVMBasicBlockRef LLVMGetLastBasicBlock(LLVMValueRef Fn); 732193323SedLLVMBasicBlockRef LLVMGetNextBasicBlock(LLVMBasicBlockRef BB); 733193323SedLLVMBasicBlockRef LLVMGetPreviousBasicBlock(LLVMBasicBlockRef BB); 734193323SedLLVMBasicBlockRef LLVMGetEntryBasicBlock(LLVMValueRef Fn); 735198090Srdivacky 736198090SrdivackyLLVMBasicBlockRef LLVMAppendBasicBlockInContext(LLVMContextRef C, 737198090Srdivacky LLVMValueRef Fn, 738198090Srdivacky const char *Name); 739198090SrdivackyLLVMBasicBlockRef LLVMInsertBasicBlockInContext(LLVMContextRef C, 740198090Srdivacky LLVMBasicBlockRef BB, 741198090Srdivacky const char *Name); 742198090Srdivacky 743193323SedLLVMBasicBlockRef LLVMAppendBasicBlock(LLVMValueRef Fn, const char *Name); 744193323SedLLVMBasicBlockRef LLVMInsertBasicBlock(LLVMBasicBlockRef InsertBeforeBB, 745193323Sed const char *Name); 746193323Sedvoid LLVMDeleteBasicBlock(LLVMBasicBlockRef BB); 747193323Sed 748212904Sdimvoid LLVMMoveBasicBlockBefore(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos); 749212904Sdimvoid LLVMMoveBasicBlockAfter(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos); 750212904Sdim 751193323Sed/* Operations on instructions */ 752193323SedLLVMBasicBlockRef LLVMGetInstructionParent(LLVMValueRef Inst); 753193323SedLLVMValueRef LLVMGetFirstInstruction(LLVMBasicBlockRef BB); 754193323SedLLVMValueRef LLVMGetLastInstruction(LLVMBasicBlockRef BB); 755193323SedLLVMValueRef LLVMGetNextInstruction(LLVMValueRef Inst); 756193323SedLLVMValueRef LLVMGetPreviousInstruction(LLVMValueRef Inst); 757193323Sed 758193323Sed/* Operations on call sites */ 759193323Sedvoid LLVMSetInstructionCallConv(LLVMValueRef Instr, unsigned CC); 760193323Sedunsigned LLVMGetInstructionCallConv(LLVMValueRef Instr); 761193323Sedvoid LLVMAddInstrAttribute(LLVMValueRef Instr, unsigned index, LLVMAttribute); 762193323Sedvoid LLVMRemoveInstrAttribute(LLVMValueRef Instr, unsigned index, 763193323Sed LLVMAttribute); 764193323Sedvoid LLVMSetInstrParamAlignment(LLVMValueRef Instr, unsigned index, 765193323Sed unsigned align); 766193323Sed 767193323Sed/* Operations on call instructions (only) */ 768202375SrdivackyLLVMBool LLVMIsTailCall(LLVMValueRef CallInst); 769202375Srdivackyvoid LLVMSetTailCall(LLVMValueRef CallInst, LLVMBool IsTailCall); 770193323Sed 771193323Sed/* Operations on phi nodes */ 772193323Sedvoid LLVMAddIncoming(LLVMValueRef PhiNode, LLVMValueRef *IncomingValues, 773193323Sed LLVMBasicBlockRef *IncomingBlocks, unsigned Count); 774193323Sedunsigned LLVMCountIncoming(LLVMValueRef PhiNode); 775193323SedLLVMValueRef LLVMGetIncomingValue(LLVMValueRef PhiNode, unsigned Index); 776193323SedLLVMBasicBlockRef LLVMGetIncomingBlock(LLVMValueRef PhiNode, unsigned Index); 777193323Sed 778193323Sed/*===-- Instruction builders ----------------------------------------------===*/ 779193323Sed 780193323Sed/* An instruction builder represents a point within a basic block, and is the 781193323Sed * exclusive means of building instructions using the C interface. 782193323Sed */ 783193323Sed 784198090SrdivackyLLVMBuilderRef LLVMCreateBuilderInContext(LLVMContextRef C); 785193323SedLLVMBuilderRef LLVMCreateBuilder(void); 786193323Sedvoid LLVMPositionBuilder(LLVMBuilderRef Builder, LLVMBasicBlockRef Block, 787193323Sed LLVMValueRef Instr); 788193323Sedvoid LLVMPositionBuilderBefore(LLVMBuilderRef Builder, LLVMValueRef Instr); 789193323Sedvoid LLVMPositionBuilderAtEnd(LLVMBuilderRef Builder, LLVMBasicBlockRef Block); 790193323SedLLVMBasicBlockRef LLVMGetInsertBlock(LLVMBuilderRef Builder); 791193323Sedvoid LLVMClearInsertionPosition(LLVMBuilderRef Builder); 792193323Sedvoid LLVMInsertIntoBuilder(LLVMBuilderRef Builder, LLVMValueRef Instr); 793198090Srdivackyvoid LLVMInsertIntoBuilderWithName(LLVMBuilderRef Builder, LLVMValueRef Instr, 794198090Srdivacky const char *Name); 795193323Sedvoid LLVMDisposeBuilder(LLVMBuilderRef Builder); 796193323Sed 797204642Srdivacky/* Metadata */ 798204642Srdivackyvoid LLVMSetCurrentDebugLocation(LLVMBuilderRef Builder, LLVMValueRef L); 799204642SrdivackyLLVMValueRef LLVMGetCurrentDebugLocation(LLVMBuilderRef Builder); 800204642Srdivackyvoid LLVMSetInstDebugLocation(LLVMBuilderRef Builder, LLVMValueRef Inst); 801204642Srdivacky 802193323Sed/* Terminators */ 803193323SedLLVMValueRef LLVMBuildRetVoid(LLVMBuilderRef); 804193323SedLLVMValueRef LLVMBuildRet(LLVMBuilderRef, LLVMValueRef V); 805198090SrdivackyLLVMValueRef LLVMBuildAggregateRet(LLVMBuilderRef, LLVMValueRef *RetVals, 806198090Srdivacky unsigned N); 807193323SedLLVMValueRef LLVMBuildBr(LLVMBuilderRef, LLVMBasicBlockRef Dest); 808193323SedLLVMValueRef LLVMBuildCondBr(LLVMBuilderRef, LLVMValueRef If, 809193323Sed LLVMBasicBlockRef Then, LLVMBasicBlockRef Else); 810193323SedLLVMValueRef LLVMBuildSwitch(LLVMBuilderRef, LLVMValueRef V, 811193323Sed LLVMBasicBlockRef Else, unsigned NumCases); 812204642SrdivackyLLVMValueRef LLVMBuildIndirectBr(LLVMBuilderRef B, LLVMValueRef Addr, 813204642Srdivacky unsigned NumDests); 814193323SedLLVMValueRef LLVMBuildInvoke(LLVMBuilderRef, LLVMValueRef Fn, 815193323Sed LLVMValueRef *Args, unsigned NumArgs, 816193323Sed LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch, 817193323Sed const char *Name); 818193323SedLLVMValueRef LLVMBuildUnwind(LLVMBuilderRef); 819193323SedLLVMValueRef LLVMBuildUnreachable(LLVMBuilderRef); 820193323Sed 821193323Sed/* Add a case to the switch instruction */ 822193323Sedvoid LLVMAddCase(LLVMValueRef Switch, LLVMValueRef OnVal, 823193323Sed LLVMBasicBlockRef Dest); 824193323Sed 825204642Srdivacky/* Add a destination to the indirectbr instruction */ 826204642Srdivackyvoid LLVMAddDestination(LLVMValueRef IndirectBr, LLVMBasicBlockRef Dest); 827204642Srdivacky 828193323Sed/* Arithmetic */ 829193323SedLLVMValueRef LLVMBuildAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, 830193323Sed const char *Name); 831198090SrdivackyLLVMValueRef LLVMBuildNSWAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, 832198090Srdivacky const char *Name); 833204642SrdivackyLLVMValueRef LLVMBuildNUWAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, 834204642Srdivacky const char *Name); 835198090SrdivackyLLVMValueRef LLVMBuildFAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, 836198090Srdivacky const char *Name); 837193323SedLLVMValueRef LLVMBuildSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, 838193323Sed const char *Name); 839204642SrdivackyLLVMValueRef LLVMBuildNSWSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, 840204642Srdivacky const char *Name); 841204642SrdivackyLLVMValueRef LLVMBuildNUWSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, 842204642Srdivacky const char *Name); 843198090SrdivackyLLVMValueRef LLVMBuildFSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, 844198090Srdivacky const char *Name); 845193323SedLLVMValueRef LLVMBuildMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, 846193323Sed const char *Name); 847204642SrdivackyLLVMValueRef LLVMBuildNSWMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, 848204642Srdivacky const char *Name); 849204642SrdivackyLLVMValueRef LLVMBuildNUWMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, 850204642Srdivacky const char *Name); 851198090SrdivackyLLVMValueRef LLVMBuildFMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, 852198090Srdivacky const char *Name); 853193323SedLLVMValueRef LLVMBuildUDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, 854193323Sed const char *Name); 855193323SedLLVMValueRef LLVMBuildSDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, 856193323Sed const char *Name); 857198090SrdivackyLLVMValueRef LLVMBuildExactSDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, 858198090Srdivacky const char *Name); 859193323SedLLVMValueRef LLVMBuildFDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, 860193323Sed const char *Name); 861193323SedLLVMValueRef LLVMBuildURem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, 862193323Sed const char *Name); 863193323SedLLVMValueRef LLVMBuildSRem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, 864193323Sed const char *Name); 865193323SedLLVMValueRef LLVMBuildFRem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, 866193323Sed const char *Name); 867193323SedLLVMValueRef LLVMBuildShl(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, 868193323Sed const char *Name); 869193323SedLLVMValueRef LLVMBuildLShr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, 870193323Sed const char *Name); 871193323SedLLVMValueRef LLVMBuildAShr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, 872193323Sed const char *Name); 873193323SedLLVMValueRef LLVMBuildAnd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, 874193323Sed const char *Name); 875193323SedLLVMValueRef LLVMBuildOr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, 876193323Sed const char *Name); 877193323SedLLVMValueRef LLVMBuildXor(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, 878193323Sed const char *Name); 879204642SrdivackyLLVMValueRef LLVMBuildBinOp(LLVMBuilderRef B, LLVMOpcode Op, 880204642Srdivacky LLVMValueRef LHS, LLVMValueRef RHS, 881204642Srdivacky const char *Name); 882193323SedLLVMValueRef LLVMBuildNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name); 883204642SrdivackyLLVMValueRef LLVMBuildNSWNeg(LLVMBuilderRef B, LLVMValueRef V, 884204642Srdivacky const char *Name); 885204642SrdivackyLLVMValueRef LLVMBuildNUWNeg(LLVMBuilderRef B, LLVMValueRef V, 886204642Srdivacky const char *Name); 887198090SrdivackyLLVMValueRef LLVMBuildFNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name); 888193323SedLLVMValueRef LLVMBuildNot(LLVMBuilderRef, LLVMValueRef V, const char *Name); 889193323Sed 890193323Sed/* Memory */ 891193323SedLLVMValueRef LLVMBuildMalloc(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name); 892193323SedLLVMValueRef LLVMBuildArrayMalloc(LLVMBuilderRef, LLVMTypeRef Ty, 893193323Sed LLVMValueRef Val, const char *Name); 894193323SedLLVMValueRef LLVMBuildAlloca(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name); 895193323SedLLVMValueRef LLVMBuildArrayAlloca(LLVMBuilderRef, LLVMTypeRef Ty, 896193323Sed LLVMValueRef Val, const char *Name); 897193323SedLLVMValueRef LLVMBuildFree(LLVMBuilderRef, LLVMValueRef PointerVal); 898193323SedLLVMValueRef LLVMBuildLoad(LLVMBuilderRef, LLVMValueRef PointerVal, 899193323Sed const char *Name); 900193323SedLLVMValueRef LLVMBuildStore(LLVMBuilderRef, LLVMValueRef Val, LLVMValueRef Ptr); 901193323SedLLVMValueRef LLVMBuildGEP(LLVMBuilderRef B, LLVMValueRef Pointer, 902193323Sed LLVMValueRef *Indices, unsigned NumIndices, 903193323Sed const char *Name); 904198090SrdivackyLLVMValueRef LLVMBuildInBoundsGEP(LLVMBuilderRef B, LLVMValueRef Pointer, 905198090Srdivacky LLVMValueRef *Indices, unsigned NumIndices, 906198090Srdivacky const char *Name); 907198090SrdivackyLLVMValueRef LLVMBuildStructGEP(LLVMBuilderRef B, LLVMValueRef Pointer, 908198090Srdivacky unsigned Idx, const char *Name); 909198090SrdivackyLLVMValueRef LLVMBuildGlobalString(LLVMBuilderRef B, const char *Str, 910198090Srdivacky const char *Name); 911198090SrdivackyLLVMValueRef LLVMBuildGlobalStringPtr(LLVMBuilderRef B, const char *Str, 912198090Srdivacky const char *Name); 913193323Sed 914193323Sed/* Casts */ 915193323SedLLVMValueRef LLVMBuildTrunc(LLVMBuilderRef, LLVMValueRef Val, 916193323Sed LLVMTypeRef DestTy, const char *Name); 917193323SedLLVMValueRef LLVMBuildZExt(LLVMBuilderRef, LLVMValueRef Val, 918193323Sed LLVMTypeRef DestTy, const char *Name); 919193323SedLLVMValueRef LLVMBuildSExt(LLVMBuilderRef, LLVMValueRef Val, 920193323Sed LLVMTypeRef DestTy, const char *Name); 921193323SedLLVMValueRef LLVMBuildFPToUI(LLVMBuilderRef, LLVMValueRef Val, 922193323Sed LLVMTypeRef DestTy, const char *Name); 923193323SedLLVMValueRef LLVMBuildFPToSI(LLVMBuilderRef, LLVMValueRef Val, 924193323Sed LLVMTypeRef DestTy, const char *Name); 925193323SedLLVMValueRef LLVMBuildUIToFP(LLVMBuilderRef, LLVMValueRef Val, 926193323Sed LLVMTypeRef DestTy, const char *Name); 927193323SedLLVMValueRef LLVMBuildSIToFP(LLVMBuilderRef, LLVMValueRef Val, 928193323Sed LLVMTypeRef DestTy, const char *Name); 929193323SedLLVMValueRef LLVMBuildFPTrunc(LLVMBuilderRef, LLVMValueRef Val, 930193323Sed LLVMTypeRef DestTy, const char *Name); 931193323SedLLVMValueRef LLVMBuildFPExt(LLVMBuilderRef, LLVMValueRef Val, 932193323Sed LLVMTypeRef DestTy, const char *Name); 933193323SedLLVMValueRef LLVMBuildPtrToInt(LLVMBuilderRef, LLVMValueRef Val, 934193323Sed LLVMTypeRef DestTy, const char *Name); 935193323SedLLVMValueRef LLVMBuildIntToPtr(LLVMBuilderRef, LLVMValueRef Val, 936193323Sed LLVMTypeRef DestTy, const char *Name); 937193323SedLLVMValueRef LLVMBuildBitCast(LLVMBuilderRef, LLVMValueRef Val, 938193323Sed LLVMTypeRef DestTy, const char *Name); 939198090SrdivackyLLVMValueRef LLVMBuildZExtOrBitCast(LLVMBuilderRef, LLVMValueRef Val, 940198090Srdivacky LLVMTypeRef DestTy, const char *Name); 941198090SrdivackyLLVMValueRef LLVMBuildSExtOrBitCast(LLVMBuilderRef, LLVMValueRef Val, 942198090Srdivacky LLVMTypeRef DestTy, const char *Name); 943198090SrdivackyLLVMValueRef LLVMBuildTruncOrBitCast(LLVMBuilderRef, LLVMValueRef Val, 944198090Srdivacky LLVMTypeRef DestTy, const char *Name); 945204642SrdivackyLLVMValueRef LLVMBuildCast(LLVMBuilderRef B, LLVMOpcode Op, LLVMValueRef Val, 946204642Srdivacky LLVMTypeRef DestTy, const char *Name); 947198090SrdivackyLLVMValueRef LLVMBuildPointerCast(LLVMBuilderRef, LLVMValueRef Val, 948198090Srdivacky LLVMTypeRef DestTy, const char *Name); 949199989SrdivackyLLVMValueRef LLVMBuildIntCast(LLVMBuilderRef, LLVMValueRef Val, /*Signed cast!*/ 950198090Srdivacky LLVMTypeRef DestTy, const char *Name); 951198090SrdivackyLLVMValueRef LLVMBuildFPCast(LLVMBuilderRef, LLVMValueRef Val, 952198090Srdivacky LLVMTypeRef DestTy, const char *Name); 953193323Sed 954193323Sed/* Comparisons */ 955193323SedLLVMValueRef LLVMBuildICmp(LLVMBuilderRef, LLVMIntPredicate Op, 956193323Sed LLVMValueRef LHS, LLVMValueRef RHS, 957193323Sed const char *Name); 958193323SedLLVMValueRef LLVMBuildFCmp(LLVMBuilderRef, LLVMRealPredicate Op, 959193323Sed LLVMValueRef LHS, LLVMValueRef RHS, 960193323Sed const char *Name); 961193323Sed 962193323Sed/* Miscellaneous instructions */ 963193323SedLLVMValueRef LLVMBuildPhi(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name); 964193323SedLLVMValueRef LLVMBuildCall(LLVMBuilderRef, LLVMValueRef Fn, 965193323Sed LLVMValueRef *Args, unsigned NumArgs, 966193323Sed const char *Name); 967193323SedLLVMValueRef LLVMBuildSelect(LLVMBuilderRef, LLVMValueRef If, 968193323Sed LLVMValueRef Then, LLVMValueRef Else, 969193323Sed const char *Name); 970193323SedLLVMValueRef LLVMBuildVAArg(LLVMBuilderRef, LLVMValueRef List, LLVMTypeRef Ty, 971193323Sed const char *Name); 972193323SedLLVMValueRef LLVMBuildExtractElement(LLVMBuilderRef, LLVMValueRef VecVal, 973193323Sed LLVMValueRef Index, const char *Name); 974193323SedLLVMValueRef LLVMBuildInsertElement(LLVMBuilderRef, LLVMValueRef VecVal, 975193323Sed LLVMValueRef EltVal, LLVMValueRef Index, 976193323Sed const char *Name); 977193323SedLLVMValueRef LLVMBuildShuffleVector(LLVMBuilderRef, LLVMValueRef V1, 978193323Sed LLVMValueRef V2, LLVMValueRef Mask, 979193323Sed const char *Name); 980193323SedLLVMValueRef LLVMBuildExtractValue(LLVMBuilderRef, LLVMValueRef AggVal, 981193323Sed unsigned Index, const char *Name); 982193323SedLLVMValueRef LLVMBuildInsertValue(LLVMBuilderRef, LLVMValueRef AggVal, 983193323Sed LLVMValueRef EltVal, unsigned Index, 984193323Sed const char *Name); 985193323Sed 986198090SrdivackyLLVMValueRef LLVMBuildIsNull(LLVMBuilderRef, LLVMValueRef Val, 987198090Srdivacky const char *Name); 988198090SrdivackyLLVMValueRef LLVMBuildIsNotNull(LLVMBuilderRef, LLVMValueRef Val, 989198090Srdivacky const char *Name); 990198090SrdivackyLLVMValueRef LLVMBuildPtrDiff(LLVMBuilderRef, LLVMValueRef LHS, 991198090Srdivacky LLVMValueRef RHS, const char *Name); 992193323Sed 993198090Srdivacky 994193323Sed/*===-- Module providers --------------------------------------------------===*/ 995193323Sed 996203954Srdivacky/* Changes the type of M so it can be passed to FunctionPassManagers and the 997203954Srdivacky * JIT. They take ModuleProviders for historical reasons. 998193323Sed */ 999193323SedLLVMModuleProviderRef 1000193323SedLLVMCreateModuleProviderForExistingModule(LLVMModuleRef M); 1001193323Sed 1002203954Srdivacky/* Destroys the module M. 1003193323Sed */ 1004203954Srdivackyvoid LLVMDisposeModuleProvider(LLVMModuleProviderRef M); 1005193323Sed 1006193323Sed 1007193323Sed/*===-- Memory buffers ----------------------------------------------------===*/ 1008193323Sed 1009202375SrdivackyLLVMBool LLVMCreateMemoryBufferWithContentsOfFile(const char *Path, 1010202375Srdivacky LLVMMemoryBufferRef *OutMemBuf, 1011202375Srdivacky char **OutMessage); 1012202375SrdivackyLLVMBool LLVMCreateMemoryBufferWithSTDIN(LLVMMemoryBufferRef *OutMemBuf, 1013202375Srdivacky char **OutMessage); 1014193323Sedvoid LLVMDisposeMemoryBuffer(LLVMMemoryBufferRef MemBuf); 1015193323Sed 1016193323Sed 1017193323Sed/*===-- Pass Managers -----------------------------------------------------===*/ 1018193323Sed 1019193323Sed/** Constructs a new whole-module pass pipeline. This type of pipeline is 1020193323Sed suitable for link-time optimization and whole-module transformations. 1021193323Sed See llvm::PassManager::PassManager. */ 1022193323SedLLVMPassManagerRef LLVMCreatePassManager(void); 1023193323Sed 1024193323Sed/** Constructs a new function-by-function pass pipeline over the module 1025193323Sed provider. It does not take ownership of the module provider. This type of 1026193323Sed pipeline is suitable for code generation and JIT compilation tasks. 1027193323Sed See llvm::FunctionPassManager::FunctionPassManager. */ 1028204642SrdivackyLLVMPassManagerRef LLVMCreateFunctionPassManagerForModule(LLVMModuleRef M); 1029204642Srdivacky 1030204642Srdivacky/** Deprecated: Use LLVMCreateFunctionPassManagerForModule instead. */ 1031193323SedLLVMPassManagerRef LLVMCreateFunctionPassManager(LLVMModuleProviderRef MP); 1032193323Sed 1033193323Sed/** Initializes, executes on the provided module, and finalizes all of the 1034193323Sed passes scheduled in the pass manager. Returns 1 if any of the passes 1035193323Sed modified the module, 0 otherwise. See llvm::PassManager::run(Module&). */ 1036202375SrdivackyLLVMBool LLVMRunPassManager(LLVMPassManagerRef PM, LLVMModuleRef M); 1037193323Sed 1038193323Sed/** Initializes all of the function passes scheduled in the function pass 1039193323Sed manager. Returns 1 if any of the passes modified the module, 0 otherwise. 1040193323Sed See llvm::FunctionPassManager::doInitialization. */ 1041202375SrdivackyLLVMBool LLVMInitializeFunctionPassManager(LLVMPassManagerRef FPM); 1042193323Sed 1043193323Sed/** Executes all of the function passes scheduled in the function pass manager 1044193323Sed on the provided function. Returns 1 if any of the passes modified the 1045193323Sed function, false otherwise. 1046193323Sed See llvm::FunctionPassManager::run(Function&). */ 1047202375SrdivackyLLVMBool LLVMRunFunctionPassManager(LLVMPassManagerRef FPM, LLVMValueRef F); 1048193323Sed 1049193323Sed/** Finalizes all of the function passes scheduled in in the function pass 1050193323Sed manager. Returns 1 if any of the passes modified the module, 0 otherwise. 1051193323Sed See llvm::FunctionPassManager::doFinalization. */ 1052202375SrdivackyLLVMBool LLVMFinalizeFunctionPassManager(LLVMPassManagerRef FPM); 1053193323Sed 1054193323Sed/** Frees the memory of a pass pipeline. For function pipelines, does not free 1055193323Sed the module provider. 1056193323Sed See llvm::PassManagerBase::~PassManagerBase. */ 1057193323Sedvoid LLVMDisposePassManager(LLVMPassManagerRef PM); 1058193323Sed 1059193323Sed 1060193323Sed#ifdef __cplusplus 1061193323Sed} 1062193323Sed 1063193323Sednamespace llvm { 1064193323Sed class MemoryBuffer; 1065193323Sed class PassManagerBase; 1066193323Sed 1067193323Sed #define DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref) \ 1068193323Sed inline ty *unwrap(ref P) { \ 1069193323Sed return reinterpret_cast<ty*>(P); \ 1070193323Sed } \ 1071193323Sed \ 1072193323Sed inline ref wrap(const ty *P) { \ 1073193323Sed return reinterpret_cast<ref>(const_cast<ty*>(P)); \ 1074193323Sed } 1075193323Sed 1076193323Sed #define DEFINE_ISA_CONVERSION_FUNCTIONS(ty, ref) \ 1077193323Sed DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref) \ 1078193323Sed \ 1079193323Sed template<typename T> \ 1080193323Sed inline T *unwrap(ref P) { \ 1081193323Sed return cast<T>(unwrap(P)); \ 1082193323Sed } 1083193323Sed 1084193323Sed #define DEFINE_STDCXX_CONVERSION_FUNCTIONS(ty, ref) \ 1085193323Sed DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref) \ 1086193323Sed \ 1087193323Sed template<typename T> \ 1088193323Sed inline T *unwrap(ref P) { \ 1089202878Srdivacky T *Q = (T*)unwrap(P); \ 1090193323Sed assert(Q && "Invalid cast!"); \ 1091193323Sed return Q; \ 1092193323Sed } 1093193323Sed 1094193323Sed DEFINE_ISA_CONVERSION_FUNCTIONS (Type, LLVMTypeRef ) 1095193323Sed DEFINE_ISA_CONVERSION_FUNCTIONS (Value, LLVMValueRef ) 1096193323Sed DEFINE_SIMPLE_CONVERSION_FUNCTIONS(Module, LLVMModuleRef ) 1097193323Sed DEFINE_SIMPLE_CONVERSION_FUNCTIONS(BasicBlock, LLVMBasicBlockRef ) 1098193323Sed DEFINE_SIMPLE_CONVERSION_FUNCTIONS(IRBuilder<>, LLVMBuilderRef ) 1099193323Sed DEFINE_SIMPLE_CONVERSION_FUNCTIONS(PATypeHolder, LLVMTypeHandleRef ) 1100193323Sed DEFINE_SIMPLE_CONVERSION_FUNCTIONS(MemoryBuffer, LLVMMemoryBufferRef ) 1101195340Sed DEFINE_SIMPLE_CONVERSION_FUNCTIONS(LLVMContext, LLVMContextRef ) 1102204642Srdivacky DEFINE_SIMPLE_CONVERSION_FUNCTIONS(Use, LLVMUseRef ) 1103193323Sed DEFINE_STDCXX_CONVERSION_FUNCTIONS(PassManagerBase, LLVMPassManagerRef ) 1104203954Srdivacky /* LLVMModuleProviderRef exists for historical reasons, but now just holds a 1105203954Srdivacky * Module. 1106203954Srdivacky */ 1107203954Srdivacky inline Module *unwrap(LLVMModuleProviderRef MP) { 1108203954Srdivacky return reinterpret_cast<Module*>(MP); 1109203954Srdivacky } 1110193323Sed 1111193323Sed #undef DEFINE_STDCXX_CONVERSION_FUNCTIONS 1112193323Sed #undef DEFINE_ISA_CONVERSION_FUNCTIONS 1113193323Sed #undef DEFINE_SIMPLE_CONVERSION_FUNCTIONS 1114198090Srdivacky 1115198090Srdivacky /* Specialized opaque context conversions. 1116198090Srdivacky */ 1117198090Srdivacky inline LLVMContext **unwrap(LLVMContextRef* Tys) { 1118198090Srdivacky return reinterpret_cast<LLVMContext**>(Tys); 1119198090Srdivacky } 1120193323Sed 1121198090Srdivacky inline LLVMContextRef *wrap(const LLVMContext **Tys) { 1122198090Srdivacky return reinterpret_cast<LLVMContextRef*>(const_cast<LLVMContext**>(Tys)); 1123198090Srdivacky } 1124198090Srdivacky 1125193323Sed /* Specialized opaque type conversions. 1126193323Sed */ 1127193323Sed inline Type **unwrap(LLVMTypeRef* Tys) { 1128193323Sed return reinterpret_cast<Type**>(Tys); 1129193323Sed } 1130193323Sed 1131193323Sed inline LLVMTypeRef *wrap(const Type **Tys) { 1132193323Sed return reinterpret_cast<LLVMTypeRef*>(const_cast<Type**>(Tys)); 1133193323Sed } 1134193323Sed 1135193323Sed /* Specialized opaque value conversions. 1136193323Sed */ 1137193323Sed inline Value **unwrap(LLVMValueRef *Vals) { 1138193323Sed return reinterpret_cast<Value**>(Vals); 1139193323Sed } 1140193323Sed 1141193323Sed template<typename T> 1142193323Sed inline T **unwrap(LLVMValueRef *Vals, unsigned Length) { 1143193323Sed #if DEBUG 1144198090Srdivacky for (LLVMValueRef *I = Vals, *E = Vals + Length; I != E; ++I) 1145193323Sed cast<T>(*I); 1146193323Sed #endif 1147193323Sed return reinterpret_cast<T**>(Vals); 1148193323Sed } 1149193323Sed 1150193323Sed inline LLVMValueRef *wrap(const Value **Vals) { 1151193323Sed return reinterpret_cast<LLVMValueRef*>(const_cast<Value**>(Vals)); 1152193323Sed } 1153193323Sed} 1154193323Sed 1155193323Sed#endif /* !defined(__cplusplus) */ 1156193323Sed 1157193323Sed#endif /* !defined(LLVM_C_CORE_H) */ 1158