Path: blob/main/contrib/llvm-project/llvm/include/llvm-c/Core.h
35233 views
/*===-- llvm-c/Core.h - Core Library C Interface ------------------*- C -*-===*\1|* *|2|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *|3|* Exceptions. *|4|* See https://llvm.org/LICENSE.txt for license information. *|5|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *|6|* *|7|*===----------------------------------------------------------------------===*|8|* *|9|* This header declares the C interface to libLLVMCore.a, which implements *|10|* the LLVM intermediate representation. *|11|* *|12\*===----------------------------------------------------------------------===*/1314#ifndef LLVM_C_CORE_H15#define LLVM_C_CORE_H1617#include "llvm-c/Deprecated.h"18#include "llvm-c/ErrorHandling.h"19#include "llvm-c/ExternC.h"2021#include "llvm-c/Types.h"2223LLVM_C_EXTERN_C_BEGIN2425/**26* @defgroup LLVMC LLVM-C: C interface to LLVM27*28* This module exposes parts of the LLVM library as a C API.29*30* @{31*/3233/**34* @defgroup LLVMCTransforms Transforms35*/3637/**38* @defgroup LLVMCCore Core39*40* This modules provide an interface to libLLVMCore, which implements41* the LLVM intermediate representation as well as other related types42* and utilities.43*44* Many exotic languages can interoperate with C code but have a harder time45* with C++ due to name mangling. So in addition to C, this interface enables46* tools written in such languages.47*48* @{49*/5051/**52* @defgroup LLVMCCoreTypes Types and Enumerations53*54* @{55*/5657/// External users depend on the following values being stable. It is not safe58/// to reorder them.59typedef enum {60/* Terminator Instructions */61LLVMRet = 1,62LLVMBr = 2,63LLVMSwitch = 3,64LLVMIndirectBr = 4,65LLVMInvoke = 5,66/* removed 6 due to API changes */67LLVMUnreachable = 7,68LLVMCallBr = 67,6970/* Standard Unary Operators */71LLVMFNeg = 66,7273/* Standard Binary Operators */74LLVMAdd = 8,75LLVMFAdd = 9,76LLVMSub = 10,77LLVMFSub = 11,78LLVMMul = 12,79LLVMFMul = 13,80LLVMUDiv = 14,81LLVMSDiv = 15,82LLVMFDiv = 16,83LLVMURem = 17,84LLVMSRem = 18,85LLVMFRem = 19,8687/* Logical Operators */88LLVMShl = 20,89LLVMLShr = 21,90LLVMAShr = 22,91LLVMAnd = 23,92LLVMOr = 24,93LLVMXor = 25,9495/* Memory Operators */96LLVMAlloca = 26,97LLVMLoad = 27,98LLVMStore = 28,99LLVMGetElementPtr = 29,100101/* Cast Operators */102LLVMTrunc = 30,103LLVMZExt = 31,104LLVMSExt = 32,105LLVMFPToUI = 33,106LLVMFPToSI = 34,107LLVMUIToFP = 35,108LLVMSIToFP = 36,109LLVMFPTrunc = 37,110LLVMFPExt = 38,111LLVMPtrToInt = 39,112LLVMIntToPtr = 40,113LLVMBitCast = 41,114LLVMAddrSpaceCast = 60,115116/* Other Operators */117LLVMICmp = 42,118LLVMFCmp = 43,119LLVMPHI = 44,120LLVMCall = 45,121LLVMSelect = 46,122LLVMUserOp1 = 47,123LLVMUserOp2 = 48,124LLVMVAArg = 49,125LLVMExtractElement = 50,126LLVMInsertElement = 51,127LLVMShuffleVector = 52,128LLVMExtractValue = 53,129LLVMInsertValue = 54,130LLVMFreeze = 68,131132/* Atomic operators */133LLVMFence = 55,134LLVMAtomicCmpXchg = 56,135LLVMAtomicRMW = 57,136137/* Exception Handling Operators */138LLVMResume = 58,139LLVMLandingPad = 59,140LLVMCleanupRet = 61,141LLVMCatchRet = 62,142LLVMCatchPad = 63,143LLVMCleanupPad = 64,144LLVMCatchSwitch = 65145} LLVMOpcode;146147typedef enum {148LLVMVoidTypeKind, /**< type with no size */149LLVMHalfTypeKind, /**< 16 bit floating point type */150LLVMFloatTypeKind, /**< 32 bit floating point type */151LLVMDoubleTypeKind, /**< 64 bit floating point type */152LLVMX86_FP80TypeKind, /**< 80 bit floating point type (X87) */153LLVMFP128TypeKind, /**< 128 bit floating point type (112-bit mantissa)*/154LLVMPPC_FP128TypeKind, /**< 128 bit floating point type (two 64-bits) */155LLVMLabelTypeKind, /**< Labels */156LLVMIntegerTypeKind, /**< Arbitrary bit width integers */157LLVMFunctionTypeKind, /**< Functions */158LLVMStructTypeKind, /**< Structures */159LLVMArrayTypeKind, /**< Arrays */160LLVMPointerTypeKind, /**< Pointers */161LLVMVectorTypeKind, /**< Fixed width SIMD vector type */162LLVMMetadataTypeKind, /**< Metadata */163LLVMX86_MMXTypeKind, /**< X86 MMX */164LLVMTokenTypeKind, /**< Tokens */165LLVMScalableVectorTypeKind, /**< Scalable SIMD vector type */166LLVMBFloatTypeKind, /**< 16 bit brain floating point type */167LLVMX86_AMXTypeKind, /**< X86 AMX */168LLVMTargetExtTypeKind, /**< Target extension type */169} LLVMTypeKind;170171typedef enum {172LLVMExternalLinkage, /**< Externally visible function */173LLVMAvailableExternallyLinkage,174LLVMLinkOnceAnyLinkage, /**< Keep one copy of function when linking (inline)*/175LLVMLinkOnceODRLinkage, /**< Same, but only replaced by something176equivalent. */177LLVMLinkOnceODRAutoHideLinkage, /**< Obsolete */178LLVMWeakAnyLinkage, /**< Keep one copy of function when linking (weak) */179LLVMWeakODRLinkage, /**< Same, but only replaced by something180equivalent. */181LLVMAppendingLinkage, /**< Special purpose, only applies to global arrays */182LLVMInternalLinkage, /**< Rename collisions when linking (static183functions) */184LLVMPrivateLinkage, /**< Like Internal, but omit from symbol table */185LLVMDLLImportLinkage, /**< Obsolete */186LLVMDLLExportLinkage, /**< Obsolete */187LLVMExternalWeakLinkage,/**< ExternalWeak linkage description */188LLVMGhostLinkage, /**< Obsolete */189LLVMCommonLinkage, /**< Tentative definitions */190LLVMLinkerPrivateLinkage, /**< Like Private, but linker removes. */191LLVMLinkerPrivateWeakLinkage /**< Like LinkerPrivate, but is weak. */192} LLVMLinkage;193194typedef enum {195LLVMDefaultVisibility, /**< The GV is visible */196LLVMHiddenVisibility, /**< The GV is hidden */197LLVMProtectedVisibility /**< The GV is protected */198} LLVMVisibility;199200typedef enum {201LLVMNoUnnamedAddr, /**< Address of the GV is significant. */202LLVMLocalUnnamedAddr, /**< Address of the GV is locally insignificant. */203LLVMGlobalUnnamedAddr /**< Address of the GV is globally insignificant. */204} LLVMUnnamedAddr;205206typedef enum {207LLVMDefaultStorageClass = 0,208LLVMDLLImportStorageClass = 1, /**< Function to be imported from DLL. */209LLVMDLLExportStorageClass = 2 /**< Function to be accessible from DLL. */210} LLVMDLLStorageClass;211212typedef enum {213LLVMCCallConv = 0,214LLVMFastCallConv = 8,215LLVMColdCallConv = 9,216LLVMGHCCallConv = 10,217LLVMHiPECallConv = 11,218LLVMAnyRegCallConv = 13,219LLVMPreserveMostCallConv = 14,220LLVMPreserveAllCallConv = 15,221LLVMSwiftCallConv = 16,222LLVMCXXFASTTLSCallConv = 17,223LLVMX86StdcallCallConv = 64,224LLVMX86FastcallCallConv = 65,225LLVMARMAPCSCallConv = 66,226LLVMARMAAPCSCallConv = 67,227LLVMARMAAPCSVFPCallConv = 68,228LLVMMSP430INTRCallConv = 69,229LLVMX86ThisCallCallConv = 70,230LLVMPTXKernelCallConv = 71,231LLVMPTXDeviceCallConv = 72,232LLVMSPIRFUNCCallConv = 75,233LLVMSPIRKERNELCallConv = 76,234LLVMIntelOCLBICallConv = 77,235LLVMX8664SysVCallConv = 78,236LLVMWin64CallConv = 79,237LLVMX86VectorCallCallConv = 80,238LLVMHHVMCallConv = 81,239LLVMHHVMCCallConv = 82,240LLVMX86INTRCallConv = 83,241LLVMAVRINTRCallConv = 84,242LLVMAVRSIGNALCallConv = 85,243LLVMAVRBUILTINCallConv = 86,244LLVMAMDGPUVSCallConv = 87,245LLVMAMDGPUGSCallConv = 88,246LLVMAMDGPUPSCallConv = 89,247LLVMAMDGPUCSCallConv = 90,248LLVMAMDGPUKERNELCallConv = 91,249LLVMX86RegCallCallConv = 92,250LLVMAMDGPUHSCallConv = 93,251LLVMMSP430BUILTINCallConv = 94,252LLVMAMDGPULSCallConv = 95,253LLVMAMDGPUESCallConv = 96254} LLVMCallConv;255256typedef enum {257LLVMArgumentValueKind,258LLVMBasicBlockValueKind,259LLVMMemoryUseValueKind,260LLVMMemoryDefValueKind,261LLVMMemoryPhiValueKind,262263LLVMFunctionValueKind,264LLVMGlobalAliasValueKind,265LLVMGlobalIFuncValueKind,266LLVMGlobalVariableValueKind,267LLVMBlockAddressValueKind,268LLVMConstantExprValueKind,269LLVMConstantArrayValueKind,270LLVMConstantStructValueKind,271LLVMConstantVectorValueKind,272273LLVMUndefValueValueKind,274LLVMConstantAggregateZeroValueKind,275LLVMConstantDataArrayValueKind,276LLVMConstantDataVectorValueKind,277LLVMConstantIntValueKind,278LLVMConstantFPValueKind,279LLVMConstantPointerNullValueKind,280LLVMConstantTokenNoneValueKind,281282LLVMMetadataAsValueValueKind,283LLVMInlineAsmValueKind,284285LLVMInstructionValueKind,286LLVMPoisonValueValueKind,287LLVMConstantTargetNoneValueKind,288LLVMConstantPtrAuthValueKind,289} LLVMValueKind;290291typedef enum {292LLVMIntEQ = 32, /**< equal */293LLVMIntNE, /**< not equal */294LLVMIntUGT, /**< unsigned greater than */295LLVMIntUGE, /**< unsigned greater or equal */296LLVMIntULT, /**< unsigned less than */297LLVMIntULE, /**< unsigned less or equal */298LLVMIntSGT, /**< signed greater than */299LLVMIntSGE, /**< signed greater or equal */300LLVMIntSLT, /**< signed less than */301LLVMIntSLE /**< signed less or equal */302} LLVMIntPredicate;303304typedef enum {305LLVMRealPredicateFalse, /**< Always false (always folded) */306LLVMRealOEQ, /**< True if ordered and equal */307LLVMRealOGT, /**< True if ordered and greater than */308LLVMRealOGE, /**< True if ordered and greater than or equal */309LLVMRealOLT, /**< True if ordered and less than */310LLVMRealOLE, /**< True if ordered and less than or equal */311LLVMRealONE, /**< True if ordered and operands are unequal */312LLVMRealORD, /**< True if ordered (no nans) */313LLVMRealUNO, /**< True if unordered: isnan(X) | isnan(Y) */314LLVMRealUEQ, /**< True if unordered or equal */315LLVMRealUGT, /**< True if unordered or greater than */316LLVMRealUGE, /**< True if unordered, greater than, or equal */317LLVMRealULT, /**< True if unordered or less than */318LLVMRealULE, /**< True if unordered, less than, or equal */319LLVMRealUNE, /**< True if unordered or not equal */320LLVMRealPredicateTrue /**< Always true (always folded) */321} LLVMRealPredicate;322323typedef enum {324LLVMLandingPadCatch, /**< A catch clause */325LLVMLandingPadFilter /**< A filter clause */326} LLVMLandingPadClauseTy;327328typedef enum {329LLVMNotThreadLocal = 0,330LLVMGeneralDynamicTLSModel,331LLVMLocalDynamicTLSModel,332LLVMInitialExecTLSModel,333LLVMLocalExecTLSModel334} LLVMThreadLocalMode;335336typedef enum {337LLVMAtomicOrderingNotAtomic = 0, /**< A load or store which is not atomic */338LLVMAtomicOrderingUnordered = 1, /**< Lowest level of atomicity, guarantees339somewhat sane results, lock free. */340LLVMAtomicOrderingMonotonic = 2, /**< guarantees that if you take all the341operations affecting a specific address,342a consistent ordering exists */343LLVMAtomicOrderingAcquire = 4, /**< Acquire provides a barrier of the sort344necessary to acquire a lock to access other345memory with normal loads and stores. */346LLVMAtomicOrderingRelease = 5, /**< Release is similar to Acquire, but with347a barrier of the sort necessary to release348a lock. */349LLVMAtomicOrderingAcquireRelease = 6, /**< provides both an Acquire and a350Release barrier (for fences and351operations which both read and write352memory). */353LLVMAtomicOrderingSequentiallyConsistent = 7 /**< provides Acquire semantics354for loads and Release355semantics for stores.356Additionally, it guarantees357that a total ordering exists358between all359SequentiallyConsistent360operations. */361} LLVMAtomicOrdering;362363typedef enum {364LLVMAtomicRMWBinOpXchg, /**< Set the new value and return the one old */365LLVMAtomicRMWBinOpAdd, /**< Add a value and return the old one */366LLVMAtomicRMWBinOpSub, /**< Subtract a value and return the old one */367LLVMAtomicRMWBinOpAnd, /**< And a value and return the old one */368LLVMAtomicRMWBinOpNand, /**< Not-And a value and return the old one */369LLVMAtomicRMWBinOpOr, /**< OR a value and return the old one */370LLVMAtomicRMWBinOpXor, /**< Xor a value and return the old one */371LLVMAtomicRMWBinOpMax, /**< Sets the value if it's greater than the372original using a signed comparison and return373the old one */374LLVMAtomicRMWBinOpMin, /**< Sets the value if it's Smaller than the375original using a signed comparison and return376the old one */377LLVMAtomicRMWBinOpUMax, /**< Sets the value if it's greater than the378original using an unsigned comparison and return379the old one */380LLVMAtomicRMWBinOpUMin, /**< Sets the value if it's greater than the381original using an unsigned comparison and return382the old one */383LLVMAtomicRMWBinOpFAdd, /**< Add a floating point value and return the384old one */385LLVMAtomicRMWBinOpFSub, /**< Subtract a floating point value and return the386old one */387LLVMAtomicRMWBinOpFMax, /**< Sets the value if it's greater than the388original using an floating point comparison and389return the old one */390LLVMAtomicRMWBinOpFMin, /**< Sets the value if it's smaller than the391original using an floating point comparison and392return the old one */393LLVMAtomicRMWBinOpUIncWrap, /**< Increments the value, wrapping back to zero394when incremented above input value */395LLVMAtomicRMWBinOpUDecWrap, /**< Decrements the value, wrapping back to396the input value when decremented below zero */397} LLVMAtomicRMWBinOp;398399typedef enum {400LLVMDSError,401LLVMDSWarning,402LLVMDSRemark,403LLVMDSNote404} LLVMDiagnosticSeverity;405406typedef enum {407LLVMInlineAsmDialectATT,408LLVMInlineAsmDialectIntel409} LLVMInlineAsmDialect;410411typedef enum {412/**413* Emits an error if two values disagree, otherwise the resulting value is414* that of the operands.415*416* @see Module::ModFlagBehavior::Error417*/418LLVMModuleFlagBehaviorError,419/**420* Emits a warning if two values disagree. The result value will be the421* operand for the flag from the first module being linked.422*423* @see Module::ModFlagBehavior::Warning424*/425LLVMModuleFlagBehaviorWarning,426/**427* Adds a requirement that another module flag be present and have a428* specified value after linking is performed. The value must be a metadata429* pair, where the first element of the pair is the ID of the module flag430* to be restricted, and the second element of the pair is the value the431* module flag should be restricted to. This behavior can be used to432* restrict the allowable results (via triggering of an error) of linking433* IDs with the **Override** behavior.434*435* @see Module::ModFlagBehavior::Require436*/437LLVMModuleFlagBehaviorRequire,438/**439* Uses the specified value, regardless of the behavior or value of the440* other module. If both modules specify **Override**, but the values441* differ, an error will be emitted.442*443* @see Module::ModFlagBehavior::Override444*/445LLVMModuleFlagBehaviorOverride,446/**447* Appends the two values, which are required to be metadata nodes.448*449* @see Module::ModFlagBehavior::Append450*/451LLVMModuleFlagBehaviorAppend,452/**453* Appends the two values, which are required to be metadata454* nodes. However, duplicate entries in the second list are dropped455* during the append operation.456*457* @see Module::ModFlagBehavior::AppendUnique458*/459LLVMModuleFlagBehaviorAppendUnique,460} LLVMModuleFlagBehavior;461462/**463* Attribute index are either LLVMAttributeReturnIndex,464* LLVMAttributeFunctionIndex or a parameter number from 1 to N.465*/466enum {467LLVMAttributeReturnIndex = 0U,468// ISO C restricts enumerator values to range of 'int'469// (4294967295 is too large)470// LLVMAttributeFunctionIndex = ~0U,471LLVMAttributeFunctionIndex = -1,472};473474typedef unsigned LLVMAttributeIndex;475476/**477* Tail call kind for LLVMSetTailCallKind and LLVMGetTailCallKind.478*479* Note that 'musttail' implies 'tail'.480*481* @see CallInst::TailCallKind482*/483typedef enum {484LLVMTailCallKindNone = 0,485LLVMTailCallKindTail = 1,486LLVMTailCallKindMustTail = 2,487LLVMTailCallKindNoTail = 3,488} LLVMTailCallKind;489490enum {491LLVMFastMathAllowReassoc = (1 << 0),492LLVMFastMathNoNaNs = (1 << 1),493LLVMFastMathNoInfs = (1 << 2),494LLVMFastMathNoSignedZeros = (1 << 3),495LLVMFastMathAllowReciprocal = (1 << 4),496LLVMFastMathAllowContract = (1 << 5),497LLVMFastMathApproxFunc = (1 << 6),498LLVMFastMathNone = 0,499LLVMFastMathAll = LLVMFastMathAllowReassoc | LLVMFastMathNoNaNs |500LLVMFastMathNoInfs | LLVMFastMathNoSignedZeros |501LLVMFastMathAllowReciprocal | LLVMFastMathAllowContract |502LLVMFastMathApproxFunc,503};504505/**506* Flags to indicate what fast-math-style optimizations are allowed507* on operations.508*509* See https://llvm.org/docs/LangRef.html#fast-math-flags510*/511typedef unsigned LLVMFastMathFlags;512513enum {514LLVMGEPFlagInBounds = (1 << 0),515LLVMGEPFlagNUSW = (1 << 1),516LLVMGEPFlagNUW = (1 << 2),517};518519/**520* Flags that constrain the allowed wrap semantics of a getelementptr521* instruction.522*523* See https://llvm.org/docs/LangRef.html#getelementptr-instruction524*/525typedef unsigned LLVMGEPNoWrapFlags;526527/**528* @}529*/530531/** Deallocate and destroy all ManagedStatic variables.532@see llvm::llvm_shutdown533@see ManagedStatic */534void LLVMShutdown(void);535536/*===-- Version query -----------------------------------------------------===*/537538/**539* Return the major, minor, and patch version of LLVM540*541* The version components are returned via the function's three output542* parameters or skipped if a NULL pointer was supplied.543*/544void LLVMGetVersion(unsigned *Major, unsigned *Minor, unsigned *Patch);545546/*===-- Error handling ----------------------------------------------------===*/547548char *LLVMCreateMessage(const char *Message);549void LLVMDisposeMessage(char *Message);550551/**552* @defgroup LLVMCCoreContext Contexts553*554* Contexts are execution states for the core LLVM IR system.555*556* Most types are tied to a context instance. Multiple contexts can557* exist simultaneously. A single context is not thread safe. However,558* different contexts can execute on different threads simultaneously.559*560* @{561*/562563typedef void (*LLVMDiagnosticHandler)(LLVMDiagnosticInfoRef, void *);564typedef void (*LLVMYieldCallback)(LLVMContextRef, void *);565566/**567* Create a new context.568*569* Every call to this function should be paired with a call to570* LLVMContextDispose() or the context will leak memory.571*/572LLVMContextRef LLVMContextCreate(void);573574/**575* Obtain the global context instance.576*/577LLVMContextRef LLVMGetGlobalContext(void);578579/**580* Set the diagnostic handler for this context.581*/582void LLVMContextSetDiagnosticHandler(LLVMContextRef C,583LLVMDiagnosticHandler Handler,584void *DiagnosticContext);585586/**587* Get the diagnostic handler of this context.588*/589LLVMDiagnosticHandler LLVMContextGetDiagnosticHandler(LLVMContextRef C);590591/**592* Get the diagnostic context of this context.593*/594void *LLVMContextGetDiagnosticContext(LLVMContextRef C);595596/**597* Set the yield callback function for this context.598*599* @see LLVMContext::setYieldCallback()600*/601void LLVMContextSetYieldCallback(LLVMContextRef C, LLVMYieldCallback Callback,602void *OpaqueHandle);603604/**605* Retrieve whether the given context is set to discard all value names.606*607* @see LLVMContext::shouldDiscardValueNames()608*/609LLVMBool LLVMContextShouldDiscardValueNames(LLVMContextRef C);610611/**612* Set whether the given context discards all value names.613*614* If true, only the names of GlobalValue objects will be available in the IR.615* This can be used to save memory and runtime, especially in release mode.616*617* @see LLVMContext::setDiscardValueNames()618*/619void LLVMContextSetDiscardValueNames(LLVMContextRef C, LLVMBool Discard);620621/**622* Destroy a context instance.623*624* This should be called for every call to LLVMContextCreate() or memory625* will be leaked.626*/627void LLVMContextDispose(LLVMContextRef C);628629/**630* Return a string representation of the DiagnosticInfo. Use631* LLVMDisposeMessage to free the string.632*633* @see DiagnosticInfo::print()634*/635char *LLVMGetDiagInfoDescription(LLVMDiagnosticInfoRef DI);636637/**638* Return an enum LLVMDiagnosticSeverity.639*640* @see DiagnosticInfo::getSeverity()641*/642LLVMDiagnosticSeverity LLVMGetDiagInfoSeverity(LLVMDiagnosticInfoRef DI);643644unsigned LLVMGetMDKindIDInContext(LLVMContextRef C, const char *Name,645unsigned SLen);646unsigned LLVMGetMDKindID(const char *Name, unsigned SLen);647648/**649* Return an unique id given the name of a enum attribute,650* or 0 if no attribute by that name exists.651*652* See http://llvm.org/docs/LangRef.html#parameter-attributes653* and http://llvm.org/docs/LangRef.html#function-attributes654* for the list of available attributes.655*656* NB: Attribute names and/or id are subject to change without657* going through the C API deprecation cycle.658*/659unsigned LLVMGetEnumAttributeKindForName(const char *Name, size_t SLen);660unsigned LLVMGetLastEnumAttributeKind(void);661662/**663* Create an enum attribute.664*/665LLVMAttributeRef LLVMCreateEnumAttribute(LLVMContextRef C, unsigned KindID,666uint64_t Val);667668/**669* Get the unique id corresponding to the enum attribute670* passed as argument.671*/672unsigned LLVMGetEnumAttributeKind(LLVMAttributeRef A);673674/**675* Get the enum attribute's value. 0 is returned if none exists.676*/677uint64_t LLVMGetEnumAttributeValue(LLVMAttributeRef A);678679/**680* Create a type attribute681*/682LLVMAttributeRef LLVMCreateTypeAttribute(LLVMContextRef C, unsigned KindID,683LLVMTypeRef type_ref);684685/**686* Get the type attribute's value.687*/688LLVMTypeRef LLVMGetTypeAttributeValue(LLVMAttributeRef A);689690/**691* Create a ConstantRange attribute.692*693* LowerWords and UpperWords need to be NumBits divided by 64 rounded up694* elements long.695*/696LLVMAttributeRef LLVMCreateConstantRangeAttribute(LLVMContextRef C,697unsigned KindID,698unsigned NumBits,699const uint64_t LowerWords[],700const uint64_t UpperWords[]);701702/**703* Create a string attribute.704*/705LLVMAttributeRef LLVMCreateStringAttribute(LLVMContextRef C,706const char *K, unsigned KLength,707const char *V, unsigned VLength);708709/**710* Get the string attribute's kind.711*/712const char *LLVMGetStringAttributeKind(LLVMAttributeRef A, unsigned *Length);713714/**715* Get the string attribute's value.716*/717const char *LLVMGetStringAttributeValue(LLVMAttributeRef A, unsigned *Length);718719/**720* Check for the different types of attributes.721*/722LLVMBool LLVMIsEnumAttribute(LLVMAttributeRef A);723LLVMBool LLVMIsStringAttribute(LLVMAttributeRef A);724LLVMBool LLVMIsTypeAttribute(LLVMAttributeRef A);725726/**727* Obtain a Type from a context by its registered name.728*/729LLVMTypeRef LLVMGetTypeByName2(LLVMContextRef C, const char *Name);730731/**732* @}733*/734735/**736* @defgroup LLVMCCoreModule Modules737*738* Modules represent the top-level structure in an LLVM program. An LLVM739* module is effectively a translation unit or a collection of740* translation units merged together.741*742* @{743*/744745/**746* Create a new, empty module in the global context.747*748* This is equivalent to calling LLVMModuleCreateWithNameInContext with749* LLVMGetGlobalContext() as the context parameter.750*751* Every invocation should be paired with LLVMDisposeModule() or memory752* will be leaked.753*/754LLVMModuleRef LLVMModuleCreateWithName(const char *ModuleID);755756/**757* Create a new, empty module in a specific context.758*759* Every invocation should be paired with LLVMDisposeModule() or memory760* will be leaked.761*/762LLVMModuleRef LLVMModuleCreateWithNameInContext(const char *ModuleID,763LLVMContextRef C);764/**765* Return an exact copy of the specified module.766*/767LLVMModuleRef LLVMCloneModule(LLVMModuleRef M);768769/**770* Destroy a module instance.771*772* This must be called for every created module or memory will be773* leaked.774*/775void LLVMDisposeModule(LLVMModuleRef M);776777/**778* Soon to be deprecated.779* See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes780*781* Returns true if the module is in the new debug info mode which uses782* non-instruction debug records instead of debug intrinsics for variable783* location tracking.784*/785LLVMBool LLVMIsNewDbgInfoFormat(LLVMModuleRef M);786787/**788* Soon to be deprecated.789* See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes790*791* Convert module into desired debug info format.792*/793void LLVMSetIsNewDbgInfoFormat(LLVMModuleRef M, LLVMBool UseNewFormat);794795/**796* Obtain the identifier of a module.797*798* @param M Module to obtain identifier of799* @param Len Out parameter which holds the length of the returned string.800* @return The identifier of M.801* @see Module::getModuleIdentifier()802*/803const char *LLVMGetModuleIdentifier(LLVMModuleRef M, size_t *Len);804805/**806* Set the identifier of a module to a string Ident with length Len.807*808* @param M The module to set identifier809* @param Ident The string to set M's identifier to810* @param Len Length of Ident811* @see Module::setModuleIdentifier()812*/813void LLVMSetModuleIdentifier(LLVMModuleRef M, const char *Ident, size_t Len);814815/**816* Obtain the module's original source file name.817*818* @param M Module to obtain the name of819* @param Len Out parameter which holds the length of the returned string820* @return The original source file name of M821* @see Module::getSourceFileName()822*/823const char *LLVMGetSourceFileName(LLVMModuleRef M, size_t *Len);824825/**826* Set the original source file name of a module to a string Name with length827* Len.828*829* @param M The module to set the source file name of830* @param Name The string to set M's source file name to831* @param Len Length of Name832* @see Module::setSourceFileName()833*/834void LLVMSetSourceFileName(LLVMModuleRef M, const char *Name, size_t Len);835836/**837* Obtain the data layout for a module.838*839* @see Module::getDataLayoutStr()840*841* LLVMGetDataLayout is DEPRECATED, as the name is not only incorrect,842* but match the name of another method on the module. Prefer the use843* of LLVMGetDataLayoutStr, which is not ambiguous.844*/845const char *LLVMGetDataLayoutStr(LLVMModuleRef M);846const char *LLVMGetDataLayout(LLVMModuleRef M);847848/**849* Set the data layout for a module.850*851* @see Module::setDataLayout()852*/853void LLVMSetDataLayout(LLVMModuleRef M, const char *DataLayoutStr);854855/**856* Obtain the target triple for a module.857*858* @see Module::getTargetTriple()859*/860const char *LLVMGetTarget(LLVMModuleRef M);861862/**863* Set the target triple for a module.864*865* @see Module::setTargetTriple()866*/867void LLVMSetTarget(LLVMModuleRef M, const char *Triple);868869/**870* Returns the module flags as an array of flag-key-value triples. The caller871* is responsible for freeing this array by calling872* \c LLVMDisposeModuleFlagsMetadata.873*874* @see Module::getModuleFlagsMetadata()875*/876LLVMModuleFlagEntry *LLVMCopyModuleFlagsMetadata(LLVMModuleRef M, size_t *Len);877878/**879* Destroys module flags metadata entries.880*/881void LLVMDisposeModuleFlagsMetadata(LLVMModuleFlagEntry *Entries);882883/**884* Returns the flag behavior for a module flag entry at a specific index.885*886* @see Module::ModuleFlagEntry::Behavior887*/888LLVMModuleFlagBehavior889LLVMModuleFlagEntriesGetFlagBehavior(LLVMModuleFlagEntry *Entries,890unsigned Index);891892/**893* Returns the key for a module flag entry at a specific index.894*895* @see Module::ModuleFlagEntry::Key896*/897const char *LLVMModuleFlagEntriesGetKey(LLVMModuleFlagEntry *Entries,898unsigned Index, size_t *Len);899900/**901* Returns the metadata for a module flag entry at a specific index.902*903* @see Module::ModuleFlagEntry::Val904*/905LLVMMetadataRef LLVMModuleFlagEntriesGetMetadata(LLVMModuleFlagEntry *Entries,906unsigned Index);907908/**909* Add a module-level flag to the module-level flags metadata if it doesn't910* already exist.911*912* @see Module::getModuleFlag()913*/914LLVMMetadataRef LLVMGetModuleFlag(LLVMModuleRef M,915const char *Key, size_t KeyLen);916917/**918* Add a module-level flag to the module-level flags metadata if it doesn't919* already exist.920*921* @see Module::addModuleFlag()922*/923void LLVMAddModuleFlag(LLVMModuleRef M, LLVMModuleFlagBehavior Behavior,924const char *Key, size_t KeyLen,925LLVMMetadataRef Val);926927/**928* Dump a representation of a module to stderr.929*930* @see Module::dump()931*/932void LLVMDumpModule(LLVMModuleRef M);933934/**935* Print a representation of a module to a file. The ErrorMessage needs to be936* disposed with LLVMDisposeMessage. Returns 0 on success, 1 otherwise.937*938* @see Module::print()939*/940LLVMBool LLVMPrintModuleToFile(LLVMModuleRef M, const char *Filename,941char **ErrorMessage);942943/**944* Return a string representation of the module. Use945* LLVMDisposeMessage to free the string.946*947* @see Module::print()948*/949char *LLVMPrintModuleToString(LLVMModuleRef M);950951/**952* Get inline assembly for a module.953*954* @see Module::getModuleInlineAsm()955*/956const char *LLVMGetModuleInlineAsm(LLVMModuleRef M, size_t *Len);957958/**959* Set inline assembly for a module.960*961* @see Module::setModuleInlineAsm()962*/963void LLVMSetModuleInlineAsm2(LLVMModuleRef M, const char *Asm, size_t Len);964965/**966* Append inline assembly to a module.967*968* @see Module::appendModuleInlineAsm()969*/970void LLVMAppendModuleInlineAsm(LLVMModuleRef M, const char *Asm, size_t Len);971972/**973* Create the specified uniqued inline asm string.974*975* @see InlineAsm::get()976*/977LLVMValueRef LLVMGetInlineAsm(LLVMTypeRef Ty, const char *AsmString,978size_t AsmStringSize, const char *Constraints,979size_t ConstraintsSize, LLVMBool HasSideEffects,980LLVMBool IsAlignStack,981LLVMInlineAsmDialect Dialect, LLVMBool CanThrow);982983/**984* Get the template string used for an inline assembly snippet985*986*/987const char *LLVMGetInlineAsmAsmString(LLVMValueRef InlineAsmVal, size_t *Len);988989/**990* Get the raw constraint string for an inline assembly snippet991*992*/993const char *LLVMGetInlineAsmConstraintString(LLVMValueRef InlineAsmVal,994size_t *Len);995996/**997* Get the dialect used by the inline asm snippet998*999*/1000LLVMInlineAsmDialect LLVMGetInlineAsmDialect(LLVMValueRef InlineAsmVal);10011002/**1003* Get the function type of the inline assembly snippet. The same type that1004* was passed into LLVMGetInlineAsm originally1005*1006* @see LLVMGetInlineAsm1007*1008*/1009LLVMTypeRef LLVMGetInlineAsmFunctionType(LLVMValueRef InlineAsmVal);10101011/**1012* Get if the inline asm snippet has side effects1013*1014*/1015LLVMBool LLVMGetInlineAsmHasSideEffects(LLVMValueRef InlineAsmVal);10161017/**1018* Get if the inline asm snippet needs an aligned stack1019*1020*/1021LLVMBool LLVMGetInlineAsmNeedsAlignedStack(LLVMValueRef InlineAsmVal);10221023/**1024* Get if the inline asm snippet may unwind the stack1025*1026*/1027LLVMBool LLVMGetInlineAsmCanUnwind(LLVMValueRef InlineAsmVal);10281029/**1030* Obtain the context to which this module is associated.1031*1032* @see Module::getContext()1033*/1034LLVMContextRef LLVMGetModuleContext(LLVMModuleRef M);10351036/** Deprecated: Use LLVMGetTypeByName2 instead. */1037LLVMTypeRef LLVMGetTypeByName(LLVMModuleRef M, const char *Name);10381039/**1040* Obtain an iterator to the first NamedMDNode in a Module.1041*1042* @see llvm::Module::named_metadata_begin()1043*/1044LLVMNamedMDNodeRef LLVMGetFirstNamedMetadata(LLVMModuleRef M);10451046/**1047* Obtain an iterator to the last NamedMDNode in a Module.1048*1049* @see llvm::Module::named_metadata_end()1050*/1051LLVMNamedMDNodeRef LLVMGetLastNamedMetadata(LLVMModuleRef M);10521053/**1054* Advance a NamedMDNode iterator to the next NamedMDNode.1055*1056* Returns NULL if the iterator was already at the end and there are no more1057* named metadata nodes.1058*/1059LLVMNamedMDNodeRef LLVMGetNextNamedMetadata(LLVMNamedMDNodeRef NamedMDNode);10601061/**1062* Decrement a NamedMDNode iterator to the previous NamedMDNode.1063*1064* Returns NULL if the iterator was already at the beginning and there are1065* no previous named metadata nodes.1066*/1067LLVMNamedMDNodeRef LLVMGetPreviousNamedMetadata(LLVMNamedMDNodeRef NamedMDNode);10681069/**1070* Retrieve a NamedMDNode with the given name, returning NULL if no such1071* node exists.1072*1073* @see llvm::Module::getNamedMetadata()1074*/1075LLVMNamedMDNodeRef LLVMGetNamedMetadata(LLVMModuleRef M,1076const char *Name, size_t NameLen);10771078/**1079* Retrieve a NamedMDNode with the given name, creating a new node if no such1080* node exists.1081*1082* @see llvm::Module::getOrInsertNamedMetadata()1083*/1084LLVMNamedMDNodeRef LLVMGetOrInsertNamedMetadata(LLVMModuleRef M,1085const char *Name,1086size_t NameLen);10871088/**1089* Retrieve the name of a NamedMDNode.1090*1091* @see llvm::NamedMDNode::getName()1092*/1093const char *LLVMGetNamedMetadataName(LLVMNamedMDNodeRef NamedMD,1094size_t *NameLen);10951096/**1097* Obtain the number of operands for named metadata in a module.1098*1099* @see llvm::Module::getNamedMetadata()1100*/1101unsigned LLVMGetNamedMetadataNumOperands(LLVMModuleRef M, const char *Name);11021103/**1104* Obtain the named metadata operands for a module.1105*1106* The passed LLVMValueRef pointer should refer to an array of1107* LLVMValueRef at least LLVMGetNamedMetadataNumOperands long. This1108* array will be populated with the LLVMValueRef instances. Each1109* instance corresponds to a llvm::MDNode.1110*1111* @see llvm::Module::getNamedMetadata()1112* @see llvm::MDNode::getOperand()1113*/1114void LLVMGetNamedMetadataOperands(LLVMModuleRef M, const char *Name,1115LLVMValueRef *Dest);11161117/**1118* Add an operand to named metadata.1119*1120* @see llvm::Module::getNamedMetadata()1121* @see llvm::MDNode::addOperand()1122*/1123void LLVMAddNamedMetadataOperand(LLVMModuleRef M, const char *Name,1124LLVMValueRef Val);11251126/**1127* Return the directory of the debug location for this value, which must be1128* an llvm::Instruction, llvm::GlobalVariable, or llvm::Function.1129*1130* @see llvm::Instruction::getDebugLoc()1131* @see llvm::GlobalVariable::getDebugInfo()1132* @see llvm::Function::getSubprogram()1133*/1134const char *LLVMGetDebugLocDirectory(LLVMValueRef Val, unsigned *Length);11351136/**1137* Return the filename of the debug location for this value, which must be1138* an llvm::Instruction, llvm::GlobalVariable, or llvm::Function.1139*1140* @see llvm::Instruction::getDebugLoc()1141* @see llvm::GlobalVariable::getDebugInfo()1142* @see llvm::Function::getSubprogram()1143*/1144const char *LLVMGetDebugLocFilename(LLVMValueRef Val, unsigned *Length);11451146/**1147* Return the line number of the debug location for this value, which must be1148* an llvm::Instruction, llvm::GlobalVariable, or llvm::Function.1149*1150* @see llvm::Instruction::getDebugLoc()1151* @see llvm::GlobalVariable::getDebugInfo()1152* @see llvm::Function::getSubprogram()1153*/1154unsigned LLVMGetDebugLocLine(LLVMValueRef Val);11551156/**1157* Return the column number of the debug location for this value, which must be1158* an llvm::Instruction.1159*1160* @see llvm::Instruction::getDebugLoc()1161*/1162unsigned LLVMGetDebugLocColumn(LLVMValueRef Val);11631164/**1165* Add a function to a module under a specified name.1166*1167* @see llvm::Function::Create()1168*/1169LLVMValueRef LLVMAddFunction(LLVMModuleRef M, const char *Name,1170LLVMTypeRef FunctionTy);11711172/**1173* Obtain a Function value from a Module by its name.1174*1175* The returned value corresponds to a llvm::Function value.1176*1177* @see llvm::Module::getFunction()1178*/1179LLVMValueRef LLVMGetNamedFunction(LLVMModuleRef M, const char *Name);11801181/**1182* Obtain an iterator to the first Function in a Module.1183*1184* @see llvm::Module::begin()1185*/1186LLVMValueRef LLVMGetFirstFunction(LLVMModuleRef M);11871188/**1189* Obtain an iterator to the last Function in a Module.1190*1191* @see llvm::Module::end()1192*/1193LLVMValueRef LLVMGetLastFunction(LLVMModuleRef M);11941195/**1196* Advance a Function iterator to the next Function.1197*1198* Returns NULL if the iterator was already at the end and there are no more1199* functions.1200*/1201LLVMValueRef LLVMGetNextFunction(LLVMValueRef Fn);12021203/**1204* Decrement a Function iterator to the previous Function.1205*1206* Returns NULL if the iterator was already at the beginning and there are1207* no previous functions.1208*/1209LLVMValueRef LLVMGetPreviousFunction(LLVMValueRef Fn);12101211/** Deprecated: Use LLVMSetModuleInlineAsm2 instead. */1212void LLVMSetModuleInlineAsm(LLVMModuleRef M, const char *Asm);12131214/**1215* @}1216*/12171218/**1219* @defgroup LLVMCCoreType Types1220*1221* Types represent the type of a value.1222*1223* Types are associated with a context instance. The context internally1224* deduplicates types so there is only 1 instance of a specific type1225* alive at a time. In other words, a unique type is shared among all1226* consumers within a context.1227*1228* A Type in the C API corresponds to llvm::Type.1229*1230* Types have the following hierarchy:1231*1232* types:1233* integer type1234* real type1235* function type1236* sequence types:1237* array type1238* pointer type1239* vector type1240* void type1241* label type1242* opaque type1243*1244* @{1245*/12461247/**1248* Obtain the enumerated type of a Type instance.1249*1250* @see llvm::Type:getTypeID()1251*/1252LLVMTypeKind LLVMGetTypeKind(LLVMTypeRef Ty);12531254/**1255* Whether the type has a known size.1256*1257* Things that don't have a size are abstract types, labels, and void.a1258*1259* @see llvm::Type::isSized()1260*/1261LLVMBool LLVMTypeIsSized(LLVMTypeRef Ty);12621263/**1264* Obtain the context to which this type instance is associated.1265*1266* @see llvm::Type::getContext()1267*/1268LLVMContextRef LLVMGetTypeContext(LLVMTypeRef Ty);12691270/**1271* Dump a representation of a type to stderr.1272*1273* @see llvm::Type::dump()1274*/1275void LLVMDumpType(LLVMTypeRef Val);12761277/**1278* Return a string representation of the type. Use1279* LLVMDisposeMessage to free the string.1280*1281* @see llvm::Type::print()1282*/1283char *LLVMPrintTypeToString(LLVMTypeRef Val);12841285/**1286* @defgroup LLVMCCoreTypeInt Integer Types1287*1288* Functions in this section operate on integer types.1289*1290* @{1291*/12921293/**1294* Obtain an integer type from a context with specified bit width.1295*/1296LLVMTypeRef LLVMInt1TypeInContext(LLVMContextRef C);1297LLVMTypeRef LLVMInt8TypeInContext(LLVMContextRef C);1298LLVMTypeRef LLVMInt16TypeInContext(LLVMContextRef C);1299LLVMTypeRef LLVMInt32TypeInContext(LLVMContextRef C);1300LLVMTypeRef LLVMInt64TypeInContext(LLVMContextRef C);1301LLVMTypeRef LLVMInt128TypeInContext(LLVMContextRef C);1302LLVMTypeRef LLVMIntTypeInContext(LLVMContextRef C, unsigned NumBits);13031304/**1305* Obtain an integer type from the global context with a specified bit1306* width.1307*/1308LLVMTypeRef LLVMInt1Type(void);1309LLVMTypeRef LLVMInt8Type(void);1310LLVMTypeRef LLVMInt16Type(void);1311LLVMTypeRef LLVMInt32Type(void);1312LLVMTypeRef LLVMInt64Type(void);1313LLVMTypeRef LLVMInt128Type(void);1314LLVMTypeRef LLVMIntType(unsigned NumBits);1315unsigned LLVMGetIntTypeWidth(LLVMTypeRef IntegerTy);13161317/**1318* @}1319*/13201321/**1322* @defgroup LLVMCCoreTypeFloat Floating Point Types1323*1324* @{1325*/13261327/**1328* Obtain a 16-bit floating point type from a context.1329*/1330LLVMTypeRef LLVMHalfTypeInContext(LLVMContextRef C);13311332/**1333* Obtain a 16-bit brain floating point type from a context.1334*/1335LLVMTypeRef LLVMBFloatTypeInContext(LLVMContextRef C);13361337/**1338* Obtain a 32-bit floating point type from a context.1339*/1340LLVMTypeRef LLVMFloatTypeInContext(LLVMContextRef C);13411342/**1343* Obtain a 64-bit floating point type from a context.1344*/1345LLVMTypeRef LLVMDoubleTypeInContext(LLVMContextRef C);13461347/**1348* Obtain a 80-bit floating point type (X87) from a context.1349*/1350LLVMTypeRef LLVMX86FP80TypeInContext(LLVMContextRef C);13511352/**1353* Obtain a 128-bit floating point type (112-bit mantissa) from a1354* context.1355*/1356LLVMTypeRef LLVMFP128TypeInContext(LLVMContextRef C);13571358/**1359* Obtain a 128-bit floating point type (two 64-bits) from a context.1360*/1361LLVMTypeRef LLVMPPCFP128TypeInContext(LLVMContextRef C);13621363/**1364* Obtain a floating point type from the global context.1365*1366* These map to the functions in this group of the same name.1367*/1368LLVMTypeRef LLVMHalfType(void);1369LLVMTypeRef LLVMBFloatType(void);1370LLVMTypeRef LLVMFloatType(void);1371LLVMTypeRef LLVMDoubleType(void);1372LLVMTypeRef LLVMX86FP80Type(void);1373LLVMTypeRef LLVMFP128Type(void);1374LLVMTypeRef LLVMPPCFP128Type(void);13751376/**1377* @}1378*/13791380/**1381* @defgroup LLVMCCoreTypeFunction Function Types1382*1383* @{1384*/13851386/**1387* Obtain a function type consisting of a specified signature.1388*1389* The function is defined as a tuple of a return Type, a list of1390* parameter types, and whether the function is variadic.1391*/1392LLVMTypeRef LLVMFunctionType(LLVMTypeRef ReturnType,1393LLVMTypeRef *ParamTypes, unsigned ParamCount,1394LLVMBool IsVarArg);13951396/**1397* Returns whether a function type is variadic.1398*/1399LLVMBool LLVMIsFunctionVarArg(LLVMTypeRef FunctionTy);14001401/**1402* Obtain the Type this function Type returns.1403*/1404LLVMTypeRef LLVMGetReturnType(LLVMTypeRef FunctionTy);14051406/**1407* Obtain the number of parameters this function accepts.1408*/1409unsigned LLVMCountParamTypes(LLVMTypeRef FunctionTy);14101411/**1412* Obtain the types of a function's parameters.1413*1414* The Dest parameter should point to a pre-allocated array of1415* LLVMTypeRef at least LLVMCountParamTypes() large. On return, the1416* first LLVMCountParamTypes() entries in the array will be populated1417* with LLVMTypeRef instances.1418*1419* @param FunctionTy The function type to operate on.1420* @param Dest Memory address of an array to be filled with result.1421*/1422void LLVMGetParamTypes(LLVMTypeRef FunctionTy, LLVMTypeRef *Dest);14231424/**1425* @}1426*/14271428/**1429* @defgroup LLVMCCoreTypeStruct Structure Types1430*1431* These functions relate to LLVMTypeRef instances.1432*1433* @see llvm::StructType1434*1435* @{1436*/14371438/**1439* Create a new structure type in a context.1440*1441* A structure is specified by a list of inner elements/types and1442* whether these can be packed together.1443*1444* @see llvm::StructType::create()1445*/1446LLVMTypeRef LLVMStructTypeInContext(LLVMContextRef C, LLVMTypeRef *ElementTypes,1447unsigned ElementCount, LLVMBool Packed);14481449/**1450* Create a new structure type in the global context.1451*1452* @see llvm::StructType::create()1453*/1454LLVMTypeRef LLVMStructType(LLVMTypeRef *ElementTypes, unsigned ElementCount,1455LLVMBool Packed);14561457/**1458* Create an empty structure in a context having a specified name.1459*1460* @see llvm::StructType::create()1461*/1462LLVMTypeRef LLVMStructCreateNamed(LLVMContextRef C, const char *Name);14631464/**1465* Obtain the name of a structure.1466*1467* @see llvm::StructType::getName()1468*/1469const char *LLVMGetStructName(LLVMTypeRef Ty);14701471/**1472* Set the contents of a structure type.1473*1474* @see llvm::StructType::setBody()1475*/1476void LLVMStructSetBody(LLVMTypeRef StructTy, LLVMTypeRef *ElementTypes,1477unsigned ElementCount, LLVMBool Packed);14781479/**1480* Get the number of elements defined inside the structure.1481*1482* @see llvm::StructType::getNumElements()1483*/1484unsigned LLVMCountStructElementTypes(LLVMTypeRef StructTy);14851486/**1487* Get the elements within a structure.1488*1489* The function is passed the address of a pre-allocated array of1490* LLVMTypeRef at least LLVMCountStructElementTypes() long. After1491* invocation, this array will be populated with the structure's1492* elements. The objects in the destination array will have a lifetime1493* of the structure type itself, which is the lifetime of the context it1494* is contained in.1495*/1496void LLVMGetStructElementTypes(LLVMTypeRef StructTy, LLVMTypeRef *Dest);14971498/**1499* Get the type of the element at a given index in the structure.1500*1501* @see llvm::StructType::getTypeAtIndex()1502*/1503LLVMTypeRef LLVMStructGetTypeAtIndex(LLVMTypeRef StructTy, unsigned i);15041505/**1506* Determine whether a structure is packed.1507*1508* @see llvm::StructType::isPacked()1509*/1510LLVMBool LLVMIsPackedStruct(LLVMTypeRef StructTy);15111512/**1513* Determine whether a structure is opaque.1514*1515* @see llvm::StructType::isOpaque()1516*/1517LLVMBool LLVMIsOpaqueStruct(LLVMTypeRef StructTy);15181519/**1520* Determine whether a structure is literal.1521*1522* @see llvm::StructType::isLiteral()1523*/1524LLVMBool LLVMIsLiteralStruct(LLVMTypeRef StructTy);15251526/**1527* @}1528*/15291530/**1531* @defgroup LLVMCCoreTypeSequential Sequential Types1532*1533* Sequential types represents "arrays" of types. This is a super class1534* for array, vector, and pointer types.1535*1536* @{1537*/15381539/**1540* Obtain the element type of an array or vector type.1541*1542* @see llvm::SequentialType::getElementType()1543*/1544LLVMTypeRef LLVMGetElementType(LLVMTypeRef Ty);15451546/**1547* Returns type's subtypes1548*1549* @see llvm::Type::subtypes()1550*/1551void LLVMGetSubtypes(LLVMTypeRef Tp, LLVMTypeRef *Arr);15521553/**1554* Return the number of types in the derived type.1555*1556* @see llvm::Type::getNumContainedTypes()1557*/1558unsigned LLVMGetNumContainedTypes(LLVMTypeRef Tp);15591560/**1561* Create a fixed size array type that refers to a specific type.1562*1563* The created type will exist in the context that its element type1564* exists in.1565*1566* @deprecated LLVMArrayType is deprecated in favor of the API accurate1567* LLVMArrayType21568* @see llvm::ArrayType::get()1569*/1570LLVMTypeRef LLVMArrayType(LLVMTypeRef ElementType, unsigned ElementCount);15711572/**1573* Create a fixed size array type that refers to a specific type.1574*1575* The created type will exist in the context that its element type1576* exists in.1577*1578* @see llvm::ArrayType::get()1579*/1580LLVMTypeRef LLVMArrayType2(LLVMTypeRef ElementType, uint64_t ElementCount);15811582/**1583* Obtain the length of an array type.1584*1585* This only works on types that represent arrays.1586*1587* @deprecated LLVMGetArrayLength is deprecated in favor of the API accurate1588* LLVMGetArrayLength21589* @see llvm::ArrayType::getNumElements()1590*/1591unsigned LLVMGetArrayLength(LLVMTypeRef ArrayTy);15921593/**1594* Obtain the length of an array type.1595*1596* This only works on types that represent arrays.1597*1598* @see llvm::ArrayType::getNumElements()1599*/1600uint64_t LLVMGetArrayLength2(LLVMTypeRef ArrayTy);16011602/**1603* Create a pointer type that points to a defined type.1604*1605* The created type will exist in the context that its pointee type1606* exists in.1607*1608* @see llvm::PointerType::get()1609*/1610LLVMTypeRef LLVMPointerType(LLVMTypeRef ElementType, unsigned AddressSpace);16111612/**1613* Determine whether a pointer is opaque.1614*1615* True if this is an instance of an opaque PointerType.1616*1617* @see llvm::Type::isOpaquePointerTy()1618*/1619LLVMBool LLVMPointerTypeIsOpaque(LLVMTypeRef Ty);16201621/**1622* Create an opaque pointer type in a context.1623*1624* @see llvm::PointerType::get()1625*/1626LLVMTypeRef LLVMPointerTypeInContext(LLVMContextRef C, unsigned AddressSpace);16271628/**1629* Obtain the address space of a pointer type.1630*1631* This only works on types that represent pointers.1632*1633* @see llvm::PointerType::getAddressSpace()1634*/1635unsigned LLVMGetPointerAddressSpace(LLVMTypeRef PointerTy);16361637/**1638* Create a vector type that contains a defined type and has a specific1639* number of elements.1640*1641* The created type will exist in the context thats its element type1642* exists in.1643*1644* @see llvm::VectorType::get()1645*/1646LLVMTypeRef LLVMVectorType(LLVMTypeRef ElementType, unsigned ElementCount);16471648/**1649* Create a vector type that contains a defined type and has a scalable1650* number of elements.1651*1652* The created type will exist in the context thats its element type1653* exists in.1654*1655* @see llvm::ScalableVectorType::get()1656*/1657LLVMTypeRef LLVMScalableVectorType(LLVMTypeRef ElementType,1658unsigned ElementCount);16591660/**1661* Obtain the (possibly scalable) number of elements in a vector type.1662*1663* This only works on types that represent vectors (fixed or scalable).1664*1665* @see llvm::VectorType::getNumElements()1666*/1667unsigned LLVMGetVectorSize(LLVMTypeRef VectorTy);16681669/**1670* Get the pointer value for the associated ConstantPtrAuth constant.1671*1672* @see llvm::ConstantPtrAuth::getPointer1673*/1674LLVMValueRef LLVMGetConstantPtrAuthPointer(LLVMValueRef PtrAuth);16751676/**1677* Get the key value for the associated ConstantPtrAuth constant.1678*1679* @see llvm::ConstantPtrAuth::getKey1680*/1681LLVMValueRef LLVMGetConstantPtrAuthKey(LLVMValueRef PtrAuth);16821683/**1684* Get the discriminator value for the associated ConstantPtrAuth constant.1685*1686* @see llvm::ConstantPtrAuth::getDiscriminator1687*/1688LLVMValueRef LLVMGetConstantPtrAuthDiscriminator(LLVMValueRef PtrAuth);16891690/**1691* Get the address discriminator value for the associated ConstantPtrAuth1692* constant.1693*1694* @see llvm::ConstantPtrAuth::getAddrDiscriminator1695*/1696LLVMValueRef LLVMGetConstantPtrAuthAddrDiscriminator(LLVMValueRef PtrAuth);16971698/**1699* @}1700*/17011702/**1703* @defgroup LLVMCCoreTypeOther Other Types1704*1705* @{1706*/17071708/**1709* Create a void type in a context.1710*/1711LLVMTypeRef LLVMVoidTypeInContext(LLVMContextRef C);17121713/**1714* Create a label type in a context.1715*/1716LLVMTypeRef LLVMLabelTypeInContext(LLVMContextRef C);17171718/**1719* Create a X86 MMX type in a context.1720*/1721LLVMTypeRef LLVMX86MMXTypeInContext(LLVMContextRef C);17221723/**1724* Create a X86 AMX type in a context.1725*/1726LLVMTypeRef LLVMX86AMXTypeInContext(LLVMContextRef C);17271728/**1729* Create a token type in a context.1730*/1731LLVMTypeRef LLVMTokenTypeInContext(LLVMContextRef C);17321733/**1734* Create a metadata type in a context.1735*/1736LLVMTypeRef LLVMMetadataTypeInContext(LLVMContextRef C);17371738/**1739* These are similar to the above functions except they operate on the1740* global context.1741*/1742LLVMTypeRef LLVMVoidType(void);1743LLVMTypeRef LLVMLabelType(void);1744LLVMTypeRef LLVMX86MMXType(void);1745LLVMTypeRef LLVMX86AMXType(void);17461747/**1748* Create a target extension type in LLVM context.1749*/1750LLVMTypeRef LLVMTargetExtTypeInContext(LLVMContextRef C, const char *Name,1751LLVMTypeRef *TypeParams,1752unsigned TypeParamCount,1753unsigned *IntParams,1754unsigned IntParamCount);17551756/**1757* Obtain the name for this target extension type.1758*1759* @see llvm::TargetExtType::getName()1760*/1761const char *LLVMGetTargetExtTypeName(LLVMTypeRef TargetExtTy);17621763/**1764* Obtain the number of type parameters for this target extension type.1765*1766* @see llvm::TargetExtType::getNumTypeParameters()1767*/1768unsigned LLVMGetTargetExtTypeNumTypeParams(LLVMTypeRef TargetExtTy);17691770/**1771* Get the type parameter at the given index for the target extension type.1772*1773* @see llvm::TargetExtType::getTypeParameter()1774*/1775LLVMTypeRef LLVMGetTargetExtTypeTypeParam(LLVMTypeRef TargetExtTy,1776unsigned Idx);17771778/**1779* Obtain the number of int parameters for this target extension type.1780*1781* @see llvm::TargetExtType::getNumIntParameters()1782*/1783unsigned LLVMGetTargetExtTypeNumIntParams(LLVMTypeRef TargetExtTy);17841785/**1786* Get the int parameter at the given index for the target extension type.1787*1788* @see llvm::TargetExtType::getIntParameter()1789*/1790unsigned LLVMGetTargetExtTypeIntParam(LLVMTypeRef TargetExtTy, unsigned Idx);17911792/**1793* @}1794*/17951796/**1797* @}1798*/17991800/**1801* @defgroup LLVMCCoreValues Values1802*1803* The bulk of LLVM's object model consists of values, which comprise a very1804* rich type hierarchy.1805*1806* LLVMValueRef essentially represents llvm::Value. There is a rich1807* hierarchy of classes within this type. Depending on the instance1808* obtained, not all APIs are available.1809*1810* Callers can determine the type of an LLVMValueRef by calling the1811* LLVMIsA* family of functions (e.g. LLVMIsAArgument()). These1812* functions are defined by a macro, so it isn't obvious which are1813* available by looking at the Doxygen source code. Instead, look at the1814* source definition of LLVM_FOR_EACH_VALUE_SUBCLASS and note the list1815* of value names given. These value names also correspond to classes in1816* the llvm::Value hierarchy.1817*1818* @{1819*/18201821// Currently, clang-format tries to format the LLVM_FOR_EACH_VALUE_SUBCLASS1822// macro in a progressively-indented fashion, which is not desired1823// clang-format off18241825#define LLVM_FOR_EACH_VALUE_SUBCLASS(macro) \1826macro(Argument) \1827macro(BasicBlock) \1828macro(InlineAsm) \1829macro(User) \1830macro(Constant) \1831macro(BlockAddress) \1832macro(ConstantAggregateZero) \1833macro(ConstantArray) \1834macro(ConstantDataSequential) \1835macro(ConstantDataArray) \1836macro(ConstantDataVector) \1837macro(ConstantExpr) \1838macro(ConstantFP) \1839macro(ConstantInt) \1840macro(ConstantPointerNull) \1841macro(ConstantStruct) \1842macro(ConstantTokenNone) \1843macro(ConstantVector) \1844macro(ConstantPtrAuth) \1845macro(GlobalValue) \1846macro(GlobalAlias) \1847macro(GlobalObject) \1848macro(Function) \1849macro(GlobalVariable) \1850macro(GlobalIFunc) \1851macro(UndefValue) \1852macro(PoisonValue) \1853macro(Instruction) \1854macro(UnaryOperator) \1855macro(BinaryOperator) \1856macro(CallInst) \1857macro(IntrinsicInst) \1858macro(DbgInfoIntrinsic) \1859macro(DbgVariableIntrinsic) \1860macro(DbgDeclareInst) \1861macro(DbgLabelInst) \1862macro(MemIntrinsic) \1863macro(MemCpyInst) \1864macro(MemMoveInst) \1865macro(MemSetInst) \1866macro(CmpInst) \1867macro(FCmpInst) \1868macro(ICmpInst) \1869macro(ExtractElementInst) \1870macro(GetElementPtrInst) \1871macro(InsertElementInst) \1872macro(InsertValueInst) \1873macro(LandingPadInst) \1874macro(PHINode) \1875macro(SelectInst) \1876macro(ShuffleVectorInst) \1877macro(StoreInst) \1878macro(BranchInst) \1879macro(IndirectBrInst) \1880macro(InvokeInst) \1881macro(ReturnInst) \1882macro(SwitchInst) \1883macro(UnreachableInst) \1884macro(ResumeInst) \1885macro(CleanupReturnInst) \1886macro(CatchReturnInst) \1887macro(CatchSwitchInst) \1888macro(CallBrInst) \1889macro(FuncletPadInst) \1890macro(CatchPadInst) \1891macro(CleanupPadInst) \1892macro(UnaryInstruction) \1893macro(AllocaInst) \1894macro(CastInst) \1895macro(AddrSpaceCastInst) \1896macro(BitCastInst) \1897macro(FPExtInst) \1898macro(FPToSIInst) \1899macro(FPToUIInst) \1900macro(FPTruncInst) \1901macro(IntToPtrInst) \1902macro(PtrToIntInst) \1903macro(SExtInst) \1904macro(SIToFPInst) \1905macro(TruncInst) \1906macro(UIToFPInst) \1907macro(ZExtInst) \1908macro(ExtractValueInst) \1909macro(LoadInst) \1910macro(VAArgInst) \1911macro(FreezeInst) \1912macro(AtomicCmpXchgInst) \1913macro(AtomicRMWInst) \1914macro(FenceInst)19151916// clang-format on19171918/**1919* @defgroup LLVMCCoreValueGeneral General APIs1920*1921* Functions in this section work on all LLVMValueRef instances,1922* regardless of their sub-type. They correspond to functions available1923* on llvm::Value.1924*1925* @{1926*/19271928/**1929* Obtain the type of a value.1930*1931* @see llvm::Value::getType()1932*/1933LLVMTypeRef LLVMTypeOf(LLVMValueRef Val);19341935/**1936* Obtain the enumerated type of a Value instance.1937*1938* @see llvm::Value::getValueID()1939*/1940LLVMValueKind LLVMGetValueKind(LLVMValueRef Val);19411942/**1943* Obtain the string name of a value.1944*1945* @see llvm::Value::getName()1946*/1947const char *LLVMGetValueName2(LLVMValueRef Val, size_t *Length);19481949/**1950* Set the string name of a value.1951*1952* @see llvm::Value::setName()1953*/1954void LLVMSetValueName2(LLVMValueRef Val, const char *Name, size_t NameLen);19551956/**1957* Dump a representation of a value to stderr.1958*1959* @see llvm::Value::dump()1960*/1961void LLVMDumpValue(LLVMValueRef Val);19621963/**1964* Return a string representation of the value. Use1965* LLVMDisposeMessage to free the string.1966*1967* @see llvm::Value::print()1968*/1969char *LLVMPrintValueToString(LLVMValueRef Val);19701971/**1972* Return a string representation of the DbgRecord. Use1973* LLVMDisposeMessage to free the string.1974*1975* @see llvm::DbgRecord::print()1976*/1977char *LLVMPrintDbgRecordToString(LLVMDbgRecordRef Record);19781979/**1980* Replace all uses of a value with another one.1981*1982* @see llvm::Value::replaceAllUsesWith()1983*/1984void LLVMReplaceAllUsesWith(LLVMValueRef OldVal, LLVMValueRef NewVal);19851986/**1987* Determine whether the specified value instance is constant.1988*/1989LLVMBool LLVMIsConstant(LLVMValueRef Val);19901991/**1992* Determine whether a value instance is undefined.1993*/1994LLVMBool LLVMIsUndef(LLVMValueRef Val);19951996/**1997* Determine whether a value instance is poisonous.1998*/1999LLVMBool LLVMIsPoison(LLVMValueRef Val);20002001/**2002* Convert value instances between types.2003*2004* Internally, an LLVMValueRef is "pinned" to a specific type. This2005* series of functions allows you to cast an instance to a specific2006* type.2007*2008* If the cast is not valid for the specified type, NULL is returned.2009*2010* @see llvm::dyn_cast_or_null<>2011*/2012#define LLVM_DECLARE_VALUE_CAST(name) \2013LLVMValueRef LLVMIsA##name(LLVMValueRef Val);2014LLVM_FOR_EACH_VALUE_SUBCLASS(LLVM_DECLARE_VALUE_CAST)20152016LLVMValueRef LLVMIsAMDNode(LLVMValueRef Val);2017LLVMValueRef LLVMIsAValueAsMetadata(LLVMValueRef Val);2018LLVMValueRef LLVMIsAMDString(LLVMValueRef Val);20192020/** Deprecated: Use LLVMGetValueName2 instead. */2021const char *LLVMGetValueName(LLVMValueRef Val);2022/** Deprecated: Use LLVMSetValueName2 instead. */2023void LLVMSetValueName(LLVMValueRef Val, const char *Name);20242025/**2026* @}2027*/20282029/**2030* @defgroup LLVMCCoreValueUses Usage2031*2032* This module defines functions that allow you to inspect the uses of a2033* LLVMValueRef.2034*2035* It is possible to obtain an LLVMUseRef for any LLVMValueRef instance.2036* Each LLVMUseRef (which corresponds to a llvm::Use instance) holds a2037* llvm::User and llvm::Value.2038*2039* @{2040*/20412042/**2043* Obtain the first use of a value.2044*2045* Uses are obtained in an iterator fashion. First, call this function2046* to obtain a reference to the first use. Then, call LLVMGetNextUse()2047* on that instance and all subsequently obtained instances until2048* LLVMGetNextUse() returns NULL.2049*2050* @see llvm::Value::use_begin()2051*/2052LLVMUseRef LLVMGetFirstUse(LLVMValueRef Val);20532054/**2055* Obtain the next use of a value.2056*2057* This effectively advances the iterator. It returns NULL if you are on2058* the final use and no more are available.2059*/2060LLVMUseRef LLVMGetNextUse(LLVMUseRef U);20612062/**2063* Obtain the user value for a user.2064*2065* The returned value corresponds to a llvm::User type.2066*2067* @see llvm::Use::getUser()2068*/2069LLVMValueRef LLVMGetUser(LLVMUseRef U);20702071/**2072* Obtain the value this use corresponds to.2073*2074* @see llvm::Use::get().2075*/2076LLVMValueRef LLVMGetUsedValue(LLVMUseRef U);20772078/**2079* @}2080*/20812082/**2083* @defgroup LLVMCCoreValueUser User value2084*2085* Function in this group pertain to LLVMValueRef instances that descent2086* from llvm::User. This includes constants, instructions, and2087* operators.2088*2089* @{2090*/20912092/**2093* Obtain an operand at a specific index in a llvm::User value.2094*2095* @see llvm::User::getOperand()2096*/2097LLVMValueRef LLVMGetOperand(LLVMValueRef Val, unsigned Index);20982099/**2100* Obtain the use of an operand at a specific index in a llvm::User value.2101*2102* @see llvm::User::getOperandUse()2103*/2104LLVMUseRef LLVMGetOperandUse(LLVMValueRef Val, unsigned Index);21052106/**2107* Set an operand at a specific index in a llvm::User value.2108*2109* @see llvm::User::setOperand()2110*/2111void LLVMSetOperand(LLVMValueRef User, unsigned Index, LLVMValueRef Val);21122113/**2114* Obtain the number of operands in a llvm::User value.2115*2116* @see llvm::User::getNumOperands()2117*/2118int LLVMGetNumOperands(LLVMValueRef Val);21192120/**2121* @}2122*/21232124/**2125* @defgroup LLVMCCoreValueConstant Constants2126*2127* This section contains APIs for interacting with LLVMValueRef that2128* correspond to llvm::Constant instances.2129*2130* These functions will work for any LLVMValueRef in the llvm::Constant2131* class hierarchy.2132*2133* @{2134*/21352136/**2137* Obtain a constant value referring to the null instance of a type.2138*2139* @see llvm::Constant::getNullValue()2140*/2141LLVMValueRef LLVMConstNull(LLVMTypeRef Ty); /* all zeroes */21422143/**2144* Obtain a constant value referring to the instance of a type2145* consisting of all ones.2146*2147* This is only valid for integer types.2148*2149* @see llvm::Constant::getAllOnesValue()2150*/2151LLVMValueRef LLVMConstAllOnes(LLVMTypeRef Ty);21522153/**2154* Obtain a constant value referring to an undefined value of a type.2155*2156* @see llvm::UndefValue::get()2157*/2158LLVMValueRef LLVMGetUndef(LLVMTypeRef Ty);21592160/**2161* Obtain a constant value referring to a poison value of a type.2162*2163* @see llvm::PoisonValue::get()2164*/2165LLVMValueRef LLVMGetPoison(LLVMTypeRef Ty);21662167/**2168* Determine whether a value instance is null.2169*2170* @see llvm::Constant::isNullValue()2171*/2172LLVMBool LLVMIsNull(LLVMValueRef Val);21732174/**2175* Obtain a constant that is a constant pointer pointing to NULL for a2176* specified type.2177*/2178LLVMValueRef LLVMConstPointerNull(LLVMTypeRef Ty);21792180/**2181* @defgroup LLVMCCoreValueConstantScalar Scalar constants2182*2183* Functions in this group model LLVMValueRef instances that correspond2184* to constants referring to scalar types.2185*2186* For integer types, the LLVMTypeRef parameter should correspond to a2187* llvm::IntegerType instance and the returned LLVMValueRef will2188* correspond to a llvm::ConstantInt.2189*2190* For floating point types, the LLVMTypeRef returned corresponds to a2191* llvm::ConstantFP.2192*2193* @{2194*/21952196/**2197* Obtain a constant value for an integer type.2198*2199* The returned value corresponds to a llvm::ConstantInt.2200*2201* @see llvm::ConstantInt::get()2202*2203* @param IntTy Integer type to obtain value of.2204* @param N The value the returned instance should refer to.2205* @param SignExtend Whether to sign extend the produced value.2206*/2207LLVMValueRef LLVMConstInt(LLVMTypeRef IntTy, unsigned long long N,2208LLVMBool SignExtend);22092210/**2211* Obtain a constant value for an integer of arbitrary precision.2212*2213* @see llvm::ConstantInt::get()2214*/2215LLVMValueRef LLVMConstIntOfArbitraryPrecision(LLVMTypeRef IntTy,2216unsigned NumWords,2217const uint64_t Words[]);22182219/**2220* Obtain a constant value for an integer parsed from a string.2221*2222* A similar API, LLVMConstIntOfStringAndSize is also available. If the2223* string's length is available, it is preferred to call that function2224* instead.2225*2226* @see llvm::ConstantInt::get()2227*/2228LLVMValueRef LLVMConstIntOfString(LLVMTypeRef IntTy, const char *Text,2229uint8_t Radix);22302231/**2232* Obtain a constant value for an integer parsed from a string with2233* specified length.2234*2235* @see llvm::ConstantInt::get()2236*/2237LLVMValueRef LLVMConstIntOfStringAndSize(LLVMTypeRef IntTy, const char *Text,2238unsigned SLen, uint8_t Radix);22392240/**2241* Obtain a constant value referring to a double floating point value.2242*/2243LLVMValueRef LLVMConstReal(LLVMTypeRef RealTy, double N);22442245/**2246* Obtain a constant for a floating point value parsed from a string.2247*2248* A similar API, LLVMConstRealOfStringAndSize is also available. It2249* should be used if the input string's length is known.2250*/2251LLVMValueRef LLVMConstRealOfString(LLVMTypeRef RealTy, const char *Text);22522253/**2254* Obtain a constant for a floating point value parsed from a string.2255*/2256LLVMValueRef LLVMConstRealOfStringAndSize(LLVMTypeRef RealTy, const char *Text,2257unsigned SLen);22582259/**2260* Obtain the zero extended value for an integer constant value.2261*2262* @see llvm::ConstantInt::getZExtValue()2263*/2264unsigned long long LLVMConstIntGetZExtValue(LLVMValueRef ConstantVal);22652266/**2267* Obtain the sign extended value for an integer constant value.2268*2269* @see llvm::ConstantInt::getSExtValue()2270*/2271long long LLVMConstIntGetSExtValue(LLVMValueRef ConstantVal);22722273/**2274* Obtain the double value for an floating point constant value.2275* losesInfo indicates if some precision was lost in the conversion.2276*2277* @see llvm::ConstantFP::getDoubleValue2278*/2279double LLVMConstRealGetDouble(LLVMValueRef ConstantVal, LLVMBool *losesInfo);22802281/**2282* @}2283*/22842285/**2286* @defgroup LLVMCCoreValueConstantComposite Composite Constants2287*2288* Functions in this group operate on composite constants.2289*2290* @{2291*/22922293/**2294* Create a ConstantDataSequential and initialize it with a string.2295*2296* @deprecated LLVMConstStringInContext is deprecated in favor of the API2297* accurate LLVMConstStringInContext22298* @see llvm::ConstantDataArray::getString()2299*/2300LLVMValueRef LLVMConstStringInContext(LLVMContextRef C, const char *Str,2301unsigned Length, LLVMBool DontNullTerminate);23022303/**2304* Create a ConstantDataSequential and initialize it with a string.2305*2306* @see llvm::ConstantDataArray::getString()2307*/2308LLVMValueRef LLVMConstStringInContext2(LLVMContextRef C, const char *Str,2309size_t Length,2310LLVMBool DontNullTerminate);23112312/**2313* Create a ConstantDataSequential with string content in the global context.2314*2315* This is the same as LLVMConstStringInContext except it operates on the2316* global context.2317*2318* @see LLVMConstStringInContext()2319* @see llvm::ConstantDataArray::getString()2320*/2321LLVMValueRef LLVMConstString(const char *Str, unsigned Length,2322LLVMBool DontNullTerminate);23232324/**2325* Returns true if the specified constant is an array of i8.2326*2327* @see ConstantDataSequential::getAsString()2328*/2329LLVMBool LLVMIsConstantString(LLVMValueRef c);23302331/**2332* Get the given constant data sequential as a string.2333*2334* @see ConstantDataSequential::getAsString()2335*/2336const char *LLVMGetAsString(LLVMValueRef c, size_t *Length);23372338/**2339* Create an anonymous ConstantStruct with the specified values.2340*2341* @see llvm::ConstantStruct::getAnon()2342*/2343LLVMValueRef LLVMConstStructInContext(LLVMContextRef C,2344LLVMValueRef *ConstantVals,2345unsigned Count, LLVMBool Packed);23462347/**2348* Create a ConstantStruct in the global Context.2349*2350* This is the same as LLVMConstStructInContext except it operates on the2351* global Context.2352*2353* @see LLVMConstStructInContext()2354*/2355LLVMValueRef LLVMConstStruct(LLVMValueRef *ConstantVals, unsigned Count,2356LLVMBool Packed);23572358/**2359* Create a ConstantArray from values.2360*2361* @deprecated LLVMConstArray is deprecated in favor of the API accurate2362* LLVMConstArray22363* @see llvm::ConstantArray::get()2364*/2365LLVMValueRef LLVMConstArray(LLVMTypeRef ElementTy,2366LLVMValueRef *ConstantVals, unsigned Length);23672368/**2369* Create a ConstantArray from values.2370*2371* @see llvm::ConstantArray::get()2372*/2373LLVMValueRef LLVMConstArray2(LLVMTypeRef ElementTy, LLVMValueRef *ConstantVals,2374uint64_t Length);23752376/**2377* Create a non-anonymous ConstantStruct from values.2378*2379* @see llvm::ConstantStruct::get()2380*/2381LLVMValueRef LLVMConstNamedStruct(LLVMTypeRef StructTy,2382LLVMValueRef *ConstantVals,2383unsigned Count);23842385/**2386* Get element of a constant aggregate (struct, array or vector) at the2387* specified index. Returns null if the index is out of range, or it's not2388* possible to determine the element (e.g., because the constant is a2389* constant expression.)2390*2391* @see llvm::Constant::getAggregateElement()2392*/2393LLVMValueRef LLVMGetAggregateElement(LLVMValueRef C, unsigned Idx);23942395/**2396* Get an element at specified index as a constant.2397*2398* @see ConstantDataSequential::getElementAsConstant()2399*/2400LLVM_ATTRIBUTE_C_DEPRECATED(2401LLVMValueRef LLVMGetElementAsConstant(LLVMValueRef C, unsigned idx),2402"Use LLVMGetAggregateElement instead");24032404/**2405* Create a ConstantVector from values.2406*2407* @see llvm::ConstantVector::get()2408*/2409LLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals, unsigned Size);24102411/**2412* Create a ConstantPtrAuth constant with the given values.2413*2414* @see llvm::ConstantPtrAuth::get()2415*/2416LLVMValueRef LLVMConstantPtrAuth(LLVMValueRef Ptr, LLVMValueRef Key,2417LLVMValueRef Disc, LLVMValueRef AddrDisc);24182419/**2420* @}2421*/24222423/**2424* @defgroup LLVMCCoreValueConstantExpressions Constant Expressions2425*2426* Functions in this group correspond to APIs on llvm::ConstantExpr.2427*2428* @see llvm::ConstantExpr.2429*2430* @{2431*/2432LLVMOpcode LLVMGetConstOpcode(LLVMValueRef ConstantVal);2433LLVMValueRef LLVMAlignOf(LLVMTypeRef Ty);2434LLVMValueRef LLVMSizeOf(LLVMTypeRef Ty);2435LLVMValueRef LLVMConstNeg(LLVMValueRef ConstantVal);2436LLVMValueRef LLVMConstNSWNeg(LLVMValueRef ConstantVal);2437LLVM_ATTRIBUTE_C_DEPRECATED(2438LLVMValueRef LLVMConstNUWNeg(LLVMValueRef ConstantVal),2439"Use LLVMConstNull instead.");2440LLVMValueRef LLVMConstNot(LLVMValueRef ConstantVal);2441LLVMValueRef LLVMConstAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);2442LLVMValueRef LLVMConstNSWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);2443LLVMValueRef LLVMConstNUWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);2444LLVMValueRef LLVMConstSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);2445LLVMValueRef LLVMConstNSWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);2446LLVMValueRef LLVMConstNUWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);2447LLVMValueRef LLVMConstMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);2448LLVMValueRef LLVMConstNSWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);2449LLVMValueRef LLVMConstNUWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);2450LLVMValueRef LLVMConstXor(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);2451LLVMValueRef LLVMConstGEP2(LLVMTypeRef Ty, LLVMValueRef ConstantVal,2452LLVMValueRef *ConstantIndices, unsigned NumIndices);2453LLVMValueRef LLVMConstInBoundsGEP2(LLVMTypeRef Ty, LLVMValueRef ConstantVal,2454LLVMValueRef *ConstantIndices,2455unsigned NumIndices);2456/**2457* Creates a constant GetElementPtr expression. Similar to LLVMConstGEP2, but2458* allows specifying the no-wrap flags.2459*2460* @see llvm::ConstantExpr::getGetElementPtr()2461*/2462LLVMValueRef LLVMConstGEPWithNoWrapFlags(LLVMTypeRef Ty,2463LLVMValueRef ConstantVal,2464LLVMValueRef *ConstantIndices,2465unsigned NumIndices,2466LLVMGEPNoWrapFlags NoWrapFlags);2467LLVMValueRef LLVMConstTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType);2468LLVMValueRef LLVMConstPtrToInt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);2469LLVMValueRef LLVMConstIntToPtr(LLVMValueRef ConstantVal, LLVMTypeRef ToType);2470LLVMValueRef LLVMConstBitCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);2471LLVMValueRef LLVMConstAddrSpaceCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);2472LLVMValueRef LLVMConstTruncOrBitCast(LLVMValueRef ConstantVal,2473LLVMTypeRef ToType);2474LLVMValueRef LLVMConstPointerCast(LLVMValueRef ConstantVal,2475LLVMTypeRef ToType);2476LLVMValueRef LLVMConstExtractElement(LLVMValueRef VectorConstant,2477LLVMValueRef IndexConstant);2478LLVMValueRef LLVMConstInsertElement(LLVMValueRef VectorConstant,2479LLVMValueRef ElementValueConstant,2480LLVMValueRef IndexConstant);2481LLVMValueRef LLVMConstShuffleVector(LLVMValueRef VectorAConstant,2482LLVMValueRef VectorBConstant,2483LLVMValueRef MaskConstant);2484LLVMValueRef LLVMBlockAddress(LLVMValueRef F, LLVMBasicBlockRef BB);24852486/**2487* Gets the function associated with a given BlockAddress constant value.2488*/2489LLVMValueRef LLVMGetBlockAddressFunction(LLVMValueRef BlockAddr);24902491/**2492* Gets the basic block associated with a given BlockAddress constant value.2493*/2494LLVMBasicBlockRef LLVMGetBlockAddressBasicBlock(LLVMValueRef BlockAddr);24952496/** Deprecated: Use LLVMGetInlineAsm instead. */2497LLVMValueRef LLVMConstInlineAsm(LLVMTypeRef Ty,2498const char *AsmString, const char *Constraints,2499LLVMBool HasSideEffects, LLVMBool IsAlignStack);25002501/**2502* @}2503*/25042505/**2506* @defgroup LLVMCCoreValueConstantGlobals Global Values2507*2508* This group contains functions that operate on global values. Functions in2509* this group relate to functions in the llvm::GlobalValue class tree.2510*2511* @see llvm::GlobalValue2512*2513* @{2514*/25152516LLVMModuleRef LLVMGetGlobalParent(LLVMValueRef Global);2517LLVMBool LLVMIsDeclaration(LLVMValueRef Global);2518LLVMLinkage LLVMGetLinkage(LLVMValueRef Global);2519void LLVMSetLinkage(LLVMValueRef Global, LLVMLinkage Linkage);2520const char *LLVMGetSection(LLVMValueRef Global);2521void LLVMSetSection(LLVMValueRef Global, const char *Section);2522LLVMVisibility LLVMGetVisibility(LLVMValueRef Global);2523void LLVMSetVisibility(LLVMValueRef Global, LLVMVisibility Viz);2524LLVMDLLStorageClass LLVMGetDLLStorageClass(LLVMValueRef Global);2525void LLVMSetDLLStorageClass(LLVMValueRef Global, LLVMDLLStorageClass Class);2526LLVMUnnamedAddr LLVMGetUnnamedAddress(LLVMValueRef Global);2527void LLVMSetUnnamedAddress(LLVMValueRef Global, LLVMUnnamedAddr UnnamedAddr);25282529/**2530* Returns the "value type" of a global value. This differs from the formal2531* type of a global value which is always a pointer type.2532*2533* @see llvm::GlobalValue::getValueType()2534*/2535LLVMTypeRef LLVMGlobalGetValueType(LLVMValueRef Global);25362537/** Deprecated: Use LLVMGetUnnamedAddress instead. */2538LLVMBool LLVMHasUnnamedAddr(LLVMValueRef Global);2539/** Deprecated: Use LLVMSetUnnamedAddress instead. */2540void LLVMSetUnnamedAddr(LLVMValueRef Global, LLVMBool HasUnnamedAddr);25412542/**2543* @defgroup LLVMCCoreValueWithAlignment Values with alignment2544*2545* Functions in this group only apply to values with alignment, i.e.2546* global variables, load and store instructions.2547*/25482549/**2550* Obtain the preferred alignment of the value.2551* @see llvm::AllocaInst::getAlignment()2552* @see llvm::LoadInst::getAlignment()2553* @see llvm::StoreInst::getAlignment()2554* @see llvm::AtomicRMWInst::setAlignment()2555* @see llvm::AtomicCmpXchgInst::setAlignment()2556* @see llvm::GlobalValue::getAlignment()2557*/2558unsigned LLVMGetAlignment(LLVMValueRef V);25592560/**2561* Set the preferred alignment of the value.2562* @see llvm::AllocaInst::setAlignment()2563* @see llvm::LoadInst::setAlignment()2564* @see llvm::StoreInst::setAlignment()2565* @see llvm::AtomicRMWInst::setAlignment()2566* @see llvm::AtomicCmpXchgInst::setAlignment()2567* @see llvm::GlobalValue::setAlignment()2568*/2569void LLVMSetAlignment(LLVMValueRef V, unsigned Bytes);25702571/**2572* Sets a metadata attachment, erasing the existing metadata attachment if2573* it already exists for the given kind.2574*2575* @see llvm::GlobalObject::setMetadata()2576*/2577void LLVMGlobalSetMetadata(LLVMValueRef Global, unsigned Kind,2578LLVMMetadataRef MD);25792580/**2581* Erases a metadata attachment of the given kind if it exists.2582*2583* @see llvm::GlobalObject::eraseMetadata()2584*/2585void LLVMGlobalEraseMetadata(LLVMValueRef Global, unsigned Kind);25862587/**2588* Removes all metadata attachments from this value.2589*2590* @see llvm::GlobalObject::clearMetadata()2591*/2592void LLVMGlobalClearMetadata(LLVMValueRef Global);25932594/**2595* Retrieves an array of metadata entries representing the metadata attached to2596* this value. The caller is responsible for freeing this array by calling2597* \c LLVMDisposeValueMetadataEntries.2598*2599* @see llvm::GlobalObject::getAllMetadata()2600*/2601LLVMValueMetadataEntry *LLVMGlobalCopyAllMetadata(LLVMValueRef Value,2602size_t *NumEntries);26032604/**2605* Destroys value metadata entries.2606*/2607void LLVMDisposeValueMetadataEntries(LLVMValueMetadataEntry *Entries);26082609/**2610* Returns the kind of a value metadata entry at a specific index.2611*/2612unsigned LLVMValueMetadataEntriesGetKind(LLVMValueMetadataEntry *Entries,2613unsigned Index);26142615/**2616* Returns the underlying metadata node of a value metadata entry at a2617* specific index.2618*/2619LLVMMetadataRef2620LLVMValueMetadataEntriesGetMetadata(LLVMValueMetadataEntry *Entries,2621unsigned Index);26222623/**2624* @}2625*/26262627/**2628* @defgroup LLVMCoreValueConstantGlobalVariable Global Variables2629*2630* This group contains functions that operate on global variable values.2631*2632* @see llvm::GlobalVariable2633*2634* @{2635*/2636LLVMValueRef LLVMAddGlobal(LLVMModuleRef M, LLVMTypeRef Ty, const char *Name);2637LLVMValueRef LLVMAddGlobalInAddressSpace(LLVMModuleRef M, LLVMTypeRef Ty,2638const char *Name,2639unsigned AddressSpace);2640LLVMValueRef LLVMGetNamedGlobal(LLVMModuleRef M, const char *Name);2641LLVMValueRef LLVMGetFirstGlobal(LLVMModuleRef M);2642LLVMValueRef LLVMGetLastGlobal(LLVMModuleRef M);2643LLVMValueRef LLVMGetNextGlobal(LLVMValueRef GlobalVar);2644LLVMValueRef LLVMGetPreviousGlobal(LLVMValueRef GlobalVar);2645void LLVMDeleteGlobal(LLVMValueRef GlobalVar);2646LLVMValueRef LLVMGetInitializer(LLVMValueRef GlobalVar);2647void LLVMSetInitializer(LLVMValueRef GlobalVar, LLVMValueRef ConstantVal);2648LLVMBool LLVMIsThreadLocal(LLVMValueRef GlobalVar);2649void LLVMSetThreadLocal(LLVMValueRef GlobalVar, LLVMBool IsThreadLocal);2650LLVMBool LLVMIsGlobalConstant(LLVMValueRef GlobalVar);2651void LLVMSetGlobalConstant(LLVMValueRef GlobalVar, LLVMBool IsConstant);2652LLVMThreadLocalMode LLVMGetThreadLocalMode(LLVMValueRef GlobalVar);2653void LLVMSetThreadLocalMode(LLVMValueRef GlobalVar, LLVMThreadLocalMode Mode);2654LLVMBool LLVMIsExternallyInitialized(LLVMValueRef GlobalVar);2655void LLVMSetExternallyInitialized(LLVMValueRef GlobalVar, LLVMBool IsExtInit);26562657/**2658* @}2659*/26602661/**2662* @defgroup LLVMCoreValueConstantGlobalAlias Global Aliases2663*2664* This group contains function that operate on global alias values.2665*2666* @see llvm::GlobalAlias2667*2668* @{2669*/26702671/**2672* Add a GlobalAlias with the given value type, address space and aliasee.2673*2674* @see llvm::GlobalAlias::create()2675*/2676LLVMValueRef LLVMAddAlias2(LLVMModuleRef M, LLVMTypeRef ValueTy,2677unsigned AddrSpace, LLVMValueRef Aliasee,2678const char *Name);26792680/**2681* Obtain a GlobalAlias value from a Module by its name.2682*2683* The returned value corresponds to a llvm::GlobalAlias value.2684*2685* @see llvm::Module::getNamedAlias()2686*/2687LLVMValueRef LLVMGetNamedGlobalAlias(LLVMModuleRef M,2688const char *Name, size_t NameLen);26892690/**2691* Obtain an iterator to the first GlobalAlias in a Module.2692*2693* @see llvm::Module::alias_begin()2694*/2695LLVMValueRef LLVMGetFirstGlobalAlias(LLVMModuleRef M);26962697/**2698* Obtain an iterator to the last GlobalAlias in a Module.2699*2700* @see llvm::Module::alias_end()2701*/2702LLVMValueRef LLVMGetLastGlobalAlias(LLVMModuleRef M);27032704/**2705* Advance a GlobalAlias iterator to the next GlobalAlias.2706*2707* Returns NULL if the iterator was already at the end and there are no more2708* global aliases.2709*/2710LLVMValueRef LLVMGetNextGlobalAlias(LLVMValueRef GA);27112712/**2713* Decrement a GlobalAlias iterator to the previous GlobalAlias.2714*2715* Returns NULL if the iterator was already at the beginning and there are2716* no previous global aliases.2717*/2718LLVMValueRef LLVMGetPreviousGlobalAlias(LLVMValueRef GA);27192720/**2721* Retrieve the target value of an alias.2722*/2723LLVMValueRef LLVMAliasGetAliasee(LLVMValueRef Alias);27242725/**2726* Set the target value of an alias.2727*/2728void LLVMAliasSetAliasee(LLVMValueRef Alias, LLVMValueRef Aliasee);27292730/**2731* @}2732*/27332734/**2735* @defgroup LLVMCCoreValueFunction Function values2736*2737* Functions in this group operate on LLVMValueRef instances that2738* correspond to llvm::Function instances.2739*2740* @see llvm::Function2741*2742* @{2743*/27442745/**2746* Remove a function from its containing module and deletes it.2747*2748* @see llvm::Function::eraseFromParent()2749*/2750void LLVMDeleteFunction(LLVMValueRef Fn);27512752/**2753* Check whether the given function has a personality function.2754*2755* @see llvm::Function::hasPersonalityFn()2756*/2757LLVMBool LLVMHasPersonalityFn(LLVMValueRef Fn);27582759/**2760* Obtain the personality function attached to the function.2761*2762* @see llvm::Function::getPersonalityFn()2763*/2764LLVMValueRef LLVMGetPersonalityFn(LLVMValueRef Fn);27652766/**2767* Set the personality function attached to the function.2768*2769* @see llvm::Function::setPersonalityFn()2770*/2771void LLVMSetPersonalityFn(LLVMValueRef Fn, LLVMValueRef PersonalityFn);27722773/**2774* Obtain the intrinsic ID number which matches the given function name.2775*2776* @see llvm::Function::lookupIntrinsicID()2777*/2778unsigned LLVMLookupIntrinsicID(const char *Name, size_t NameLen);27792780/**2781* Obtain the ID number from a function instance.2782*2783* @see llvm::Function::getIntrinsicID()2784*/2785unsigned LLVMGetIntrinsicID(LLVMValueRef Fn);27862787/**2788* Create or insert the declaration of an intrinsic. For overloaded intrinsics,2789* parameter types must be provided to uniquely identify an overload.2790*2791* @see llvm::Intrinsic::getDeclaration()2792*/2793LLVMValueRef LLVMGetIntrinsicDeclaration(LLVMModuleRef Mod,2794unsigned ID,2795LLVMTypeRef *ParamTypes,2796size_t ParamCount);27972798/**2799* Retrieves the type of an intrinsic. For overloaded intrinsics, parameter2800* types must be provided to uniquely identify an overload.2801*2802* @see llvm::Intrinsic::getType()2803*/2804LLVMTypeRef LLVMIntrinsicGetType(LLVMContextRef Ctx, unsigned ID,2805LLVMTypeRef *ParamTypes, size_t ParamCount);28062807/**2808* Retrieves the name of an intrinsic.2809*2810* @see llvm::Intrinsic::getName()2811*/2812const char *LLVMIntrinsicGetName(unsigned ID, size_t *NameLength);28132814/** Deprecated: Use LLVMIntrinsicCopyOverloadedName2 instead. */2815const char *LLVMIntrinsicCopyOverloadedName(unsigned ID,2816LLVMTypeRef *ParamTypes,2817size_t ParamCount,2818size_t *NameLength);28192820/**2821* Copies the name of an overloaded intrinsic identified by a given list of2822* parameter types.2823*2824* Unlike LLVMIntrinsicGetName, the caller is responsible for freeing the2825* returned string.2826*2827* This version also supports unnamed types.2828*2829* @see llvm::Intrinsic::getName()2830*/2831const char *LLVMIntrinsicCopyOverloadedName2(LLVMModuleRef Mod, unsigned ID,2832LLVMTypeRef *ParamTypes,2833size_t ParamCount,2834size_t *NameLength);28352836/**2837* Obtain if the intrinsic identified by the given ID is overloaded.2838*2839* @see llvm::Intrinsic::isOverloaded()2840*/2841LLVMBool LLVMIntrinsicIsOverloaded(unsigned ID);28422843/**2844* Obtain the calling function of a function.2845*2846* The returned value corresponds to the LLVMCallConv enumeration.2847*2848* @see llvm::Function::getCallingConv()2849*/2850unsigned LLVMGetFunctionCallConv(LLVMValueRef Fn);28512852/**2853* Set the calling convention of a function.2854*2855* @see llvm::Function::setCallingConv()2856*2857* @param Fn Function to operate on2858* @param CC LLVMCallConv to set calling convention to2859*/2860void LLVMSetFunctionCallConv(LLVMValueRef Fn, unsigned CC);28612862/**2863* Obtain the name of the garbage collector to use during code2864* generation.2865*2866* @see llvm::Function::getGC()2867*/2868const char *LLVMGetGC(LLVMValueRef Fn);28692870/**2871* Define the garbage collector to use during code generation.2872*2873* @see llvm::Function::setGC()2874*/2875void LLVMSetGC(LLVMValueRef Fn, const char *Name);28762877/**2878* Gets the prefix data associated with a function. Only valid on functions, and2879* only if LLVMHasPrefixData returns true.2880* See https://llvm.org/docs/LangRef.html#prefix-data2881*/2882LLVMValueRef LLVMGetPrefixData(LLVMValueRef Fn);28832884/**2885* Check if a given function has prefix data. Only valid on functions.2886* See https://llvm.org/docs/LangRef.html#prefix-data2887*/2888LLVMBool LLVMHasPrefixData(LLVMValueRef Fn);28892890/**2891* Sets the prefix data for the function. Only valid on functions.2892* See https://llvm.org/docs/LangRef.html#prefix-data2893*/2894void LLVMSetPrefixData(LLVMValueRef Fn, LLVMValueRef prefixData);28952896/**2897* Gets the prologue data associated with a function. Only valid on functions,2898* and only if LLVMHasPrologueData returns true.2899* See https://llvm.org/docs/LangRef.html#prologue-data2900*/2901LLVMValueRef LLVMGetPrologueData(LLVMValueRef Fn);29022903/**2904* Check if a given function has prologue data. Only valid on functions.2905* See https://llvm.org/docs/LangRef.html#prologue-data2906*/2907LLVMBool LLVMHasPrologueData(LLVMValueRef Fn);29082909/**2910* Sets the prologue data for the function. Only valid on functions.2911* See https://llvm.org/docs/LangRef.html#prologue-data2912*/2913void LLVMSetPrologueData(LLVMValueRef Fn, LLVMValueRef prologueData);29142915/**2916* Add an attribute to a function.2917*2918* @see llvm::Function::addAttribute()2919*/2920void LLVMAddAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx,2921LLVMAttributeRef A);2922unsigned LLVMGetAttributeCountAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx);2923void LLVMGetAttributesAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx,2924LLVMAttributeRef *Attrs);2925LLVMAttributeRef LLVMGetEnumAttributeAtIndex(LLVMValueRef F,2926LLVMAttributeIndex Idx,2927unsigned KindID);2928LLVMAttributeRef LLVMGetStringAttributeAtIndex(LLVMValueRef F,2929LLVMAttributeIndex Idx,2930const char *K, unsigned KLen);2931void LLVMRemoveEnumAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx,2932unsigned KindID);2933void LLVMRemoveStringAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx,2934const char *K, unsigned KLen);29352936/**2937* Add a target-dependent attribute to a function2938* @see llvm::AttrBuilder::addAttribute()2939*/2940void LLVMAddTargetDependentFunctionAttr(LLVMValueRef Fn, const char *A,2941const char *V);29422943/**2944* @defgroup LLVMCCoreValueFunctionParameters Function Parameters2945*2946* Functions in this group relate to arguments/parameters on functions.2947*2948* Functions in this group expect LLVMValueRef instances that correspond2949* to llvm::Function instances.2950*2951* @{2952*/29532954/**2955* Obtain the number of parameters in a function.2956*2957* @see llvm::Function::arg_size()2958*/2959unsigned LLVMCountParams(LLVMValueRef Fn);29602961/**2962* Obtain the parameters in a function.2963*2964* The takes a pointer to a pre-allocated array of LLVMValueRef that is2965* at least LLVMCountParams() long. This array will be filled with2966* LLVMValueRef instances which correspond to the parameters the2967* function receives. Each LLVMValueRef corresponds to a llvm::Argument2968* instance.2969*2970* @see llvm::Function::arg_begin()2971*/2972void LLVMGetParams(LLVMValueRef Fn, LLVMValueRef *Params);29732974/**2975* Obtain the parameter at the specified index.2976*2977* Parameters are indexed from 0.2978*2979* @see llvm::Function::arg_begin()2980*/2981LLVMValueRef LLVMGetParam(LLVMValueRef Fn, unsigned Index);29822983/**2984* Obtain the function to which this argument belongs.2985*2986* Unlike other functions in this group, this one takes an LLVMValueRef2987* that corresponds to a llvm::Attribute.2988*2989* The returned LLVMValueRef is the llvm::Function to which this2990* argument belongs.2991*/2992LLVMValueRef LLVMGetParamParent(LLVMValueRef Inst);29932994/**2995* Obtain the first parameter to a function.2996*2997* @see llvm::Function::arg_begin()2998*/2999LLVMValueRef LLVMGetFirstParam(LLVMValueRef Fn);30003001/**3002* Obtain the last parameter to a function.3003*3004* @see llvm::Function::arg_end()3005*/3006LLVMValueRef LLVMGetLastParam(LLVMValueRef Fn);30073008/**3009* Obtain the next parameter to a function.3010*3011* This takes an LLVMValueRef obtained from LLVMGetFirstParam() (which is3012* actually a wrapped iterator) and obtains the next parameter from the3013* underlying iterator.3014*/3015LLVMValueRef LLVMGetNextParam(LLVMValueRef Arg);30163017/**3018* Obtain the previous parameter to a function.3019*3020* This is the opposite of LLVMGetNextParam().3021*/3022LLVMValueRef LLVMGetPreviousParam(LLVMValueRef Arg);30233024/**3025* Set the alignment for a function parameter.3026*3027* @see llvm::Argument::addAttr()3028* @see llvm::AttrBuilder::addAlignmentAttr()3029*/3030void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned Align);30313032/**3033* @}3034*/30353036/**3037* @defgroup LLVMCCoreValueGlobalIFunc IFuncs3038*3039* Functions in this group relate to indirect functions.3040*3041* Functions in this group expect LLVMValueRef instances that correspond3042* to llvm::GlobalIFunc instances.3043*3044* @{3045*/30463047/**3048* Add a global indirect function to a module under a specified name.3049*3050* @see llvm::GlobalIFunc::create()3051*/3052LLVMValueRef LLVMAddGlobalIFunc(LLVMModuleRef M,3053const char *Name, size_t NameLen,3054LLVMTypeRef Ty, unsigned AddrSpace,3055LLVMValueRef Resolver);30563057/**3058* Obtain a GlobalIFunc value from a Module by its name.3059*3060* The returned value corresponds to a llvm::GlobalIFunc value.3061*3062* @see llvm::Module::getNamedIFunc()3063*/3064LLVMValueRef LLVMGetNamedGlobalIFunc(LLVMModuleRef M,3065const char *Name, size_t NameLen);30663067/**3068* Obtain an iterator to the first GlobalIFunc in a Module.3069*3070* @see llvm::Module::ifunc_begin()3071*/3072LLVMValueRef LLVMGetFirstGlobalIFunc(LLVMModuleRef M);30733074/**3075* Obtain an iterator to the last GlobalIFunc in a Module.3076*3077* @see llvm::Module::ifunc_end()3078*/3079LLVMValueRef LLVMGetLastGlobalIFunc(LLVMModuleRef M);30803081/**3082* Advance a GlobalIFunc iterator to the next GlobalIFunc.3083*3084* Returns NULL if the iterator was already at the end and there are no more3085* global aliases.3086*/3087LLVMValueRef LLVMGetNextGlobalIFunc(LLVMValueRef IFunc);30883089/**3090* Decrement a GlobalIFunc iterator to the previous GlobalIFunc.3091*3092* Returns NULL if the iterator was already at the beginning and there are3093* no previous global aliases.3094*/3095LLVMValueRef LLVMGetPreviousGlobalIFunc(LLVMValueRef IFunc);30963097/**3098* Retrieves the resolver function associated with this indirect function, or3099* NULL if it doesn't not exist.3100*3101* @see llvm::GlobalIFunc::getResolver()3102*/3103LLVMValueRef LLVMGetGlobalIFuncResolver(LLVMValueRef IFunc);31043105/**3106* Sets the resolver function associated with this indirect function.3107*3108* @see llvm::GlobalIFunc::setResolver()3109*/3110void LLVMSetGlobalIFuncResolver(LLVMValueRef IFunc, LLVMValueRef Resolver);31113112/**3113* Remove a global indirect function from its parent module and delete it.3114*3115* @see llvm::GlobalIFunc::eraseFromParent()3116*/3117void LLVMEraseGlobalIFunc(LLVMValueRef IFunc);31183119/**3120* Remove a global indirect function from its parent module.3121*3122* This unlinks the global indirect function from its containing module but3123* keeps it alive.3124*3125* @see llvm::GlobalIFunc::removeFromParent()3126*/3127void LLVMRemoveGlobalIFunc(LLVMValueRef IFunc);31283129/**3130* @}3131*/31323133/**3134* @}3135*/31363137/**3138* @}3139*/31403141/**3142* @}3143*/31443145/**3146* @defgroup LLVMCCoreValueMetadata Metadata3147*3148* @{3149*/31503151/**3152* Create an MDString value from a given string value.3153*3154* The MDString value does not take ownership of the given string, it remains3155* the responsibility of the caller to free it.3156*3157* @see llvm::MDString::get()3158*/3159LLVMMetadataRef LLVMMDStringInContext2(LLVMContextRef C, const char *Str,3160size_t SLen);31613162/**3163* Create an MDNode value with the given array of operands.3164*3165* @see llvm::MDNode::get()3166*/3167LLVMMetadataRef LLVMMDNodeInContext2(LLVMContextRef C, LLVMMetadataRef *MDs,3168size_t Count);31693170/**3171* Obtain a Metadata as a Value.3172*/3173LLVMValueRef LLVMMetadataAsValue(LLVMContextRef C, LLVMMetadataRef MD);31743175/**3176* Obtain a Value as a Metadata.3177*/3178LLVMMetadataRef LLVMValueAsMetadata(LLVMValueRef Val);31793180/**3181* Obtain the underlying string from a MDString value.3182*3183* @param V Instance to obtain string from.3184* @param Length Memory address which will hold length of returned string.3185* @return String data in MDString.3186*/3187const char *LLVMGetMDString(LLVMValueRef V, unsigned *Length);31883189/**3190* Obtain the number of operands from an MDNode value.3191*3192* @param V MDNode to get number of operands from.3193* @return Number of operands of the MDNode.3194*/3195unsigned LLVMGetMDNodeNumOperands(LLVMValueRef V);31963197/**3198* Obtain the given MDNode's operands.3199*3200* The passed LLVMValueRef pointer should point to enough memory to hold all of3201* the operands of the given MDNode (see LLVMGetMDNodeNumOperands) as3202* LLVMValueRefs. This memory will be populated with the LLVMValueRefs of the3203* MDNode's operands.3204*3205* @param V MDNode to get the operands from.3206* @param Dest Destination array for operands.3207*/3208void LLVMGetMDNodeOperands(LLVMValueRef V, LLVMValueRef *Dest);32093210/**3211* Replace an operand at a specific index in a llvm::MDNode value.3212*3213* @see llvm::MDNode::replaceOperandWith()3214*/3215void LLVMReplaceMDNodeOperandWith(LLVMValueRef V, unsigned Index,3216LLVMMetadataRef Replacement);32173218/** Deprecated: Use LLVMMDStringInContext2 instead. */3219LLVMValueRef LLVMMDStringInContext(LLVMContextRef C, const char *Str,3220unsigned SLen);3221/** Deprecated: Use LLVMMDStringInContext2 instead. */3222LLVMValueRef LLVMMDString(const char *Str, unsigned SLen);3223/** Deprecated: Use LLVMMDNodeInContext2 instead. */3224LLVMValueRef LLVMMDNodeInContext(LLVMContextRef C, LLVMValueRef *Vals,3225unsigned Count);3226/** Deprecated: Use LLVMMDNodeInContext2 instead. */3227LLVMValueRef LLVMMDNode(LLVMValueRef *Vals, unsigned Count);32283229/**3230* @}3231*/32323233/**3234* @defgroup LLVMCCoreOperandBundle Operand Bundles3235*3236* Functions in this group operate on LLVMOperandBundleRef instances that3237* correspond to llvm::OperandBundleDef instances.3238*3239* @see llvm::OperandBundleDef3240*3241* @{3242*/32433244/**3245* Create a new operand bundle.3246*3247* Every invocation should be paired with LLVMDisposeOperandBundle() or memory3248* will be leaked.3249*3250* @param Tag Tag name of the operand bundle3251* @param TagLen Length of Tag3252* @param Args Memory address of an array of bundle operands3253* @param NumArgs Length of Args3254*/3255LLVMOperandBundleRef LLVMCreateOperandBundle(const char *Tag, size_t TagLen,3256LLVMValueRef *Args,3257unsigned NumArgs);32583259/**3260* Destroy an operand bundle.3261*3262* This must be called for every created operand bundle or memory will be3263* leaked.3264*/3265void LLVMDisposeOperandBundle(LLVMOperandBundleRef Bundle);32663267/**3268* Obtain the tag of an operand bundle as a string.3269*3270* @param Bundle Operand bundle to obtain tag of.3271* @param Len Out parameter which holds the length of the returned string.3272* @return The tag name of Bundle.3273* @see OperandBundleDef::getTag()3274*/3275const char *LLVMGetOperandBundleTag(LLVMOperandBundleRef Bundle, size_t *Len);32763277/**3278* Obtain the number of operands for an operand bundle.3279*3280* @param Bundle Operand bundle to obtain operand count of.3281* @return The number of operands.3282* @see OperandBundleDef::input_size()3283*/3284unsigned LLVMGetNumOperandBundleArgs(LLVMOperandBundleRef Bundle);32853286/**3287* Obtain the operand for an operand bundle at the given index.3288*3289* @param Bundle Operand bundle to obtain operand of.3290* @param Index An operand index, must be less than3291* LLVMGetNumOperandBundleArgs().3292* @return The operand.3293*/3294LLVMValueRef LLVMGetOperandBundleArgAtIndex(LLVMOperandBundleRef Bundle,3295unsigned Index);32963297/**3298* @}3299*/33003301/**3302* @defgroup LLVMCCoreValueBasicBlock Basic Block3303*3304* A basic block represents a single entry single exit section of code.3305* Basic blocks contain a list of instructions which form the body of3306* the block.3307*3308* Basic blocks belong to functions. They have the type of label.3309*3310* Basic blocks are themselves values. However, the C API models them as3311* LLVMBasicBlockRef.3312*3313* @see llvm::BasicBlock3314*3315* @{3316*/33173318/**3319* Convert a basic block instance to a value type.3320*/3321LLVMValueRef LLVMBasicBlockAsValue(LLVMBasicBlockRef BB);33223323/**3324* Determine whether an LLVMValueRef is itself a basic block.3325*/3326LLVMBool LLVMValueIsBasicBlock(LLVMValueRef Val);33273328/**3329* Convert an LLVMValueRef to an LLVMBasicBlockRef instance.3330*/3331LLVMBasicBlockRef LLVMValueAsBasicBlock(LLVMValueRef Val);33323333/**3334* Obtain the string name of a basic block.3335*/3336const char *LLVMGetBasicBlockName(LLVMBasicBlockRef BB);33373338/**3339* Obtain the function to which a basic block belongs.3340*3341* @see llvm::BasicBlock::getParent()3342*/3343LLVMValueRef LLVMGetBasicBlockParent(LLVMBasicBlockRef BB);33443345/**3346* Obtain the terminator instruction for a basic block.3347*3348* If the basic block does not have a terminator (it is not well-formed3349* if it doesn't), then NULL is returned.3350*3351* The returned LLVMValueRef corresponds to an llvm::Instruction.3352*3353* @see llvm::BasicBlock::getTerminator()3354*/3355LLVMValueRef LLVMGetBasicBlockTerminator(LLVMBasicBlockRef BB);33563357/**3358* Obtain the number of basic blocks in a function.3359*3360* @param Fn Function value to operate on.3361*/3362unsigned LLVMCountBasicBlocks(LLVMValueRef Fn);33633364/**3365* Obtain all of the basic blocks in a function.3366*3367* This operates on a function value. The BasicBlocks parameter is a3368* pointer to a pre-allocated array of LLVMBasicBlockRef of at least3369* LLVMCountBasicBlocks() in length. This array is populated with3370* LLVMBasicBlockRef instances.3371*/3372void LLVMGetBasicBlocks(LLVMValueRef Fn, LLVMBasicBlockRef *BasicBlocks);33733374/**3375* Obtain the first basic block in a function.3376*3377* The returned basic block can be used as an iterator. You will likely3378* eventually call into LLVMGetNextBasicBlock() with it.3379*3380* @see llvm::Function::begin()3381*/3382LLVMBasicBlockRef LLVMGetFirstBasicBlock(LLVMValueRef Fn);33833384/**3385* Obtain the last basic block in a function.3386*3387* @see llvm::Function::end()3388*/3389LLVMBasicBlockRef LLVMGetLastBasicBlock(LLVMValueRef Fn);33903391/**3392* Advance a basic block iterator.3393*/3394LLVMBasicBlockRef LLVMGetNextBasicBlock(LLVMBasicBlockRef BB);33953396/**3397* Go backwards in a basic block iterator.3398*/3399LLVMBasicBlockRef LLVMGetPreviousBasicBlock(LLVMBasicBlockRef BB);34003401/**3402* Obtain the basic block that corresponds to the entry point of a3403* function.3404*3405* @see llvm::Function::getEntryBlock()3406*/3407LLVMBasicBlockRef LLVMGetEntryBasicBlock(LLVMValueRef Fn);34083409/**3410* Insert the given basic block after the insertion point of the given builder.3411*3412* The insertion point must be valid.3413*3414* @see llvm::Function::BasicBlockListType::insertAfter()3415*/3416void LLVMInsertExistingBasicBlockAfterInsertBlock(LLVMBuilderRef Builder,3417LLVMBasicBlockRef BB);34183419/**3420* Append the given basic block to the basic block list of the given function.3421*3422* @see llvm::Function::BasicBlockListType::push_back()3423*/3424void LLVMAppendExistingBasicBlock(LLVMValueRef Fn,3425LLVMBasicBlockRef BB);34263427/**3428* Create a new basic block without inserting it into a function.3429*3430* @see llvm::BasicBlock::Create()3431*/3432LLVMBasicBlockRef LLVMCreateBasicBlockInContext(LLVMContextRef C,3433const char *Name);34343435/**3436* Append a basic block to the end of a function.3437*3438* @see llvm::BasicBlock::Create()3439*/3440LLVMBasicBlockRef LLVMAppendBasicBlockInContext(LLVMContextRef C,3441LLVMValueRef Fn,3442const char *Name);34433444/**3445* Append a basic block to the end of a function using the global3446* context.3447*3448* @see llvm::BasicBlock::Create()3449*/3450LLVMBasicBlockRef LLVMAppendBasicBlock(LLVMValueRef Fn, const char *Name);34513452/**3453* Insert a basic block in a function before another basic block.3454*3455* The function to add to is determined by the function of the3456* passed basic block.3457*3458* @see llvm::BasicBlock::Create()3459*/3460LLVMBasicBlockRef LLVMInsertBasicBlockInContext(LLVMContextRef C,3461LLVMBasicBlockRef BB,3462const char *Name);34633464/**3465* Insert a basic block in a function using the global context.3466*3467* @see llvm::BasicBlock::Create()3468*/3469LLVMBasicBlockRef LLVMInsertBasicBlock(LLVMBasicBlockRef InsertBeforeBB,3470const char *Name);34713472/**3473* Remove a basic block from a function and delete it.3474*3475* This deletes the basic block from its containing function and deletes3476* the basic block itself.3477*3478* @see llvm::BasicBlock::eraseFromParent()3479*/3480void LLVMDeleteBasicBlock(LLVMBasicBlockRef BB);34813482/**3483* Remove a basic block from a function.3484*3485* This deletes the basic block from its containing function but keep3486* the basic block alive.3487*3488* @see llvm::BasicBlock::removeFromParent()3489*/3490void LLVMRemoveBasicBlockFromParent(LLVMBasicBlockRef BB);34913492/**3493* Move a basic block to before another one.3494*3495* @see llvm::BasicBlock::moveBefore()3496*/3497void LLVMMoveBasicBlockBefore(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos);34983499/**3500* Move a basic block to after another one.3501*3502* @see llvm::BasicBlock::moveAfter()3503*/3504void LLVMMoveBasicBlockAfter(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos);35053506/**3507* Obtain the first instruction in a basic block.3508*3509* The returned LLVMValueRef corresponds to a llvm::Instruction3510* instance.3511*/3512LLVMValueRef LLVMGetFirstInstruction(LLVMBasicBlockRef BB);35133514/**3515* Obtain the last instruction in a basic block.3516*3517* The returned LLVMValueRef corresponds to an LLVM:Instruction.3518*/3519LLVMValueRef LLVMGetLastInstruction(LLVMBasicBlockRef BB);35203521/**3522* @}3523*/35243525/**3526* @defgroup LLVMCCoreValueInstruction Instructions3527*3528* Functions in this group relate to the inspection and manipulation of3529* individual instructions.3530*3531* In the C++ API, an instruction is modeled by llvm::Instruction. This3532* class has a large number of descendents. llvm::Instruction is a3533* llvm::Value and in the C API, instructions are modeled by3534* LLVMValueRef.3535*3536* This group also contains sub-groups which operate on specific3537* llvm::Instruction types, e.g. llvm::CallInst.3538*3539* @{3540*/35413542/**3543* Determine whether an instruction has any metadata attached.3544*/3545int LLVMHasMetadata(LLVMValueRef Val);35463547/**3548* Return metadata associated with an instruction value.3549*/3550LLVMValueRef LLVMGetMetadata(LLVMValueRef Val, unsigned KindID);35513552/**3553* Set metadata associated with an instruction value.3554*/3555void LLVMSetMetadata(LLVMValueRef Val, unsigned KindID, LLVMValueRef Node);35563557/**3558* Returns the metadata associated with an instruction value, but filters out3559* all the debug locations.3560*3561* @see llvm::Instruction::getAllMetadataOtherThanDebugLoc()3562*/3563LLVMValueMetadataEntry *3564LLVMInstructionGetAllMetadataOtherThanDebugLoc(LLVMValueRef Instr,3565size_t *NumEntries);35663567/**3568* Obtain the basic block to which an instruction belongs.3569*3570* @see llvm::Instruction::getParent()3571*/3572LLVMBasicBlockRef LLVMGetInstructionParent(LLVMValueRef Inst);35733574/**3575* Obtain the instruction that occurs after the one specified.3576*3577* The next instruction will be from the same basic block.3578*3579* If this is the last instruction in a basic block, NULL will be3580* returned.3581*/3582LLVMValueRef LLVMGetNextInstruction(LLVMValueRef Inst);35833584/**3585* Obtain the instruction that occurred before this one.3586*3587* If the instruction is the first instruction in a basic block, NULL3588* will be returned.3589*/3590LLVMValueRef LLVMGetPreviousInstruction(LLVMValueRef Inst);35913592/**3593* Remove an instruction.3594*3595* The instruction specified is removed from its containing building3596* block but is kept alive.3597*3598* @see llvm::Instruction::removeFromParent()3599*/3600void LLVMInstructionRemoveFromParent(LLVMValueRef Inst);36013602/**3603* Remove and delete an instruction.3604*3605* The instruction specified is removed from its containing building3606* block and then deleted.3607*3608* @see llvm::Instruction::eraseFromParent()3609*/3610void LLVMInstructionEraseFromParent(LLVMValueRef Inst);36113612/**3613* Delete an instruction.3614*3615* The instruction specified is deleted. It must have previously been3616* removed from its containing building block.3617*3618* @see llvm::Value::deleteValue()3619*/3620void LLVMDeleteInstruction(LLVMValueRef Inst);36213622/**3623* Obtain the code opcode for an individual instruction.3624*3625* @see llvm::Instruction::getOpCode()3626*/3627LLVMOpcode LLVMGetInstructionOpcode(LLVMValueRef Inst);36283629/**3630* Obtain the predicate of an instruction.3631*3632* This is only valid for instructions that correspond to llvm::ICmpInst.3633*3634* @see llvm::ICmpInst::getPredicate()3635*/3636LLVMIntPredicate LLVMGetICmpPredicate(LLVMValueRef Inst);36373638/**3639* Obtain the float predicate of an instruction.3640*3641* This is only valid for instructions that correspond to llvm::FCmpInst.3642*3643* @see llvm::FCmpInst::getPredicate()3644*/3645LLVMRealPredicate LLVMGetFCmpPredicate(LLVMValueRef Inst);36463647/**3648* Create a copy of 'this' instruction that is identical in all ways3649* except the following:3650* * The instruction has no parent3651* * The instruction has no name3652*3653* @see llvm::Instruction::clone()3654*/3655LLVMValueRef LLVMInstructionClone(LLVMValueRef Inst);36563657/**3658* Determine whether an instruction is a terminator. This routine is named to3659* be compatible with historical functions that did this by querying the3660* underlying C++ type.3661*3662* @see llvm::Instruction::isTerminator()3663*/3664LLVMValueRef LLVMIsATerminatorInst(LLVMValueRef Inst);36653666/**3667* @defgroup LLVMCCoreValueInstructionCall Call Sites and Invocations3668*3669* Functions in this group apply to instructions that refer to call3670* sites and invocations. These correspond to C++ types in the3671* llvm::CallInst class tree.3672*3673* @{3674*/36753676/**3677* Obtain the argument count for a call instruction.3678*3679* This expects an LLVMValueRef that corresponds to a llvm::CallInst,3680* llvm::InvokeInst, or llvm:FuncletPadInst.3681*3682* @see llvm::CallInst::getNumArgOperands()3683* @see llvm::InvokeInst::getNumArgOperands()3684* @see llvm::FuncletPadInst::getNumArgOperands()3685*/3686unsigned LLVMGetNumArgOperands(LLVMValueRef Instr);36873688/**3689* Set the calling convention for a call instruction.3690*3691* This expects an LLVMValueRef that corresponds to a llvm::CallInst or3692* llvm::InvokeInst.3693*3694* @see llvm::CallInst::setCallingConv()3695* @see llvm::InvokeInst::setCallingConv()3696*/3697void LLVMSetInstructionCallConv(LLVMValueRef Instr, unsigned CC);36983699/**3700* Obtain the calling convention for a call instruction.3701*3702* This is the opposite of LLVMSetInstructionCallConv(). Reads its3703* usage.3704*3705* @see LLVMSetInstructionCallConv()3706*/3707unsigned LLVMGetInstructionCallConv(LLVMValueRef Instr);37083709void LLVMSetInstrParamAlignment(LLVMValueRef Instr, LLVMAttributeIndex Idx,3710unsigned Align);37113712void LLVMAddCallSiteAttribute(LLVMValueRef C, LLVMAttributeIndex Idx,3713LLVMAttributeRef A);3714unsigned LLVMGetCallSiteAttributeCount(LLVMValueRef C, LLVMAttributeIndex Idx);3715void LLVMGetCallSiteAttributes(LLVMValueRef C, LLVMAttributeIndex Idx,3716LLVMAttributeRef *Attrs);3717LLVMAttributeRef LLVMGetCallSiteEnumAttribute(LLVMValueRef C,3718LLVMAttributeIndex Idx,3719unsigned KindID);3720LLVMAttributeRef LLVMGetCallSiteStringAttribute(LLVMValueRef C,3721LLVMAttributeIndex Idx,3722const char *K, unsigned KLen);3723void LLVMRemoveCallSiteEnumAttribute(LLVMValueRef C, LLVMAttributeIndex Idx,3724unsigned KindID);3725void LLVMRemoveCallSiteStringAttribute(LLVMValueRef C, LLVMAttributeIndex Idx,3726const char *K, unsigned KLen);37273728/**3729* Obtain the function type called by this instruction.3730*3731* @see llvm::CallBase::getFunctionType()3732*/3733LLVMTypeRef LLVMGetCalledFunctionType(LLVMValueRef C);37343735/**3736* Obtain the pointer to the function invoked by this instruction.3737*3738* This expects an LLVMValueRef that corresponds to a llvm::CallInst or3739* llvm::InvokeInst.3740*3741* @see llvm::CallInst::getCalledOperand()3742* @see llvm::InvokeInst::getCalledOperand()3743*/3744LLVMValueRef LLVMGetCalledValue(LLVMValueRef Instr);37453746/**3747* Obtain the number of operand bundles attached to this instruction.3748*3749* This only works on llvm::CallInst and llvm::InvokeInst instructions.3750*3751* @see llvm::CallBase::getNumOperandBundles()3752*/3753unsigned LLVMGetNumOperandBundles(LLVMValueRef C);37543755/**3756* Obtain the operand bundle attached to this instruction at the given index.3757* Use LLVMDisposeOperandBundle to free the operand bundle.3758*3759* This only works on llvm::CallInst and llvm::InvokeInst instructions.3760*/3761LLVMOperandBundleRef LLVMGetOperandBundleAtIndex(LLVMValueRef C,3762unsigned Index);37633764/**3765* Obtain whether a call instruction is a tail call.3766*3767* This only works on llvm::CallInst instructions.3768*3769* @see llvm::CallInst::isTailCall()3770*/3771LLVMBool LLVMIsTailCall(LLVMValueRef CallInst);37723773/**3774* Set whether a call instruction is a tail call.3775*3776* This only works on llvm::CallInst instructions.3777*3778* @see llvm::CallInst::setTailCall()3779*/3780void LLVMSetTailCall(LLVMValueRef CallInst, LLVMBool IsTailCall);37813782/**3783* Obtain a tail call kind of the call instruction.3784*3785* @see llvm::CallInst::setTailCallKind()3786*/3787LLVMTailCallKind LLVMGetTailCallKind(LLVMValueRef CallInst);37883789/**3790* Set the call kind of the call instruction.3791*3792* @see llvm::CallInst::getTailCallKind()3793*/3794void LLVMSetTailCallKind(LLVMValueRef CallInst, LLVMTailCallKind kind);37953796/**3797* Return the normal destination basic block.3798*3799* This only works on llvm::InvokeInst instructions.3800*3801* @see llvm::InvokeInst::getNormalDest()3802*/3803LLVMBasicBlockRef LLVMGetNormalDest(LLVMValueRef InvokeInst);38043805/**3806* Return the unwind destination basic block.3807*3808* Works on llvm::InvokeInst, llvm::CleanupReturnInst, and3809* llvm::CatchSwitchInst instructions.3810*3811* @see llvm::InvokeInst::getUnwindDest()3812* @see llvm::CleanupReturnInst::getUnwindDest()3813* @see llvm::CatchSwitchInst::getUnwindDest()3814*/3815LLVMBasicBlockRef LLVMGetUnwindDest(LLVMValueRef InvokeInst);38163817/**3818* Set the normal destination basic block.3819*3820* This only works on llvm::InvokeInst instructions.3821*3822* @see llvm::InvokeInst::setNormalDest()3823*/3824void LLVMSetNormalDest(LLVMValueRef InvokeInst, LLVMBasicBlockRef B);38253826/**3827* Set the unwind destination basic block.3828*3829* Works on llvm::InvokeInst, llvm::CleanupReturnInst, and3830* llvm::CatchSwitchInst instructions.3831*3832* @see llvm::InvokeInst::setUnwindDest()3833* @see llvm::CleanupReturnInst::setUnwindDest()3834* @see llvm::CatchSwitchInst::setUnwindDest()3835*/3836void LLVMSetUnwindDest(LLVMValueRef InvokeInst, LLVMBasicBlockRef B);38373838/**3839* Get the default destination of a CallBr instruction.3840*3841* @see llvm::CallBrInst::getDefaultDest()3842*/3843LLVMBasicBlockRef LLVMGetCallBrDefaultDest(LLVMValueRef CallBr);38443845/**3846* Get the number of indirect destinations of a CallBr instruction.3847*3848* @see llvm::CallBrInst::getNumIndirectDests()38493850*/3851unsigned LLVMGetCallBrNumIndirectDests(LLVMValueRef CallBr);38523853/**3854* Get the indirect destination of a CallBr instruction at the given index.3855*3856* @see llvm::CallBrInst::getIndirectDest()3857*/3858LLVMBasicBlockRef LLVMGetCallBrIndirectDest(LLVMValueRef CallBr, unsigned Idx);38593860/**3861* @}3862*/38633864/**3865* @defgroup LLVMCCoreValueInstructionTerminator Terminators3866*3867* Functions in this group only apply to instructions for which3868* LLVMIsATerminatorInst returns true.3869*3870* @{3871*/38723873/**3874* Return the number of successors that this terminator has.3875*3876* @see llvm::Instruction::getNumSuccessors3877*/3878unsigned LLVMGetNumSuccessors(LLVMValueRef Term);38793880/**3881* Return the specified successor.3882*3883* @see llvm::Instruction::getSuccessor3884*/3885LLVMBasicBlockRef LLVMGetSuccessor(LLVMValueRef Term, unsigned i);38863887/**3888* Update the specified successor to point at the provided block.3889*3890* @see llvm::Instruction::setSuccessor3891*/3892void LLVMSetSuccessor(LLVMValueRef Term, unsigned i, LLVMBasicBlockRef block);38933894/**3895* Return if a branch is conditional.3896*3897* This only works on llvm::BranchInst instructions.3898*3899* @see llvm::BranchInst::isConditional3900*/3901LLVMBool LLVMIsConditional(LLVMValueRef Branch);39023903/**3904* Return the condition of a branch instruction.3905*3906* This only works on llvm::BranchInst instructions.3907*3908* @see llvm::BranchInst::getCondition3909*/3910LLVMValueRef LLVMGetCondition(LLVMValueRef Branch);39113912/**3913* Set the condition of a branch instruction.3914*3915* This only works on llvm::BranchInst instructions.3916*3917* @see llvm::BranchInst::setCondition3918*/3919void LLVMSetCondition(LLVMValueRef Branch, LLVMValueRef Cond);39203921/**3922* Obtain the default destination basic block of a switch instruction.3923*3924* This only works on llvm::SwitchInst instructions.3925*3926* @see llvm::SwitchInst::getDefaultDest()3927*/3928LLVMBasicBlockRef LLVMGetSwitchDefaultDest(LLVMValueRef SwitchInstr);39293930/**3931* @}3932*/39333934/**3935* @defgroup LLVMCCoreValueInstructionAlloca Allocas3936*3937* Functions in this group only apply to instructions that map to3938* llvm::AllocaInst instances.3939*3940* @{3941*/39423943/**3944* Obtain the type that is being allocated by the alloca instruction.3945*/3946LLVMTypeRef LLVMGetAllocatedType(LLVMValueRef Alloca);39473948/**3949* @}3950*/39513952/**3953* @defgroup LLVMCCoreValueInstructionGetElementPointer GEPs3954*3955* Functions in this group only apply to instructions that map to3956* llvm::GetElementPtrInst instances.3957*3958* @{3959*/39603961/**3962* Check whether the given GEP operator is inbounds.3963*/3964LLVMBool LLVMIsInBounds(LLVMValueRef GEP);39653966/**3967* Set the given GEP instruction to be inbounds or not.3968*/3969void LLVMSetIsInBounds(LLVMValueRef GEP, LLVMBool InBounds);39703971/**3972* Get the source element type of the given GEP operator.3973*/3974LLVMTypeRef LLVMGetGEPSourceElementType(LLVMValueRef GEP);39753976/**3977* Get the no-wrap related flags for the given GEP instruction.3978*3979* @see llvm::GetElementPtrInst::getNoWrapFlags3980*/3981LLVMGEPNoWrapFlags LLVMGEPGetNoWrapFlags(LLVMValueRef GEP);39823983/**3984* Set the no-wrap related flags for the given GEP instruction.3985*3986* @see llvm::GetElementPtrInst::setNoWrapFlags3987*/3988void LLVMGEPSetNoWrapFlags(LLVMValueRef GEP, LLVMGEPNoWrapFlags NoWrapFlags);39893990/**3991* @}3992*/39933994/**3995* @defgroup LLVMCCoreValueInstructionPHINode PHI Nodes3996*3997* Functions in this group only apply to instructions that map to3998* llvm::PHINode instances.3999*4000* @{4001*/40024003/**4004* Add an incoming value to the end of a PHI list.4005*/4006void LLVMAddIncoming(LLVMValueRef PhiNode, LLVMValueRef *IncomingValues,4007LLVMBasicBlockRef *IncomingBlocks, unsigned Count);40084009/**4010* Obtain the number of incoming basic blocks to a PHI node.4011*/4012unsigned LLVMCountIncoming(LLVMValueRef PhiNode);40134014/**4015* Obtain an incoming value to a PHI node as an LLVMValueRef.4016*/4017LLVMValueRef LLVMGetIncomingValue(LLVMValueRef PhiNode, unsigned Index);40184019/**4020* Obtain an incoming value to a PHI node as an LLVMBasicBlockRef.4021*/4022LLVMBasicBlockRef LLVMGetIncomingBlock(LLVMValueRef PhiNode, unsigned Index);40234024/**4025* @}4026*/40274028/**4029* @defgroup LLVMCCoreValueInstructionExtractValue ExtractValue4030* @defgroup LLVMCCoreValueInstructionInsertValue InsertValue4031*4032* Functions in this group only apply to instructions that map to4033* llvm::ExtractValue and llvm::InsertValue instances.4034*4035* @{4036*/40374038/**4039* Obtain the number of indices.4040* NB: This also works on GEP operators.4041*/4042unsigned LLVMGetNumIndices(LLVMValueRef Inst);40434044/**4045* Obtain the indices as an array.4046*/4047const unsigned *LLVMGetIndices(LLVMValueRef Inst);40484049/**4050* @}4051*/40524053/**4054* @}4055*/40564057/**4058* @}4059*/40604061/**4062* @defgroup LLVMCCoreInstructionBuilder Instruction Builders4063*4064* An instruction builder represents a point within a basic block and is4065* the exclusive means of building instructions using the C interface.4066*4067* @{4068*/40694070LLVMBuilderRef LLVMCreateBuilderInContext(LLVMContextRef C);4071LLVMBuilderRef LLVMCreateBuilder(void);4072/**4073* Set the builder position before Instr but after any attached debug records,4074* or if Instr is null set the position to the end of Block.4075*/4076void LLVMPositionBuilder(LLVMBuilderRef Builder, LLVMBasicBlockRef Block,4077LLVMValueRef Instr);4078/**4079* Set the builder position before Instr and any attached debug records,4080* or if Instr is null set the position to the end of Block.4081*/4082void LLVMPositionBuilderBeforeDbgRecords(LLVMBuilderRef Builder,4083LLVMBasicBlockRef Block,4084LLVMValueRef Inst);4085/**4086* Set the builder position before Instr but after any attached debug records.4087*/4088void LLVMPositionBuilderBefore(LLVMBuilderRef Builder, LLVMValueRef Instr);4089/**4090* Set the builder position before Instr and any attached debug records.4091*/4092void LLVMPositionBuilderBeforeInstrAndDbgRecords(LLVMBuilderRef Builder,4093LLVMValueRef Instr);4094void LLVMPositionBuilderAtEnd(LLVMBuilderRef Builder, LLVMBasicBlockRef Block);4095LLVMBasicBlockRef LLVMGetInsertBlock(LLVMBuilderRef Builder);4096void LLVMClearInsertionPosition(LLVMBuilderRef Builder);4097void LLVMInsertIntoBuilder(LLVMBuilderRef Builder, LLVMValueRef Instr);4098void LLVMInsertIntoBuilderWithName(LLVMBuilderRef Builder, LLVMValueRef Instr,4099const char *Name);4100void LLVMDisposeBuilder(LLVMBuilderRef Builder);41014102/* Metadata */41034104/**4105* Get location information used by debugging information.4106*4107* @see llvm::IRBuilder::getCurrentDebugLocation()4108*/4109LLVMMetadataRef LLVMGetCurrentDebugLocation2(LLVMBuilderRef Builder);41104111/**4112* Set location information used by debugging information.4113*4114* To clear the location metadata of the given instruction, pass NULL to \p Loc.4115*4116* @see llvm::IRBuilder::SetCurrentDebugLocation()4117*/4118void LLVMSetCurrentDebugLocation2(LLVMBuilderRef Builder, LLVMMetadataRef Loc);41194120/**4121* Attempts to set the debug location for the given instruction using the4122* current debug location for the given builder. If the builder has no current4123* debug location, this function is a no-op.4124*4125* @deprecated LLVMSetInstDebugLocation is deprecated in favor of the more general4126* LLVMAddMetadataToInst.4127*4128* @see llvm::IRBuilder::SetInstDebugLocation()4129*/4130void LLVMSetInstDebugLocation(LLVMBuilderRef Builder, LLVMValueRef Inst);41314132/**4133* Adds the metadata registered with the given builder to the given instruction.4134*4135* @see llvm::IRBuilder::AddMetadataToInst()4136*/4137void LLVMAddMetadataToInst(LLVMBuilderRef Builder, LLVMValueRef Inst);41384139/**4140* Get the dafult floating-point math metadata for a given builder.4141*4142* @see llvm::IRBuilder::getDefaultFPMathTag()4143*/4144LLVMMetadataRef LLVMBuilderGetDefaultFPMathTag(LLVMBuilderRef Builder);41454146/**4147* Set the default floating-point math metadata for the given builder.4148*4149* To clear the metadata, pass NULL to \p FPMathTag.4150*4151* @see llvm::IRBuilder::setDefaultFPMathTag()4152*/4153void LLVMBuilderSetDefaultFPMathTag(LLVMBuilderRef Builder,4154LLVMMetadataRef FPMathTag);41554156/**4157* Deprecated: Passing the NULL location will crash.4158* Use LLVMGetCurrentDebugLocation2 instead.4159*/4160void LLVMSetCurrentDebugLocation(LLVMBuilderRef Builder, LLVMValueRef L);4161/**4162* Deprecated: Returning the NULL location will crash.4163* Use LLVMGetCurrentDebugLocation2 instead.4164*/4165LLVMValueRef LLVMGetCurrentDebugLocation(LLVMBuilderRef Builder);41664167/* Terminators */4168LLVMValueRef LLVMBuildRetVoid(LLVMBuilderRef);4169LLVMValueRef LLVMBuildRet(LLVMBuilderRef, LLVMValueRef V);4170LLVMValueRef LLVMBuildAggregateRet(LLVMBuilderRef, LLVMValueRef *RetVals,4171unsigned N);4172LLVMValueRef LLVMBuildBr(LLVMBuilderRef, LLVMBasicBlockRef Dest);4173LLVMValueRef LLVMBuildCondBr(LLVMBuilderRef, LLVMValueRef If,4174LLVMBasicBlockRef Then, LLVMBasicBlockRef Else);4175LLVMValueRef LLVMBuildSwitch(LLVMBuilderRef, LLVMValueRef V,4176LLVMBasicBlockRef Else, unsigned NumCases);4177LLVMValueRef LLVMBuildIndirectBr(LLVMBuilderRef B, LLVMValueRef Addr,4178unsigned NumDests);4179LLVMValueRef LLVMBuildCallBr(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Fn,4180LLVMBasicBlockRef DefaultDest,4181LLVMBasicBlockRef *IndirectDests,4182unsigned NumIndirectDests, LLVMValueRef *Args,4183unsigned NumArgs, LLVMOperandBundleRef *Bundles,4184unsigned NumBundles, const char *Name);4185LLVMValueRef LLVMBuildInvoke2(LLVMBuilderRef, LLVMTypeRef Ty, LLVMValueRef Fn,4186LLVMValueRef *Args, unsigned NumArgs,4187LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch,4188const char *Name);4189LLVMValueRef LLVMBuildInvokeWithOperandBundles(4190LLVMBuilderRef, LLVMTypeRef Ty, LLVMValueRef Fn, LLVMValueRef *Args,4191unsigned NumArgs, LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch,4192LLVMOperandBundleRef *Bundles, unsigned NumBundles, const char *Name);4193LLVMValueRef LLVMBuildUnreachable(LLVMBuilderRef);41944195/* Exception Handling */4196LLVMValueRef LLVMBuildResume(LLVMBuilderRef B, LLVMValueRef Exn);4197LLVMValueRef LLVMBuildLandingPad(LLVMBuilderRef B, LLVMTypeRef Ty,4198LLVMValueRef PersFn, unsigned NumClauses,4199const char *Name);4200LLVMValueRef LLVMBuildCleanupRet(LLVMBuilderRef B, LLVMValueRef CatchPad,4201LLVMBasicBlockRef BB);4202LLVMValueRef LLVMBuildCatchRet(LLVMBuilderRef B, LLVMValueRef CatchPad,4203LLVMBasicBlockRef BB);4204LLVMValueRef LLVMBuildCatchPad(LLVMBuilderRef B, LLVMValueRef ParentPad,4205LLVMValueRef *Args, unsigned NumArgs,4206const char *Name);4207LLVMValueRef LLVMBuildCleanupPad(LLVMBuilderRef B, LLVMValueRef ParentPad,4208LLVMValueRef *Args, unsigned NumArgs,4209const char *Name);4210LLVMValueRef LLVMBuildCatchSwitch(LLVMBuilderRef B, LLVMValueRef ParentPad,4211LLVMBasicBlockRef UnwindBB,4212unsigned NumHandlers, const char *Name);42134214/* Add a case to the switch instruction */4215void LLVMAddCase(LLVMValueRef Switch, LLVMValueRef OnVal,4216LLVMBasicBlockRef Dest);42174218/* Add a destination to the indirectbr instruction */4219void LLVMAddDestination(LLVMValueRef IndirectBr, LLVMBasicBlockRef Dest);42204221/* Get the number of clauses on the landingpad instruction */4222unsigned LLVMGetNumClauses(LLVMValueRef LandingPad);42234224/* Get the value of the clause at index Idx on the landingpad instruction */4225LLVMValueRef LLVMGetClause(LLVMValueRef LandingPad, unsigned Idx);42264227/* Add a catch or filter clause to the landingpad instruction */4228void LLVMAddClause(LLVMValueRef LandingPad, LLVMValueRef ClauseVal);42294230/* Get the 'cleanup' flag in the landingpad instruction */4231LLVMBool LLVMIsCleanup(LLVMValueRef LandingPad);42324233/* Set the 'cleanup' flag in the landingpad instruction */4234void LLVMSetCleanup(LLVMValueRef LandingPad, LLVMBool Val);42354236/* Add a destination to the catchswitch instruction */4237void LLVMAddHandler(LLVMValueRef CatchSwitch, LLVMBasicBlockRef Dest);42384239/* Get the number of handlers on the catchswitch instruction */4240unsigned LLVMGetNumHandlers(LLVMValueRef CatchSwitch);42414242/**4243* Obtain the basic blocks acting as handlers for a catchswitch instruction.4244*4245* The Handlers parameter should point to a pre-allocated array of4246* LLVMBasicBlockRefs at least LLVMGetNumHandlers() large. On return, the4247* first LLVMGetNumHandlers() entries in the array will be populated4248* with LLVMBasicBlockRef instances.4249*4250* @param CatchSwitch The catchswitch instruction to operate on.4251* @param Handlers Memory address of an array to be filled with basic blocks.4252*/4253void LLVMGetHandlers(LLVMValueRef CatchSwitch, LLVMBasicBlockRef *Handlers);42544255/* Funclets */42564257/* Get the number of funcletpad arguments. */4258LLVMValueRef LLVMGetArgOperand(LLVMValueRef Funclet, unsigned i);42594260/* Set a funcletpad argument at the given index. */4261void LLVMSetArgOperand(LLVMValueRef Funclet, unsigned i, LLVMValueRef value);42624263/**4264* Get the parent catchswitch instruction of a catchpad instruction.4265*4266* This only works on llvm::CatchPadInst instructions.4267*4268* @see llvm::CatchPadInst::getCatchSwitch()4269*/4270LLVMValueRef LLVMGetParentCatchSwitch(LLVMValueRef CatchPad);42714272/**4273* Set the parent catchswitch instruction of a catchpad instruction.4274*4275* This only works on llvm::CatchPadInst instructions.4276*4277* @see llvm::CatchPadInst::setCatchSwitch()4278*/4279void LLVMSetParentCatchSwitch(LLVMValueRef CatchPad, LLVMValueRef CatchSwitch);42804281/* Arithmetic */4282LLVMValueRef LLVMBuildAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,4283const char *Name);4284LLVMValueRef LLVMBuildNSWAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,4285const char *Name);4286LLVMValueRef LLVMBuildNUWAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,4287const char *Name);4288LLVMValueRef LLVMBuildFAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,4289const char *Name);4290LLVMValueRef LLVMBuildSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,4291const char *Name);4292LLVMValueRef LLVMBuildNSWSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,4293const char *Name);4294LLVMValueRef LLVMBuildNUWSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,4295const char *Name);4296LLVMValueRef LLVMBuildFSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,4297const char *Name);4298LLVMValueRef LLVMBuildMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,4299const char *Name);4300LLVMValueRef LLVMBuildNSWMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,4301const char *Name);4302LLVMValueRef LLVMBuildNUWMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,4303const char *Name);4304LLVMValueRef LLVMBuildFMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,4305const char *Name);4306LLVMValueRef LLVMBuildUDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,4307const char *Name);4308LLVMValueRef LLVMBuildExactUDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,4309const char *Name);4310LLVMValueRef LLVMBuildSDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,4311const char *Name);4312LLVMValueRef LLVMBuildExactSDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,4313const char *Name);4314LLVMValueRef LLVMBuildFDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,4315const char *Name);4316LLVMValueRef LLVMBuildURem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,4317const char *Name);4318LLVMValueRef LLVMBuildSRem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,4319const char *Name);4320LLVMValueRef LLVMBuildFRem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,4321const char *Name);4322LLVMValueRef LLVMBuildShl(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,4323const char *Name);4324LLVMValueRef LLVMBuildLShr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,4325const char *Name);4326LLVMValueRef LLVMBuildAShr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,4327const char *Name);4328LLVMValueRef LLVMBuildAnd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,4329const char *Name);4330LLVMValueRef LLVMBuildOr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,4331const char *Name);4332LLVMValueRef LLVMBuildXor(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,4333const char *Name);4334LLVMValueRef LLVMBuildBinOp(LLVMBuilderRef B, LLVMOpcode Op,4335LLVMValueRef LHS, LLVMValueRef RHS,4336const char *Name);4337LLVMValueRef LLVMBuildNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name);4338LLVMValueRef LLVMBuildNSWNeg(LLVMBuilderRef B, LLVMValueRef V,4339const char *Name);4340LLVM_ATTRIBUTE_C_DEPRECATED(LLVMValueRef LLVMBuildNUWNeg(LLVMBuilderRef B,4341LLVMValueRef V,4342const char *Name),4343"Use LLVMBuildNeg + LLVMSetNUW instead.");4344LLVMValueRef LLVMBuildFNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name);4345LLVMValueRef LLVMBuildNot(LLVMBuilderRef, LLVMValueRef V, const char *Name);43464347LLVMBool LLVMGetNUW(LLVMValueRef ArithInst);4348void LLVMSetNUW(LLVMValueRef ArithInst, LLVMBool HasNUW);4349LLVMBool LLVMGetNSW(LLVMValueRef ArithInst);4350void LLVMSetNSW(LLVMValueRef ArithInst, LLVMBool HasNSW);4351LLVMBool LLVMGetExact(LLVMValueRef DivOrShrInst);4352void LLVMSetExact(LLVMValueRef DivOrShrInst, LLVMBool IsExact);43534354/**4355* Gets if the instruction has the non-negative flag set.4356* Only valid for zext instructions.4357*/4358LLVMBool LLVMGetNNeg(LLVMValueRef NonNegInst);4359/**4360* Sets the non-negative flag for the instruction.4361* Only valid for zext instructions.4362*/4363void LLVMSetNNeg(LLVMValueRef NonNegInst, LLVMBool IsNonNeg);43644365/**4366* Get the flags for which fast-math-style optimizations are allowed for this4367* value.4368*4369* Only valid on floating point instructions.4370* @see LLVMCanValueUseFastMathFlags4371*/4372LLVMFastMathFlags LLVMGetFastMathFlags(LLVMValueRef FPMathInst);43734374/**4375* Sets the flags for which fast-math-style optimizations are allowed for this4376* value.4377*4378* Only valid on floating point instructions.4379* @see LLVMCanValueUseFastMathFlags4380*/4381void LLVMSetFastMathFlags(LLVMValueRef FPMathInst, LLVMFastMathFlags FMF);43824383/**4384* Check if a given value can potentially have fast math flags.4385*4386* Will return true for floating point arithmetic instructions, and for select,4387* phi, and call instructions whose type is a floating point type, or a vector4388* or array thereof. See https://llvm.org/docs/LangRef.html#fast-math-flags4389*/4390LLVMBool LLVMCanValueUseFastMathFlags(LLVMValueRef Inst);43914392/**4393* Gets whether the instruction has the disjoint flag set.4394* Only valid for or instructions.4395*/4396LLVMBool LLVMGetIsDisjoint(LLVMValueRef Inst);4397/**4398* Sets the disjoint flag for the instruction.4399* Only valid for or instructions.4400*/4401void LLVMSetIsDisjoint(LLVMValueRef Inst, LLVMBool IsDisjoint);44024403/* Memory */4404LLVMValueRef LLVMBuildMalloc(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);4405LLVMValueRef LLVMBuildArrayMalloc(LLVMBuilderRef, LLVMTypeRef Ty,4406LLVMValueRef Val, const char *Name);44074408/**4409* Creates and inserts a memset to the specified pointer and the4410* specified value.4411*4412* @see llvm::IRRBuilder::CreateMemSet()4413*/4414LLVMValueRef LLVMBuildMemSet(LLVMBuilderRef B, LLVMValueRef Ptr,4415LLVMValueRef Val, LLVMValueRef Len,4416unsigned Align);4417/**4418* Creates and inserts a memcpy between the specified pointers.4419*4420* @see llvm::IRRBuilder::CreateMemCpy()4421*/4422LLVMValueRef LLVMBuildMemCpy(LLVMBuilderRef B,4423LLVMValueRef Dst, unsigned DstAlign,4424LLVMValueRef Src, unsigned SrcAlign,4425LLVMValueRef Size);4426/**4427* Creates and inserts a memmove between the specified pointers.4428*4429* @see llvm::IRRBuilder::CreateMemMove()4430*/4431LLVMValueRef LLVMBuildMemMove(LLVMBuilderRef B,4432LLVMValueRef Dst, unsigned DstAlign,4433LLVMValueRef Src, unsigned SrcAlign,4434LLVMValueRef Size);44354436LLVMValueRef LLVMBuildAlloca(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);4437LLVMValueRef LLVMBuildArrayAlloca(LLVMBuilderRef, LLVMTypeRef Ty,4438LLVMValueRef Val, const char *Name);4439LLVMValueRef LLVMBuildFree(LLVMBuilderRef, LLVMValueRef PointerVal);4440LLVMValueRef LLVMBuildLoad2(LLVMBuilderRef, LLVMTypeRef Ty,4441LLVMValueRef PointerVal, const char *Name);4442LLVMValueRef LLVMBuildStore(LLVMBuilderRef, LLVMValueRef Val, LLVMValueRef Ptr);4443LLVMValueRef LLVMBuildGEP2(LLVMBuilderRef B, LLVMTypeRef Ty,4444LLVMValueRef Pointer, LLVMValueRef *Indices,4445unsigned NumIndices, const char *Name);4446LLVMValueRef LLVMBuildInBoundsGEP2(LLVMBuilderRef B, LLVMTypeRef Ty,4447LLVMValueRef Pointer, LLVMValueRef *Indices,4448unsigned NumIndices, const char *Name);4449/**4450* Creates a GetElementPtr instruction. Similar to LLVMBuildGEP2, but allows4451* specifying the no-wrap flags.4452*4453* @see llvm::IRBuilder::CreateGEP()4454*/4455LLVMValueRef LLVMBuildGEPWithNoWrapFlags(LLVMBuilderRef B, LLVMTypeRef Ty,4456LLVMValueRef Pointer,4457LLVMValueRef *Indices,4458unsigned NumIndices, const char *Name,4459LLVMGEPNoWrapFlags NoWrapFlags);4460LLVMValueRef LLVMBuildStructGEP2(LLVMBuilderRef B, LLVMTypeRef Ty,4461LLVMValueRef Pointer, unsigned Idx,4462const char *Name);4463LLVMValueRef LLVMBuildGlobalString(LLVMBuilderRef B, const char *Str,4464const char *Name);4465LLVMValueRef LLVMBuildGlobalStringPtr(LLVMBuilderRef B, const char *Str,4466const char *Name);4467LLVMBool LLVMGetVolatile(LLVMValueRef MemoryAccessInst);4468void LLVMSetVolatile(LLVMValueRef MemoryAccessInst, LLVMBool IsVolatile);4469LLVMBool LLVMGetWeak(LLVMValueRef CmpXchgInst);4470void LLVMSetWeak(LLVMValueRef CmpXchgInst, LLVMBool IsWeak);4471LLVMAtomicOrdering LLVMGetOrdering(LLVMValueRef MemoryAccessInst);4472void LLVMSetOrdering(LLVMValueRef MemoryAccessInst, LLVMAtomicOrdering Ordering);4473LLVMAtomicRMWBinOp LLVMGetAtomicRMWBinOp(LLVMValueRef AtomicRMWInst);4474void LLVMSetAtomicRMWBinOp(LLVMValueRef AtomicRMWInst, LLVMAtomicRMWBinOp BinOp);44754476/* Casts */4477LLVMValueRef LLVMBuildTrunc(LLVMBuilderRef, LLVMValueRef Val,4478LLVMTypeRef DestTy, const char *Name);4479LLVMValueRef LLVMBuildZExt(LLVMBuilderRef, LLVMValueRef Val,4480LLVMTypeRef DestTy, const char *Name);4481LLVMValueRef LLVMBuildSExt(LLVMBuilderRef, LLVMValueRef Val,4482LLVMTypeRef DestTy, const char *Name);4483LLVMValueRef LLVMBuildFPToUI(LLVMBuilderRef, LLVMValueRef Val,4484LLVMTypeRef DestTy, const char *Name);4485LLVMValueRef LLVMBuildFPToSI(LLVMBuilderRef, LLVMValueRef Val,4486LLVMTypeRef DestTy, const char *Name);4487LLVMValueRef LLVMBuildUIToFP(LLVMBuilderRef, LLVMValueRef Val,4488LLVMTypeRef DestTy, const char *Name);4489LLVMValueRef LLVMBuildSIToFP(LLVMBuilderRef, LLVMValueRef Val,4490LLVMTypeRef DestTy, const char *Name);4491LLVMValueRef LLVMBuildFPTrunc(LLVMBuilderRef, LLVMValueRef Val,4492LLVMTypeRef DestTy, const char *Name);4493LLVMValueRef LLVMBuildFPExt(LLVMBuilderRef, LLVMValueRef Val,4494LLVMTypeRef DestTy, const char *Name);4495LLVMValueRef LLVMBuildPtrToInt(LLVMBuilderRef, LLVMValueRef Val,4496LLVMTypeRef DestTy, const char *Name);4497LLVMValueRef LLVMBuildIntToPtr(LLVMBuilderRef, LLVMValueRef Val,4498LLVMTypeRef DestTy, const char *Name);4499LLVMValueRef LLVMBuildBitCast(LLVMBuilderRef, LLVMValueRef Val,4500LLVMTypeRef DestTy, const char *Name);4501LLVMValueRef LLVMBuildAddrSpaceCast(LLVMBuilderRef, LLVMValueRef Val,4502LLVMTypeRef DestTy, const char *Name);4503LLVMValueRef LLVMBuildZExtOrBitCast(LLVMBuilderRef, LLVMValueRef Val,4504LLVMTypeRef DestTy, const char *Name);4505LLVMValueRef LLVMBuildSExtOrBitCast(LLVMBuilderRef, LLVMValueRef Val,4506LLVMTypeRef DestTy, const char *Name);4507LLVMValueRef LLVMBuildTruncOrBitCast(LLVMBuilderRef, LLVMValueRef Val,4508LLVMTypeRef DestTy, const char *Name);4509LLVMValueRef LLVMBuildCast(LLVMBuilderRef B, LLVMOpcode Op, LLVMValueRef Val,4510LLVMTypeRef DestTy, const char *Name);4511LLVMValueRef LLVMBuildPointerCast(LLVMBuilderRef, LLVMValueRef Val,4512LLVMTypeRef DestTy, const char *Name);4513LLVMValueRef LLVMBuildIntCast2(LLVMBuilderRef, LLVMValueRef Val,4514LLVMTypeRef DestTy, LLVMBool IsSigned,4515const char *Name);4516LLVMValueRef LLVMBuildFPCast(LLVMBuilderRef, LLVMValueRef Val,4517LLVMTypeRef DestTy, const char *Name);45184519/** Deprecated: This cast is always signed. Use LLVMBuildIntCast2 instead. */4520LLVMValueRef LLVMBuildIntCast(LLVMBuilderRef, LLVMValueRef Val, /*Signed cast!*/4521LLVMTypeRef DestTy, const char *Name);45224523LLVMOpcode LLVMGetCastOpcode(LLVMValueRef Src, LLVMBool SrcIsSigned,4524LLVMTypeRef DestTy, LLVMBool DestIsSigned);45254526/* Comparisons */4527LLVMValueRef LLVMBuildICmp(LLVMBuilderRef, LLVMIntPredicate Op,4528LLVMValueRef LHS, LLVMValueRef RHS,4529const char *Name);4530LLVMValueRef LLVMBuildFCmp(LLVMBuilderRef, LLVMRealPredicate Op,4531LLVMValueRef LHS, LLVMValueRef RHS,4532const char *Name);45334534/* Miscellaneous instructions */4535LLVMValueRef LLVMBuildPhi(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);4536LLVMValueRef LLVMBuildCall2(LLVMBuilderRef, LLVMTypeRef, LLVMValueRef Fn,4537LLVMValueRef *Args, unsigned NumArgs,4538const char *Name);4539LLVMValueRef4540LLVMBuildCallWithOperandBundles(LLVMBuilderRef, LLVMTypeRef, LLVMValueRef Fn,4541LLVMValueRef *Args, unsigned NumArgs,4542LLVMOperandBundleRef *Bundles,4543unsigned NumBundles, const char *Name);4544LLVMValueRef LLVMBuildSelect(LLVMBuilderRef, LLVMValueRef If,4545LLVMValueRef Then, LLVMValueRef Else,4546const char *Name);4547LLVMValueRef LLVMBuildVAArg(LLVMBuilderRef, LLVMValueRef List, LLVMTypeRef Ty,4548const char *Name);4549LLVMValueRef LLVMBuildExtractElement(LLVMBuilderRef, LLVMValueRef VecVal,4550LLVMValueRef Index, const char *Name);4551LLVMValueRef LLVMBuildInsertElement(LLVMBuilderRef, LLVMValueRef VecVal,4552LLVMValueRef EltVal, LLVMValueRef Index,4553const char *Name);4554LLVMValueRef LLVMBuildShuffleVector(LLVMBuilderRef, LLVMValueRef V1,4555LLVMValueRef V2, LLVMValueRef Mask,4556const char *Name);4557LLVMValueRef LLVMBuildExtractValue(LLVMBuilderRef, LLVMValueRef AggVal,4558unsigned Index, const char *Name);4559LLVMValueRef LLVMBuildInsertValue(LLVMBuilderRef, LLVMValueRef AggVal,4560LLVMValueRef EltVal, unsigned Index,4561const char *Name);4562LLVMValueRef LLVMBuildFreeze(LLVMBuilderRef, LLVMValueRef Val,4563const char *Name);45644565LLVMValueRef LLVMBuildIsNull(LLVMBuilderRef, LLVMValueRef Val,4566const char *Name);4567LLVMValueRef LLVMBuildIsNotNull(LLVMBuilderRef, LLVMValueRef Val,4568const char *Name);4569LLVMValueRef LLVMBuildPtrDiff2(LLVMBuilderRef, LLVMTypeRef ElemTy,4570LLVMValueRef LHS, LLVMValueRef RHS,4571const char *Name);4572LLVMValueRef LLVMBuildFence(LLVMBuilderRef B, LLVMAtomicOrdering ordering,4573LLVMBool singleThread, const char *Name);4574LLVMValueRef LLVMBuildAtomicRMW(LLVMBuilderRef B, LLVMAtomicRMWBinOp op,4575LLVMValueRef PTR, LLVMValueRef Val,4576LLVMAtomicOrdering ordering,4577LLVMBool singleThread);4578LLVMValueRef LLVMBuildAtomicCmpXchg(LLVMBuilderRef B, LLVMValueRef Ptr,4579LLVMValueRef Cmp, LLVMValueRef New,4580LLVMAtomicOrdering SuccessOrdering,4581LLVMAtomicOrdering FailureOrdering,4582LLVMBool SingleThread);45834584/**4585* Get the number of elements in the mask of a ShuffleVector instruction.4586*/4587unsigned LLVMGetNumMaskElements(LLVMValueRef ShuffleVectorInst);45884589/**4590* \returns a constant that specifies that the result of a \c ShuffleVectorInst4591* is undefined.4592*/4593int LLVMGetUndefMaskElem(void);45944595/**4596* Get the mask value at position Elt in the mask of a ShuffleVector4597* instruction.4598*4599* \Returns the result of \c LLVMGetUndefMaskElem() if the mask value is4600* poison at that position.4601*/4602int LLVMGetMaskValue(LLVMValueRef ShuffleVectorInst, unsigned Elt);46034604LLVMBool LLVMIsAtomicSingleThread(LLVMValueRef AtomicInst);4605void LLVMSetAtomicSingleThread(LLVMValueRef AtomicInst, LLVMBool SingleThread);46064607LLVMAtomicOrdering LLVMGetCmpXchgSuccessOrdering(LLVMValueRef CmpXchgInst);4608void LLVMSetCmpXchgSuccessOrdering(LLVMValueRef CmpXchgInst,4609LLVMAtomicOrdering Ordering);4610LLVMAtomicOrdering LLVMGetCmpXchgFailureOrdering(LLVMValueRef CmpXchgInst);4611void LLVMSetCmpXchgFailureOrdering(LLVMValueRef CmpXchgInst,4612LLVMAtomicOrdering Ordering);46134614/**4615* @}4616*/46174618/**4619* @defgroup LLVMCCoreModuleProvider Module Providers4620*4621* @{4622*/46234624/**4625* Changes the type of M so it can be passed to FunctionPassManagers and the4626* JIT. They take ModuleProviders for historical reasons.4627*/4628LLVMModuleProviderRef4629LLVMCreateModuleProviderForExistingModule(LLVMModuleRef M);46304631/**4632* Destroys the module M.4633*/4634void LLVMDisposeModuleProvider(LLVMModuleProviderRef M);46354636/**4637* @}4638*/46394640/**4641* @defgroup LLVMCCoreMemoryBuffers Memory Buffers4642*4643* @{4644*/46454646LLVMBool LLVMCreateMemoryBufferWithContentsOfFile(const char *Path,4647LLVMMemoryBufferRef *OutMemBuf,4648char **OutMessage);4649LLVMBool LLVMCreateMemoryBufferWithSTDIN(LLVMMemoryBufferRef *OutMemBuf,4650char **OutMessage);4651LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRange(const char *InputData,4652size_t InputDataLength,4653const char *BufferName,4654LLVMBool RequiresNullTerminator);4655LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRangeCopy(const char *InputData,4656size_t InputDataLength,4657const char *BufferName);4658const char *LLVMGetBufferStart(LLVMMemoryBufferRef MemBuf);4659size_t LLVMGetBufferSize(LLVMMemoryBufferRef MemBuf);4660void LLVMDisposeMemoryBuffer(LLVMMemoryBufferRef MemBuf);46614662/**4663* @}4664*/46654666/**4667* @defgroup LLVMCCorePassManagers Pass Managers4668* @ingroup LLVMCCore4669*4670* @{4671*/46724673/** Constructs a new whole-module pass pipeline. This type of pipeline is4674suitable for link-time optimization and whole-module transformations.4675@see llvm::PassManager::PassManager */4676LLVMPassManagerRef LLVMCreatePassManager(void);46774678/** Constructs a new function-by-function pass pipeline over the module4679provider. It does not take ownership of the module provider. This type of4680pipeline is suitable for code generation and JIT compilation tasks.4681@see llvm::FunctionPassManager::FunctionPassManager */4682LLVMPassManagerRef LLVMCreateFunctionPassManagerForModule(LLVMModuleRef M);46834684/** Deprecated: Use LLVMCreateFunctionPassManagerForModule instead. */4685LLVMPassManagerRef LLVMCreateFunctionPassManager(LLVMModuleProviderRef MP);46864687/** Initializes, executes on the provided module, and finalizes all of the4688passes scheduled in the pass manager. Returns 1 if any of the passes4689modified the module, 0 otherwise.4690@see llvm::PassManager::run(Module&) */4691LLVMBool LLVMRunPassManager(LLVMPassManagerRef PM, LLVMModuleRef M);46924693/** Initializes all of the function passes scheduled in the function pass4694manager. Returns 1 if any of the passes modified the module, 0 otherwise.4695@see llvm::FunctionPassManager::doInitialization */4696LLVMBool LLVMInitializeFunctionPassManager(LLVMPassManagerRef FPM);46974698/** Executes all of the function passes scheduled in the function pass manager4699on the provided function. Returns 1 if any of the passes modified the4700function, false otherwise.4701@see llvm::FunctionPassManager::run(Function&) */4702LLVMBool LLVMRunFunctionPassManager(LLVMPassManagerRef FPM, LLVMValueRef F);47034704/** Finalizes all of the function passes scheduled in the function pass4705manager. Returns 1 if any of the passes modified the module, 0 otherwise.4706@see llvm::FunctionPassManager::doFinalization */4707LLVMBool LLVMFinalizeFunctionPassManager(LLVMPassManagerRef FPM);47084709/** Frees the memory of a pass pipeline. For function pipelines, does not free4710the module provider.4711@see llvm::PassManagerBase::~PassManagerBase. */4712void LLVMDisposePassManager(LLVMPassManagerRef PM);47134714/**4715* @}4716*/47174718/**4719* @defgroup LLVMCCoreThreading Threading4720*4721* Handle the structures needed to make LLVM safe for multithreading.4722*4723* @{4724*/47254726/** Deprecated: Multi-threading can only be enabled/disabled with the compile4727time define LLVM_ENABLE_THREADS. This function always returns4728LLVMIsMultithreaded(). */4729LLVMBool LLVMStartMultithreaded(void);47304731/** Deprecated: Multi-threading can only be enabled/disabled with the compile4732time define LLVM_ENABLE_THREADS. */4733void LLVMStopMultithreaded(void);47344735/** Check whether LLVM is executing in thread-safe mode or not.4736@see llvm::llvm_is_multithreaded */4737LLVMBool LLVMIsMultithreaded(void);47384739/**4740* @}4741*/47424743/**4744* @}4745*/47464747/**4748* @}4749*/47504751LLVM_C_EXTERN_C_END47524753#endif /* LLVM_C_CORE_H */475447554756