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\*===----------------------------------------------------------------------===*/ 14193323Sed 15193323Sed#ifndef LLVM_C_CORE_H 16193323Sed#define LLVM_C_CORE_H 17193323Sed 18296417Sdim#include "llvm-c/ErrorHandling.h" 19296417Sdim#include "llvm-c/Types.h" 20198090Srdivacky 21193323Sed#ifdef __cplusplus 22193323Sedextern "C" { 23193323Sed#endif 24193323Sed 25234353Sdim/** 26234353Sdim * @defgroup LLVMC LLVM-C: C interface to LLVM 27234353Sdim * 28234353Sdim * This module exposes parts of the LLVM library as a C API. 29234353Sdim * 30234353Sdim * @{ 31234353Sdim */ 32193323Sed 33234353Sdim/** 34234353Sdim * @defgroup LLVMCTransforms Transforms 35234353Sdim */ 36234353Sdim 37234353Sdim/** 38234353Sdim * @defgroup LLVMCCore Core 39234353Sdim * 40234353Sdim * This modules provide an interface to libLLVMCore, which implements 41234353Sdim * the LLVM intermediate representation as well as other related types 42234353Sdim * and utilities. 43234353Sdim * 44234353Sdim * Many exotic languages can interoperate with C code but have a harder time 45234353Sdim * with C++ due to name mangling. So in addition to C, this interface enables 46234353Sdim * tools written in such languages. 47234353Sdim * 48234353Sdim * @{ 49234353Sdim */ 50234353Sdim 51234353Sdim/** 52234353Sdim * @defgroup LLVMCCoreTypes Types and Enumerations 53234353Sdim * 54234353Sdim * @{ 55234353Sdim */ 56234353Sdim 57193323Sedtypedef enum { 58193323Sed LLVMZExtAttribute = 1<<0, 59193323Sed LLVMSExtAttribute = 1<<1, 60193323Sed LLVMNoReturnAttribute = 1<<2, 61193323Sed LLVMInRegAttribute = 1<<3, 62193323Sed LLVMStructRetAttribute = 1<<4, 63193323Sed LLVMNoUnwindAttribute = 1<<5, 64193323Sed LLVMNoAliasAttribute = 1<<6, 65193323Sed LLVMByValAttribute = 1<<7, 66193323Sed LLVMNestAttribute = 1<<8, 67193323Sed LLVMReadNoneAttribute = 1<<9, 68198090Srdivacky LLVMReadOnlyAttribute = 1<<10, 69198090Srdivacky LLVMNoInlineAttribute = 1<<11, 70198090Srdivacky LLVMAlwaysInlineAttribute = 1<<12, 71198090Srdivacky LLVMOptimizeForSizeAttribute = 1<<13, 72198090Srdivacky LLVMStackProtectAttribute = 1<<14, 73198090Srdivacky LLVMStackProtectReqAttribute = 1<<15, 74204792Srdivacky LLVMAlignment = 31<<16, 75198090Srdivacky LLVMNoCaptureAttribute = 1<<21, 76198090Srdivacky LLVMNoRedZoneAttribute = 1<<22, 77198090Srdivacky LLVMNoImplicitFloatAttribute = 1<<23, 78203954Srdivacky LLVMNakedAttribute = 1<<24, 79204792Srdivacky LLVMInlineHintAttribute = 1<<25, 80226633Sdim LLVMStackAlignment = 7<<26, 81226633Sdim LLVMReturnsTwice = 1 << 29, 82226633Sdim LLVMUWTable = 1 << 30, 83226633Sdim LLVMNonLazyBind = 1 << 31 84234353Sdim 85249423Sdim /* FIXME: These attributes are currently not included in the C API as 86243830Sdim a temporary measure until the API/ABI impact to the C API is understood 87243830Sdim and the path forward agreed upon. 88288943Sdim LLVMSanitizeAddressAttribute = 1ULL << 32, 89288943Sdim LLVMStackProtectStrongAttribute = 1ULL<<35, 90288943Sdim LLVMColdAttribute = 1ULL << 40, 91288943Sdim LLVMOptimizeNoneAttribute = 1ULL << 42, 92288943Sdim LLVMInAllocaAttribute = 1ULL << 43, 93288943Sdim LLVMNonNullAttribute = 1ULL << 44, 94288943Sdim LLVMJumpTableAttribute = 1ULL << 45, 95288943Sdim LLVMConvergentAttribute = 1ULL << 46, 96288943Sdim LLVMSafeStackAttribute = 1ULL << 47, 97243830Sdim */ 98193323Sed} LLVMAttribute; 99193323Sed 100193323Sedtypedef enum { 101203954Srdivacky /* Terminator Instructions */ 102198090Srdivacky LLVMRet = 1, 103198090Srdivacky LLVMBr = 2, 104198090Srdivacky LLVMSwitch = 3, 105203954Srdivacky LLVMIndirectBr = 4, 106203954Srdivacky LLVMInvoke = 5, 107226633Sdim /* removed 6 due to API changes */ 108203954Srdivacky LLVMUnreachable = 7, 109203954Srdivacky 110203954Srdivacky /* Standard Binary Operators */ 111203954Srdivacky LLVMAdd = 8, 112203954Srdivacky LLVMFAdd = 9, 113203954Srdivacky LLVMSub = 10, 114203954Srdivacky LLVMFSub = 11, 115203954Srdivacky LLVMMul = 12, 116203954Srdivacky LLVMFMul = 13, 117203954Srdivacky LLVMUDiv = 14, 118203954Srdivacky LLVMSDiv = 15, 119203954Srdivacky LLVMFDiv = 16, 120203954Srdivacky LLVMURem = 17, 121203954Srdivacky LLVMSRem = 18, 122203954Srdivacky LLVMFRem = 19, 123203954Srdivacky 124203954Srdivacky /* Logical Operators */ 125203954Srdivacky LLVMShl = 20, 126203954Srdivacky LLVMLShr = 21, 127203954Srdivacky LLVMAShr = 22, 128203954Srdivacky LLVMAnd = 23, 129203954Srdivacky LLVMOr = 24, 130203954Srdivacky LLVMXor = 25, 131203954Srdivacky 132203954Srdivacky /* Memory Operators */ 133203954Srdivacky LLVMAlloca = 26, 134203954Srdivacky LLVMLoad = 27, 135203954Srdivacky LLVMStore = 28, 136203954Srdivacky LLVMGetElementPtr = 29, 137203954Srdivacky 138203954Srdivacky /* Cast Operators */ 139203954Srdivacky LLVMTrunc = 30, 140203954Srdivacky LLVMZExt = 31, 141203954Srdivacky LLVMSExt = 32, 142203954Srdivacky LLVMFPToUI = 33, 143203954Srdivacky LLVMFPToSI = 34, 144203954Srdivacky LLVMUIToFP = 35, 145203954Srdivacky LLVMSIToFP = 36, 146203954Srdivacky LLVMFPTrunc = 37, 147203954Srdivacky LLVMFPExt = 38, 148203954Srdivacky LLVMPtrToInt = 39, 149203954Srdivacky LLVMIntToPtr = 40, 150203954Srdivacky LLVMBitCast = 41, 151261991Sdim LLVMAddrSpaceCast = 60, 152203954Srdivacky 153203954Srdivacky /* Other Operators */ 154203954Srdivacky LLVMICmp = 42, 155203954Srdivacky LLVMFCmp = 43, 156203954Srdivacky LLVMPHI = 44, 157203954Srdivacky LLVMCall = 45, 158203954Srdivacky LLVMSelect = 46, 159226633Sdim LLVMUserOp1 = 47, 160226633Sdim LLVMUserOp2 = 48, 161203954Srdivacky LLVMVAArg = 49, 162203954Srdivacky LLVMExtractElement = 50, 163203954Srdivacky LLVMInsertElement = 51, 164203954Srdivacky LLVMShuffleVector = 52, 165203954Srdivacky LLVMExtractValue = 53, 166226633Sdim LLVMInsertValue = 54, 167226633Sdim 168226633Sdim /* Atomic operators */ 169226633Sdim LLVMFence = 55, 170226633Sdim LLVMAtomicCmpXchg = 56, 171226633Sdim LLVMAtomicRMW = 57, 172226633Sdim 173226633Sdim /* Exception Handling Operators */ 174226633Sdim LLVMResume = 58, 175296417Sdim LLVMLandingPad = 59, 176296417Sdim LLVMCleanupRet = 61, 177296417Sdim LLVMCatchRet = 62, 178296417Sdim LLVMCatchPad = 63, 179296417Sdim LLVMCleanupPad = 64, 180296417Sdim LLVMCatchSwitch = 65 181198090Srdivacky} LLVMOpcode; 182198090Srdivacky 183198090Srdivackytypedef enum { 184193323Sed LLVMVoidTypeKind, /**< type with no size */ 185234353Sdim LLVMHalfTypeKind, /**< 16 bit floating point type */ 186193323Sed LLVMFloatTypeKind, /**< 32 bit floating point type */ 187193323Sed LLVMDoubleTypeKind, /**< 64 bit floating point type */ 188193323Sed LLVMX86_FP80TypeKind, /**< 80 bit floating point type (X87) */ 189193323Sed LLVMFP128TypeKind, /**< 128 bit floating point type (112-bit mantissa)*/ 190193323Sed LLVMPPC_FP128TypeKind, /**< 128 bit floating point type (two 64-bits) */ 191193323Sed LLVMLabelTypeKind, /**< Labels */ 192193323Sed LLVMIntegerTypeKind, /**< Arbitrary bit width integers */ 193193323Sed LLVMFunctionTypeKind, /**< Functions */ 194193323Sed LLVMStructTypeKind, /**< Structures */ 195193323Sed LLVMArrayTypeKind, /**< Arrays */ 196193323Sed LLVMPointerTypeKind, /**< Pointers */ 197198090Srdivacky LLVMVectorTypeKind, /**< SIMD 'packed' format, or other vector type */ 198218893Sdim LLVMMetadataTypeKind, /**< Metadata */ 199296417Sdim LLVMX86_MMXTypeKind, /**< X86 MMX */ 200296417Sdim LLVMTokenTypeKind /**< Tokens */ 201193323Sed} LLVMTypeKind; 202193323Sed 203193323Sedtypedef enum { 204193323Sed LLVMExternalLinkage, /**< Externally visible function */ 205193323Sed LLVMAvailableExternallyLinkage, 206193323Sed LLVMLinkOnceAnyLinkage, /**< Keep one copy of function when linking (inline)*/ 207193323Sed LLVMLinkOnceODRLinkage, /**< Same, but only replaced by something 208193323Sed equivalent. */ 209261991Sdim LLVMLinkOnceODRAutoHideLinkage, /**< Obsolete */ 210193323Sed LLVMWeakAnyLinkage, /**< Keep one copy of function when linking (weak) */ 211193323Sed LLVMWeakODRLinkage, /**< Same, but only replaced by something 212193323Sed equivalent. */ 213193323Sed LLVMAppendingLinkage, /**< Special purpose, only applies to global arrays */ 214193323Sed LLVMInternalLinkage, /**< Rename collisions when linking (static 215193323Sed functions) */ 216193323Sed LLVMPrivateLinkage, /**< Like Internal, but omit from symbol table */ 217276479Sdim LLVMDLLImportLinkage, /**< Obsolete */ 218276479Sdim LLVMDLLExportLinkage, /**< Obsolete */ 219193323Sed LLVMExternalWeakLinkage,/**< ExternalWeak linkage description */ 220203954Srdivacky LLVMGhostLinkage, /**< Obsolete */ 221198090Srdivacky LLVMCommonLinkage, /**< Tentative definitions */ 222210299Sed LLVMLinkerPrivateLinkage, /**< Like Private, but linker removes. */ 223243830Sdim LLVMLinkerPrivateWeakLinkage /**< Like LinkerPrivate, but is weak. */ 224193323Sed} LLVMLinkage; 225193323Sed 226193323Sedtypedef enum { 227193323Sed LLVMDefaultVisibility, /**< The GV is visible */ 228193323Sed LLVMHiddenVisibility, /**< The GV is hidden */ 229193323Sed LLVMProtectedVisibility /**< The GV is protected */ 230193323Sed} LLVMVisibility; 231193323Sed 232193323Sedtypedef enum { 233276479Sdim LLVMDefaultStorageClass = 0, 234276479Sdim LLVMDLLImportStorageClass = 1, /**< Function to be imported from DLL. */ 235276479Sdim LLVMDLLExportStorageClass = 2 /**< Function to be accessible from DLL. */ 236276479Sdim} LLVMDLLStorageClass; 237276479Sdim 238276479Sdimtypedef enum { 239193323Sed LLVMCCallConv = 0, 240193323Sed LLVMFastCallConv = 8, 241193323Sed LLVMColdCallConv = 9, 242261991Sdim LLVMWebKitJSCallConv = 12, 243261991Sdim LLVMAnyRegCallConv = 13, 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 280226633Sdimtypedef enum { 281226633Sdim LLVMLandingPadCatch, /**< A catch clause */ 282226633Sdim LLVMLandingPadFilter /**< A filter clause */ 283226633Sdim} LLVMLandingPadClauseTy; 284226633Sdim 285251662Sdimtypedef enum { 286251662Sdim LLVMNotThreadLocal = 0, 287251662Sdim LLVMGeneralDynamicTLSModel, 288251662Sdim LLVMLocalDynamicTLSModel, 289251662Sdim LLVMInitialExecTLSModel, 290251662Sdim LLVMLocalExecTLSModel 291251662Sdim} LLVMThreadLocalMode; 292251662Sdim 293251662Sdimtypedef enum { 294251662Sdim LLVMAtomicOrderingNotAtomic = 0, /**< A load or store which is not atomic */ 295251662Sdim LLVMAtomicOrderingUnordered = 1, /**< Lowest level of atomicity, guarantees 296251662Sdim somewhat sane results, lock free. */ 297261991Sdim LLVMAtomicOrderingMonotonic = 2, /**< guarantees that if you take all the 298261991Sdim operations affecting a specific address, 299251662Sdim a consistent ordering exists */ 300261991Sdim LLVMAtomicOrderingAcquire = 4, /**< Acquire provides a barrier of the sort 301261991Sdim necessary to acquire a lock to access other 302251662Sdim memory with normal loads and stores. */ 303261991Sdim LLVMAtomicOrderingRelease = 5, /**< Release is similar to Acquire, but with 304261991Sdim a barrier of the sort necessary to release 305251662Sdim a lock. */ 306261991Sdim LLVMAtomicOrderingAcquireRelease = 6, /**< provides both an Acquire and a 307261991Sdim Release barrier (for fences and 308251662Sdim operations which both read and write 309251662Sdim memory). */ 310261991Sdim LLVMAtomicOrderingSequentiallyConsistent = 7 /**< provides Acquire semantics 311261991Sdim for loads and Release 312261991Sdim semantics for stores. 313261991Sdim Additionally, it guarantees 314261991Sdim that a total ordering exists 315261991Sdim between all 316261991Sdim SequentiallyConsistent 317251662Sdim operations. */ 318251662Sdim} LLVMAtomicOrdering; 319251662Sdim 320251662Sdimtypedef enum { 321251662Sdim LLVMAtomicRMWBinOpXchg, /**< Set the new value and return the one old */ 322251662Sdim LLVMAtomicRMWBinOpAdd, /**< Add a value and return the old one */ 323251662Sdim LLVMAtomicRMWBinOpSub, /**< Subtract a value and return the old one */ 324251662Sdim LLVMAtomicRMWBinOpAnd, /**< And a value and return the old one */ 325251662Sdim LLVMAtomicRMWBinOpNand, /**< Not-And a value and return the old one */ 326251662Sdim LLVMAtomicRMWBinOpOr, /**< OR a value and return the old one */ 327251662Sdim LLVMAtomicRMWBinOpXor, /**< Xor a value and return the old one */ 328251662Sdim LLVMAtomicRMWBinOpMax, /**< Sets the value if it's greater than the 329261991Sdim original using a signed comparison and return 330251662Sdim the old one */ 331251662Sdim LLVMAtomicRMWBinOpMin, /**< Sets the value if it's Smaller than the 332261991Sdim original using a signed comparison and return 333251662Sdim the old one */ 334251662Sdim LLVMAtomicRMWBinOpUMax, /**< Sets the value if it's greater than the 335261991Sdim original using an unsigned comparison and return 336251662Sdim the old one */ 337251662Sdim LLVMAtomicRMWBinOpUMin /**< Sets the value if it's greater than the 338261991Sdim original using an unsigned comparison and return 339251662Sdim the old one */ 340251662Sdim} LLVMAtomicRMWBinOp; 341251662Sdim 342276479Sdimtypedef enum { 343276479Sdim LLVMDSError, 344276479Sdim LLVMDSWarning, 345276479Sdim LLVMDSRemark, 346276479Sdim LLVMDSNote 347276479Sdim} LLVMDiagnosticSeverity; 348276479Sdim 349234353Sdim/** 350234353Sdim * @} 351234353Sdim */ 352234353Sdim 353223017Sdimvoid LLVMInitializeCore(LLVMPassRegistryRef R); 354193323Sed 355249423Sdim/** Deallocate and destroy all ManagedStatic variables. 356249423Sdim @see llvm::llvm_shutdown 357249423Sdim @see ManagedStatic */ 358261991Sdimvoid LLVMShutdown(void); 359223017Sdim 360193323Sed/*===-- Error handling ----------------------------------------------------===*/ 361193323Sed 362261991Sdimchar *LLVMCreateMessage(const char *Message); 363193323Sedvoid LLVMDisposeMessage(char *Message); 364193323Sed 365234353Sdim/** 366234353Sdim * @defgroup LLVMCCoreContext Contexts 367234353Sdim * 368234353Sdim * Contexts are execution states for the core LLVM IR system. 369234353Sdim * 370234353Sdim * Most types are tied to a context instance. Multiple contexts can 371234353Sdim * exist simultaneously. A single context is not thread safe. However, 372234353Sdim * different contexts can execute on different threads simultaneously. 373234353Sdim * 374234353Sdim * @{ 375234353Sdim */ 376193323Sed 377276479Sdimtypedef void (*LLVMDiagnosticHandler)(LLVMDiagnosticInfoRef, void *); 378276479Sdimtypedef void (*LLVMYieldCallback)(LLVMContextRef, void *); 379276479Sdim 380234353Sdim/** 381234353Sdim * Create a new context. 382234353Sdim * 383234353Sdim * Every call to this function should be paired with a call to 384234353Sdim * LLVMContextDispose() or the context will leak memory. 385234353Sdim */ 386198090SrdivackyLLVMContextRef LLVMContextCreate(void); 387234353Sdim 388234353Sdim/** 389234353Sdim * Obtain the global context instance. 390234353Sdim */ 391198090SrdivackyLLVMContextRef LLVMGetGlobalContext(void); 392234353Sdim 393234353Sdim/** 394276479Sdim * Set the diagnostic handler for this context. 395276479Sdim */ 396276479Sdimvoid LLVMContextSetDiagnosticHandler(LLVMContextRef C, 397276479Sdim LLVMDiagnosticHandler Handler, 398276479Sdim void *DiagnosticContext); 399276479Sdim 400276479Sdim/** 401276479Sdim * Set the yield callback function for this context. 402276479Sdim * 403276479Sdim * @see LLVMContext::setYieldCallback() 404276479Sdim */ 405276479Sdimvoid LLVMContextSetYieldCallback(LLVMContextRef C, LLVMYieldCallback Callback, 406276479Sdim void *OpaqueHandle); 407276479Sdim 408276479Sdim/** 409234353Sdim * Destroy a context instance. 410234353Sdim * 411234353Sdim * This should be called for every call to LLVMContextCreate() or memory 412234353Sdim * will be leaked. 413234353Sdim */ 414195340Sedvoid LLVMContextDispose(LLVMContextRef C); 415195340Sed 416276479Sdim/** 417276479Sdim * Return a string representation of the DiagnosticInfo. Use 418276479Sdim * LLVMDisposeMessage to free the string. 419276479Sdim * 420276479Sdim * @see DiagnosticInfo::print() 421276479Sdim */ 422276479Sdimchar *LLVMGetDiagInfoDescription(LLVMDiagnosticInfoRef DI); 423276479Sdim 424276479Sdim/** 425276479Sdim * Return an enum LLVMDiagnosticSeverity. 426276479Sdim * 427276479Sdim * @see DiagnosticInfo::getSeverity() 428276479Sdim */ 429276479SdimLLVMDiagnosticSeverity LLVMGetDiagInfoSeverity(LLVMDiagnosticInfoRef DI); 430276479Sdim 431204642Srdivackyunsigned LLVMGetMDKindIDInContext(LLVMContextRef C, const char* Name, 432204642Srdivacky unsigned SLen); 433204642Srdivackyunsigned LLVMGetMDKindID(const char* Name, unsigned SLen); 434204642Srdivacky 435234353Sdim/** 436234353Sdim * @} 437234353Sdim */ 438204642Srdivacky 439234353Sdim/** 440234353Sdim * @defgroup LLVMCCoreModule Modules 441234353Sdim * 442261991Sdim * Modules represent the top-level structure in an LLVM program. An LLVM 443234353Sdim * module is effectively a translation unit or a collection of 444234353Sdim * translation units merged together. 445234353Sdim * 446234353Sdim * @{ 447234353Sdim */ 448234353Sdim 449234353Sdim/** 450234353Sdim * Create a new, empty module in the global context. 451234353Sdim * 452234353Sdim * This is equivalent to calling LLVMModuleCreateWithNameInContext with 453234353Sdim * LLVMGetGlobalContext() as the context parameter. 454234353Sdim * 455234353Sdim * Every invocation should be paired with LLVMDisposeModule() or memory 456234353Sdim * will be leaked. 457234353Sdim */ 458193323SedLLVMModuleRef LLVMModuleCreateWithName(const char *ModuleID); 459234353Sdim 460234353Sdim/** 461234353Sdim * Create a new, empty module in a specific context. 462234353Sdim * 463234353Sdim * Every invocation should be paired with LLVMDisposeModule() or memory 464234353Sdim * will be leaked. 465234353Sdim */ 466195340SedLLVMModuleRef LLVMModuleCreateWithNameInContext(const char *ModuleID, 467195340Sed LLVMContextRef C); 468280031Sdim/** 469280031Sdim * Return an exact copy of the specified module. 470280031Sdim */ 471280031SdimLLVMModuleRef LLVMCloneModule(LLVMModuleRef M); 472193323Sed 473234353Sdim/** 474234353Sdim * Destroy a module instance. 475234353Sdim * 476234353Sdim * This must be called for every created module or memory will be 477234353Sdim * leaked. 478234353Sdim */ 479193323Sedvoid LLVMDisposeModule(LLVMModuleRef M); 480193323Sed 481234353Sdim/** 482234353Sdim * Obtain the data layout for a module. 483234353Sdim * 484234353Sdim * @see Module::getDataLayout() 485234353Sdim */ 486193323Sedconst char *LLVMGetDataLayout(LLVMModuleRef M); 487234353Sdim 488234353Sdim/** 489234353Sdim * Set the data layout for a module. 490234353Sdim * 491234353Sdim * @see Module::setDataLayout() 492234353Sdim */ 493193323Sedvoid LLVMSetDataLayout(LLVMModuleRef M, const char *Triple); 494193323Sed 495234353Sdim/** 496234353Sdim * Obtain the target triple for a module. 497234353Sdim * 498234353Sdim * @see Module::getTargetTriple() 499234353Sdim */ 500193323Sedconst char *LLVMGetTarget(LLVMModuleRef M); 501234353Sdim 502234353Sdim/** 503234353Sdim * Set the target triple for a module. 504234353Sdim * 505234353Sdim * @see Module::setTargetTriple() 506234353Sdim */ 507193323Sedvoid LLVMSetTarget(LLVMModuleRef M, const char *Triple); 508193323Sed 509234353Sdim/** 510234353Sdim * Dump a representation of a module to stderr. 511234353Sdim * 512234353Sdim * @see Module::dump() 513234353Sdim */ 514193323Sedvoid LLVMDumpModule(LLVMModuleRef M); 515193323Sed 516234353Sdim/** 517239462Sdim * Print a representation of a module to a file. The ErrorMessage needs to be 518239462Sdim * disposed with LLVMDisposeMessage. Returns 0 on success, 1 otherwise. 519239462Sdim * 520239462Sdim * @see Module::print() 521239462Sdim */ 522239462SdimLLVMBool LLVMPrintModuleToFile(LLVMModuleRef M, const char *Filename, 523239462Sdim char **ErrorMessage); 524239462Sdim 525239462Sdim/** 526261991Sdim * Return a string representation of the module. Use 527261991Sdim * LLVMDisposeMessage to free the string. 528261991Sdim * 529261991Sdim * @see Module::print() 530261991Sdim */ 531261991Sdimchar *LLVMPrintModuleToString(LLVMModuleRef M); 532261991Sdim 533261991Sdim/** 534234353Sdim * Set inline assembly for a module. 535234353Sdim * 536234353Sdim * @see Module::setModuleInlineAsm() 537234353Sdim */ 538207618Srdivackyvoid LLVMSetModuleInlineAsm(LLVMModuleRef M, const char *Asm); 539193323Sed 540234353Sdim/** 541234353Sdim * Obtain the context to which this module is associated. 542234353Sdim * 543234353Sdim * @see Module::getContext() 544234353Sdim */ 545218893SdimLLVMContextRef LLVMGetModuleContext(LLVMModuleRef M); 546218893Sdim 547234353Sdim/** 548234353Sdim * Obtain a Type from a module by its registered name. 549234353Sdim */ 550234353SdimLLVMTypeRef LLVMGetTypeByName(LLVMModuleRef M, const char *Name); 551193323Sed 552234353Sdim/** 553234353Sdim * Obtain the number of operands for named metadata in a module. 554234353Sdim * 555234353Sdim * @see llvm::Module::getNamedMetadata() 556234353Sdim */ 557234353Sdimunsigned LLVMGetNamedMetadataNumOperands(LLVMModuleRef M, const char* name); 558234353Sdim 559234353Sdim/** 560234353Sdim * Obtain the named metadata operands for a module. 561234353Sdim * 562234353Sdim * The passed LLVMValueRef pointer should refer to an array of 563234353Sdim * LLVMValueRef at least LLVMGetNamedMetadataNumOperands long. This 564234353Sdim * array will be populated with the LLVMValueRef instances. Each 565234353Sdim * instance corresponds to a llvm::MDNode. 566234353Sdim * 567234353Sdim * @see llvm::Module::getNamedMetadata() 568234353Sdim * @see llvm::MDNode::getOperand() 569234353Sdim */ 570234353Sdimvoid LLVMGetNamedMetadataOperands(LLVMModuleRef M, const char* name, LLVMValueRef *Dest); 571234353Sdim 572234353Sdim/** 573234353Sdim * Add an operand to named metadata. 574234353Sdim * 575234353Sdim * @see llvm::Module::getNamedMetadata() 576234353Sdim * @see llvm::MDNode::addOperand() 577234353Sdim */ 578234353Sdimvoid LLVMAddNamedMetadataOperand(LLVMModuleRef M, const char* name, 579234353Sdim LLVMValueRef Val); 580234353Sdim 581234353Sdim/** 582234353Sdim * Add a function to a module under a specified name. 583234353Sdim * 584234353Sdim * @see llvm::Function::Create() 585234353Sdim */ 586234353SdimLLVMValueRef LLVMAddFunction(LLVMModuleRef M, const char *Name, 587234353Sdim LLVMTypeRef FunctionTy); 588234353Sdim 589234353Sdim/** 590234353Sdim * Obtain a Function value from a Module by its name. 591234353Sdim * 592234353Sdim * The returned value corresponds to a llvm::Function value. 593234353Sdim * 594234353Sdim * @see llvm::Module::getFunction() 595234353Sdim */ 596234353SdimLLVMValueRef LLVMGetNamedFunction(LLVMModuleRef M, const char *Name); 597234353Sdim 598234353Sdim/** 599234353Sdim * Obtain an iterator to the first Function in a Module. 600234353Sdim * 601234353Sdim * @see llvm::Module::begin() 602234353Sdim */ 603234353SdimLLVMValueRef LLVMGetFirstFunction(LLVMModuleRef M); 604234353Sdim 605234353Sdim/** 606234353Sdim * Obtain an iterator to the last Function in a Module. 607234353Sdim * 608234353Sdim * @see llvm::Module::end() 609234353Sdim */ 610234353SdimLLVMValueRef LLVMGetLastFunction(LLVMModuleRef M); 611234353Sdim 612234353Sdim/** 613234353Sdim * Advance a Function iterator to the next Function. 614234353Sdim * 615234353Sdim * Returns NULL if the iterator was already at the end and there are no more 616234353Sdim * functions. 617234353Sdim */ 618234353SdimLLVMValueRef LLVMGetNextFunction(LLVMValueRef Fn); 619234353Sdim 620234353Sdim/** 621234353Sdim * Decrement a Function iterator to the previous Function. 622234353Sdim * 623234353Sdim * Returns NULL if the iterator was already at the beginning and there are 624234353Sdim * no previous functions. 625234353Sdim */ 626234353SdimLLVMValueRef LLVMGetPreviousFunction(LLVMValueRef Fn); 627234353Sdim 628234353Sdim/** 629234353Sdim * @} 630234353Sdim */ 631234353Sdim 632234353Sdim/** 633234353Sdim * @defgroup LLVMCCoreType Types 634234353Sdim * 635234353Sdim * Types represent the type of a value. 636234353Sdim * 637234353Sdim * Types are associated with a context instance. The context internally 638234353Sdim * deduplicates types so there is only 1 instance of a specific type 639234353Sdim * alive at a time. In other words, a unique type is shared among all 640234353Sdim * consumers within a context. 641234353Sdim * 642234353Sdim * A Type in the C API corresponds to llvm::Type. 643234353Sdim * 644234353Sdim * Types have the following hierarchy: 645234353Sdim * 646193323Sed * types: 647193323Sed * integer type 648193323Sed * real type 649193323Sed * function type 650193323Sed * sequence types: 651193323Sed * array type 652193323Sed * pointer type 653193323Sed * vector type 654193323Sed * void type 655193323Sed * label type 656193323Sed * opaque type 657234353Sdim * 658234353Sdim * @{ 659193323Sed */ 660193323Sed 661234353Sdim/** 662234353Sdim * Obtain the enumerated type of a Type instance. 663234353Sdim * 664234353Sdim * @see llvm::Type:getTypeID() 665234353Sdim */ 666193323SedLLVMTypeKind LLVMGetTypeKind(LLVMTypeRef Ty); 667234353Sdim 668234353Sdim/** 669234353Sdim * Whether the type has a known size. 670234353Sdim * 671234353Sdim * Things that don't have a size are abstract types, labels, and void.a 672234353Sdim * 673234353Sdim * @see llvm::Type::isSized() 674234353Sdim */ 675226633SdimLLVMBool LLVMTypeIsSized(LLVMTypeRef Ty); 676193323Sed 677234353Sdim/** 678234353Sdim * Obtain the context to which this type instance is associated. 679234353Sdim * 680234353Sdim * @see llvm::Type::getContext() 681234353Sdim */ 682198090SrdivackyLLVMContextRef LLVMGetTypeContext(LLVMTypeRef Ty); 683198090Srdivacky 684234353Sdim/** 685261991Sdim * Dump a representation of a type to stderr. 686261991Sdim * 687261991Sdim * @see llvm::Type::dump() 688261991Sdim */ 689261991Sdimvoid LLVMDumpType(LLVMTypeRef Val); 690261991Sdim 691261991Sdim/** 692261991Sdim * Return a string representation of the type. Use 693261991Sdim * LLVMDisposeMessage to free the string. 694261991Sdim * 695261991Sdim * @see llvm::Type::print() 696261991Sdim */ 697261991Sdimchar *LLVMPrintTypeToString(LLVMTypeRef Val); 698261991Sdim 699261991Sdim/** 700234353Sdim * @defgroup LLVMCCoreTypeInt Integer Types 701234353Sdim * 702234353Sdim * Functions in this section operate on integer types. 703234353Sdim * 704234353Sdim * @{ 705234353Sdim */ 706234353Sdim 707234353Sdim/** 708234353Sdim * Obtain an integer type from a context with specified bit width. 709234353Sdim */ 710198090SrdivackyLLVMTypeRef LLVMInt1TypeInContext(LLVMContextRef C); 711198090SrdivackyLLVMTypeRef LLVMInt8TypeInContext(LLVMContextRef C); 712198090SrdivackyLLVMTypeRef LLVMInt16TypeInContext(LLVMContextRef C); 713198090SrdivackyLLVMTypeRef LLVMInt32TypeInContext(LLVMContextRef C); 714198090SrdivackyLLVMTypeRef LLVMInt64TypeInContext(LLVMContextRef C); 715296417SdimLLVMTypeRef LLVMInt128TypeInContext(LLVMContextRef C); 716198090SrdivackyLLVMTypeRef LLVMIntTypeInContext(LLVMContextRef C, unsigned NumBits); 717198090Srdivacky 718234353Sdim/** 719234353Sdim * Obtain an integer type from the global context with a specified bit 720234353Sdim * width. 721234353Sdim */ 722193323SedLLVMTypeRef LLVMInt1Type(void); 723193323SedLLVMTypeRef LLVMInt8Type(void); 724193323SedLLVMTypeRef LLVMInt16Type(void); 725193323SedLLVMTypeRef LLVMInt32Type(void); 726193323SedLLVMTypeRef LLVMInt64Type(void); 727296417SdimLLVMTypeRef LLVMInt128Type(void); 728193323SedLLVMTypeRef LLVMIntType(unsigned NumBits); 729193323Sedunsigned LLVMGetIntTypeWidth(LLVMTypeRef IntegerTy); 730193323Sed 731234353Sdim/** 732234353Sdim * @} 733234353Sdim */ 734234353Sdim 735234353Sdim/** 736234353Sdim * @defgroup LLVMCCoreTypeFloat Floating Point Types 737234353Sdim * 738234353Sdim * @{ 739234353Sdim */ 740234353Sdim 741234353Sdim/** 742234353Sdim * Obtain a 16-bit floating point type from a context. 743234353Sdim */ 744234353SdimLLVMTypeRef LLVMHalfTypeInContext(LLVMContextRef C); 745234353Sdim 746234353Sdim/** 747234353Sdim * Obtain a 32-bit floating point type from a context. 748234353Sdim */ 749198090SrdivackyLLVMTypeRef LLVMFloatTypeInContext(LLVMContextRef C); 750234353Sdim 751234353Sdim/** 752234353Sdim * Obtain a 64-bit floating point type from a context. 753234353Sdim */ 754198090SrdivackyLLVMTypeRef LLVMDoubleTypeInContext(LLVMContextRef C); 755234353Sdim 756234353Sdim/** 757234353Sdim * Obtain a 80-bit floating point type (X87) from a context. 758234353Sdim */ 759198090SrdivackyLLVMTypeRef LLVMX86FP80TypeInContext(LLVMContextRef C); 760234353Sdim 761234353Sdim/** 762234353Sdim * Obtain a 128-bit floating point type (112-bit mantissa) from a 763234353Sdim * context. 764234353Sdim */ 765198090SrdivackyLLVMTypeRef LLVMFP128TypeInContext(LLVMContextRef C); 766234353Sdim 767234353Sdim/** 768234353Sdim * Obtain a 128-bit floating point type (two 64-bits) from a context. 769234353Sdim */ 770198090SrdivackyLLVMTypeRef LLVMPPCFP128TypeInContext(LLVMContextRef C); 771198090Srdivacky 772234353Sdim/** 773234353Sdim * Obtain a floating point type from the global context. 774234353Sdim * 775234353Sdim * These map to the functions in this group of the same name. 776234353Sdim */ 777234353SdimLLVMTypeRef LLVMHalfType(void); 778193323SedLLVMTypeRef LLVMFloatType(void); 779193323SedLLVMTypeRef LLVMDoubleType(void); 780193323SedLLVMTypeRef LLVMX86FP80Type(void); 781193323SedLLVMTypeRef LLVMFP128Type(void); 782193323SedLLVMTypeRef LLVMPPCFP128Type(void); 783193323Sed 784234353Sdim/** 785234353Sdim * @} 786234353Sdim */ 787234353Sdim 788234353Sdim/** 789234353Sdim * @defgroup LLVMCCoreTypeFunction Function Types 790234353Sdim * 791234353Sdim * @{ 792234353Sdim */ 793234353Sdim 794234353Sdim/** 795234353Sdim * Obtain a function type consisting of a specified signature. 796234353Sdim * 797234353Sdim * The function is defined as a tuple of a return Type, a list of 798234353Sdim * parameter types, and whether the function is variadic. 799234353Sdim */ 800193323SedLLVMTypeRef LLVMFunctionType(LLVMTypeRef ReturnType, 801193323Sed LLVMTypeRef *ParamTypes, unsigned ParamCount, 802202375Srdivacky LLVMBool IsVarArg); 803234353Sdim 804234353Sdim/** 805234353Sdim * Returns whether a function type is variadic. 806234353Sdim */ 807202375SrdivackyLLVMBool LLVMIsFunctionVarArg(LLVMTypeRef FunctionTy); 808234353Sdim 809234353Sdim/** 810234353Sdim * Obtain the Type this function Type returns. 811234353Sdim */ 812193323SedLLVMTypeRef LLVMGetReturnType(LLVMTypeRef FunctionTy); 813234353Sdim 814234353Sdim/** 815234353Sdim * Obtain the number of parameters this function accepts. 816234353Sdim */ 817193323Sedunsigned LLVMCountParamTypes(LLVMTypeRef FunctionTy); 818234353Sdim 819234353Sdim/** 820234353Sdim * Obtain the types of a function's parameters. 821234353Sdim * 822234353Sdim * The Dest parameter should point to a pre-allocated array of 823234353Sdim * LLVMTypeRef at least LLVMCountParamTypes() large. On return, the 824234353Sdim * first LLVMCountParamTypes() entries in the array will be populated 825234353Sdim * with LLVMTypeRef instances. 826234353Sdim * 827234353Sdim * @param FunctionTy The function type to operate on. 828234353Sdim * @param Dest Memory address of an array to be filled with result. 829234353Sdim */ 830193323Sedvoid LLVMGetParamTypes(LLVMTypeRef FunctionTy, LLVMTypeRef *Dest); 831193323Sed 832234353Sdim/** 833234353Sdim * @} 834234353Sdim */ 835234353Sdim 836234353Sdim/** 837234353Sdim * @defgroup LLVMCCoreTypeStruct Structure Types 838234353Sdim * 839234353Sdim * These functions relate to LLVMTypeRef instances. 840234353Sdim * 841234353Sdim * @see llvm::StructType 842234353Sdim * 843234353Sdim * @{ 844234353Sdim */ 845234353Sdim 846234353Sdim/** 847234353Sdim * Create a new structure type in a context. 848234353Sdim * 849234353Sdim * A structure is specified by a list of inner elements/types and 850234353Sdim * whether these can be packed together. 851234353Sdim * 852234353Sdim * @see llvm::StructType::create() 853234353Sdim */ 854198090SrdivackyLLVMTypeRef LLVMStructTypeInContext(LLVMContextRef C, LLVMTypeRef *ElementTypes, 855202375Srdivacky unsigned ElementCount, LLVMBool Packed); 856234353Sdim 857234353Sdim/** 858234353Sdim * Create a new structure type in the global context. 859234353Sdim * 860234353Sdim * @see llvm::StructType::create() 861234353Sdim */ 862193323SedLLVMTypeRef LLVMStructType(LLVMTypeRef *ElementTypes, unsigned ElementCount, 863202375Srdivacky LLVMBool Packed); 864234353Sdim 865234353Sdim/** 866234353Sdim * Create an empty structure in a context having a specified name. 867234353Sdim * 868234353Sdim * @see llvm::StructType::create() 869234353Sdim */ 870224145SdimLLVMTypeRef LLVMStructCreateNamed(LLVMContextRef C, const char *Name); 871234353Sdim 872234353Sdim/** 873234353Sdim * Obtain the name of a structure. 874234353Sdim * 875234353Sdim * @see llvm::StructType::getName() 876234353Sdim */ 877226633Sdimconst char *LLVMGetStructName(LLVMTypeRef Ty); 878234353Sdim 879234353Sdim/** 880234353Sdim * Set the contents of a structure type. 881234353Sdim * 882234353Sdim * @see llvm::StructType::setBody() 883234353Sdim */ 884224145Sdimvoid LLVMStructSetBody(LLVMTypeRef StructTy, LLVMTypeRef *ElementTypes, 885224145Sdim unsigned ElementCount, LLVMBool Packed); 886224145Sdim 887234353Sdim/** 888234353Sdim * Get the number of elements defined inside the structure. 889234353Sdim * 890234353Sdim * @see llvm::StructType::getNumElements() 891234353Sdim */ 892193323Sedunsigned LLVMCountStructElementTypes(LLVMTypeRef StructTy); 893234353Sdim 894234353Sdim/** 895234353Sdim * Get the elements within a structure. 896234353Sdim * 897234353Sdim * The function is passed the address of a pre-allocated array of 898234353Sdim * LLVMTypeRef at least LLVMCountStructElementTypes() long. After 899234353Sdim * invocation, this array will be populated with the structure's 900234353Sdim * elements. The objects in the destination array will have a lifetime 901234353Sdim * of the structure type itself, which is the lifetime of the context it 902234353Sdim * is contained in. 903234353Sdim */ 904193323Sedvoid LLVMGetStructElementTypes(LLVMTypeRef StructTy, LLVMTypeRef *Dest); 905234353Sdim 906234353Sdim/** 907288943Sdim * Get the type of the element at a given index in the structure. 908288943Sdim * 909288943Sdim * @see llvm::StructType::getTypeAtIndex() 910288943Sdim */ 911288943SdimLLVMTypeRef LLVMStructGetTypeAtIndex(LLVMTypeRef StructTy, unsigned i); 912288943Sdim 913288943Sdim/** 914234353Sdim * Determine whether a structure is packed. 915234353Sdim * 916234353Sdim * @see llvm::StructType::isPacked() 917234353Sdim */ 918202375SrdivackyLLVMBool LLVMIsPackedStruct(LLVMTypeRef StructTy); 919234353Sdim 920234353Sdim/** 921234353Sdim * Determine whether a structure is opaque. 922234353Sdim * 923234353Sdim * @see llvm::StructType::isOpaque() 924234353Sdim */ 925224145SdimLLVMBool LLVMIsOpaqueStruct(LLVMTypeRef StructTy); 926193323Sed 927234353Sdim/** 928234353Sdim * @} 929234353Sdim */ 930224145Sdim 931234353Sdim/** 932234353Sdim * @defgroup LLVMCCoreTypeSequential Sequential Types 933234353Sdim * 934234353Sdim * Sequential types represents "arrays" of types. This is a super class 935234353Sdim * for array, vector, and pointer types. 936234353Sdim * 937234353Sdim * @{ 938234353Sdim */ 939234353Sdim 940234353Sdim/** 941234353Sdim * Obtain the type of elements within a sequential type. 942234353Sdim * 943234353Sdim * This works on array, vector, and pointer types. 944234353Sdim * 945234353Sdim * @see llvm::SequentialType::getElementType() 946234353Sdim */ 947234353SdimLLVMTypeRef LLVMGetElementType(LLVMTypeRef Ty); 948234353Sdim 949234353Sdim/** 950234353Sdim * Create a fixed size array type that refers to a specific type. 951234353Sdim * 952234353Sdim * The created type will exist in the context that its element type 953234353Sdim * exists in. 954234353Sdim * 955234353Sdim * @see llvm::ArrayType::get() 956234353Sdim */ 957193323SedLLVMTypeRef LLVMArrayType(LLVMTypeRef ElementType, unsigned ElementCount); 958234353Sdim 959234353Sdim/** 960234353Sdim * Obtain the length of an array type. 961234353Sdim * 962234353Sdim * This only works on types that represent arrays. 963234353Sdim * 964234353Sdim * @see llvm::ArrayType::getNumElements() 965234353Sdim */ 966234353Sdimunsigned LLVMGetArrayLength(LLVMTypeRef ArrayTy); 967234353Sdim 968234353Sdim/** 969234353Sdim * Create a pointer type that points to a defined type. 970234353Sdim * 971234353Sdim * The created type will exist in the context that its pointee type 972234353Sdim * exists in. 973234353Sdim * 974234353Sdim * @see llvm::PointerType::get() 975234353Sdim */ 976193323SedLLVMTypeRef LLVMPointerType(LLVMTypeRef ElementType, unsigned AddressSpace); 977234353Sdim 978234353Sdim/** 979234353Sdim * Obtain the address space of a pointer type. 980234353Sdim * 981234353Sdim * This only works on types that represent pointers. 982234353Sdim * 983234353Sdim * @see llvm::PointerType::getAddressSpace() 984234353Sdim */ 985234353Sdimunsigned LLVMGetPointerAddressSpace(LLVMTypeRef PointerTy); 986234353Sdim 987234353Sdim/** 988234353Sdim * Create a vector type that contains a defined type and has a specific 989234353Sdim * number of elements. 990234353Sdim * 991234353Sdim * The created type will exist in the context thats its element type 992234353Sdim * exists in. 993234353Sdim * 994234353Sdim * @see llvm::VectorType::get() 995234353Sdim */ 996193323SedLLVMTypeRef LLVMVectorType(LLVMTypeRef ElementType, unsigned ElementCount); 997193323Sed 998234353Sdim/** 999234353Sdim * Obtain the number of elements in a vector type. 1000234353Sdim * 1001234353Sdim * This only works on types that represent vectors. 1002234353Sdim * 1003234353Sdim * @see llvm::VectorType::getNumElements() 1004234353Sdim */ 1005193323Sedunsigned LLVMGetVectorSize(LLVMTypeRef VectorTy); 1006193323Sed 1007234353Sdim/** 1008234353Sdim * @} 1009234353Sdim */ 1010234353Sdim 1011234353Sdim/** 1012234353Sdim * @defgroup LLVMCCoreTypeOther Other Types 1013234353Sdim * 1014234353Sdim * @{ 1015234353Sdim */ 1016234353Sdim 1017234353Sdim/** 1018234353Sdim * Create a void type in a context. 1019234353Sdim */ 1020198090SrdivackyLLVMTypeRef LLVMVoidTypeInContext(LLVMContextRef C); 1021234353Sdim 1022234353Sdim/** 1023234353Sdim * Create a label type in a context. 1024234353Sdim */ 1025198090SrdivackyLLVMTypeRef LLVMLabelTypeInContext(LLVMContextRef C); 1026234353Sdim 1027234353Sdim/** 1028234353Sdim * Create a X86 MMX type in a context. 1029234353Sdim */ 1030218893SdimLLVMTypeRef LLVMX86MMXTypeInContext(LLVMContextRef C); 1031198090Srdivacky 1032234353Sdim/** 1033234353Sdim * These are similar to the above functions except they operate on the 1034234353Sdim * global context. 1035234353Sdim */ 1036193323SedLLVMTypeRef LLVMVoidType(void); 1037193323SedLLVMTypeRef LLVMLabelType(void); 1038218893SdimLLVMTypeRef LLVMX86MMXType(void); 1039193323Sed 1040234353Sdim/** 1041234353Sdim * @} 1042234353Sdim */ 1043193323Sed 1044234353Sdim/** 1045234353Sdim * @} 1046234353Sdim */ 1047234353Sdim 1048234353Sdim/** 1049234353Sdim * @defgroup LLVMCCoreValues Values 1050234353Sdim * 1051234353Sdim * The bulk of LLVM's object model consists of values, which comprise a very 1052193323Sed * rich type hierarchy. 1053234353Sdim * 1054234353Sdim * LLVMValueRef essentially represents llvm::Value. There is a rich 1055234353Sdim * hierarchy of classes within this type. Depending on the instance 1056239462Sdim * obtained, not all APIs are available. 1057234353Sdim * 1058261991Sdim * Callers can determine the type of an LLVMValueRef by calling the 1059234353Sdim * LLVMIsA* family of functions (e.g. LLVMIsAArgument()). These 1060234353Sdim * functions are defined by a macro, so it isn't obvious which are 1061234353Sdim * available by looking at the Doxygen source code. Instead, look at the 1062234353Sdim * source definition of LLVM_FOR_EACH_VALUE_SUBCLASS and note the list 1063234353Sdim * of value names given. These value names also correspond to classes in 1064234353Sdim * the llvm::Value hierarchy. 1065234353Sdim * 1066234353Sdim * @{ 1067193323Sed */ 1068193323Sed 1069193323Sed#define LLVM_FOR_EACH_VALUE_SUBCLASS(macro) \ 1070193323Sed macro(Argument) \ 1071193323Sed macro(BasicBlock) \ 1072193323Sed macro(InlineAsm) \ 1073193323Sed macro(User) \ 1074193323Sed macro(Constant) \ 1075226633Sdim macro(BlockAddress) \ 1076193323Sed macro(ConstantAggregateZero) \ 1077193323Sed macro(ConstantArray) \ 1078261991Sdim macro(ConstantDataSequential) \ 1079261991Sdim macro(ConstantDataArray) \ 1080261991Sdim macro(ConstantDataVector) \ 1081193323Sed macro(ConstantExpr) \ 1082193323Sed macro(ConstantFP) \ 1083193323Sed macro(ConstantInt) \ 1084193323Sed macro(ConstantPointerNull) \ 1085193323Sed macro(ConstantStruct) \ 1086296417Sdim macro(ConstantTokenNone) \ 1087193323Sed macro(ConstantVector) \ 1088193323Sed macro(GlobalValue) \ 1089193323Sed macro(GlobalAlias) \ 1090276479Sdim macro(GlobalObject) \ 1091276479Sdim macro(Function) \ 1092276479Sdim macro(GlobalVariable) \ 1093193323Sed macro(UndefValue) \ 1094193323Sed macro(Instruction) \ 1095193323Sed macro(BinaryOperator) \ 1096193323Sed macro(CallInst) \ 1097193323Sed macro(IntrinsicInst) \ 1098193323Sed macro(DbgInfoIntrinsic) \ 1099193323Sed macro(DbgDeclareInst) \ 1100193323Sed macro(MemIntrinsic) \ 1101193323Sed macro(MemCpyInst) \ 1102193323Sed macro(MemMoveInst) \ 1103193323Sed macro(MemSetInst) \ 1104193323Sed macro(CmpInst) \ 1105226633Sdim macro(FCmpInst) \ 1106226633Sdim macro(ICmpInst) \ 1107193323Sed macro(ExtractElementInst) \ 1108193323Sed macro(GetElementPtrInst) \ 1109193323Sed macro(InsertElementInst) \ 1110193323Sed macro(InsertValueInst) \ 1111226633Sdim macro(LandingPadInst) \ 1112193323Sed macro(PHINode) \ 1113193323Sed macro(SelectInst) \ 1114193323Sed macro(ShuffleVectorInst) \ 1115193323Sed macro(StoreInst) \ 1116193323Sed macro(TerminatorInst) \ 1117193323Sed macro(BranchInst) \ 1118226633Sdim macro(IndirectBrInst) \ 1119193323Sed macro(InvokeInst) \ 1120193323Sed macro(ReturnInst) \ 1121193323Sed macro(SwitchInst) \ 1122193323Sed macro(UnreachableInst) \ 1123226633Sdim macro(ResumeInst) \ 1124296417Sdim macro(CleanupReturnInst) \ 1125296417Sdim macro(CatchReturnInst) \ 1126296417Sdim macro(FuncletPadInst) \ 1127296417Sdim macro(CatchPadInst) \ 1128296417Sdim macro(CleanupPadInst) \ 1129251662Sdim macro(UnaryInstruction) \ 1130251662Sdim macro(AllocaInst) \ 1131251662Sdim macro(CastInst) \ 1132261991Sdim macro(AddrSpaceCastInst) \ 1133251662Sdim macro(BitCastInst) \ 1134251662Sdim macro(FPExtInst) \ 1135251662Sdim macro(FPToSIInst) \ 1136251662Sdim macro(FPToUIInst) \ 1137251662Sdim macro(FPTruncInst) \ 1138251662Sdim macro(IntToPtrInst) \ 1139251662Sdim macro(PtrToIntInst) \ 1140251662Sdim macro(SExtInst) \ 1141251662Sdim macro(SIToFPInst) \ 1142251662Sdim macro(TruncInst) \ 1143251662Sdim macro(UIToFPInst) \ 1144251662Sdim macro(ZExtInst) \ 1145251662Sdim macro(ExtractValueInst) \ 1146251662Sdim macro(LoadInst) \ 1147251662Sdim macro(VAArgInst) 1148193323Sed 1149234353Sdim/** 1150234353Sdim * @defgroup LLVMCCoreValueGeneral General APIs 1151234353Sdim * 1152234353Sdim * Functions in this section work on all LLVMValueRef instances, 1153234353Sdim * regardless of their sub-type. They correspond to functions available 1154234353Sdim * on llvm::Value. 1155234353Sdim * 1156234353Sdim * @{ 1157234353Sdim */ 1158234353Sdim 1159234353Sdim/** 1160234353Sdim * Obtain the type of a value. 1161234353Sdim * 1162234353Sdim * @see llvm::Value::getType() 1163234353Sdim */ 1164193323SedLLVMTypeRef LLVMTypeOf(LLVMValueRef Val); 1165234353Sdim 1166234353Sdim/** 1167234353Sdim * Obtain the string name of a value. 1168234353Sdim * 1169234353Sdim * @see llvm::Value::getName() 1170234353Sdim */ 1171193323Sedconst char *LLVMGetValueName(LLVMValueRef Val); 1172234353Sdim 1173234353Sdim/** 1174234353Sdim * Set the string name of a value. 1175234353Sdim * 1176234353Sdim * @see llvm::Value::setName() 1177234353Sdim */ 1178193323Sedvoid LLVMSetValueName(LLVMValueRef Val, const char *Name); 1179234353Sdim 1180234353Sdim/** 1181234353Sdim * Dump a representation of a value to stderr. 1182234353Sdim * 1183234353Sdim * @see llvm::Value::dump() 1184234353Sdim */ 1185193323Sedvoid LLVMDumpValue(LLVMValueRef Val); 1186234353Sdim 1187234353Sdim/** 1188261991Sdim * Return a string representation of the value. Use 1189261991Sdim * LLVMDisposeMessage to free the string. 1190261991Sdim * 1191261991Sdim * @see llvm::Value::print() 1192261991Sdim */ 1193261991Sdimchar *LLVMPrintValueToString(LLVMValueRef Val); 1194261991Sdim 1195261991Sdim/** 1196234353Sdim * Replace all uses of a value with another one. 1197234353Sdim * 1198234353Sdim * @see llvm::Value::replaceAllUsesWith() 1199234353Sdim */ 1200198090Srdivackyvoid LLVMReplaceAllUsesWith(LLVMValueRef OldVal, LLVMValueRef NewVal); 1201193323Sed 1202234353Sdim/** 1203234353Sdim * Determine whether the specified constant instance is constant. 1204234353Sdim */ 1205234353SdimLLVMBool LLVMIsConstant(LLVMValueRef Val); 1206234353Sdim 1207234353Sdim/** 1208234353Sdim * Determine whether a value instance is undefined. 1209234353Sdim */ 1210234353SdimLLVMBool LLVMIsUndef(LLVMValueRef Val); 1211234353Sdim 1212234353Sdim/** 1213234353Sdim * Convert value instances between types. 1214234353Sdim * 1215261991Sdim * Internally, an LLVMValueRef is "pinned" to a specific type. This 1216234353Sdim * series of functions allows you to cast an instance to a specific 1217234353Sdim * type. 1218234353Sdim * 1219234353Sdim * If the cast is not valid for the specified type, NULL is returned. 1220234353Sdim * 1221234353Sdim * @see llvm::dyn_cast_or_null<> 1222234353Sdim */ 1223193323Sed#define LLVM_DECLARE_VALUE_CAST(name) \ 1224193323Sed LLVMValueRef LLVMIsA##name(LLVMValueRef Val); 1225193323SedLLVM_FOR_EACH_VALUE_SUBCLASS(LLVM_DECLARE_VALUE_CAST) 1226193323Sed 1227280031SdimLLVMValueRef LLVMIsAMDNode(LLVMValueRef Val); 1228280031SdimLLVMValueRef LLVMIsAMDString(LLVMValueRef Val); 1229280031Sdim 1230234353Sdim/** 1231234353Sdim * @} 1232234353Sdim */ 1233234353Sdim 1234234353Sdim/** 1235234353Sdim * @defgroup LLVMCCoreValueUses Usage 1236234353Sdim * 1237234353Sdim * This module defines functions that allow you to inspect the uses of a 1238234353Sdim * LLVMValueRef. 1239234353Sdim * 1240261991Sdim * It is possible to obtain an LLVMUseRef for any LLVMValueRef instance. 1241234353Sdim * Each LLVMUseRef (which corresponds to a llvm::Use instance) holds a 1242234353Sdim * llvm::User and llvm::Value. 1243234353Sdim * 1244234353Sdim * @{ 1245234353Sdim */ 1246234353Sdim 1247234353Sdim/** 1248234353Sdim * Obtain the first use of a value. 1249234353Sdim * 1250234353Sdim * Uses are obtained in an iterator fashion. First, call this function 1251234353Sdim * to obtain a reference to the first use. Then, call LLVMGetNextUse() 1252239462Sdim * on that instance and all subsequently obtained instances until 1253234353Sdim * LLVMGetNextUse() returns NULL. 1254234353Sdim * 1255234353Sdim * @see llvm::Value::use_begin() 1256234353Sdim */ 1257204642SrdivackyLLVMUseRef LLVMGetFirstUse(LLVMValueRef Val); 1258234353Sdim 1259234353Sdim/** 1260234353Sdim * Obtain the next use of a value. 1261234353Sdim * 1262234353Sdim * This effectively advances the iterator. It returns NULL if you are on 1263234353Sdim * the final use and no more are available. 1264234353Sdim */ 1265204642SrdivackyLLVMUseRef LLVMGetNextUse(LLVMUseRef U); 1266234353Sdim 1267234353Sdim/** 1268234353Sdim * Obtain the user value for a user. 1269234353Sdim * 1270234353Sdim * The returned value corresponds to a llvm::User type. 1271234353Sdim * 1272234353Sdim * @see llvm::Use::getUser() 1273234353Sdim */ 1274204642SrdivackyLLVMValueRef LLVMGetUser(LLVMUseRef U); 1275234353Sdim 1276234353Sdim/** 1277234353Sdim * Obtain the value this use corresponds to. 1278234353Sdim * 1279234353Sdim * @see llvm::Use::get(). 1280234353Sdim */ 1281204642SrdivackyLLVMValueRef LLVMGetUsedValue(LLVMUseRef U); 1282198090Srdivacky 1283234353Sdim/** 1284234353Sdim * @} 1285234353Sdim */ 1286234353Sdim 1287234353Sdim/** 1288234353Sdim * @defgroup LLVMCCoreValueUser User value 1289234353Sdim * 1290234353Sdim * Function in this group pertain to LLVMValueRef instances that descent 1291234353Sdim * from llvm::User. This includes constants, instructions, and 1292234353Sdim * operators. 1293234353Sdim * 1294234353Sdim * @{ 1295234353Sdim */ 1296234353Sdim 1297234353Sdim/** 1298234353Sdim * Obtain an operand at a specific index in a llvm::User value. 1299234353Sdim * 1300234353Sdim * @see llvm::User::getOperand() 1301234353Sdim */ 1302198090SrdivackyLLVMValueRef LLVMGetOperand(LLVMValueRef Val, unsigned Index); 1303234353Sdim 1304234353Sdim/** 1305280031Sdim * Obtain the use of an operand at a specific index in a llvm::User value. 1306280031Sdim * 1307280031Sdim * @see llvm::User::getOperandUse() 1308280031Sdim */ 1309280031SdimLLVMUseRef LLVMGetOperandUse(LLVMValueRef Val, unsigned Index); 1310280031Sdim 1311280031Sdim/** 1312234353Sdim * Set an operand at a specific index in a llvm::User value. 1313234353Sdim * 1314234353Sdim * @see llvm::User::setOperand() 1315234353Sdim */ 1316212904Sdimvoid LLVMSetOperand(LLVMValueRef User, unsigned Index, LLVMValueRef Val); 1317234353Sdim 1318234353Sdim/** 1319234353Sdim * Obtain the number of operands in a llvm::User value. 1320234353Sdim * 1321234353Sdim * @see llvm::User::getNumOperands() 1322234353Sdim */ 1323212904Sdimint LLVMGetNumOperands(LLVMValueRef Val); 1324198090Srdivacky 1325234353Sdim/** 1326234353Sdim * @} 1327234353Sdim */ 1328234353Sdim 1329234353Sdim/** 1330234353Sdim * @defgroup LLVMCCoreValueConstant Constants 1331234353Sdim * 1332234353Sdim * This section contains APIs for interacting with LLVMValueRef that 1333234353Sdim * correspond to llvm::Constant instances. 1334234353Sdim * 1335234353Sdim * These functions will work for any LLVMValueRef in the llvm::Constant 1336234353Sdim * class hierarchy. 1337234353Sdim * 1338234353Sdim * @{ 1339234353Sdim */ 1340234353Sdim 1341234353Sdim/** 1342234353Sdim * Obtain a constant value referring to the null instance of a type. 1343234353Sdim * 1344234353Sdim * @see llvm::Constant::getNullValue() 1345234353Sdim */ 1346193323SedLLVMValueRef LLVMConstNull(LLVMTypeRef Ty); /* all zeroes */ 1347234353Sdim 1348234353Sdim/** 1349234353Sdim * Obtain a constant value referring to the instance of a type 1350234353Sdim * consisting of all ones. 1351234353Sdim * 1352234353Sdim * This is only valid for integer types. 1353234353Sdim * 1354234353Sdim * @see llvm::Constant::getAllOnesValue() 1355234353Sdim */ 1356234353SdimLLVMValueRef LLVMConstAllOnes(LLVMTypeRef Ty); 1357234353Sdim 1358234353Sdim/** 1359234353Sdim * Obtain a constant value referring to an undefined value of a type. 1360234353Sdim * 1361234353Sdim * @see llvm::UndefValue::get() 1362234353Sdim */ 1363193323SedLLVMValueRef LLVMGetUndef(LLVMTypeRef Ty); 1364234353Sdim 1365234353Sdim/** 1366234353Sdim * Determine whether a value instance is null. 1367234353Sdim * 1368234353Sdim * @see llvm::Constant::isNullValue() 1369234353Sdim */ 1370202375SrdivackyLLVMBool LLVMIsNull(LLVMValueRef Val); 1371234353Sdim 1372234353Sdim/** 1373234353Sdim * Obtain a constant that is a constant pointer pointing to NULL for a 1374234353Sdim * specified type. 1375234353Sdim */ 1376198090SrdivackyLLVMValueRef LLVMConstPointerNull(LLVMTypeRef Ty); 1377193323Sed 1378234353Sdim/** 1379234353Sdim * @defgroup LLVMCCoreValueConstantScalar Scalar constants 1380234353Sdim * 1381234353Sdim * Functions in this group model LLVMValueRef instances that correspond 1382234353Sdim * to constants referring to scalar types. 1383234353Sdim * 1384234353Sdim * For integer types, the LLVMTypeRef parameter should correspond to a 1385234353Sdim * llvm::IntegerType instance and the returned LLVMValueRef will 1386234353Sdim * correspond to a llvm::ConstantInt. 1387234353Sdim * 1388234353Sdim * For floating point types, the LLVMTypeRef returned corresponds to a 1389234353Sdim * llvm::ConstantFP. 1390234353Sdim * 1391234353Sdim * @{ 1392234353Sdim */ 1393204642Srdivacky 1394234353Sdim/** 1395234353Sdim * Obtain a constant value for an integer type. 1396234353Sdim * 1397234353Sdim * The returned value corresponds to a llvm::ConstantInt. 1398234353Sdim * 1399234353Sdim * @see llvm::ConstantInt::get() 1400234353Sdim * 1401234353Sdim * @param IntTy Integer type to obtain value of. 1402234353Sdim * @param N The value the returned instance should refer to. 1403234353Sdim * @param SignExtend Whether to sign extend the produced value. 1404234353Sdim */ 1405193323SedLLVMValueRef LLVMConstInt(LLVMTypeRef IntTy, unsigned long long N, 1406202375Srdivacky LLVMBool SignExtend); 1407234353Sdim 1408234353Sdim/** 1409234353Sdim * Obtain a constant value for an integer of arbitrary precision. 1410234353Sdim * 1411234353Sdim * @see llvm::ConstantInt::get() 1412234353Sdim */ 1413218893SdimLLVMValueRef LLVMConstIntOfArbitraryPrecision(LLVMTypeRef IntTy, 1414218893Sdim unsigned NumWords, 1415218893Sdim const uint64_t Words[]); 1416234353Sdim 1417234353Sdim/** 1418234353Sdim * Obtain a constant value for an integer parsed from a string. 1419234353Sdim * 1420234353Sdim * A similar API, LLVMConstIntOfStringAndSize is also available. If the 1421234353Sdim * string's length is available, it is preferred to call that function 1422234353Sdim * instead. 1423234353Sdim * 1424234353Sdim * @see llvm::ConstantInt::get() 1425234353Sdim */ 1426198090SrdivackyLLVMValueRef LLVMConstIntOfString(LLVMTypeRef IntTy, const char *Text, 1427198090Srdivacky uint8_t Radix); 1428234353Sdim 1429234353Sdim/** 1430234353Sdim * Obtain a constant value for an integer parsed from a string with 1431234353Sdim * specified length. 1432234353Sdim * 1433234353Sdim * @see llvm::ConstantInt::get() 1434234353Sdim */ 1435198090SrdivackyLLVMValueRef LLVMConstIntOfStringAndSize(LLVMTypeRef IntTy, const char *Text, 1436198090Srdivacky unsigned SLen, uint8_t Radix); 1437234353Sdim 1438234353Sdim/** 1439234353Sdim * Obtain a constant value referring to a double floating point value. 1440234353Sdim */ 1441193323SedLLVMValueRef LLVMConstReal(LLVMTypeRef RealTy, double N); 1442234353Sdim 1443234353Sdim/** 1444234353Sdim * Obtain a constant for a floating point value parsed from a string. 1445234353Sdim * 1446234353Sdim * A similar API, LLVMConstRealOfStringAndSize is also available. It 1447234353Sdim * should be used if the input string's length is known. 1448234353Sdim */ 1449193323SedLLVMValueRef LLVMConstRealOfString(LLVMTypeRef RealTy, const char *Text); 1450234353Sdim 1451234353Sdim/** 1452234353Sdim * Obtain a constant for a floating point value parsed from a string. 1453234353Sdim */ 1454198090SrdivackyLLVMValueRef LLVMConstRealOfStringAndSize(LLVMTypeRef RealTy, const char *Text, 1455198090Srdivacky unsigned SLen); 1456234353Sdim 1457234353Sdim/** 1458234353Sdim * Obtain the zero extended value for an integer constant value. 1459234353Sdim * 1460234353Sdim * @see llvm::ConstantInt::getZExtValue() 1461234353Sdim */ 1462198090Srdivackyunsigned long long LLVMConstIntGetZExtValue(LLVMValueRef ConstantVal); 1463234353Sdim 1464234353Sdim/** 1465234353Sdim * Obtain the sign extended value for an integer constant value. 1466234353Sdim * 1467234353Sdim * @see llvm::ConstantInt::getSExtValue() 1468234353Sdim */ 1469198090Srdivackylong long LLVMConstIntGetSExtValue(LLVMValueRef ConstantVal); 1470193323Sed 1471234353Sdim/** 1472280031Sdim * Obtain the double value for an floating point constant value. 1473280031Sdim * losesInfo indicates if some precision was lost in the conversion. 1474280031Sdim * 1475280031Sdim * @see llvm::ConstantFP::getDoubleValue 1476280031Sdim */ 1477280031Sdimdouble LLVMConstRealGetDouble(LLVMValueRef ConstantVal, LLVMBool *losesInfo); 1478280031Sdim 1479280031Sdim/** 1480234353Sdim * @} 1481234353Sdim */ 1482198090Srdivacky 1483234353Sdim/** 1484234353Sdim * @defgroup LLVMCCoreValueConstantComposite Composite Constants 1485234353Sdim * 1486234353Sdim * Functions in this group operate on composite constants. 1487234353Sdim * 1488234353Sdim * @{ 1489234353Sdim */ 1490234353Sdim 1491234353Sdim/** 1492234353Sdim * Create a ConstantDataSequential and initialize it with a string. 1493234353Sdim * 1494234353Sdim * @see llvm::ConstantDataArray::getString() 1495234353Sdim */ 1496198090SrdivackyLLVMValueRef LLVMConstStringInContext(LLVMContextRef C, const char *Str, 1497202375Srdivacky unsigned Length, LLVMBool DontNullTerminate); 1498234353Sdim 1499234353Sdim/** 1500234353Sdim * Create a ConstantDataSequential with string content in the global context. 1501234353Sdim * 1502234353Sdim * This is the same as LLVMConstStringInContext except it operates on the 1503234353Sdim * global context. 1504234353Sdim * 1505234353Sdim * @see LLVMConstStringInContext() 1506234353Sdim * @see llvm::ConstantDataArray::getString() 1507234353Sdim */ 1508234353SdimLLVMValueRef LLVMConstString(const char *Str, unsigned Length, 1509234353Sdim LLVMBool DontNullTerminate); 1510234353Sdim 1511234353Sdim/** 1512280031Sdim * Returns true if the specified constant is an array of i8. 1513280031Sdim * 1514280031Sdim * @see ConstantDataSequential::getAsString() 1515280031Sdim */ 1516280031SdimLLVMBool LLVMIsConstantString(LLVMValueRef c); 1517280031Sdim 1518280031Sdim/** 1519280031Sdim * Get the given constant data sequential as a string. 1520280031Sdim * 1521280031Sdim * @see ConstantDataSequential::getAsString() 1522280031Sdim */ 1523280031Sdimconst char *LLVMGetAsString(LLVMValueRef c, size_t* out); 1524280031Sdim 1525280031Sdim/** 1526234353Sdim * Create an anonymous ConstantStruct with the specified values. 1527234353Sdim * 1528234353Sdim * @see llvm::ConstantStruct::getAnon() 1529234353Sdim */ 1530234353SdimLLVMValueRef LLVMConstStructInContext(LLVMContextRef C, 1531198090Srdivacky LLVMValueRef *ConstantVals, 1532202375Srdivacky unsigned Count, LLVMBool Packed); 1533198090Srdivacky 1534234353Sdim/** 1535234353Sdim * Create a ConstantStruct in the global Context. 1536234353Sdim * 1537234353Sdim * This is the same as LLVMConstStructInContext except it operates on the 1538234353Sdim * global Context. 1539234353Sdim * 1540234353Sdim * @see LLVMConstStructInContext() 1541234353Sdim */ 1542234353SdimLLVMValueRef LLVMConstStruct(LLVMValueRef *ConstantVals, unsigned Count, 1543234353Sdim LLVMBool Packed); 1544234353Sdim 1545234353Sdim/** 1546234353Sdim * Create a ConstantArray from values. 1547234353Sdim * 1548234353Sdim * @see llvm::ConstantArray::get() 1549234353Sdim */ 1550193323SedLLVMValueRef LLVMConstArray(LLVMTypeRef ElementTy, 1551193323Sed LLVMValueRef *ConstantVals, unsigned Length); 1552234353Sdim 1553234353Sdim/** 1554234353Sdim * Create a non-anonymous ConstantStruct from values. 1555234353Sdim * 1556234353Sdim * @see llvm::ConstantStruct::get() 1557234353Sdim */ 1558224145SdimLLVMValueRef LLVMConstNamedStruct(LLVMTypeRef StructTy, 1559224145Sdim LLVMValueRef *ConstantVals, 1560224145Sdim unsigned Count); 1561234353Sdim 1562234353Sdim/** 1563280031Sdim * Get an element at specified index as a constant. 1564280031Sdim * 1565280031Sdim * @see ConstantDataSequential::getElementAsConstant() 1566280031Sdim */ 1567280031SdimLLVMValueRef LLVMGetElementAsConstant(LLVMValueRef c, unsigned idx); 1568280031Sdim 1569280031Sdim/** 1570234353Sdim * Create a ConstantVector from values. 1571234353Sdim * 1572234353Sdim * @see llvm::ConstantVector::get() 1573234353Sdim */ 1574193323SedLLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals, unsigned Size); 1575193323Sed 1576234353Sdim/** 1577234353Sdim * @} 1578234353Sdim */ 1579234353Sdim 1580234353Sdim/** 1581234353Sdim * @defgroup LLVMCCoreValueConstantExpressions Constant Expressions 1582234353Sdim * 1583234353Sdim * Functions in this group correspond to APIs on llvm::ConstantExpr. 1584234353Sdim * 1585234353Sdim * @see llvm::ConstantExpr. 1586234353Sdim * 1587234353Sdim * @{ 1588234353Sdim */ 1589198090SrdivackyLLVMOpcode LLVMGetConstOpcode(LLVMValueRef ConstantVal); 1590198090SrdivackyLLVMValueRef LLVMAlignOf(LLVMTypeRef Ty); 1591193323SedLLVMValueRef LLVMSizeOf(LLVMTypeRef Ty); 1592193323SedLLVMValueRef LLVMConstNeg(LLVMValueRef ConstantVal); 1593204642SrdivackyLLVMValueRef LLVMConstNSWNeg(LLVMValueRef ConstantVal); 1594204642SrdivackyLLVMValueRef LLVMConstNUWNeg(LLVMValueRef ConstantVal); 1595198090SrdivackyLLVMValueRef LLVMConstFNeg(LLVMValueRef ConstantVal); 1596193323SedLLVMValueRef LLVMConstNot(LLVMValueRef ConstantVal); 1597193323SedLLVMValueRef LLVMConstAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); 1598198090SrdivackyLLVMValueRef LLVMConstNSWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); 1599204642SrdivackyLLVMValueRef LLVMConstNUWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); 1600198090SrdivackyLLVMValueRef LLVMConstFAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); 1601193323SedLLVMValueRef LLVMConstSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); 1602204642SrdivackyLLVMValueRef LLVMConstNSWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); 1603204642SrdivackyLLVMValueRef LLVMConstNUWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); 1604198090SrdivackyLLVMValueRef LLVMConstFSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); 1605193323SedLLVMValueRef LLVMConstMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); 1606204642SrdivackyLLVMValueRef LLVMConstNSWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); 1607204642SrdivackyLLVMValueRef LLVMConstNUWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); 1608198090SrdivackyLLVMValueRef LLVMConstFMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); 1609193323SedLLVMValueRef LLVMConstUDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); 1610193323SedLLVMValueRef LLVMConstSDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); 1611198090SrdivackyLLVMValueRef LLVMConstExactSDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); 1612193323SedLLVMValueRef LLVMConstFDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); 1613193323SedLLVMValueRef LLVMConstURem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); 1614193323SedLLVMValueRef LLVMConstSRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); 1615193323SedLLVMValueRef LLVMConstFRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); 1616193323SedLLVMValueRef LLVMConstAnd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); 1617193323SedLLVMValueRef LLVMConstOr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); 1618193323SedLLVMValueRef LLVMConstXor(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); 1619193323SedLLVMValueRef LLVMConstICmp(LLVMIntPredicate Predicate, 1620193323Sed LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); 1621193323SedLLVMValueRef LLVMConstFCmp(LLVMRealPredicate Predicate, 1622193323Sed LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); 1623193323SedLLVMValueRef LLVMConstShl(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); 1624193323SedLLVMValueRef LLVMConstLShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); 1625193323SedLLVMValueRef LLVMConstAShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); 1626193323SedLLVMValueRef LLVMConstGEP(LLVMValueRef ConstantVal, 1627193323Sed LLVMValueRef *ConstantIndices, unsigned NumIndices); 1628198090SrdivackyLLVMValueRef LLVMConstInBoundsGEP(LLVMValueRef ConstantVal, 1629198090Srdivacky LLVMValueRef *ConstantIndices, 1630198090Srdivacky unsigned NumIndices); 1631193323SedLLVMValueRef LLVMConstTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType); 1632193323SedLLVMValueRef LLVMConstSExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType); 1633193323SedLLVMValueRef LLVMConstZExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType); 1634193323SedLLVMValueRef LLVMConstFPTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType); 1635193323SedLLVMValueRef LLVMConstFPExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType); 1636193323SedLLVMValueRef LLVMConstUIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType); 1637193323SedLLVMValueRef LLVMConstSIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType); 1638193323SedLLVMValueRef LLVMConstFPToUI(LLVMValueRef ConstantVal, LLVMTypeRef ToType); 1639193323SedLLVMValueRef LLVMConstFPToSI(LLVMValueRef ConstantVal, LLVMTypeRef ToType); 1640193323SedLLVMValueRef LLVMConstPtrToInt(LLVMValueRef ConstantVal, LLVMTypeRef ToType); 1641193323SedLLVMValueRef LLVMConstIntToPtr(LLVMValueRef ConstantVal, LLVMTypeRef ToType); 1642193323SedLLVMValueRef LLVMConstBitCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType); 1643261991SdimLLVMValueRef LLVMConstAddrSpaceCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType); 1644198090SrdivackyLLVMValueRef LLVMConstZExtOrBitCast(LLVMValueRef ConstantVal, 1645198090Srdivacky LLVMTypeRef ToType); 1646198090SrdivackyLLVMValueRef LLVMConstSExtOrBitCast(LLVMValueRef ConstantVal, 1647198090Srdivacky LLVMTypeRef ToType); 1648198090SrdivackyLLVMValueRef LLVMConstTruncOrBitCast(LLVMValueRef ConstantVal, 1649198090Srdivacky LLVMTypeRef ToType); 1650198090SrdivackyLLVMValueRef LLVMConstPointerCast(LLVMValueRef ConstantVal, 1651198090Srdivacky LLVMTypeRef ToType); 1652198090SrdivackyLLVMValueRef LLVMConstIntCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType, 1653202375Srdivacky LLVMBool isSigned); 1654198090SrdivackyLLVMValueRef LLVMConstFPCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType); 1655193323SedLLVMValueRef LLVMConstSelect(LLVMValueRef ConstantCondition, 1656193323Sed LLVMValueRef ConstantIfTrue, 1657193323Sed LLVMValueRef ConstantIfFalse); 1658193323SedLLVMValueRef LLVMConstExtractElement(LLVMValueRef VectorConstant, 1659193323Sed LLVMValueRef IndexConstant); 1660193323SedLLVMValueRef LLVMConstInsertElement(LLVMValueRef VectorConstant, 1661193323Sed LLVMValueRef ElementValueConstant, 1662193323Sed LLVMValueRef IndexConstant); 1663193323SedLLVMValueRef LLVMConstShuffleVector(LLVMValueRef VectorAConstant, 1664193323Sed LLVMValueRef VectorBConstant, 1665193323Sed LLVMValueRef MaskConstant); 1666193323SedLLVMValueRef LLVMConstExtractValue(LLVMValueRef AggConstant, unsigned *IdxList, 1667193323Sed unsigned NumIdx); 1668193323SedLLVMValueRef LLVMConstInsertValue(LLVMValueRef AggConstant, 1669193323Sed LLVMValueRef ElementValueConstant, 1670193323Sed unsigned *IdxList, unsigned NumIdx); 1671202375SrdivackyLLVMValueRef LLVMConstInlineAsm(LLVMTypeRef Ty, 1672193323Sed const char *AsmString, const char *Constraints, 1673202375Srdivacky LLVMBool HasSideEffects, LLVMBool IsAlignStack); 1674204642SrdivackyLLVMValueRef LLVMBlockAddress(LLVMValueRef F, LLVMBasicBlockRef BB); 1675193323Sed 1676234353Sdim/** 1677234353Sdim * @} 1678234353Sdim */ 1679234353Sdim 1680234353Sdim/** 1681234353Sdim * @defgroup LLVMCCoreValueConstantGlobals Global Values 1682234353Sdim * 1683234353Sdim * This group contains functions that operate on global values. Functions in 1684234353Sdim * this group relate to functions in the llvm::GlobalValue class tree. 1685234353Sdim * 1686234353Sdim * @see llvm::GlobalValue 1687234353Sdim * 1688234353Sdim * @{ 1689234353Sdim */ 1690234353Sdim 1691193323SedLLVMModuleRef LLVMGetGlobalParent(LLVMValueRef Global); 1692202375SrdivackyLLVMBool LLVMIsDeclaration(LLVMValueRef Global); 1693193323SedLLVMLinkage LLVMGetLinkage(LLVMValueRef Global); 1694193323Sedvoid LLVMSetLinkage(LLVMValueRef Global, LLVMLinkage Linkage); 1695193323Sedconst char *LLVMGetSection(LLVMValueRef Global); 1696193323Sedvoid LLVMSetSection(LLVMValueRef Global, const char *Section); 1697193323SedLLVMVisibility LLVMGetVisibility(LLVMValueRef Global); 1698193323Sedvoid LLVMSetVisibility(LLVMValueRef Global, LLVMVisibility Viz); 1699276479SdimLLVMDLLStorageClass LLVMGetDLLStorageClass(LLVMValueRef Global); 1700276479Sdimvoid LLVMSetDLLStorageClass(LLVMValueRef Global, LLVMDLLStorageClass Class); 1701276479SdimLLVMBool LLVMHasUnnamedAddr(LLVMValueRef Global); 1702276479Sdimvoid LLVMSetUnnamedAddr(LLVMValueRef Global, LLVMBool HasUnnamedAddr); 1703193323Sed 1704234353Sdim/** 1705261991Sdim * @defgroup LLVMCCoreValueWithAlignment Values with alignment 1706261991Sdim * 1707261991Sdim * Functions in this group only apply to values with alignment, i.e. 1708261991Sdim * global variables, load and store instructions. 1709261991Sdim */ 1710261991Sdim 1711261991Sdim/** 1712261991Sdim * Obtain the preferred alignment of the value. 1713276479Sdim * @see llvm::AllocaInst::getAlignment() 1714261991Sdim * @see llvm::LoadInst::getAlignment() 1715261991Sdim * @see llvm::StoreInst::getAlignment() 1716261991Sdim * @see llvm::GlobalValue::getAlignment() 1717261991Sdim */ 1718261991Sdimunsigned LLVMGetAlignment(LLVMValueRef V); 1719261991Sdim 1720261991Sdim/** 1721261991Sdim * Set the preferred alignment of the value. 1722276479Sdim * @see llvm::AllocaInst::setAlignment() 1723261991Sdim * @see llvm::LoadInst::setAlignment() 1724261991Sdim * @see llvm::StoreInst::setAlignment() 1725261991Sdim * @see llvm::GlobalValue::setAlignment() 1726261991Sdim */ 1727261991Sdimvoid LLVMSetAlignment(LLVMValueRef V, unsigned Bytes); 1728261991Sdim 1729261991Sdim/** 1730261991Sdim * @} 1731261991Sdim */ 1732261991Sdim 1733261991Sdim/** 1734234353Sdim * @defgroup LLVMCoreValueConstantGlobalVariable Global Variables 1735234353Sdim * 1736234353Sdim * This group contains functions that operate on global variable values. 1737234353Sdim * 1738234353Sdim * @see llvm::GlobalVariable 1739234353Sdim * 1740234353Sdim * @{ 1741234353Sdim */ 1742193323SedLLVMValueRef LLVMAddGlobal(LLVMModuleRef M, LLVMTypeRef Ty, const char *Name); 1743204642SrdivackyLLVMValueRef LLVMAddGlobalInAddressSpace(LLVMModuleRef M, LLVMTypeRef Ty, 1744204642Srdivacky const char *Name, 1745204642Srdivacky unsigned AddressSpace); 1746193323SedLLVMValueRef LLVMGetNamedGlobal(LLVMModuleRef M, const char *Name); 1747193323SedLLVMValueRef LLVMGetFirstGlobal(LLVMModuleRef M); 1748193323SedLLVMValueRef LLVMGetLastGlobal(LLVMModuleRef M); 1749193323SedLLVMValueRef LLVMGetNextGlobal(LLVMValueRef GlobalVar); 1750193323SedLLVMValueRef LLVMGetPreviousGlobal(LLVMValueRef GlobalVar); 1751193323Sedvoid LLVMDeleteGlobal(LLVMValueRef GlobalVar); 1752193323SedLLVMValueRef LLVMGetInitializer(LLVMValueRef GlobalVar); 1753193323Sedvoid LLVMSetInitializer(LLVMValueRef GlobalVar, LLVMValueRef ConstantVal); 1754202375SrdivackyLLVMBool LLVMIsThreadLocal(LLVMValueRef GlobalVar); 1755202375Srdivackyvoid LLVMSetThreadLocal(LLVMValueRef GlobalVar, LLVMBool IsThreadLocal); 1756202375SrdivackyLLVMBool LLVMIsGlobalConstant(LLVMValueRef GlobalVar); 1757202375Srdivackyvoid LLVMSetGlobalConstant(LLVMValueRef GlobalVar, LLVMBool IsConstant); 1758251662SdimLLVMThreadLocalMode LLVMGetThreadLocalMode(LLVMValueRef GlobalVar); 1759251662Sdimvoid LLVMSetThreadLocalMode(LLVMValueRef GlobalVar, LLVMThreadLocalMode Mode); 1760251662SdimLLVMBool LLVMIsExternallyInitialized(LLVMValueRef GlobalVar); 1761251662Sdimvoid LLVMSetExternallyInitialized(LLVMValueRef GlobalVar, LLVMBool IsExtInit); 1762193323Sed 1763234353Sdim/** 1764234353Sdim * @} 1765234353Sdim */ 1766234353Sdim 1767234353Sdim/** 1768234353Sdim * @defgroup LLVMCoreValueConstantGlobalAlias Global Aliases 1769234353Sdim * 1770234353Sdim * This group contains function that operate on global alias values. 1771234353Sdim * 1772234353Sdim * @see llvm::GlobalAlias 1773234353Sdim * 1774234353Sdim * @{ 1775234353Sdim */ 1776193323SedLLVMValueRef LLVMAddAlias(LLVMModuleRef M, LLVMTypeRef Ty, LLVMValueRef Aliasee, 1777193323Sed const char *Name); 1778193323Sed 1779234353Sdim/** 1780234353Sdim * @} 1781234353Sdim */ 1782234353Sdim 1783234353Sdim/** 1784234353Sdim * @defgroup LLVMCCoreValueFunction Function values 1785234353Sdim * 1786234353Sdim * Functions in this group operate on LLVMValueRef instances that 1787234353Sdim * correspond to llvm::Function instances. 1788234353Sdim * 1789234353Sdim * @see llvm::Function 1790234353Sdim * 1791234353Sdim * @{ 1792234353Sdim */ 1793234353Sdim 1794234353Sdim/** 1795234353Sdim * Remove a function from its containing module and deletes it. 1796234353Sdim * 1797234353Sdim * @see llvm::Function::eraseFromParent() 1798234353Sdim */ 1799193323Sedvoid LLVMDeleteFunction(LLVMValueRef Fn); 1800234353Sdim 1801234353Sdim/** 1802288943Sdim * Obtain the personality function attached to the function. 1803288943Sdim * 1804288943Sdim * @see llvm::Function::getPersonalityFn() 1805288943Sdim */ 1806288943SdimLLVMValueRef LLVMGetPersonalityFn(LLVMValueRef Fn); 1807288943Sdim 1808288943Sdim/** 1809288943Sdim * Set the personality function attached to the function. 1810288943Sdim * 1811288943Sdim * @see llvm::Function::setPersonalityFn() 1812288943Sdim */ 1813288943Sdimvoid LLVMSetPersonalityFn(LLVMValueRef Fn, LLVMValueRef PersonalityFn); 1814288943Sdim 1815288943Sdim/** 1816234353Sdim * Obtain the ID number from a function instance. 1817234353Sdim * 1818234353Sdim * @see llvm::Function::getIntrinsicID() 1819234353Sdim */ 1820193323Sedunsigned LLVMGetIntrinsicID(LLVMValueRef Fn); 1821234353Sdim 1822234353Sdim/** 1823234353Sdim * Obtain the calling function of a function. 1824234353Sdim * 1825234353Sdim * The returned value corresponds to the LLVMCallConv enumeration. 1826234353Sdim * 1827234353Sdim * @see llvm::Function::getCallingConv() 1828234353Sdim */ 1829193323Sedunsigned LLVMGetFunctionCallConv(LLVMValueRef Fn); 1830234353Sdim 1831234353Sdim/** 1832234353Sdim * Set the calling convention of a function. 1833234353Sdim * 1834234353Sdim * @see llvm::Function::setCallingConv() 1835234353Sdim * 1836234353Sdim * @param Fn Function to operate on 1837234353Sdim * @param CC LLVMCallConv to set calling convention to 1838234353Sdim */ 1839193323Sedvoid LLVMSetFunctionCallConv(LLVMValueRef Fn, unsigned CC); 1840234353Sdim 1841234353Sdim/** 1842234353Sdim * Obtain the name of the garbage collector to use during code 1843234353Sdim * generation. 1844234353Sdim * 1845234353Sdim * @see llvm::Function::getGC() 1846234353Sdim */ 1847193323Sedconst char *LLVMGetGC(LLVMValueRef Fn); 1848234353Sdim 1849234353Sdim/** 1850234353Sdim * Define the garbage collector to use during code generation. 1851234353Sdim * 1852234353Sdim * @see llvm::Function::setGC() 1853234353Sdim */ 1854193323Sedvoid LLVMSetGC(LLVMValueRef Fn, const char *Name); 1855234353Sdim 1856234353Sdim/** 1857234353Sdim * Add an attribute to a function. 1858234353Sdim * 1859234353Sdim * @see llvm::Function::addAttribute() 1860234353Sdim */ 1861193323Sedvoid LLVMAddFunctionAttr(LLVMValueRef Fn, LLVMAttribute PA); 1862234353Sdim 1863234353Sdim/** 1864296417Sdim * Add a target-dependent attribute to a function 1865251662Sdim * @see llvm::AttrBuilder::addAttribute() 1866251662Sdim */ 1867251662Sdimvoid LLVMAddTargetDependentFunctionAttr(LLVMValueRef Fn, const char *A, 1868251662Sdim const char *V); 1869251662Sdim 1870251662Sdim/** 1871234353Sdim * Obtain an attribute from a function. 1872234353Sdim * 1873234353Sdim * @see llvm::Function::getAttributes() 1874234353Sdim */ 1875198090SrdivackyLLVMAttribute LLVMGetFunctionAttr(LLVMValueRef Fn); 1876234353Sdim 1877234353Sdim/** 1878234353Sdim * Remove an attribute from a function. 1879234353Sdim */ 1880193323Sedvoid LLVMRemoveFunctionAttr(LLVMValueRef Fn, LLVMAttribute PA); 1881193323Sed 1882234353Sdim/** 1883234353Sdim * @defgroup LLVMCCoreValueFunctionParameters Function Parameters 1884234353Sdim * 1885234353Sdim * Functions in this group relate to arguments/parameters on functions. 1886234353Sdim * 1887234353Sdim * Functions in this group expect LLVMValueRef instances that correspond 1888234353Sdim * to llvm::Function instances. 1889234353Sdim * 1890234353Sdim * @{ 1891234353Sdim */ 1892234353Sdim 1893234353Sdim/** 1894234353Sdim * Obtain the number of parameters in a function. 1895234353Sdim * 1896234353Sdim * @see llvm::Function::arg_size() 1897234353Sdim */ 1898193323Sedunsigned LLVMCountParams(LLVMValueRef Fn); 1899234353Sdim 1900234353Sdim/** 1901234353Sdim * Obtain the parameters in a function. 1902234353Sdim * 1903234353Sdim * The takes a pointer to a pre-allocated array of LLVMValueRef that is 1904234353Sdim * at least LLVMCountParams() long. This array will be filled with 1905234353Sdim * LLVMValueRef instances which correspond to the parameters the 1906234353Sdim * function receives. Each LLVMValueRef corresponds to a llvm::Argument 1907234353Sdim * instance. 1908234353Sdim * 1909234353Sdim * @see llvm::Function::arg_begin() 1910234353Sdim */ 1911193323Sedvoid LLVMGetParams(LLVMValueRef Fn, LLVMValueRef *Params); 1912234353Sdim 1913234353Sdim/** 1914234353Sdim * Obtain the parameter at the specified index. 1915234353Sdim * 1916234353Sdim * Parameters are indexed from 0. 1917234353Sdim * 1918234353Sdim * @see llvm::Function::arg_begin() 1919234353Sdim */ 1920193323SedLLVMValueRef LLVMGetParam(LLVMValueRef Fn, unsigned Index); 1921234353Sdim 1922234353Sdim/** 1923234353Sdim * Obtain the function to which this argument belongs. 1924234353Sdim * 1925261991Sdim * Unlike other functions in this group, this one takes an LLVMValueRef 1926234353Sdim * that corresponds to a llvm::Attribute. 1927234353Sdim * 1928234353Sdim * The returned LLVMValueRef is the llvm::Function to which this 1929234353Sdim * argument belongs. 1930234353Sdim */ 1931193323SedLLVMValueRef LLVMGetParamParent(LLVMValueRef Inst); 1932234353Sdim 1933234353Sdim/** 1934234353Sdim * Obtain the first parameter to a function. 1935234353Sdim * 1936234353Sdim * @see llvm::Function::arg_begin() 1937234353Sdim */ 1938193323SedLLVMValueRef LLVMGetFirstParam(LLVMValueRef Fn); 1939234353Sdim 1940234353Sdim/** 1941234353Sdim * Obtain the last parameter to a function. 1942234353Sdim * 1943234353Sdim * @see llvm::Function::arg_end() 1944234353Sdim */ 1945193323SedLLVMValueRef LLVMGetLastParam(LLVMValueRef Fn); 1946234353Sdim 1947234353Sdim/** 1948234353Sdim * Obtain the next parameter to a function. 1949234353Sdim * 1950261991Sdim * This takes an LLVMValueRef obtained from LLVMGetFirstParam() (which is 1951234353Sdim * actually a wrapped iterator) and obtains the next parameter from the 1952234353Sdim * underlying iterator. 1953234353Sdim */ 1954193323SedLLVMValueRef LLVMGetNextParam(LLVMValueRef Arg); 1955234353Sdim 1956234353Sdim/** 1957234353Sdim * Obtain the previous parameter to a function. 1958234353Sdim * 1959234353Sdim * This is the opposite of LLVMGetNextParam(). 1960234353Sdim */ 1961193323SedLLVMValueRef LLVMGetPreviousParam(LLVMValueRef Arg); 1962234353Sdim 1963234353Sdim/** 1964234353Sdim * Add an attribute to a function argument. 1965234353Sdim * 1966234353Sdim * @see llvm::Argument::addAttr() 1967234353Sdim */ 1968193323Sedvoid LLVMAddAttribute(LLVMValueRef Arg, LLVMAttribute PA); 1969234353Sdim 1970234353Sdim/** 1971234353Sdim * Remove an attribute from a function argument. 1972234353Sdim * 1973234353Sdim * @see llvm::Argument::removeAttr() 1974234353Sdim */ 1975193323Sedvoid LLVMRemoveAttribute(LLVMValueRef Arg, LLVMAttribute PA); 1976234353Sdim 1977234353Sdim/** 1978234353Sdim * Get an attribute from a function argument. 1979234353Sdim */ 1980198090SrdivackyLLVMAttribute LLVMGetAttribute(LLVMValueRef Arg); 1981234353Sdim 1982234353Sdim/** 1983234353Sdim * Set the alignment for a function parameter. 1984234353Sdim * 1985234353Sdim * @see llvm::Argument::addAttr() 1986243830Sdim * @see llvm::AttrBuilder::addAlignmentAttr() 1987234353Sdim */ 1988193323Sedvoid LLVMSetParamAlignment(LLVMValueRef Arg, unsigned align); 1989193323Sed 1990234353Sdim/** 1991234353Sdim * @} 1992234353Sdim */ 1993234353Sdim 1994234353Sdim/** 1995234353Sdim * @} 1996234353Sdim */ 1997234353Sdim 1998234353Sdim/** 1999234353Sdim * @} 2000234353Sdim */ 2001234353Sdim 2002234353Sdim/** 2003234353Sdim * @} 2004234353Sdim */ 2005234353Sdim 2006234353Sdim/** 2007234353Sdim * @defgroup LLVMCCoreValueMetadata Metadata 2008234353Sdim * 2009234353Sdim * @{ 2010234353Sdim */ 2011234353Sdim 2012234353Sdim/** 2013234353Sdim * Obtain a MDString value from a context. 2014234353Sdim * 2015234353Sdim * The returned instance corresponds to the llvm::MDString class. 2016234353Sdim * 2017234353Sdim * The instance is specified by string data of a specified length. The 2018234353Sdim * string content is copied, so the backing memory can be freed after 2019234353Sdim * this function returns. 2020234353Sdim */ 2021234353SdimLLVMValueRef LLVMMDStringInContext(LLVMContextRef C, const char *Str, 2022234353Sdim unsigned SLen); 2023234353Sdim 2024234353Sdim/** 2025234353Sdim * Obtain a MDString value from the global context. 2026234353Sdim */ 2027234353SdimLLVMValueRef LLVMMDString(const char *Str, unsigned SLen); 2028234353Sdim 2029234353Sdim/** 2030234353Sdim * Obtain a MDNode value from a context. 2031234353Sdim * 2032234353Sdim * The returned value corresponds to the llvm::MDNode class. 2033234353Sdim */ 2034234353SdimLLVMValueRef LLVMMDNodeInContext(LLVMContextRef C, LLVMValueRef *Vals, 2035234353Sdim unsigned Count); 2036234353Sdim 2037234353Sdim/** 2038234353Sdim * Obtain a MDNode value from the global context. 2039234353Sdim */ 2040234353SdimLLVMValueRef LLVMMDNode(LLVMValueRef *Vals, unsigned Count); 2041234353Sdim 2042234353Sdim/** 2043234353Sdim * Obtain the underlying string from a MDString value. 2044234353Sdim * 2045234353Sdim * @param V Instance to obtain string from. 2046234353Sdim * @param Len Memory address which will hold length of returned string. 2047234353Sdim * @return String data in MDString. 2048234353Sdim */ 2049234353Sdimconst char *LLVMGetMDString(LLVMValueRef V, unsigned* Len); 2050234353Sdim 2051234353Sdim/** 2052243830Sdim * Obtain the number of operands from an MDNode value. 2053243830Sdim * 2054243830Sdim * @param V MDNode to get number of operands from. 2055243830Sdim * @return Number of operands of the MDNode. 2056243830Sdim */ 2057243830Sdimunsigned LLVMGetMDNodeNumOperands(LLVMValueRef V); 2058243830Sdim 2059243830Sdim/** 2060243830Sdim * Obtain the given MDNode's operands. 2061243830Sdim * 2062243830Sdim * The passed LLVMValueRef pointer should point to enough memory to hold all of 2063243830Sdim * the operands of the given MDNode (see LLVMGetMDNodeNumOperands) as 2064243830Sdim * LLVMValueRefs. This memory will be populated with the LLVMValueRefs of the 2065243830Sdim * MDNode's operands. 2066243830Sdim * 2067243830Sdim * @param V MDNode to get the operands from. 2068243830Sdim * @param Dest Destination array for operands. 2069243830Sdim */ 2070243830Sdimvoid LLVMGetMDNodeOperands(LLVMValueRef V, LLVMValueRef *Dest); 2071243830Sdim 2072243830Sdim/** 2073234353Sdim * @} 2074234353Sdim */ 2075234353Sdim 2076234353Sdim/** 2077234353Sdim * @defgroup LLVMCCoreValueBasicBlock Basic Block 2078234353Sdim * 2079234353Sdim * A basic block represents a single entry single exit section of code. 2080234353Sdim * Basic blocks contain a list of instructions which form the body of 2081234353Sdim * the block. 2082234353Sdim * 2083234353Sdim * Basic blocks belong to functions. They have the type of label. 2084234353Sdim * 2085234353Sdim * Basic blocks are themselves values. However, the C API models them as 2086234353Sdim * LLVMBasicBlockRef. 2087234353Sdim * 2088234353Sdim * @see llvm::BasicBlock 2089234353Sdim * 2090234353Sdim * @{ 2091234353Sdim */ 2092234353Sdim 2093234353Sdim/** 2094234353Sdim * Convert a basic block instance to a value type. 2095234353Sdim */ 2096193323SedLLVMValueRef LLVMBasicBlockAsValue(LLVMBasicBlockRef BB); 2097234353Sdim 2098234353Sdim/** 2099261991Sdim * Determine whether an LLVMValueRef is itself a basic block. 2100234353Sdim */ 2101202375SrdivackyLLVMBool LLVMValueIsBasicBlock(LLVMValueRef Val); 2102234353Sdim 2103234353Sdim/** 2104261991Sdim * Convert an LLVMValueRef to an LLVMBasicBlockRef instance. 2105234353Sdim */ 2106193323SedLLVMBasicBlockRef LLVMValueAsBasicBlock(LLVMValueRef Val); 2107234353Sdim 2108234353Sdim/** 2109234353Sdim * Obtain the function to which a basic block belongs. 2110234353Sdim * 2111234353Sdim * @see llvm::BasicBlock::getParent() 2112234353Sdim */ 2113193323SedLLVMValueRef LLVMGetBasicBlockParent(LLVMBasicBlockRef BB); 2114234353Sdim 2115234353Sdim/** 2116234353Sdim * Obtain the terminator instruction for a basic block. 2117234353Sdim * 2118234353Sdim * If the basic block does not have a terminator (it is not well-formed 2119234353Sdim * if it doesn't), then NULL is returned. 2120234353Sdim * 2121234353Sdim * The returned LLVMValueRef corresponds to a llvm::TerminatorInst. 2122234353Sdim * 2123234353Sdim * @see llvm::BasicBlock::getTerminator() 2124234353Sdim */ 2125226633SdimLLVMValueRef LLVMGetBasicBlockTerminator(LLVMBasicBlockRef BB); 2126234353Sdim 2127234353Sdim/** 2128234353Sdim * Obtain the number of basic blocks in a function. 2129234353Sdim * 2130234353Sdim * @param Fn Function value to operate on. 2131234353Sdim */ 2132193323Sedunsigned LLVMCountBasicBlocks(LLVMValueRef Fn); 2133234353Sdim 2134234353Sdim/** 2135234353Sdim * Obtain all of the basic blocks in a function. 2136234353Sdim * 2137234353Sdim * This operates on a function value. The BasicBlocks parameter is a 2138234353Sdim * pointer to a pre-allocated array of LLVMBasicBlockRef of at least 2139234353Sdim * LLVMCountBasicBlocks() in length. This array is populated with 2140234353Sdim * LLVMBasicBlockRef instances. 2141234353Sdim */ 2142193323Sedvoid LLVMGetBasicBlocks(LLVMValueRef Fn, LLVMBasicBlockRef *BasicBlocks); 2143234353Sdim 2144234353Sdim/** 2145234353Sdim * Obtain the first basic block in a function. 2146234353Sdim * 2147234353Sdim * The returned basic block can be used as an iterator. You will likely 2148234353Sdim * eventually call into LLVMGetNextBasicBlock() with it. 2149234353Sdim * 2150234353Sdim * @see llvm::Function::begin() 2151234353Sdim */ 2152193323SedLLVMBasicBlockRef LLVMGetFirstBasicBlock(LLVMValueRef Fn); 2153234353Sdim 2154234353Sdim/** 2155234353Sdim * Obtain the last basic block in a function. 2156234353Sdim * 2157234353Sdim * @see llvm::Function::end() 2158234353Sdim */ 2159193323SedLLVMBasicBlockRef LLVMGetLastBasicBlock(LLVMValueRef Fn); 2160234353Sdim 2161234353Sdim/** 2162234353Sdim * Advance a basic block iterator. 2163234353Sdim */ 2164193323SedLLVMBasicBlockRef LLVMGetNextBasicBlock(LLVMBasicBlockRef BB); 2165234353Sdim 2166234353Sdim/** 2167234353Sdim * Go backwards in a basic block iterator. 2168234353Sdim */ 2169193323SedLLVMBasicBlockRef LLVMGetPreviousBasicBlock(LLVMBasicBlockRef BB); 2170234353Sdim 2171234353Sdim/** 2172234353Sdim * Obtain the basic block that corresponds to the entry point of a 2173234353Sdim * function. 2174234353Sdim * 2175234353Sdim * @see llvm::Function::getEntryBlock() 2176234353Sdim */ 2177193323SedLLVMBasicBlockRef LLVMGetEntryBasicBlock(LLVMValueRef Fn); 2178198090Srdivacky 2179234353Sdim/** 2180234353Sdim * Append a basic block to the end of a function. 2181234353Sdim * 2182234353Sdim * @see llvm::BasicBlock::Create() 2183234353Sdim */ 2184198090SrdivackyLLVMBasicBlockRef LLVMAppendBasicBlockInContext(LLVMContextRef C, 2185198090Srdivacky LLVMValueRef Fn, 2186198090Srdivacky const char *Name); 2187234353Sdim 2188234353Sdim/** 2189234353Sdim * Append a basic block to the end of a function using the global 2190234353Sdim * context. 2191234353Sdim * 2192234353Sdim * @see llvm::BasicBlock::Create() 2193234353Sdim */ 2194234353SdimLLVMBasicBlockRef LLVMAppendBasicBlock(LLVMValueRef Fn, const char *Name); 2195234353Sdim 2196234353Sdim/** 2197234353Sdim * Insert a basic block in a function before another basic block. 2198234353Sdim * 2199234353Sdim * The function to add to is determined by the function of the 2200234353Sdim * passed basic block. 2201234353Sdim * 2202234353Sdim * @see llvm::BasicBlock::Create() 2203234353Sdim */ 2204198090SrdivackyLLVMBasicBlockRef LLVMInsertBasicBlockInContext(LLVMContextRef C, 2205198090Srdivacky LLVMBasicBlockRef BB, 2206198090Srdivacky const char *Name); 2207198090Srdivacky 2208234353Sdim/** 2209234353Sdim * Insert a basic block in a function using the global context. 2210234353Sdim * 2211234353Sdim * @see llvm::BasicBlock::Create() 2212234353Sdim */ 2213193323SedLLVMBasicBlockRef LLVMInsertBasicBlock(LLVMBasicBlockRef InsertBeforeBB, 2214193323Sed const char *Name); 2215234353Sdim 2216234353Sdim/** 2217234353Sdim * Remove a basic block from a function and delete it. 2218234353Sdim * 2219234353Sdim * This deletes the basic block from its containing function and deletes 2220234353Sdim * the basic block itself. 2221234353Sdim * 2222234353Sdim * @see llvm::BasicBlock::eraseFromParent() 2223234353Sdim */ 2224193323Sedvoid LLVMDeleteBasicBlock(LLVMBasicBlockRef BB); 2225234353Sdim 2226234353Sdim/** 2227234353Sdim * Remove a basic block from a function. 2228234353Sdim * 2229234353Sdim * This deletes the basic block from its containing function but keep 2230234353Sdim * the basic block alive. 2231234353Sdim * 2232234353Sdim * @see llvm::BasicBlock::removeFromParent() 2233234353Sdim */ 2234226633Sdimvoid LLVMRemoveBasicBlockFromParent(LLVMBasicBlockRef BB); 2235193323Sed 2236234353Sdim/** 2237234353Sdim * Move a basic block to before another one. 2238234353Sdim * 2239234353Sdim * @see llvm::BasicBlock::moveBefore() 2240234353Sdim */ 2241212904Sdimvoid LLVMMoveBasicBlockBefore(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos); 2242234353Sdim 2243234353Sdim/** 2244234353Sdim * Move a basic block to after another one. 2245234353Sdim * 2246234353Sdim * @see llvm::BasicBlock::moveAfter() 2247234353Sdim */ 2248212904Sdimvoid LLVMMoveBasicBlockAfter(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos); 2249212904Sdim 2250234353Sdim/** 2251234353Sdim * Obtain the first instruction in a basic block. 2252234353Sdim * 2253234353Sdim * The returned LLVMValueRef corresponds to a llvm::Instruction 2254234353Sdim * instance. 2255234353Sdim */ 2256226633SdimLLVMValueRef LLVMGetFirstInstruction(LLVMBasicBlockRef BB); 2257234353Sdim 2258234353Sdim/** 2259234353Sdim * Obtain the last instruction in a basic block. 2260234353Sdim * 2261261991Sdim * The returned LLVMValueRef corresponds to an LLVM:Instruction. 2262234353Sdim */ 2263226633SdimLLVMValueRef LLVMGetLastInstruction(LLVMBasicBlockRef BB); 2264226633Sdim 2265234353Sdim/** 2266234353Sdim * @} 2267234353Sdim */ 2268234353Sdim 2269234353Sdim/** 2270234353Sdim * @defgroup LLVMCCoreValueInstruction Instructions 2271234353Sdim * 2272234353Sdim * Functions in this group relate to the inspection and manipulation of 2273234353Sdim * individual instructions. 2274234353Sdim * 2275234353Sdim * In the C++ API, an instruction is modeled by llvm::Instruction. This 2276234353Sdim * class has a large number of descendents. llvm::Instruction is a 2277234353Sdim * llvm::Value and in the C API, instructions are modeled by 2278234353Sdim * LLVMValueRef. 2279234353Sdim * 2280234353Sdim * This group also contains sub-groups which operate on specific 2281234353Sdim * llvm::Instruction types, e.g. llvm::CallInst. 2282234353Sdim * 2283234353Sdim * @{ 2284234353Sdim */ 2285234353Sdim 2286234353Sdim/** 2287234353Sdim * Determine whether an instruction has any metadata attached. 2288234353Sdim */ 2289234353Sdimint LLVMHasMetadata(LLVMValueRef Val); 2290234353Sdim 2291234353Sdim/** 2292234353Sdim * Return metadata associated with an instruction value. 2293234353Sdim */ 2294234353SdimLLVMValueRef LLVMGetMetadata(LLVMValueRef Val, unsigned KindID); 2295234353Sdim 2296234353Sdim/** 2297234353Sdim * Set metadata associated with an instruction value. 2298234353Sdim */ 2299234353Sdimvoid LLVMSetMetadata(LLVMValueRef Val, unsigned KindID, LLVMValueRef Node); 2300234353Sdim 2301234353Sdim/** 2302234353Sdim * Obtain the basic block to which an instruction belongs. 2303234353Sdim * 2304234353Sdim * @see llvm::Instruction::getParent() 2305234353Sdim */ 2306193323SedLLVMBasicBlockRef LLVMGetInstructionParent(LLVMValueRef Inst); 2307234353Sdim 2308234353Sdim/** 2309234353Sdim * Obtain the instruction that occurs after the one specified. 2310234353Sdim * 2311234353Sdim * The next instruction will be from the same basic block. 2312234353Sdim * 2313234353Sdim * If this is the last instruction in a basic block, NULL will be 2314234353Sdim * returned. 2315234353Sdim */ 2316193323SedLLVMValueRef LLVMGetNextInstruction(LLVMValueRef Inst); 2317234353Sdim 2318234353Sdim/** 2319239462Sdim * Obtain the instruction that occurred before this one. 2320234353Sdim * 2321234353Sdim * If the instruction is the first instruction in a basic block, NULL 2322234353Sdim * will be returned. 2323234353Sdim */ 2324193323SedLLVMValueRef LLVMGetPreviousInstruction(LLVMValueRef Inst); 2325234353Sdim 2326234353Sdim/** 2327234353Sdim * Remove and delete an instruction. 2328234353Sdim * 2329234353Sdim * The instruction specified is removed from its containing building 2330234353Sdim * block and then deleted. 2331234353Sdim * 2332234353Sdim * @see llvm::Instruction::eraseFromParent() 2333234353Sdim */ 2334226633Sdimvoid LLVMInstructionEraseFromParent(LLVMValueRef Inst); 2335234353Sdim 2336234353Sdim/** 2337234353Sdim * Obtain the code opcode for an individual instruction. 2338234353Sdim * 2339234353Sdim * @see llvm::Instruction::getOpCode() 2340234353Sdim */ 2341296417SdimLLVMOpcode LLVMGetInstructionOpcode(LLVMValueRef Inst); 2342234353Sdim 2343234353Sdim/** 2344234353Sdim * Obtain the predicate of an instruction. 2345234353Sdim * 2346234353Sdim * This is only valid for instructions that correspond to llvm::ICmpInst 2347234353Sdim * or llvm::ConstantExpr whose opcode is llvm::Instruction::ICmp. 2348234353Sdim * 2349234353Sdim * @see llvm::ICmpInst::getPredicate() 2350234353Sdim */ 2351226633SdimLLVMIntPredicate LLVMGetICmpPredicate(LLVMValueRef Inst); 2352193323Sed 2353234353Sdim/** 2354280031Sdim * Obtain the float predicate of an instruction. 2355280031Sdim * 2356280031Sdim * This is only valid for instructions that correspond to llvm::FCmpInst 2357280031Sdim * or llvm::ConstantExpr whose opcode is llvm::Instruction::FCmp. 2358280031Sdim * 2359280031Sdim * @see llvm::FCmpInst::getPredicate() 2360280031Sdim */ 2361280031SdimLLVMRealPredicate LLVMGetFCmpPredicate(LLVMValueRef Inst); 2362280031Sdim 2363280031Sdim/** 2364280031Sdim * Create a copy of 'this' instruction that is identical in all ways 2365280031Sdim * except the following: 2366280031Sdim * * The instruction has no parent 2367280031Sdim * * The instruction has no name 2368280031Sdim * 2369280031Sdim * @see llvm::Instruction::clone() 2370280031Sdim */ 2371280031SdimLLVMValueRef LLVMInstructionClone(LLVMValueRef Inst); 2372280031Sdim 2373280031Sdim/** 2374234353Sdim * @defgroup LLVMCCoreValueInstructionCall Call Sites and Invocations 2375234353Sdim * 2376234353Sdim * Functions in this group apply to instructions that refer to call 2377234353Sdim * sites and invocations. These correspond to C++ types in the 2378234353Sdim * llvm::CallInst class tree. 2379234353Sdim * 2380234353Sdim * @{ 2381234353Sdim */ 2382234353Sdim 2383234353Sdim/** 2384234353Sdim * Set the calling convention for a call instruction. 2385234353Sdim * 2386234353Sdim * This expects an LLVMValueRef that corresponds to a llvm::CallInst or 2387234353Sdim * llvm::InvokeInst. 2388234353Sdim * 2389234353Sdim * @see llvm::CallInst::setCallingConv() 2390234353Sdim * @see llvm::InvokeInst::setCallingConv() 2391234353Sdim */ 2392193323Sedvoid LLVMSetInstructionCallConv(LLVMValueRef Instr, unsigned CC); 2393234353Sdim 2394234353Sdim/** 2395234353Sdim * Obtain the calling convention for a call instruction. 2396234353Sdim * 2397234353Sdim * This is the opposite of LLVMSetInstructionCallConv(). Reads its 2398234353Sdim * usage. 2399234353Sdim * 2400234353Sdim * @see LLVMSetInstructionCallConv() 2401234353Sdim */ 2402193323Sedunsigned LLVMGetInstructionCallConv(LLVMValueRef Instr); 2403234353Sdim 2404234353Sdim 2405193323Sedvoid LLVMAddInstrAttribute(LLVMValueRef Instr, unsigned index, LLVMAttribute); 2406234353Sdimvoid LLVMRemoveInstrAttribute(LLVMValueRef Instr, unsigned index, 2407193323Sed LLVMAttribute); 2408234353Sdimvoid LLVMSetInstrParamAlignment(LLVMValueRef Instr, unsigned index, 2409193323Sed unsigned align); 2410193323Sed 2411234353Sdim/** 2412234353Sdim * Obtain whether a call instruction is a tail call. 2413234353Sdim * 2414234353Sdim * This only works on llvm::CallInst instructions. 2415234353Sdim * 2416234353Sdim * @see llvm::CallInst::isTailCall() 2417234353Sdim */ 2418202375SrdivackyLLVMBool LLVMIsTailCall(LLVMValueRef CallInst); 2419234353Sdim 2420234353Sdim/** 2421234353Sdim * Set whether a call instruction is a tail call. 2422234353Sdim * 2423234353Sdim * This only works on llvm::CallInst instructions. 2424234353Sdim * 2425234353Sdim * @see llvm::CallInst::setTailCall() 2426234353Sdim */ 2427202375Srdivackyvoid LLVMSetTailCall(LLVMValueRef CallInst, LLVMBool IsTailCall); 2428193323Sed 2429234353Sdim/** 2430234353Sdim * @} 2431234353Sdim */ 2432234353Sdim 2433234353Sdim/** 2434280031Sdim * @defgroup LLVMCCoreValueInstructionTerminator Terminators 2435280031Sdim * 2436280031Sdim * Functions in this group only apply to instructions that map to 2437280031Sdim * llvm::TerminatorInst instances. 2438280031Sdim * 2439280031Sdim * @{ 2440280031Sdim */ 2441280031Sdim 2442280031Sdim/** 2443280031Sdim * Return the number of successors that this terminator has. 2444280031Sdim * 2445280031Sdim * @see llvm::TerminatorInst::getNumSuccessors 2446280031Sdim */ 2447280031Sdimunsigned LLVMGetNumSuccessors(LLVMValueRef Term); 2448280031Sdim 2449280031Sdim/** 2450280031Sdim * Return the specified successor. 2451280031Sdim * 2452280031Sdim * @see llvm::TerminatorInst::getSuccessor 2453280031Sdim */ 2454280031SdimLLVMBasicBlockRef LLVMGetSuccessor(LLVMValueRef Term, unsigned i); 2455280031Sdim 2456280031Sdim/** 2457280031Sdim * Update the specified successor to point at the provided block. 2458280031Sdim * 2459280031Sdim * @see llvm::TerminatorInst::setSuccessor 2460280031Sdim */ 2461280031Sdimvoid LLVMSetSuccessor(LLVMValueRef Term, unsigned i, LLVMBasicBlockRef block); 2462280031Sdim 2463280031Sdim/** 2464280031Sdim * Return if a branch is conditional. 2465280031Sdim * 2466280031Sdim * This only works on llvm::BranchInst instructions. 2467280031Sdim * 2468280031Sdim * @see llvm::BranchInst::isConditional 2469280031Sdim */ 2470280031SdimLLVMBool LLVMIsConditional(LLVMValueRef Branch); 2471280031Sdim 2472280031Sdim/** 2473280031Sdim * Return the condition of a branch instruction. 2474280031Sdim * 2475280031Sdim * This only works on llvm::BranchInst instructions. 2476280031Sdim * 2477280031Sdim * @see llvm::BranchInst::getCondition 2478280031Sdim */ 2479280031SdimLLVMValueRef LLVMGetCondition(LLVMValueRef Branch); 2480280031Sdim 2481280031Sdim/** 2482280031Sdim * Set the condition of a branch instruction. 2483280031Sdim * 2484280031Sdim * This only works on llvm::BranchInst instructions. 2485280031Sdim * 2486280031Sdim * @see llvm::BranchInst::setCondition 2487280031Sdim */ 2488280031Sdimvoid LLVMSetCondition(LLVMValueRef Branch, LLVMValueRef Cond); 2489280031Sdim 2490280031Sdim/** 2491234353Sdim * Obtain the default destination basic block of a switch instruction. 2492234353Sdim * 2493234353Sdim * This only works on llvm::SwitchInst instructions. 2494234353Sdim * 2495234353Sdim * @see llvm::SwitchInst::getDefaultDest() 2496234353Sdim */ 2497226633SdimLLVMBasicBlockRef LLVMGetSwitchDefaultDest(LLVMValueRef SwitchInstr); 2498226633Sdim 2499234353Sdim/** 2500280031Sdim * @} 2501280031Sdim */ 2502280031Sdim 2503280031Sdim/** 2504234353Sdim * @defgroup LLVMCCoreValueInstructionPHINode PHI Nodes 2505234353Sdim * 2506234353Sdim * Functions in this group only apply to instructions that map to 2507234353Sdim * llvm::PHINode instances. 2508234353Sdim * 2509234353Sdim * @{ 2510234353Sdim */ 2511234353Sdim 2512234353Sdim/** 2513234353Sdim * Add an incoming value to the end of a PHI list. 2514234353Sdim */ 2515193323Sedvoid LLVMAddIncoming(LLVMValueRef PhiNode, LLVMValueRef *IncomingValues, 2516193323Sed LLVMBasicBlockRef *IncomingBlocks, unsigned Count); 2517234353Sdim 2518234353Sdim/** 2519234353Sdim * Obtain the number of incoming basic blocks to a PHI node. 2520234353Sdim */ 2521193323Sedunsigned LLVMCountIncoming(LLVMValueRef PhiNode); 2522234353Sdim 2523234353Sdim/** 2524261991Sdim * Obtain an incoming value to a PHI node as an LLVMValueRef. 2525234353Sdim */ 2526193323SedLLVMValueRef LLVMGetIncomingValue(LLVMValueRef PhiNode, unsigned Index); 2527234353Sdim 2528234353Sdim/** 2529261991Sdim * Obtain an incoming value to a PHI node as an LLVMBasicBlockRef. 2530234353Sdim */ 2531193323SedLLVMBasicBlockRef LLVMGetIncomingBlock(LLVMValueRef PhiNode, unsigned Index); 2532193323Sed 2533234353Sdim/** 2534234353Sdim * @} 2535234353Sdim */ 2536193323Sed 2537234353Sdim/** 2538234353Sdim * @} 2539193323Sed */ 2540193323Sed 2541234353Sdim/** 2542234353Sdim * @} 2543234353Sdim */ 2544234353Sdim 2545234353Sdim/** 2546234353Sdim * @defgroup LLVMCCoreInstructionBuilder Instruction Builders 2547234353Sdim * 2548234353Sdim * An instruction builder represents a point within a basic block and is 2549234353Sdim * the exclusive means of building instructions using the C interface. 2550234353Sdim * 2551234353Sdim * @{ 2552234353Sdim */ 2553234353Sdim 2554198090SrdivackyLLVMBuilderRef LLVMCreateBuilderInContext(LLVMContextRef C); 2555193323SedLLVMBuilderRef LLVMCreateBuilder(void); 2556193323Sedvoid LLVMPositionBuilder(LLVMBuilderRef Builder, LLVMBasicBlockRef Block, 2557193323Sed LLVMValueRef Instr); 2558193323Sedvoid LLVMPositionBuilderBefore(LLVMBuilderRef Builder, LLVMValueRef Instr); 2559193323Sedvoid LLVMPositionBuilderAtEnd(LLVMBuilderRef Builder, LLVMBasicBlockRef Block); 2560193323SedLLVMBasicBlockRef LLVMGetInsertBlock(LLVMBuilderRef Builder); 2561193323Sedvoid LLVMClearInsertionPosition(LLVMBuilderRef Builder); 2562193323Sedvoid LLVMInsertIntoBuilder(LLVMBuilderRef Builder, LLVMValueRef Instr); 2563198090Srdivackyvoid LLVMInsertIntoBuilderWithName(LLVMBuilderRef Builder, LLVMValueRef Instr, 2564198090Srdivacky const char *Name); 2565193323Sedvoid LLVMDisposeBuilder(LLVMBuilderRef Builder); 2566193323Sed 2567204642Srdivacky/* Metadata */ 2568204642Srdivackyvoid LLVMSetCurrentDebugLocation(LLVMBuilderRef Builder, LLVMValueRef L); 2569204642SrdivackyLLVMValueRef LLVMGetCurrentDebugLocation(LLVMBuilderRef Builder); 2570204642Srdivackyvoid LLVMSetInstDebugLocation(LLVMBuilderRef Builder, LLVMValueRef Inst); 2571204642Srdivacky 2572193323Sed/* Terminators */ 2573193323SedLLVMValueRef LLVMBuildRetVoid(LLVMBuilderRef); 2574193323SedLLVMValueRef LLVMBuildRet(LLVMBuilderRef, LLVMValueRef V); 2575198090SrdivackyLLVMValueRef LLVMBuildAggregateRet(LLVMBuilderRef, LLVMValueRef *RetVals, 2576198090Srdivacky unsigned N); 2577193323SedLLVMValueRef LLVMBuildBr(LLVMBuilderRef, LLVMBasicBlockRef Dest); 2578193323SedLLVMValueRef LLVMBuildCondBr(LLVMBuilderRef, LLVMValueRef If, 2579193323Sed LLVMBasicBlockRef Then, LLVMBasicBlockRef Else); 2580193323SedLLVMValueRef LLVMBuildSwitch(LLVMBuilderRef, LLVMValueRef V, 2581193323Sed LLVMBasicBlockRef Else, unsigned NumCases); 2582204642SrdivackyLLVMValueRef LLVMBuildIndirectBr(LLVMBuilderRef B, LLVMValueRef Addr, 2583204642Srdivacky unsigned NumDests); 2584193323SedLLVMValueRef LLVMBuildInvoke(LLVMBuilderRef, LLVMValueRef Fn, 2585193323Sed LLVMValueRef *Args, unsigned NumArgs, 2586193323Sed LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch, 2587193323Sed const char *Name); 2588226633SdimLLVMValueRef LLVMBuildLandingPad(LLVMBuilderRef B, LLVMTypeRef Ty, 2589292735Sdim LLVMValueRef PersFn, unsigned NumClauses, 2590292735Sdim const char *Name); 2591226633SdimLLVMValueRef LLVMBuildResume(LLVMBuilderRef B, LLVMValueRef Exn); 2592193323SedLLVMValueRef LLVMBuildUnreachable(LLVMBuilderRef); 2593193323Sed 2594193323Sed/* Add a case to the switch instruction */ 2595193323Sedvoid LLVMAddCase(LLVMValueRef Switch, LLVMValueRef OnVal, 2596193323Sed LLVMBasicBlockRef Dest); 2597193323Sed 2598204642Srdivacky/* Add a destination to the indirectbr instruction */ 2599204642Srdivackyvoid LLVMAddDestination(LLVMValueRef IndirectBr, LLVMBasicBlockRef Dest); 2600204642Srdivacky 2601226633Sdim/* Add a catch or filter clause to the landingpad instruction */ 2602226633Sdimvoid LLVMAddClause(LLVMValueRef LandingPad, LLVMValueRef ClauseVal); 2603226633Sdim 2604226633Sdim/* Set the 'cleanup' flag in the landingpad instruction */ 2605226633Sdimvoid LLVMSetCleanup(LLVMValueRef LandingPad, LLVMBool Val); 2606226633Sdim 2607193323Sed/* Arithmetic */ 2608193323SedLLVMValueRef LLVMBuildAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, 2609193323Sed const char *Name); 2610198090SrdivackyLLVMValueRef LLVMBuildNSWAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, 2611198090Srdivacky const char *Name); 2612204642SrdivackyLLVMValueRef LLVMBuildNUWAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, 2613204642Srdivacky const char *Name); 2614198090SrdivackyLLVMValueRef LLVMBuildFAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, 2615198090Srdivacky const char *Name); 2616193323SedLLVMValueRef LLVMBuildSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, 2617193323Sed const char *Name); 2618204642SrdivackyLLVMValueRef LLVMBuildNSWSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, 2619204642Srdivacky const char *Name); 2620204642SrdivackyLLVMValueRef LLVMBuildNUWSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, 2621204642Srdivacky const char *Name); 2622198090SrdivackyLLVMValueRef LLVMBuildFSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, 2623198090Srdivacky const char *Name); 2624193323SedLLVMValueRef LLVMBuildMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, 2625193323Sed const char *Name); 2626204642SrdivackyLLVMValueRef LLVMBuildNSWMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, 2627204642Srdivacky const char *Name); 2628204642SrdivackyLLVMValueRef LLVMBuildNUWMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, 2629204642Srdivacky const char *Name); 2630198090SrdivackyLLVMValueRef LLVMBuildFMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, 2631198090Srdivacky const char *Name); 2632193323SedLLVMValueRef LLVMBuildUDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, 2633193323Sed const char *Name); 2634193323SedLLVMValueRef LLVMBuildSDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, 2635193323Sed const char *Name); 2636198090SrdivackyLLVMValueRef LLVMBuildExactSDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, 2637198090Srdivacky const char *Name); 2638193323SedLLVMValueRef LLVMBuildFDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, 2639193323Sed const char *Name); 2640193323SedLLVMValueRef LLVMBuildURem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, 2641193323Sed const char *Name); 2642193323SedLLVMValueRef LLVMBuildSRem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, 2643193323Sed const char *Name); 2644193323SedLLVMValueRef LLVMBuildFRem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, 2645193323Sed const char *Name); 2646193323SedLLVMValueRef LLVMBuildShl(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, 2647193323Sed const char *Name); 2648193323SedLLVMValueRef LLVMBuildLShr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, 2649193323Sed const char *Name); 2650193323SedLLVMValueRef LLVMBuildAShr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, 2651193323Sed const char *Name); 2652193323SedLLVMValueRef LLVMBuildAnd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, 2653193323Sed const char *Name); 2654193323SedLLVMValueRef LLVMBuildOr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, 2655193323Sed const char *Name); 2656193323SedLLVMValueRef LLVMBuildXor(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, 2657193323Sed const char *Name); 2658204642SrdivackyLLVMValueRef LLVMBuildBinOp(LLVMBuilderRef B, LLVMOpcode Op, 2659204642Srdivacky LLVMValueRef LHS, LLVMValueRef RHS, 2660204642Srdivacky const char *Name); 2661193323SedLLVMValueRef LLVMBuildNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name); 2662204642SrdivackyLLVMValueRef LLVMBuildNSWNeg(LLVMBuilderRef B, LLVMValueRef V, 2663204642Srdivacky const char *Name); 2664204642SrdivackyLLVMValueRef LLVMBuildNUWNeg(LLVMBuilderRef B, LLVMValueRef V, 2665204642Srdivacky const char *Name); 2666198090SrdivackyLLVMValueRef LLVMBuildFNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name); 2667193323SedLLVMValueRef LLVMBuildNot(LLVMBuilderRef, LLVMValueRef V, const char *Name); 2668193323Sed 2669193323Sed/* Memory */ 2670193323SedLLVMValueRef LLVMBuildMalloc(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name); 2671193323SedLLVMValueRef LLVMBuildArrayMalloc(LLVMBuilderRef, LLVMTypeRef Ty, 2672193323Sed LLVMValueRef Val, const char *Name); 2673193323SedLLVMValueRef LLVMBuildAlloca(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name); 2674193323SedLLVMValueRef LLVMBuildArrayAlloca(LLVMBuilderRef, LLVMTypeRef Ty, 2675193323Sed LLVMValueRef Val, const char *Name); 2676193323SedLLVMValueRef LLVMBuildFree(LLVMBuilderRef, LLVMValueRef PointerVal); 2677193323SedLLVMValueRef LLVMBuildLoad(LLVMBuilderRef, LLVMValueRef PointerVal, 2678193323Sed const char *Name); 2679193323SedLLVMValueRef LLVMBuildStore(LLVMBuilderRef, LLVMValueRef Val, LLVMValueRef Ptr); 2680193323SedLLVMValueRef LLVMBuildGEP(LLVMBuilderRef B, LLVMValueRef Pointer, 2681193323Sed LLVMValueRef *Indices, unsigned NumIndices, 2682193323Sed const char *Name); 2683198090SrdivackyLLVMValueRef LLVMBuildInBoundsGEP(LLVMBuilderRef B, LLVMValueRef Pointer, 2684198090Srdivacky LLVMValueRef *Indices, unsigned NumIndices, 2685198090Srdivacky const char *Name); 2686198090SrdivackyLLVMValueRef LLVMBuildStructGEP(LLVMBuilderRef B, LLVMValueRef Pointer, 2687198090Srdivacky unsigned Idx, const char *Name); 2688198090SrdivackyLLVMValueRef LLVMBuildGlobalString(LLVMBuilderRef B, const char *Str, 2689198090Srdivacky const char *Name); 2690198090SrdivackyLLVMValueRef LLVMBuildGlobalStringPtr(LLVMBuilderRef B, const char *Str, 2691198090Srdivacky const char *Name); 2692234353SdimLLVMBool LLVMGetVolatile(LLVMValueRef MemoryAccessInst); 2693234353Sdimvoid LLVMSetVolatile(LLVMValueRef MemoryAccessInst, LLVMBool IsVolatile); 2694296417SdimLLVMAtomicOrdering LLVMGetOrdering(LLVMValueRef MemoryAccessInst); 2695296417Sdimvoid LLVMSetOrdering(LLVMValueRef MemoryAccessInst, LLVMAtomicOrdering Ordering); 2696193323Sed 2697193323Sed/* Casts */ 2698193323SedLLVMValueRef LLVMBuildTrunc(LLVMBuilderRef, LLVMValueRef Val, 2699193323Sed LLVMTypeRef DestTy, const char *Name); 2700193323SedLLVMValueRef LLVMBuildZExt(LLVMBuilderRef, LLVMValueRef Val, 2701193323Sed LLVMTypeRef DestTy, const char *Name); 2702193323SedLLVMValueRef LLVMBuildSExt(LLVMBuilderRef, LLVMValueRef Val, 2703193323Sed LLVMTypeRef DestTy, const char *Name); 2704193323SedLLVMValueRef LLVMBuildFPToUI(LLVMBuilderRef, LLVMValueRef Val, 2705193323Sed LLVMTypeRef DestTy, const char *Name); 2706193323SedLLVMValueRef LLVMBuildFPToSI(LLVMBuilderRef, LLVMValueRef Val, 2707193323Sed LLVMTypeRef DestTy, const char *Name); 2708193323SedLLVMValueRef LLVMBuildUIToFP(LLVMBuilderRef, LLVMValueRef Val, 2709193323Sed LLVMTypeRef DestTy, const char *Name); 2710193323SedLLVMValueRef LLVMBuildSIToFP(LLVMBuilderRef, LLVMValueRef Val, 2711193323Sed LLVMTypeRef DestTy, const char *Name); 2712193323SedLLVMValueRef LLVMBuildFPTrunc(LLVMBuilderRef, LLVMValueRef Val, 2713193323Sed LLVMTypeRef DestTy, const char *Name); 2714193323SedLLVMValueRef LLVMBuildFPExt(LLVMBuilderRef, LLVMValueRef Val, 2715193323Sed LLVMTypeRef DestTy, const char *Name); 2716193323SedLLVMValueRef LLVMBuildPtrToInt(LLVMBuilderRef, LLVMValueRef Val, 2717193323Sed LLVMTypeRef DestTy, const char *Name); 2718193323SedLLVMValueRef LLVMBuildIntToPtr(LLVMBuilderRef, LLVMValueRef Val, 2719193323Sed LLVMTypeRef DestTy, const char *Name); 2720193323SedLLVMValueRef LLVMBuildBitCast(LLVMBuilderRef, LLVMValueRef Val, 2721193323Sed LLVMTypeRef DestTy, const char *Name); 2722261991SdimLLVMValueRef LLVMBuildAddrSpaceCast(LLVMBuilderRef, LLVMValueRef Val, 2723261991Sdim LLVMTypeRef DestTy, const char *Name); 2724198090SrdivackyLLVMValueRef LLVMBuildZExtOrBitCast(LLVMBuilderRef, LLVMValueRef Val, 2725198090Srdivacky LLVMTypeRef DestTy, const char *Name); 2726198090SrdivackyLLVMValueRef LLVMBuildSExtOrBitCast(LLVMBuilderRef, LLVMValueRef Val, 2727198090Srdivacky LLVMTypeRef DestTy, const char *Name); 2728198090SrdivackyLLVMValueRef LLVMBuildTruncOrBitCast(LLVMBuilderRef, LLVMValueRef Val, 2729198090Srdivacky LLVMTypeRef DestTy, const char *Name); 2730204642SrdivackyLLVMValueRef LLVMBuildCast(LLVMBuilderRef B, LLVMOpcode Op, LLVMValueRef Val, 2731204642Srdivacky LLVMTypeRef DestTy, const char *Name); 2732198090SrdivackyLLVMValueRef LLVMBuildPointerCast(LLVMBuilderRef, LLVMValueRef Val, 2733198090Srdivacky LLVMTypeRef DestTy, const char *Name); 2734199989SrdivackyLLVMValueRef LLVMBuildIntCast(LLVMBuilderRef, LLVMValueRef Val, /*Signed cast!*/ 2735198090Srdivacky LLVMTypeRef DestTy, const char *Name); 2736198090SrdivackyLLVMValueRef LLVMBuildFPCast(LLVMBuilderRef, LLVMValueRef Val, 2737198090Srdivacky LLVMTypeRef DestTy, const char *Name); 2738193323Sed 2739193323Sed/* Comparisons */ 2740193323SedLLVMValueRef LLVMBuildICmp(LLVMBuilderRef, LLVMIntPredicate Op, 2741193323Sed LLVMValueRef LHS, LLVMValueRef RHS, 2742193323Sed const char *Name); 2743193323SedLLVMValueRef LLVMBuildFCmp(LLVMBuilderRef, LLVMRealPredicate Op, 2744193323Sed LLVMValueRef LHS, LLVMValueRef RHS, 2745193323Sed const char *Name); 2746193323Sed 2747193323Sed/* Miscellaneous instructions */ 2748193323SedLLVMValueRef LLVMBuildPhi(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name); 2749193323SedLLVMValueRef LLVMBuildCall(LLVMBuilderRef, LLVMValueRef Fn, 2750193323Sed LLVMValueRef *Args, unsigned NumArgs, 2751193323Sed const char *Name); 2752193323SedLLVMValueRef LLVMBuildSelect(LLVMBuilderRef, LLVMValueRef If, 2753193323Sed LLVMValueRef Then, LLVMValueRef Else, 2754193323Sed const char *Name); 2755193323SedLLVMValueRef LLVMBuildVAArg(LLVMBuilderRef, LLVMValueRef List, LLVMTypeRef Ty, 2756193323Sed const char *Name); 2757193323SedLLVMValueRef LLVMBuildExtractElement(LLVMBuilderRef, LLVMValueRef VecVal, 2758193323Sed LLVMValueRef Index, const char *Name); 2759193323SedLLVMValueRef LLVMBuildInsertElement(LLVMBuilderRef, LLVMValueRef VecVal, 2760193323Sed LLVMValueRef EltVal, LLVMValueRef Index, 2761193323Sed const char *Name); 2762193323SedLLVMValueRef LLVMBuildShuffleVector(LLVMBuilderRef, LLVMValueRef V1, 2763193323Sed LLVMValueRef V2, LLVMValueRef Mask, 2764193323Sed const char *Name); 2765193323SedLLVMValueRef LLVMBuildExtractValue(LLVMBuilderRef, LLVMValueRef AggVal, 2766193323Sed unsigned Index, const char *Name); 2767193323SedLLVMValueRef LLVMBuildInsertValue(LLVMBuilderRef, LLVMValueRef AggVal, 2768193323Sed LLVMValueRef EltVal, unsigned Index, 2769193323Sed const char *Name); 2770193323Sed 2771198090SrdivackyLLVMValueRef LLVMBuildIsNull(LLVMBuilderRef, LLVMValueRef Val, 2772198090Srdivacky const char *Name); 2773198090SrdivackyLLVMValueRef LLVMBuildIsNotNull(LLVMBuilderRef, LLVMValueRef Val, 2774198090Srdivacky const char *Name); 2775198090SrdivackyLLVMValueRef LLVMBuildPtrDiff(LLVMBuilderRef, LLVMValueRef LHS, 2776198090Srdivacky LLVMValueRef RHS, const char *Name); 2777276479SdimLLVMValueRef LLVMBuildFence(LLVMBuilderRef B, LLVMAtomicOrdering ordering, 2778276479Sdim LLVMBool singleThread, const char *Name); 2779276479SdimLLVMValueRef LLVMBuildAtomicRMW(LLVMBuilderRef B, LLVMAtomicRMWBinOp op, 2780261991Sdim LLVMValueRef PTR, LLVMValueRef Val, 2781261991Sdim LLVMAtomicOrdering ordering, 2782251662Sdim LLVMBool singleThread); 2783193323Sed 2784234353Sdim/** 2785234353Sdim * @} 2786234353Sdim */ 2787198090Srdivacky 2788234353Sdim/** 2789234353Sdim * @defgroup LLVMCCoreModuleProvider Module Providers 2790234353Sdim * 2791234353Sdim * @{ 2792234353Sdim */ 2793193323Sed 2794234353Sdim/** 2795234353Sdim * Changes the type of M so it can be passed to FunctionPassManagers and the 2796203954Srdivacky * JIT. They take ModuleProviders for historical reasons. 2797193323Sed */ 2798193323SedLLVMModuleProviderRef 2799193323SedLLVMCreateModuleProviderForExistingModule(LLVMModuleRef M); 2800193323Sed 2801234353Sdim/** 2802234353Sdim * Destroys the module M. 2803193323Sed */ 2804203954Srdivackyvoid LLVMDisposeModuleProvider(LLVMModuleProviderRef M); 2805193323Sed 2806234353Sdim/** 2807234353Sdim * @} 2808234353Sdim */ 2809193323Sed 2810234353Sdim/** 2811234353Sdim * @defgroup LLVMCCoreMemoryBuffers Memory Buffers 2812234353Sdim * 2813234353Sdim * @{ 2814234353Sdim */ 2815193323Sed 2816202375SrdivackyLLVMBool LLVMCreateMemoryBufferWithContentsOfFile(const char *Path, 2817202375Srdivacky LLVMMemoryBufferRef *OutMemBuf, 2818202375Srdivacky char **OutMessage); 2819202375SrdivackyLLVMBool LLVMCreateMemoryBufferWithSTDIN(LLVMMemoryBufferRef *OutMemBuf, 2820202375Srdivacky char **OutMessage); 2821249423SdimLLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRange(const char *InputData, 2822249423Sdim size_t InputDataLength, 2823249423Sdim const char *BufferName, 2824249423Sdim LLVMBool RequiresNullTerminator); 2825249423SdimLLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRangeCopy(const char *InputData, 2826249423Sdim size_t InputDataLength, 2827249423Sdim const char *BufferName); 2828251662Sdimconst char *LLVMGetBufferStart(LLVMMemoryBufferRef MemBuf); 2829251662Sdimsize_t LLVMGetBufferSize(LLVMMemoryBufferRef MemBuf); 2830193323Sedvoid LLVMDisposeMemoryBuffer(LLVMMemoryBufferRef MemBuf); 2831193323Sed 2832234353Sdim/** 2833234353Sdim * @} 2834234353Sdim */ 2835193323Sed 2836234353Sdim/** 2837234353Sdim * @defgroup LLVMCCorePassRegistry Pass Registry 2838234353Sdim * 2839234353Sdim * @{ 2840234353Sdim */ 2841234353Sdim 2842218893Sdim/** Return the global pass registry, for use with initialization functions. 2843234353Sdim @see llvm::PassRegistry::getPassRegistry */ 2844218893SdimLLVMPassRegistryRef LLVMGetGlobalPassRegistry(void); 2845218893Sdim 2846234353Sdim/** 2847234353Sdim * @} 2848234353Sdim */ 2849193323Sed 2850234353Sdim/** 2851234353Sdim * @defgroup LLVMCCorePassManagers Pass Managers 2852234353Sdim * 2853234353Sdim * @{ 2854234353Sdim */ 2855234353Sdim 2856193323Sed/** Constructs a new whole-module pass pipeline. This type of pipeline is 2857193323Sed suitable for link-time optimization and whole-module transformations. 2858234353Sdim @see llvm::PassManager::PassManager */ 2859193323SedLLVMPassManagerRef LLVMCreatePassManager(void); 2860193323Sed 2861193323Sed/** Constructs a new function-by-function pass pipeline over the module 2862193323Sed provider. It does not take ownership of the module provider. This type of 2863193323Sed pipeline is suitable for code generation and JIT compilation tasks. 2864234353Sdim @see llvm::FunctionPassManager::FunctionPassManager */ 2865204642SrdivackyLLVMPassManagerRef LLVMCreateFunctionPassManagerForModule(LLVMModuleRef M); 2866204642Srdivacky 2867204642Srdivacky/** Deprecated: Use LLVMCreateFunctionPassManagerForModule instead. */ 2868193323SedLLVMPassManagerRef LLVMCreateFunctionPassManager(LLVMModuleProviderRef MP); 2869193323Sed 2870193323Sed/** Initializes, executes on the provided module, and finalizes all of the 2871193323Sed passes scheduled in the pass manager. Returns 1 if any of the passes 2872234353Sdim modified the module, 0 otherwise. 2873234353Sdim @see llvm::PassManager::run(Module&) */ 2874202375SrdivackyLLVMBool LLVMRunPassManager(LLVMPassManagerRef PM, LLVMModuleRef M); 2875193323Sed 2876193323Sed/** Initializes all of the function passes scheduled in the function pass 2877193323Sed manager. Returns 1 if any of the passes modified the module, 0 otherwise. 2878234353Sdim @see llvm::FunctionPassManager::doInitialization */ 2879202375SrdivackyLLVMBool LLVMInitializeFunctionPassManager(LLVMPassManagerRef FPM); 2880193323Sed 2881193323Sed/** Executes all of the function passes scheduled in the function pass manager 2882193323Sed on the provided function. Returns 1 if any of the passes modified the 2883193323Sed function, false otherwise. 2884234353Sdim @see llvm::FunctionPassManager::run(Function&) */ 2885202375SrdivackyLLVMBool LLVMRunFunctionPassManager(LLVMPassManagerRef FPM, LLVMValueRef F); 2886193323Sed 2887193323Sed/** Finalizes all of the function passes scheduled in in the function pass 2888193323Sed manager. Returns 1 if any of the passes modified the module, 0 otherwise. 2889234353Sdim @see llvm::FunctionPassManager::doFinalization */ 2890202375SrdivackyLLVMBool LLVMFinalizeFunctionPassManager(LLVMPassManagerRef FPM); 2891193323Sed 2892193323Sed/** Frees the memory of a pass pipeline. For function pipelines, does not free 2893193323Sed the module provider. 2894234353Sdim @see llvm::PassManagerBase::~PassManagerBase. */ 2895193323Sedvoid LLVMDisposePassManager(LLVMPassManagerRef PM); 2896193323Sed 2897234353Sdim/** 2898234353Sdim * @} 2899234353Sdim */ 2900193323Sed 2901234353Sdim/** 2902249423Sdim * @defgroup LLVMCCoreThreading Threading 2903249423Sdim * 2904249423Sdim * Handle the structures needed to make LLVM safe for multithreading. 2905249423Sdim * 2906249423Sdim * @{ 2907249423Sdim */ 2908249423Sdim 2909276479Sdim/** Deprecated: Multi-threading can only be enabled/disabled with the compile 2910276479Sdim time define LLVM_ENABLE_THREADS. This function always returns 2911276479Sdim LLVMIsMultithreaded(). */ 2912261991SdimLLVMBool LLVMStartMultithreaded(void); 2913249423Sdim 2914276479Sdim/** Deprecated: Multi-threading can only be enabled/disabled with the compile 2915276479Sdim time define LLVM_ENABLE_THREADS. */ 2916261991Sdimvoid LLVMStopMultithreaded(void); 2917249423Sdim 2918249423Sdim/** Check whether LLVM is executing in thread-safe mode or not. 2919249423Sdim @see llvm::llvm_is_multithreaded */ 2920261991SdimLLVMBool LLVMIsMultithreaded(void); 2921249423Sdim 2922249423Sdim/** 2923234353Sdim * @} 2924234353Sdim */ 2925234353Sdim 2926234353Sdim/** 2927234353Sdim * @} 2928234353Sdim */ 2929234353Sdim 2930249423Sdim/** 2931249423Sdim * @} 2932249423Sdim */ 2933249423Sdim 2934193323Sed#ifdef __cplusplus 2935193323Sed} 2936296417Sdim#endif 2937193323Sed 2938296417Sdim#endif /* LLVM_C_CORE_H */ 2939