brintos

brintos / llvm-project-archived public Read only

0
0
Text · 167.8 KiB · 83dd1eb Raw
5136 lines · c
1/*===-- llvm-c/Core.h - Core Library C Interface ------------------*- C -*-===*\2|*                                                                            *|3|* Part of the LLVM Project, under the Apache License v2.0 with LLVM          *|4|* Exceptions.                                                                *|5|* See https://llvm.org/LICENSE.txt for license information.                  *|6|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception                    *|7|*                                                                            *|8|*===----------------------------------------------------------------------===*|9|*                                                                            *|10|* This header declares the C interface to libLLVMCore.a, which implements    *|11|* the LLVM intermediate representation.                                      *|12|*                                                                            *|13\*===----------------------------------------------------------------------===*/14 15#ifndef LLVM_C_CORE_H16#define LLVM_C_CORE_H17 18#include "llvm-c/Deprecated.h"19#include "llvm-c/ErrorHandling.h"20#include "llvm-c/ExternC.h"21#include "llvm-c/Visibility.h"22 23#include "llvm-c/Types.h"24 25LLVM_C_EXTERN_C_BEGIN26 27/**28 * @defgroup LLVMC LLVM-C: C interface to LLVM29 *30 * This module exposes parts of the LLVM library as a C API.31 *32 * @{33 */34 35/**36 * @defgroup LLVMCTransforms Transforms37 */38 39/**40 * @defgroup LLVMCCore Core41 *42 * This modules provide an interface to libLLVMCore, which implements43 * the LLVM intermediate representation as well as other related types44 * and utilities.45 *46 * Many exotic languages can interoperate with C code but have a harder time47 * with C++ due to name mangling. So in addition to C, this interface enables48 * tools written in such languages.49 *50 * @{51 */52 53/**54 * @defgroup LLVMCCoreTypes Types and Enumerations55 *56 * @{57 */58 59/// External users depend on the following values being stable. It is not safe60/// to reorder them.61typedef enum {62  /* Terminator Instructions */63  LLVMRet            = 1,64  LLVMBr             = 2,65  LLVMSwitch         = 3,66  LLVMIndirectBr     = 4,67  LLVMInvoke         = 5,68  /* removed 6 due to API changes */69  LLVMUnreachable    = 7,70  LLVMCallBr         = 67,71 72  /* Standard Unary Operators */73  LLVMFNeg           = 66,74 75  /* Standard Binary Operators */76  LLVMAdd            = 8,77  LLVMFAdd           = 9,78  LLVMSub            = 10,79  LLVMFSub           = 11,80  LLVMMul            = 12,81  LLVMFMul           = 13,82  LLVMUDiv           = 14,83  LLVMSDiv           = 15,84  LLVMFDiv           = 16,85  LLVMURem           = 17,86  LLVMSRem           = 18,87  LLVMFRem           = 19,88 89  /* Logical Operators */90  LLVMShl            = 20,91  LLVMLShr           = 21,92  LLVMAShr           = 22,93  LLVMAnd            = 23,94  LLVMOr             = 24,95  LLVMXor            = 25,96 97  /* Memory Operators */98  LLVMAlloca         = 26,99  LLVMLoad           = 27,100  LLVMStore          = 28,101  LLVMGetElementPtr  = 29,102 103  /* Cast Operators */104  LLVMTrunc          = 30,105  LLVMZExt           = 31,106  LLVMSExt           = 32,107  LLVMFPToUI         = 33,108  LLVMFPToSI         = 34,109  LLVMUIToFP         = 35,110  LLVMSIToFP         = 36,111  LLVMFPTrunc        = 37,112  LLVMFPExt          = 38,113  LLVMPtrToInt       = 39,114  LLVMPtrToAddr      = 69,115  LLVMIntToPtr       = 40,116  LLVMBitCast        = 41,117  LLVMAddrSpaceCast  = 60,118 119  /* Other Operators */120  LLVMICmp           = 42,121  LLVMFCmp           = 43,122  LLVMPHI            = 44,123  LLVMCall           = 45,124  LLVMSelect         = 46,125  LLVMUserOp1        = 47,126  LLVMUserOp2        = 48,127  LLVMVAArg          = 49,128  LLVMExtractElement = 50,129  LLVMInsertElement  = 51,130  LLVMShuffleVector  = 52,131  LLVMExtractValue   = 53,132  LLVMInsertValue    = 54,133  LLVMFreeze         = 68,134 135  /* Atomic operators */136  LLVMFence          = 55,137  LLVMAtomicCmpXchg  = 56,138  LLVMAtomicRMW      = 57,139 140  /* Exception Handling Operators */141  LLVMResume         = 58,142  LLVMLandingPad     = 59,143  LLVMCleanupRet     = 61,144  LLVMCatchRet       = 62,145  LLVMCatchPad       = 63,146  LLVMCleanupPad     = 64,147  LLVMCatchSwitch    = 65148} LLVMOpcode;149 150typedef enum {151  LLVMVoidTypeKind = 0,     /**< type with no size */152  LLVMHalfTypeKind = 1,     /**< 16 bit floating point type */153  LLVMFloatTypeKind = 2,    /**< 32 bit floating point type */154  LLVMDoubleTypeKind = 3,   /**< 64 bit floating point type */155  LLVMX86_FP80TypeKind = 4, /**< 80 bit floating point type (X87) */156  LLVMFP128TypeKind = 5, /**< 128 bit floating point type (112-bit mantissa)*/157  LLVMPPC_FP128TypeKind = 6, /**< 128 bit floating point type (two 64-bits) */158  LLVMLabelTypeKind = 7,     /**< Labels */159  LLVMIntegerTypeKind = 8,   /**< Arbitrary bit width integers */160  LLVMFunctionTypeKind = 9,  /**< Functions */161  LLVMStructTypeKind = 10,   /**< Structures */162  LLVMArrayTypeKind = 11,    /**< Arrays */163  LLVMPointerTypeKind = 12,  /**< Pointers */164  LLVMVectorTypeKind = 13,   /**< Fixed width SIMD vector type */165  LLVMMetadataTypeKind = 14, /**< Metadata */166                             /* 15 previously used by LLVMX86_MMXTypeKind */167  LLVMTokenTypeKind = 16,    /**< Tokens */168  LLVMScalableVectorTypeKind = 17, /**< Scalable SIMD vector type */169  LLVMBFloatTypeKind = 18,         /**< 16 bit brain floating point type */170  LLVMX86_AMXTypeKind = 19,        /**< X86 AMX */171  LLVMTargetExtTypeKind = 20,      /**< Target extension type */172} LLVMTypeKind;173 174typedef enum {175  LLVMExternalLinkage,    /**< Externally visible function */176  LLVMAvailableExternallyLinkage,177  LLVMLinkOnceAnyLinkage, /**< Keep one copy of function when linking (inline)*/178  LLVMLinkOnceODRLinkage, /**< Same, but only replaced by something179                            equivalent. */180  LLVMLinkOnceODRAutoHideLinkage, /**< Obsolete */181  LLVMWeakAnyLinkage,     /**< Keep one copy of function when linking (weak) */182  LLVMWeakODRLinkage,     /**< Same, but only replaced by something183                            equivalent. */184  LLVMAppendingLinkage,   /**< Special purpose, only applies to global arrays */185  LLVMInternalLinkage,    /**< Rename collisions when linking (static186                               functions) */187  LLVMPrivateLinkage,     /**< Like Internal, but omit from symbol table */188  LLVMDLLImportLinkage,   /**< Obsolete */189  LLVMDLLExportLinkage,   /**< Obsolete */190  LLVMExternalWeakLinkage,/**< ExternalWeak linkage description */191  LLVMGhostLinkage,       /**< Obsolete */192  LLVMCommonLinkage,      /**< Tentative definitions */193  LLVMLinkerPrivateLinkage, /**< Like Private, but linker removes. */194  LLVMLinkerPrivateWeakLinkage /**< Like LinkerPrivate, but is weak. */195} LLVMLinkage;196 197typedef enum {198  LLVMDefaultVisibility,  /**< The GV is visible */199  LLVMHiddenVisibility,   /**< The GV is hidden */200  LLVMProtectedVisibility /**< The GV is protected */201} LLVMVisibility;202 203typedef enum {204  LLVMNoUnnamedAddr,    /**< Address of the GV is significant. */205  LLVMLocalUnnamedAddr, /**< Address of the GV is locally insignificant. */206  LLVMGlobalUnnamedAddr /**< Address of the GV is globally insignificant. */207} LLVMUnnamedAddr;208 209typedef enum {210  LLVMDefaultStorageClass   = 0,211  LLVMDLLImportStorageClass = 1, /**< Function to be imported from DLL. */212  LLVMDLLExportStorageClass = 2  /**< Function to be accessible from DLL. */213} LLVMDLLStorageClass;214 215typedef enum {216  LLVMCCallConv             = 0,217  LLVMFastCallConv          = 8,218  LLVMColdCallConv          = 9,219  LLVMGHCCallConv           = 10,220  LLVMHiPECallConv          = 11,221  LLVMAnyRegCallConv        = 13,222  LLVMPreserveMostCallConv  = 14,223  LLVMPreserveAllCallConv   = 15,224  LLVMSwiftCallConv         = 16,225  LLVMCXXFASTTLSCallConv    = 17,226  LLVMX86StdcallCallConv    = 64,227  LLVMX86FastcallCallConv   = 65,228  LLVMARMAPCSCallConv       = 66,229  LLVMARMAAPCSCallConv      = 67,230  LLVMARMAAPCSVFPCallConv   = 68,231  LLVMMSP430INTRCallConv    = 69,232  LLVMX86ThisCallCallConv   = 70,233  LLVMPTXKernelCallConv     = 71,234  LLVMPTXDeviceCallConv     = 72,235  LLVMSPIRFUNCCallConv      = 75,236  LLVMSPIRKERNELCallConv    = 76,237  LLVMIntelOCLBICallConv    = 77,238  LLVMX8664SysVCallConv     = 78,239  LLVMWin64CallConv         = 79,240  LLVMX86VectorCallCallConv = 80,241  LLVMHHVMCallConv          = 81,242  LLVMHHVMCCallConv         = 82,243  LLVMX86INTRCallConv       = 83,244  LLVMAVRINTRCallConv       = 84,245  LLVMAVRSIGNALCallConv     = 85,246  LLVMAVRBUILTINCallConv    = 86,247  LLVMAMDGPUVSCallConv      = 87,248  LLVMAMDGPUGSCallConv      = 88,249  LLVMAMDGPUPSCallConv      = 89,250  LLVMAMDGPUCSCallConv      = 90,251  LLVMAMDGPUKERNELCallConv  = 91,252  LLVMX86RegCallCallConv    = 92,253  LLVMAMDGPUHSCallConv      = 93,254  LLVMMSP430BUILTINCallConv = 94,255  LLVMAMDGPULSCallConv      = 95,256  LLVMAMDGPUESCallConv      = 96257} LLVMCallConv;258 259typedef enum {260  LLVMArgumentValueKind,261  LLVMBasicBlockValueKind,262  LLVMMemoryUseValueKind,263  LLVMMemoryDefValueKind,264  LLVMMemoryPhiValueKind,265 266  LLVMFunctionValueKind,267  LLVMGlobalAliasValueKind,268  LLVMGlobalIFuncValueKind,269  LLVMGlobalVariableValueKind,270  LLVMBlockAddressValueKind,271  LLVMConstantExprValueKind,272  LLVMConstantArrayValueKind,273  LLVMConstantStructValueKind,274  LLVMConstantVectorValueKind,275 276  LLVMUndefValueValueKind,277  LLVMConstantAggregateZeroValueKind,278  LLVMConstantDataArrayValueKind,279  LLVMConstantDataVectorValueKind,280  LLVMConstantIntValueKind,281  LLVMConstantFPValueKind,282  LLVMConstantPointerNullValueKind,283  LLVMConstantTokenNoneValueKind,284 285  LLVMMetadataAsValueValueKind,286  LLVMInlineAsmValueKind,287 288  LLVMInstructionValueKind,289  LLVMPoisonValueValueKind,290  LLVMConstantTargetNoneValueKind,291  LLVMConstantPtrAuthValueKind,292} LLVMValueKind;293 294typedef enum {295  LLVMIntEQ = 32, /**< equal */296  LLVMIntNE,      /**< not equal */297  LLVMIntUGT,     /**< unsigned greater than */298  LLVMIntUGE,     /**< unsigned greater or equal */299  LLVMIntULT,     /**< unsigned less than */300  LLVMIntULE,     /**< unsigned less or equal */301  LLVMIntSGT,     /**< signed greater than */302  LLVMIntSGE,     /**< signed greater or equal */303  LLVMIntSLT,     /**< signed less than */304  LLVMIntSLE      /**< signed less or equal */305} LLVMIntPredicate;306 307typedef enum {308  LLVMRealPredicateFalse, /**< Always false (always folded) */309  LLVMRealOEQ,            /**< True if ordered and equal */310  LLVMRealOGT,            /**< True if ordered and greater than */311  LLVMRealOGE,            /**< True if ordered and greater than or equal */312  LLVMRealOLT,            /**< True if ordered and less than */313  LLVMRealOLE,            /**< True if ordered and less than or equal */314  LLVMRealONE,            /**< True if ordered and operands are unequal */315  LLVMRealORD,            /**< True if ordered (no nans) */316  LLVMRealUNO,            /**< True if unordered: isnan(X) | isnan(Y) */317  LLVMRealUEQ,            /**< True if unordered or equal */318  LLVMRealUGT,            /**< True if unordered or greater than */319  LLVMRealUGE,            /**< True if unordered, greater than, or equal */320  LLVMRealULT,            /**< True if unordered or less than */321  LLVMRealULE,            /**< True if unordered, less than, or equal */322  LLVMRealUNE,            /**< True if unordered or not equal */323  LLVMRealPredicateTrue   /**< Always true (always folded) */324} LLVMRealPredicate;325 326typedef enum {327  LLVMNotThreadLocal = 0,328  LLVMGeneralDynamicTLSModel,329  LLVMLocalDynamicTLSModel,330  LLVMInitialExecTLSModel,331  LLVMLocalExecTLSModel332} LLVMThreadLocalMode;333 334typedef enum {335  LLVMAtomicOrderingNotAtomic = 0, /**< A load or store which is not atomic */336  LLVMAtomicOrderingUnordered = 1, /**< Lowest level of atomicity, guarantees337                                     somewhat sane results, lock free. */338  LLVMAtomicOrderingMonotonic = 2, /**< guarantees that if you take all the339                                     operations affecting a specific address,340                                     a consistent ordering exists */341  LLVMAtomicOrderingAcquire = 4, /**< Acquire provides a barrier of the sort342                                   necessary to acquire a lock to access other343                                   memory with normal loads and stores. */344  LLVMAtomicOrderingRelease = 5, /**< Release is similar to Acquire, but with345                                   a barrier of the sort necessary to release346                                   a lock. */347  LLVMAtomicOrderingAcquireRelease = 6, /**< provides both an Acquire and a348                                          Release barrier (for fences and349                                          operations which both read and write350                                           memory). */351  LLVMAtomicOrderingSequentiallyConsistent = 7 /**< provides Acquire semantics352                                                 for loads and Release353                                                 semantics for stores.354                                                 Additionally, it guarantees355                                                 that a total ordering exists356                                                 between all357                                                 SequentiallyConsistent358                                                 operations. */359} LLVMAtomicOrdering;360 361typedef enum {362  LLVMAtomicRMWBinOpXchg, /**< Set the new value and return the one old */363  LLVMAtomicRMWBinOpAdd,  /**< Add a value and return the old one */364  LLVMAtomicRMWBinOpSub,  /**< Subtract a value and return the old one */365  LLVMAtomicRMWBinOpAnd,  /**< And a value and return the old one */366  LLVMAtomicRMWBinOpNand, /**< Not-And a value and return the old one */367  LLVMAtomicRMWBinOpOr,   /**< OR a value and return the old one */368  LLVMAtomicRMWBinOpXor,  /**< Xor a value and return the old one */369  LLVMAtomicRMWBinOpMax,  /**< Sets the value if it's greater than the370                            original using a signed comparison and return371                            the old one */372  LLVMAtomicRMWBinOpMin,  /**< Sets the value if it's Smaller than the373                            original using a signed comparison and return374                            the old one */375  LLVMAtomicRMWBinOpUMax, /**< Sets the value if it's greater than the376                           original using an unsigned comparison and return377                           the old one */378  LLVMAtomicRMWBinOpUMin, /**< Sets the value if it's greater than the379                            original using an unsigned comparison and return380                            the old one */381  LLVMAtomicRMWBinOpFAdd, /**< Add a floating point value and return the382                            old one */383  LLVMAtomicRMWBinOpFSub, /**< Subtract a floating point value and return the384                          old one */385  LLVMAtomicRMWBinOpFMax, /**< Sets the value if it's greater than the386                           original using an floating point comparison and387                           return the old one */388  LLVMAtomicRMWBinOpFMin, /**< Sets the value if it's smaller than the389                           original using an floating point comparison and390                           return the old one */391  LLVMAtomicRMWBinOpUIncWrap, /**< Increments the value, wrapping back to zero392                               when incremented above input value */393  LLVMAtomicRMWBinOpUDecWrap, /**< Decrements the value, wrapping back to394                               the input value when decremented below zero */395  LLVMAtomicRMWBinOpUSubCond, /**<Subtracts the value only if no unsigned396                                 overflow */397  LLVMAtomicRMWBinOpUSubSat,  /**<Subtracts the value, clamping to zero */398  LLVMAtomicRMWBinOpFMaximum, /**< Sets the value if it's greater than the399                           original using an floating point comparison and400                           return the old one */401  LLVMAtomicRMWBinOpFMinimum, /**< Sets the value if it's smaller than the402                           original using an floating point comparison and403                           return the old one */404} LLVMAtomicRMWBinOp;405 406typedef enum {407    LLVMDSError,408    LLVMDSWarning,409    LLVMDSRemark,410    LLVMDSNote411} LLVMDiagnosticSeverity;412 413typedef enum {414  LLVMInlineAsmDialectATT,415  LLVMInlineAsmDialectIntel416} LLVMInlineAsmDialect;417 418typedef enum {419  /**420   * Emits an error if two values disagree, otherwise the resulting value is421   * that of the operands.422   *423   * @see Module::ModFlagBehavior::Error424   */425  LLVMModuleFlagBehaviorError,426  /**427   * Emits a warning if two values disagree. The result value will be the428   * operand for the flag from the first module being linked.429   *430   * @see Module::ModFlagBehavior::Warning431   */432  LLVMModuleFlagBehaviorWarning,433  /**434   * Adds a requirement that another module flag be present and have a435   * specified value after linking is performed. The value must be a metadata436   * pair, where the first element of the pair is the ID of the module flag437   * to be restricted, and the second element of the pair is the value the438   * module flag should be restricted to. This behavior can be used to439   * restrict the allowable results (via triggering of an error) of linking440   * IDs with the **Override** behavior.441   *442   * @see Module::ModFlagBehavior::Require443   */444  LLVMModuleFlagBehaviorRequire,445  /**446   * Uses the specified value, regardless of the behavior or value of the447   * other module. If both modules specify **Override**, but the values448   * differ, an error will be emitted.449   *450   * @see Module::ModFlagBehavior::Override451   */452  LLVMModuleFlagBehaviorOverride,453  /**454   * Appends the two values, which are required to be metadata nodes.455   *456   * @see Module::ModFlagBehavior::Append457   */458  LLVMModuleFlagBehaviorAppend,459  /**460   * Appends the two values, which are required to be metadata461   * nodes. However, duplicate entries in the second list are dropped462   * during the append operation.463   *464   * @see Module::ModFlagBehavior::AppendUnique465   */466  LLVMModuleFlagBehaviorAppendUnique,467} LLVMModuleFlagBehavior;468 469/**470 * Attribute index are either LLVMAttributeReturnIndex,471 * LLVMAttributeFunctionIndex or a parameter number from 1 to N.472 */473enum {474  LLVMAttributeReturnIndex = 0U,475  // ISO C restricts enumerator values to range of 'int'476  // (4294967295 is too large)477  // LLVMAttributeFunctionIndex = ~0U,478  LLVMAttributeFunctionIndex = -1,479};480 481typedef unsigned LLVMAttributeIndex;482 483/**484 * Tail call kind for LLVMSetTailCallKind and LLVMGetTailCallKind.485 *486 * Note that 'musttail' implies 'tail'.487 *488 * @see CallInst::TailCallKind489 */490typedef enum {491  LLVMTailCallKindNone = 0,492  LLVMTailCallKindTail = 1,493  LLVMTailCallKindMustTail = 2,494  LLVMTailCallKindNoTail = 3,495} LLVMTailCallKind;496 497enum {498  LLVMFastMathAllowReassoc = (1 << 0),499  LLVMFastMathNoNaNs = (1 << 1),500  LLVMFastMathNoInfs = (1 << 2),501  LLVMFastMathNoSignedZeros = (1 << 3),502  LLVMFastMathAllowReciprocal = (1 << 4),503  LLVMFastMathAllowContract = (1 << 5),504  LLVMFastMathApproxFunc = (1 << 6),505  LLVMFastMathNone = 0,506  LLVMFastMathAll = LLVMFastMathAllowReassoc | LLVMFastMathNoNaNs |507                    LLVMFastMathNoInfs | LLVMFastMathNoSignedZeros |508                    LLVMFastMathAllowReciprocal | LLVMFastMathAllowContract |509                    LLVMFastMathApproxFunc,510};511 512/**513 * Flags to indicate what fast-math-style optimizations are allowed514 * on operations.515 *516 * See https://llvm.org/docs/LangRef.html#fast-math-flags517 */518typedef unsigned LLVMFastMathFlags;519 520enum {521  LLVMGEPFlagInBounds = (1 << 0),522  LLVMGEPFlagNUSW = (1 << 1),523  LLVMGEPFlagNUW = (1 << 2),524};525 526/**527 * Flags that constrain the allowed wrap semantics of a getelementptr528 * instruction.529 *530 * See https://llvm.org/docs/LangRef.html#getelementptr-instruction531 */532typedef unsigned LLVMGEPNoWrapFlags;533 534typedef enum {535  LLVMDbgRecordLabel,536  LLVMDbgRecordDeclare,537  LLVMDbgRecordValue,538  LLVMDbgRecordAssign,539} LLVMDbgRecordKind;540 541/**542 * @}543 */544 545/** Deallocate and destroy all ManagedStatic variables.546    @see llvm::llvm_shutdown547    @see ManagedStatic */548LLVM_C_ABI void LLVMShutdown(void);549 550/*===-- Version query -----------------------------------------------------===*/551 552/**553 * Return the major, minor, and patch version of LLVM554 *555 * The version components are returned via the function's three output556 * parameters or skipped if a NULL pointer was supplied.557 */558LLVM_C_ABI void LLVMGetVersion(unsigned *Major, unsigned *Minor,559                               unsigned *Patch);560 561/*===-- Error handling ----------------------------------------------------===*/562 563LLVM_C_ABI char *LLVMCreateMessage(const char *Message);564LLVM_C_ABI void LLVMDisposeMessage(char *Message);565 566/**567 * @defgroup LLVMCCoreContext Contexts568 *569 * Contexts are execution states for the core LLVM IR system.570 *571 * Most types are tied to a context instance. Multiple contexts can572 * exist simultaneously. A single context is not thread safe. However,573 * different contexts can execute on different threads simultaneously.574 *575 * @{576 */577 578typedef void (*LLVMDiagnosticHandler)(LLVMDiagnosticInfoRef, void *);579typedef void (*LLVMYieldCallback)(LLVMContextRef, void *);580 581/**582 * Create a new context.583 *584 * Every call to this function should be paired with a call to585 * LLVMContextDispose() or the context will leak memory.586 */587LLVM_C_ABI LLVMContextRef LLVMContextCreate(void);588 589/**590 * Obtain the global context instance.591 */592LLVM_C_ABI LLVMContextRef LLVMGetGlobalContext(void);593 594/**595 * Set the diagnostic handler for this context.596 */597LLVM_C_ABI void LLVMContextSetDiagnosticHandler(LLVMContextRef C,598                                                LLVMDiagnosticHandler Handler,599                                                void *DiagnosticContext);600 601/**602 * Get the diagnostic handler of this context.603 */604LLVM_C_ABI LLVMDiagnosticHandler605LLVMContextGetDiagnosticHandler(LLVMContextRef C);606 607/**608 * Get the diagnostic context of this context.609 */610LLVM_C_ABI void *LLVMContextGetDiagnosticContext(LLVMContextRef C);611 612/**613 * Set the yield callback function for this context.614 *615 * @see LLVMContext::setYieldCallback()616 */617LLVM_C_ABI void LLVMContextSetYieldCallback(LLVMContextRef C,618                                            LLVMYieldCallback Callback,619                                            void *OpaqueHandle);620 621/**622 * Retrieve whether the given context is set to discard all value names.623 *624 * @see LLVMContext::shouldDiscardValueNames()625 */626LLVM_C_ABI LLVMBool LLVMContextShouldDiscardValueNames(LLVMContextRef C);627 628/**629 * Set whether the given context discards all value names.630 *631 * If true, only the names of GlobalValue objects will be available in the IR.632 * This can be used to save memory and runtime, especially in release mode.633 *634 * @see LLVMContext::setDiscardValueNames()635 */636LLVM_C_ABI void LLVMContextSetDiscardValueNames(LLVMContextRef C,637                                                LLVMBool Discard);638 639/**640 * Destroy a context instance.641 *642 * This should be called for every call to LLVMContextCreate() or memory643 * will be leaked.644 */645LLVM_C_ABI void LLVMContextDispose(LLVMContextRef C);646 647/**648 * Return a string representation of the DiagnosticInfo. Use649 * LLVMDisposeMessage to free the string.650 *651 * @see DiagnosticInfo::print()652 */653LLVM_C_ABI char *LLVMGetDiagInfoDescription(LLVMDiagnosticInfoRef DI);654 655/**656 * Return an enum LLVMDiagnosticSeverity.657 *658 * @see DiagnosticInfo::getSeverity()659 */660LLVM_C_ABI LLVMDiagnosticSeverity661LLVMGetDiagInfoSeverity(LLVMDiagnosticInfoRef DI);662 663LLVM_C_ABI unsigned LLVMGetMDKindIDInContext(LLVMContextRef C, const char *Name,664                                             unsigned SLen);665LLVM_C_ABI unsigned LLVMGetMDKindID(const char *Name, unsigned SLen);666 667/**668 * Maps a synchronization scope name to a ID unique within this context.669 */670LLVM_C_ABI unsigned LLVMGetSyncScopeID(LLVMContextRef C, const char *Name,671                                       size_t SLen);672 673/**674 * Return an unique id given the name of a enum attribute,675 * or 0 if no attribute by that name exists.676 *677 * See http://llvm.org/docs/LangRef.html#parameter-attributes678 * and http://llvm.org/docs/LangRef.html#function-attributes679 * for the list of available attributes.680 *681 * NB: Attribute names and/or id are subject to change without682 * going through the C API deprecation cycle.683 */684LLVM_C_ABI unsigned LLVMGetEnumAttributeKindForName(const char *Name,685                                                    size_t SLen);686LLVM_C_ABI unsigned LLVMGetLastEnumAttributeKind(void);687 688/**689 * Create an enum attribute.690 */691LLVM_C_ABI LLVMAttributeRef LLVMCreateEnumAttribute(LLVMContextRef C,692                                                    unsigned KindID,693                                                    uint64_t Val);694 695/**696 * Get the unique id corresponding to the enum attribute697 * passed as argument.698 */699LLVM_C_ABI unsigned LLVMGetEnumAttributeKind(LLVMAttributeRef A);700 701/**702 * Get the enum attribute's value. 0 is returned if none exists.703 */704LLVM_C_ABI uint64_t LLVMGetEnumAttributeValue(LLVMAttributeRef A);705 706/**707 * Create a type attribute708 */709LLVM_C_ABI LLVMAttributeRef LLVMCreateTypeAttribute(LLVMContextRef C,710                                                    unsigned KindID,711                                                    LLVMTypeRef type_ref);712 713/**714 * Get the type attribute's value.715 */716LLVM_C_ABI LLVMTypeRef LLVMGetTypeAttributeValue(LLVMAttributeRef A);717 718/**719 * Create a ConstantRange attribute.720 *721 * LowerWords and UpperWords need to be NumBits divided by 64 rounded up722 * elements long.723 */724LLVM_C_ABI LLVMAttributeRef LLVMCreateConstantRangeAttribute(725    LLVMContextRef C, unsigned KindID, unsigned NumBits,726    const uint64_t LowerWords[], const uint64_t UpperWords[]);727 728/**729 * Create a string attribute.730 */731LLVM_C_ABI LLVMAttributeRef LLVMCreateStringAttribute(LLVMContextRef C,732                                                      const char *K,733                                                      unsigned KLength,734                                                      const char *V,735                                                      unsigned VLength);736 737/**738 * Get the string attribute's kind.739 */740LLVM_C_ABI const char *LLVMGetStringAttributeKind(LLVMAttributeRef A,741                                                  unsigned *Length);742 743/**744 * Get the string attribute's value.745 */746LLVM_C_ABI const char *LLVMGetStringAttributeValue(LLVMAttributeRef A,747                                                   unsigned *Length);748 749/**750 * Check for the different types of attributes.751 */752LLVM_C_ABI LLVMBool LLVMIsEnumAttribute(LLVMAttributeRef A);753LLVM_C_ABI LLVMBool LLVMIsStringAttribute(LLVMAttributeRef A);754LLVM_C_ABI LLVMBool LLVMIsTypeAttribute(LLVMAttributeRef A);755 756/**757 * Obtain a Type from a context by its registered name.758 */759LLVM_C_ABI LLVMTypeRef LLVMGetTypeByName2(LLVMContextRef C, const char *Name);760 761/**762 * @}763 */764 765/**766 * @defgroup LLVMCCoreModule Modules767 *768 * Modules represent the top-level structure in an LLVM program. An LLVM769 * module is effectively a translation unit or a collection of770 * translation units merged together.771 *772 * @{773 */774 775/**776 * Create a new, empty module in the global context.777 *778 * This is equivalent to calling LLVMModuleCreateWithNameInContext with779 * LLVMGetGlobalContext() as the context parameter.780 *781 * Every invocation should be paired with LLVMDisposeModule() or memory782 * will be leaked.783 */784LLVM_C_ABI LLVMModuleRef LLVMModuleCreateWithName(const char *ModuleID);785 786/**787 * Create a new, empty module in a specific context.788 *789 * Every invocation should be paired with LLVMDisposeModule() or memory790 * will be leaked.791 */792LLVM_C_ABI LLVMModuleRef LLVMModuleCreateWithNameInContext(const char *ModuleID,793                                                           LLVMContextRef C);794/**795 * Return an exact copy of the specified module.796 */797LLVM_C_ABI LLVMModuleRef LLVMCloneModule(LLVMModuleRef M);798 799/**800 * Destroy a module instance.801 *802 * This must be called for every created module or memory will be803 * leaked.804 */805LLVM_C_ABI void LLVMDisposeModule(LLVMModuleRef M);806 807/**808 * Soon to be deprecated.809 * See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes810 *811 * Returns true if the module is in the new debug info mode which uses812 * non-instruction debug records instead of debug intrinsics for variable813 * location tracking.814 */815LLVM_C_ABI LLVMBool LLVMIsNewDbgInfoFormat(LLVMModuleRef M);816 817/**818 * Soon to be deprecated.819 * See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes820 *821 * Convert module into desired debug info format.822 */823LLVM_C_ABI void LLVMSetIsNewDbgInfoFormat(LLVMModuleRef M,824                                          LLVMBool UseNewFormat);825 826/**827 * Obtain the identifier of a module.828 *829 * @param M Module to obtain identifier of830 * @param Len Out parameter which holds the length of the returned string.831 * @return The identifier of M.832 * @see Module::getModuleIdentifier()833 */834LLVM_C_ABI const char *LLVMGetModuleIdentifier(LLVMModuleRef M, size_t *Len);835 836/**837 * Set the identifier of a module to a string Ident with length Len.838 *839 * @param M The module to set identifier840 * @param Ident The string to set M's identifier to841 * @param Len Length of Ident842 * @see Module::setModuleIdentifier()843 */844LLVM_C_ABI void LLVMSetModuleIdentifier(LLVMModuleRef M, const char *Ident,845                                        size_t Len);846 847/**848 * Obtain the module's original source file name.849 *850 * @param M Module to obtain the name of851 * @param Len Out parameter which holds the length of the returned string852 * @return The original source file name of M853 * @see Module::getSourceFileName()854 */855LLVM_C_ABI const char *LLVMGetSourceFileName(LLVMModuleRef M, size_t *Len);856 857/**858 * Set the original source file name of a module to a string Name with length859 * Len.860 *861 * @param M The module to set the source file name of862 * @param Name The string to set M's source file name to863 * @param Len Length of Name864 * @see Module::setSourceFileName()865 */866LLVM_C_ABI void LLVMSetSourceFileName(LLVMModuleRef M, const char *Name,867                                      size_t Len);868 869/**870 * Obtain the data layout for a module.871 *872 * @see Module::getDataLayoutStr()873 *874 * LLVMGetDataLayout is DEPRECATED, as the name is not only incorrect,875 * but match the name of another method on the module. Prefer the use876 * of LLVMGetDataLayoutStr, which is not ambiguous.877 */878LLVM_C_ABI const char *LLVMGetDataLayoutStr(LLVMModuleRef M);879LLVM_C_ABI const char *LLVMGetDataLayout(LLVMModuleRef M);880 881/**882 * Set the data layout for a module.883 *884 * @see Module::setDataLayout()885 */886LLVM_C_ABI void LLVMSetDataLayout(LLVMModuleRef M, const char *DataLayoutStr);887 888/**889 * Obtain the target triple for a module.890 *891 * @see Module::getTargetTriple()892 */893LLVM_C_ABI const char *LLVMGetTarget(LLVMModuleRef M);894 895/**896 * Set the target triple for a module.897 *898 * @see Module::setTargetTriple()899 */900LLVM_C_ABI void LLVMSetTarget(LLVMModuleRef M, const char *Triple);901 902/**903 * Returns the module flags as an array of flag-key-value triples.  The caller904 * is responsible for freeing this array by calling905 * \c LLVMDisposeModuleFlagsMetadata.906 *907 * @see Module::getModuleFlagsMetadata()908 */909LLVM_C_ABI LLVMModuleFlagEntry *LLVMCopyModuleFlagsMetadata(LLVMModuleRef M,910                                                            size_t *Len);911 912/**913 * Destroys module flags metadata entries.914 */915LLVM_C_ABI void LLVMDisposeModuleFlagsMetadata(LLVMModuleFlagEntry *Entries);916 917/**918 * Returns the flag behavior for a module flag entry at a specific index.919 *920 * @see Module::ModuleFlagEntry::Behavior921 */922LLVM_C_ABI LLVMModuleFlagBehavior LLVMModuleFlagEntriesGetFlagBehavior(923    LLVMModuleFlagEntry *Entries, unsigned Index);924 925/**926 * Returns the key for a module flag entry at a specific index.927 *928 * @see Module::ModuleFlagEntry::Key929 */930LLVM_C_ABI const char *LLVMModuleFlagEntriesGetKey(LLVMModuleFlagEntry *Entries,931                                                   unsigned Index, size_t *Len);932 933/**934 * Returns the metadata for a module flag entry at a specific index.935 *936 * @see Module::ModuleFlagEntry::Val937 */938LLVM_C_ABI LLVMMetadataRef939LLVMModuleFlagEntriesGetMetadata(LLVMModuleFlagEntry *Entries, unsigned Index);940 941/**942 * Add a module-level flag to the module-level flags metadata if it doesn't943 * already exist.944 *945 * @see Module::getModuleFlag()946 */947LLVM_C_ABI LLVMMetadataRef LLVMGetModuleFlag(LLVMModuleRef M, const char *Key,948                                             size_t KeyLen);949 950/**951 * Add a module-level flag to the module-level flags metadata if it doesn't952 * already exist.953 *954 * @see Module::addModuleFlag()955 */956LLVM_C_ABI void LLVMAddModuleFlag(LLVMModuleRef M,957                                  LLVMModuleFlagBehavior Behavior,958                                  const char *Key, size_t KeyLen,959                                  LLVMMetadataRef Val);960 961/**962 * Dump a representation of a module to stderr.963 *964 * @see Module::dump()965 */966LLVM_C_ABI void LLVMDumpModule(LLVMModuleRef M);967 968/**969 * Print a representation of a module to a file. The ErrorMessage needs to be970 * disposed with LLVMDisposeMessage. Returns 0 on success, 1 otherwise.971 *972 * @see Module::print()973 */974LLVM_C_ABI LLVMBool LLVMPrintModuleToFile(LLVMModuleRef M, const char *Filename,975                                          char **ErrorMessage);976 977/**978 * Return a string representation of the module. Use979 * LLVMDisposeMessage to free the string.980 *981 * @see Module::print()982 */983LLVM_C_ABI char *LLVMPrintModuleToString(LLVMModuleRef M);984 985/**986 * Get inline assembly for a module.987 *988 * @see Module::getModuleInlineAsm()989 */990LLVM_C_ABI const char *LLVMGetModuleInlineAsm(LLVMModuleRef M, size_t *Len);991 992/**993 * Set inline assembly for a module.994 *995 * @see Module::setModuleInlineAsm()996 */997LLVM_C_ABI void LLVMSetModuleInlineAsm2(LLVMModuleRef M, const char *Asm,998                                        size_t Len);999 1000/**1001 * Append inline assembly to a module.1002 *1003 * @see Module::appendModuleInlineAsm()1004 */1005LLVM_C_ABI void LLVMAppendModuleInlineAsm(LLVMModuleRef M, const char *Asm,1006                                          size_t Len);1007 1008/**1009 * Create the specified uniqued inline asm string.1010 *1011 * @see InlineAsm::get()1012 */1013LLVM_C_ABI LLVMValueRef LLVMGetInlineAsm(1014    LLVMTypeRef Ty, const char *AsmString, size_t AsmStringSize,1015    const char *Constraints, size_t ConstraintsSize, LLVMBool HasSideEffects,1016    LLVMBool IsAlignStack, LLVMInlineAsmDialect Dialect, LLVMBool CanThrow);1017 1018/**1019 * Get the template string used for an inline assembly snippet1020 *1021 */1022LLVM_C_ABI const char *LLVMGetInlineAsmAsmString(LLVMValueRef InlineAsmVal,1023                                                 size_t *Len);1024 1025/**1026 * Get the raw constraint string for an inline assembly snippet1027 *1028 */1029LLVM_C_ABI const char *1030LLVMGetInlineAsmConstraintString(LLVMValueRef InlineAsmVal, size_t *Len);1031 1032/**1033 * Get the dialect used by the inline asm snippet1034 *1035 */1036LLVM_C_ABI LLVMInlineAsmDialect1037LLVMGetInlineAsmDialect(LLVMValueRef InlineAsmVal);1038 1039/**1040 * Get the function type of the inline assembly snippet. The same type that1041 * was passed into LLVMGetInlineAsm originally1042 *1043 * @see LLVMGetInlineAsm1044 *1045 */1046LLVM_C_ABI LLVMTypeRef LLVMGetInlineAsmFunctionType(LLVMValueRef InlineAsmVal);1047 1048/**1049 * Get if the inline asm snippet has side effects1050 *1051 */1052LLVM_C_ABI LLVMBool LLVMGetInlineAsmHasSideEffects(LLVMValueRef InlineAsmVal);1053 1054/**1055 * Get if the inline asm snippet needs an aligned stack1056 *1057 */1058LLVM_C_ABI LLVMBool1059LLVMGetInlineAsmNeedsAlignedStack(LLVMValueRef InlineAsmVal);1060 1061/**1062 * Get if the inline asm snippet may unwind the stack1063 *1064 */1065LLVM_C_ABI LLVMBool LLVMGetInlineAsmCanUnwind(LLVMValueRef InlineAsmVal);1066 1067/**1068 * Obtain the context to which this module is associated.1069 *1070 * @see Module::getContext()1071 */1072LLVM_C_ABI LLVMContextRef LLVMGetModuleContext(LLVMModuleRef M);1073 1074/** Deprecated: Use LLVMGetTypeByName2 instead. */1075LLVM_C_ABI LLVMTypeRef LLVMGetTypeByName(LLVMModuleRef M, const char *Name);1076 1077/**1078 * Obtain an iterator to the first NamedMDNode in a Module.1079 *1080 * @see llvm::Module::named_metadata_begin()1081 */1082LLVM_C_ABI LLVMNamedMDNodeRef LLVMGetFirstNamedMetadata(LLVMModuleRef M);1083 1084/**1085 * Obtain an iterator to the last NamedMDNode in a Module.1086 *1087 * @see llvm::Module::named_metadata_end()1088 */1089LLVM_C_ABI LLVMNamedMDNodeRef LLVMGetLastNamedMetadata(LLVMModuleRef M);1090 1091/**1092 * Advance a NamedMDNode iterator to the next NamedMDNode.1093 *1094 * Returns NULL if the iterator was already at the end and there are no more1095 * named metadata nodes.1096 */1097LLVM_C_ABI LLVMNamedMDNodeRef1098LLVMGetNextNamedMetadata(LLVMNamedMDNodeRef NamedMDNode);1099 1100/**1101 * Decrement a NamedMDNode iterator to the previous NamedMDNode.1102 *1103 * Returns NULL if the iterator was already at the beginning and there are1104 * no previous named metadata nodes.1105 */1106LLVM_C_ABI LLVMNamedMDNodeRef1107LLVMGetPreviousNamedMetadata(LLVMNamedMDNodeRef NamedMDNode);1108 1109/**1110 * Retrieve a NamedMDNode with the given name, returning NULL if no such1111 * node exists.1112 *1113 * @see llvm::Module::getNamedMetadata()1114 */1115LLVM_C_ABI LLVMNamedMDNodeRef LLVMGetNamedMetadata(LLVMModuleRef M,1116                                                   const char *Name,1117                                                   size_t NameLen);1118 1119/**1120 * Retrieve a NamedMDNode with the given name, creating a new node if no such1121 * node exists.1122 *1123 * @see llvm::Module::getOrInsertNamedMetadata()1124 */1125LLVM_C_ABI LLVMNamedMDNodeRef LLVMGetOrInsertNamedMetadata(LLVMModuleRef M,1126                                                           const char *Name,1127                                                           size_t NameLen);1128 1129/**1130 * Retrieve the name of a NamedMDNode.1131 *1132 * @see llvm::NamedMDNode::getName()1133 */1134LLVM_C_ABI const char *LLVMGetNamedMetadataName(LLVMNamedMDNodeRef NamedMD,1135                                                size_t *NameLen);1136 1137/**1138 * Obtain the number of operands for named metadata in a module.1139 *1140 * @see llvm::Module::getNamedMetadata()1141 */1142LLVM_C_ABI unsigned LLVMGetNamedMetadataNumOperands(LLVMModuleRef M,1143                                                    const char *Name);1144 1145/**1146 * Obtain the named metadata operands for a module.1147 *1148 * The passed LLVMValueRef pointer should refer to an array of1149 * LLVMValueRef at least LLVMGetNamedMetadataNumOperands long. This1150 * array will be populated with the LLVMValueRef instances. Each1151 * instance corresponds to a llvm::MDNode.1152 *1153 * @see llvm::Module::getNamedMetadata()1154 * @see llvm::MDNode::getOperand()1155 */1156LLVM_C_ABI void LLVMGetNamedMetadataOperands(LLVMModuleRef M, const char *Name,1157                                             LLVMValueRef *Dest);1158 1159/**1160 * Add an operand to named metadata.1161 *1162 * @see llvm::Module::getNamedMetadata()1163 * @see llvm::MDNode::addOperand()1164 */1165LLVM_C_ABI void LLVMAddNamedMetadataOperand(LLVMModuleRef M, const char *Name,1166                                            LLVMValueRef Val);1167 1168/**1169 * Return the directory of the debug location for this value, which must be1170 * an llvm::Instruction, llvm::GlobalVariable, or llvm::Function.1171 *1172 * @see llvm::Instruction::getDebugLoc()1173 * @see llvm::GlobalVariable::getDebugInfo()1174 * @see llvm::Function::getSubprogram()1175 */1176LLVM_C_ABI const char *LLVMGetDebugLocDirectory(LLVMValueRef Val,1177                                                unsigned *Length);1178 1179/**1180 * Return the filename of the debug location for this value, which must be1181 * an llvm::Instruction, llvm::GlobalVariable, or llvm::Function.1182 *1183 * @see llvm::Instruction::getDebugLoc()1184 * @see llvm::GlobalVariable::getDebugInfo()1185 * @see llvm::Function::getSubprogram()1186 */1187LLVM_C_ABI const char *LLVMGetDebugLocFilename(LLVMValueRef Val,1188                                               unsigned *Length);1189 1190/**1191 * Return the line number of the debug location for this value, which must be1192 * an llvm::Instruction, llvm::GlobalVariable, or llvm::Function.1193 *1194 * @see llvm::Instruction::getDebugLoc()1195 * @see llvm::GlobalVariable::getDebugInfo()1196 * @see llvm::Function::getSubprogram()1197 */1198LLVM_C_ABI unsigned LLVMGetDebugLocLine(LLVMValueRef Val);1199 1200/**1201 * Return the column number of the debug location for this value, which must be1202 * an llvm::Instruction.1203 *1204 * @see llvm::Instruction::getDebugLoc()1205 */1206LLVM_C_ABI unsigned LLVMGetDebugLocColumn(LLVMValueRef Val);1207 1208/**1209 * Add a function to a module under a specified name.1210 *1211 * @see llvm::Function::Create()1212 */1213LLVM_C_ABI LLVMValueRef LLVMAddFunction(LLVMModuleRef M, const char *Name,1214                                        LLVMTypeRef FunctionTy);1215 1216/**1217 * Obtain or insert a function into a module.1218 *1219 * If a function with the specified name already exists in the module, it1220 * is returned. Otherwise, a new function is created in the module with the1221 * specified name and type and is returned.1222 *1223 * The returned value corresponds to a llvm::Function instance.1224 *1225 * @see llvm::Module::getOrInsertFunction()1226 */1227LLVM_C_ABI LLVMValueRef LLVMGetOrInsertFunction(LLVMModuleRef M,1228                                                const char *Name,1229                                                size_t NameLen,1230                                                LLVMTypeRef FunctionTy);1231 1232/**1233 * Obtain a Function value from a Module by its name.1234 *1235 * The returned value corresponds to a llvm::Function value.1236 *1237 * @see llvm::Module::getFunction()1238 */1239LLVM_C_ABI LLVMValueRef LLVMGetNamedFunction(LLVMModuleRef M, const char *Name);1240 1241/**1242 * Obtain a Function value from a Module by its name.1243 *1244 * The returned value corresponds to a llvm::Function value.1245 *1246 * @see llvm::Module::getFunction()1247 */1248LLVM_C_ABI LLVMValueRef LLVMGetNamedFunctionWithLength(LLVMModuleRef M,1249                                                       const char *Name,1250                                                       size_t Length);1251 1252/**1253 * Obtain an iterator to the first Function in a Module.1254 *1255 * @see llvm::Module::begin()1256 */1257LLVM_C_ABI LLVMValueRef LLVMGetFirstFunction(LLVMModuleRef M);1258 1259/**1260 * Obtain an iterator to the last Function in a Module.1261 *1262 * @see llvm::Module::end()1263 */1264LLVM_C_ABI LLVMValueRef LLVMGetLastFunction(LLVMModuleRef M);1265 1266/**1267 * Advance a Function iterator to the next Function.1268 *1269 * Returns NULL if the iterator was already at the end and there are no more1270 * functions.1271 */1272LLVM_C_ABI LLVMValueRef LLVMGetNextFunction(LLVMValueRef Fn);1273 1274/**1275 * Decrement a Function iterator to the previous Function.1276 *1277 * Returns NULL if the iterator was already at the beginning and there are1278 * no previous functions.1279 */1280LLVM_C_ABI LLVMValueRef LLVMGetPreviousFunction(LLVMValueRef Fn);1281 1282/** Deprecated: Use LLVMSetModuleInlineAsm2 instead. */1283LLVM_C_ABI void LLVMSetModuleInlineAsm(LLVMModuleRef M, const char *Asm);1284 1285/**1286 * @}1287 */1288 1289/**1290 * @defgroup LLVMCCoreType Types1291 *1292 * Types represent the type of a value.1293 *1294 * Types are associated with a context instance. The context internally1295 * deduplicates types so there is only 1 instance of a specific type1296 * alive at a time. In other words, a unique type is shared among all1297 * consumers within a context.1298 *1299 * A Type in the C API corresponds to llvm::Type.1300 *1301 * Types have the following hierarchy:1302 *1303 *   types:1304 *     integer type1305 *     real type1306 *     function type1307 *     sequence types:1308 *       array type1309 *       pointer type1310 *       vector type1311 *     void type1312 *     label type1313 *     opaque type1314 *1315 * @{1316 */1317 1318/**1319 * Obtain the enumerated type of a Type instance.1320 *1321 * @see llvm::Type:getTypeID()1322 */1323LLVM_C_ABI LLVMTypeKind LLVMGetTypeKind(LLVMTypeRef Ty);1324 1325/**1326 * Whether the type has a known size.1327 *1328 * Things that don't have a size are abstract types, labels, and void.a1329 *1330 * @see llvm::Type::isSized()1331 */1332LLVM_C_ABI LLVMBool LLVMTypeIsSized(LLVMTypeRef Ty);1333 1334/**1335 * Obtain the context to which this type instance is associated.1336 *1337 * @see llvm::Type::getContext()1338 */1339LLVM_C_ABI LLVMContextRef LLVMGetTypeContext(LLVMTypeRef Ty);1340 1341/**1342 * Dump a representation of a type to stderr.1343 *1344 * @see llvm::Type::dump()1345 */1346LLVM_C_ABI void LLVMDumpType(LLVMTypeRef Val);1347 1348/**1349 * Return a string representation of the type. Use1350 * LLVMDisposeMessage to free the string.1351 *1352 * @see llvm::Type::print()1353 */1354LLVM_C_ABI char *LLVMPrintTypeToString(LLVMTypeRef Val);1355 1356/**1357 * @defgroup LLVMCCoreTypeInt Integer Types1358 *1359 * Functions in this section operate on integer types.1360 *1361 * @{1362 */1363 1364/**1365 * Obtain an integer type from a context with specified bit width.1366 */1367LLVM_C_ABI LLVMTypeRef LLVMInt1TypeInContext(LLVMContextRef C);1368LLVM_C_ABI LLVMTypeRef LLVMInt8TypeInContext(LLVMContextRef C);1369LLVM_C_ABI LLVMTypeRef LLVMInt16TypeInContext(LLVMContextRef C);1370LLVM_C_ABI LLVMTypeRef LLVMInt32TypeInContext(LLVMContextRef C);1371LLVM_C_ABI LLVMTypeRef LLVMInt64TypeInContext(LLVMContextRef C);1372LLVM_C_ABI LLVMTypeRef LLVMInt128TypeInContext(LLVMContextRef C);1373LLVM_C_ABI LLVMTypeRef LLVMIntTypeInContext(LLVMContextRef C, unsigned NumBits);1374 1375/**1376 * Obtain an integer type from the global context with a specified bit1377 * width.1378 */1379LLVM_C_ABI LLVMTypeRef LLVMInt1Type(void);1380LLVM_C_ABI LLVMTypeRef LLVMInt8Type(void);1381LLVM_C_ABI LLVMTypeRef LLVMInt16Type(void);1382LLVM_C_ABI LLVMTypeRef LLVMInt32Type(void);1383LLVM_C_ABI LLVMTypeRef LLVMInt64Type(void);1384LLVM_C_ABI LLVMTypeRef LLVMInt128Type(void);1385LLVM_C_ABI LLVMTypeRef LLVMIntType(unsigned NumBits);1386LLVM_C_ABI unsigned LLVMGetIntTypeWidth(LLVMTypeRef IntegerTy);1387 1388/**1389 * @}1390 */1391 1392/**1393 * @defgroup LLVMCCoreTypeFloat Floating Point Types1394 *1395 * @{1396 */1397 1398/**1399 * Obtain a 16-bit floating point type from a context.1400 */1401LLVM_C_ABI LLVMTypeRef LLVMHalfTypeInContext(LLVMContextRef C);1402 1403/**1404 * Obtain a 16-bit brain floating point type from a context.1405 */1406LLVM_C_ABI LLVMTypeRef LLVMBFloatTypeInContext(LLVMContextRef C);1407 1408/**1409 * Obtain a 32-bit floating point type from a context.1410 */1411LLVM_C_ABI LLVMTypeRef LLVMFloatTypeInContext(LLVMContextRef C);1412 1413/**1414 * Obtain a 64-bit floating point type from a context.1415 */1416LLVM_C_ABI LLVMTypeRef LLVMDoubleTypeInContext(LLVMContextRef C);1417 1418/**1419 * Obtain a 80-bit floating point type (X87) from a context.1420 */1421LLVM_C_ABI LLVMTypeRef LLVMX86FP80TypeInContext(LLVMContextRef C);1422 1423/**1424 * Obtain a 128-bit floating point type (112-bit mantissa) from a1425 * context.1426 */1427LLVM_C_ABI LLVMTypeRef LLVMFP128TypeInContext(LLVMContextRef C);1428 1429/**1430 * Obtain a 128-bit floating point type (two 64-bits) from a context.1431 */1432LLVM_C_ABI LLVMTypeRef LLVMPPCFP128TypeInContext(LLVMContextRef C);1433 1434/**1435 * Obtain a floating point type from the global context.1436 *1437 * These map to the functions in this group of the same name.1438 */1439LLVM_C_ABI LLVMTypeRef LLVMHalfType(void);1440LLVM_C_ABI LLVMTypeRef LLVMBFloatType(void);1441LLVM_C_ABI LLVMTypeRef LLVMFloatType(void);1442LLVM_C_ABI LLVMTypeRef LLVMDoubleType(void);1443LLVM_C_ABI LLVMTypeRef LLVMX86FP80Type(void);1444LLVM_C_ABI LLVMTypeRef LLVMFP128Type(void);1445LLVM_C_ABI LLVMTypeRef LLVMPPCFP128Type(void);1446 1447/**1448 * @}1449 */1450 1451/**1452 * @defgroup LLVMCCoreTypeFunction Function Types1453 *1454 * @{1455 */1456 1457/**1458 * Obtain a function type consisting of a specified signature.1459 *1460 * The function is defined as a tuple of a return Type, a list of1461 * parameter types, and whether the function is variadic.1462 */1463LLVM_C_ABI LLVMTypeRef LLVMFunctionType(LLVMTypeRef ReturnType,1464                                        LLVMTypeRef *ParamTypes,1465                                        unsigned ParamCount, LLVMBool IsVarArg);1466 1467/**1468 * Returns whether a function type is variadic.1469 */1470LLVM_C_ABI LLVMBool LLVMIsFunctionVarArg(LLVMTypeRef FunctionTy);1471 1472/**1473 * Obtain the Type this function Type returns.1474 */1475LLVM_C_ABI LLVMTypeRef LLVMGetReturnType(LLVMTypeRef FunctionTy);1476 1477/**1478 * Obtain the number of parameters this function accepts.1479 */1480LLVM_C_ABI unsigned LLVMCountParamTypes(LLVMTypeRef FunctionTy);1481 1482/**1483 * Obtain the types of a function's parameters.1484 *1485 * The Dest parameter should point to a pre-allocated array of1486 * LLVMTypeRef at least LLVMCountParamTypes() large. On return, the1487 * first LLVMCountParamTypes() entries in the array will be populated1488 * with LLVMTypeRef instances.1489 *1490 * @param FunctionTy The function type to operate on.1491 * @param Dest Memory address of an array to be filled with result.1492 */1493LLVM_C_ABI void LLVMGetParamTypes(LLVMTypeRef FunctionTy, LLVMTypeRef *Dest);1494 1495/**1496 * @}1497 */1498 1499/**1500 * @defgroup LLVMCCoreTypeStruct Structure Types1501 *1502 * These functions relate to LLVMTypeRef instances.1503 *1504 * @see llvm::StructType1505 *1506 * @{1507 */1508 1509/**1510 * Create a new structure type in a context.1511 *1512 * A structure is specified by a list of inner elements/types and1513 * whether these can be packed together.1514 *1515 * @see llvm::StructType::create()1516 */1517LLVM_C_ABI LLVMTypeRef LLVMStructTypeInContext(LLVMContextRef C,1518                                               LLVMTypeRef *ElementTypes,1519                                               unsigned ElementCount,1520                                               LLVMBool Packed);1521 1522/**1523 * Create a new structure type in the global context.1524 *1525 * @see llvm::StructType::create()1526 */1527LLVM_C_ABI LLVMTypeRef LLVMStructType(LLVMTypeRef *ElementTypes,1528                                      unsigned ElementCount, LLVMBool Packed);1529 1530/**1531 * Create an empty structure in a context having a specified name.1532 *1533 * @see llvm::StructType::create()1534 */1535LLVM_C_ABI LLVMTypeRef LLVMStructCreateNamed(LLVMContextRef C,1536                                             const char *Name);1537 1538/**1539 * Obtain the name of a structure.1540 *1541 * @see llvm::StructType::getName()1542 */1543LLVM_C_ABI const char *LLVMGetStructName(LLVMTypeRef Ty);1544 1545/**1546 * Set the contents of a structure type.1547 *1548 * @see llvm::StructType::setBody()1549 */1550LLVM_C_ABI void LLVMStructSetBody(LLVMTypeRef StructTy,1551                                  LLVMTypeRef *ElementTypes,1552                                  unsigned ElementCount, LLVMBool Packed);1553 1554/**1555 * Get the number of elements defined inside the structure.1556 *1557 * @see llvm::StructType::getNumElements()1558 */1559LLVM_C_ABI unsigned LLVMCountStructElementTypes(LLVMTypeRef StructTy);1560 1561/**1562 * Get the elements within a structure.1563 *1564 * The function is passed the address of a pre-allocated array of1565 * LLVMTypeRef at least LLVMCountStructElementTypes() long. After1566 * invocation, this array will be populated with the structure's1567 * elements. The objects in the destination array will have a lifetime1568 * of the structure type itself, which is the lifetime of the context it1569 * is contained in.1570 */1571LLVM_C_ABI void LLVMGetStructElementTypes(LLVMTypeRef StructTy,1572                                          LLVMTypeRef *Dest);1573 1574/**1575 * Get the type of the element at a given index in the structure.1576 *1577 * @see llvm::StructType::getTypeAtIndex()1578 */1579LLVM_C_ABI LLVMTypeRef LLVMStructGetTypeAtIndex(LLVMTypeRef StructTy,1580                                                unsigned i);1581 1582/**1583 * Determine whether a structure is packed.1584 *1585 * @see llvm::StructType::isPacked()1586 */1587LLVM_C_ABI LLVMBool LLVMIsPackedStruct(LLVMTypeRef StructTy);1588 1589/**1590 * Determine whether a structure is opaque.1591 *1592 * @see llvm::StructType::isOpaque()1593 */1594LLVM_C_ABI LLVMBool LLVMIsOpaqueStruct(LLVMTypeRef StructTy);1595 1596/**1597 * Determine whether a structure is literal.1598 *1599 * @see llvm::StructType::isLiteral()1600 */1601LLVM_C_ABI LLVMBool LLVMIsLiteralStruct(LLVMTypeRef StructTy);1602 1603/**1604 * @}1605 */1606 1607/**1608 * @defgroup LLVMCCoreTypeSequential Sequential Types1609 *1610 * Sequential types represents "arrays" of types. This is a super class1611 * for array, vector, and pointer types.1612 *1613 * @{1614 */1615 1616/**1617 * Obtain the element type of an array or vector type.1618 *1619 * @see llvm::SequentialType::getElementType()1620 */1621LLVM_C_ABI LLVMTypeRef LLVMGetElementType(LLVMTypeRef Ty);1622 1623/**1624 * Returns type's subtypes1625 *1626 * @see llvm::Type::subtypes()1627 */1628LLVM_C_ABI void LLVMGetSubtypes(LLVMTypeRef Tp, LLVMTypeRef *Arr);1629 1630/**1631 *  Return the number of types in the derived type.1632 *1633 * @see llvm::Type::getNumContainedTypes()1634 */1635LLVM_C_ABI unsigned LLVMGetNumContainedTypes(LLVMTypeRef Tp);1636 1637/**1638 * Create a fixed size array type that refers to a specific type.1639 *1640 * The created type will exist in the context that its element type1641 * exists in.1642 *1643 * @deprecated LLVMArrayType is deprecated in favor of the API accurate1644 * LLVMArrayType21645 * @see llvm::ArrayType::get()1646 */1647LLVM_C_ABI LLVMTypeRef LLVMArrayType(LLVMTypeRef ElementType,1648                                     unsigned ElementCount);1649 1650/**1651 * Create a fixed size array type that refers to a specific type.1652 *1653 * The created type will exist in the context that its element type1654 * exists in.1655 *1656 * @see llvm::ArrayType::get()1657 */1658LLVM_C_ABI LLVMTypeRef LLVMArrayType2(LLVMTypeRef ElementType,1659                                      uint64_t ElementCount);1660 1661/**1662 * Obtain the length of an array type.1663 *1664 * This only works on types that represent arrays.1665 *1666 * @deprecated LLVMGetArrayLength is deprecated in favor of the API accurate1667 * LLVMGetArrayLength21668 * @see llvm::ArrayType::getNumElements()1669 */1670LLVM_C_ABI unsigned LLVMGetArrayLength(LLVMTypeRef ArrayTy);1671 1672/**1673 * Obtain the length of an array type.1674 *1675 * This only works on types that represent arrays.1676 *1677 * @see llvm::ArrayType::getNumElements()1678 */1679LLVM_C_ABI uint64_t LLVMGetArrayLength2(LLVMTypeRef ArrayTy);1680 1681/**1682 * Create a pointer type that points to a defined type.1683 *1684 * The created type will exist in the context that its pointee type1685 * exists in.1686 *1687 * @see llvm::PointerType::get()1688 */1689LLVM_C_ABI LLVMTypeRef LLVMPointerType(LLVMTypeRef ElementType,1690                                       unsigned AddressSpace);1691 1692/**1693 * Determine whether a pointer is opaque.1694 *1695 * True if this is an instance of an opaque PointerType.1696 *1697 * @see llvm::Type::isOpaquePointerTy()1698 */1699LLVM_C_ABI LLVMBool LLVMPointerTypeIsOpaque(LLVMTypeRef Ty);1700 1701/**1702 * Create an opaque pointer type in a context.1703 *1704 * @see llvm::PointerType::get()1705 */1706LLVM_C_ABI LLVMTypeRef LLVMPointerTypeInContext(LLVMContextRef C,1707                                                unsigned AddressSpace);1708 1709/**1710 * Obtain the address space of a pointer type.1711 *1712 * This only works on types that represent pointers.1713 *1714 * @see llvm::PointerType::getAddressSpace()1715 */1716LLVM_C_ABI unsigned LLVMGetPointerAddressSpace(LLVMTypeRef PointerTy);1717 1718/**1719 * Create a vector type that contains a defined type and has a specific1720 * number of elements.1721 *1722 * The created type will exist in the context thats its element type1723 * exists in.1724 *1725 * @see llvm::VectorType::get()1726 */1727LLVM_C_ABI LLVMTypeRef LLVMVectorType(LLVMTypeRef ElementType,1728                                      unsigned ElementCount);1729 1730/**1731 * Create a vector type that contains a defined type and has a scalable1732 * number of elements.1733 *1734 * The created type will exist in the context thats its element type1735 * exists in.1736 *1737 * @see llvm::ScalableVectorType::get()1738 */1739LLVM_C_ABI LLVMTypeRef LLVMScalableVectorType(LLVMTypeRef ElementType,1740                                              unsigned ElementCount);1741 1742/**1743 * Obtain the (possibly scalable) number of elements in a vector type.1744 *1745 * This only works on types that represent vectors (fixed or scalable).1746 *1747 * @see llvm::VectorType::getNumElements()1748 */1749LLVM_C_ABI unsigned LLVMGetVectorSize(LLVMTypeRef VectorTy);1750 1751/**1752 * Get the pointer value for the associated ConstantPtrAuth constant.1753 *1754 * @see llvm::ConstantPtrAuth::getPointer1755 */1756LLVM_C_ABI LLVMValueRef LLVMGetConstantPtrAuthPointer(LLVMValueRef PtrAuth);1757 1758/**1759 * Get the key value for the associated ConstantPtrAuth constant.1760 *1761 * @see llvm::ConstantPtrAuth::getKey1762 */1763LLVM_C_ABI LLVMValueRef LLVMGetConstantPtrAuthKey(LLVMValueRef PtrAuth);1764 1765/**1766 * Get the discriminator value for the associated ConstantPtrAuth constant.1767 *1768 * @see llvm::ConstantPtrAuth::getDiscriminator1769 */1770LLVM_C_ABI LLVMValueRef1771LLVMGetConstantPtrAuthDiscriminator(LLVMValueRef PtrAuth);1772 1773/**1774 * Get the address discriminator value for the associated ConstantPtrAuth1775 * constant.1776 *1777 * @see llvm::ConstantPtrAuth::getAddrDiscriminator1778 */1779LLVM_C_ABI LLVMValueRef1780LLVMGetConstantPtrAuthAddrDiscriminator(LLVMValueRef PtrAuth);1781 1782/**1783 * @}1784 */1785 1786/**1787 * @defgroup LLVMCCoreTypeOther Other Types1788 *1789 * @{1790 */1791 1792/**1793 * Create a void type in a context.1794 */1795LLVM_C_ABI LLVMTypeRef LLVMVoidTypeInContext(LLVMContextRef C);1796 1797/**1798 * Create a label type in a context.1799 */1800LLVM_C_ABI LLVMTypeRef LLVMLabelTypeInContext(LLVMContextRef C);1801 1802/**1803 * Create a X86 AMX type in a context.1804 */1805LLVM_C_ABI LLVMTypeRef LLVMX86AMXTypeInContext(LLVMContextRef C);1806 1807/**1808 * Create a token type in a context.1809 */1810LLVM_C_ABI LLVMTypeRef LLVMTokenTypeInContext(LLVMContextRef C);1811 1812/**1813 * Create a metadata type in a context.1814 */1815LLVM_C_ABI LLVMTypeRef LLVMMetadataTypeInContext(LLVMContextRef C);1816 1817/**1818 * These are similar to the above functions except they operate on the1819 * global context.1820 */1821LLVM_C_ABI LLVMTypeRef LLVMVoidType(void);1822LLVM_C_ABI LLVMTypeRef LLVMLabelType(void);1823LLVM_C_ABI LLVMTypeRef LLVMX86AMXType(void);1824 1825/**1826 * Create a target extension type in LLVM context.1827 */1828LLVM_C_ABI LLVMTypeRef LLVMTargetExtTypeInContext(1829    LLVMContextRef C, const char *Name, LLVMTypeRef *TypeParams,1830    unsigned TypeParamCount, unsigned *IntParams, unsigned IntParamCount);1831 1832/**1833 * Obtain the name for this target extension type.1834 *1835 * @see llvm::TargetExtType::getName()1836 */1837LLVM_C_ABI const char *LLVMGetTargetExtTypeName(LLVMTypeRef TargetExtTy);1838 1839/**1840 * Obtain the number of type parameters for this target extension type.1841 *1842 * @see llvm::TargetExtType::getNumTypeParameters()1843 */1844LLVM_C_ABI unsigned LLVMGetTargetExtTypeNumTypeParams(LLVMTypeRef TargetExtTy);1845 1846/**1847 * Get the type parameter at the given index for the target extension type.1848 *1849 * @see llvm::TargetExtType::getTypeParameter()1850 */1851LLVM_C_ABI LLVMTypeRef LLVMGetTargetExtTypeTypeParam(LLVMTypeRef TargetExtTy,1852                                                     unsigned Idx);1853 1854/**1855 * Obtain the number of int parameters for this target extension type.1856 *1857 * @see llvm::TargetExtType::getNumIntParameters()1858 */1859LLVM_C_ABI unsigned LLVMGetTargetExtTypeNumIntParams(LLVMTypeRef TargetExtTy);1860 1861/**1862 * Get the int parameter at the given index for the target extension type.1863 *1864 * @see llvm::TargetExtType::getIntParameter()1865 */1866LLVM_C_ABI unsigned LLVMGetTargetExtTypeIntParam(LLVMTypeRef TargetExtTy,1867                                                 unsigned Idx);1868 1869/**1870 * @}1871 */1872 1873/**1874 * @}1875 */1876 1877/**1878 * @defgroup LLVMCCoreValues Values1879 *1880 * The bulk of LLVM's object model consists of values, which comprise a very1881 * rich type hierarchy.1882 *1883 * LLVMValueRef essentially represents llvm::Value. There is a rich1884 * hierarchy of classes within this type. Depending on the instance1885 * obtained, not all APIs are available.1886 *1887 * Callers can determine the type of an LLVMValueRef by calling the1888 * LLVMIsA* family of functions (e.g. LLVMIsAArgument()). These1889 * functions are defined by a macro, so it isn't obvious which are1890 * available by looking at the Doxygen source code. Instead, look at the1891 * source definition of LLVM_FOR_EACH_VALUE_SUBCLASS and note the list1892 * of value names given. These value names also correspond to classes in1893 * the llvm::Value hierarchy.1894 *1895 * @{1896 */1897 1898// Currently, clang-format tries to format the LLVM_FOR_EACH_VALUE_SUBCLASS1899// macro in a progressively-indented fashion, which is not desired1900// clang-format off1901 1902#define LLVM_FOR_EACH_VALUE_SUBCLASS(macro) \1903  macro(Argument)                           \1904  macro(BasicBlock)                         \1905  macro(InlineAsm)                          \1906  macro(User)                               \1907    macro(Constant)                         \1908      macro(BlockAddress)                   \1909      macro(ConstantAggregateZero)          \1910      macro(ConstantArray)                  \1911      macro(ConstantDataSequential)         \1912        macro(ConstantDataArray)            \1913        macro(ConstantDataVector)           \1914      macro(ConstantExpr)                   \1915      macro(ConstantFP)                     \1916      macro(ConstantInt)                    \1917      macro(ConstantPointerNull)            \1918      macro(ConstantStruct)                 \1919      macro(ConstantTokenNone)              \1920      macro(ConstantVector)                 \1921      macro(ConstantPtrAuth)                \1922      macro(GlobalValue)                    \1923        macro(GlobalAlias)                  \1924        macro(GlobalObject)                 \1925          macro(Function)                   \1926          macro(GlobalVariable)             \1927          macro(GlobalIFunc)                \1928      macro(UndefValue)                     \1929      macro(PoisonValue)                    \1930    macro(Instruction)                      \1931      macro(UnaryOperator)                  \1932      macro(BinaryOperator)                 \1933      macro(CallInst)                       \1934        macro(IntrinsicInst)                \1935          macro(DbgInfoIntrinsic)           \1936            macro(DbgVariableIntrinsic)     \1937              macro(DbgDeclareInst)         \1938            macro(DbgLabelInst)             \1939          macro(MemIntrinsic)               \1940            macro(MemCpyInst)               \1941            macro(MemMoveInst)              \1942            macro(MemSetInst)               \1943      macro(CmpInst)                        \1944        macro(FCmpInst)                     \1945        macro(ICmpInst)                     \1946      macro(ExtractElementInst)             \1947      macro(GetElementPtrInst)              \1948      macro(InsertElementInst)              \1949      macro(InsertValueInst)                \1950      macro(LandingPadInst)                 \1951      macro(PHINode)                        \1952      macro(SelectInst)                     \1953      macro(ShuffleVectorInst)              \1954      macro(StoreInst)                      \1955      macro(BranchInst)                     \1956      macro(IndirectBrInst)                 \1957      macro(InvokeInst)                     \1958      macro(ReturnInst)                     \1959      macro(SwitchInst)                     \1960      macro(UnreachableInst)                \1961      macro(ResumeInst)                     \1962      macro(CleanupReturnInst)              \1963      macro(CatchReturnInst)                \1964      macro(CatchSwitchInst)                \1965      macro(CallBrInst)                     \1966      macro(FuncletPadInst)                 \1967        macro(CatchPadInst)                 \1968        macro(CleanupPadInst)               \1969      macro(UnaryInstruction)               \1970        macro(AllocaInst)                   \1971        macro(CastInst)                     \1972          macro(AddrSpaceCastInst)          \1973          macro(BitCastInst)                \1974          macro(FPExtInst)                  \1975          macro(FPToSIInst)                 \1976          macro(FPToUIInst)                 \1977          macro(FPTruncInst)                \1978          macro(IntToPtrInst)               \1979          macro(PtrToIntInst)               \1980          macro(SExtInst)                   \1981          macro(SIToFPInst)                 \1982          macro(TruncInst)                  \1983          macro(UIToFPInst)                 \1984          macro(ZExtInst)                   \1985        macro(ExtractValueInst)             \1986        macro(LoadInst)                     \1987        macro(VAArgInst)                    \1988        macro(FreezeInst)                   \1989      macro(AtomicCmpXchgInst)              \1990      macro(AtomicRMWInst)                  \1991      macro(FenceInst)1992 1993// clang-format on1994 1995/**1996 * @defgroup LLVMCCoreValueGeneral General APIs1997 *1998 * Functions in this section work on all LLVMValueRef instances,1999 * regardless of their sub-type. They correspond to functions available2000 * on llvm::Value.2001 *2002 * @{2003 */2004 2005/**2006 * Obtain the type of a value.2007 *2008 * @see llvm::Value::getType()2009 */2010LLVM_C_ABI LLVMTypeRef LLVMTypeOf(LLVMValueRef Val);2011 2012/**2013 * Obtain the enumerated type of a Value instance.2014 *2015 * @see llvm::Value::getValueID()2016 */2017LLVM_C_ABI LLVMValueKind LLVMGetValueKind(LLVMValueRef Val);2018 2019/**2020 * Obtain the string name of a value.2021 *2022 * @see llvm::Value::getName()2023 */2024LLVM_C_ABI const char *LLVMGetValueName2(LLVMValueRef Val, size_t *Length);2025 2026/**2027 * Set the string name of a value.2028 *2029 * @see llvm::Value::setName()2030 */2031LLVM_C_ABI void LLVMSetValueName2(LLVMValueRef Val, const char *Name,2032                                  size_t NameLen);2033 2034/**2035 * Dump a representation of a value to stderr.2036 *2037 * @see llvm::Value::dump()2038 */2039LLVM_C_ABI void LLVMDumpValue(LLVMValueRef Val);2040 2041/**2042 * Return a string representation of the value. Use2043 * LLVMDisposeMessage to free the string.2044 *2045 * @see llvm::Value::print()2046 */2047LLVM_C_ABI char *LLVMPrintValueToString(LLVMValueRef Val);2048 2049/**2050 * Obtain the context to which this value is associated.2051 *2052 * @see llvm::Value::getContext()2053 */2054LLVM_C_ABI LLVMContextRef LLVMGetValueContext(LLVMValueRef Val);2055 2056/**2057 * Return a string representation of the DbgRecord. Use2058 * LLVMDisposeMessage to free the string.2059 *2060 * @see llvm::DbgRecord::print()2061 */2062LLVM_C_ABI char *LLVMPrintDbgRecordToString(LLVMDbgRecordRef Record);2063 2064/**2065 * Replace all uses of a value with another one.2066 *2067 * @see llvm::Value::replaceAllUsesWith()2068 */2069LLVM_C_ABI void LLVMReplaceAllUsesWith(LLVMValueRef OldVal,2070                                       LLVMValueRef NewVal);2071 2072/**2073 * Determine whether the specified value instance is constant.2074 */2075LLVM_C_ABI LLVMBool LLVMIsConstant(LLVMValueRef Val);2076 2077/**2078 * Determine whether a value instance is undefined.2079 */2080LLVM_C_ABI LLVMBool LLVMIsUndef(LLVMValueRef Val);2081 2082/**2083 * Determine whether a value instance is poisonous.2084 */2085LLVM_C_ABI LLVMBool LLVMIsPoison(LLVMValueRef Val);2086 2087/**2088 * Convert value instances between types.2089 *2090 * Internally, an LLVMValueRef is "pinned" to a specific type. This2091 * series of functions allows you to cast an instance to a specific2092 * type.2093 *2094 * If the cast is not valid for the specified type, NULL is returned.2095 *2096 * @see llvm::dyn_cast_or_null<>2097 */2098#define LLVM_DECLARE_VALUE_CAST(name)                                          \2099  LLVM_C_ABI LLVMValueRef LLVMIsA##name(LLVMValueRef Val);2100LLVM_FOR_EACH_VALUE_SUBCLASS(LLVM_DECLARE_VALUE_CAST)2101 2102LLVM_C_ABI LLVMValueRef LLVMIsAMDNode(LLVMValueRef Val);2103LLVM_C_ABI LLVMValueRef LLVMIsAValueAsMetadata(LLVMValueRef Val);2104LLVM_C_ABI LLVMValueRef LLVMIsAMDString(LLVMValueRef Val);2105 2106/** Deprecated: Use LLVMGetValueName2 instead. */2107LLVM_C_ABI const char *LLVMGetValueName(LLVMValueRef Val);2108/** Deprecated: Use LLVMSetValueName2 instead. */2109LLVM_C_ABI void LLVMSetValueName(LLVMValueRef Val, const char *Name);2110 2111/**2112 * @}2113 */2114 2115/**2116 * @defgroup LLVMCCoreValueUses Usage2117 *2118 * This module defines functions that allow you to inspect the uses of a2119 * LLVMValueRef.2120 *2121 * It is possible to obtain an LLVMUseRef for any LLVMValueRef instance.2122 * Each LLVMUseRef (which corresponds to a llvm::Use instance) holds a2123 * llvm::User and llvm::Value.2124 *2125 * @{2126 */2127 2128/**2129 * Obtain the first use of a value.2130 *2131 * Uses are obtained in an iterator fashion. First, call this function2132 * to obtain a reference to the first use. Then, call LLVMGetNextUse()2133 * on that instance and all subsequently obtained instances until2134 * LLVMGetNextUse() returns NULL.2135 *2136 * @see llvm::Value::use_begin()2137 */2138LLVM_C_ABI LLVMUseRef LLVMGetFirstUse(LLVMValueRef Val);2139 2140/**2141 * Obtain the next use of a value.2142 *2143 * This effectively advances the iterator. It returns NULL if you are on2144 * the final use and no more are available.2145 */2146LLVM_C_ABI LLVMUseRef LLVMGetNextUse(LLVMUseRef U);2147 2148/**2149 * Obtain the user value for a user.2150 *2151 * The returned value corresponds to a llvm::User type.2152 *2153 * @see llvm::Use::getUser()2154 */2155LLVM_C_ABI LLVMValueRef LLVMGetUser(LLVMUseRef U);2156 2157/**2158 * Obtain the value this use corresponds to.2159 *2160 * @see llvm::Use::get().2161 */2162LLVM_C_ABI LLVMValueRef LLVMGetUsedValue(LLVMUseRef U);2163 2164/**2165 * @}2166 */2167 2168/**2169 * @defgroup LLVMCCoreValueUser User value2170 *2171 * Function in this group pertain to LLVMValueRef instances that descent2172 * from llvm::User. This includes constants, instructions, and2173 * operators.2174 *2175 * @{2176 */2177 2178/**2179 * Obtain an operand at a specific index in a llvm::User value.2180 *2181 * @see llvm::User::getOperand()2182 */2183LLVM_C_ABI LLVMValueRef LLVMGetOperand(LLVMValueRef Val, unsigned Index);2184 2185/**2186 * Obtain the use of an operand at a specific index in a llvm::User value.2187 *2188 * @see llvm::User::getOperandUse()2189 */2190LLVM_C_ABI LLVMUseRef LLVMGetOperandUse(LLVMValueRef Val, unsigned Index);2191 2192/**2193 * Set an operand at a specific index in a llvm::User value.2194 *2195 * @see llvm::User::setOperand()2196 */2197LLVM_C_ABI void LLVMSetOperand(LLVMValueRef User, unsigned Index,2198                               LLVMValueRef Val);2199 2200/**2201 * Obtain the number of operands in a llvm::User value.2202 *2203 * @see llvm::User::getNumOperands()2204 */2205LLVM_C_ABI int LLVMGetNumOperands(LLVMValueRef Val);2206 2207/**2208 * @}2209 */2210 2211/**2212 * @defgroup LLVMCCoreValueConstant Constants2213 *2214 * This section contains APIs for interacting with LLVMValueRef that2215 * correspond to llvm::Constant instances.2216 *2217 * These functions will work for any LLVMValueRef in the llvm::Constant2218 * class hierarchy.2219 *2220 * @{2221 */2222 2223/**2224 * Obtain a constant value referring to the null instance of a type.2225 *2226 * @see llvm::Constant::getNullValue()2227 */2228LLVM_C_ABI LLVMValueRef LLVMConstNull(LLVMTypeRef Ty); /* all zeroes */2229 2230/**2231 * Obtain a constant value referring to the instance of a type2232 * consisting of all ones.2233 *2234 * This is only valid for integer types.2235 *2236 * @see llvm::Constant::getAllOnesValue()2237 */2238LLVM_C_ABI LLVMValueRef LLVMConstAllOnes(LLVMTypeRef Ty);2239 2240/**2241 * Obtain a constant value referring to an undefined value of a type.2242 *2243 * @see llvm::UndefValue::get()2244 */2245LLVM_C_ABI LLVMValueRef LLVMGetUndef(LLVMTypeRef Ty);2246 2247/**2248 * Obtain a constant value referring to a poison value of a type.2249 *2250 * @see llvm::PoisonValue::get()2251 */2252LLVM_C_ABI LLVMValueRef LLVMGetPoison(LLVMTypeRef Ty);2253 2254/**2255 * Determine whether a value instance is null.2256 *2257 * @see llvm::Constant::isNullValue()2258 */2259LLVM_C_ABI LLVMBool LLVMIsNull(LLVMValueRef Val);2260 2261/**2262 * Obtain a constant that is a constant pointer pointing to NULL for a2263 * specified type.2264 */2265LLVM_C_ABI LLVMValueRef LLVMConstPointerNull(LLVMTypeRef Ty);2266 2267/**2268 * @defgroup LLVMCCoreValueConstantScalar Scalar constants2269 *2270 * Functions in this group model LLVMValueRef instances that correspond2271 * to constants referring to scalar types.2272 *2273 * For integer types, the LLVMTypeRef parameter should correspond to a2274 * llvm::IntegerType instance and the returned LLVMValueRef will2275 * correspond to a llvm::ConstantInt.2276 *2277 * For floating point types, the LLVMTypeRef returned corresponds to a2278 * llvm::ConstantFP.2279 *2280 * @{2281 */2282 2283/**2284 * Obtain a constant value for an integer type.2285 *2286 * The returned value corresponds to a llvm::ConstantInt.2287 *2288 * @see llvm::ConstantInt::get()2289 *2290 * @param IntTy Integer type to obtain value of.2291 * @param N The value the returned instance should refer to.2292 * @param SignExtend Whether to sign extend the produced value.2293 */2294LLVM_C_ABI LLVMValueRef LLVMConstInt(LLVMTypeRef IntTy, unsigned long long N,2295                                     LLVMBool SignExtend);2296 2297/**2298 * Obtain a constant value for an integer of arbitrary precision.2299 *2300 * @see llvm::ConstantInt::get()2301 */2302LLVM_C_ABI LLVMValueRef LLVMConstIntOfArbitraryPrecision(2303    LLVMTypeRef IntTy, unsigned NumWords, const uint64_t Words[]);2304 2305/**2306 * Obtain a constant value for an integer parsed from a string.2307 *2308 * A similar API, LLVMConstIntOfStringAndSize is also available. If the2309 * string's length is available, it is preferred to call that function2310 * instead.2311 *2312 * @see llvm::ConstantInt::get()2313 */2314LLVM_C_ABI LLVMValueRef LLVMConstIntOfString(LLVMTypeRef IntTy,2315                                             const char *Text, uint8_t Radix);2316 2317/**2318 * Obtain a constant value for an integer parsed from a string with2319 * specified length.2320 *2321 * @see llvm::ConstantInt::get()2322 */2323LLVM_C_ABI LLVMValueRef LLVMConstIntOfStringAndSize(LLVMTypeRef IntTy,2324                                                    const char *Text,2325                                                    unsigned SLen,2326                                                    uint8_t Radix);2327 2328/**2329 * Obtain a constant value referring to a double floating point value.2330 */2331LLVM_C_ABI LLVMValueRef LLVMConstReal(LLVMTypeRef RealTy, double N);2332 2333/**2334 * Obtain a constant for a floating point value parsed from a string.2335 *2336 * A similar API, LLVMConstRealOfStringAndSize is also available. It2337 * should be used if the input string's length is known.2338 */2339LLVM_C_ABI LLVMValueRef LLVMConstRealOfString(LLVMTypeRef RealTy,2340                                              const char *Text);2341 2342/**2343 * Obtain a constant for a floating point value parsed from a string.2344 */2345LLVM_C_ABI LLVMValueRef LLVMConstRealOfStringAndSize(LLVMTypeRef RealTy,2346                                                     const char *Text,2347                                                     unsigned SLen);2348 2349/**2350 * Obtain the zero extended value for an integer constant value.2351 *2352 * @see llvm::ConstantInt::getZExtValue()2353 */2354LLVM_C_ABI unsigned long long2355LLVMConstIntGetZExtValue(LLVMValueRef ConstantVal);2356 2357/**2358 * Obtain the sign extended value for an integer constant value.2359 *2360 * @see llvm::ConstantInt::getSExtValue()2361 */2362LLVM_C_ABI long long LLVMConstIntGetSExtValue(LLVMValueRef ConstantVal);2363 2364/**2365 * Obtain the double value for an floating point constant value.2366 * losesInfo indicates if some precision was lost in the conversion.2367 *2368 * @see llvm::ConstantFP::getDoubleValue2369 */2370LLVM_C_ABI double LLVMConstRealGetDouble(LLVMValueRef ConstantVal,2371                                         LLVMBool *losesInfo);2372 2373/**2374 * @}2375 */2376 2377/**2378 * @defgroup LLVMCCoreValueConstantComposite Composite Constants2379 *2380 * Functions in this group operate on composite constants.2381 *2382 * @{2383 */2384 2385/**2386 * Create a ConstantDataSequential and initialize it with a string.2387 *2388 * @deprecated LLVMConstStringInContext is deprecated in favor of the API2389 * accurate LLVMConstStringInContext22390 * @see llvm::ConstantDataArray::getString()2391 */2392LLVM_C_ABI LLVMValueRef LLVMConstStringInContext(LLVMContextRef C,2393                                                 const char *Str,2394                                                 unsigned Length,2395                                                 LLVMBool DontNullTerminate);2396 2397/**2398 * Create a ConstantDataSequential and initialize it with a string.2399 *2400 * @see llvm::ConstantDataArray::getString()2401 */2402LLVM_C_ABI LLVMValueRef LLVMConstStringInContext2(LLVMContextRef C,2403                                                  const char *Str,2404                                                  size_t Length,2405                                                  LLVMBool DontNullTerminate);2406 2407/**2408 * Create a ConstantDataSequential with string content in the global context.2409 *2410 * This is the same as LLVMConstStringInContext except it operates on the2411 * global context.2412 *2413 * @see LLVMConstStringInContext()2414 * @see llvm::ConstantDataArray::getString()2415 */2416LLVM_C_ABI LLVMValueRef LLVMConstString(const char *Str, unsigned Length,2417                                        LLVMBool DontNullTerminate);2418 2419/**2420 * Returns true if the specified constant is an array of i8.2421 *2422 * @see ConstantDataSequential::getAsString()2423 */2424LLVM_C_ABI LLVMBool LLVMIsConstantString(LLVMValueRef c);2425 2426/**2427 * Get the given constant data sequential as a string.2428 *2429 * @see ConstantDataSequential::getAsString()2430 */2431LLVM_C_ABI const char *LLVMGetAsString(LLVMValueRef c, size_t *Length);2432 2433/**2434 * Get the raw, underlying bytes of the given constant data sequential.2435 *2436 * This is the same as LLVMGetAsString except it works for all constant data2437 * sequentials, not just i8 arrays.2438 *2439 * @see ConstantDataSequential::getRawDataValues()2440 */2441LLVM_C_ABI const char *LLVMGetRawDataValues(LLVMValueRef c,2442                                            size_t *SizeInBytes);2443 2444/**2445 * Create an anonymous ConstantStruct with the specified values.2446 *2447 * @see llvm::ConstantStruct::getAnon()2448 */2449LLVM_C_ABI LLVMValueRef LLVMConstStructInContext(LLVMContextRef C,2450                                                 LLVMValueRef *ConstantVals,2451                                                 unsigned Count,2452                                                 LLVMBool Packed);2453 2454/**2455 * Create a ConstantStruct in the global Context.2456 *2457 * This is the same as LLVMConstStructInContext except it operates on the2458 * global Context.2459 *2460 * @see LLVMConstStructInContext()2461 */2462LLVM_C_ABI LLVMValueRef LLVMConstStruct(LLVMValueRef *ConstantVals,2463                                        unsigned Count, LLVMBool Packed);2464 2465/**2466 * Create a ConstantArray from values.2467 *2468 * @deprecated LLVMConstArray is deprecated in favor of the API accurate2469 * LLVMConstArray22470 * @see llvm::ConstantArray::get()2471 */2472LLVM_C_ABI LLVMValueRef LLVMConstArray(LLVMTypeRef ElementTy,2473                                       LLVMValueRef *ConstantVals,2474                                       unsigned Length);2475 2476/**2477 * Create a ConstantArray from values.2478 *2479 * @see llvm::ConstantArray::get()2480 */2481LLVM_C_ABI LLVMValueRef LLVMConstArray2(LLVMTypeRef ElementTy,2482                                        LLVMValueRef *ConstantVals,2483                                        uint64_t Length);2484 2485/**2486 * Create a ConstantDataArray from raw values.2487 *2488 * ElementTy must be one of i8, i16, i32, i64, half, bfloat, float, or double.2489 * Data points to a contiguous buffer of raw values in the host endianness. The2490 * element count is inferred from the element type and the data size in bytes.2491 *2492 * @see llvm::ConstantDataArray::getRaw()2493 */2494LLVM_C_ABI LLVMValueRef LLVMConstDataArray(LLVMTypeRef ElementTy,2495                                           const char *Data,2496                                           size_t SizeInBytes);2497 2498/**2499 * Create a non-anonymous ConstantStruct from values.2500 *2501 * @see llvm::ConstantStruct::get()2502 */2503LLVM_C_ABI LLVMValueRef LLVMConstNamedStruct(LLVMTypeRef StructTy,2504                                             LLVMValueRef *ConstantVals,2505                                             unsigned Count);2506 2507/**2508 * Get element of a constant aggregate (struct, array or vector) at the2509 * specified index. Returns null if the index is out of range, or it's not2510 * possible to determine the element (e.g., because the constant is a2511 * constant expression.)2512 *2513 * @see llvm::Constant::getAggregateElement()2514 */2515LLVM_C_ABI LLVMValueRef LLVMGetAggregateElement(LLVMValueRef C, unsigned Idx);2516 2517/**2518 * Get an element at specified index as a constant.2519 *2520 * @see ConstantDataSequential::getElementAsConstant()2521 */2522LLVM_C_ABI LLVM_ATTRIBUTE_C_DEPRECATED(2523    LLVMValueRef LLVMGetElementAsConstant(LLVMValueRef C, unsigned idx),2524    "Use LLVMGetAggregateElement instead");2525 2526/**2527 * Create a ConstantVector from values.2528 *2529 * @see llvm::ConstantVector::get()2530 */2531LLVM_C_ABI LLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals,2532                                        unsigned Size);2533 2534/**2535 * Create a ConstantPtrAuth constant with the given values.2536 *2537 * @see llvm::ConstantPtrAuth::get()2538 */2539LLVM_C_ABI LLVMValueRef LLVMConstantPtrAuth(LLVMValueRef Ptr, LLVMValueRef Key,2540                                            LLVMValueRef Disc,2541                                            LLVMValueRef AddrDisc);2542 2543/**2544 * @}2545 */2546 2547/**2548 * @defgroup LLVMCCoreValueConstantExpressions Constant Expressions2549 *2550 * Functions in this group correspond to APIs on llvm::ConstantExpr.2551 *2552 * @see llvm::ConstantExpr.2553 *2554 * @{2555 */2556LLVM_C_ABI LLVMOpcode LLVMGetConstOpcode(LLVMValueRef ConstantVal);2557LLVM_C_ABI LLVMValueRef LLVMAlignOf(LLVMTypeRef Ty);2558LLVM_C_ABI LLVMValueRef LLVMSizeOf(LLVMTypeRef Ty);2559LLVM_C_ABI LLVMValueRef LLVMConstNeg(LLVMValueRef ConstantVal);2560LLVM_C_ABI LLVMValueRef LLVMConstNSWNeg(LLVMValueRef ConstantVal);2561LLVM_C_ABI LLVM_ATTRIBUTE_C_DEPRECATED(2562    LLVMValueRef LLVMConstNUWNeg(LLVMValueRef ConstantVal),2563    "Use LLVMConstNull instead.");2564LLVM_C_ABI LLVMValueRef LLVMConstNot(LLVMValueRef ConstantVal);2565LLVM_C_ABI LLVMValueRef LLVMConstAdd(LLVMValueRef LHSConstant,2566                                     LLVMValueRef RHSConstant);2567LLVM_C_ABI LLVMValueRef LLVMConstNSWAdd(LLVMValueRef LHSConstant,2568                                        LLVMValueRef RHSConstant);2569LLVM_C_ABI LLVMValueRef LLVMConstNUWAdd(LLVMValueRef LHSConstant,2570                                        LLVMValueRef RHSConstant);2571LLVM_C_ABI LLVMValueRef LLVMConstSub(LLVMValueRef LHSConstant,2572                                     LLVMValueRef RHSConstant);2573LLVM_C_ABI LLVMValueRef LLVMConstNSWSub(LLVMValueRef LHSConstant,2574                                        LLVMValueRef RHSConstant);2575LLVM_C_ABI LLVMValueRef LLVMConstNUWSub(LLVMValueRef LHSConstant,2576                                        LLVMValueRef RHSConstant);2577LLVM_C_ABI LLVMValueRef LLVMConstXor(LLVMValueRef LHSConstant,2578                                     LLVMValueRef RHSConstant);2579LLVM_C_ABI LLVMValueRef LLVMConstGEP2(LLVMTypeRef Ty, LLVMValueRef ConstantVal,2580                                      LLVMValueRef *ConstantIndices,2581                                      unsigned NumIndices);2582LLVM_C_ABI LLVMValueRef LLVMConstInBoundsGEP2(LLVMTypeRef Ty,2583                                              LLVMValueRef ConstantVal,2584                                              LLVMValueRef *ConstantIndices,2585                                              unsigned NumIndices);2586/**2587 * Creates a constant GetElementPtr expression. Similar to LLVMConstGEP2, but2588 * allows specifying the no-wrap flags.2589 *2590 * @see llvm::ConstantExpr::getGetElementPtr()2591 */2592LLVM_C_ABI LLVMValueRef LLVMConstGEPWithNoWrapFlags(2593    LLVMTypeRef Ty, LLVMValueRef ConstantVal, LLVMValueRef *ConstantIndices,2594    unsigned NumIndices, LLVMGEPNoWrapFlags NoWrapFlags);2595LLVM_C_ABI LLVMValueRef LLVMConstTrunc(LLVMValueRef ConstantVal,2596                                       LLVMTypeRef ToType);2597LLVM_C_ABI LLVMValueRef LLVMConstPtrToInt(LLVMValueRef ConstantVal,2598                                          LLVMTypeRef ToType);2599LLVM_C_ABI LLVMValueRef LLVMConstIntToPtr(LLVMValueRef ConstantVal,2600                                          LLVMTypeRef ToType);2601LLVM_C_ABI LLVMValueRef LLVMConstBitCast(LLVMValueRef ConstantVal,2602                                         LLVMTypeRef ToType);2603LLVM_C_ABI LLVMValueRef LLVMConstAddrSpaceCast(LLVMValueRef ConstantVal,2604                                               LLVMTypeRef ToType);2605LLVM_C_ABI LLVMValueRef LLVMConstTruncOrBitCast(LLVMValueRef ConstantVal,2606                                                LLVMTypeRef ToType);2607LLVM_C_ABI LLVMValueRef LLVMConstPointerCast(LLVMValueRef ConstantVal,2608                                             LLVMTypeRef ToType);2609LLVM_C_ABI LLVMValueRef LLVMConstExtractElement(LLVMValueRef VectorConstant,2610                                                LLVMValueRef IndexConstant);2611LLVM_C_ABI LLVMValueRef LLVMConstInsertElement(2612    LLVMValueRef VectorConstant, LLVMValueRef ElementValueConstant,2613    LLVMValueRef IndexConstant);2614LLVM_C_ABI LLVMValueRef LLVMConstShuffleVector(LLVMValueRef VectorAConstant,2615                                               LLVMValueRef VectorBConstant,2616                                               LLVMValueRef MaskConstant);2617LLVM_C_ABI LLVMValueRef LLVMBlockAddress(LLVMValueRef F, LLVMBasicBlockRef BB);2618 2619/**2620 * Gets the function associated with a given BlockAddress constant value.2621 */2622LLVM_C_ABI LLVMValueRef LLVMGetBlockAddressFunction(LLVMValueRef BlockAddr);2623 2624/**2625 * Gets the basic block associated with a given BlockAddress constant value.2626 */2627LLVM_C_ABI LLVMBasicBlockRef2628LLVMGetBlockAddressBasicBlock(LLVMValueRef BlockAddr);2629 2630/** Deprecated: Use LLVMGetInlineAsm instead. */2631LLVM_C_ABI LLVMValueRef LLVMConstInlineAsm(LLVMTypeRef Ty,2632                                           const char *AsmString,2633                                           const char *Constraints,2634                                           LLVMBool HasSideEffects,2635                                           LLVMBool IsAlignStack);2636 2637/**2638 * @}2639 */2640 2641/**2642 * @defgroup LLVMCCoreValueConstantGlobals Global Values2643 *2644 * This group contains functions that operate on global values. Functions in2645 * this group relate to functions in the llvm::GlobalValue class tree.2646 *2647 * @see llvm::GlobalValue2648 *2649 * @{2650 */2651 2652LLVM_C_ABI LLVMModuleRef LLVMGetGlobalParent(LLVMValueRef Global);2653LLVM_C_ABI LLVMBool LLVMIsDeclaration(LLVMValueRef Global);2654LLVM_C_ABI LLVMLinkage LLVMGetLinkage(LLVMValueRef Global);2655LLVM_C_ABI void LLVMSetLinkage(LLVMValueRef Global, LLVMLinkage Linkage);2656LLVM_C_ABI const char *LLVMGetSection(LLVMValueRef Global);2657LLVM_C_ABI void LLVMSetSection(LLVMValueRef Global, const char *Section);2658LLVM_C_ABI LLVMVisibility LLVMGetVisibility(LLVMValueRef Global);2659LLVM_C_ABI void LLVMSetVisibility(LLVMValueRef Global, LLVMVisibility Viz);2660LLVM_C_ABI LLVMDLLStorageClass LLVMGetDLLStorageClass(LLVMValueRef Global);2661LLVM_C_ABI void LLVMSetDLLStorageClass(LLVMValueRef Global,2662                                       LLVMDLLStorageClass Class);2663LLVM_C_ABI LLVMUnnamedAddr LLVMGetUnnamedAddress(LLVMValueRef Global);2664LLVM_C_ABI void LLVMSetUnnamedAddress(LLVMValueRef Global,2665                                      LLVMUnnamedAddr UnnamedAddr);2666 2667/**2668 * Returns the "value type" of a global value.  This differs from the formal2669 * type of a global value which is always a pointer type.2670 *2671 * @see llvm::GlobalValue::getValueType()2672 * @see llvm::Function::getFunctionType()2673 */2674LLVM_C_ABI LLVMTypeRef LLVMGlobalGetValueType(LLVMValueRef Global);2675 2676/** Deprecated: Use LLVMGetUnnamedAddress instead. */2677LLVM_C_ABI LLVMBool LLVMHasUnnamedAddr(LLVMValueRef Global);2678/** Deprecated: Use LLVMSetUnnamedAddress instead. */2679LLVM_C_ABI void LLVMSetUnnamedAddr(LLVMValueRef Global,2680                                   LLVMBool HasUnnamedAddr);2681 2682/**2683 * @defgroup LLVMCCoreValueWithAlignment Values with alignment2684 *2685 * Functions in this group only apply to values with alignment, i.e.2686 * global variables, load and store instructions.2687 */2688 2689/**2690 * Obtain the preferred alignment of the value.2691 * @see llvm::AllocaInst::getAlignment()2692 * @see llvm::LoadInst::getAlignment()2693 * @see llvm::StoreInst::getAlignment()2694 * @see llvm::AtomicRMWInst::setAlignment()2695 * @see llvm::AtomicCmpXchgInst::setAlignment()2696 * @see llvm::GlobalValue::getAlignment()2697 */2698LLVM_C_ABI unsigned LLVMGetAlignment(LLVMValueRef V);2699 2700/**2701 * Set the preferred alignment of the value.2702 * @see llvm::AllocaInst::setAlignment()2703 * @see llvm::LoadInst::setAlignment()2704 * @see llvm::StoreInst::setAlignment()2705 * @see llvm::AtomicRMWInst::setAlignment()2706 * @see llvm::AtomicCmpXchgInst::setAlignment()2707 * @see llvm::GlobalValue::setAlignment()2708 */2709LLVM_C_ABI void LLVMSetAlignment(LLVMValueRef V, unsigned Bytes);2710 2711/**2712 * Sets a metadata attachment, erasing the existing metadata attachment if2713 * it already exists for the given kind.2714 *2715 * @see llvm::GlobalObject::setMetadata()2716 */2717LLVM_C_ABI void LLVMGlobalSetMetadata(LLVMValueRef Global, unsigned Kind,2718                                      LLVMMetadataRef MD);2719 2720/**2721 * Adds a metadata attachment.2722 *2723 * @see llvm::GlobalObject::addMetadata()2724 */2725LLVM_C_ABI void LLVMGlobalAddMetadata(LLVMValueRef Global, unsigned Kind,2726                                      LLVMMetadataRef MD);2727 2728/**2729 * Erases a metadata attachment of the given kind if it exists.2730 *2731 * @see llvm::GlobalObject::eraseMetadata()2732 */2733LLVM_C_ABI void LLVMGlobalEraseMetadata(LLVMValueRef Global, unsigned Kind);2734 2735/**2736 * Removes all metadata attachments from this value.2737 *2738 * @see llvm::GlobalObject::clearMetadata()2739 */2740LLVM_C_ABI void LLVMGlobalClearMetadata(LLVMValueRef Global);2741 2742/**2743 * Add debuginfo metadata to this global.2744 *2745 * @see llvm::GlobalVariable::addDebugInfo()2746 */2747LLVM_C_ABI void LLVMGlobalAddDebugInfo(LLVMValueRef Global,2748                                       LLVMMetadataRef GVE);2749 2750/**2751 * Retrieves an array of metadata entries representing the metadata attached to2752 * this value. The caller is responsible for freeing this array by calling2753 * \c LLVMDisposeValueMetadataEntries.2754 *2755 * @see llvm::GlobalObject::getAllMetadata()2756 */2757LLVM_C_ABI LLVMValueMetadataEntry *2758LLVMGlobalCopyAllMetadata(LLVMValueRef Value, size_t *NumEntries);2759 2760/**2761 * Destroys value metadata entries.2762 */2763LLVM_C_ABI void2764LLVMDisposeValueMetadataEntries(LLVMValueMetadataEntry *Entries);2765 2766/**2767 * Returns the kind of a value metadata entry at a specific index.2768 */2769LLVM_C_ABI unsigned2770LLVMValueMetadataEntriesGetKind(LLVMValueMetadataEntry *Entries,2771                                unsigned Index);2772 2773/**2774 * Returns the underlying metadata node of a value metadata entry at a2775 * specific index.2776 */2777LLVM_C_ABI LLVMMetadataRef LLVMValueMetadataEntriesGetMetadata(2778    LLVMValueMetadataEntry *Entries, unsigned Index);2779 2780/**2781 * @}2782 */2783 2784/**2785 * @defgroup LLVMCoreValueConstantGlobalVariable Global Variables2786 *2787 * This group contains functions that operate on global variable values.2788 *2789 * @see llvm::GlobalVariable2790 *2791 * @{2792 */2793LLVM_C_ABI LLVMValueRef LLVMAddGlobal(LLVMModuleRef M, LLVMTypeRef Ty,2794                                      const char *Name);2795LLVM_C_ABI LLVMValueRef LLVMAddGlobalInAddressSpace(LLVMModuleRef M,2796                                                    LLVMTypeRef Ty,2797                                                    const char *Name,2798                                                    unsigned AddressSpace);2799LLVM_C_ABI LLVMValueRef LLVMGetNamedGlobal(LLVMModuleRef M, const char *Name);2800LLVM_C_ABI LLVMValueRef LLVMGetNamedGlobalWithLength(LLVMModuleRef M,2801                                                     const char *Name,2802                                                     size_t Length);2803LLVM_C_ABI LLVMValueRef LLVMGetFirstGlobal(LLVMModuleRef M);2804LLVM_C_ABI LLVMValueRef LLVMGetLastGlobal(LLVMModuleRef M);2805LLVM_C_ABI LLVMValueRef LLVMGetNextGlobal(LLVMValueRef GlobalVar);2806LLVM_C_ABI LLVMValueRef LLVMGetPreviousGlobal(LLVMValueRef GlobalVar);2807LLVM_C_ABI void LLVMDeleteGlobal(LLVMValueRef GlobalVar);2808LLVM_C_ABI LLVMValueRef LLVMGetInitializer(LLVMValueRef GlobalVar);2809LLVM_C_ABI void LLVMSetInitializer(LLVMValueRef GlobalVar,2810                                   LLVMValueRef ConstantVal);2811LLVM_C_ABI LLVMBool LLVMIsThreadLocal(LLVMValueRef GlobalVar);2812LLVM_C_ABI void LLVMSetThreadLocal(LLVMValueRef GlobalVar,2813                                   LLVMBool IsThreadLocal);2814LLVM_C_ABI LLVMBool LLVMIsGlobalConstant(LLVMValueRef GlobalVar);2815LLVM_C_ABI void LLVMSetGlobalConstant(LLVMValueRef GlobalVar,2816                                      LLVMBool IsConstant);2817LLVM_C_ABI LLVMThreadLocalMode LLVMGetThreadLocalMode(LLVMValueRef GlobalVar);2818LLVM_C_ABI void LLVMSetThreadLocalMode(LLVMValueRef GlobalVar,2819                                       LLVMThreadLocalMode Mode);2820LLVM_C_ABI LLVMBool LLVMIsExternallyInitialized(LLVMValueRef GlobalVar);2821LLVM_C_ABI void LLVMSetExternallyInitialized(LLVMValueRef GlobalVar,2822                                             LLVMBool IsExtInit);2823 2824/**2825 * @}2826 */2827 2828/**2829 * @defgroup LLVMCoreValueConstantGlobalAlias Global Aliases2830 *2831 * This group contains function that operate on global alias values.2832 *2833 * @see llvm::GlobalAlias2834 *2835 * @{2836 */2837 2838/**2839 * Add a GlobalAlias with the given value type, address space and aliasee.2840 *2841 * @see llvm::GlobalAlias::create()2842 */2843LLVM_C_ABI LLVMValueRef LLVMAddAlias2(LLVMModuleRef M, LLVMTypeRef ValueTy,2844                                      unsigned AddrSpace, LLVMValueRef Aliasee,2845                                      const char *Name);2846 2847/**2848 * Obtain a GlobalAlias value from a Module by its name.2849 *2850 * The returned value corresponds to a llvm::GlobalAlias value.2851 *2852 * @see llvm::Module::getNamedAlias()2853 */2854LLVM_C_ABI LLVMValueRef LLVMGetNamedGlobalAlias(LLVMModuleRef M,2855                                                const char *Name,2856                                                size_t NameLen);2857 2858/**2859 * Obtain an iterator to the first GlobalAlias in a Module.2860 *2861 * @see llvm::Module::alias_begin()2862 */2863LLVM_C_ABI LLVMValueRef LLVMGetFirstGlobalAlias(LLVMModuleRef M);2864 2865/**2866 * Obtain an iterator to the last GlobalAlias in a Module.2867 *2868 * @see llvm::Module::alias_end()2869 */2870LLVM_C_ABI LLVMValueRef LLVMGetLastGlobalAlias(LLVMModuleRef M);2871 2872/**2873 * Advance a GlobalAlias iterator to the next GlobalAlias.2874 *2875 * Returns NULL if the iterator was already at the end and there are no more2876 * global aliases.2877 */2878LLVM_C_ABI LLVMValueRef LLVMGetNextGlobalAlias(LLVMValueRef GA);2879 2880/**2881 * Decrement a GlobalAlias iterator to the previous GlobalAlias.2882 *2883 * Returns NULL if the iterator was already at the beginning and there are2884 * no previous global aliases.2885 */2886LLVM_C_ABI LLVMValueRef LLVMGetPreviousGlobalAlias(LLVMValueRef GA);2887 2888/**2889 * Retrieve the target value of an alias.2890 */2891LLVM_C_ABI LLVMValueRef LLVMAliasGetAliasee(LLVMValueRef Alias);2892 2893/**2894 * Set the target value of an alias.2895 */2896LLVM_C_ABI void LLVMAliasSetAliasee(LLVMValueRef Alias, LLVMValueRef Aliasee);2897 2898/**2899 * @}2900 */2901 2902/**2903 * @defgroup LLVMCCoreValueFunction Function values2904 *2905 * Functions in this group operate on LLVMValueRef instances that2906 * correspond to llvm::Function instances.2907 *2908 * @see llvm::Function2909 *2910 * @{2911 */2912 2913/**2914 * Remove a function from its containing module and deletes it.2915 *2916 * @see llvm::Function::eraseFromParent()2917 */2918LLVM_C_ABI void LLVMDeleteFunction(LLVMValueRef Fn);2919 2920/**2921 * Check whether the given function has a personality function.2922 *2923 * @see llvm::Function::hasPersonalityFn()2924 */2925LLVM_C_ABI LLVMBool LLVMHasPersonalityFn(LLVMValueRef Fn);2926 2927/**2928 * Obtain the personality function attached to the function.2929 *2930 * @see llvm::Function::getPersonalityFn()2931 */2932LLVM_C_ABI LLVMValueRef LLVMGetPersonalityFn(LLVMValueRef Fn);2933 2934/**2935 * Set the personality function attached to the function.2936 *2937 * @see llvm::Function::setPersonalityFn()2938 */2939LLVM_C_ABI void LLVMSetPersonalityFn(LLVMValueRef Fn,2940                                     LLVMValueRef PersonalityFn);2941 2942/**2943 * Obtain the intrinsic ID number which matches the given function name.2944 *2945 * @see llvm::Intrinsic::lookupIntrinsicID()2946 */2947LLVM_C_ABI unsigned LLVMLookupIntrinsicID(const char *Name, size_t NameLen);2948 2949/**2950 * Obtain the ID number from a function instance.2951 *2952 * @see llvm::Function::getIntrinsicID()2953 */2954LLVM_C_ABI unsigned LLVMGetIntrinsicID(LLVMValueRef Fn);2955 2956/**2957 * Get or insert the declaration of an intrinsic.  For overloaded intrinsics,2958 * parameter types must be provided to uniquely identify an overload.2959 *2960 * @see llvm::Intrinsic::getOrInsertDeclaration()2961 */2962LLVM_C_ABI LLVMValueRef LLVMGetIntrinsicDeclaration(LLVMModuleRef Mod,2963                                                    unsigned ID,2964                                                    LLVMTypeRef *ParamTypes,2965                                                    size_t ParamCount);2966 2967/**2968 * Retrieves the type of an intrinsic.  For overloaded intrinsics, parameter2969 * types must be provided to uniquely identify an overload.2970 *2971 * @see llvm::Intrinsic::getType()2972 */2973LLVM_C_ABI LLVMTypeRef LLVMIntrinsicGetType(LLVMContextRef Ctx, unsigned ID,2974                                            LLVMTypeRef *ParamTypes,2975                                            size_t ParamCount);2976 2977/**2978 * Retrieves the name of an intrinsic.2979 *2980 * @see llvm::Intrinsic::getName()2981 */2982LLVM_C_ABI const char *LLVMIntrinsicGetName(unsigned ID, size_t *NameLength);2983 2984/** Deprecated: Use LLVMIntrinsicCopyOverloadedName2 instead. */2985LLVM_C_ABI char *LLVMIntrinsicCopyOverloadedName(unsigned ID,2986                                                 LLVMTypeRef *ParamTypes,2987                                                 size_t ParamCount,2988                                                 size_t *NameLength);2989 2990/**2991 * Copies the name of an overloaded intrinsic identified by a given list of2992 * parameter types.2993 *2994 * Unlike LLVMIntrinsicGetName, the caller is responsible for freeing the2995 * returned string.2996 *2997 * This version also supports unnamed types.2998 *2999 * @see llvm::Intrinsic::getName()3000 */3001LLVM_C_ABI char *LLVMIntrinsicCopyOverloadedName2(LLVMModuleRef Mod,3002                                                  unsigned ID,3003                                                  LLVMTypeRef *ParamTypes,3004                                                  size_t ParamCount,3005                                                  size_t *NameLength);3006 3007/**3008 * Obtain if the intrinsic identified by the given ID is overloaded.3009 *3010 * @see llvm::Intrinsic::isOverloaded()3011 */3012LLVM_C_ABI LLVMBool LLVMIntrinsicIsOverloaded(unsigned ID);3013 3014/**3015 * Obtain the calling function of a function.3016 *3017 * The returned value corresponds to the LLVMCallConv enumeration.3018 *3019 * @see llvm::Function::getCallingConv()3020 */3021LLVM_C_ABI unsigned LLVMGetFunctionCallConv(LLVMValueRef Fn);3022 3023/**3024 * Set the calling convention of a function.3025 *3026 * @see llvm::Function::setCallingConv()3027 *3028 * @param Fn Function to operate on3029 * @param CC LLVMCallConv to set calling convention to3030 */3031LLVM_C_ABI void LLVMSetFunctionCallConv(LLVMValueRef Fn, unsigned CC);3032 3033/**3034 * Obtain the name of the garbage collector to use during code3035 * generation.3036 *3037 * @see llvm::Function::getGC()3038 */3039LLVM_C_ABI const char *LLVMGetGC(LLVMValueRef Fn);3040 3041/**3042 * Define the garbage collector to use during code generation.3043 *3044 * @see llvm::Function::setGC()3045 */3046LLVM_C_ABI void LLVMSetGC(LLVMValueRef Fn, const char *Name);3047 3048/**3049 * Gets the prefix data associated with a function. Only valid on functions, and3050 * only if LLVMHasPrefixData returns true.3051 * See https://llvm.org/docs/LangRef.html#prefix-data3052 */3053LLVM_C_ABI LLVMValueRef LLVMGetPrefixData(LLVMValueRef Fn);3054 3055/**3056 * Check if a given function has prefix data. Only valid on functions.3057 * See https://llvm.org/docs/LangRef.html#prefix-data3058 */3059LLVM_C_ABI LLVMBool LLVMHasPrefixData(LLVMValueRef Fn);3060 3061/**3062 * Sets the prefix data for the function. Only valid on functions.3063 * See https://llvm.org/docs/LangRef.html#prefix-data3064 */3065LLVM_C_ABI void LLVMSetPrefixData(LLVMValueRef Fn, LLVMValueRef prefixData);3066 3067/**3068 * Gets the prologue data associated with a function. Only valid on functions,3069 * and only if LLVMHasPrologueData returns true.3070 * See https://llvm.org/docs/LangRef.html#prologue-data3071 */3072LLVM_C_ABI LLVMValueRef LLVMGetPrologueData(LLVMValueRef Fn);3073 3074/**3075 * Check if a given function has prologue data. Only valid on functions.3076 * See https://llvm.org/docs/LangRef.html#prologue-data3077 */3078LLVM_C_ABI LLVMBool LLVMHasPrologueData(LLVMValueRef Fn);3079 3080/**3081 * Sets the prologue data for the function. Only valid on functions.3082 * See https://llvm.org/docs/LangRef.html#prologue-data3083 */3084LLVM_C_ABI void LLVMSetPrologueData(LLVMValueRef Fn, LLVMValueRef prologueData);3085 3086/**3087 * Add an attribute to a function.3088 *3089 * @see llvm::Function::addAttribute()3090 */3091LLVM_C_ABI void LLVMAddAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx,3092                                        LLVMAttributeRef A);3093LLVM_C_ABI unsigned LLVMGetAttributeCountAtIndex(LLVMValueRef F,3094                                                 LLVMAttributeIndex Idx);3095LLVM_C_ABI void LLVMGetAttributesAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx,3096                                         LLVMAttributeRef *Attrs);3097LLVM_C_ABI LLVMAttributeRef LLVMGetEnumAttributeAtIndex(LLVMValueRef F,3098                                                        LLVMAttributeIndex Idx,3099                                                        unsigned KindID);3100LLVM_C_ABI LLVMAttributeRef LLVMGetStringAttributeAtIndex(3101    LLVMValueRef F, LLVMAttributeIndex Idx, const char *K, unsigned KLen);3102LLVM_C_ABI void LLVMRemoveEnumAttributeAtIndex(LLVMValueRef F,3103                                               LLVMAttributeIndex Idx,3104                                               unsigned KindID);3105LLVM_C_ABI void LLVMRemoveStringAttributeAtIndex(LLVMValueRef F,3106                                                 LLVMAttributeIndex Idx,3107                                                 const char *K, unsigned KLen);3108 3109/**3110 * Add a target-dependent attribute to a function3111 * @see llvm::AttrBuilder::addAttribute()3112 */3113LLVM_C_ABI void LLVMAddTargetDependentFunctionAttr(LLVMValueRef Fn,3114                                                   const char *A,3115                                                   const char *V);3116 3117/**3118 * @defgroup LLVMCCoreValueFunctionParameters Function Parameters3119 *3120 * Functions in this group relate to arguments/parameters on functions.3121 *3122 * Functions in this group expect LLVMValueRef instances that correspond3123 * to llvm::Function instances.3124 *3125 * @{3126 */3127 3128/**3129 * Obtain the number of parameters in a function.3130 *3131 * @see llvm::Function::arg_size()3132 */3133LLVM_C_ABI unsigned LLVMCountParams(LLVMValueRef Fn);3134 3135/**3136 * Obtain the parameters in a function.3137 *3138 * The takes a pointer to a pre-allocated array of LLVMValueRef that is3139 * at least LLVMCountParams() long. This array will be filled with3140 * LLVMValueRef instances which correspond to the parameters the3141 * function receives. Each LLVMValueRef corresponds to a llvm::Argument3142 * instance.3143 *3144 * @see llvm::Function::arg_begin()3145 */3146LLVM_C_ABI void LLVMGetParams(LLVMValueRef Fn, LLVMValueRef *Params);3147 3148/**3149 * Obtain the parameter at the specified index.3150 *3151 * Parameters are indexed from 0.3152 *3153 * @see llvm::Function::arg_begin()3154 */3155LLVM_C_ABI LLVMValueRef LLVMGetParam(LLVMValueRef Fn, unsigned Index);3156 3157/**3158 * Obtain the function to which this argument belongs.3159 *3160 * Unlike other functions in this group, this one takes an LLVMValueRef3161 * that corresponds to a llvm::Attribute.3162 *3163 * The returned LLVMValueRef is the llvm::Function to which this3164 * argument belongs.3165 */3166LLVM_C_ABI LLVMValueRef LLVMGetParamParent(LLVMValueRef Inst);3167 3168/**3169 * Obtain the first parameter to a function.3170 *3171 * @see llvm::Function::arg_begin()3172 */3173LLVM_C_ABI LLVMValueRef LLVMGetFirstParam(LLVMValueRef Fn);3174 3175/**3176 * Obtain the last parameter to a function.3177 *3178 * @see llvm::Function::arg_end()3179 */3180LLVM_C_ABI LLVMValueRef LLVMGetLastParam(LLVMValueRef Fn);3181 3182/**3183 * Obtain the next parameter to a function.3184 *3185 * This takes an LLVMValueRef obtained from LLVMGetFirstParam() (which is3186 * actually a wrapped iterator) and obtains the next parameter from the3187 * underlying iterator.3188 */3189LLVM_C_ABI LLVMValueRef LLVMGetNextParam(LLVMValueRef Arg);3190 3191/**3192 * Obtain the previous parameter to a function.3193 *3194 * This is the opposite of LLVMGetNextParam().3195 */3196LLVM_C_ABI LLVMValueRef LLVMGetPreviousParam(LLVMValueRef Arg);3197 3198/**3199 * Set the alignment for a function parameter.3200 *3201 * @see llvm::Argument::addAttr()3202 * @see llvm::AttrBuilder::addAlignmentAttr()3203 */3204LLVM_C_ABI void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned Align);3205 3206/**3207 * @}3208 */3209 3210/**3211 * @defgroup LLVMCCoreValueGlobalIFunc IFuncs3212 *3213 * Functions in this group relate to indirect functions.3214 *3215 * Functions in this group expect LLVMValueRef instances that correspond3216 * to llvm::GlobalIFunc instances.3217 *3218 * @{3219 */3220 3221/**3222 * Add a global indirect function to a module under a specified name.3223 *3224 * @see llvm::GlobalIFunc::create()3225 */3226LLVM_C_ABI LLVMValueRef LLVMAddGlobalIFunc(LLVMModuleRef M, const char *Name,3227                                           size_t NameLen, LLVMTypeRef Ty,3228                                           unsigned AddrSpace,3229                                           LLVMValueRef Resolver);3230 3231/**3232 * Obtain a GlobalIFunc value from a Module by its name.3233 *3234 * The returned value corresponds to a llvm::GlobalIFunc value.3235 *3236 * @see llvm::Module::getNamedIFunc()3237 */3238LLVM_C_ABI LLVMValueRef LLVMGetNamedGlobalIFunc(LLVMModuleRef M,3239                                                const char *Name,3240                                                size_t NameLen);3241 3242/**3243 * Obtain an iterator to the first GlobalIFunc in a Module.3244 *3245 * @see llvm::Module::ifunc_begin()3246 */3247LLVM_C_ABI LLVMValueRef LLVMGetFirstGlobalIFunc(LLVMModuleRef M);3248 3249/**3250 * Obtain an iterator to the last GlobalIFunc in a Module.3251 *3252 * @see llvm::Module::ifunc_end()3253 */3254LLVM_C_ABI LLVMValueRef LLVMGetLastGlobalIFunc(LLVMModuleRef M);3255 3256/**3257 * Advance a GlobalIFunc iterator to the next GlobalIFunc.3258 *3259 * Returns NULL if the iterator was already at the end and there are no more3260 * global aliases.3261 */3262LLVM_C_ABI LLVMValueRef LLVMGetNextGlobalIFunc(LLVMValueRef IFunc);3263 3264/**3265 * Decrement a GlobalIFunc iterator to the previous GlobalIFunc.3266 *3267 * Returns NULL if the iterator was already at the beginning and there are3268 * no previous global aliases.3269 */3270LLVM_C_ABI LLVMValueRef LLVMGetPreviousGlobalIFunc(LLVMValueRef IFunc);3271 3272/**3273 * Retrieves the resolver function associated with this indirect function, or3274 * NULL if it doesn't not exist.3275 *3276 * @see llvm::GlobalIFunc::getResolver()3277 */3278LLVM_C_ABI LLVMValueRef LLVMGetGlobalIFuncResolver(LLVMValueRef IFunc);3279 3280/**3281 * Sets the resolver function associated with this indirect function.3282 *3283 * @see llvm::GlobalIFunc::setResolver()3284 */3285LLVM_C_ABI void LLVMSetGlobalIFuncResolver(LLVMValueRef IFunc,3286                                           LLVMValueRef Resolver);3287 3288/**3289 * Remove a global indirect function from its parent module and delete it.3290 *3291 * @see llvm::GlobalIFunc::eraseFromParent()3292 */3293LLVM_C_ABI void LLVMEraseGlobalIFunc(LLVMValueRef IFunc);3294 3295/**3296 * Remove a global indirect function from its parent module.3297 *3298 * This unlinks the global indirect function from its containing module but3299 * keeps it alive.3300 *3301 * @see llvm::GlobalIFunc::removeFromParent()3302 */3303LLVM_C_ABI void LLVMRemoveGlobalIFunc(LLVMValueRef IFunc);3304 3305/**3306 * @}3307 */3308 3309/**3310 * @}3311 */3312 3313/**3314 * @}3315 */3316 3317/**3318 * @}3319 */3320 3321/**3322 * @defgroup LLVMCCoreValueMetadata Metadata3323 *3324 * @{3325 */3326 3327/**3328 * Create an MDString value from a given string value.3329 *3330 * The MDString value does not take ownership of the given string, it remains3331 * the responsibility of the caller to free it.3332 *3333 * @see llvm::MDString::get()3334 */3335LLVM_C_ABI LLVMMetadataRef LLVMMDStringInContext2(LLVMContextRef C,3336                                                  const char *Str, size_t SLen);3337 3338/**3339 * Create an MDNode value with the given array of operands.3340 *3341 * @see llvm::MDNode::get()3342 */3343LLVM_C_ABI LLVMMetadataRef LLVMMDNodeInContext2(LLVMContextRef C,3344                                                LLVMMetadataRef *MDs,3345                                                size_t Count);3346 3347/**3348 * Obtain a Metadata as a Value.3349 */3350LLVM_C_ABI LLVMValueRef LLVMMetadataAsValue(LLVMContextRef C,3351                                            LLVMMetadataRef MD);3352 3353/**3354 * Obtain a Value as a Metadata.3355 */3356LLVM_C_ABI LLVMMetadataRef LLVMValueAsMetadata(LLVMValueRef Val);3357 3358/**3359 * Obtain the underlying string from a MDString value.3360 *3361 * @param V Instance to obtain string from.3362 * @param Length Memory address which will hold length of returned string.3363 * @return String data in MDString.3364 */3365LLVM_C_ABI const char *LLVMGetMDString(LLVMValueRef V, unsigned *Length);3366 3367/**3368 * Obtain the number of operands from an MDNode value.3369 *3370 * @param V MDNode to get number of operands from.3371 * @return Number of operands of the MDNode.3372 */3373LLVM_C_ABI unsigned LLVMGetMDNodeNumOperands(LLVMValueRef V);3374 3375/**3376 * Obtain the given MDNode's operands.3377 *3378 * The passed LLVMValueRef pointer should point to enough memory to hold all of3379 * the operands of the given MDNode (see LLVMGetMDNodeNumOperands) as3380 * LLVMValueRefs. This memory will be populated with the LLVMValueRefs of the3381 * MDNode's operands.3382 *3383 * @param V MDNode to get the operands from.3384 * @param Dest Destination array for operands.3385 */3386LLVM_C_ABI void LLVMGetMDNodeOperands(LLVMValueRef V, LLVMValueRef *Dest);3387 3388/**3389 * Replace an operand at a specific index in a llvm::MDNode value.3390 *3391 * @see llvm::MDNode::replaceOperandWith()3392 */3393LLVM_C_ABI void LLVMReplaceMDNodeOperandWith(LLVMValueRef V, unsigned Index,3394                                             LLVMMetadataRef Replacement);3395 3396/** Deprecated: Use LLVMMDStringInContext2 instead. */3397LLVM_C_ABI LLVMValueRef LLVMMDStringInContext(LLVMContextRef C, const char *Str,3398                                              unsigned SLen);3399/** Deprecated: Use LLVMMDStringInContext2 instead. */3400LLVM_C_ABI LLVMValueRef LLVMMDString(const char *Str, unsigned SLen);3401/** Deprecated: Use LLVMMDNodeInContext2 instead. */3402LLVM_C_ABI LLVMValueRef LLVMMDNodeInContext(LLVMContextRef C,3403                                            LLVMValueRef *Vals, unsigned Count);3404/** Deprecated: Use LLVMMDNodeInContext2 instead. */3405LLVM_C_ABI LLVMValueRef LLVMMDNode(LLVMValueRef *Vals, unsigned Count);3406 3407/**3408 * @}3409 */3410 3411/**3412 * @defgroup LLVMCCoreOperandBundle Operand Bundles3413 *3414 * Functions in this group operate on LLVMOperandBundleRef instances that3415 * correspond to llvm::OperandBundleDef instances.3416 *3417 * @see llvm::OperandBundleDef3418 *3419 * @{3420 */3421 3422/**3423 * Create a new operand bundle.3424 *3425 * Every invocation should be paired with LLVMDisposeOperandBundle() or memory3426 * will be leaked.3427 *3428 * @param Tag Tag name of the operand bundle3429 * @param TagLen Length of Tag3430 * @param Args Memory address of an array of bundle operands3431 * @param NumArgs Length of Args3432 */3433LLVM_C_ABI LLVMOperandBundleRef LLVMCreateOperandBundle(const char *Tag,3434                                                        size_t TagLen,3435                                                        LLVMValueRef *Args,3436                                                        unsigned NumArgs);3437 3438/**3439 * Destroy an operand bundle.3440 *3441 * This must be called for every created operand bundle or memory will be3442 * leaked.3443 */3444LLVM_C_ABI void LLVMDisposeOperandBundle(LLVMOperandBundleRef Bundle);3445 3446/**3447 * Obtain the tag of an operand bundle as a string.3448 *3449 * @param Bundle Operand bundle to obtain tag of.3450 * @param Len Out parameter which holds the length of the returned string.3451 * @return The tag name of Bundle.3452 * @see OperandBundleDef::getTag()3453 */3454LLVM_C_ABI const char *LLVMGetOperandBundleTag(LLVMOperandBundleRef Bundle,3455                                               size_t *Len);3456 3457/**3458 * Obtain the number of operands for an operand bundle.3459 *3460 * @param Bundle Operand bundle to obtain operand count of.3461 * @return The number of operands.3462 * @see OperandBundleDef::input_size()3463 */3464LLVM_C_ABI unsigned LLVMGetNumOperandBundleArgs(LLVMOperandBundleRef Bundle);3465 3466/**3467 * Obtain the operand for an operand bundle at the given index.3468 *3469 * @param Bundle Operand bundle to obtain operand of.3470 * @param Index An operand index, must be less than3471 * LLVMGetNumOperandBundleArgs().3472 * @return The operand.3473 */3474LLVM_C_ABI LLVMValueRef3475LLVMGetOperandBundleArgAtIndex(LLVMOperandBundleRef Bundle, unsigned Index);3476 3477/**3478 * @}3479 */3480 3481/**3482 * @defgroup LLVMCCoreValueBasicBlock Basic Block3483 *3484 * A basic block represents a single entry single exit section of code.3485 * Basic blocks contain a list of instructions which form the body of3486 * the block.3487 *3488 * Basic blocks belong to functions. They have the type of label.3489 *3490 * Basic blocks are themselves values. However, the C API models them as3491 * LLVMBasicBlockRef.3492 *3493 * @see llvm::BasicBlock3494 *3495 * @{3496 */3497 3498/**3499 * Convert a basic block instance to a value type.3500 */3501LLVM_C_ABI LLVMValueRef LLVMBasicBlockAsValue(LLVMBasicBlockRef BB);3502 3503/**3504 * Determine whether an LLVMValueRef is itself a basic block.3505 */3506LLVM_C_ABI LLVMBool LLVMValueIsBasicBlock(LLVMValueRef Val);3507 3508/**3509 * Convert an LLVMValueRef to an LLVMBasicBlockRef instance.3510 */3511LLVM_C_ABI LLVMBasicBlockRef LLVMValueAsBasicBlock(LLVMValueRef Val);3512 3513/**3514 * Obtain the string name of a basic block.3515 */3516LLVM_C_ABI const char *LLVMGetBasicBlockName(LLVMBasicBlockRef BB);3517 3518/**3519 * Obtain the function to which a basic block belongs.3520 *3521 * @see llvm::BasicBlock::getParent()3522 */3523LLVM_C_ABI LLVMValueRef LLVMGetBasicBlockParent(LLVMBasicBlockRef BB);3524 3525/**3526 * Obtain the terminator instruction for a basic block.3527 *3528 * If the basic block does not have a terminator (it is not well-formed3529 * if it doesn't), then NULL is returned.3530 *3531 * The returned LLVMValueRef corresponds to an llvm::Instruction.3532 *3533 * @see llvm::BasicBlock::getTerminator()3534 */3535LLVM_C_ABI LLVMValueRef LLVMGetBasicBlockTerminator(LLVMBasicBlockRef BB);3536 3537/**3538 * Obtain the number of basic blocks in a function.3539 *3540 * @param Fn Function value to operate on.3541 */3542LLVM_C_ABI unsigned LLVMCountBasicBlocks(LLVMValueRef Fn);3543 3544/**3545 * Obtain all of the basic blocks in a function.3546 *3547 * This operates on a function value. The BasicBlocks parameter is a3548 * pointer to a pre-allocated array of LLVMBasicBlockRef of at least3549 * LLVMCountBasicBlocks() in length. This array is populated with3550 * LLVMBasicBlockRef instances.3551 */3552LLVM_C_ABI void LLVMGetBasicBlocks(LLVMValueRef Fn,3553                                   LLVMBasicBlockRef *BasicBlocks);3554 3555/**3556 * Obtain the first basic block in a function.3557 *3558 * The returned basic block can be used as an iterator. You will likely3559 * eventually call into LLVMGetNextBasicBlock() with it.3560 *3561 * @see llvm::Function::begin()3562 */3563LLVM_C_ABI LLVMBasicBlockRef LLVMGetFirstBasicBlock(LLVMValueRef Fn);3564 3565/**3566 * Obtain the last basic block in a function.3567 *3568 * @see llvm::Function::end()3569 */3570LLVM_C_ABI LLVMBasicBlockRef LLVMGetLastBasicBlock(LLVMValueRef Fn);3571 3572/**3573 * Advance a basic block iterator.3574 */3575LLVM_C_ABI LLVMBasicBlockRef LLVMGetNextBasicBlock(LLVMBasicBlockRef BB);3576 3577/**3578 * Go backwards in a basic block iterator.3579 */3580LLVM_C_ABI LLVMBasicBlockRef LLVMGetPreviousBasicBlock(LLVMBasicBlockRef BB);3581 3582/**3583 * Obtain the basic block that corresponds to the entry point of a3584 * function.3585 *3586 * @see llvm::Function::getEntryBlock()3587 */3588LLVM_C_ABI LLVMBasicBlockRef LLVMGetEntryBasicBlock(LLVMValueRef Fn);3589 3590/**3591 * Insert the given basic block after the insertion point of the given builder.3592 *3593 * The insertion point must be valid.3594 *3595 * @see llvm::Function::BasicBlockListType::insertAfter()3596 */3597LLVM_C_ABI void3598LLVMInsertExistingBasicBlockAfterInsertBlock(LLVMBuilderRef Builder,3599                                             LLVMBasicBlockRef BB);3600 3601/**3602 * Append the given basic block to the basic block list of the given function.3603 *3604 * @see llvm::Function::BasicBlockListType::push_back()3605 */3606LLVM_C_ABI void LLVMAppendExistingBasicBlock(LLVMValueRef Fn,3607                                             LLVMBasicBlockRef BB);3608 3609/**3610 * Create a new basic block without inserting it into a function.3611 *3612 * @see llvm::BasicBlock::Create()3613 */3614LLVM_C_ABI LLVMBasicBlockRef LLVMCreateBasicBlockInContext(LLVMContextRef C,3615                                                           const char *Name);3616 3617/**3618 * Append a basic block to the end of a function.3619 *3620 * @see llvm::BasicBlock::Create()3621 */3622LLVM_C_ABI LLVMBasicBlockRef LLVMAppendBasicBlockInContext(LLVMContextRef C,3623                                                           LLVMValueRef Fn,3624                                                           const char *Name);3625 3626/**3627 * Append a basic block to the end of a function using the global3628 * context.3629 *3630 * @see llvm::BasicBlock::Create()3631 */3632LLVM_C_ABI LLVMBasicBlockRef LLVMAppendBasicBlock(LLVMValueRef Fn,3633                                                  const char *Name);3634 3635/**3636 * Insert a basic block in a function before another basic block.3637 *3638 * The function to add to is determined by the function of the3639 * passed basic block.3640 *3641 * @see llvm::BasicBlock::Create()3642 */3643LLVM_C_ABI LLVMBasicBlockRef LLVMInsertBasicBlockInContext(LLVMContextRef C,3644                                                           LLVMBasicBlockRef BB,3645                                                           const char *Name);3646 3647/**3648 * Insert a basic block in a function using the global context.3649 *3650 * @see llvm::BasicBlock::Create()3651 */3652LLVM_C_ABI LLVMBasicBlockRef3653LLVMInsertBasicBlock(LLVMBasicBlockRef InsertBeforeBB, const char *Name);3654 3655/**3656 * Remove a basic block from a function and delete it.3657 *3658 * This deletes the basic block from its containing function and deletes3659 * the basic block itself.3660 *3661 * @see llvm::BasicBlock::eraseFromParent()3662 */3663LLVM_C_ABI void LLVMDeleteBasicBlock(LLVMBasicBlockRef BB);3664 3665/**3666 * Remove a basic block from a function.3667 *3668 * This deletes the basic block from its containing function but keep3669 * the basic block alive.3670 *3671 * @see llvm::BasicBlock::removeFromParent()3672 */3673LLVM_C_ABI void LLVMRemoveBasicBlockFromParent(LLVMBasicBlockRef BB);3674 3675/**3676 * Move a basic block to before another one.3677 *3678 * @see llvm::BasicBlock::moveBefore()3679 */3680LLVM_C_ABI void LLVMMoveBasicBlockBefore(LLVMBasicBlockRef BB,3681                                         LLVMBasicBlockRef MovePos);3682 3683/**3684 * Move a basic block to after another one.3685 *3686 * @see llvm::BasicBlock::moveAfter()3687 */3688LLVM_C_ABI void LLVMMoveBasicBlockAfter(LLVMBasicBlockRef BB,3689                                        LLVMBasicBlockRef MovePos);3690 3691/**3692 * Obtain the first instruction in a basic block.3693 *3694 * The returned LLVMValueRef corresponds to a llvm::Instruction3695 * instance.3696 */3697LLVM_C_ABI LLVMValueRef LLVMGetFirstInstruction(LLVMBasicBlockRef BB);3698 3699/**3700 * Obtain the last instruction in a basic block.3701 *3702 * The returned LLVMValueRef corresponds to an LLVM:Instruction.3703 */3704LLVM_C_ABI LLVMValueRef LLVMGetLastInstruction(LLVMBasicBlockRef BB);3705 3706/**3707 * @}3708 */3709 3710/**3711 * @defgroup LLVMCCoreValueInstruction Instructions3712 *3713 * Functions in this group relate to the inspection and manipulation of3714 * individual instructions.3715 *3716 * In the C++ API, an instruction is modeled by llvm::Instruction. This3717 * class has a large number of descendents. llvm::Instruction is a3718 * llvm::Value and in the C API, instructions are modeled by3719 * LLVMValueRef.3720 *3721 * This group also contains sub-groups which operate on specific3722 * llvm::Instruction types, e.g. llvm::CallInst.3723 *3724 * @{3725 */3726 3727/**3728 * Determine whether an instruction has any metadata attached.3729 */3730LLVM_C_ABI int LLVMHasMetadata(LLVMValueRef Val);3731 3732/**3733 * Return metadata associated with an instruction value.3734 */3735LLVM_C_ABI LLVMValueRef LLVMGetMetadata(LLVMValueRef Val, unsigned KindID);3736 3737/**3738 * Set metadata associated with an instruction value.3739 */3740LLVM_C_ABI void LLVMSetMetadata(LLVMValueRef Val, unsigned KindID,3741                                LLVMValueRef Node);3742 3743/**3744 * Returns the metadata associated with an instruction value, but filters out3745 * all the debug locations.3746 *3747 * @see llvm::Instruction::getAllMetadataOtherThanDebugLoc()3748 */3749LLVM_C_ABI LLVMValueMetadataEntry *3750LLVMInstructionGetAllMetadataOtherThanDebugLoc(LLVMValueRef Instr,3751                                               size_t *NumEntries);3752 3753/**3754 * Obtain the basic block to which an instruction belongs.3755 *3756 * @see llvm::Instruction::getParent()3757 */3758LLVM_C_ABI LLVMBasicBlockRef LLVMGetInstructionParent(LLVMValueRef Inst);3759 3760/**3761 * Obtain the instruction that occurs after the one specified.3762 *3763 * The next instruction will be from the same basic block.3764 *3765 * If this is the last instruction in a basic block, NULL will be3766 * returned.3767 */3768LLVM_C_ABI LLVMValueRef LLVMGetNextInstruction(LLVMValueRef Inst);3769 3770/**3771 * Obtain the instruction that occurred before this one.3772 *3773 * If the instruction is the first instruction in a basic block, NULL3774 * will be returned.3775 */3776LLVM_C_ABI LLVMValueRef LLVMGetPreviousInstruction(LLVMValueRef Inst);3777 3778/**3779 * Remove an instruction.3780 *3781 * The instruction specified is removed from its containing building3782 * block but is kept alive.3783 *3784 * @see llvm::Instruction::removeFromParent()3785 */3786LLVM_C_ABI void LLVMInstructionRemoveFromParent(LLVMValueRef Inst);3787 3788/**3789 * Remove and delete an instruction.3790 *3791 * The instruction specified is removed from its containing building3792 * block and then deleted.3793 *3794 * @see llvm::Instruction::eraseFromParent()3795 */3796LLVM_C_ABI void LLVMInstructionEraseFromParent(LLVMValueRef Inst);3797 3798/**3799 * Delete an instruction.3800 *3801 * The instruction specified is deleted. It must have previously been3802 * removed from its containing building block.3803 *3804 * @see llvm::Value::deleteValue()3805 */3806LLVM_C_ABI void LLVMDeleteInstruction(LLVMValueRef Inst);3807 3808/**3809 * Obtain the code opcode for an individual instruction.3810 *3811 * @see llvm::Instruction::getOpCode()3812 */3813LLVM_C_ABI LLVMOpcode LLVMGetInstructionOpcode(LLVMValueRef Inst);3814 3815/**3816 * Obtain the predicate of an instruction.3817 *3818 * This is only valid for instructions that correspond to llvm::ICmpInst.3819 *3820 * @see llvm::ICmpInst::getPredicate()3821 */3822LLVM_C_ABI LLVMIntPredicate LLVMGetICmpPredicate(LLVMValueRef Inst);3823 3824/**3825 * Get whether or not an icmp instruction has the samesign flag.3826 *3827 * This is only valid for instructions that correspond to llvm::ICmpInst.3828 *3829 * @see llvm::ICmpInst::hasSameSign()3830 */3831LLVM_C_ABI LLVMBool LLVMGetICmpSameSign(LLVMValueRef Inst);3832 3833/**3834 * Set the samesign flag on an icmp instruction.3835 *3836 * This is only valid for instructions that correspond to llvm::ICmpInst.3837 *3838 * @see llvm::ICmpInst::setSameSign()3839 */3840LLVM_C_ABI void LLVMSetICmpSameSign(LLVMValueRef Inst, LLVMBool SameSign);3841 3842/**3843 * Obtain the float predicate of an instruction.3844 *3845 * This is only valid for instructions that correspond to llvm::FCmpInst.3846 *3847 * @see llvm::FCmpInst::getPredicate()3848 */3849LLVM_C_ABI LLVMRealPredicate LLVMGetFCmpPredicate(LLVMValueRef Inst);3850 3851/**3852 * Create a copy of 'this' instruction that is identical in all ways3853 * except the following:3854 *   * The instruction has no parent3855 *   * The instruction has no name3856 *3857 * @see llvm::Instruction::clone()3858 */3859LLVM_C_ABI LLVMValueRef LLVMInstructionClone(LLVMValueRef Inst);3860 3861/**3862 * Determine whether an instruction is a terminator. This routine is named to3863 * be compatible with historical functions that did this by querying the3864 * underlying C++ type.3865 *3866 * @see llvm::Instruction::isTerminator()3867 */3868LLVM_C_ABI LLVMValueRef LLVMIsATerminatorInst(LLVMValueRef Inst);3869 3870/**3871 * Obtain the first debug record attached to an instruction.3872 *3873 * Use LLVMGetNextDbgRecord() and LLVMGetPreviousDbgRecord() to traverse the3874 * sequence of DbgRecords.3875 *3876 * Return the first DbgRecord attached to Inst or NULL if there are none.3877 *3878 * @see llvm::Instruction::getDbgRecordRange()3879 */3880LLVM_C_ABI LLVMDbgRecordRef LLVMGetFirstDbgRecord(LLVMValueRef Inst);3881 3882/**3883 * Obtain the last debug record attached to an instruction.3884 *3885 * Return the last DbgRecord attached to Inst or NULL if there are none.3886 *3887 * @see llvm::Instruction::getDbgRecordRange()3888 */3889LLVM_C_ABI LLVMDbgRecordRef LLVMGetLastDbgRecord(LLVMValueRef Inst);3890 3891/**3892 * Obtain the next DbgRecord in the sequence or NULL if there are no more.3893 *3894 * @see llvm::Instruction::getDbgRecordRange()3895 */3896LLVM_C_ABI LLVMDbgRecordRef LLVMGetNextDbgRecord(LLVMDbgRecordRef DbgRecord);3897 3898/**3899 * Obtain the previous DbgRecord in the sequence or NULL if there are no more.3900 *3901 * @see llvm::Instruction::getDbgRecordRange()3902 */3903LLVM_C_ABI LLVMDbgRecordRef3904LLVMGetPreviousDbgRecord(LLVMDbgRecordRef DbgRecord);3905 3906/**3907 * Get the debug location attached to the debug record.3908 *3909 * @see llvm::DbgRecord::getDebugLoc()3910 */3911LLVMMetadataRef LLVMDbgRecordGetDebugLoc(LLVMDbgRecordRef Rec);3912 3913LLVMDbgRecordKind LLVMDbgRecordGetKind(LLVMDbgRecordRef Rec);3914 3915/**3916 * Get the value of the DbgVariableRecord.3917 *3918 * @see llvm::DbgVariableRecord::getValue()3919 */3920LLVMValueRef LLVMDbgVariableRecordGetValue(LLVMDbgRecordRef Rec,3921                                           unsigned OpIdx);3922 3923/**3924 * Get the debug info variable of the DbgVariableRecord.3925 *3926 * @see llvm::DbgVariableRecord::getVariable()3927 */3928LLVMMetadataRef LLVMDbgVariableRecordGetVariable(LLVMDbgRecordRef Rec);3929 3930/**3931 * Get the debug info expression of the DbgVariableRecord.3932 *3933 * @see llvm::DbgVariableRecord::getExpression()3934 */3935LLVMMetadataRef LLVMDbgVariableRecordGetExpression(LLVMDbgRecordRef Rec);3936 3937/**3938 * @defgroup LLVMCCoreValueInstructionCall Call Sites and Invocations3939 *3940 * Functions in this group apply to instructions that refer to call3941 * sites and invocations. These correspond to C++ types in the3942 * llvm::CallInst class tree.3943 *3944 * @{3945 */3946 3947/**3948 * Obtain the argument count for a call instruction.3949 *3950 * This expects an LLVMValueRef that corresponds to a llvm::CallInst,3951 * llvm::InvokeInst, or llvm:FuncletPadInst.3952 *3953 * @see llvm::CallInst::getNumArgOperands()3954 * @see llvm::InvokeInst::getNumArgOperands()3955 * @see llvm::FuncletPadInst::getNumArgOperands()3956 */3957LLVM_C_ABI unsigned LLVMGetNumArgOperands(LLVMValueRef Instr);3958 3959/**3960 * Set the calling convention for a call instruction.3961 *3962 * This expects an LLVMValueRef that corresponds to a llvm::CallInst or3963 * llvm::InvokeInst.3964 *3965 * @see llvm::CallInst::setCallingConv()3966 * @see llvm::InvokeInst::setCallingConv()3967 */3968LLVM_C_ABI void LLVMSetInstructionCallConv(LLVMValueRef Instr, unsigned CC);3969 3970/**3971 * Obtain the calling convention for a call instruction.3972 *3973 * This is the opposite of LLVMSetInstructionCallConv(). Reads its3974 * usage.3975 *3976 * @see LLVMSetInstructionCallConv()3977 */3978LLVM_C_ABI unsigned LLVMGetInstructionCallConv(LLVMValueRef Instr);3979 3980LLVM_C_ABI void LLVMSetInstrParamAlignment(LLVMValueRef Instr,3981                                           LLVMAttributeIndex Idx,3982                                           unsigned Align);3983 3984LLVM_C_ABI void LLVMAddCallSiteAttribute(LLVMValueRef C, LLVMAttributeIndex Idx,3985                                         LLVMAttributeRef A);3986LLVM_C_ABI unsigned LLVMGetCallSiteAttributeCount(LLVMValueRef C,3987                                                  LLVMAttributeIndex Idx);3988LLVM_C_ABI void LLVMGetCallSiteAttributes(LLVMValueRef C,3989                                          LLVMAttributeIndex Idx,3990                                          LLVMAttributeRef *Attrs);3991LLVM_C_ABI LLVMAttributeRef LLVMGetCallSiteEnumAttribute(LLVMValueRef C,3992                                                         LLVMAttributeIndex Idx,3993                                                         unsigned KindID);3994LLVM_C_ABI LLVMAttributeRef LLVMGetCallSiteStringAttribute(3995    LLVMValueRef C, LLVMAttributeIndex Idx, const char *K, unsigned KLen);3996LLVM_C_ABI void LLVMRemoveCallSiteEnumAttribute(LLVMValueRef C,3997                                                LLVMAttributeIndex Idx,3998                                                unsigned KindID);3999LLVM_C_ABI void LLVMRemoveCallSiteStringAttribute(LLVMValueRef C,4000                                                  LLVMAttributeIndex Idx,4001                                                  const char *K, unsigned KLen);4002 4003/**4004 * Obtain the function type called by this instruction.4005 *4006 * @see llvm::CallBase::getFunctionType()4007 */4008LLVM_C_ABI LLVMTypeRef LLVMGetCalledFunctionType(LLVMValueRef C);4009 4010/**4011 * Obtain the pointer to the function invoked by this instruction.4012 *4013 * This expects an LLVMValueRef that corresponds to a llvm::CallInst or4014 * llvm::InvokeInst.4015 *4016 * @see llvm::CallInst::getCalledOperand()4017 * @see llvm::InvokeInst::getCalledOperand()4018 */4019LLVM_C_ABI LLVMValueRef LLVMGetCalledValue(LLVMValueRef Instr);4020 4021/**4022 * Obtain the number of operand bundles attached to this instruction.4023 *4024 * This only works on llvm::CallInst and llvm::InvokeInst instructions.4025 *4026 * @see llvm::CallBase::getNumOperandBundles()4027 */4028LLVM_C_ABI unsigned LLVMGetNumOperandBundles(LLVMValueRef C);4029 4030/**4031 * Obtain the operand bundle attached to this instruction at the given index.4032 * Use LLVMDisposeOperandBundle to free the operand bundle.4033 *4034 * This only works on llvm::CallInst and llvm::InvokeInst instructions.4035 */4036LLVM_C_ABI LLVMOperandBundleRef LLVMGetOperandBundleAtIndex(LLVMValueRef C,4037                                                            unsigned Index);4038 4039/**4040 * Obtain whether a call instruction is a tail call.4041 *4042 * This only works on llvm::CallInst instructions.4043 *4044 * @see llvm::CallInst::isTailCall()4045 */4046LLVM_C_ABI LLVMBool LLVMIsTailCall(LLVMValueRef CallInst);4047 4048/**4049 * Set whether a call instruction is a tail call.4050 *4051 * This only works on llvm::CallInst instructions.4052 *4053 * @see llvm::CallInst::setTailCall()4054 */4055LLVM_C_ABI void LLVMSetTailCall(LLVMValueRef CallInst, LLVMBool IsTailCall);4056 4057/**4058 * Obtain a tail call kind of the call instruction.4059 *4060 * @see llvm::CallInst::setTailCallKind()4061 */4062LLVM_C_ABI LLVMTailCallKind LLVMGetTailCallKind(LLVMValueRef CallInst);4063 4064/**4065 * Set the call kind of the call instruction.4066 *4067 * @see llvm::CallInst::getTailCallKind()4068 */4069LLVM_C_ABI void LLVMSetTailCallKind(LLVMValueRef CallInst,4070                                    LLVMTailCallKind kind);4071 4072/**4073 * Return the normal destination basic block.4074 *4075 * This only works on llvm::InvokeInst instructions.4076 *4077 * @see llvm::InvokeInst::getNormalDest()4078 */4079LLVM_C_ABI LLVMBasicBlockRef LLVMGetNormalDest(LLVMValueRef InvokeInst);4080 4081/**4082 * Return the unwind destination basic block.4083 *4084 * Works on llvm::InvokeInst, llvm::CleanupReturnInst, and4085 * llvm::CatchSwitchInst instructions.4086 *4087 * @see llvm::InvokeInst::getUnwindDest()4088 * @see llvm::CleanupReturnInst::getUnwindDest()4089 * @see llvm::CatchSwitchInst::getUnwindDest()4090 */4091LLVM_C_ABI LLVMBasicBlockRef LLVMGetUnwindDest(LLVMValueRef InvokeInst);4092 4093/**4094 * Set the normal destination basic block.4095 *4096 * This only works on llvm::InvokeInst instructions.4097 *4098 * @see llvm::InvokeInst::setNormalDest()4099 */4100LLVM_C_ABI void LLVMSetNormalDest(LLVMValueRef InvokeInst, LLVMBasicBlockRef B);4101 4102/**4103 * Set the unwind destination basic block.4104 *4105 * Works on llvm::InvokeInst, llvm::CleanupReturnInst, and4106 * llvm::CatchSwitchInst instructions.4107 *4108 * @see llvm::InvokeInst::setUnwindDest()4109 * @see llvm::CleanupReturnInst::setUnwindDest()4110 * @see llvm::CatchSwitchInst::setUnwindDest()4111 */4112LLVM_C_ABI void LLVMSetUnwindDest(LLVMValueRef InvokeInst, LLVMBasicBlockRef B);4113 4114/**4115 * Get the default destination of a CallBr instruction.4116 *4117 * @see llvm::CallBrInst::getDefaultDest()4118 */4119LLVM_C_ABI LLVMBasicBlockRef LLVMGetCallBrDefaultDest(LLVMValueRef CallBr);4120 4121/**4122 * Get the number of indirect destinations of a CallBr instruction.4123 *4124 * @see llvm::CallBrInst::getNumIndirectDests()4125 4126 */4127LLVM_C_ABI unsigned LLVMGetCallBrNumIndirectDests(LLVMValueRef CallBr);4128 4129/**4130 * Get the indirect destination of a CallBr instruction at the given index.4131 *4132 * @see llvm::CallBrInst::getIndirectDest()4133 */4134LLVM_C_ABI LLVMBasicBlockRef LLVMGetCallBrIndirectDest(LLVMValueRef CallBr,4135                                                       unsigned Idx);4136 4137/**4138 * @}4139 */4140 4141/**4142 * @defgroup LLVMCCoreValueInstructionTerminator Terminators4143 *4144 * Functions in this group only apply to instructions for which4145 * LLVMIsATerminatorInst returns true.4146 *4147 * @{4148 */4149 4150/**4151 * Return the number of successors that this terminator has.4152 *4153 * @see llvm::Instruction::getNumSuccessors4154 */4155LLVM_C_ABI unsigned LLVMGetNumSuccessors(LLVMValueRef Term);4156 4157/**4158 * Return the specified successor.4159 *4160 * @see llvm::Instruction::getSuccessor4161 */4162LLVM_C_ABI LLVMBasicBlockRef LLVMGetSuccessor(LLVMValueRef Term, unsigned i);4163 4164/**4165 * Update the specified successor to point at the provided block.4166 *4167 * @see llvm::Instruction::setSuccessor4168 */4169LLVM_C_ABI void LLVMSetSuccessor(LLVMValueRef Term, unsigned i,4170                                 LLVMBasicBlockRef block);4171 4172/**4173 * Return if a branch is conditional.4174 *4175 * This only works on llvm::BranchInst instructions.4176 *4177 * @see llvm::BranchInst::isConditional4178 */4179LLVM_C_ABI LLVMBool LLVMIsConditional(LLVMValueRef Branch);4180 4181/**4182 * Return the condition of a branch instruction.4183 *4184 * This only works on llvm::BranchInst instructions.4185 *4186 * @see llvm::BranchInst::getCondition4187 */4188LLVM_C_ABI LLVMValueRef LLVMGetCondition(LLVMValueRef Branch);4189 4190/**4191 * Set the condition of a branch instruction.4192 *4193 * This only works on llvm::BranchInst instructions.4194 *4195 * @see llvm::BranchInst::setCondition4196 */4197LLVM_C_ABI void LLVMSetCondition(LLVMValueRef Branch, LLVMValueRef Cond);4198 4199/**4200 * Obtain the default destination basic block of a switch instruction.4201 *4202 * This only works on llvm::SwitchInst instructions.4203 *4204 * @see llvm::SwitchInst::getDefaultDest()4205 */4206LLVM_C_ABI LLVMBasicBlockRef LLVMGetSwitchDefaultDest(LLVMValueRef SwitchInstr);4207 4208/**4209 * @}4210 */4211 4212/**4213 * @defgroup LLVMCCoreValueInstructionAlloca Allocas4214 *4215 * Functions in this group only apply to instructions that map to4216 * llvm::AllocaInst instances.4217 *4218 * @{4219 */4220 4221/**4222 * Obtain the type that is being allocated by the alloca instruction.4223 */4224LLVM_C_ABI LLVMTypeRef LLVMGetAllocatedType(LLVMValueRef Alloca);4225 4226/**4227 * @}4228 */4229 4230/**4231 * @defgroup LLVMCCoreValueInstructionGetElementPointer GEPs4232 *4233 * Functions in this group only apply to instructions that map to4234 * llvm::GetElementPtrInst instances.4235 *4236 * @{4237 */4238 4239/**4240 * Check whether the given GEP operator is inbounds.4241 */4242LLVM_C_ABI LLVMBool LLVMIsInBounds(LLVMValueRef GEP);4243 4244/**4245 * Set the given GEP instruction to be inbounds or not.4246 */4247LLVM_C_ABI void LLVMSetIsInBounds(LLVMValueRef GEP, LLVMBool InBounds);4248 4249/**4250 * Get the source element type of the given GEP operator.4251 */4252LLVM_C_ABI LLVMTypeRef LLVMGetGEPSourceElementType(LLVMValueRef GEP);4253 4254/**4255 * Get the no-wrap related flags for the given GEP instruction.4256 *4257 * @see llvm::GetElementPtrInst::getNoWrapFlags4258 */4259LLVM_C_ABI LLVMGEPNoWrapFlags LLVMGEPGetNoWrapFlags(LLVMValueRef GEP);4260 4261/**4262 * Set the no-wrap related flags for the given GEP instruction.4263 *4264 * @see llvm::GetElementPtrInst::setNoWrapFlags4265 */4266LLVM_C_ABI void LLVMGEPSetNoWrapFlags(LLVMValueRef GEP,4267                                      LLVMGEPNoWrapFlags NoWrapFlags);4268 4269/**4270 * @}4271 */4272 4273/**4274 * @defgroup LLVMCCoreValueInstructionPHINode PHI Nodes4275 *4276 * Functions in this group only apply to instructions that map to4277 * llvm::PHINode instances.4278 *4279 * @{4280 */4281 4282/**4283 * Add an incoming value to the end of a PHI list.4284 */4285LLVM_C_ABI void LLVMAddIncoming(LLVMValueRef PhiNode,4286                                LLVMValueRef *IncomingValues,4287                                LLVMBasicBlockRef *IncomingBlocks,4288                                unsigned Count);4289 4290/**4291 * Obtain the number of incoming basic blocks to a PHI node.4292 */4293LLVM_C_ABI unsigned LLVMCountIncoming(LLVMValueRef PhiNode);4294 4295/**4296 * Obtain an incoming value to a PHI node as an LLVMValueRef.4297 */4298LLVM_C_ABI LLVMValueRef LLVMGetIncomingValue(LLVMValueRef PhiNode,4299                                             unsigned Index);4300 4301/**4302 * Obtain an incoming value to a PHI node as an LLVMBasicBlockRef.4303 */4304LLVM_C_ABI LLVMBasicBlockRef LLVMGetIncomingBlock(LLVMValueRef PhiNode,4305                                                  unsigned Index);4306 4307/**4308 * @}4309 */4310 4311/**4312 * @defgroup LLVMCCoreValueInstructionExtractValue ExtractValue4313 * @defgroup LLVMCCoreValueInstructionInsertValue InsertValue4314 *4315 * Functions in this group only apply to instructions that map to4316 * llvm::ExtractValue and llvm::InsertValue instances.4317 *4318 * @{4319 */4320 4321/**4322 * Obtain the number of indices.4323 * NB: This also works on GEP operators.4324 */4325LLVM_C_ABI unsigned LLVMGetNumIndices(LLVMValueRef Inst);4326 4327/**4328 * Obtain the indices as an array.4329 */4330LLVM_C_ABI const unsigned *LLVMGetIndices(LLVMValueRef Inst);4331 4332/**4333 * @}4334 */4335 4336/**4337 * @}4338 */4339 4340/**4341 * @}4342 */4343 4344/**4345 * @defgroup LLVMCCoreInstructionBuilder Instruction Builders4346 *4347 * An instruction builder represents a point within a basic block and is4348 * the exclusive means of building instructions using the C interface.4349 *4350 * @{4351 */4352 4353LLVM_C_ABI LLVMBuilderRef LLVMCreateBuilderInContext(LLVMContextRef C);4354LLVM_C_ABI LLVMBuilderRef LLVMCreateBuilder(void);4355/**4356 * Set the builder position before Instr but after any attached debug records,4357 * or if Instr is null set the position to the end of Block.4358 */4359LLVM_C_ABI void LLVMPositionBuilder(LLVMBuilderRef Builder,4360                                    LLVMBasicBlockRef Block,4361                                    LLVMValueRef Instr);4362/**4363 * Set the builder position before Instr and any attached debug records,4364 * or if Instr is null set the position to the end of Block.4365 */4366LLVM_C_ABI void LLVMPositionBuilderBeforeDbgRecords(LLVMBuilderRef Builder,4367                                                    LLVMBasicBlockRef Block,4368                                                    LLVMValueRef Inst);4369/**4370 * Set the builder position before Instr but after any attached debug records.4371 */4372LLVM_C_ABI void LLVMPositionBuilderBefore(LLVMBuilderRef Builder,4373                                          LLVMValueRef Instr);4374/**4375 * Set the builder position before Instr and any attached debug records.4376 */4377LLVM_C_ABI void4378LLVMPositionBuilderBeforeInstrAndDbgRecords(LLVMBuilderRef Builder,4379                                            LLVMValueRef Instr);4380LLVM_C_ABI void LLVMPositionBuilderAtEnd(LLVMBuilderRef Builder,4381                                         LLVMBasicBlockRef Block);4382LLVM_C_ABI LLVMBasicBlockRef LLVMGetInsertBlock(LLVMBuilderRef Builder);4383LLVM_C_ABI void LLVMClearInsertionPosition(LLVMBuilderRef Builder);4384LLVM_C_ABI void LLVMInsertIntoBuilder(LLVMBuilderRef Builder,4385                                      LLVMValueRef Instr);4386LLVM_C_ABI void LLVMInsertIntoBuilderWithName(LLVMBuilderRef Builder,4387                                              LLVMValueRef Instr,4388                                              const char *Name);4389LLVM_C_ABI void LLVMDisposeBuilder(LLVMBuilderRef Builder);4390 4391/* Metadata */4392 4393/**4394 * Get location information used by debugging information.4395 *4396 * @see llvm::IRBuilder::getCurrentDebugLocation()4397 */4398LLVM_C_ABI LLVMMetadataRef LLVMGetCurrentDebugLocation2(LLVMBuilderRef Builder);4399 4400/**4401 * Set location information used by debugging information.4402 *4403 * To clear the location metadata of the given instruction, pass NULL to \p Loc.4404 *4405 * @see llvm::IRBuilder::SetCurrentDebugLocation()4406 */4407LLVM_C_ABI void LLVMSetCurrentDebugLocation2(LLVMBuilderRef Builder,4408                                             LLVMMetadataRef Loc);4409 4410/**4411 * Attempts to set the debug location for the given instruction using the4412 * current debug location for the given builder.  If the builder has no current4413 * debug location, this function is a no-op.4414 *4415 * @deprecated LLVMSetInstDebugLocation is deprecated in favor of the more general4416 *             LLVMAddMetadataToInst.4417 *4418 * @see llvm::IRBuilder::SetInstDebugLocation()4419 */4420LLVM_C_ABI void LLVMSetInstDebugLocation(LLVMBuilderRef Builder,4421                                         LLVMValueRef Inst);4422 4423/**4424 * Adds the metadata registered with the given builder to the given instruction.4425 *4426 * @see llvm::IRBuilder::AddMetadataToInst()4427 */4428LLVM_C_ABI void LLVMAddMetadataToInst(LLVMBuilderRef Builder,4429                                      LLVMValueRef Inst);4430 4431/**4432 * Get the dafult floating-point math metadata for a given builder.4433 *4434 * @see llvm::IRBuilder::getDefaultFPMathTag()4435 */4436LLVM_C_ABI LLVMMetadataRef4437LLVMBuilderGetDefaultFPMathTag(LLVMBuilderRef Builder);4438 4439/**4440 * Set the default floating-point math metadata for the given builder.4441 *4442 * To clear the metadata, pass NULL to \p FPMathTag.4443 *4444 * @see llvm::IRBuilder::setDefaultFPMathTag()4445 */4446LLVM_C_ABI void LLVMBuilderSetDefaultFPMathTag(LLVMBuilderRef Builder,4447                                               LLVMMetadataRef FPMathTag);4448 4449/**4450 * Obtain the context to which this builder is associated.4451 *4452 * @see llvm::IRBuilder::getContext()4453 */4454LLVM_C_ABI LLVMContextRef LLVMGetBuilderContext(LLVMBuilderRef Builder);4455 4456/**4457 * Deprecated: Passing the NULL location will crash.4458 * Use LLVMGetCurrentDebugLocation2 instead.4459 */4460LLVM_C_ABI void LLVMSetCurrentDebugLocation(LLVMBuilderRef Builder,4461                                            LLVMValueRef L);4462/**4463 * Deprecated: Returning the NULL location will crash.4464 * Use LLVMGetCurrentDebugLocation2 instead.4465 */4466LLVM_C_ABI LLVMValueRef LLVMGetCurrentDebugLocation(LLVMBuilderRef Builder);4467 4468/* Terminators */4469LLVM_C_ABI LLVMValueRef LLVMBuildRetVoid(LLVMBuilderRef);4470LLVM_C_ABI LLVMValueRef LLVMBuildRet(LLVMBuilderRef, LLVMValueRef V);4471LLVM_C_ABI LLVMValueRef LLVMBuildAggregateRet(LLVMBuilderRef,4472                                              LLVMValueRef *RetVals,4473                                              unsigned N);4474LLVM_C_ABI LLVMValueRef LLVMBuildBr(LLVMBuilderRef, LLVMBasicBlockRef Dest);4475LLVM_C_ABI LLVMValueRef LLVMBuildCondBr(LLVMBuilderRef, LLVMValueRef If,4476                                        LLVMBasicBlockRef Then,4477                                        LLVMBasicBlockRef Else);4478LLVM_C_ABI LLVMValueRef LLVMBuildSwitch(LLVMBuilderRef, LLVMValueRef V,4479                                        LLVMBasicBlockRef Else,4480                                        unsigned NumCases);4481LLVM_C_ABI LLVMValueRef LLVMBuildIndirectBr(LLVMBuilderRef B, LLVMValueRef Addr,4482                                            unsigned NumDests);4483LLVM_C_ABI LLVMValueRef LLVMBuildCallBr(4484    LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Fn,4485    LLVMBasicBlockRef DefaultDest, LLVMBasicBlockRef *IndirectDests,4486    unsigned NumIndirectDests, LLVMValueRef *Args, unsigned NumArgs,4487    LLVMOperandBundleRef *Bundles, unsigned NumBundles, const char *Name);4488LLVM_C_ABI LLVMValueRef LLVMBuildInvoke2(LLVMBuilderRef, LLVMTypeRef Ty,4489                                         LLVMValueRef Fn, LLVMValueRef *Args,4490                                         unsigned NumArgs,4491                                         LLVMBasicBlockRef Then,4492                                         LLVMBasicBlockRef Catch,4493                                         const char *Name);4494LLVM_C_ABI LLVMValueRef LLVMBuildInvokeWithOperandBundles(4495    LLVMBuilderRef, LLVMTypeRef Ty, LLVMValueRef Fn, LLVMValueRef *Args,4496    unsigned NumArgs, LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch,4497    LLVMOperandBundleRef *Bundles, unsigned NumBundles, const char *Name);4498LLVM_C_ABI LLVMValueRef LLVMBuildUnreachable(LLVMBuilderRef);4499 4500/* Exception Handling */4501LLVM_C_ABI LLVMValueRef LLVMBuildResume(LLVMBuilderRef B, LLVMValueRef Exn);4502LLVM_C_ABI LLVMValueRef LLVMBuildLandingPad(LLVMBuilderRef B, LLVMTypeRef Ty,4503                                            LLVMValueRef PersFn,4504                                            unsigned NumClauses,4505                                            const char *Name);4506LLVM_C_ABI LLVMValueRef LLVMBuildCleanupRet(LLVMBuilderRef B,4507                                            LLVMValueRef CatchPad,4508                                            LLVMBasicBlockRef BB);4509LLVM_C_ABI LLVMValueRef LLVMBuildCatchRet(LLVMBuilderRef B,4510                                          LLVMValueRef CatchPad,4511                                          LLVMBasicBlockRef BB);4512LLVM_C_ABI LLVMValueRef LLVMBuildCatchPad(LLVMBuilderRef B,4513                                          LLVMValueRef ParentPad,4514                                          LLVMValueRef *Args, unsigned NumArgs,4515                                          const char *Name);4516LLVM_C_ABI LLVMValueRef LLVMBuildCleanupPad(LLVMBuilderRef B,4517                                            LLVMValueRef ParentPad,4518                                            LLVMValueRef *Args,4519                                            unsigned NumArgs, const char *Name);4520LLVM_C_ABI LLVMValueRef LLVMBuildCatchSwitch(LLVMBuilderRef B,4521                                             LLVMValueRef ParentPad,4522                                             LLVMBasicBlockRef UnwindBB,4523                                             unsigned NumHandlers,4524                                             const char *Name);4525 4526/* Add a case to the switch instruction */4527LLVM_C_ABI void LLVMAddCase(LLVMValueRef Switch, LLVMValueRef OnVal,4528                            LLVMBasicBlockRef Dest);4529 4530/* Add a destination to the indirectbr instruction */4531LLVM_C_ABI void LLVMAddDestination(LLVMValueRef IndirectBr,4532                                   LLVMBasicBlockRef Dest);4533 4534/* Get the number of clauses on the landingpad instruction */4535LLVM_C_ABI unsigned LLVMGetNumClauses(LLVMValueRef LandingPad);4536 4537/* Get the value of the clause at index Idx on the landingpad instruction */4538LLVM_C_ABI LLVMValueRef LLVMGetClause(LLVMValueRef LandingPad, unsigned Idx);4539 4540/* Add a catch or filter clause to the landingpad instruction */4541LLVM_C_ABI void LLVMAddClause(LLVMValueRef LandingPad, LLVMValueRef ClauseVal);4542 4543/* Get the 'cleanup' flag in the landingpad instruction */4544LLVM_C_ABI LLVMBool LLVMIsCleanup(LLVMValueRef LandingPad);4545 4546/* Set the 'cleanup' flag in the landingpad instruction */4547LLVM_C_ABI void LLVMSetCleanup(LLVMValueRef LandingPad, LLVMBool Val);4548 4549/* Add a destination to the catchswitch instruction */4550LLVM_C_ABI void LLVMAddHandler(LLVMValueRef CatchSwitch,4551                               LLVMBasicBlockRef Dest);4552 4553/* Get the number of handlers on the catchswitch instruction */4554LLVM_C_ABI unsigned LLVMGetNumHandlers(LLVMValueRef CatchSwitch);4555 4556/**4557 * Obtain the basic blocks acting as handlers for a catchswitch instruction.4558 *4559 * The Handlers parameter should point to a pre-allocated array of4560 * LLVMBasicBlockRefs at least LLVMGetNumHandlers() large. On return, the4561 * first LLVMGetNumHandlers() entries in the array will be populated4562 * with LLVMBasicBlockRef instances.4563 *4564 * @param CatchSwitch The catchswitch instruction to operate on.4565 * @param Handlers Memory address of an array to be filled with basic blocks.4566 */4567LLVM_C_ABI void LLVMGetHandlers(LLVMValueRef CatchSwitch,4568                                LLVMBasicBlockRef *Handlers);4569 4570/* Funclets */4571 4572/* Get the number of funcletpad arguments. */4573LLVM_C_ABI LLVMValueRef LLVMGetArgOperand(LLVMValueRef Funclet, unsigned i);4574 4575/* Set a funcletpad argument at the given index. */4576LLVM_C_ABI void LLVMSetArgOperand(LLVMValueRef Funclet, unsigned i,4577                                  LLVMValueRef value);4578 4579/**4580 * Get the parent catchswitch instruction of a catchpad instruction.4581 *4582 * This only works on llvm::CatchPadInst instructions.4583 *4584 * @see llvm::CatchPadInst::getCatchSwitch()4585 */4586LLVM_C_ABI LLVMValueRef LLVMGetParentCatchSwitch(LLVMValueRef CatchPad);4587 4588/**4589 * Set the parent catchswitch instruction of a catchpad instruction.4590 *4591 * This only works on llvm::CatchPadInst instructions.4592 *4593 * @see llvm::CatchPadInst::setCatchSwitch()4594 */4595LLVM_C_ABI void LLVMSetParentCatchSwitch(LLVMValueRef CatchPad,4596                                         LLVMValueRef CatchSwitch);4597 4598/* Arithmetic */4599LLVM_C_ABI LLVMValueRef LLVMBuildAdd(LLVMBuilderRef, LLVMValueRef LHS,4600                                     LLVMValueRef RHS, const char *Name);4601LLVM_C_ABI LLVMValueRef LLVMBuildNSWAdd(LLVMBuilderRef, LLVMValueRef LHS,4602                                        LLVMValueRef RHS, const char *Name);4603LLVM_C_ABI LLVMValueRef LLVMBuildNUWAdd(LLVMBuilderRef, LLVMValueRef LHS,4604                                        LLVMValueRef RHS, const char *Name);4605LLVM_C_ABI LLVMValueRef LLVMBuildFAdd(LLVMBuilderRef, LLVMValueRef LHS,4606                                      LLVMValueRef RHS, const char *Name);4607LLVM_C_ABI LLVMValueRef LLVMBuildSub(LLVMBuilderRef, LLVMValueRef LHS,4608                                     LLVMValueRef RHS, const char *Name);4609LLVM_C_ABI LLVMValueRef LLVMBuildNSWSub(LLVMBuilderRef, LLVMValueRef LHS,4610                                        LLVMValueRef RHS, const char *Name);4611LLVM_C_ABI LLVMValueRef LLVMBuildNUWSub(LLVMBuilderRef, LLVMValueRef LHS,4612                                        LLVMValueRef RHS, const char *Name);4613LLVM_C_ABI LLVMValueRef LLVMBuildFSub(LLVMBuilderRef, LLVMValueRef LHS,4614                                      LLVMValueRef RHS, const char *Name);4615LLVM_C_ABI LLVMValueRef LLVMBuildMul(LLVMBuilderRef, LLVMValueRef LHS,4616                                     LLVMValueRef RHS, const char *Name);4617LLVM_C_ABI LLVMValueRef LLVMBuildNSWMul(LLVMBuilderRef, LLVMValueRef LHS,4618                                        LLVMValueRef RHS, const char *Name);4619LLVM_C_ABI LLVMValueRef LLVMBuildNUWMul(LLVMBuilderRef, LLVMValueRef LHS,4620                                        LLVMValueRef RHS, const char *Name);4621LLVM_C_ABI LLVMValueRef LLVMBuildFMul(LLVMBuilderRef, LLVMValueRef LHS,4622                                      LLVMValueRef RHS, const char *Name);4623LLVM_C_ABI LLVMValueRef LLVMBuildUDiv(LLVMBuilderRef, LLVMValueRef LHS,4624                                      LLVMValueRef RHS, const char *Name);4625LLVM_C_ABI LLVMValueRef LLVMBuildExactUDiv(LLVMBuilderRef, LLVMValueRef LHS,4626                                           LLVMValueRef RHS, const char *Name);4627LLVM_C_ABI LLVMValueRef LLVMBuildSDiv(LLVMBuilderRef, LLVMValueRef LHS,4628                                      LLVMValueRef RHS, const char *Name);4629LLVM_C_ABI LLVMValueRef LLVMBuildExactSDiv(LLVMBuilderRef, LLVMValueRef LHS,4630                                           LLVMValueRef RHS, const char *Name);4631LLVM_C_ABI LLVMValueRef LLVMBuildFDiv(LLVMBuilderRef, LLVMValueRef LHS,4632                                      LLVMValueRef RHS, const char *Name);4633LLVM_C_ABI LLVMValueRef LLVMBuildURem(LLVMBuilderRef, LLVMValueRef LHS,4634                                      LLVMValueRef RHS, const char *Name);4635LLVM_C_ABI LLVMValueRef LLVMBuildSRem(LLVMBuilderRef, LLVMValueRef LHS,4636                                      LLVMValueRef RHS, const char *Name);4637LLVM_C_ABI LLVMValueRef LLVMBuildFRem(LLVMBuilderRef, LLVMValueRef LHS,4638                                      LLVMValueRef RHS, const char *Name);4639LLVM_C_ABI LLVMValueRef LLVMBuildShl(LLVMBuilderRef, LLVMValueRef LHS,4640                                     LLVMValueRef RHS, const char *Name);4641LLVM_C_ABI LLVMValueRef LLVMBuildLShr(LLVMBuilderRef, LLVMValueRef LHS,4642                                      LLVMValueRef RHS, const char *Name);4643LLVM_C_ABI LLVMValueRef LLVMBuildAShr(LLVMBuilderRef, LLVMValueRef LHS,4644                                      LLVMValueRef RHS, const char *Name);4645LLVM_C_ABI LLVMValueRef LLVMBuildAnd(LLVMBuilderRef, LLVMValueRef LHS,4646                                     LLVMValueRef RHS, const char *Name);4647LLVM_C_ABI LLVMValueRef LLVMBuildOr(LLVMBuilderRef, LLVMValueRef LHS,4648                                    LLVMValueRef RHS, const char *Name);4649LLVM_C_ABI LLVMValueRef LLVMBuildXor(LLVMBuilderRef, LLVMValueRef LHS,4650                                     LLVMValueRef RHS, const char *Name);4651LLVM_C_ABI LLVMValueRef LLVMBuildBinOp(LLVMBuilderRef B, LLVMOpcode Op,4652                                       LLVMValueRef LHS, LLVMValueRef RHS,4653                                       const char *Name);4654LLVM_C_ABI LLVMValueRef LLVMBuildNeg(LLVMBuilderRef, LLVMValueRef V,4655                                     const char *Name);4656LLVM_C_ABI LLVMValueRef LLVMBuildNSWNeg(LLVMBuilderRef B, LLVMValueRef V,4657                                        const char *Name);4658LLVM_C_ABI LLVM_ATTRIBUTE_C_DEPRECATED(4659    LLVMValueRef LLVMBuildNUWNeg(LLVMBuilderRef B, LLVMValueRef V,4660                                 const char *Name),4661    "Use LLVMBuildNeg + LLVMSetNUW instead.");4662LLVM_C_ABI LLVMValueRef LLVMBuildFNeg(LLVMBuilderRef, LLVMValueRef V,4663                                      const char *Name);4664LLVM_C_ABI LLVMValueRef LLVMBuildNot(LLVMBuilderRef, LLVMValueRef V,4665                                     const char *Name);4666 4667LLVM_C_ABI LLVMBool LLVMGetNUW(LLVMValueRef ArithInst);4668LLVM_C_ABI void LLVMSetNUW(LLVMValueRef ArithInst, LLVMBool HasNUW);4669LLVM_C_ABI LLVMBool LLVMGetNSW(LLVMValueRef ArithInst);4670LLVM_C_ABI void LLVMSetNSW(LLVMValueRef ArithInst, LLVMBool HasNSW);4671LLVM_C_ABI LLVMBool LLVMGetExact(LLVMValueRef DivOrShrInst);4672LLVM_C_ABI void LLVMSetExact(LLVMValueRef DivOrShrInst, LLVMBool IsExact);4673 4674/**4675 * Gets if the instruction has the non-negative flag set.4676 * Only valid for zext instructions.4677 */4678LLVM_C_ABI LLVMBool LLVMGetNNeg(LLVMValueRef NonNegInst);4679/**4680 * Sets the non-negative flag for the instruction.4681 * Only valid for zext instructions.4682 */4683LLVM_C_ABI void LLVMSetNNeg(LLVMValueRef NonNegInst, LLVMBool IsNonNeg);4684 4685/**4686 * Get the flags for which fast-math-style optimizations are allowed for this4687 * value.4688 *4689 * Only valid on floating point instructions.4690 * @see LLVMCanValueUseFastMathFlags4691 */4692LLVM_C_ABI LLVMFastMathFlags LLVMGetFastMathFlags(LLVMValueRef FPMathInst);4693 4694/**4695 * Sets the flags for which fast-math-style optimizations are allowed for this4696 * value.4697 *4698 * Only valid on floating point instructions.4699 * @see LLVMCanValueUseFastMathFlags4700 */4701LLVM_C_ABI void LLVMSetFastMathFlags(LLVMValueRef FPMathInst,4702                                     LLVMFastMathFlags FMF);4703 4704/**4705 * Check if a given value can potentially have fast math flags.4706 *4707 * Will return true for floating point arithmetic instructions, and for select,4708 * phi, and call instructions whose type is a floating point type, or a vector4709 * or array thereof. See https://llvm.org/docs/LangRef.html#fast-math-flags4710 */4711LLVM_C_ABI LLVMBool LLVMCanValueUseFastMathFlags(LLVMValueRef Inst);4712 4713/**4714 * Gets whether the instruction has the disjoint flag set.4715 * Only valid for or instructions.4716 */4717LLVM_C_ABI LLVMBool LLVMGetIsDisjoint(LLVMValueRef Inst);4718/**4719 * Sets the disjoint flag for the instruction.4720 * Only valid for or instructions.4721 */4722LLVM_C_ABI void LLVMSetIsDisjoint(LLVMValueRef Inst, LLVMBool IsDisjoint);4723 4724/* Memory */4725LLVM_C_ABI LLVMValueRef LLVMBuildMalloc(LLVMBuilderRef, LLVMTypeRef Ty,4726                                        const char *Name);4727LLVM_C_ABI LLVMValueRef LLVMBuildArrayMalloc(LLVMBuilderRef, LLVMTypeRef Ty,4728                                             LLVMValueRef Val,4729                                             const char *Name);4730 4731/**4732 * Creates and inserts a memset to the specified pointer and the4733 * specified value.4734 *4735 * @see llvm::IRRBuilder::CreateMemSet()4736 */4737LLVM_C_ABI LLVMValueRef LLVMBuildMemSet(LLVMBuilderRef B, LLVMValueRef Ptr,4738                                        LLVMValueRef Val, LLVMValueRef Len,4739                                        unsigned Align);4740/**4741 * Creates and inserts a memcpy between the specified pointers.4742 *4743 * @see llvm::IRRBuilder::CreateMemCpy()4744 */4745LLVM_C_ABI LLVMValueRef LLVMBuildMemCpy(LLVMBuilderRef B, LLVMValueRef Dst,4746                                        unsigned DstAlign, LLVMValueRef Src,4747                                        unsigned SrcAlign, LLVMValueRef Size);4748/**4749 * Creates and inserts a memmove between the specified pointers.4750 *4751 * @see llvm::IRRBuilder::CreateMemMove()4752 */4753LLVM_C_ABI LLVMValueRef LLVMBuildMemMove(LLVMBuilderRef B, LLVMValueRef Dst,4754                                         unsigned DstAlign, LLVMValueRef Src,4755                                         unsigned SrcAlign, LLVMValueRef Size);4756 4757LLVM_C_ABI LLVMValueRef LLVMBuildAlloca(LLVMBuilderRef, LLVMTypeRef Ty,4758                                        const char *Name);4759LLVM_C_ABI LLVMValueRef LLVMBuildArrayAlloca(LLVMBuilderRef, LLVMTypeRef Ty,4760                                             LLVMValueRef Val,4761                                             const char *Name);4762LLVM_C_ABI LLVMValueRef LLVMBuildFree(LLVMBuilderRef, LLVMValueRef PointerVal);4763LLVM_C_ABI LLVMValueRef LLVMBuildLoad2(LLVMBuilderRef, LLVMTypeRef Ty,4764                                       LLVMValueRef PointerVal,4765                                       const char *Name);4766LLVM_C_ABI LLVMValueRef LLVMBuildStore(LLVMBuilderRef, LLVMValueRef Val,4767                                       LLVMValueRef Ptr);4768LLVM_C_ABI LLVMValueRef LLVMBuildGEP2(LLVMBuilderRef B, LLVMTypeRef Ty,4769                                      LLVMValueRef Pointer,4770                                      LLVMValueRef *Indices,4771                                      unsigned NumIndices, const char *Name);4772LLVM_C_ABI LLVMValueRef LLVMBuildInBoundsGEP2(LLVMBuilderRef B, LLVMTypeRef Ty,4773                                              LLVMValueRef Pointer,4774                                              LLVMValueRef *Indices,4775                                              unsigned NumIndices,4776                                              const char *Name);4777/**4778 * Creates a GetElementPtr instruction. Similar to LLVMBuildGEP2, but allows4779 * specifying the no-wrap flags.4780 *4781 * @see llvm::IRBuilder::CreateGEP()4782 */4783LLVM_C_ABI LLVMValueRef LLVMBuildGEPWithNoWrapFlags(4784    LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Pointer,4785    LLVMValueRef *Indices, unsigned NumIndices, const char *Name,4786    LLVMGEPNoWrapFlags NoWrapFlags);4787LLVM_C_ABI LLVMValueRef LLVMBuildStructGEP2(LLVMBuilderRef B, LLVMTypeRef Ty,4788                                            LLVMValueRef Pointer, unsigned Idx,4789                                            const char *Name);4790LLVM_C_ABI LLVMValueRef LLVMBuildGlobalString(LLVMBuilderRef B, const char *Str,4791                                              const char *Name);4792/**4793 * Deprecated: Use LLVMBuildGlobalString instead, which has identical behavior.4794 */4795LLVM_C_ABI LLVMValueRef LLVMBuildGlobalStringPtr(LLVMBuilderRef B,4796                                                 const char *Str,4797                                                 const char *Name);4798LLVM_C_ABI LLVMBool LLVMGetVolatile(LLVMValueRef Inst);4799LLVM_C_ABI void LLVMSetVolatile(LLVMValueRef MemoryAccessInst,4800                                LLVMBool IsVolatile);4801LLVM_C_ABI LLVMBool LLVMGetWeak(LLVMValueRef CmpXchgInst);4802LLVM_C_ABI void LLVMSetWeak(LLVMValueRef CmpXchgInst, LLVMBool IsWeak);4803LLVM_C_ABI LLVMAtomicOrdering LLVMGetOrdering(LLVMValueRef MemoryAccessInst);4804LLVM_C_ABI void LLVMSetOrdering(LLVMValueRef MemoryAccessInst,4805                                LLVMAtomicOrdering Ordering);4806LLVM_C_ABI LLVMAtomicRMWBinOp LLVMGetAtomicRMWBinOp(LLVMValueRef AtomicRMWInst);4807LLVM_C_ABI void LLVMSetAtomicRMWBinOp(LLVMValueRef AtomicRMWInst,4808                                      LLVMAtomicRMWBinOp BinOp);4809 4810/* Casts */4811LLVM_C_ABI LLVMValueRef LLVMBuildTrunc(LLVMBuilderRef, LLVMValueRef Val,4812                                       LLVMTypeRef DestTy, const char *Name);4813LLVM_C_ABI LLVMValueRef LLVMBuildZExt(LLVMBuilderRef, LLVMValueRef Val,4814                                      LLVMTypeRef DestTy, const char *Name);4815LLVM_C_ABI LLVMValueRef LLVMBuildSExt(LLVMBuilderRef, LLVMValueRef Val,4816                                      LLVMTypeRef DestTy, const char *Name);4817LLVM_C_ABI LLVMValueRef LLVMBuildFPToUI(LLVMBuilderRef, LLVMValueRef Val,4818                                        LLVMTypeRef DestTy, const char *Name);4819LLVM_C_ABI LLVMValueRef LLVMBuildFPToSI(LLVMBuilderRef, LLVMValueRef Val,4820                                        LLVMTypeRef DestTy, const char *Name);4821LLVM_C_ABI LLVMValueRef LLVMBuildUIToFP(LLVMBuilderRef, LLVMValueRef Val,4822                                        LLVMTypeRef DestTy, const char *Name);4823LLVM_C_ABI LLVMValueRef LLVMBuildSIToFP(LLVMBuilderRef, LLVMValueRef Val,4824                                        LLVMTypeRef DestTy, const char *Name);4825LLVM_C_ABI LLVMValueRef LLVMBuildFPTrunc(LLVMBuilderRef, LLVMValueRef Val,4826                                         LLVMTypeRef DestTy, const char *Name);4827LLVM_C_ABI LLVMValueRef LLVMBuildFPExt(LLVMBuilderRef, LLVMValueRef Val,4828                                       LLVMTypeRef DestTy, const char *Name);4829LLVM_C_ABI LLVMValueRef LLVMBuildPtrToInt(LLVMBuilderRef, LLVMValueRef Val,4830                                          LLVMTypeRef DestTy, const char *Name);4831LLVM_C_ABI LLVMValueRef LLVMBuildIntToPtr(LLVMBuilderRef, LLVMValueRef Val,4832                                          LLVMTypeRef DestTy, const char *Name);4833LLVM_C_ABI LLVMValueRef LLVMBuildBitCast(LLVMBuilderRef, LLVMValueRef Val,4834                                         LLVMTypeRef DestTy, const char *Name);4835LLVM_C_ABI LLVMValueRef LLVMBuildAddrSpaceCast(LLVMBuilderRef, LLVMValueRef Val,4836                                               LLVMTypeRef DestTy,4837                                               const char *Name);4838LLVM_C_ABI LLVMValueRef LLVMBuildZExtOrBitCast(LLVMBuilderRef, LLVMValueRef Val,4839                                               LLVMTypeRef DestTy,4840                                               const char *Name);4841LLVM_C_ABI LLVMValueRef LLVMBuildSExtOrBitCast(LLVMBuilderRef, LLVMValueRef Val,4842                                               LLVMTypeRef DestTy,4843                                               const char *Name);4844LLVM_C_ABI LLVMValueRef LLVMBuildTruncOrBitCast(LLVMBuilderRef,4845                                                LLVMValueRef Val,4846                                                LLVMTypeRef DestTy,4847                                                const char *Name);4848LLVM_C_ABI LLVMValueRef LLVMBuildCast(LLVMBuilderRef B, LLVMOpcode Op,4849                                      LLVMValueRef Val, LLVMTypeRef DestTy,4850                                      const char *Name);4851LLVM_C_ABI LLVMValueRef LLVMBuildPointerCast(LLVMBuilderRef, LLVMValueRef Val,4852                                             LLVMTypeRef DestTy,4853                                             const char *Name);4854LLVM_C_ABI LLVMValueRef LLVMBuildIntCast2(LLVMBuilderRef, LLVMValueRef Val,4855                                          LLVMTypeRef DestTy, LLVMBool IsSigned,4856                                          const char *Name);4857LLVM_C_ABI LLVMValueRef LLVMBuildFPCast(LLVMBuilderRef, LLVMValueRef Val,4858                                        LLVMTypeRef DestTy, const char *Name);4859 4860/** Deprecated: This cast is always signed. Use LLVMBuildIntCast2 instead. */4861LLVM_C_ABI LLVMValueRef LLVMBuildIntCast(LLVMBuilderRef,4862                                         LLVMValueRef Val, /*Signed cast!*/4863                                         LLVMTypeRef DestTy, const char *Name);4864 4865LLVM_C_ABI LLVMOpcode LLVMGetCastOpcode(LLVMValueRef Src, LLVMBool SrcIsSigned,4866                                        LLVMTypeRef DestTy,4867                                        LLVMBool DestIsSigned);4868 4869/* Comparisons */4870LLVM_C_ABI LLVMValueRef LLVMBuildICmp(LLVMBuilderRef, LLVMIntPredicate Op,4871                                      LLVMValueRef LHS, LLVMValueRef RHS,4872                                      const char *Name);4873LLVM_C_ABI LLVMValueRef LLVMBuildFCmp(LLVMBuilderRef, LLVMRealPredicate Op,4874                                      LLVMValueRef LHS, LLVMValueRef RHS,4875                                      const char *Name);4876 4877/* Miscellaneous instructions */4878LLVM_C_ABI LLVMValueRef LLVMBuildPhi(LLVMBuilderRef, LLVMTypeRef Ty,4879                                     const char *Name);4880LLVM_C_ABI LLVMValueRef LLVMBuildCall2(LLVMBuilderRef, LLVMTypeRef,4881                                       LLVMValueRef Fn, LLVMValueRef *Args,4882                                       unsigned NumArgs, const char *Name);4883LLVM_C_ABI LLVMValueRef LLVMBuildCallWithOperandBundles(4884    LLVMBuilderRef, LLVMTypeRef, LLVMValueRef Fn, LLVMValueRef *Args,4885    unsigned NumArgs, LLVMOperandBundleRef *Bundles, unsigned NumBundles,4886    const char *Name);4887LLVM_C_ABI LLVMValueRef LLVMBuildSelect(LLVMBuilderRef, LLVMValueRef If,4888                                        LLVMValueRef Then, LLVMValueRef Else,4889                                        const char *Name);4890LLVM_C_ABI LLVMValueRef LLVMBuildVAArg(LLVMBuilderRef, LLVMValueRef List,4891                                       LLVMTypeRef Ty, const char *Name);4892LLVM_C_ABI LLVMValueRef LLVMBuildExtractElement(LLVMBuilderRef,4893                                                LLVMValueRef VecVal,4894                                                LLVMValueRef Index,4895                                                const char *Name);4896LLVM_C_ABI LLVMValueRef LLVMBuildInsertElement(LLVMBuilderRef,4897                                               LLVMValueRef VecVal,4898                                               LLVMValueRef EltVal,4899                                               LLVMValueRef Index,4900                                               const char *Name);4901LLVM_C_ABI LLVMValueRef LLVMBuildShuffleVector(LLVMBuilderRef, LLVMValueRef V1,4902                                               LLVMValueRef V2,4903                                               LLVMValueRef Mask,4904                                               const char *Name);4905LLVM_C_ABI LLVMValueRef LLVMBuildExtractValue(LLVMBuilderRef,4906                                              LLVMValueRef AggVal,4907                                              unsigned Index, const char *Name);4908LLVM_C_ABI LLVMValueRef LLVMBuildInsertValue(LLVMBuilderRef,4909                                             LLVMValueRef AggVal,4910                                             LLVMValueRef EltVal,4911                                             unsigned Index, const char *Name);4912LLVM_C_ABI LLVMValueRef LLVMBuildFreeze(LLVMBuilderRef, LLVMValueRef Val,4913                                        const char *Name);4914 4915LLVM_C_ABI LLVMValueRef LLVMBuildIsNull(LLVMBuilderRef, LLVMValueRef Val,4916                                        const char *Name);4917LLVM_C_ABI LLVMValueRef LLVMBuildIsNotNull(LLVMBuilderRef, LLVMValueRef Val,4918                                           const char *Name);4919LLVM_C_ABI LLVMValueRef LLVMBuildPtrDiff2(LLVMBuilderRef, LLVMTypeRef ElemTy,4920                                          LLVMValueRef LHS, LLVMValueRef RHS,4921                                          const char *Name);4922LLVM_C_ABI LLVMValueRef LLVMBuildFence(LLVMBuilderRef B,4923                                       LLVMAtomicOrdering ordering,4924                                       LLVMBool singleThread, const char *Name);4925LLVM_C_ABI LLVMValueRef LLVMBuildFenceSyncScope(LLVMBuilderRef B,4926                                                LLVMAtomicOrdering ordering,4927                                                unsigned SSID,4928                                                const char *Name);4929LLVM_C_ABI LLVMValueRef LLVMBuildAtomicRMW(LLVMBuilderRef B,4930                                           LLVMAtomicRMWBinOp op,4931                                           LLVMValueRef PTR, LLVMValueRef Val,4932                                           LLVMAtomicOrdering ordering,4933                                           LLVMBool singleThread);4934LLVM_C_ABI LLVMValueRef LLVMBuildAtomicRMWSyncScope(4935    LLVMBuilderRef B, LLVMAtomicRMWBinOp op, LLVMValueRef PTR, LLVMValueRef Val,4936    LLVMAtomicOrdering ordering, unsigned SSID);4937LLVM_C_ABI LLVMValueRef LLVMBuildAtomicCmpXchg(4938    LLVMBuilderRef B, LLVMValueRef Ptr, LLVMValueRef Cmp, LLVMValueRef New,4939    LLVMAtomicOrdering SuccessOrdering, LLVMAtomicOrdering FailureOrdering,4940    LLVMBool SingleThread);4941LLVM_C_ABI LLVMValueRef LLVMBuildAtomicCmpXchgSyncScope(4942    LLVMBuilderRef B, LLVMValueRef Ptr, LLVMValueRef Cmp, LLVMValueRef New,4943    LLVMAtomicOrdering SuccessOrdering, LLVMAtomicOrdering FailureOrdering,4944    unsigned SSID);4945 4946/**4947 * Get the number of elements in the mask of a ShuffleVector instruction.4948 */4949LLVM_C_ABI unsigned LLVMGetNumMaskElements(LLVMValueRef ShuffleVectorInst);4950 4951/**4952 * \returns a constant that specifies that the result of a \c ShuffleVectorInst4953 * is undefined.4954 */4955LLVM_C_ABI int LLVMGetUndefMaskElem(void);4956 4957/**4958 * Get the mask value at position Elt in the mask of a ShuffleVector4959 * instruction.4960 *4961 * \Returns the result of \c LLVMGetUndefMaskElem() if the mask value is4962 * poison at that position.4963 */4964LLVM_C_ABI int LLVMGetMaskValue(LLVMValueRef ShuffleVectorInst, unsigned Elt);4965 4966LLVM_C_ABI LLVMBool LLVMIsAtomicSingleThread(LLVMValueRef AtomicInst);4967LLVM_C_ABI void LLVMSetAtomicSingleThread(LLVMValueRef AtomicInst,4968                                          LLVMBool SingleThread);4969 4970/**4971 * Returns whether an instruction is an atomic instruction, e.g., atomicrmw,4972 * cmpxchg, fence, or loads and stores with atomic ordering.4973 */4974LLVM_C_ABI LLVMBool LLVMIsAtomic(LLVMValueRef Inst);4975 4976/**4977 * Returns the synchronization scope ID of an atomic instruction.4978 */4979LLVM_C_ABI unsigned LLVMGetAtomicSyncScopeID(LLVMValueRef AtomicInst);4980 4981/**4982 * Sets the synchronization scope ID of an atomic instruction.4983 */4984LLVM_C_ABI void LLVMSetAtomicSyncScopeID(LLVMValueRef AtomicInst,4985                                         unsigned SSID);4986 4987LLVM_C_ABI LLVMAtomicOrdering4988LLVMGetCmpXchgSuccessOrdering(LLVMValueRef CmpXchgInst);4989LLVM_C_ABI void LLVMSetCmpXchgSuccessOrdering(LLVMValueRef CmpXchgInst,4990                                              LLVMAtomicOrdering Ordering);4991LLVM_C_ABI LLVMAtomicOrdering4992LLVMGetCmpXchgFailureOrdering(LLVMValueRef CmpXchgInst);4993LLVM_C_ABI void LLVMSetCmpXchgFailureOrdering(LLVMValueRef CmpXchgInst,4994                                              LLVMAtomicOrdering Ordering);4995 4996/**4997 * @}4998 */4999 5000/**5001 * @defgroup LLVMCCoreModuleProvider Module Providers5002 *5003 * @{5004 */5005 5006/**5007 * Changes the type of M so it can be passed to FunctionPassManagers and the5008 * JIT.  They take ModuleProviders for historical reasons.5009 */5010LLVM_C_ABI LLVMModuleProviderRef5011LLVMCreateModuleProviderForExistingModule(LLVMModuleRef M);5012 5013/**5014 * Destroys the module M.5015 */5016LLVM_C_ABI void LLVMDisposeModuleProvider(LLVMModuleProviderRef M);5017 5018/**5019 * @}5020 */5021 5022/**5023 * @defgroup LLVMCCoreMemoryBuffers Memory Buffers5024 *5025 * @{5026 */5027 5028LLVM_C_ABI LLVMBool LLVMCreateMemoryBufferWithContentsOfFile(5029    const char *Path, LLVMMemoryBufferRef *OutMemBuf, char **OutMessage);5030LLVM_C_ABI LLVMBool LLVMCreateMemoryBufferWithSTDIN(5031    LLVMMemoryBufferRef *OutMemBuf, char **OutMessage);5032LLVM_C_ABI LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRange(5033    const char *InputData, size_t InputDataLength, const char *BufferName,5034    LLVMBool RequiresNullTerminator);5035LLVM_C_ABI LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRangeCopy(5036    const char *InputData, size_t InputDataLength, const char *BufferName);5037LLVM_C_ABI const char *LLVMGetBufferStart(LLVMMemoryBufferRef MemBuf);5038LLVM_C_ABI size_t LLVMGetBufferSize(LLVMMemoryBufferRef MemBuf);5039LLVM_C_ABI void LLVMDisposeMemoryBuffer(LLVMMemoryBufferRef MemBuf);5040 5041/**5042 * @}5043 */5044 5045/**5046 * @defgroup LLVMCCorePassManagers Pass Managers5047 * @ingroup LLVMCCore5048 *5049 * @{5050 */5051 5052/** Constructs a new whole-module pass pipeline. This type of pipeline is5053    suitable for link-time optimization and whole-module transformations.5054    @see llvm::PassManager::PassManager */5055LLVM_C_ABI LLVMPassManagerRef LLVMCreatePassManager(void);5056 5057/** Constructs a new function-by-function pass pipeline over the module5058    provider. It does not take ownership of the module provider. This type of5059    pipeline is suitable for code generation and JIT compilation tasks.5060    @see llvm::FunctionPassManager::FunctionPassManager */5061LLVM_C_ABI LLVMPassManagerRef5062LLVMCreateFunctionPassManagerForModule(LLVMModuleRef M);5063 5064/** Deprecated: Use LLVMCreateFunctionPassManagerForModule instead. */5065LLVM_C_ABI LLVMPassManagerRef5066LLVMCreateFunctionPassManager(LLVMModuleProviderRef MP);5067 5068/** Initializes, executes on the provided module, and finalizes all of the5069    passes scheduled in the pass manager. Returns 1 if any of the passes5070    modified the module, 0 otherwise.5071    @see llvm::PassManager::run(Module&) */5072LLVM_C_ABI LLVMBool LLVMRunPassManager(LLVMPassManagerRef PM, LLVMModuleRef M);5073 5074/** Initializes all of the function passes scheduled in the function pass5075    manager. Returns 1 if any of the passes modified the module, 0 otherwise.5076    @see llvm::FunctionPassManager::doInitialization */5077LLVM_C_ABI LLVMBool LLVMInitializeFunctionPassManager(LLVMPassManagerRef FPM);5078 5079/** Executes all of the function passes scheduled in the function pass manager5080    on the provided function. Returns 1 if any of the passes modified the5081    function, false otherwise.5082    @see llvm::FunctionPassManager::run(Function&) */5083LLVM_C_ABI LLVMBool LLVMRunFunctionPassManager(LLVMPassManagerRef FPM,5084                                               LLVMValueRef F);5085 5086/** Finalizes all of the function passes scheduled in the function pass5087    manager. Returns 1 if any of the passes modified the module, 0 otherwise.5088    @see llvm::FunctionPassManager::doFinalization */5089LLVM_C_ABI LLVMBool LLVMFinalizeFunctionPassManager(LLVMPassManagerRef FPM);5090 5091/** Frees the memory of a pass pipeline. For function pipelines, does not free5092    the module provider.5093    @see llvm::PassManagerBase::~PassManagerBase. */5094LLVM_C_ABI void LLVMDisposePassManager(LLVMPassManagerRef PM);5095 5096/**5097 * @}5098 */5099 5100/**5101 * @defgroup LLVMCCoreThreading Threading5102 *5103 * Handle the structures needed to make LLVM safe for multithreading.5104 *5105 * @{5106 */5107 5108/** Deprecated: Multi-threading can only be enabled/disabled with the compile5109    time define LLVM_ENABLE_THREADS.  This function always returns5110    LLVMIsMultithreaded(). */5111LLVM_C_ABI LLVMBool LLVMStartMultithreaded(void);5112 5113/** Deprecated: Multi-threading can only be enabled/disabled with the compile5114    time define LLVM_ENABLE_THREADS. */5115LLVM_C_ABI void LLVMStopMultithreaded(void);5116 5117/** Check whether LLVM is executing in thread-safe mode or not.5118    @see llvm::llvm_is_multithreaded */5119LLVM_C_ABI LLVMBool LLVMIsMultithreaded(void);5120 5121/**5122 * @}5123 */5124 5125/**5126 * @}5127 */5128 5129/**5130 * @}5131 */5132 5133LLVM_C_EXTERN_C_END5134 5135#endif /* LLVM_C_CORE_H */5136