106f32e7eSjoerg /*===-- llvm-c/Core.h - Core Library C Interface ------------------*- C -*-===*\
206f32e7eSjoerg |*                                                                            *|
306f32e7eSjoerg |* Part of the LLVM Project, under the Apache License v2.0 with LLVM          *|
406f32e7eSjoerg |* Exceptions.                                                                *|
506f32e7eSjoerg |* See https://llvm.org/LICENSE.txt for license information.                  *|
606f32e7eSjoerg |* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception                    *|
706f32e7eSjoerg |*                                                                            *|
806f32e7eSjoerg |*===----------------------------------------------------------------------===*|
906f32e7eSjoerg |*                                                                            *|
1006f32e7eSjoerg |* This header declares the C interface to libLLVMCore.a, which implements    *|
1106f32e7eSjoerg |* the LLVM intermediate representation.                                      *|
1206f32e7eSjoerg |*                                                                            *|
1306f32e7eSjoerg \*===----------------------------------------------------------------------===*/
1406f32e7eSjoerg 
1506f32e7eSjoerg #ifndef LLVM_C_CORE_H
1606f32e7eSjoerg #define LLVM_C_CORE_H
1706f32e7eSjoerg 
1806f32e7eSjoerg #include "llvm-c/ErrorHandling.h"
19*da58b97aSjoerg #include "llvm-c/ExternC.h"
2006f32e7eSjoerg #include "llvm-c/Types.h"
2106f32e7eSjoerg 
22*da58b97aSjoerg LLVM_C_EXTERN_C_BEGIN
2306f32e7eSjoerg 
2406f32e7eSjoerg /**
2506f32e7eSjoerg  * @defgroup LLVMC LLVM-C: C interface to LLVM
2606f32e7eSjoerg  *
2706f32e7eSjoerg  * This module exposes parts of the LLVM library as a C API.
2806f32e7eSjoerg  *
2906f32e7eSjoerg  * @{
3006f32e7eSjoerg  */
3106f32e7eSjoerg 
3206f32e7eSjoerg /**
3306f32e7eSjoerg  * @defgroup LLVMCTransforms Transforms
3406f32e7eSjoerg  */
3506f32e7eSjoerg 
3606f32e7eSjoerg /**
3706f32e7eSjoerg  * @defgroup LLVMCCore Core
3806f32e7eSjoerg  *
3906f32e7eSjoerg  * This modules provide an interface to libLLVMCore, which implements
4006f32e7eSjoerg  * the LLVM intermediate representation as well as other related types
4106f32e7eSjoerg  * and utilities.
4206f32e7eSjoerg  *
4306f32e7eSjoerg  * Many exotic languages can interoperate with C code but have a harder time
4406f32e7eSjoerg  * with C++ due to name mangling. So in addition to C, this interface enables
4506f32e7eSjoerg  * tools written in such languages.
4606f32e7eSjoerg  *
4706f32e7eSjoerg  * @{
4806f32e7eSjoerg  */
4906f32e7eSjoerg 
5006f32e7eSjoerg /**
5106f32e7eSjoerg  * @defgroup LLVMCCoreTypes Types and Enumerations
5206f32e7eSjoerg  *
5306f32e7eSjoerg  * @{
5406f32e7eSjoerg  */
5506f32e7eSjoerg 
5606f32e7eSjoerg /// External users depend on the following values being stable. It is not safe
5706f32e7eSjoerg /// to reorder them.
5806f32e7eSjoerg typedef enum {
5906f32e7eSjoerg   /* Terminator Instructions */
6006f32e7eSjoerg   LLVMRet            = 1,
6106f32e7eSjoerg   LLVMBr             = 2,
6206f32e7eSjoerg   LLVMSwitch         = 3,
6306f32e7eSjoerg   LLVMIndirectBr     = 4,
6406f32e7eSjoerg   LLVMInvoke         = 5,
6506f32e7eSjoerg   /* removed 6 due to API changes */
6606f32e7eSjoerg   LLVMUnreachable    = 7,
6706f32e7eSjoerg   LLVMCallBr         = 67,
6806f32e7eSjoerg 
6906f32e7eSjoerg   /* Standard Unary Operators */
7006f32e7eSjoerg   LLVMFNeg           = 66,
7106f32e7eSjoerg 
7206f32e7eSjoerg   /* Standard Binary Operators */
7306f32e7eSjoerg   LLVMAdd            = 8,
7406f32e7eSjoerg   LLVMFAdd           = 9,
7506f32e7eSjoerg   LLVMSub            = 10,
7606f32e7eSjoerg   LLVMFSub           = 11,
7706f32e7eSjoerg   LLVMMul            = 12,
7806f32e7eSjoerg   LLVMFMul           = 13,
7906f32e7eSjoerg   LLVMUDiv           = 14,
8006f32e7eSjoerg   LLVMSDiv           = 15,
8106f32e7eSjoerg   LLVMFDiv           = 16,
8206f32e7eSjoerg   LLVMURem           = 17,
8306f32e7eSjoerg   LLVMSRem           = 18,
8406f32e7eSjoerg   LLVMFRem           = 19,
8506f32e7eSjoerg 
8606f32e7eSjoerg   /* Logical Operators */
8706f32e7eSjoerg   LLVMShl            = 20,
8806f32e7eSjoerg   LLVMLShr           = 21,
8906f32e7eSjoerg   LLVMAShr           = 22,
9006f32e7eSjoerg   LLVMAnd            = 23,
9106f32e7eSjoerg   LLVMOr             = 24,
9206f32e7eSjoerg   LLVMXor            = 25,
9306f32e7eSjoerg 
9406f32e7eSjoerg   /* Memory Operators */
9506f32e7eSjoerg   LLVMAlloca         = 26,
9606f32e7eSjoerg   LLVMLoad           = 27,
9706f32e7eSjoerg   LLVMStore          = 28,
9806f32e7eSjoerg   LLVMGetElementPtr  = 29,
9906f32e7eSjoerg 
10006f32e7eSjoerg   /* Cast Operators */
10106f32e7eSjoerg   LLVMTrunc          = 30,
10206f32e7eSjoerg   LLVMZExt           = 31,
10306f32e7eSjoerg   LLVMSExt           = 32,
10406f32e7eSjoerg   LLVMFPToUI         = 33,
10506f32e7eSjoerg   LLVMFPToSI         = 34,
10606f32e7eSjoerg   LLVMUIToFP         = 35,
10706f32e7eSjoerg   LLVMSIToFP         = 36,
10806f32e7eSjoerg   LLVMFPTrunc        = 37,
10906f32e7eSjoerg   LLVMFPExt          = 38,
11006f32e7eSjoerg   LLVMPtrToInt       = 39,
11106f32e7eSjoerg   LLVMIntToPtr       = 40,
11206f32e7eSjoerg   LLVMBitCast        = 41,
11306f32e7eSjoerg   LLVMAddrSpaceCast  = 60,
11406f32e7eSjoerg 
11506f32e7eSjoerg   /* Other Operators */
11606f32e7eSjoerg   LLVMICmp           = 42,
11706f32e7eSjoerg   LLVMFCmp           = 43,
11806f32e7eSjoerg   LLVMPHI            = 44,
11906f32e7eSjoerg   LLVMCall           = 45,
12006f32e7eSjoerg   LLVMSelect         = 46,
12106f32e7eSjoerg   LLVMUserOp1        = 47,
12206f32e7eSjoerg   LLVMUserOp2        = 48,
12306f32e7eSjoerg   LLVMVAArg          = 49,
12406f32e7eSjoerg   LLVMExtractElement = 50,
12506f32e7eSjoerg   LLVMInsertElement  = 51,
12606f32e7eSjoerg   LLVMShuffleVector  = 52,
12706f32e7eSjoerg   LLVMExtractValue   = 53,
12806f32e7eSjoerg   LLVMInsertValue    = 54,
129*da58b97aSjoerg   LLVMFreeze         = 68,
13006f32e7eSjoerg 
13106f32e7eSjoerg   /* Atomic operators */
13206f32e7eSjoerg   LLVMFence          = 55,
13306f32e7eSjoerg   LLVMAtomicCmpXchg  = 56,
13406f32e7eSjoerg   LLVMAtomicRMW      = 57,
13506f32e7eSjoerg 
13606f32e7eSjoerg   /* Exception Handling Operators */
13706f32e7eSjoerg   LLVMResume         = 58,
13806f32e7eSjoerg   LLVMLandingPad     = 59,
13906f32e7eSjoerg   LLVMCleanupRet     = 61,
14006f32e7eSjoerg   LLVMCatchRet       = 62,
14106f32e7eSjoerg   LLVMCatchPad       = 63,
14206f32e7eSjoerg   LLVMCleanupPad     = 64,
14306f32e7eSjoerg   LLVMCatchSwitch    = 65
14406f32e7eSjoerg } LLVMOpcode;
14506f32e7eSjoerg 
14606f32e7eSjoerg typedef enum {
14706f32e7eSjoerg   LLVMVoidTypeKind,      /**< type with no size */
14806f32e7eSjoerg   LLVMHalfTypeKind,      /**< 16 bit floating point type */
14906f32e7eSjoerg   LLVMFloatTypeKind,     /**< 32 bit floating point type */
15006f32e7eSjoerg   LLVMDoubleTypeKind,    /**< 64 bit floating point type */
15106f32e7eSjoerg   LLVMX86_FP80TypeKind,  /**< 80 bit floating point type (X87) */
15206f32e7eSjoerg   LLVMFP128TypeKind,     /**< 128 bit floating point type (112-bit mantissa)*/
15306f32e7eSjoerg   LLVMPPC_FP128TypeKind, /**< 128 bit floating point type (two 64-bits) */
15406f32e7eSjoerg   LLVMLabelTypeKind,     /**< Labels */
15506f32e7eSjoerg   LLVMIntegerTypeKind,   /**< Arbitrary bit width integers */
15606f32e7eSjoerg   LLVMFunctionTypeKind,  /**< Functions */
15706f32e7eSjoerg   LLVMStructTypeKind,    /**< Structures */
15806f32e7eSjoerg   LLVMArrayTypeKind,     /**< Arrays */
15906f32e7eSjoerg   LLVMPointerTypeKind,   /**< Pointers */
160*da58b97aSjoerg   LLVMVectorTypeKind,    /**< Fixed width SIMD vector type */
16106f32e7eSjoerg   LLVMMetadataTypeKind,  /**< Metadata */
16206f32e7eSjoerg   LLVMX86_MMXTypeKind,   /**< X86 MMX */
163*da58b97aSjoerg   LLVMTokenTypeKind,     /**< Tokens */
164*da58b97aSjoerg   LLVMScalableVectorTypeKind, /**< Scalable SIMD vector type */
165*da58b97aSjoerg   LLVMBFloatTypeKind,    /**< 16 bit brain floating point type */
166*da58b97aSjoerg   LLVMX86_AMXTypeKind    /**< X86 AMX */
16706f32e7eSjoerg } LLVMTypeKind;
16806f32e7eSjoerg 
16906f32e7eSjoerg typedef enum {
17006f32e7eSjoerg   LLVMExternalLinkage,    /**< Externally visible function */
17106f32e7eSjoerg   LLVMAvailableExternallyLinkage,
17206f32e7eSjoerg   LLVMLinkOnceAnyLinkage, /**< Keep one copy of function when linking (inline)*/
17306f32e7eSjoerg   LLVMLinkOnceODRLinkage, /**< Same, but only replaced by something
17406f32e7eSjoerg                             equivalent. */
17506f32e7eSjoerg   LLVMLinkOnceODRAutoHideLinkage, /**< Obsolete */
17606f32e7eSjoerg   LLVMWeakAnyLinkage,     /**< Keep one copy of function when linking (weak) */
17706f32e7eSjoerg   LLVMWeakODRLinkage,     /**< Same, but only replaced by something
17806f32e7eSjoerg                             equivalent. */
17906f32e7eSjoerg   LLVMAppendingLinkage,   /**< Special purpose, only applies to global arrays */
18006f32e7eSjoerg   LLVMInternalLinkage,    /**< Rename collisions when linking (static
18106f32e7eSjoerg                                functions) */
18206f32e7eSjoerg   LLVMPrivateLinkage,     /**< Like Internal, but omit from symbol table */
18306f32e7eSjoerg   LLVMDLLImportLinkage,   /**< Obsolete */
18406f32e7eSjoerg   LLVMDLLExportLinkage,   /**< Obsolete */
18506f32e7eSjoerg   LLVMExternalWeakLinkage,/**< ExternalWeak linkage description */
18606f32e7eSjoerg   LLVMGhostLinkage,       /**< Obsolete */
18706f32e7eSjoerg   LLVMCommonLinkage,      /**< Tentative definitions */
18806f32e7eSjoerg   LLVMLinkerPrivateLinkage, /**< Like Private, but linker removes. */
18906f32e7eSjoerg   LLVMLinkerPrivateWeakLinkage /**< Like LinkerPrivate, but is weak. */
19006f32e7eSjoerg } LLVMLinkage;
19106f32e7eSjoerg 
19206f32e7eSjoerg typedef enum {
19306f32e7eSjoerg   LLVMDefaultVisibility,  /**< The GV is visible */
19406f32e7eSjoerg   LLVMHiddenVisibility,   /**< The GV is hidden */
19506f32e7eSjoerg   LLVMProtectedVisibility /**< The GV is protected */
19606f32e7eSjoerg } LLVMVisibility;
19706f32e7eSjoerg 
19806f32e7eSjoerg typedef enum {
19906f32e7eSjoerg   LLVMNoUnnamedAddr,    /**< Address of the GV is significant. */
20006f32e7eSjoerg   LLVMLocalUnnamedAddr, /**< Address of the GV is locally insignificant. */
20106f32e7eSjoerg   LLVMGlobalUnnamedAddr /**< Address of the GV is globally insignificant. */
20206f32e7eSjoerg } LLVMUnnamedAddr;
20306f32e7eSjoerg 
20406f32e7eSjoerg typedef enum {
20506f32e7eSjoerg   LLVMDefaultStorageClass   = 0,
20606f32e7eSjoerg   LLVMDLLImportStorageClass = 1, /**< Function to be imported from DLL. */
20706f32e7eSjoerg   LLVMDLLExportStorageClass = 2  /**< Function to be accessible from DLL. */
20806f32e7eSjoerg } LLVMDLLStorageClass;
20906f32e7eSjoerg 
21006f32e7eSjoerg typedef enum {
21106f32e7eSjoerg   LLVMCCallConv             = 0,
21206f32e7eSjoerg   LLVMFastCallConv          = 8,
21306f32e7eSjoerg   LLVMColdCallConv          = 9,
21406f32e7eSjoerg   LLVMGHCCallConv           = 10,
21506f32e7eSjoerg   LLVMHiPECallConv          = 11,
21606f32e7eSjoerg   LLVMWebKitJSCallConv      = 12,
21706f32e7eSjoerg   LLVMAnyRegCallConv        = 13,
21806f32e7eSjoerg   LLVMPreserveMostCallConv  = 14,
21906f32e7eSjoerg   LLVMPreserveAllCallConv   = 15,
22006f32e7eSjoerg   LLVMSwiftCallConv         = 16,
22106f32e7eSjoerg   LLVMCXXFASTTLSCallConv    = 17,
22206f32e7eSjoerg   LLVMX86StdcallCallConv    = 64,
22306f32e7eSjoerg   LLVMX86FastcallCallConv   = 65,
22406f32e7eSjoerg   LLVMARMAPCSCallConv       = 66,
22506f32e7eSjoerg   LLVMARMAAPCSCallConv      = 67,
22606f32e7eSjoerg   LLVMARMAAPCSVFPCallConv   = 68,
22706f32e7eSjoerg   LLVMMSP430INTRCallConv    = 69,
22806f32e7eSjoerg   LLVMX86ThisCallCallConv   = 70,
22906f32e7eSjoerg   LLVMPTXKernelCallConv     = 71,
23006f32e7eSjoerg   LLVMPTXDeviceCallConv     = 72,
23106f32e7eSjoerg   LLVMSPIRFUNCCallConv      = 75,
23206f32e7eSjoerg   LLVMSPIRKERNELCallConv    = 76,
23306f32e7eSjoerg   LLVMIntelOCLBICallConv    = 77,
23406f32e7eSjoerg   LLVMX8664SysVCallConv     = 78,
23506f32e7eSjoerg   LLVMWin64CallConv         = 79,
23606f32e7eSjoerg   LLVMX86VectorCallCallConv = 80,
23706f32e7eSjoerg   LLVMHHVMCallConv          = 81,
23806f32e7eSjoerg   LLVMHHVMCCallConv         = 82,
23906f32e7eSjoerg   LLVMX86INTRCallConv       = 83,
24006f32e7eSjoerg   LLVMAVRINTRCallConv       = 84,
24106f32e7eSjoerg   LLVMAVRSIGNALCallConv     = 85,
24206f32e7eSjoerg   LLVMAVRBUILTINCallConv    = 86,
24306f32e7eSjoerg   LLVMAMDGPUVSCallConv      = 87,
24406f32e7eSjoerg   LLVMAMDGPUGSCallConv      = 88,
24506f32e7eSjoerg   LLVMAMDGPUPSCallConv      = 89,
24606f32e7eSjoerg   LLVMAMDGPUCSCallConv      = 90,
24706f32e7eSjoerg   LLVMAMDGPUKERNELCallConv  = 91,
24806f32e7eSjoerg   LLVMX86RegCallCallConv    = 92,
24906f32e7eSjoerg   LLVMAMDGPUHSCallConv      = 93,
25006f32e7eSjoerg   LLVMMSP430BUILTINCallConv = 94,
25106f32e7eSjoerg   LLVMAMDGPULSCallConv      = 95,
25206f32e7eSjoerg   LLVMAMDGPUESCallConv      = 96
25306f32e7eSjoerg } LLVMCallConv;
25406f32e7eSjoerg 
25506f32e7eSjoerg typedef enum {
25606f32e7eSjoerg   LLVMArgumentValueKind,
25706f32e7eSjoerg   LLVMBasicBlockValueKind,
25806f32e7eSjoerg   LLVMMemoryUseValueKind,
25906f32e7eSjoerg   LLVMMemoryDefValueKind,
26006f32e7eSjoerg   LLVMMemoryPhiValueKind,
26106f32e7eSjoerg 
26206f32e7eSjoerg   LLVMFunctionValueKind,
26306f32e7eSjoerg   LLVMGlobalAliasValueKind,
26406f32e7eSjoerg   LLVMGlobalIFuncValueKind,
26506f32e7eSjoerg   LLVMGlobalVariableValueKind,
26606f32e7eSjoerg   LLVMBlockAddressValueKind,
26706f32e7eSjoerg   LLVMConstantExprValueKind,
26806f32e7eSjoerg   LLVMConstantArrayValueKind,
26906f32e7eSjoerg   LLVMConstantStructValueKind,
27006f32e7eSjoerg   LLVMConstantVectorValueKind,
27106f32e7eSjoerg 
27206f32e7eSjoerg   LLVMUndefValueValueKind,
27306f32e7eSjoerg   LLVMConstantAggregateZeroValueKind,
27406f32e7eSjoerg   LLVMConstantDataArrayValueKind,
27506f32e7eSjoerg   LLVMConstantDataVectorValueKind,
27606f32e7eSjoerg   LLVMConstantIntValueKind,
27706f32e7eSjoerg   LLVMConstantFPValueKind,
27806f32e7eSjoerg   LLVMConstantPointerNullValueKind,
27906f32e7eSjoerg   LLVMConstantTokenNoneValueKind,
28006f32e7eSjoerg 
28106f32e7eSjoerg   LLVMMetadataAsValueValueKind,
28206f32e7eSjoerg   LLVMInlineAsmValueKind,
28306f32e7eSjoerg 
28406f32e7eSjoerg   LLVMInstructionValueKind,
285*da58b97aSjoerg   LLVMPoisonValueValueKind
28606f32e7eSjoerg } LLVMValueKind;
28706f32e7eSjoerg 
28806f32e7eSjoerg typedef enum {
28906f32e7eSjoerg   LLVMIntEQ = 32, /**< equal */
29006f32e7eSjoerg   LLVMIntNE,      /**< not equal */
29106f32e7eSjoerg   LLVMIntUGT,     /**< unsigned greater than */
29206f32e7eSjoerg   LLVMIntUGE,     /**< unsigned greater or equal */
29306f32e7eSjoerg   LLVMIntULT,     /**< unsigned less than */
29406f32e7eSjoerg   LLVMIntULE,     /**< unsigned less or equal */
29506f32e7eSjoerg   LLVMIntSGT,     /**< signed greater than */
29606f32e7eSjoerg   LLVMIntSGE,     /**< signed greater or equal */
29706f32e7eSjoerg   LLVMIntSLT,     /**< signed less than */
29806f32e7eSjoerg   LLVMIntSLE      /**< signed less or equal */
29906f32e7eSjoerg } LLVMIntPredicate;
30006f32e7eSjoerg 
30106f32e7eSjoerg typedef enum {
30206f32e7eSjoerg   LLVMRealPredicateFalse, /**< Always false (always folded) */
30306f32e7eSjoerg   LLVMRealOEQ,            /**< True if ordered and equal */
30406f32e7eSjoerg   LLVMRealOGT,            /**< True if ordered and greater than */
30506f32e7eSjoerg   LLVMRealOGE,            /**< True if ordered and greater than or equal */
30606f32e7eSjoerg   LLVMRealOLT,            /**< True if ordered and less than */
30706f32e7eSjoerg   LLVMRealOLE,            /**< True if ordered and less than or equal */
30806f32e7eSjoerg   LLVMRealONE,            /**< True if ordered and operands are unequal */
30906f32e7eSjoerg   LLVMRealORD,            /**< True if ordered (no nans) */
31006f32e7eSjoerg   LLVMRealUNO,            /**< True if unordered: isnan(X) | isnan(Y) */
31106f32e7eSjoerg   LLVMRealUEQ,            /**< True if unordered or equal */
31206f32e7eSjoerg   LLVMRealUGT,            /**< True if unordered or greater than */
31306f32e7eSjoerg   LLVMRealUGE,            /**< True if unordered, greater than, or equal */
31406f32e7eSjoerg   LLVMRealULT,            /**< True if unordered or less than */
31506f32e7eSjoerg   LLVMRealULE,            /**< True if unordered, less than, or equal */
31606f32e7eSjoerg   LLVMRealUNE,            /**< True if unordered or not equal */
31706f32e7eSjoerg   LLVMRealPredicateTrue   /**< Always true (always folded) */
31806f32e7eSjoerg } LLVMRealPredicate;
31906f32e7eSjoerg 
32006f32e7eSjoerg typedef enum {
32106f32e7eSjoerg   LLVMLandingPadCatch,    /**< A catch clause   */
32206f32e7eSjoerg   LLVMLandingPadFilter    /**< A filter clause  */
32306f32e7eSjoerg } LLVMLandingPadClauseTy;
32406f32e7eSjoerg 
32506f32e7eSjoerg typedef enum {
32606f32e7eSjoerg   LLVMNotThreadLocal = 0,
32706f32e7eSjoerg   LLVMGeneralDynamicTLSModel,
32806f32e7eSjoerg   LLVMLocalDynamicTLSModel,
32906f32e7eSjoerg   LLVMInitialExecTLSModel,
33006f32e7eSjoerg   LLVMLocalExecTLSModel
33106f32e7eSjoerg } LLVMThreadLocalMode;
33206f32e7eSjoerg 
33306f32e7eSjoerg typedef enum {
33406f32e7eSjoerg   LLVMAtomicOrderingNotAtomic = 0, /**< A load or store which is not atomic */
33506f32e7eSjoerg   LLVMAtomicOrderingUnordered = 1, /**< Lowest level of atomicity, guarantees
33606f32e7eSjoerg                                      somewhat sane results, lock free. */
33706f32e7eSjoerg   LLVMAtomicOrderingMonotonic = 2, /**< guarantees that if you take all the
33806f32e7eSjoerg                                      operations affecting a specific address,
33906f32e7eSjoerg                                      a consistent ordering exists */
34006f32e7eSjoerg   LLVMAtomicOrderingAcquire = 4, /**< Acquire provides a barrier of the sort
34106f32e7eSjoerg                                    necessary to acquire a lock to access other
34206f32e7eSjoerg                                    memory with normal loads and stores. */
34306f32e7eSjoerg   LLVMAtomicOrderingRelease = 5, /**< Release is similar to Acquire, but with
34406f32e7eSjoerg                                    a barrier of the sort necessary to release
34506f32e7eSjoerg                                    a lock. */
34606f32e7eSjoerg   LLVMAtomicOrderingAcquireRelease = 6, /**< provides both an Acquire and a
34706f32e7eSjoerg                                           Release barrier (for fences and
34806f32e7eSjoerg                                           operations which both read and write
34906f32e7eSjoerg                                            memory). */
35006f32e7eSjoerg   LLVMAtomicOrderingSequentiallyConsistent = 7 /**< provides Acquire semantics
35106f32e7eSjoerg                                                  for loads and Release
35206f32e7eSjoerg                                                  semantics for stores.
35306f32e7eSjoerg                                                  Additionally, it guarantees
35406f32e7eSjoerg                                                  that a total ordering exists
35506f32e7eSjoerg                                                  between all
35606f32e7eSjoerg                                                  SequentiallyConsistent
35706f32e7eSjoerg                                                  operations. */
35806f32e7eSjoerg } LLVMAtomicOrdering;
35906f32e7eSjoerg 
36006f32e7eSjoerg typedef enum {
36106f32e7eSjoerg     LLVMAtomicRMWBinOpXchg, /**< Set the new value and return the one old */
36206f32e7eSjoerg     LLVMAtomicRMWBinOpAdd, /**< Add a value and return the old one */
36306f32e7eSjoerg     LLVMAtomicRMWBinOpSub, /**< Subtract a value and return the old one */
36406f32e7eSjoerg     LLVMAtomicRMWBinOpAnd, /**< And a value and return the old one */
36506f32e7eSjoerg     LLVMAtomicRMWBinOpNand, /**< Not-And a value and return the old one */
36606f32e7eSjoerg     LLVMAtomicRMWBinOpOr, /**< OR a value and return the old one */
36706f32e7eSjoerg     LLVMAtomicRMWBinOpXor, /**< Xor a value and return the old one */
36806f32e7eSjoerg     LLVMAtomicRMWBinOpMax, /**< Sets the value if it's greater than the
36906f32e7eSjoerg                              original using a signed comparison and return
37006f32e7eSjoerg                              the old one */
37106f32e7eSjoerg     LLVMAtomicRMWBinOpMin, /**< Sets the value if it's Smaller than the
37206f32e7eSjoerg                              original using a signed comparison and return
37306f32e7eSjoerg                              the old one */
37406f32e7eSjoerg     LLVMAtomicRMWBinOpUMax, /**< Sets the value if it's greater than the
37506f32e7eSjoerg                              original using an unsigned comparison and return
37606f32e7eSjoerg                              the old one */
37706f32e7eSjoerg     LLVMAtomicRMWBinOpUMin, /**< Sets the value if it's greater than the
37806f32e7eSjoerg                               original using an unsigned comparison and return
37906f32e7eSjoerg                               the old one */
38006f32e7eSjoerg     LLVMAtomicRMWBinOpFAdd, /**< Add a floating point value and return the
38106f32e7eSjoerg                               old one */
38206f32e7eSjoerg     LLVMAtomicRMWBinOpFSub /**< Subtract a floating point value and return the
38306f32e7eSjoerg                              old one */
38406f32e7eSjoerg } LLVMAtomicRMWBinOp;
38506f32e7eSjoerg 
38606f32e7eSjoerg typedef enum {
38706f32e7eSjoerg     LLVMDSError,
38806f32e7eSjoerg     LLVMDSWarning,
38906f32e7eSjoerg     LLVMDSRemark,
39006f32e7eSjoerg     LLVMDSNote
39106f32e7eSjoerg } LLVMDiagnosticSeverity;
39206f32e7eSjoerg 
39306f32e7eSjoerg typedef enum {
39406f32e7eSjoerg   LLVMInlineAsmDialectATT,
39506f32e7eSjoerg   LLVMInlineAsmDialectIntel
39606f32e7eSjoerg } LLVMInlineAsmDialect;
39706f32e7eSjoerg 
39806f32e7eSjoerg typedef enum {
39906f32e7eSjoerg   /**
40006f32e7eSjoerg    * Emits an error if two values disagree, otherwise the resulting value is
40106f32e7eSjoerg    * that of the operands.
40206f32e7eSjoerg    *
40306f32e7eSjoerg    * @see Module::ModFlagBehavior::Error
40406f32e7eSjoerg    */
40506f32e7eSjoerg   LLVMModuleFlagBehaviorError,
40606f32e7eSjoerg   /**
40706f32e7eSjoerg    * Emits a warning if two values disagree. The result value will be the
40806f32e7eSjoerg    * operand for the flag from the first module being linked.
40906f32e7eSjoerg    *
41006f32e7eSjoerg    * @see Module::ModFlagBehavior::Warning
41106f32e7eSjoerg    */
41206f32e7eSjoerg   LLVMModuleFlagBehaviorWarning,
41306f32e7eSjoerg   /**
41406f32e7eSjoerg    * Adds a requirement that another module flag be present and have a
41506f32e7eSjoerg    * specified value after linking is performed. The value must be a metadata
41606f32e7eSjoerg    * pair, where the first element of the pair is the ID of the module flag
41706f32e7eSjoerg    * to be restricted, and the second element of the pair is the value the
41806f32e7eSjoerg    * module flag should be restricted to. This behavior can be used to
41906f32e7eSjoerg    * restrict the allowable results (via triggering of an error) of linking
42006f32e7eSjoerg    * IDs with the **Override** behavior.
42106f32e7eSjoerg    *
42206f32e7eSjoerg    * @see Module::ModFlagBehavior::Require
42306f32e7eSjoerg    */
42406f32e7eSjoerg   LLVMModuleFlagBehaviorRequire,
42506f32e7eSjoerg   /**
42606f32e7eSjoerg    * Uses the specified value, regardless of the behavior or value of the
42706f32e7eSjoerg    * other module. If both modules specify **Override**, but the values
42806f32e7eSjoerg    * differ, an error will be emitted.
42906f32e7eSjoerg    *
43006f32e7eSjoerg    * @see Module::ModFlagBehavior::Override
43106f32e7eSjoerg    */
43206f32e7eSjoerg   LLVMModuleFlagBehaviorOverride,
43306f32e7eSjoerg   /**
43406f32e7eSjoerg    * Appends the two values, which are required to be metadata nodes.
43506f32e7eSjoerg    *
43606f32e7eSjoerg    * @see Module::ModFlagBehavior::Append
43706f32e7eSjoerg    */
43806f32e7eSjoerg   LLVMModuleFlagBehaviorAppend,
43906f32e7eSjoerg   /**
44006f32e7eSjoerg    * Appends the two values, which are required to be metadata
44106f32e7eSjoerg    * nodes. However, duplicate entries in the second list are dropped
44206f32e7eSjoerg    * during the append operation.
44306f32e7eSjoerg    *
44406f32e7eSjoerg    * @see Module::ModFlagBehavior::AppendUnique
44506f32e7eSjoerg    */
44606f32e7eSjoerg   LLVMModuleFlagBehaviorAppendUnique,
44706f32e7eSjoerg } LLVMModuleFlagBehavior;
44806f32e7eSjoerg 
44906f32e7eSjoerg /**
45006f32e7eSjoerg  * Attribute index are either LLVMAttributeReturnIndex,
45106f32e7eSjoerg  * LLVMAttributeFunctionIndex or a parameter number from 1 to N.
45206f32e7eSjoerg  */
45306f32e7eSjoerg enum {
45406f32e7eSjoerg   LLVMAttributeReturnIndex = 0U,
45506f32e7eSjoerg   // ISO C restricts enumerator values to range of 'int'
45606f32e7eSjoerg   // (4294967295 is too large)
45706f32e7eSjoerg   // LLVMAttributeFunctionIndex = ~0U,
45806f32e7eSjoerg   LLVMAttributeFunctionIndex = -1,
45906f32e7eSjoerg };
46006f32e7eSjoerg 
46106f32e7eSjoerg typedef unsigned LLVMAttributeIndex;
46206f32e7eSjoerg 
46306f32e7eSjoerg /**
46406f32e7eSjoerg  * @}
46506f32e7eSjoerg  */
46606f32e7eSjoerg 
46706f32e7eSjoerg void LLVMInitializeCore(LLVMPassRegistryRef R);
46806f32e7eSjoerg 
46906f32e7eSjoerg /** Deallocate and destroy all ManagedStatic variables.
47006f32e7eSjoerg     @see llvm::llvm_shutdown
47106f32e7eSjoerg     @see ManagedStatic */
47206f32e7eSjoerg void LLVMShutdown(void);
47306f32e7eSjoerg 
47406f32e7eSjoerg /*===-- Error handling ----------------------------------------------------===*/
47506f32e7eSjoerg 
47606f32e7eSjoerg char *LLVMCreateMessage(const char *Message);
47706f32e7eSjoerg void LLVMDisposeMessage(char *Message);
47806f32e7eSjoerg 
47906f32e7eSjoerg /**
48006f32e7eSjoerg  * @defgroup LLVMCCoreContext Contexts
48106f32e7eSjoerg  *
48206f32e7eSjoerg  * Contexts are execution states for the core LLVM IR system.
48306f32e7eSjoerg  *
48406f32e7eSjoerg  * Most types are tied to a context instance. Multiple contexts can
48506f32e7eSjoerg  * exist simultaneously. A single context is not thread safe. However,
48606f32e7eSjoerg  * different contexts can execute on different threads simultaneously.
48706f32e7eSjoerg  *
48806f32e7eSjoerg  * @{
48906f32e7eSjoerg  */
49006f32e7eSjoerg 
49106f32e7eSjoerg typedef void (*LLVMDiagnosticHandler)(LLVMDiagnosticInfoRef, void *);
49206f32e7eSjoerg typedef void (*LLVMYieldCallback)(LLVMContextRef, void *);
49306f32e7eSjoerg 
49406f32e7eSjoerg /**
49506f32e7eSjoerg  * Create a new context.
49606f32e7eSjoerg  *
49706f32e7eSjoerg  * Every call to this function should be paired with a call to
49806f32e7eSjoerg  * LLVMContextDispose() or the context will leak memory.
49906f32e7eSjoerg  */
50006f32e7eSjoerg LLVMContextRef LLVMContextCreate(void);
50106f32e7eSjoerg 
50206f32e7eSjoerg /**
50306f32e7eSjoerg  * Obtain the global context instance.
50406f32e7eSjoerg  */
50506f32e7eSjoerg LLVMContextRef LLVMGetGlobalContext(void);
50606f32e7eSjoerg 
50706f32e7eSjoerg /**
50806f32e7eSjoerg  * Set the diagnostic handler for this context.
50906f32e7eSjoerg  */
51006f32e7eSjoerg void LLVMContextSetDiagnosticHandler(LLVMContextRef C,
51106f32e7eSjoerg                                      LLVMDiagnosticHandler Handler,
51206f32e7eSjoerg                                      void *DiagnosticContext);
51306f32e7eSjoerg 
51406f32e7eSjoerg /**
51506f32e7eSjoerg  * Get the diagnostic handler of this context.
51606f32e7eSjoerg  */
51706f32e7eSjoerg LLVMDiagnosticHandler LLVMContextGetDiagnosticHandler(LLVMContextRef C);
51806f32e7eSjoerg 
51906f32e7eSjoerg /**
52006f32e7eSjoerg  * Get the diagnostic context of this context.
52106f32e7eSjoerg  */
52206f32e7eSjoerg void *LLVMContextGetDiagnosticContext(LLVMContextRef C);
52306f32e7eSjoerg 
52406f32e7eSjoerg /**
52506f32e7eSjoerg  * Set the yield callback function for this context.
52606f32e7eSjoerg  *
52706f32e7eSjoerg  * @see LLVMContext::setYieldCallback()
52806f32e7eSjoerg  */
52906f32e7eSjoerg void LLVMContextSetYieldCallback(LLVMContextRef C, LLVMYieldCallback Callback,
53006f32e7eSjoerg                                  void *OpaqueHandle);
53106f32e7eSjoerg 
53206f32e7eSjoerg /**
53306f32e7eSjoerg  * Retrieve whether the given context is set to discard all value names.
53406f32e7eSjoerg  *
53506f32e7eSjoerg  * @see LLVMContext::shouldDiscardValueNames()
53606f32e7eSjoerg  */
53706f32e7eSjoerg LLVMBool LLVMContextShouldDiscardValueNames(LLVMContextRef C);
53806f32e7eSjoerg 
53906f32e7eSjoerg /**
54006f32e7eSjoerg  * Set whether the given context discards all value names.
54106f32e7eSjoerg  *
54206f32e7eSjoerg  * If true, only the names of GlobalValue objects will be available in the IR.
54306f32e7eSjoerg  * This can be used to save memory and runtime, especially in release mode.
54406f32e7eSjoerg  *
54506f32e7eSjoerg  * @see LLVMContext::setDiscardValueNames()
54606f32e7eSjoerg  */
54706f32e7eSjoerg void LLVMContextSetDiscardValueNames(LLVMContextRef C, LLVMBool Discard);
54806f32e7eSjoerg 
54906f32e7eSjoerg /**
55006f32e7eSjoerg  * Destroy a context instance.
55106f32e7eSjoerg  *
55206f32e7eSjoerg  * This should be called for every call to LLVMContextCreate() or memory
55306f32e7eSjoerg  * will be leaked.
55406f32e7eSjoerg  */
55506f32e7eSjoerg void LLVMContextDispose(LLVMContextRef C);
55606f32e7eSjoerg 
55706f32e7eSjoerg /**
55806f32e7eSjoerg  * Return a string representation of the DiagnosticInfo. Use
55906f32e7eSjoerg  * LLVMDisposeMessage to free the string.
56006f32e7eSjoerg  *
56106f32e7eSjoerg  * @see DiagnosticInfo::print()
56206f32e7eSjoerg  */
56306f32e7eSjoerg char *LLVMGetDiagInfoDescription(LLVMDiagnosticInfoRef DI);
56406f32e7eSjoerg 
56506f32e7eSjoerg /**
56606f32e7eSjoerg  * Return an enum LLVMDiagnosticSeverity.
56706f32e7eSjoerg  *
56806f32e7eSjoerg  * @see DiagnosticInfo::getSeverity()
56906f32e7eSjoerg  */
57006f32e7eSjoerg LLVMDiagnosticSeverity LLVMGetDiagInfoSeverity(LLVMDiagnosticInfoRef DI);
57106f32e7eSjoerg 
57206f32e7eSjoerg unsigned LLVMGetMDKindIDInContext(LLVMContextRef C, const char *Name,
57306f32e7eSjoerg                                   unsigned SLen);
57406f32e7eSjoerg unsigned LLVMGetMDKindID(const char *Name, unsigned SLen);
57506f32e7eSjoerg 
57606f32e7eSjoerg /**
57706f32e7eSjoerg  * Return an unique id given the name of a enum attribute,
57806f32e7eSjoerg  * or 0 if no attribute by that name exists.
57906f32e7eSjoerg  *
58006f32e7eSjoerg  * See http://llvm.org/docs/LangRef.html#parameter-attributes
58106f32e7eSjoerg  * and http://llvm.org/docs/LangRef.html#function-attributes
58206f32e7eSjoerg  * for the list of available attributes.
58306f32e7eSjoerg  *
58406f32e7eSjoerg  * NB: Attribute names and/or id are subject to change without
58506f32e7eSjoerg  * going through the C API deprecation cycle.
58606f32e7eSjoerg  */
58706f32e7eSjoerg unsigned LLVMGetEnumAttributeKindForName(const char *Name, size_t SLen);
58806f32e7eSjoerg unsigned LLVMGetLastEnumAttributeKind(void);
58906f32e7eSjoerg 
59006f32e7eSjoerg /**
59106f32e7eSjoerg  * Create an enum attribute.
59206f32e7eSjoerg  */
59306f32e7eSjoerg LLVMAttributeRef LLVMCreateEnumAttribute(LLVMContextRef C, unsigned KindID,
59406f32e7eSjoerg                                          uint64_t Val);
59506f32e7eSjoerg 
59606f32e7eSjoerg /**
59706f32e7eSjoerg  * Get the unique id corresponding to the enum attribute
59806f32e7eSjoerg  * passed as argument.
59906f32e7eSjoerg  */
60006f32e7eSjoerg unsigned LLVMGetEnumAttributeKind(LLVMAttributeRef A);
60106f32e7eSjoerg 
60206f32e7eSjoerg /**
60306f32e7eSjoerg  * Get the enum attribute's value. 0 is returned if none exists.
60406f32e7eSjoerg  */
60506f32e7eSjoerg uint64_t LLVMGetEnumAttributeValue(LLVMAttributeRef A);
60606f32e7eSjoerg 
60706f32e7eSjoerg /**
608*da58b97aSjoerg  * Create a type attribute
609*da58b97aSjoerg  */
610*da58b97aSjoerg LLVMAttributeRef LLVMCreateTypeAttribute(LLVMContextRef C, unsigned KindID,
611*da58b97aSjoerg                                          LLVMTypeRef type_ref);
612*da58b97aSjoerg 
613*da58b97aSjoerg /**
614*da58b97aSjoerg  * Get the type attribute's value.
615*da58b97aSjoerg  */
616*da58b97aSjoerg LLVMTypeRef LLVMGetTypeAttributeValue(LLVMAttributeRef A);
617*da58b97aSjoerg 
618*da58b97aSjoerg /**
61906f32e7eSjoerg  * Create a string attribute.
62006f32e7eSjoerg  */
62106f32e7eSjoerg LLVMAttributeRef LLVMCreateStringAttribute(LLVMContextRef C,
62206f32e7eSjoerg                                            const char *K, unsigned KLength,
62306f32e7eSjoerg                                            const char *V, unsigned VLength);
62406f32e7eSjoerg 
62506f32e7eSjoerg /**
62606f32e7eSjoerg  * Get the string attribute's kind.
62706f32e7eSjoerg  */
62806f32e7eSjoerg const char *LLVMGetStringAttributeKind(LLVMAttributeRef A, unsigned *Length);
62906f32e7eSjoerg 
63006f32e7eSjoerg /**
63106f32e7eSjoerg  * Get the string attribute's value.
63206f32e7eSjoerg  */
63306f32e7eSjoerg const char *LLVMGetStringAttributeValue(LLVMAttributeRef A, unsigned *Length);
63406f32e7eSjoerg 
63506f32e7eSjoerg /**
63606f32e7eSjoerg  * Check for the different types of attributes.
63706f32e7eSjoerg  */
63806f32e7eSjoerg LLVMBool LLVMIsEnumAttribute(LLVMAttributeRef A);
63906f32e7eSjoerg LLVMBool LLVMIsStringAttribute(LLVMAttributeRef A);
640*da58b97aSjoerg LLVMBool LLVMIsTypeAttribute(LLVMAttributeRef A);
641*da58b97aSjoerg 
642*da58b97aSjoerg /**
643*da58b97aSjoerg  * Obtain a Type from a context by its registered name.
644*da58b97aSjoerg  */
645*da58b97aSjoerg LLVMTypeRef LLVMGetTypeByName2(LLVMContextRef C, const char *Name);
64606f32e7eSjoerg 
64706f32e7eSjoerg /**
64806f32e7eSjoerg  * @}
64906f32e7eSjoerg  */
65006f32e7eSjoerg 
65106f32e7eSjoerg /**
65206f32e7eSjoerg  * @defgroup LLVMCCoreModule Modules
65306f32e7eSjoerg  *
65406f32e7eSjoerg  * Modules represent the top-level structure in an LLVM program. An LLVM
65506f32e7eSjoerg  * module is effectively a translation unit or a collection of
65606f32e7eSjoerg  * translation units merged together.
65706f32e7eSjoerg  *
65806f32e7eSjoerg  * @{
65906f32e7eSjoerg  */
66006f32e7eSjoerg 
66106f32e7eSjoerg /**
66206f32e7eSjoerg  * Create a new, empty module in the global context.
66306f32e7eSjoerg  *
66406f32e7eSjoerg  * This is equivalent to calling LLVMModuleCreateWithNameInContext with
66506f32e7eSjoerg  * LLVMGetGlobalContext() as the context parameter.
66606f32e7eSjoerg  *
66706f32e7eSjoerg  * Every invocation should be paired with LLVMDisposeModule() or memory
66806f32e7eSjoerg  * will be leaked.
66906f32e7eSjoerg  */
67006f32e7eSjoerg LLVMModuleRef LLVMModuleCreateWithName(const char *ModuleID);
67106f32e7eSjoerg 
67206f32e7eSjoerg /**
67306f32e7eSjoerg  * Create a new, empty module in a specific context.
67406f32e7eSjoerg  *
67506f32e7eSjoerg  * Every invocation should be paired with LLVMDisposeModule() or memory
67606f32e7eSjoerg  * will be leaked.
67706f32e7eSjoerg  */
67806f32e7eSjoerg LLVMModuleRef LLVMModuleCreateWithNameInContext(const char *ModuleID,
67906f32e7eSjoerg                                                 LLVMContextRef C);
68006f32e7eSjoerg /**
68106f32e7eSjoerg  * Return an exact copy of the specified module.
68206f32e7eSjoerg  */
68306f32e7eSjoerg LLVMModuleRef LLVMCloneModule(LLVMModuleRef M);
68406f32e7eSjoerg 
68506f32e7eSjoerg /**
68606f32e7eSjoerg  * Destroy a module instance.
68706f32e7eSjoerg  *
68806f32e7eSjoerg  * This must be called for every created module or memory will be
68906f32e7eSjoerg  * leaked.
69006f32e7eSjoerg  */
69106f32e7eSjoerg void LLVMDisposeModule(LLVMModuleRef M);
69206f32e7eSjoerg 
69306f32e7eSjoerg /**
69406f32e7eSjoerg  * Obtain the identifier of a module.
69506f32e7eSjoerg  *
69606f32e7eSjoerg  * @param M Module to obtain identifier of
69706f32e7eSjoerg  * @param Len Out parameter which holds the length of the returned string.
69806f32e7eSjoerg  * @return The identifier of M.
69906f32e7eSjoerg  * @see Module::getModuleIdentifier()
70006f32e7eSjoerg  */
70106f32e7eSjoerg const char *LLVMGetModuleIdentifier(LLVMModuleRef M, size_t *Len);
70206f32e7eSjoerg 
70306f32e7eSjoerg /**
70406f32e7eSjoerg  * Set the identifier of a module to a string Ident with length Len.
70506f32e7eSjoerg  *
70606f32e7eSjoerg  * @param M The module to set identifier
70706f32e7eSjoerg  * @param Ident The string to set M's identifier to
70806f32e7eSjoerg  * @param Len Length of Ident
70906f32e7eSjoerg  * @see Module::setModuleIdentifier()
71006f32e7eSjoerg  */
71106f32e7eSjoerg void LLVMSetModuleIdentifier(LLVMModuleRef M, const char *Ident, size_t Len);
71206f32e7eSjoerg 
71306f32e7eSjoerg /**
71406f32e7eSjoerg  * Obtain the module's original source file name.
71506f32e7eSjoerg  *
71606f32e7eSjoerg  * @param M Module to obtain the name of
71706f32e7eSjoerg  * @param Len Out parameter which holds the length of the returned string
71806f32e7eSjoerg  * @return The original source file name of M
71906f32e7eSjoerg  * @see Module::getSourceFileName()
72006f32e7eSjoerg  */
72106f32e7eSjoerg const char *LLVMGetSourceFileName(LLVMModuleRef M, size_t *Len);
72206f32e7eSjoerg 
72306f32e7eSjoerg /**
72406f32e7eSjoerg  * Set the original source file name of a module to a string Name with length
72506f32e7eSjoerg  * Len.
72606f32e7eSjoerg  *
72706f32e7eSjoerg  * @param M The module to set the source file name of
72806f32e7eSjoerg  * @param Name The string to set M's source file name to
72906f32e7eSjoerg  * @param Len Length of Name
73006f32e7eSjoerg  * @see Module::setSourceFileName()
73106f32e7eSjoerg  */
73206f32e7eSjoerg void LLVMSetSourceFileName(LLVMModuleRef M, const char *Name, size_t Len);
73306f32e7eSjoerg 
73406f32e7eSjoerg /**
73506f32e7eSjoerg  * Obtain the data layout for a module.
73606f32e7eSjoerg  *
73706f32e7eSjoerg  * @see Module::getDataLayoutStr()
73806f32e7eSjoerg  *
73906f32e7eSjoerg  * LLVMGetDataLayout is DEPRECATED, as the name is not only incorrect,
74006f32e7eSjoerg  * but match the name of another method on the module. Prefer the use
74106f32e7eSjoerg  * of LLVMGetDataLayoutStr, which is not ambiguous.
74206f32e7eSjoerg  */
74306f32e7eSjoerg const char *LLVMGetDataLayoutStr(LLVMModuleRef M);
74406f32e7eSjoerg const char *LLVMGetDataLayout(LLVMModuleRef M);
74506f32e7eSjoerg 
74606f32e7eSjoerg /**
74706f32e7eSjoerg  * Set the data layout for a module.
74806f32e7eSjoerg  *
74906f32e7eSjoerg  * @see Module::setDataLayout()
75006f32e7eSjoerg  */
75106f32e7eSjoerg void LLVMSetDataLayout(LLVMModuleRef M, const char *DataLayoutStr);
75206f32e7eSjoerg 
75306f32e7eSjoerg /**
75406f32e7eSjoerg  * Obtain the target triple for a module.
75506f32e7eSjoerg  *
75606f32e7eSjoerg  * @see Module::getTargetTriple()
75706f32e7eSjoerg  */
75806f32e7eSjoerg const char *LLVMGetTarget(LLVMModuleRef M);
75906f32e7eSjoerg 
76006f32e7eSjoerg /**
76106f32e7eSjoerg  * Set the target triple for a module.
76206f32e7eSjoerg  *
76306f32e7eSjoerg  * @see Module::setTargetTriple()
76406f32e7eSjoerg  */
76506f32e7eSjoerg void LLVMSetTarget(LLVMModuleRef M, const char *Triple);
76606f32e7eSjoerg 
76706f32e7eSjoerg /**
76806f32e7eSjoerg  * Returns the module flags as an array of flag-key-value triples.  The caller
76906f32e7eSjoerg  * is responsible for freeing this array by calling
77006f32e7eSjoerg  * \c LLVMDisposeModuleFlagsMetadata.
77106f32e7eSjoerg  *
77206f32e7eSjoerg  * @see Module::getModuleFlagsMetadata()
77306f32e7eSjoerg  */
77406f32e7eSjoerg LLVMModuleFlagEntry *LLVMCopyModuleFlagsMetadata(LLVMModuleRef M, size_t *Len);
77506f32e7eSjoerg 
77606f32e7eSjoerg /**
77706f32e7eSjoerg  * Destroys module flags metadata entries.
77806f32e7eSjoerg  */
77906f32e7eSjoerg void LLVMDisposeModuleFlagsMetadata(LLVMModuleFlagEntry *Entries);
78006f32e7eSjoerg 
78106f32e7eSjoerg /**
78206f32e7eSjoerg  * Returns the flag behavior for a module flag entry at a specific index.
78306f32e7eSjoerg  *
78406f32e7eSjoerg  * @see Module::ModuleFlagEntry::Behavior
78506f32e7eSjoerg  */
78606f32e7eSjoerg LLVMModuleFlagBehavior
78706f32e7eSjoerg LLVMModuleFlagEntriesGetFlagBehavior(LLVMModuleFlagEntry *Entries,
78806f32e7eSjoerg                                      unsigned Index);
78906f32e7eSjoerg 
79006f32e7eSjoerg /**
79106f32e7eSjoerg  * Returns the key for a module flag entry at a specific index.
79206f32e7eSjoerg  *
79306f32e7eSjoerg  * @see Module::ModuleFlagEntry::Key
79406f32e7eSjoerg  */
79506f32e7eSjoerg const char *LLVMModuleFlagEntriesGetKey(LLVMModuleFlagEntry *Entries,
79606f32e7eSjoerg                                         unsigned Index, size_t *Len);
79706f32e7eSjoerg 
79806f32e7eSjoerg /**
79906f32e7eSjoerg  * Returns the metadata for a module flag entry at a specific index.
80006f32e7eSjoerg  *
80106f32e7eSjoerg  * @see Module::ModuleFlagEntry::Val
80206f32e7eSjoerg  */
80306f32e7eSjoerg LLVMMetadataRef LLVMModuleFlagEntriesGetMetadata(LLVMModuleFlagEntry *Entries,
80406f32e7eSjoerg                                                  unsigned Index);
80506f32e7eSjoerg 
80606f32e7eSjoerg /**
80706f32e7eSjoerg  * Add a module-level flag to the module-level flags metadata if it doesn't
80806f32e7eSjoerg  * already exist.
80906f32e7eSjoerg  *
81006f32e7eSjoerg  * @see Module::getModuleFlag()
81106f32e7eSjoerg  */
81206f32e7eSjoerg LLVMMetadataRef LLVMGetModuleFlag(LLVMModuleRef M,
81306f32e7eSjoerg                                   const char *Key, size_t KeyLen);
81406f32e7eSjoerg 
81506f32e7eSjoerg /**
81606f32e7eSjoerg  * Add a module-level flag to the module-level flags metadata if it doesn't
81706f32e7eSjoerg  * already exist.
81806f32e7eSjoerg  *
81906f32e7eSjoerg  * @see Module::addModuleFlag()
82006f32e7eSjoerg  */
82106f32e7eSjoerg void LLVMAddModuleFlag(LLVMModuleRef M, LLVMModuleFlagBehavior Behavior,
82206f32e7eSjoerg                        const char *Key, size_t KeyLen,
82306f32e7eSjoerg                        LLVMMetadataRef Val);
82406f32e7eSjoerg 
82506f32e7eSjoerg /**
82606f32e7eSjoerg  * Dump a representation of a module to stderr.
82706f32e7eSjoerg  *
82806f32e7eSjoerg  * @see Module::dump()
82906f32e7eSjoerg  */
83006f32e7eSjoerg void LLVMDumpModule(LLVMModuleRef M);
83106f32e7eSjoerg 
83206f32e7eSjoerg /**
83306f32e7eSjoerg  * Print a representation of a module to a file. The ErrorMessage needs to be
83406f32e7eSjoerg  * disposed with LLVMDisposeMessage. Returns 0 on success, 1 otherwise.
83506f32e7eSjoerg  *
83606f32e7eSjoerg  * @see Module::print()
83706f32e7eSjoerg  */
83806f32e7eSjoerg LLVMBool LLVMPrintModuleToFile(LLVMModuleRef M, const char *Filename,
83906f32e7eSjoerg                                char **ErrorMessage);
84006f32e7eSjoerg 
84106f32e7eSjoerg /**
84206f32e7eSjoerg  * Return a string representation of the module. Use
84306f32e7eSjoerg  * LLVMDisposeMessage to free the string.
84406f32e7eSjoerg  *
84506f32e7eSjoerg  * @see Module::print()
84606f32e7eSjoerg  */
84706f32e7eSjoerg char *LLVMPrintModuleToString(LLVMModuleRef M);
84806f32e7eSjoerg 
84906f32e7eSjoerg /**
85006f32e7eSjoerg  * Get inline assembly for a module.
85106f32e7eSjoerg  *
85206f32e7eSjoerg  * @see Module::getModuleInlineAsm()
85306f32e7eSjoerg  */
85406f32e7eSjoerg const char *LLVMGetModuleInlineAsm(LLVMModuleRef M, size_t *Len);
85506f32e7eSjoerg 
85606f32e7eSjoerg /**
85706f32e7eSjoerg  * Set inline assembly for a module.
85806f32e7eSjoerg  *
85906f32e7eSjoerg  * @see Module::setModuleInlineAsm()
86006f32e7eSjoerg  */
86106f32e7eSjoerg void LLVMSetModuleInlineAsm2(LLVMModuleRef M, const char *Asm, size_t Len);
86206f32e7eSjoerg 
86306f32e7eSjoerg /**
86406f32e7eSjoerg  * Append inline assembly to a module.
86506f32e7eSjoerg  *
86606f32e7eSjoerg  * @see Module::appendModuleInlineAsm()
86706f32e7eSjoerg  */
86806f32e7eSjoerg void LLVMAppendModuleInlineAsm(LLVMModuleRef M, const char *Asm, size_t Len);
86906f32e7eSjoerg 
87006f32e7eSjoerg /**
87106f32e7eSjoerg  * Create the specified uniqued inline asm string.
87206f32e7eSjoerg  *
87306f32e7eSjoerg  * @see InlineAsm::get()
87406f32e7eSjoerg  */
875*da58b97aSjoerg LLVMValueRef LLVMGetInlineAsm(LLVMTypeRef Ty, char *AsmString,
876*da58b97aSjoerg                               size_t AsmStringSize, char *Constraints,
877*da58b97aSjoerg                               size_t ConstraintsSize, LLVMBool HasSideEffects,
878*da58b97aSjoerg                               LLVMBool IsAlignStack,
879*da58b97aSjoerg                               LLVMInlineAsmDialect Dialect, LLVMBool CanThrow);
88006f32e7eSjoerg 
88106f32e7eSjoerg /**
88206f32e7eSjoerg  * Obtain the context to which this module is associated.
88306f32e7eSjoerg  *
88406f32e7eSjoerg  * @see Module::getContext()
88506f32e7eSjoerg  */
88606f32e7eSjoerg LLVMContextRef LLVMGetModuleContext(LLVMModuleRef M);
88706f32e7eSjoerg 
888*da58b97aSjoerg /** Deprecated: Use LLVMGetTypeByName2 instead. */
88906f32e7eSjoerg LLVMTypeRef LLVMGetTypeByName(LLVMModuleRef M, const char *Name);
89006f32e7eSjoerg 
89106f32e7eSjoerg /**
89206f32e7eSjoerg  * Obtain an iterator to the first NamedMDNode in a Module.
89306f32e7eSjoerg  *
89406f32e7eSjoerg  * @see llvm::Module::named_metadata_begin()
89506f32e7eSjoerg  */
89606f32e7eSjoerg LLVMNamedMDNodeRef LLVMGetFirstNamedMetadata(LLVMModuleRef M);
89706f32e7eSjoerg 
89806f32e7eSjoerg /**
89906f32e7eSjoerg  * Obtain an iterator to the last NamedMDNode in a Module.
90006f32e7eSjoerg  *
90106f32e7eSjoerg  * @see llvm::Module::named_metadata_end()
90206f32e7eSjoerg  */
90306f32e7eSjoerg LLVMNamedMDNodeRef LLVMGetLastNamedMetadata(LLVMModuleRef M);
90406f32e7eSjoerg 
90506f32e7eSjoerg /**
90606f32e7eSjoerg  * Advance a NamedMDNode iterator to the next NamedMDNode.
90706f32e7eSjoerg  *
90806f32e7eSjoerg  * Returns NULL if the iterator was already at the end and there are no more
90906f32e7eSjoerg  * named metadata nodes.
91006f32e7eSjoerg  */
91106f32e7eSjoerg LLVMNamedMDNodeRef LLVMGetNextNamedMetadata(LLVMNamedMDNodeRef NamedMDNode);
91206f32e7eSjoerg 
91306f32e7eSjoerg /**
91406f32e7eSjoerg  * Decrement a NamedMDNode iterator to the previous NamedMDNode.
91506f32e7eSjoerg  *
91606f32e7eSjoerg  * Returns NULL if the iterator was already at the beginning and there are
91706f32e7eSjoerg  * no previous named metadata nodes.
91806f32e7eSjoerg  */
91906f32e7eSjoerg LLVMNamedMDNodeRef LLVMGetPreviousNamedMetadata(LLVMNamedMDNodeRef NamedMDNode);
92006f32e7eSjoerg 
92106f32e7eSjoerg /**
92206f32e7eSjoerg  * Retrieve a NamedMDNode with the given name, returning NULL if no such
92306f32e7eSjoerg  * node exists.
92406f32e7eSjoerg  *
92506f32e7eSjoerg  * @see llvm::Module::getNamedMetadata()
92606f32e7eSjoerg  */
92706f32e7eSjoerg LLVMNamedMDNodeRef LLVMGetNamedMetadata(LLVMModuleRef M,
92806f32e7eSjoerg                                         const char *Name, size_t NameLen);
92906f32e7eSjoerg 
93006f32e7eSjoerg /**
93106f32e7eSjoerg  * Retrieve a NamedMDNode with the given name, creating a new node if no such
93206f32e7eSjoerg  * node exists.
93306f32e7eSjoerg  *
93406f32e7eSjoerg  * @see llvm::Module::getOrInsertNamedMetadata()
93506f32e7eSjoerg  */
93606f32e7eSjoerg LLVMNamedMDNodeRef LLVMGetOrInsertNamedMetadata(LLVMModuleRef M,
93706f32e7eSjoerg                                                 const char *Name,
93806f32e7eSjoerg                                                 size_t NameLen);
93906f32e7eSjoerg 
94006f32e7eSjoerg /**
94106f32e7eSjoerg  * Retrieve the name of a NamedMDNode.
94206f32e7eSjoerg  *
94306f32e7eSjoerg  * @see llvm::NamedMDNode::getName()
94406f32e7eSjoerg  */
94506f32e7eSjoerg const char *LLVMGetNamedMetadataName(LLVMNamedMDNodeRef NamedMD,
94606f32e7eSjoerg                                      size_t *NameLen);
94706f32e7eSjoerg 
94806f32e7eSjoerg /**
94906f32e7eSjoerg  * Obtain the number of operands for named metadata in a module.
95006f32e7eSjoerg  *
95106f32e7eSjoerg  * @see llvm::Module::getNamedMetadata()
95206f32e7eSjoerg  */
95306f32e7eSjoerg unsigned LLVMGetNamedMetadataNumOperands(LLVMModuleRef M, const char *Name);
95406f32e7eSjoerg 
95506f32e7eSjoerg /**
95606f32e7eSjoerg  * Obtain the named metadata operands for a module.
95706f32e7eSjoerg  *
95806f32e7eSjoerg  * The passed LLVMValueRef pointer should refer to an array of
95906f32e7eSjoerg  * LLVMValueRef at least LLVMGetNamedMetadataNumOperands long. This
96006f32e7eSjoerg  * array will be populated with the LLVMValueRef instances. Each
96106f32e7eSjoerg  * instance corresponds to a llvm::MDNode.
96206f32e7eSjoerg  *
96306f32e7eSjoerg  * @see llvm::Module::getNamedMetadata()
96406f32e7eSjoerg  * @see llvm::MDNode::getOperand()
96506f32e7eSjoerg  */
96606f32e7eSjoerg void LLVMGetNamedMetadataOperands(LLVMModuleRef M, const char *Name,
96706f32e7eSjoerg                                   LLVMValueRef *Dest);
96806f32e7eSjoerg 
96906f32e7eSjoerg /**
97006f32e7eSjoerg  * Add an operand to named metadata.
97106f32e7eSjoerg  *
97206f32e7eSjoerg  * @see llvm::Module::getNamedMetadata()
97306f32e7eSjoerg  * @see llvm::MDNode::addOperand()
97406f32e7eSjoerg  */
97506f32e7eSjoerg void LLVMAddNamedMetadataOperand(LLVMModuleRef M, const char *Name,
97606f32e7eSjoerg                                  LLVMValueRef Val);
97706f32e7eSjoerg 
97806f32e7eSjoerg /**
97906f32e7eSjoerg  * Return the directory of the debug location for this value, which must be
98006f32e7eSjoerg  * an llvm::Instruction, llvm::GlobalVariable, or llvm::Function.
98106f32e7eSjoerg  *
98206f32e7eSjoerg  * @see llvm::Instruction::getDebugLoc()
98306f32e7eSjoerg  * @see llvm::GlobalVariable::getDebugInfo()
98406f32e7eSjoerg  * @see llvm::Function::getSubprogram()
98506f32e7eSjoerg  */
98606f32e7eSjoerg const char *LLVMGetDebugLocDirectory(LLVMValueRef Val, unsigned *Length);
98706f32e7eSjoerg 
98806f32e7eSjoerg /**
98906f32e7eSjoerg  * Return the filename of the debug location for this value, which must be
99006f32e7eSjoerg  * an llvm::Instruction, llvm::GlobalVariable, or llvm::Function.
99106f32e7eSjoerg  *
99206f32e7eSjoerg  * @see llvm::Instruction::getDebugLoc()
99306f32e7eSjoerg  * @see llvm::GlobalVariable::getDebugInfo()
99406f32e7eSjoerg  * @see llvm::Function::getSubprogram()
99506f32e7eSjoerg  */
99606f32e7eSjoerg const char *LLVMGetDebugLocFilename(LLVMValueRef Val, unsigned *Length);
99706f32e7eSjoerg 
99806f32e7eSjoerg /**
99906f32e7eSjoerg  * Return the line number of the debug location for this value, which must be
100006f32e7eSjoerg  * an llvm::Instruction, llvm::GlobalVariable, or llvm::Function.
100106f32e7eSjoerg  *
100206f32e7eSjoerg  * @see llvm::Instruction::getDebugLoc()
100306f32e7eSjoerg  * @see llvm::GlobalVariable::getDebugInfo()
100406f32e7eSjoerg  * @see llvm::Function::getSubprogram()
100506f32e7eSjoerg  */
100606f32e7eSjoerg unsigned LLVMGetDebugLocLine(LLVMValueRef Val);
100706f32e7eSjoerg 
100806f32e7eSjoerg /**
100906f32e7eSjoerg  * Return the column number of the debug location for this value, which must be
101006f32e7eSjoerg  * an llvm::Instruction.
101106f32e7eSjoerg  *
101206f32e7eSjoerg  * @see llvm::Instruction::getDebugLoc()
101306f32e7eSjoerg  */
101406f32e7eSjoerg unsigned LLVMGetDebugLocColumn(LLVMValueRef Val);
101506f32e7eSjoerg 
101606f32e7eSjoerg /**
101706f32e7eSjoerg  * Add a function to a module under a specified name.
101806f32e7eSjoerg  *
101906f32e7eSjoerg  * @see llvm::Function::Create()
102006f32e7eSjoerg  */
102106f32e7eSjoerg LLVMValueRef LLVMAddFunction(LLVMModuleRef M, const char *Name,
102206f32e7eSjoerg                              LLVMTypeRef FunctionTy);
102306f32e7eSjoerg 
102406f32e7eSjoerg /**
102506f32e7eSjoerg  * Obtain a Function value from a Module by its name.
102606f32e7eSjoerg  *
102706f32e7eSjoerg  * The returned value corresponds to a llvm::Function value.
102806f32e7eSjoerg  *
102906f32e7eSjoerg  * @see llvm::Module::getFunction()
103006f32e7eSjoerg  */
103106f32e7eSjoerg LLVMValueRef LLVMGetNamedFunction(LLVMModuleRef M, const char *Name);
103206f32e7eSjoerg 
103306f32e7eSjoerg /**
103406f32e7eSjoerg  * Obtain an iterator to the first Function in a Module.
103506f32e7eSjoerg  *
103606f32e7eSjoerg  * @see llvm::Module::begin()
103706f32e7eSjoerg  */
103806f32e7eSjoerg LLVMValueRef LLVMGetFirstFunction(LLVMModuleRef M);
103906f32e7eSjoerg 
104006f32e7eSjoerg /**
104106f32e7eSjoerg  * Obtain an iterator to the last Function in a Module.
104206f32e7eSjoerg  *
104306f32e7eSjoerg  * @see llvm::Module::end()
104406f32e7eSjoerg  */
104506f32e7eSjoerg LLVMValueRef LLVMGetLastFunction(LLVMModuleRef M);
104606f32e7eSjoerg 
104706f32e7eSjoerg /**
104806f32e7eSjoerg  * Advance a Function iterator to the next Function.
104906f32e7eSjoerg  *
105006f32e7eSjoerg  * Returns NULL if the iterator was already at the end and there are no more
105106f32e7eSjoerg  * functions.
105206f32e7eSjoerg  */
105306f32e7eSjoerg LLVMValueRef LLVMGetNextFunction(LLVMValueRef Fn);
105406f32e7eSjoerg 
105506f32e7eSjoerg /**
105606f32e7eSjoerg  * Decrement a Function iterator to the previous Function.
105706f32e7eSjoerg  *
105806f32e7eSjoerg  * Returns NULL if the iterator was already at the beginning and there are
105906f32e7eSjoerg  * no previous functions.
106006f32e7eSjoerg  */
106106f32e7eSjoerg LLVMValueRef LLVMGetPreviousFunction(LLVMValueRef Fn);
106206f32e7eSjoerg 
106306f32e7eSjoerg /** Deprecated: Use LLVMSetModuleInlineAsm2 instead. */
106406f32e7eSjoerg void LLVMSetModuleInlineAsm(LLVMModuleRef M, const char *Asm);
106506f32e7eSjoerg 
106606f32e7eSjoerg /**
106706f32e7eSjoerg  * @}
106806f32e7eSjoerg  */
106906f32e7eSjoerg 
107006f32e7eSjoerg /**
107106f32e7eSjoerg  * @defgroup LLVMCCoreType Types
107206f32e7eSjoerg  *
107306f32e7eSjoerg  * Types represent the type of a value.
107406f32e7eSjoerg  *
107506f32e7eSjoerg  * Types are associated with a context instance. The context internally
107606f32e7eSjoerg  * deduplicates types so there is only 1 instance of a specific type
107706f32e7eSjoerg  * alive at a time. In other words, a unique type is shared among all
107806f32e7eSjoerg  * consumers within a context.
107906f32e7eSjoerg  *
108006f32e7eSjoerg  * A Type in the C API corresponds to llvm::Type.
108106f32e7eSjoerg  *
108206f32e7eSjoerg  * Types have the following hierarchy:
108306f32e7eSjoerg  *
108406f32e7eSjoerg  *   types:
108506f32e7eSjoerg  *     integer type
108606f32e7eSjoerg  *     real type
108706f32e7eSjoerg  *     function type
108806f32e7eSjoerg  *     sequence types:
108906f32e7eSjoerg  *       array type
109006f32e7eSjoerg  *       pointer type
109106f32e7eSjoerg  *       vector type
109206f32e7eSjoerg  *     void type
109306f32e7eSjoerg  *     label type
109406f32e7eSjoerg  *     opaque type
109506f32e7eSjoerg  *
109606f32e7eSjoerg  * @{
109706f32e7eSjoerg  */
109806f32e7eSjoerg 
109906f32e7eSjoerg /**
110006f32e7eSjoerg  * Obtain the enumerated type of a Type instance.
110106f32e7eSjoerg  *
110206f32e7eSjoerg  * @see llvm::Type:getTypeID()
110306f32e7eSjoerg  */
110406f32e7eSjoerg LLVMTypeKind LLVMGetTypeKind(LLVMTypeRef Ty);
110506f32e7eSjoerg 
110606f32e7eSjoerg /**
110706f32e7eSjoerg  * Whether the type has a known size.
110806f32e7eSjoerg  *
110906f32e7eSjoerg  * Things that don't have a size are abstract types, labels, and void.a
111006f32e7eSjoerg  *
111106f32e7eSjoerg  * @see llvm::Type::isSized()
111206f32e7eSjoerg  */
111306f32e7eSjoerg LLVMBool LLVMTypeIsSized(LLVMTypeRef Ty);
111406f32e7eSjoerg 
111506f32e7eSjoerg /**
111606f32e7eSjoerg  * Obtain the context to which this type instance is associated.
111706f32e7eSjoerg  *
111806f32e7eSjoerg  * @see llvm::Type::getContext()
111906f32e7eSjoerg  */
112006f32e7eSjoerg LLVMContextRef LLVMGetTypeContext(LLVMTypeRef Ty);
112106f32e7eSjoerg 
112206f32e7eSjoerg /**
112306f32e7eSjoerg  * Dump a representation of a type to stderr.
112406f32e7eSjoerg  *
112506f32e7eSjoerg  * @see llvm::Type::dump()
112606f32e7eSjoerg  */
112706f32e7eSjoerg void LLVMDumpType(LLVMTypeRef Val);
112806f32e7eSjoerg 
112906f32e7eSjoerg /**
113006f32e7eSjoerg  * Return a string representation of the type. Use
113106f32e7eSjoerg  * LLVMDisposeMessage to free the string.
113206f32e7eSjoerg  *
113306f32e7eSjoerg  * @see llvm::Type::print()
113406f32e7eSjoerg  */
113506f32e7eSjoerg char *LLVMPrintTypeToString(LLVMTypeRef Val);
113606f32e7eSjoerg 
113706f32e7eSjoerg /**
113806f32e7eSjoerg  * @defgroup LLVMCCoreTypeInt Integer Types
113906f32e7eSjoerg  *
114006f32e7eSjoerg  * Functions in this section operate on integer types.
114106f32e7eSjoerg  *
114206f32e7eSjoerg  * @{
114306f32e7eSjoerg  */
114406f32e7eSjoerg 
114506f32e7eSjoerg /**
114606f32e7eSjoerg  * Obtain an integer type from a context with specified bit width.
114706f32e7eSjoerg  */
114806f32e7eSjoerg LLVMTypeRef LLVMInt1TypeInContext(LLVMContextRef C);
114906f32e7eSjoerg LLVMTypeRef LLVMInt8TypeInContext(LLVMContextRef C);
115006f32e7eSjoerg LLVMTypeRef LLVMInt16TypeInContext(LLVMContextRef C);
115106f32e7eSjoerg LLVMTypeRef LLVMInt32TypeInContext(LLVMContextRef C);
115206f32e7eSjoerg LLVMTypeRef LLVMInt64TypeInContext(LLVMContextRef C);
115306f32e7eSjoerg LLVMTypeRef LLVMInt128TypeInContext(LLVMContextRef C);
115406f32e7eSjoerg LLVMTypeRef LLVMIntTypeInContext(LLVMContextRef C, unsigned NumBits);
115506f32e7eSjoerg 
115606f32e7eSjoerg /**
115706f32e7eSjoerg  * Obtain an integer type from the global context with a specified bit
115806f32e7eSjoerg  * width.
115906f32e7eSjoerg  */
116006f32e7eSjoerg LLVMTypeRef LLVMInt1Type(void);
116106f32e7eSjoerg LLVMTypeRef LLVMInt8Type(void);
116206f32e7eSjoerg LLVMTypeRef LLVMInt16Type(void);
116306f32e7eSjoerg LLVMTypeRef LLVMInt32Type(void);
116406f32e7eSjoerg LLVMTypeRef LLVMInt64Type(void);
116506f32e7eSjoerg LLVMTypeRef LLVMInt128Type(void);
116606f32e7eSjoerg LLVMTypeRef LLVMIntType(unsigned NumBits);
116706f32e7eSjoerg unsigned LLVMGetIntTypeWidth(LLVMTypeRef IntegerTy);
116806f32e7eSjoerg 
116906f32e7eSjoerg /**
117006f32e7eSjoerg  * @}
117106f32e7eSjoerg  */
117206f32e7eSjoerg 
117306f32e7eSjoerg /**
117406f32e7eSjoerg  * @defgroup LLVMCCoreTypeFloat Floating Point Types
117506f32e7eSjoerg  *
117606f32e7eSjoerg  * @{
117706f32e7eSjoerg  */
117806f32e7eSjoerg 
117906f32e7eSjoerg /**
118006f32e7eSjoerg  * Obtain a 16-bit floating point type from a context.
118106f32e7eSjoerg  */
118206f32e7eSjoerg LLVMTypeRef LLVMHalfTypeInContext(LLVMContextRef C);
118306f32e7eSjoerg 
118406f32e7eSjoerg /**
1185*da58b97aSjoerg  * Obtain a 16-bit brain floating point type from a context.
1186*da58b97aSjoerg  */
1187*da58b97aSjoerg LLVMTypeRef LLVMBFloatTypeInContext(LLVMContextRef C);
1188*da58b97aSjoerg 
1189*da58b97aSjoerg /**
119006f32e7eSjoerg  * Obtain a 32-bit floating point type from a context.
119106f32e7eSjoerg  */
119206f32e7eSjoerg LLVMTypeRef LLVMFloatTypeInContext(LLVMContextRef C);
119306f32e7eSjoerg 
119406f32e7eSjoerg /**
119506f32e7eSjoerg  * Obtain a 64-bit floating point type from a context.
119606f32e7eSjoerg  */
119706f32e7eSjoerg LLVMTypeRef LLVMDoubleTypeInContext(LLVMContextRef C);
119806f32e7eSjoerg 
119906f32e7eSjoerg /**
120006f32e7eSjoerg  * Obtain a 80-bit floating point type (X87) from a context.
120106f32e7eSjoerg  */
120206f32e7eSjoerg LLVMTypeRef LLVMX86FP80TypeInContext(LLVMContextRef C);
120306f32e7eSjoerg 
120406f32e7eSjoerg /**
120506f32e7eSjoerg  * Obtain a 128-bit floating point type (112-bit mantissa) from a
120606f32e7eSjoerg  * context.
120706f32e7eSjoerg  */
120806f32e7eSjoerg LLVMTypeRef LLVMFP128TypeInContext(LLVMContextRef C);
120906f32e7eSjoerg 
121006f32e7eSjoerg /**
121106f32e7eSjoerg  * Obtain a 128-bit floating point type (two 64-bits) from a context.
121206f32e7eSjoerg  */
121306f32e7eSjoerg LLVMTypeRef LLVMPPCFP128TypeInContext(LLVMContextRef C);
121406f32e7eSjoerg 
121506f32e7eSjoerg /**
121606f32e7eSjoerg  * Obtain a floating point type from the global context.
121706f32e7eSjoerg  *
121806f32e7eSjoerg  * These map to the functions in this group of the same name.
121906f32e7eSjoerg  */
122006f32e7eSjoerg LLVMTypeRef LLVMHalfType(void);
1221*da58b97aSjoerg LLVMTypeRef LLVMBFloatType(void);
122206f32e7eSjoerg LLVMTypeRef LLVMFloatType(void);
122306f32e7eSjoerg LLVMTypeRef LLVMDoubleType(void);
122406f32e7eSjoerg LLVMTypeRef LLVMX86FP80Type(void);
122506f32e7eSjoerg LLVMTypeRef LLVMFP128Type(void);
122606f32e7eSjoerg LLVMTypeRef LLVMPPCFP128Type(void);
122706f32e7eSjoerg 
122806f32e7eSjoerg /**
122906f32e7eSjoerg  * @}
123006f32e7eSjoerg  */
123106f32e7eSjoerg 
123206f32e7eSjoerg /**
123306f32e7eSjoerg  * @defgroup LLVMCCoreTypeFunction Function Types
123406f32e7eSjoerg  *
123506f32e7eSjoerg  * @{
123606f32e7eSjoerg  */
123706f32e7eSjoerg 
123806f32e7eSjoerg /**
123906f32e7eSjoerg  * Obtain a function type consisting of a specified signature.
124006f32e7eSjoerg  *
124106f32e7eSjoerg  * The function is defined as a tuple of a return Type, a list of
124206f32e7eSjoerg  * parameter types, and whether the function is variadic.
124306f32e7eSjoerg  */
124406f32e7eSjoerg LLVMTypeRef LLVMFunctionType(LLVMTypeRef ReturnType,
124506f32e7eSjoerg                              LLVMTypeRef *ParamTypes, unsigned ParamCount,
124606f32e7eSjoerg                              LLVMBool IsVarArg);
124706f32e7eSjoerg 
124806f32e7eSjoerg /**
124906f32e7eSjoerg  * Returns whether a function type is variadic.
125006f32e7eSjoerg  */
125106f32e7eSjoerg LLVMBool LLVMIsFunctionVarArg(LLVMTypeRef FunctionTy);
125206f32e7eSjoerg 
125306f32e7eSjoerg /**
125406f32e7eSjoerg  * Obtain the Type this function Type returns.
125506f32e7eSjoerg  */
125606f32e7eSjoerg LLVMTypeRef LLVMGetReturnType(LLVMTypeRef FunctionTy);
125706f32e7eSjoerg 
125806f32e7eSjoerg /**
125906f32e7eSjoerg  * Obtain the number of parameters this function accepts.
126006f32e7eSjoerg  */
126106f32e7eSjoerg unsigned LLVMCountParamTypes(LLVMTypeRef FunctionTy);
126206f32e7eSjoerg 
126306f32e7eSjoerg /**
126406f32e7eSjoerg  * Obtain the types of a function's parameters.
126506f32e7eSjoerg  *
126606f32e7eSjoerg  * The Dest parameter should point to a pre-allocated array of
126706f32e7eSjoerg  * LLVMTypeRef at least LLVMCountParamTypes() large. On return, the
126806f32e7eSjoerg  * first LLVMCountParamTypes() entries in the array will be populated
126906f32e7eSjoerg  * with LLVMTypeRef instances.
127006f32e7eSjoerg  *
127106f32e7eSjoerg  * @param FunctionTy The function type to operate on.
127206f32e7eSjoerg  * @param Dest Memory address of an array to be filled with result.
127306f32e7eSjoerg  */
127406f32e7eSjoerg void LLVMGetParamTypes(LLVMTypeRef FunctionTy, LLVMTypeRef *Dest);
127506f32e7eSjoerg 
127606f32e7eSjoerg /**
127706f32e7eSjoerg  * @}
127806f32e7eSjoerg  */
127906f32e7eSjoerg 
128006f32e7eSjoerg /**
128106f32e7eSjoerg  * @defgroup LLVMCCoreTypeStruct Structure Types
128206f32e7eSjoerg  *
128306f32e7eSjoerg  * These functions relate to LLVMTypeRef instances.
128406f32e7eSjoerg  *
128506f32e7eSjoerg  * @see llvm::StructType
128606f32e7eSjoerg  *
128706f32e7eSjoerg  * @{
128806f32e7eSjoerg  */
128906f32e7eSjoerg 
129006f32e7eSjoerg /**
129106f32e7eSjoerg  * Create a new structure type in a context.
129206f32e7eSjoerg  *
129306f32e7eSjoerg  * A structure is specified by a list of inner elements/types and
129406f32e7eSjoerg  * whether these can be packed together.
129506f32e7eSjoerg  *
129606f32e7eSjoerg  * @see llvm::StructType::create()
129706f32e7eSjoerg  */
129806f32e7eSjoerg LLVMTypeRef LLVMStructTypeInContext(LLVMContextRef C, LLVMTypeRef *ElementTypes,
129906f32e7eSjoerg                                     unsigned ElementCount, LLVMBool Packed);
130006f32e7eSjoerg 
130106f32e7eSjoerg /**
130206f32e7eSjoerg  * Create a new structure type in the global context.
130306f32e7eSjoerg  *
130406f32e7eSjoerg  * @see llvm::StructType::create()
130506f32e7eSjoerg  */
130606f32e7eSjoerg LLVMTypeRef LLVMStructType(LLVMTypeRef *ElementTypes, unsigned ElementCount,
130706f32e7eSjoerg                            LLVMBool Packed);
130806f32e7eSjoerg 
130906f32e7eSjoerg /**
131006f32e7eSjoerg  * Create an empty structure in a context having a specified name.
131106f32e7eSjoerg  *
131206f32e7eSjoerg  * @see llvm::StructType::create()
131306f32e7eSjoerg  */
131406f32e7eSjoerg LLVMTypeRef LLVMStructCreateNamed(LLVMContextRef C, const char *Name);
131506f32e7eSjoerg 
131606f32e7eSjoerg /**
131706f32e7eSjoerg  * Obtain the name of a structure.
131806f32e7eSjoerg  *
131906f32e7eSjoerg  * @see llvm::StructType::getName()
132006f32e7eSjoerg  */
132106f32e7eSjoerg const char *LLVMGetStructName(LLVMTypeRef Ty);
132206f32e7eSjoerg 
132306f32e7eSjoerg /**
132406f32e7eSjoerg  * Set the contents of a structure type.
132506f32e7eSjoerg  *
132606f32e7eSjoerg  * @see llvm::StructType::setBody()
132706f32e7eSjoerg  */
132806f32e7eSjoerg void LLVMStructSetBody(LLVMTypeRef StructTy, LLVMTypeRef *ElementTypes,
132906f32e7eSjoerg                        unsigned ElementCount, LLVMBool Packed);
133006f32e7eSjoerg 
133106f32e7eSjoerg /**
133206f32e7eSjoerg  * Get the number of elements defined inside the structure.
133306f32e7eSjoerg  *
133406f32e7eSjoerg  * @see llvm::StructType::getNumElements()
133506f32e7eSjoerg  */
133606f32e7eSjoerg unsigned LLVMCountStructElementTypes(LLVMTypeRef StructTy);
133706f32e7eSjoerg 
133806f32e7eSjoerg /**
133906f32e7eSjoerg  * Get the elements within a structure.
134006f32e7eSjoerg  *
134106f32e7eSjoerg  * The function is passed the address of a pre-allocated array of
134206f32e7eSjoerg  * LLVMTypeRef at least LLVMCountStructElementTypes() long. After
134306f32e7eSjoerg  * invocation, this array will be populated with the structure's
134406f32e7eSjoerg  * elements. The objects in the destination array will have a lifetime
134506f32e7eSjoerg  * of the structure type itself, which is the lifetime of the context it
134606f32e7eSjoerg  * is contained in.
134706f32e7eSjoerg  */
134806f32e7eSjoerg void LLVMGetStructElementTypes(LLVMTypeRef StructTy, LLVMTypeRef *Dest);
134906f32e7eSjoerg 
135006f32e7eSjoerg /**
135106f32e7eSjoerg  * Get the type of the element at a given index in the structure.
135206f32e7eSjoerg  *
135306f32e7eSjoerg  * @see llvm::StructType::getTypeAtIndex()
135406f32e7eSjoerg  */
135506f32e7eSjoerg LLVMTypeRef LLVMStructGetTypeAtIndex(LLVMTypeRef StructTy, unsigned i);
135606f32e7eSjoerg 
135706f32e7eSjoerg /**
135806f32e7eSjoerg  * Determine whether a structure is packed.
135906f32e7eSjoerg  *
136006f32e7eSjoerg  * @see llvm::StructType::isPacked()
136106f32e7eSjoerg  */
136206f32e7eSjoerg LLVMBool LLVMIsPackedStruct(LLVMTypeRef StructTy);
136306f32e7eSjoerg 
136406f32e7eSjoerg /**
136506f32e7eSjoerg  * Determine whether a structure is opaque.
136606f32e7eSjoerg  *
136706f32e7eSjoerg  * @see llvm::StructType::isOpaque()
136806f32e7eSjoerg  */
136906f32e7eSjoerg LLVMBool LLVMIsOpaqueStruct(LLVMTypeRef StructTy);
137006f32e7eSjoerg 
137106f32e7eSjoerg /**
137206f32e7eSjoerg  * Determine whether a structure is literal.
137306f32e7eSjoerg  *
137406f32e7eSjoerg  * @see llvm::StructType::isLiteral()
137506f32e7eSjoerg  */
137606f32e7eSjoerg LLVMBool LLVMIsLiteralStruct(LLVMTypeRef StructTy);
137706f32e7eSjoerg 
137806f32e7eSjoerg /**
137906f32e7eSjoerg  * @}
138006f32e7eSjoerg  */
138106f32e7eSjoerg 
138206f32e7eSjoerg /**
138306f32e7eSjoerg  * @defgroup LLVMCCoreTypeSequential Sequential Types
138406f32e7eSjoerg  *
138506f32e7eSjoerg  * Sequential types represents "arrays" of types. This is a super class
138606f32e7eSjoerg  * for array, vector, and pointer types.
138706f32e7eSjoerg  *
138806f32e7eSjoerg  * @{
138906f32e7eSjoerg  */
139006f32e7eSjoerg 
139106f32e7eSjoerg /**
139206f32e7eSjoerg  * Obtain the type of elements within a sequential type.
139306f32e7eSjoerg  *
139406f32e7eSjoerg  * This works on array, vector, and pointer types.
139506f32e7eSjoerg  *
139606f32e7eSjoerg  * @see llvm::SequentialType::getElementType()
139706f32e7eSjoerg  */
139806f32e7eSjoerg LLVMTypeRef LLVMGetElementType(LLVMTypeRef Ty);
139906f32e7eSjoerg 
140006f32e7eSjoerg /**
140106f32e7eSjoerg  * Returns type's subtypes
140206f32e7eSjoerg  *
140306f32e7eSjoerg  * @see llvm::Type::subtypes()
140406f32e7eSjoerg  */
140506f32e7eSjoerg void LLVMGetSubtypes(LLVMTypeRef Tp, LLVMTypeRef *Arr);
140606f32e7eSjoerg 
140706f32e7eSjoerg /**
140806f32e7eSjoerg  *  Return the number of types in the derived type.
140906f32e7eSjoerg  *
141006f32e7eSjoerg  * @see llvm::Type::getNumContainedTypes()
141106f32e7eSjoerg  */
141206f32e7eSjoerg unsigned LLVMGetNumContainedTypes(LLVMTypeRef Tp);
141306f32e7eSjoerg 
141406f32e7eSjoerg /**
141506f32e7eSjoerg  * Create a fixed size array type that refers to a specific type.
141606f32e7eSjoerg  *
141706f32e7eSjoerg  * The created type will exist in the context that its element type
141806f32e7eSjoerg  * exists in.
141906f32e7eSjoerg  *
142006f32e7eSjoerg  * @see llvm::ArrayType::get()
142106f32e7eSjoerg  */
142206f32e7eSjoerg LLVMTypeRef LLVMArrayType(LLVMTypeRef ElementType, unsigned ElementCount);
142306f32e7eSjoerg 
142406f32e7eSjoerg /**
142506f32e7eSjoerg  * Obtain the length of an array type.
142606f32e7eSjoerg  *
142706f32e7eSjoerg  * This only works on types that represent arrays.
142806f32e7eSjoerg  *
142906f32e7eSjoerg  * @see llvm::ArrayType::getNumElements()
143006f32e7eSjoerg  */
143106f32e7eSjoerg unsigned LLVMGetArrayLength(LLVMTypeRef ArrayTy);
143206f32e7eSjoerg 
143306f32e7eSjoerg /**
143406f32e7eSjoerg  * Create a pointer type that points to a defined type.
143506f32e7eSjoerg  *
143606f32e7eSjoerg  * The created type will exist in the context that its pointee type
143706f32e7eSjoerg  * exists in.
143806f32e7eSjoerg  *
143906f32e7eSjoerg  * @see llvm::PointerType::get()
144006f32e7eSjoerg  */
144106f32e7eSjoerg LLVMTypeRef LLVMPointerType(LLVMTypeRef ElementType, unsigned AddressSpace);
144206f32e7eSjoerg 
144306f32e7eSjoerg /**
144406f32e7eSjoerg  * Obtain the address space of a pointer type.
144506f32e7eSjoerg  *
144606f32e7eSjoerg  * This only works on types that represent pointers.
144706f32e7eSjoerg  *
144806f32e7eSjoerg  * @see llvm::PointerType::getAddressSpace()
144906f32e7eSjoerg  */
145006f32e7eSjoerg unsigned LLVMGetPointerAddressSpace(LLVMTypeRef PointerTy);
145106f32e7eSjoerg 
145206f32e7eSjoerg /**
145306f32e7eSjoerg  * Create a vector type that contains a defined type and has a specific
145406f32e7eSjoerg  * number of elements.
145506f32e7eSjoerg  *
145606f32e7eSjoerg  * The created type will exist in the context thats its element type
145706f32e7eSjoerg  * exists in.
145806f32e7eSjoerg  *
145906f32e7eSjoerg  * @see llvm::VectorType::get()
146006f32e7eSjoerg  */
146106f32e7eSjoerg LLVMTypeRef LLVMVectorType(LLVMTypeRef ElementType, unsigned ElementCount);
146206f32e7eSjoerg 
146306f32e7eSjoerg /**
1464*da58b97aSjoerg  * Create a vector type that contains a defined type and has a scalable
1465*da58b97aSjoerg  * number of elements.
146606f32e7eSjoerg  *
1467*da58b97aSjoerg  * The created type will exist in the context thats its element type
1468*da58b97aSjoerg  * exists in.
1469*da58b97aSjoerg  *
1470*da58b97aSjoerg  * @see llvm::ScalableVectorType::get()
1471*da58b97aSjoerg  */
1472*da58b97aSjoerg LLVMTypeRef LLVMScalableVectorType(LLVMTypeRef ElementType,
1473*da58b97aSjoerg                                    unsigned ElementCount);
1474*da58b97aSjoerg 
1475*da58b97aSjoerg /**
1476*da58b97aSjoerg  * Obtain the (possibly scalable) number of elements in a vector type.
1477*da58b97aSjoerg  *
1478*da58b97aSjoerg  * This only works on types that represent vectors (fixed or scalable).
147906f32e7eSjoerg  *
148006f32e7eSjoerg  * @see llvm::VectorType::getNumElements()
148106f32e7eSjoerg  */
148206f32e7eSjoerg unsigned LLVMGetVectorSize(LLVMTypeRef VectorTy);
148306f32e7eSjoerg 
148406f32e7eSjoerg /**
148506f32e7eSjoerg  * @}
148606f32e7eSjoerg  */
148706f32e7eSjoerg 
148806f32e7eSjoerg /**
148906f32e7eSjoerg  * @defgroup LLVMCCoreTypeOther Other Types
149006f32e7eSjoerg  *
149106f32e7eSjoerg  * @{
149206f32e7eSjoerg  */
149306f32e7eSjoerg 
149406f32e7eSjoerg /**
149506f32e7eSjoerg  * Create a void type in a context.
149606f32e7eSjoerg  */
149706f32e7eSjoerg LLVMTypeRef LLVMVoidTypeInContext(LLVMContextRef C);
149806f32e7eSjoerg 
149906f32e7eSjoerg /**
150006f32e7eSjoerg  * Create a label type in a context.
150106f32e7eSjoerg  */
150206f32e7eSjoerg LLVMTypeRef LLVMLabelTypeInContext(LLVMContextRef C);
150306f32e7eSjoerg 
150406f32e7eSjoerg /**
150506f32e7eSjoerg  * Create a X86 MMX type in a context.
150606f32e7eSjoerg  */
150706f32e7eSjoerg LLVMTypeRef LLVMX86MMXTypeInContext(LLVMContextRef C);
150806f32e7eSjoerg 
150906f32e7eSjoerg /**
1510*da58b97aSjoerg  * Create a X86 AMX type in a context.
1511*da58b97aSjoerg  */
1512*da58b97aSjoerg LLVMTypeRef LLVMX86AMXTypeInContext(LLVMContextRef C);
1513*da58b97aSjoerg 
1514*da58b97aSjoerg /**
151506f32e7eSjoerg  * Create a token type in a context.
151606f32e7eSjoerg  */
151706f32e7eSjoerg LLVMTypeRef LLVMTokenTypeInContext(LLVMContextRef C);
151806f32e7eSjoerg 
151906f32e7eSjoerg /**
152006f32e7eSjoerg  * Create a metadata type in a context.
152106f32e7eSjoerg  */
152206f32e7eSjoerg LLVMTypeRef LLVMMetadataTypeInContext(LLVMContextRef C);
152306f32e7eSjoerg 
152406f32e7eSjoerg /**
152506f32e7eSjoerg  * These are similar to the above functions except they operate on the
152606f32e7eSjoerg  * global context.
152706f32e7eSjoerg  */
152806f32e7eSjoerg LLVMTypeRef LLVMVoidType(void);
152906f32e7eSjoerg LLVMTypeRef LLVMLabelType(void);
153006f32e7eSjoerg LLVMTypeRef LLVMX86MMXType(void);
1531*da58b97aSjoerg LLVMTypeRef LLVMX86AMXType(void);
153206f32e7eSjoerg 
153306f32e7eSjoerg /**
153406f32e7eSjoerg  * @}
153506f32e7eSjoerg  */
153606f32e7eSjoerg 
153706f32e7eSjoerg /**
153806f32e7eSjoerg  * @}
153906f32e7eSjoerg  */
154006f32e7eSjoerg 
154106f32e7eSjoerg /**
154206f32e7eSjoerg  * @defgroup LLVMCCoreValues Values
154306f32e7eSjoerg  *
154406f32e7eSjoerg  * The bulk of LLVM's object model consists of values, which comprise a very
154506f32e7eSjoerg  * rich type hierarchy.
154606f32e7eSjoerg  *
154706f32e7eSjoerg  * LLVMValueRef essentially represents llvm::Value. There is a rich
154806f32e7eSjoerg  * hierarchy of classes within this type. Depending on the instance
154906f32e7eSjoerg  * obtained, not all APIs are available.
155006f32e7eSjoerg  *
155106f32e7eSjoerg  * Callers can determine the type of an LLVMValueRef by calling the
155206f32e7eSjoerg  * LLVMIsA* family of functions (e.g. LLVMIsAArgument()). These
155306f32e7eSjoerg  * functions are defined by a macro, so it isn't obvious which are
155406f32e7eSjoerg  * available by looking at the Doxygen source code. Instead, look at the
155506f32e7eSjoerg  * source definition of LLVM_FOR_EACH_VALUE_SUBCLASS and note the list
155606f32e7eSjoerg  * of value names given. These value names also correspond to classes in
155706f32e7eSjoerg  * the llvm::Value hierarchy.
155806f32e7eSjoerg  *
155906f32e7eSjoerg  * @{
156006f32e7eSjoerg  */
156106f32e7eSjoerg 
156206f32e7eSjoerg #define LLVM_FOR_EACH_VALUE_SUBCLASS(macro) \
156306f32e7eSjoerg   macro(Argument)                           \
156406f32e7eSjoerg   macro(BasicBlock)                         \
156506f32e7eSjoerg   macro(InlineAsm)                          \
156606f32e7eSjoerg   macro(User)                               \
156706f32e7eSjoerg     macro(Constant)                         \
156806f32e7eSjoerg       macro(BlockAddress)                   \
156906f32e7eSjoerg       macro(ConstantAggregateZero)          \
157006f32e7eSjoerg       macro(ConstantArray)                  \
157106f32e7eSjoerg       macro(ConstantDataSequential)         \
157206f32e7eSjoerg         macro(ConstantDataArray)            \
157306f32e7eSjoerg         macro(ConstantDataVector)           \
157406f32e7eSjoerg       macro(ConstantExpr)                   \
157506f32e7eSjoerg       macro(ConstantFP)                     \
157606f32e7eSjoerg       macro(ConstantInt)                    \
157706f32e7eSjoerg       macro(ConstantPointerNull)            \
157806f32e7eSjoerg       macro(ConstantStruct)                 \
157906f32e7eSjoerg       macro(ConstantTokenNone)              \
158006f32e7eSjoerg       macro(ConstantVector)                 \
158106f32e7eSjoerg       macro(GlobalValue)                    \
158206f32e7eSjoerg         macro(GlobalAlias)                  \
158306f32e7eSjoerg         macro(GlobalIFunc)                  \
158406f32e7eSjoerg         macro(GlobalObject)                 \
158506f32e7eSjoerg           macro(Function)                   \
158606f32e7eSjoerg           macro(GlobalVariable)             \
158706f32e7eSjoerg       macro(UndefValue)                     \
1588*da58b97aSjoerg       macro(PoisonValue)                    \
158906f32e7eSjoerg     macro(Instruction)                      \
159006f32e7eSjoerg       macro(UnaryOperator)                  \
159106f32e7eSjoerg       macro(BinaryOperator)                 \
159206f32e7eSjoerg       macro(CallInst)                       \
159306f32e7eSjoerg         macro(IntrinsicInst)                \
159406f32e7eSjoerg           macro(DbgInfoIntrinsic)           \
159506f32e7eSjoerg             macro(DbgVariableIntrinsic)     \
159606f32e7eSjoerg               macro(DbgDeclareInst)         \
159706f32e7eSjoerg             macro(DbgLabelInst)             \
159806f32e7eSjoerg           macro(MemIntrinsic)               \
159906f32e7eSjoerg             macro(MemCpyInst)               \
160006f32e7eSjoerg             macro(MemMoveInst)              \
160106f32e7eSjoerg             macro(MemSetInst)               \
160206f32e7eSjoerg       macro(CmpInst)                        \
160306f32e7eSjoerg         macro(FCmpInst)                     \
160406f32e7eSjoerg         macro(ICmpInst)                     \
160506f32e7eSjoerg       macro(ExtractElementInst)             \
160606f32e7eSjoerg       macro(GetElementPtrInst)              \
160706f32e7eSjoerg       macro(InsertElementInst)              \
160806f32e7eSjoerg       macro(InsertValueInst)                \
160906f32e7eSjoerg       macro(LandingPadInst)                 \
161006f32e7eSjoerg       macro(PHINode)                        \
161106f32e7eSjoerg       macro(SelectInst)                     \
161206f32e7eSjoerg       macro(ShuffleVectorInst)              \
161306f32e7eSjoerg       macro(StoreInst)                      \
161406f32e7eSjoerg       macro(BranchInst)                     \
161506f32e7eSjoerg       macro(IndirectBrInst)                 \
161606f32e7eSjoerg       macro(InvokeInst)                     \
161706f32e7eSjoerg       macro(ReturnInst)                     \
161806f32e7eSjoerg       macro(SwitchInst)                     \
161906f32e7eSjoerg       macro(UnreachableInst)                \
162006f32e7eSjoerg       macro(ResumeInst)                     \
162106f32e7eSjoerg       macro(CleanupReturnInst)              \
162206f32e7eSjoerg       macro(CatchReturnInst)                \
162306f32e7eSjoerg       macro(CatchSwitchInst)                \
162406f32e7eSjoerg       macro(CallBrInst)                     \
162506f32e7eSjoerg       macro(FuncletPadInst)                 \
162606f32e7eSjoerg         macro(CatchPadInst)                 \
162706f32e7eSjoerg         macro(CleanupPadInst)               \
162806f32e7eSjoerg       macro(UnaryInstruction)               \
162906f32e7eSjoerg         macro(AllocaInst)                   \
163006f32e7eSjoerg         macro(CastInst)                     \
163106f32e7eSjoerg           macro(AddrSpaceCastInst)          \
163206f32e7eSjoerg           macro(BitCastInst)                \
163306f32e7eSjoerg           macro(FPExtInst)                  \
163406f32e7eSjoerg           macro(FPToSIInst)                 \
163506f32e7eSjoerg           macro(FPToUIInst)                 \
163606f32e7eSjoerg           macro(FPTruncInst)                \
163706f32e7eSjoerg           macro(IntToPtrInst)               \
163806f32e7eSjoerg           macro(PtrToIntInst)               \
163906f32e7eSjoerg           macro(SExtInst)                   \
164006f32e7eSjoerg           macro(SIToFPInst)                 \
164106f32e7eSjoerg           macro(TruncInst)                  \
164206f32e7eSjoerg           macro(UIToFPInst)                 \
164306f32e7eSjoerg           macro(ZExtInst)                   \
164406f32e7eSjoerg         macro(ExtractValueInst)             \
164506f32e7eSjoerg         macro(LoadInst)                     \
164606f32e7eSjoerg         macro(VAArgInst)                    \
1647*da58b97aSjoerg         macro(FreezeInst)                   \
164806f32e7eSjoerg       macro(AtomicCmpXchgInst)              \
164906f32e7eSjoerg       macro(AtomicRMWInst)                  \
165006f32e7eSjoerg       macro(FenceInst)
165106f32e7eSjoerg 
165206f32e7eSjoerg /**
165306f32e7eSjoerg  * @defgroup LLVMCCoreValueGeneral General APIs
165406f32e7eSjoerg  *
165506f32e7eSjoerg  * Functions in this section work on all LLVMValueRef instances,
165606f32e7eSjoerg  * regardless of their sub-type. They correspond to functions available
165706f32e7eSjoerg  * on llvm::Value.
165806f32e7eSjoerg  *
165906f32e7eSjoerg  * @{
166006f32e7eSjoerg  */
166106f32e7eSjoerg 
166206f32e7eSjoerg /**
166306f32e7eSjoerg  * Obtain the type of a value.
166406f32e7eSjoerg  *
166506f32e7eSjoerg  * @see llvm::Value::getType()
166606f32e7eSjoerg  */
166706f32e7eSjoerg LLVMTypeRef LLVMTypeOf(LLVMValueRef Val);
166806f32e7eSjoerg 
166906f32e7eSjoerg /**
167006f32e7eSjoerg  * Obtain the enumerated type of a Value instance.
167106f32e7eSjoerg  *
167206f32e7eSjoerg  * @see llvm::Value::getValueID()
167306f32e7eSjoerg  */
167406f32e7eSjoerg LLVMValueKind LLVMGetValueKind(LLVMValueRef Val);
167506f32e7eSjoerg 
167606f32e7eSjoerg /**
167706f32e7eSjoerg  * Obtain the string name of a value.
167806f32e7eSjoerg  *
167906f32e7eSjoerg  * @see llvm::Value::getName()
168006f32e7eSjoerg  */
168106f32e7eSjoerg const char *LLVMGetValueName2(LLVMValueRef Val, size_t *Length);
168206f32e7eSjoerg 
168306f32e7eSjoerg /**
168406f32e7eSjoerg  * Set the string name of a value.
168506f32e7eSjoerg  *
168606f32e7eSjoerg  * @see llvm::Value::setName()
168706f32e7eSjoerg  */
168806f32e7eSjoerg void LLVMSetValueName2(LLVMValueRef Val, const char *Name, size_t NameLen);
168906f32e7eSjoerg 
169006f32e7eSjoerg /**
169106f32e7eSjoerg  * Dump a representation of a value to stderr.
169206f32e7eSjoerg  *
169306f32e7eSjoerg  * @see llvm::Value::dump()
169406f32e7eSjoerg  */
169506f32e7eSjoerg void LLVMDumpValue(LLVMValueRef Val);
169606f32e7eSjoerg 
169706f32e7eSjoerg /**
169806f32e7eSjoerg  * Return a string representation of the value. Use
169906f32e7eSjoerg  * LLVMDisposeMessage to free the string.
170006f32e7eSjoerg  *
170106f32e7eSjoerg  * @see llvm::Value::print()
170206f32e7eSjoerg  */
170306f32e7eSjoerg char *LLVMPrintValueToString(LLVMValueRef Val);
170406f32e7eSjoerg 
170506f32e7eSjoerg /**
170606f32e7eSjoerg  * Replace all uses of a value with another one.
170706f32e7eSjoerg  *
170806f32e7eSjoerg  * @see llvm::Value::replaceAllUsesWith()
170906f32e7eSjoerg  */
171006f32e7eSjoerg void LLVMReplaceAllUsesWith(LLVMValueRef OldVal, LLVMValueRef NewVal);
171106f32e7eSjoerg 
171206f32e7eSjoerg /**
171306f32e7eSjoerg  * Determine whether the specified value instance is constant.
171406f32e7eSjoerg  */
171506f32e7eSjoerg LLVMBool LLVMIsConstant(LLVMValueRef Val);
171606f32e7eSjoerg 
171706f32e7eSjoerg /**
171806f32e7eSjoerg  * Determine whether a value instance is undefined.
171906f32e7eSjoerg  */
172006f32e7eSjoerg LLVMBool LLVMIsUndef(LLVMValueRef Val);
172106f32e7eSjoerg 
172206f32e7eSjoerg /**
1723*da58b97aSjoerg  * Determine whether a value instance is poisonous.
1724*da58b97aSjoerg  */
1725*da58b97aSjoerg LLVMBool LLVMIsPoison(LLVMValueRef Val);
1726*da58b97aSjoerg 
1727*da58b97aSjoerg /**
172806f32e7eSjoerg  * Convert value instances between types.
172906f32e7eSjoerg  *
173006f32e7eSjoerg  * Internally, an LLVMValueRef is "pinned" to a specific type. This
173106f32e7eSjoerg  * series of functions allows you to cast an instance to a specific
173206f32e7eSjoerg  * type.
173306f32e7eSjoerg  *
173406f32e7eSjoerg  * If the cast is not valid for the specified type, NULL is returned.
173506f32e7eSjoerg  *
173606f32e7eSjoerg  * @see llvm::dyn_cast_or_null<>
173706f32e7eSjoerg  */
173806f32e7eSjoerg #define LLVM_DECLARE_VALUE_CAST(name) \
173906f32e7eSjoerg   LLVMValueRef LLVMIsA##name(LLVMValueRef Val);
174006f32e7eSjoerg LLVM_FOR_EACH_VALUE_SUBCLASS(LLVM_DECLARE_VALUE_CAST)
174106f32e7eSjoerg 
174206f32e7eSjoerg LLVMValueRef LLVMIsAMDNode(LLVMValueRef Val);
174306f32e7eSjoerg LLVMValueRef LLVMIsAMDString(LLVMValueRef Val);
174406f32e7eSjoerg 
174506f32e7eSjoerg /** Deprecated: Use LLVMGetValueName2 instead. */
174606f32e7eSjoerg const char *LLVMGetValueName(LLVMValueRef Val);
174706f32e7eSjoerg /** Deprecated: Use LLVMSetValueName2 instead. */
174806f32e7eSjoerg void LLVMSetValueName(LLVMValueRef Val, const char *Name);
174906f32e7eSjoerg 
175006f32e7eSjoerg /**
175106f32e7eSjoerg  * @}
175206f32e7eSjoerg  */
175306f32e7eSjoerg 
175406f32e7eSjoerg /**
175506f32e7eSjoerg  * @defgroup LLVMCCoreValueUses Usage
175606f32e7eSjoerg  *
175706f32e7eSjoerg  * This module defines functions that allow you to inspect the uses of a
175806f32e7eSjoerg  * LLVMValueRef.
175906f32e7eSjoerg  *
176006f32e7eSjoerg  * It is possible to obtain an LLVMUseRef for any LLVMValueRef instance.
176106f32e7eSjoerg  * Each LLVMUseRef (which corresponds to a llvm::Use instance) holds a
176206f32e7eSjoerg  * llvm::User and llvm::Value.
176306f32e7eSjoerg  *
176406f32e7eSjoerg  * @{
176506f32e7eSjoerg  */
176606f32e7eSjoerg 
176706f32e7eSjoerg /**
176806f32e7eSjoerg  * Obtain the first use of a value.
176906f32e7eSjoerg  *
177006f32e7eSjoerg  * Uses are obtained in an iterator fashion. First, call this function
177106f32e7eSjoerg  * to obtain a reference to the first use. Then, call LLVMGetNextUse()
177206f32e7eSjoerg  * on that instance and all subsequently obtained instances until
177306f32e7eSjoerg  * LLVMGetNextUse() returns NULL.
177406f32e7eSjoerg  *
177506f32e7eSjoerg  * @see llvm::Value::use_begin()
177606f32e7eSjoerg  */
177706f32e7eSjoerg LLVMUseRef LLVMGetFirstUse(LLVMValueRef Val);
177806f32e7eSjoerg 
177906f32e7eSjoerg /**
178006f32e7eSjoerg  * Obtain the next use of a value.
178106f32e7eSjoerg  *
178206f32e7eSjoerg  * This effectively advances the iterator. It returns NULL if you are on
178306f32e7eSjoerg  * the final use and no more are available.
178406f32e7eSjoerg  */
178506f32e7eSjoerg LLVMUseRef LLVMGetNextUse(LLVMUseRef U);
178606f32e7eSjoerg 
178706f32e7eSjoerg /**
178806f32e7eSjoerg  * Obtain the user value for a user.
178906f32e7eSjoerg  *
179006f32e7eSjoerg  * The returned value corresponds to a llvm::User type.
179106f32e7eSjoerg  *
179206f32e7eSjoerg  * @see llvm::Use::getUser()
179306f32e7eSjoerg  */
179406f32e7eSjoerg LLVMValueRef LLVMGetUser(LLVMUseRef U);
179506f32e7eSjoerg 
179606f32e7eSjoerg /**
179706f32e7eSjoerg  * Obtain the value this use corresponds to.
179806f32e7eSjoerg  *
179906f32e7eSjoerg  * @see llvm::Use::get().
180006f32e7eSjoerg  */
180106f32e7eSjoerg LLVMValueRef LLVMGetUsedValue(LLVMUseRef U);
180206f32e7eSjoerg 
180306f32e7eSjoerg /**
180406f32e7eSjoerg  * @}
180506f32e7eSjoerg  */
180606f32e7eSjoerg 
180706f32e7eSjoerg /**
180806f32e7eSjoerg  * @defgroup LLVMCCoreValueUser User value
180906f32e7eSjoerg  *
181006f32e7eSjoerg  * Function in this group pertain to LLVMValueRef instances that descent
181106f32e7eSjoerg  * from llvm::User. This includes constants, instructions, and
181206f32e7eSjoerg  * operators.
181306f32e7eSjoerg  *
181406f32e7eSjoerg  * @{
181506f32e7eSjoerg  */
181606f32e7eSjoerg 
181706f32e7eSjoerg /**
181806f32e7eSjoerg  * Obtain an operand at a specific index in a llvm::User value.
181906f32e7eSjoerg  *
182006f32e7eSjoerg  * @see llvm::User::getOperand()
182106f32e7eSjoerg  */
182206f32e7eSjoerg LLVMValueRef LLVMGetOperand(LLVMValueRef Val, unsigned Index);
182306f32e7eSjoerg 
182406f32e7eSjoerg /**
182506f32e7eSjoerg  * Obtain the use of an operand at a specific index in a llvm::User value.
182606f32e7eSjoerg  *
182706f32e7eSjoerg  * @see llvm::User::getOperandUse()
182806f32e7eSjoerg  */
182906f32e7eSjoerg LLVMUseRef LLVMGetOperandUse(LLVMValueRef Val, unsigned Index);
183006f32e7eSjoerg 
183106f32e7eSjoerg /**
183206f32e7eSjoerg  * Set an operand at a specific index in a llvm::User value.
183306f32e7eSjoerg  *
183406f32e7eSjoerg  * @see llvm::User::setOperand()
183506f32e7eSjoerg  */
183606f32e7eSjoerg void LLVMSetOperand(LLVMValueRef User, unsigned Index, LLVMValueRef Val);
183706f32e7eSjoerg 
183806f32e7eSjoerg /**
183906f32e7eSjoerg  * Obtain the number of operands in a llvm::User value.
184006f32e7eSjoerg  *
184106f32e7eSjoerg  * @see llvm::User::getNumOperands()
184206f32e7eSjoerg  */
184306f32e7eSjoerg int LLVMGetNumOperands(LLVMValueRef Val);
184406f32e7eSjoerg 
184506f32e7eSjoerg /**
184606f32e7eSjoerg  * @}
184706f32e7eSjoerg  */
184806f32e7eSjoerg 
184906f32e7eSjoerg /**
185006f32e7eSjoerg  * @defgroup LLVMCCoreValueConstant Constants
185106f32e7eSjoerg  *
185206f32e7eSjoerg  * This section contains APIs for interacting with LLVMValueRef that
185306f32e7eSjoerg  * correspond to llvm::Constant instances.
185406f32e7eSjoerg  *
185506f32e7eSjoerg  * These functions will work for any LLVMValueRef in the llvm::Constant
185606f32e7eSjoerg  * class hierarchy.
185706f32e7eSjoerg  *
185806f32e7eSjoerg  * @{
185906f32e7eSjoerg  */
186006f32e7eSjoerg 
186106f32e7eSjoerg /**
186206f32e7eSjoerg  * Obtain a constant value referring to the null instance of a type.
186306f32e7eSjoerg  *
186406f32e7eSjoerg  * @see llvm::Constant::getNullValue()
186506f32e7eSjoerg  */
186606f32e7eSjoerg LLVMValueRef LLVMConstNull(LLVMTypeRef Ty); /* all zeroes */
186706f32e7eSjoerg 
186806f32e7eSjoerg /**
186906f32e7eSjoerg  * Obtain a constant value referring to the instance of a type
187006f32e7eSjoerg  * consisting of all ones.
187106f32e7eSjoerg  *
187206f32e7eSjoerg  * This is only valid for integer types.
187306f32e7eSjoerg  *
187406f32e7eSjoerg  * @see llvm::Constant::getAllOnesValue()
187506f32e7eSjoerg  */
187606f32e7eSjoerg LLVMValueRef LLVMConstAllOnes(LLVMTypeRef Ty);
187706f32e7eSjoerg 
187806f32e7eSjoerg /**
187906f32e7eSjoerg  * Obtain a constant value referring to an undefined value of a type.
188006f32e7eSjoerg  *
188106f32e7eSjoerg  * @see llvm::UndefValue::get()
188206f32e7eSjoerg  */
188306f32e7eSjoerg LLVMValueRef LLVMGetUndef(LLVMTypeRef Ty);
188406f32e7eSjoerg 
188506f32e7eSjoerg /**
1886*da58b97aSjoerg  * Obtain a constant value referring to a poison value of a type.
1887*da58b97aSjoerg  *
1888*da58b97aSjoerg  * @see llvm::PoisonValue::get()
1889*da58b97aSjoerg  */
1890*da58b97aSjoerg LLVMValueRef LLVMGetPoison(LLVMTypeRef Ty);
1891*da58b97aSjoerg 
1892*da58b97aSjoerg /**
189306f32e7eSjoerg  * Determine whether a value instance is null.
189406f32e7eSjoerg  *
189506f32e7eSjoerg  * @see llvm::Constant::isNullValue()
189606f32e7eSjoerg  */
189706f32e7eSjoerg LLVMBool LLVMIsNull(LLVMValueRef Val);
189806f32e7eSjoerg 
189906f32e7eSjoerg /**
190006f32e7eSjoerg  * Obtain a constant that is a constant pointer pointing to NULL for a
190106f32e7eSjoerg  * specified type.
190206f32e7eSjoerg  */
190306f32e7eSjoerg LLVMValueRef LLVMConstPointerNull(LLVMTypeRef Ty);
190406f32e7eSjoerg 
190506f32e7eSjoerg /**
190606f32e7eSjoerg  * @defgroup LLVMCCoreValueConstantScalar Scalar constants
190706f32e7eSjoerg  *
190806f32e7eSjoerg  * Functions in this group model LLVMValueRef instances that correspond
190906f32e7eSjoerg  * to constants referring to scalar types.
191006f32e7eSjoerg  *
191106f32e7eSjoerg  * For integer types, the LLVMTypeRef parameter should correspond to a
191206f32e7eSjoerg  * llvm::IntegerType instance and the returned LLVMValueRef will
191306f32e7eSjoerg  * correspond to a llvm::ConstantInt.
191406f32e7eSjoerg  *
191506f32e7eSjoerg  * For floating point types, the LLVMTypeRef returned corresponds to a
191606f32e7eSjoerg  * llvm::ConstantFP.
191706f32e7eSjoerg  *
191806f32e7eSjoerg  * @{
191906f32e7eSjoerg  */
192006f32e7eSjoerg 
192106f32e7eSjoerg /**
192206f32e7eSjoerg  * Obtain a constant value for an integer type.
192306f32e7eSjoerg  *
192406f32e7eSjoerg  * The returned value corresponds to a llvm::ConstantInt.
192506f32e7eSjoerg  *
192606f32e7eSjoerg  * @see llvm::ConstantInt::get()
192706f32e7eSjoerg  *
192806f32e7eSjoerg  * @param IntTy Integer type to obtain value of.
192906f32e7eSjoerg  * @param N The value the returned instance should refer to.
193006f32e7eSjoerg  * @param SignExtend Whether to sign extend the produced value.
193106f32e7eSjoerg  */
193206f32e7eSjoerg LLVMValueRef LLVMConstInt(LLVMTypeRef IntTy, unsigned long long N,
193306f32e7eSjoerg                           LLVMBool SignExtend);
193406f32e7eSjoerg 
193506f32e7eSjoerg /**
193606f32e7eSjoerg  * Obtain a constant value for an integer of arbitrary precision.
193706f32e7eSjoerg  *
193806f32e7eSjoerg  * @see llvm::ConstantInt::get()
193906f32e7eSjoerg  */
194006f32e7eSjoerg LLVMValueRef LLVMConstIntOfArbitraryPrecision(LLVMTypeRef IntTy,
194106f32e7eSjoerg                                               unsigned NumWords,
194206f32e7eSjoerg                                               const uint64_t Words[]);
194306f32e7eSjoerg 
194406f32e7eSjoerg /**
194506f32e7eSjoerg  * Obtain a constant value for an integer parsed from a string.
194606f32e7eSjoerg  *
194706f32e7eSjoerg  * A similar API, LLVMConstIntOfStringAndSize is also available. If the
194806f32e7eSjoerg  * string's length is available, it is preferred to call that function
194906f32e7eSjoerg  * instead.
195006f32e7eSjoerg  *
195106f32e7eSjoerg  * @see llvm::ConstantInt::get()
195206f32e7eSjoerg  */
195306f32e7eSjoerg LLVMValueRef LLVMConstIntOfString(LLVMTypeRef IntTy, const char *Text,
195406f32e7eSjoerg                                   uint8_t Radix);
195506f32e7eSjoerg 
195606f32e7eSjoerg /**
195706f32e7eSjoerg  * Obtain a constant value for an integer parsed from a string with
195806f32e7eSjoerg  * specified length.
195906f32e7eSjoerg  *
196006f32e7eSjoerg  * @see llvm::ConstantInt::get()
196106f32e7eSjoerg  */
196206f32e7eSjoerg LLVMValueRef LLVMConstIntOfStringAndSize(LLVMTypeRef IntTy, const char *Text,
196306f32e7eSjoerg                                          unsigned SLen, uint8_t Radix);
196406f32e7eSjoerg 
196506f32e7eSjoerg /**
196606f32e7eSjoerg  * Obtain a constant value referring to a double floating point value.
196706f32e7eSjoerg  */
196806f32e7eSjoerg LLVMValueRef LLVMConstReal(LLVMTypeRef RealTy, double N);
196906f32e7eSjoerg 
197006f32e7eSjoerg /**
197106f32e7eSjoerg  * Obtain a constant for a floating point value parsed from a string.
197206f32e7eSjoerg  *
197306f32e7eSjoerg  * A similar API, LLVMConstRealOfStringAndSize is also available. It
197406f32e7eSjoerg  * should be used if the input string's length is known.
197506f32e7eSjoerg  */
197606f32e7eSjoerg LLVMValueRef LLVMConstRealOfString(LLVMTypeRef RealTy, const char *Text);
197706f32e7eSjoerg 
197806f32e7eSjoerg /**
197906f32e7eSjoerg  * Obtain a constant for a floating point value parsed from a string.
198006f32e7eSjoerg  */
198106f32e7eSjoerg LLVMValueRef LLVMConstRealOfStringAndSize(LLVMTypeRef RealTy, const char *Text,
198206f32e7eSjoerg                                           unsigned SLen);
198306f32e7eSjoerg 
198406f32e7eSjoerg /**
198506f32e7eSjoerg  * Obtain the zero extended value for an integer constant value.
198606f32e7eSjoerg  *
198706f32e7eSjoerg  * @see llvm::ConstantInt::getZExtValue()
198806f32e7eSjoerg  */
198906f32e7eSjoerg unsigned long long LLVMConstIntGetZExtValue(LLVMValueRef ConstantVal);
199006f32e7eSjoerg 
199106f32e7eSjoerg /**
199206f32e7eSjoerg  * Obtain the sign extended value for an integer constant value.
199306f32e7eSjoerg  *
199406f32e7eSjoerg  * @see llvm::ConstantInt::getSExtValue()
199506f32e7eSjoerg  */
199606f32e7eSjoerg long long LLVMConstIntGetSExtValue(LLVMValueRef ConstantVal);
199706f32e7eSjoerg 
199806f32e7eSjoerg /**
199906f32e7eSjoerg  * Obtain the double value for an floating point constant value.
200006f32e7eSjoerg  * losesInfo indicates if some precision was lost in the conversion.
200106f32e7eSjoerg  *
200206f32e7eSjoerg  * @see llvm::ConstantFP::getDoubleValue
200306f32e7eSjoerg  */
200406f32e7eSjoerg double LLVMConstRealGetDouble(LLVMValueRef ConstantVal, LLVMBool *losesInfo);
200506f32e7eSjoerg 
200606f32e7eSjoerg /**
200706f32e7eSjoerg  * @}
200806f32e7eSjoerg  */
200906f32e7eSjoerg 
201006f32e7eSjoerg /**
201106f32e7eSjoerg  * @defgroup LLVMCCoreValueConstantComposite Composite Constants
201206f32e7eSjoerg  *
201306f32e7eSjoerg  * Functions in this group operate on composite constants.
201406f32e7eSjoerg  *
201506f32e7eSjoerg  * @{
201606f32e7eSjoerg  */
201706f32e7eSjoerg 
201806f32e7eSjoerg /**
201906f32e7eSjoerg  * Create a ConstantDataSequential and initialize it with a string.
202006f32e7eSjoerg  *
202106f32e7eSjoerg  * @see llvm::ConstantDataArray::getString()
202206f32e7eSjoerg  */
202306f32e7eSjoerg LLVMValueRef LLVMConstStringInContext(LLVMContextRef C, const char *Str,
202406f32e7eSjoerg                                       unsigned Length, LLVMBool DontNullTerminate);
202506f32e7eSjoerg 
202606f32e7eSjoerg /**
202706f32e7eSjoerg  * Create a ConstantDataSequential with string content in the global context.
202806f32e7eSjoerg  *
202906f32e7eSjoerg  * This is the same as LLVMConstStringInContext except it operates on the
203006f32e7eSjoerg  * global context.
203106f32e7eSjoerg  *
203206f32e7eSjoerg  * @see LLVMConstStringInContext()
203306f32e7eSjoerg  * @see llvm::ConstantDataArray::getString()
203406f32e7eSjoerg  */
203506f32e7eSjoerg LLVMValueRef LLVMConstString(const char *Str, unsigned Length,
203606f32e7eSjoerg                              LLVMBool DontNullTerminate);
203706f32e7eSjoerg 
203806f32e7eSjoerg /**
203906f32e7eSjoerg  * Returns true if the specified constant is an array of i8.
204006f32e7eSjoerg  *
204106f32e7eSjoerg  * @see ConstantDataSequential::getAsString()
204206f32e7eSjoerg  */
204306f32e7eSjoerg LLVMBool LLVMIsConstantString(LLVMValueRef c);
204406f32e7eSjoerg 
204506f32e7eSjoerg /**
204606f32e7eSjoerg  * Get the given constant data sequential as a string.
204706f32e7eSjoerg  *
204806f32e7eSjoerg  * @see ConstantDataSequential::getAsString()
204906f32e7eSjoerg  */
205006f32e7eSjoerg const char *LLVMGetAsString(LLVMValueRef c, size_t *Length);
205106f32e7eSjoerg 
205206f32e7eSjoerg /**
205306f32e7eSjoerg  * Create an anonymous ConstantStruct with the specified values.
205406f32e7eSjoerg  *
205506f32e7eSjoerg  * @see llvm::ConstantStruct::getAnon()
205606f32e7eSjoerg  */
205706f32e7eSjoerg LLVMValueRef LLVMConstStructInContext(LLVMContextRef C,
205806f32e7eSjoerg                                       LLVMValueRef *ConstantVals,
205906f32e7eSjoerg                                       unsigned Count, LLVMBool Packed);
206006f32e7eSjoerg 
206106f32e7eSjoerg /**
206206f32e7eSjoerg  * Create a ConstantStruct in the global Context.
206306f32e7eSjoerg  *
206406f32e7eSjoerg  * This is the same as LLVMConstStructInContext except it operates on the
206506f32e7eSjoerg  * global Context.
206606f32e7eSjoerg  *
206706f32e7eSjoerg  * @see LLVMConstStructInContext()
206806f32e7eSjoerg  */
206906f32e7eSjoerg LLVMValueRef LLVMConstStruct(LLVMValueRef *ConstantVals, unsigned Count,
207006f32e7eSjoerg                              LLVMBool Packed);
207106f32e7eSjoerg 
207206f32e7eSjoerg /**
207306f32e7eSjoerg  * Create a ConstantArray from values.
207406f32e7eSjoerg  *
207506f32e7eSjoerg  * @see llvm::ConstantArray::get()
207606f32e7eSjoerg  */
207706f32e7eSjoerg LLVMValueRef LLVMConstArray(LLVMTypeRef ElementTy,
207806f32e7eSjoerg                             LLVMValueRef *ConstantVals, unsigned Length);
207906f32e7eSjoerg 
208006f32e7eSjoerg /**
208106f32e7eSjoerg  * Create a non-anonymous ConstantStruct from values.
208206f32e7eSjoerg  *
208306f32e7eSjoerg  * @see llvm::ConstantStruct::get()
208406f32e7eSjoerg  */
208506f32e7eSjoerg LLVMValueRef LLVMConstNamedStruct(LLVMTypeRef StructTy,
208606f32e7eSjoerg                                   LLVMValueRef *ConstantVals,
208706f32e7eSjoerg                                   unsigned Count);
208806f32e7eSjoerg 
208906f32e7eSjoerg /**
209006f32e7eSjoerg  * Get an element at specified index as a constant.
209106f32e7eSjoerg  *
209206f32e7eSjoerg  * @see ConstantDataSequential::getElementAsConstant()
209306f32e7eSjoerg  */
209406f32e7eSjoerg LLVMValueRef LLVMGetElementAsConstant(LLVMValueRef C, unsigned idx);
209506f32e7eSjoerg 
209606f32e7eSjoerg /**
209706f32e7eSjoerg  * Create a ConstantVector from values.
209806f32e7eSjoerg  *
209906f32e7eSjoerg  * @see llvm::ConstantVector::get()
210006f32e7eSjoerg  */
210106f32e7eSjoerg LLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals, unsigned Size);
210206f32e7eSjoerg 
210306f32e7eSjoerg /**
210406f32e7eSjoerg  * @}
210506f32e7eSjoerg  */
210606f32e7eSjoerg 
210706f32e7eSjoerg /**
210806f32e7eSjoerg  * @defgroup LLVMCCoreValueConstantExpressions Constant Expressions
210906f32e7eSjoerg  *
211006f32e7eSjoerg  * Functions in this group correspond to APIs on llvm::ConstantExpr.
211106f32e7eSjoerg  *
211206f32e7eSjoerg  * @see llvm::ConstantExpr.
211306f32e7eSjoerg  *
211406f32e7eSjoerg  * @{
211506f32e7eSjoerg  */
211606f32e7eSjoerg LLVMOpcode LLVMGetConstOpcode(LLVMValueRef ConstantVal);
211706f32e7eSjoerg LLVMValueRef LLVMAlignOf(LLVMTypeRef Ty);
211806f32e7eSjoerg LLVMValueRef LLVMSizeOf(LLVMTypeRef Ty);
211906f32e7eSjoerg LLVMValueRef LLVMConstNeg(LLVMValueRef ConstantVal);
212006f32e7eSjoerg LLVMValueRef LLVMConstNSWNeg(LLVMValueRef ConstantVal);
212106f32e7eSjoerg LLVMValueRef LLVMConstNUWNeg(LLVMValueRef ConstantVal);
212206f32e7eSjoerg LLVMValueRef LLVMConstFNeg(LLVMValueRef ConstantVal);
212306f32e7eSjoerg LLVMValueRef LLVMConstNot(LLVMValueRef ConstantVal);
212406f32e7eSjoerg LLVMValueRef LLVMConstAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
212506f32e7eSjoerg LLVMValueRef LLVMConstNSWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
212606f32e7eSjoerg LLVMValueRef LLVMConstNUWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
212706f32e7eSjoerg LLVMValueRef LLVMConstFAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
212806f32e7eSjoerg LLVMValueRef LLVMConstSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
212906f32e7eSjoerg LLVMValueRef LLVMConstNSWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
213006f32e7eSjoerg LLVMValueRef LLVMConstNUWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
213106f32e7eSjoerg LLVMValueRef LLVMConstFSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
213206f32e7eSjoerg LLVMValueRef LLVMConstMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
213306f32e7eSjoerg LLVMValueRef LLVMConstNSWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
213406f32e7eSjoerg LLVMValueRef LLVMConstNUWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
213506f32e7eSjoerg LLVMValueRef LLVMConstFMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
213606f32e7eSjoerg LLVMValueRef LLVMConstUDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
213706f32e7eSjoerg LLVMValueRef LLVMConstExactUDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
213806f32e7eSjoerg LLVMValueRef LLVMConstSDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
213906f32e7eSjoerg LLVMValueRef LLVMConstExactSDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
214006f32e7eSjoerg LLVMValueRef LLVMConstFDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
214106f32e7eSjoerg LLVMValueRef LLVMConstURem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
214206f32e7eSjoerg LLVMValueRef LLVMConstSRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
214306f32e7eSjoerg LLVMValueRef LLVMConstFRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
214406f32e7eSjoerg LLVMValueRef LLVMConstAnd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
214506f32e7eSjoerg LLVMValueRef LLVMConstOr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
214606f32e7eSjoerg LLVMValueRef LLVMConstXor(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
214706f32e7eSjoerg LLVMValueRef LLVMConstICmp(LLVMIntPredicate Predicate,
214806f32e7eSjoerg                            LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
214906f32e7eSjoerg LLVMValueRef LLVMConstFCmp(LLVMRealPredicate Predicate,
215006f32e7eSjoerg                            LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
215106f32e7eSjoerg LLVMValueRef LLVMConstShl(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
215206f32e7eSjoerg LLVMValueRef LLVMConstLShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
215306f32e7eSjoerg LLVMValueRef LLVMConstAShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
215406f32e7eSjoerg LLVMValueRef LLVMConstGEP(LLVMValueRef ConstantVal,
215506f32e7eSjoerg                           LLVMValueRef *ConstantIndices, unsigned NumIndices);
215606f32e7eSjoerg LLVMValueRef LLVMConstGEP2(LLVMTypeRef Ty, LLVMValueRef ConstantVal,
215706f32e7eSjoerg                            LLVMValueRef *ConstantIndices, unsigned NumIndices);
215806f32e7eSjoerg LLVMValueRef LLVMConstInBoundsGEP(LLVMValueRef ConstantVal,
215906f32e7eSjoerg                                   LLVMValueRef *ConstantIndices,
216006f32e7eSjoerg                                   unsigned NumIndices);
216106f32e7eSjoerg LLVMValueRef LLVMConstInBoundsGEP2(LLVMTypeRef Ty, LLVMValueRef ConstantVal,
216206f32e7eSjoerg                                    LLVMValueRef *ConstantIndices,
216306f32e7eSjoerg                                    unsigned NumIndices);
216406f32e7eSjoerg LLVMValueRef LLVMConstTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
216506f32e7eSjoerg LLVMValueRef LLVMConstSExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
216606f32e7eSjoerg LLVMValueRef LLVMConstZExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
216706f32e7eSjoerg LLVMValueRef LLVMConstFPTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
216806f32e7eSjoerg LLVMValueRef LLVMConstFPExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
216906f32e7eSjoerg LLVMValueRef LLVMConstUIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
217006f32e7eSjoerg LLVMValueRef LLVMConstSIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
217106f32e7eSjoerg LLVMValueRef LLVMConstFPToUI(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
217206f32e7eSjoerg LLVMValueRef LLVMConstFPToSI(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
217306f32e7eSjoerg LLVMValueRef LLVMConstPtrToInt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
217406f32e7eSjoerg LLVMValueRef LLVMConstIntToPtr(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
217506f32e7eSjoerg LLVMValueRef LLVMConstBitCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
217606f32e7eSjoerg LLVMValueRef LLVMConstAddrSpaceCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
217706f32e7eSjoerg LLVMValueRef LLVMConstZExtOrBitCast(LLVMValueRef ConstantVal,
217806f32e7eSjoerg                                     LLVMTypeRef ToType);
217906f32e7eSjoerg LLVMValueRef LLVMConstSExtOrBitCast(LLVMValueRef ConstantVal,
218006f32e7eSjoerg                                     LLVMTypeRef ToType);
218106f32e7eSjoerg LLVMValueRef LLVMConstTruncOrBitCast(LLVMValueRef ConstantVal,
218206f32e7eSjoerg                                      LLVMTypeRef ToType);
218306f32e7eSjoerg LLVMValueRef LLVMConstPointerCast(LLVMValueRef ConstantVal,
218406f32e7eSjoerg                                   LLVMTypeRef ToType);
218506f32e7eSjoerg LLVMValueRef LLVMConstIntCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType,
218606f32e7eSjoerg                               LLVMBool isSigned);
218706f32e7eSjoerg LLVMValueRef LLVMConstFPCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
218806f32e7eSjoerg LLVMValueRef LLVMConstSelect(LLVMValueRef ConstantCondition,
218906f32e7eSjoerg                              LLVMValueRef ConstantIfTrue,
219006f32e7eSjoerg                              LLVMValueRef ConstantIfFalse);
219106f32e7eSjoerg LLVMValueRef LLVMConstExtractElement(LLVMValueRef VectorConstant,
219206f32e7eSjoerg                                      LLVMValueRef IndexConstant);
219306f32e7eSjoerg LLVMValueRef LLVMConstInsertElement(LLVMValueRef VectorConstant,
219406f32e7eSjoerg                                     LLVMValueRef ElementValueConstant,
219506f32e7eSjoerg                                     LLVMValueRef IndexConstant);
219606f32e7eSjoerg LLVMValueRef LLVMConstShuffleVector(LLVMValueRef VectorAConstant,
219706f32e7eSjoerg                                     LLVMValueRef VectorBConstant,
219806f32e7eSjoerg                                     LLVMValueRef MaskConstant);
219906f32e7eSjoerg LLVMValueRef LLVMConstExtractValue(LLVMValueRef AggConstant, unsigned *IdxList,
220006f32e7eSjoerg                                    unsigned NumIdx);
220106f32e7eSjoerg LLVMValueRef LLVMConstInsertValue(LLVMValueRef AggConstant,
220206f32e7eSjoerg                                   LLVMValueRef ElementValueConstant,
220306f32e7eSjoerg                                   unsigned *IdxList, unsigned NumIdx);
220406f32e7eSjoerg LLVMValueRef LLVMBlockAddress(LLVMValueRef F, LLVMBasicBlockRef BB);
220506f32e7eSjoerg 
220606f32e7eSjoerg /** Deprecated: Use LLVMGetInlineAsm instead. */
220706f32e7eSjoerg LLVMValueRef LLVMConstInlineAsm(LLVMTypeRef Ty,
220806f32e7eSjoerg                                 const char *AsmString, const char *Constraints,
220906f32e7eSjoerg                                 LLVMBool HasSideEffects, LLVMBool IsAlignStack);
221006f32e7eSjoerg 
221106f32e7eSjoerg /**
221206f32e7eSjoerg  * @}
221306f32e7eSjoerg  */
221406f32e7eSjoerg 
221506f32e7eSjoerg /**
221606f32e7eSjoerg  * @defgroup LLVMCCoreValueConstantGlobals Global Values
221706f32e7eSjoerg  *
221806f32e7eSjoerg  * This group contains functions that operate on global values. Functions in
221906f32e7eSjoerg  * this group relate to functions in the llvm::GlobalValue class tree.
222006f32e7eSjoerg  *
222106f32e7eSjoerg  * @see llvm::GlobalValue
222206f32e7eSjoerg  *
222306f32e7eSjoerg  * @{
222406f32e7eSjoerg  */
222506f32e7eSjoerg 
222606f32e7eSjoerg LLVMModuleRef LLVMGetGlobalParent(LLVMValueRef Global);
222706f32e7eSjoerg LLVMBool LLVMIsDeclaration(LLVMValueRef Global);
222806f32e7eSjoerg LLVMLinkage LLVMGetLinkage(LLVMValueRef Global);
222906f32e7eSjoerg void LLVMSetLinkage(LLVMValueRef Global, LLVMLinkage Linkage);
223006f32e7eSjoerg const char *LLVMGetSection(LLVMValueRef Global);
223106f32e7eSjoerg void LLVMSetSection(LLVMValueRef Global, const char *Section);
223206f32e7eSjoerg LLVMVisibility LLVMGetVisibility(LLVMValueRef Global);
223306f32e7eSjoerg void LLVMSetVisibility(LLVMValueRef Global, LLVMVisibility Viz);
223406f32e7eSjoerg LLVMDLLStorageClass LLVMGetDLLStorageClass(LLVMValueRef Global);
223506f32e7eSjoerg void LLVMSetDLLStorageClass(LLVMValueRef Global, LLVMDLLStorageClass Class);
223606f32e7eSjoerg LLVMUnnamedAddr LLVMGetUnnamedAddress(LLVMValueRef Global);
223706f32e7eSjoerg void LLVMSetUnnamedAddress(LLVMValueRef Global, LLVMUnnamedAddr UnnamedAddr);
223806f32e7eSjoerg 
223906f32e7eSjoerg /**
224006f32e7eSjoerg  * Returns the "value type" of a global value.  This differs from the formal
224106f32e7eSjoerg  * type of a global value which is always a pointer type.
224206f32e7eSjoerg  *
224306f32e7eSjoerg  * @see llvm::GlobalValue::getValueType()
224406f32e7eSjoerg  */
224506f32e7eSjoerg LLVMTypeRef LLVMGlobalGetValueType(LLVMValueRef Global);
224606f32e7eSjoerg 
224706f32e7eSjoerg /** Deprecated: Use LLVMGetUnnamedAddress instead. */
224806f32e7eSjoerg LLVMBool LLVMHasUnnamedAddr(LLVMValueRef Global);
224906f32e7eSjoerg /** Deprecated: Use LLVMSetUnnamedAddress instead. */
225006f32e7eSjoerg void LLVMSetUnnamedAddr(LLVMValueRef Global, LLVMBool HasUnnamedAddr);
225106f32e7eSjoerg 
225206f32e7eSjoerg /**
225306f32e7eSjoerg  * @defgroup LLVMCCoreValueWithAlignment Values with alignment
225406f32e7eSjoerg  *
225506f32e7eSjoerg  * Functions in this group only apply to values with alignment, i.e.
225606f32e7eSjoerg  * global variables, load and store instructions.
225706f32e7eSjoerg  */
225806f32e7eSjoerg 
225906f32e7eSjoerg /**
226006f32e7eSjoerg  * Obtain the preferred alignment of the value.
226106f32e7eSjoerg  * @see llvm::AllocaInst::getAlignment()
226206f32e7eSjoerg  * @see llvm::LoadInst::getAlignment()
226306f32e7eSjoerg  * @see llvm::StoreInst::getAlignment()
2264*da58b97aSjoerg  * @see llvm::AtomicRMWInst::setAlignment()
2265*da58b97aSjoerg  * @see llvm::AtomicCmpXchgInst::setAlignment()
226606f32e7eSjoerg  * @see llvm::GlobalValue::getAlignment()
226706f32e7eSjoerg  */
226806f32e7eSjoerg unsigned LLVMGetAlignment(LLVMValueRef V);
226906f32e7eSjoerg 
227006f32e7eSjoerg /**
227106f32e7eSjoerg  * Set the preferred alignment of the value.
227206f32e7eSjoerg  * @see llvm::AllocaInst::setAlignment()
227306f32e7eSjoerg  * @see llvm::LoadInst::setAlignment()
227406f32e7eSjoerg  * @see llvm::StoreInst::setAlignment()
2275*da58b97aSjoerg  * @see llvm::AtomicRMWInst::setAlignment()
2276*da58b97aSjoerg  * @see llvm::AtomicCmpXchgInst::setAlignment()
227706f32e7eSjoerg  * @see llvm::GlobalValue::setAlignment()
227806f32e7eSjoerg  */
227906f32e7eSjoerg void LLVMSetAlignment(LLVMValueRef V, unsigned Bytes);
228006f32e7eSjoerg 
228106f32e7eSjoerg /**
228206f32e7eSjoerg  * Sets a metadata attachment, erasing the existing metadata attachment if
228306f32e7eSjoerg  * it already exists for the given kind.
228406f32e7eSjoerg  *
228506f32e7eSjoerg  * @see llvm::GlobalObject::setMetadata()
228606f32e7eSjoerg  */
228706f32e7eSjoerg void LLVMGlobalSetMetadata(LLVMValueRef Global, unsigned Kind,
228806f32e7eSjoerg                            LLVMMetadataRef MD);
228906f32e7eSjoerg 
229006f32e7eSjoerg /**
229106f32e7eSjoerg  * Erases a metadata attachment of the given kind if it exists.
229206f32e7eSjoerg  *
229306f32e7eSjoerg  * @see llvm::GlobalObject::eraseMetadata()
229406f32e7eSjoerg  */
229506f32e7eSjoerg void LLVMGlobalEraseMetadata(LLVMValueRef Global, unsigned Kind);
229606f32e7eSjoerg 
229706f32e7eSjoerg /**
229806f32e7eSjoerg  * Removes all metadata attachments from this value.
229906f32e7eSjoerg  *
230006f32e7eSjoerg  * @see llvm::GlobalObject::clearMetadata()
230106f32e7eSjoerg  */
230206f32e7eSjoerg void LLVMGlobalClearMetadata(LLVMValueRef Global);
230306f32e7eSjoerg 
230406f32e7eSjoerg /**
230506f32e7eSjoerg  * Retrieves an array of metadata entries representing the metadata attached to
230606f32e7eSjoerg  * this value. The caller is responsible for freeing this array by calling
230706f32e7eSjoerg  * \c LLVMDisposeValueMetadataEntries.
230806f32e7eSjoerg  *
230906f32e7eSjoerg  * @see llvm::GlobalObject::getAllMetadata()
231006f32e7eSjoerg  */
231106f32e7eSjoerg LLVMValueMetadataEntry *LLVMGlobalCopyAllMetadata(LLVMValueRef Value,
231206f32e7eSjoerg                                                   size_t *NumEntries);
231306f32e7eSjoerg 
231406f32e7eSjoerg /**
231506f32e7eSjoerg  * Destroys value metadata entries.
231606f32e7eSjoerg  */
231706f32e7eSjoerg void LLVMDisposeValueMetadataEntries(LLVMValueMetadataEntry *Entries);
231806f32e7eSjoerg 
231906f32e7eSjoerg /**
232006f32e7eSjoerg  * Returns the kind of a value metadata entry at a specific index.
232106f32e7eSjoerg  */
232206f32e7eSjoerg unsigned LLVMValueMetadataEntriesGetKind(LLVMValueMetadataEntry *Entries,
232306f32e7eSjoerg                                          unsigned Index);
232406f32e7eSjoerg 
232506f32e7eSjoerg /**
232606f32e7eSjoerg  * Returns the underlying metadata node of a value metadata entry at a
232706f32e7eSjoerg  * specific index.
232806f32e7eSjoerg  */
232906f32e7eSjoerg LLVMMetadataRef
233006f32e7eSjoerg LLVMValueMetadataEntriesGetMetadata(LLVMValueMetadataEntry *Entries,
233106f32e7eSjoerg                                     unsigned Index);
233206f32e7eSjoerg 
233306f32e7eSjoerg /**
233406f32e7eSjoerg  * @}
233506f32e7eSjoerg  */
233606f32e7eSjoerg 
233706f32e7eSjoerg /**
233806f32e7eSjoerg  * @defgroup LLVMCoreValueConstantGlobalVariable Global Variables
233906f32e7eSjoerg  *
234006f32e7eSjoerg  * This group contains functions that operate on global variable values.
234106f32e7eSjoerg  *
234206f32e7eSjoerg  * @see llvm::GlobalVariable
234306f32e7eSjoerg  *
234406f32e7eSjoerg  * @{
234506f32e7eSjoerg  */
234606f32e7eSjoerg LLVMValueRef LLVMAddGlobal(LLVMModuleRef M, LLVMTypeRef Ty, const char *Name);
234706f32e7eSjoerg LLVMValueRef LLVMAddGlobalInAddressSpace(LLVMModuleRef M, LLVMTypeRef Ty,
234806f32e7eSjoerg                                          const char *Name,
234906f32e7eSjoerg                                          unsigned AddressSpace);
235006f32e7eSjoerg LLVMValueRef LLVMGetNamedGlobal(LLVMModuleRef M, const char *Name);
235106f32e7eSjoerg LLVMValueRef LLVMGetFirstGlobal(LLVMModuleRef M);
235206f32e7eSjoerg LLVMValueRef LLVMGetLastGlobal(LLVMModuleRef M);
235306f32e7eSjoerg LLVMValueRef LLVMGetNextGlobal(LLVMValueRef GlobalVar);
235406f32e7eSjoerg LLVMValueRef LLVMGetPreviousGlobal(LLVMValueRef GlobalVar);
235506f32e7eSjoerg void LLVMDeleteGlobal(LLVMValueRef GlobalVar);
235606f32e7eSjoerg LLVMValueRef LLVMGetInitializer(LLVMValueRef GlobalVar);
235706f32e7eSjoerg void LLVMSetInitializer(LLVMValueRef GlobalVar, LLVMValueRef ConstantVal);
235806f32e7eSjoerg LLVMBool LLVMIsThreadLocal(LLVMValueRef GlobalVar);
235906f32e7eSjoerg void LLVMSetThreadLocal(LLVMValueRef GlobalVar, LLVMBool IsThreadLocal);
236006f32e7eSjoerg LLVMBool LLVMIsGlobalConstant(LLVMValueRef GlobalVar);
236106f32e7eSjoerg void LLVMSetGlobalConstant(LLVMValueRef GlobalVar, LLVMBool IsConstant);
236206f32e7eSjoerg LLVMThreadLocalMode LLVMGetThreadLocalMode(LLVMValueRef GlobalVar);
236306f32e7eSjoerg void LLVMSetThreadLocalMode(LLVMValueRef GlobalVar, LLVMThreadLocalMode Mode);
236406f32e7eSjoerg LLVMBool LLVMIsExternallyInitialized(LLVMValueRef GlobalVar);
236506f32e7eSjoerg void LLVMSetExternallyInitialized(LLVMValueRef GlobalVar, LLVMBool IsExtInit);
236606f32e7eSjoerg 
236706f32e7eSjoerg /**
236806f32e7eSjoerg  * @}
236906f32e7eSjoerg  */
237006f32e7eSjoerg 
237106f32e7eSjoerg /**
237206f32e7eSjoerg  * @defgroup LLVMCoreValueConstantGlobalAlias Global Aliases
237306f32e7eSjoerg  *
237406f32e7eSjoerg  * This group contains function that operate on global alias values.
237506f32e7eSjoerg  *
237606f32e7eSjoerg  * @see llvm::GlobalAlias
237706f32e7eSjoerg  *
237806f32e7eSjoerg  * @{
237906f32e7eSjoerg  */
238006f32e7eSjoerg LLVMValueRef LLVMAddAlias(LLVMModuleRef M, LLVMTypeRef Ty, LLVMValueRef Aliasee,
238106f32e7eSjoerg                           const char *Name);
238206f32e7eSjoerg 
238306f32e7eSjoerg /**
238406f32e7eSjoerg  * Obtain a GlobalAlias value from a Module by its name.
238506f32e7eSjoerg  *
238606f32e7eSjoerg  * The returned value corresponds to a llvm::GlobalAlias value.
238706f32e7eSjoerg  *
238806f32e7eSjoerg  * @see llvm::Module::getNamedAlias()
238906f32e7eSjoerg  */
239006f32e7eSjoerg LLVMValueRef LLVMGetNamedGlobalAlias(LLVMModuleRef M,
239106f32e7eSjoerg                                      const char *Name, size_t NameLen);
239206f32e7eSjoerg 
239306f32e7eSjoerg /**
239406f32e7eSjoerg  * Obtain an iterator to the first GlobalAlias in a Module.
239506f32e7eSjoerg  *
239606f32e7eSjoerg  * @see llvm::Module::alias_begin()
239706f32e7eSjoerg  */
239806f32e7eSjoerg LLVMValueRef LLVMGetFirstGlobalAlias(LLVMModuleRef M);
239906f32e7eSjoerg 
240006f32e7eSjoerg /**
240106f32e7eSjoerg  * Obtain an iterator to the last GlobalAlias in a Module.
240206f32e7eSjoerg  *
240306f32e7eSjoerg  * @see llvm::Module::alias_end()
240406f32e7eSjoerg  */
240506f32e7eSjoerg LLVMValueRef LLVMGetLastGlobalAlias(LLVMModuleRef M);
240606f32e7eSjoerg 
240706f32e7eSjoerg /**
240806f32e7eSjoerg  * Advance a GlobalAlias iterator to the next GlobalAlias.
240906f32e7eSjoerg  *
241006f32e7eSjoerg  * Returns NULL if the iterator was already at the end and there are no more
241106f32e7eSjoerg  * global aliases.
241206f32e7eSjoerg  */
241306f32e7eSjoerg LLVMValueRef LLVMGetNextGlobalAlias(LLVMValueRef GA);
241406f32e7eSjoerg 
241506f32e7eSjoerg /**
241606f32e7eSjoerg  * Decrement a GlobalAlias iterator to the previous GlobalAlias.
241706f32e7eSjoerg  *
241806f32e7eSjoerg  * Returns NULL if the iterator was already at the beginning and there are
241906f32e7eSjoerg  * no previous global aliases.
242006f32e7eSjoerg  */
242106f32e7eSjoerg LLVMValueRef LLVMGetPreviousGlobalAlias(LLVMValueRef GA);
242206f32e7eSjoerg 
242306f32e7eSjoerg /**
242406f32e7eSjoerg  * Retrieve the target value of an alias.
242506f32e7eSjoerg  */
242606f32e7eSjoerg LLVMValueRef LLVMAliasGetAliasee(LLVMValueRef Alias);
242706f32e7eSjoerg 
242806f32e7eSjoerg /**
242906f32e7eSjoerg  * Set the target value of an alias.
243006f32e7eSjoerg  */
243106f32e7eSjoerg void LLVMAliasSetAliasee(LLVMValueRef Alias, LLVMValueRef Aliasee);
243206f32e7eSjoerg 
243306f32e7eSjoerg /**
243406f32e7eSjoerg  * @}
243506f32e7eSjoerg  */
243606f32e7eSjoerg 
243706f32e7eSjoerg /**
243806f32e7eSjoerg  * @defgroup LLVMCCoreValueFunction Function values
243906f32e7eSjoerg  *
244006f32e7eSjoerg  * Functions in this group operate on LLVMValueRef instances that
244106f32e7eSjoerg  * correspond to llvm::Function instances.
244206f32e7eSjoerg  *
244306f32e7eSjoerg  * @see llvm::Function
244406f32e7eSjoerg  *
244506f32e7eSjoerg  * @{
244606f32e7eSjoerg  */
244706f32e7eSjoerg 
244806f32e7eSjoerg /**
244906f32e7eSjoerg  * Remove a function from its containing module and deletes it.
245006f32e7eSjoerg  *
245106f32e7eSjoerg  * @see llvm::Function::eraseFromParent()
245206f32e7eSjoerg  */
245306f32e7eSjoerg void LLVMDeleteFunction(LLVMValueRef Fn);
245406f32e7eSjoerg 
245506f32e7eSjoerg /**
245606f32e7eSjoerg  * Check whether the given function has a personality function.
245706f32e7eSjoerg  *
245806f32e7eSjoerg  * @see llvm::Function::hasPersonalityFn()
245906f32e7eSjoerg  */
246006f32e7eSjoerg LLVMBool LLVMHasPersonalityFn(LLVMValueRef Fn);
246106f32e7eSjoerg 
246206f32e7eSjoerg /**
246306f32e7eSjoerg  * Obtain the personality function attached to the function.
246406f32e7eSjoerg  *
246506f32e7eSjoerg  * @see llvm::Function::getPersonalityFn()
246606f32e7eSjoerg  */
246706f32e7eSjoerg LLVMValueRef LLVMGetPersonalityFn(LLVMValueRef Fn);
246806f32e7eSjoerg 
246906f32e7eSjoerg /**
247006f32e7eSjoerg  * Set the personality function attached to the function.
247106f32e7eSjoerg  *
247206f32e7eSjoerg  * @see llvm::Function::setPersonalityFn()
247306f32e7eSjoerg  */
247406f32e7eSjoerg void LLVMSetPersonalityFn(LLVMValueRef Fn, LLVMValueRef PersonalityFn);
247506f32e7eSjoerg 
247606f32e7eSjoerg /**
247706f32e7eSjoerg  * Obtain the intrinsic ID number which matches the given function name.
247806f32e7eSjoerg  *
247906f32e7eSjoerg  * @see llvm::Function::lookupIntrinsicID()
248006f32e7eSjoerg  */
248106f32e7eSjoerg unsigned LLVMLookupIntrinsicID(const char *Name, size_t NameLen);
248206f32e7eSjoerg 
248306f32e7eSjoerg /**
248406f32e7eSjoerg  * Obtain the ID number from a function instance.
248506f32e7eSjoerg  *
248606f32e7eSjoerg  * @see llvm::Function::getIntrinsicID()
248706f32e7eSjoerg  */
248806f32e7eSjoerg unsigned LLVMGetIntrinsicID(LLVMValueRef Fn);
248906f32e7eSjoerg 
249006f32e7eSjoerg /**
249106f32e7eSjoerg  * Create or insert the declaration of an intrinsic.  For overloaded intrinsics,
249206f32e7eSjoerg  * parameter types must be provided to uniquely identify an overload.
249306f32e7eSjoerg  *
249406f32e7eSjoerg  * @see llvm::Intrinsic::getDeclaration()
249506f32e7eSjoerg  */
249606f32e7eSjoerg LLVMValueRef LLVMGetIntrinsicDeclaration(LLVMModuleRef Mod,
249706f32e7eSjoerg                                          unsigned ID,
249806f32e7eSjoerg                                          LLVMTypeRef *ParamTypes,
249906f32e7eSjoerg                                          size_t ParamCount);
250006f32e7eSjoerg 
250106f32e7eSjoerg /**
250206f32e7eSjoerg  * Retrieves the type of an intrinsic.  For overloaded intrinsics, parameter
250306f32e7eSjoerg  * types must be provided to uniquely identify an overload.
250406f32e7eSjoerg  *
250506f32e7eSjoerg  * @see llvm::Intrinsic::getType()
250606f32e7eSjoerg  */
250706f32e7eSjoerg LLVMTypeRef LLVMIntrinsicGetType(LLVMContextRef Ctx, unsigned ID,
250806f32e7eSjoerg                                  LLVMTypeRef *ParamTypes, size_t ParamCount);
250906f32e7eSjoerg 
251006f32e7eSjoerg /**
251106f32e7eSjoerg  * Retrieves the name of an intrinsic.
251206f32e7eSjoerg  *
251306f32e7eSjoerg  * @see llvm::Intrinsic::getName()
251406f32e7eSjoerg  */
251506f32e7eSjoerg const char *LLVMIntrinsicGetName(unsigned ID, size_t *NameLength);
251606f32e7eSjoerg 
251706f32e7eSjoerg /**
251806f32e7eSjoerg  * Copies the name of an overloaded intrinsic identified by a given list of
251906f32e7eSjoerg  * parameter types.
252006f32e7eSjoerg  *
252106f32e7eSjoerg  * Unlike LLVMIntrinsicGetName, the caller is responsible for freeing the
252206f32e7eSjoerg  * returned string.
252306f32e7eSjoerg  *
252406f32e7eSjoerg  * @see llvm::Intrinsic::getName()
252506f32e7eSjoerg  */
252606f32e7eSjoerg const char *LLVMIntrinsicCopyOverloadedName(unsigned ID,
252706f32e7eSjoerg                                             LLVMTypeRef *ParamTypes,
252806f32e7eSjoerg                                             size_t ParamCount,
252906f32e7eSjoerg                                             size_t *NameLength);
253006f32e7eSjoerg 
253106f32e7eSjoerg /**
253206f32e7eSjoerg  * Obtain if the intrinsic identified by the given ID is overloaded.
253306f32e7eSjoerg  *
253406f32e7eSjoerg  * @see llvm::Intrinsic::isOverloaded()
253506f32e7eSjoerg  */
253606f32e7eSjoerg LLVMBool LLVMIntrinsicIsOverloaded(unsigned ID);
253706f32e7eSjoerg 
253806f32e7eSjoerg /**
253906f32e7eSjoerg  * Obtain the calling function of a function.
254006f32e7eSjoerg  *
254106f32e7eSjoerg  * The returned value corresponds to the LLVMCallConv enumeration.
254206f32e7eSjoerg  *
254306f32e7eSjoerg  * @see llvm::Function::getCallingConv()
254406f32e7eSjoerg  */
254506f32e7eSjoerg unsigned LLVMGetFunctionCallConv(LLVMValueRef Fn);
254606f32e7eSjoerg 
254706f32e7eSjoerg /**
254806f32e7eSjoerg  * Set the calling convention of a function.
254906f32e7eSjoerg  *
255006f32e7eSjoerg  * @see llvm::Function::setCallingConv()
255106f32e7eSjoerg  *
255206f32e7eSjoerg  * @param Fn Function to operate on
255306f32e7eSjoerg  * @param CC LLVMCallConv to set calling convention to
255406f32e7eSjoerg  */
255506f32e7eSjoerg void LLVMSetFunctionCallConv(LLVMValueRef Fn, unsigned CC);
255606f32e7eSjoerg 
255706f32e7eSjoerg /**
255806f32e7eSjoerg  * Obtain the name of the garbage collector to use during code
255906f32e7eSjoerg  * generation.
256006f32e7eSjoerg  *
256106f32e7eSjoerg  * @see llvm::Function::getGC()
256206f32e7eSjoerg  */
256306f32e7eSjoerg const char *LLVMGetGC(LLVMValueRef Fn);
256406f32e7eSjoerg 
256506f32e7eSjoerg /**
256606f32e7eSjoerg  * Define the garbage collector to use during code generation.
256706f32e7eSjoerg  *
256806f32e7eSjoerg  * @see llvm::Function::setGC()
256906f32e7eSjoerg  */
257006f32e7eSjoerg void LLVMSetGC(LLVMValueRef Fn, const char *Name);
257106f32e7eSjoerg 
257206f32e7eSjoerg /**
257306f32e7eSjoerg  * Add an attribute to a function.
257406f32e7eSjoerg  *
257506f32e7eSjoerg  * @see llvm::Function::addAttribute()
257606f32e7eSjoerg  */
257706f32e7eSjoerg void LLVMAddAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx,
257806f32e7eSjoerg                              LLVMAttributeRef A);
257906f32e7eSjoerg unsigned LLVMGetAttributeCountAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx);
258006f32e7eSjoerg void LLVMGetAttributesAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx,
258106f32e7eSjoerg                               LLVMAttributeRef *Attrs);
258206f32e7eSjoerg LLVMAttributeRef LLVMGetEnumAttributeAtIndex(LLVMValueRef F,
258306f32e7eSjoerg                                              LLVMAttributeIndex Idx,
258406f32e7eSjoerg                                              unsigned KindID);
258506f32e7eSjoerg LLVMAttributeRef LLVMGetStringAttributeAtIndex(LLVMValueRef F,
258606f32e7eSjoerg                                                LLVMAttributeIndex Idx,
258706f32e7eSjoerg                                                const char *K, unsigned KLen);
258806f32e7eSjoerg void LLVMRemoveEnumAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx,
258906f32e7eSjoerg                                     unsigned KindID);
259006f32e7eSjoerg void LLVMRemoveStringAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx,
259106f32e7eSjoerg                                       const char *K, unsigned KLen);
259206f32e7eSjoerg 
259306f32e7eSjoerg /**
259406f32e7eSjoerg  * Add a target-dependent attribute to a function
259506f32e7eSjoerg  * @see llvm::AttrBuilder::addAttribute()
259606f32e7eSjoerg  */
259706f32e7eSjoerg void LLVMAddTargetDependentFunctionAttr(LLVMValueRef Fn, const char *A,
259806f32e7eSjoerg                                         const char *V);
259906f32e7eSjoerg 
260006f32e7eSjoerg /**
260106f32e7eSjoerg  * @defgroup LLVMCCoreValueFunctionParameters Function Parameters
260206f32e7eSjoerg  *
260306f32e7eSjoerg  * Functions in this group relate to arguments/parameters on functions.
260406f32e7eSjoerg  *
260506f32e7eSjoerg  * Functions in this group expect LLVMValueRef instances that correspond
260606f32e7eSjoerg  * to llvm::Function instances.
260706f32e7eSjoerg  *
260806f32e7eSjoerg  * @{
260906f32e7eSjoerg  */
261006f32e7eSjoerg 
261106f32e7eSjoerg /**
261206f32e7eSjoerg  * Obtain the number of parameters in a function.
261306f32e7eSjoerg  *
261406f32e7eSjoerg  * @see llvm::Function::arg_size()
261506f32e7eSjoerg  */
261606f32e7eSjoerg unsigned LLVMCountParams(LLVMValueRef Fn);
261706f32e7eSjoerg 
261806f32e7eSjoerg /**
261906f32e7eSjoerg  * Obtain the parameters in a function.
262006f32e7eSjoerg  *
262106f32e7eSjoerg  * The takes a pointer to a pre-allocated array of LLVMValueRef that is
262206f32e7eSjoerg  * at least LLVMCountParams() long. This array will be filled with
262306f32e7eSjoerg  * LLVMValueRef instances which correspond to the parameters the
262406f32e7eSjoerg  * function receives. Each LLVMValueRef corresponds to a llvm::Argument
262506f32e7eSjoerg  * instance.
262606f32e7eSjoerg  *
262706f32e7eSjoerg  * @see llvm::Function::arg_begin()
262806f32e7eSjoerg  */
262906f32e7eSjoerg void LLVMGetParams(LLVMValueRef Fn, LLVMValueRef *Params);
263006f32e7eSjoerg 
263106f32e7eSjoerg /**
263206f32e7eSjoerg  * Obtain the parameter at the specified index.
263306f32e7eSjoerg  *
263406f32e7eSjoerg  * Parameters are indexed from 0.
263506f32e7eSjoerg  *
263606f32e7eSjoerg  * @see llvm::Function::arg_begin()
263706f32e7eSjoerg  */
263806f32e7eSjoerg LLVMValueRef LLVMGetParam(LLVMValueRef Fn, unsigned Index);
263906f32e7eSjoerg 
264006f32e7eSjoerg /**
264106f32e7eSjoerg  * Obtain the function to which this argument belongs.
264206f32e7eSjoerg  *
264306f32e7eSjoerg  * Unlike other functions in this group, this one takes an LLVMValueRef
264406f32e7eSjoerg  * that corresponds to a llvm::Attribute.
264506f32e7eSjoerg  *
264606f32e7eSjoerg  * The returned LLVMValueRef is the llvm::Function to which this
264706f32e7eSjoerg  * argument belongs.
264806f32e7eSjoerg  */
264906f32e7eSjoerg LLVMValueRef LLVMGetParamParent(LLVMValueRef Inst);
265006f32e7eSjoerg 
265106f32e7eSjoerg /**
265206f32e7eSjoerg  * Obtain the first parameter to a function.
265306f32e7eSjoerg  *
265406f32e7eSjoerg  * @see llvm::Function::arg_begin()
265506f32e7eSjoerg  */
265606f32e7eSjoerg LLVMValueRef LLVMGetFirstParam(LLVMValueRef Fn);
265706f32e7eSjoerg 
265806f32e7eSjoerg /**
265906f32e7eSjoerg  * Obtain the last parameter to a function.
266006f32e7eSjoerg  *
266106f32e7eSjoerg  * @see llvm::Function::arg_end()
266206f32e7eSjoerg  */
266306f32e7eSjoerg LLVMValueRef LLVMGetLastParam(LLVMValueRef Fn);
266406f32e7eSjoerg 
266506f32e7eSjoerg /**
266606f32e7eSjoerg  * Obtain the next parameter to a function.
266706f32e7eSjoerg  *
266806f32e7eSjoerg  * This takes an LLVMValueRef obtained from LLVMGetFirstParam() (which is
266906f32e7eSjoerg  * actually a wrapped iterator) and obtains the next parameter from the
267006f32e7eSjoerg  * underlying iterator.
267106f32e7eSjoerg  */
267206f32e7eSjoerg LLVMValueRef LLVMGetNextParam(LLVMValueRef Arg);
267306f32e7eSjoerg 
267406f32e7eSjoerg /**
267506f32e7eSjoerg  * Obtain the previous parameter to a function.
267606f32e7eSjoerg  *
267706f32e7eSjoerg  * This is the opposite of LLVMGetNextParam().
267806f32e7eSjoerg  */
267906f32e7eSjoerg LLVMValueRef LLVMGetPreviousParam(LLVMValueRef Arg);
268006f32e7eSjoerg 
268106f32e7eSjoerg /**
268206f32e7eSjoerg  * Set the alignment for a function parameter.
268306f32e7eSjoerg  *
268406f32e7eSjoerg  * @see llvm::Argument::addAttr()
268506f32e7eSjoerg  * @see llvm::AttrBuilder::addAlignmentAttr()
268606f32e7eSjoerg  */
268706f32e7eSjoerg void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned Align);
268806f32e7eSjoerg 
268906f32e7eSjoerg /**
269006f32e7eSjoerg  * @}
269106f32e7eSjoerg  */
269206f32e7eSjoerg 
269306f32e7eSjoerg /**
269406f32e7eSjoerg  * @defgroup LLVMCCoreValueGlobalIFunc IFuncs
269506f32e7eSjoerg  *
269606f32e7eSjoerg  * Functions in this group relate to indirect functions.
269706f32e7eSjoerg  *
269806f32e7eSjoerg  * Functions in this group expect LLVMValueRef instances that correspond
269906f32e7eSjoerg  * to llvm::GlobalIFunc instances.
270006f32e7eSjoerg  *
270106f32e7eSjoerg  * @{
270206f32e7eSjoerg  */
270306f32e7eSjoerg 
270406f32e7eSjoerg /**
270506f32e7eSjoerg  * Add a global indirect function to a module under a specified name.
270606f32e7eSjoerg  *
270706f32e7eSjoerg  * @see llvm::GlobalIFunc::create()
270806f32e7eSjoerg  */
270906f32e7eSjoerg LLVMValueRef LLVMAddGlobalIFunc(LLVMModuleRef M,
271006f32e7eSjoerg                                 const char *Name, size_t NameLen,
271106f32e7eSjoerg                                 LLVMTypeRef Ty, unsigned AddrSpace,
271206f32e7eSjoerg                                 LLVMValueRef Resolver);
271306f32e7eSjoerg 
271406f32e7eSjoerg /**
271506f32e7eSjoerg  * Obtain a GlobalIFunc value from a Module by its name.
271606f32e7eSjoerg  *
271706f32e7eSjoerg  * The returned value corresponds to a llvm::GlobalIFunc value.
271806f32e7eSjoerg  *
271906f32e7eSjoerg  * @see llvm::Module::getNamedIFunc()
272006f32e7eSjoerg  */
272106f32e7eSjoerg LLVMValueRef LLVMGetNamedGlobalIFunc(LLVMModuleRef M,
272206f32e7eSjoerg                                      const char *Name, size_t NameLen);
272306f32e7eSjoerg 
272406f32e7eSjoerg /**
272506f32e7eSjoerg  * Obtain an iterator to the first GlobalIFunc in a Module.
272606f32e7eSjoerg  *
272706f32e7eSjoerg  * @see llvm::Module::ifunc_begin()
272806f32e7eSjoerg  */
272906f32e7eSjoerg LLVMValueRef LLVMGetFirstGlobalIFunc(LLVMModuleRef M);
273006f32e7eSjoerg 
273106f32e7eSjoerg /**
273206f32e7eSjoerg  * Obtain an iterator to the last GlobalIFunc in a Module.
273306f32e7eSjoerg  *
273406f32e7eSjoerg  * @see llvm::Module::ifunc_end()
273506f32e7eSjoerg  */
273606f32e7eSjoerg LLVMValueRef LLVMGetLastGlobalIFunc(LLVMModuleRef M);
273706f32e7eSjoerg 
273806f32e7eSjoerg /**
273906f32e7eSjoerg  * Advance a GlobalIFunc iterator to the next GlobalIFunc.
274006f32e7eSjoerg  *
274106f32e7eSjoerg  * Returns NULL if the iterator was already at the end and there are no more
274206f32e7eSjoerg  * global aliases.
274306f32e7eSjoerg  */
274406f32e7eSjoerg LLVMValueRef LLVMGetNextGlobalIFunc(LLVMValueRef IFunc);
274506f32e7eSjoerg 
274606f32e7eSjoerg /**
274706f32e7eSjoerg  * Decrement a GlobalIFunc iterator to the previous GlobalIFunc.
274806f32e7eSjoerg  *
274906f32e7eSjoerg  * Returns NULL if the iterator was already at the beginning and there are
275006f32e7eSjoerg  * no previous global aliases.
275106f32e7eSjoerg  */
275206f32e7eSjoerg LLVMValueRef LLVMGetPreviousGlobalIFunc(LLVMValueRef IFunc);
275306f32e7eSjoerg 
275406f32e7eSjoerg /**
275506f32e7eSjoerg  * Retrieves the resolver function associated with this indirect function, or
275606f32e7eSjoerg  * NULL if it doesn't not exist.
275706f32e7eSjoerg  *
275806f32e7eSjoerg  * @see llvm::GlobalIFunc::getResolver()
275906f32e7eSjoerg  */
276006f32e7eSjoerg LLVMValueRef LLVMGetGlobalIFuncResolver(LLVMValueRef IFunc);
276106f32e7eSjoerg 
276206f32e7eSjoerg /**
276306f32e7eSjoerg  * Sets the resolver function associated with this indirect function.
276406f32e7eSjoerg  *
276506f32e7eSjoerg  * @see llvm::GlobalIFunc::setResolver()
276606f32e7eSjoerg  */
276706f32e7eSjoerg void LLVMSetGlobalIFuncResolver(LLVMValueRef IFunc, LLVMValueRef Resolver);
276806f32e7eSjoerg 
276906f32e7eSjoerg /**
277006f32e7eSjoerg  * Remove a global indirect function from its parent module and delete it.
277106f32e7eSjoerg  *
277206f32e7eSjoerg  * @see llvm::GlobalIFunc::eraseFromParent()
277306f32e7eSjoerg  */
277406f32e7eSjoerg void LLVMEraseGlobalIFunc(LLVMValueRef IFunc);
277506f32e7eSjoerg 
277606f32e7eSjoerg /**
277706f32e7eSjoerg  * Remove a global indirect function from its parent module.
277806f32e7eSjoerg  *
277906f32e7eSjoerg  * This unlinks the global indirect function from its containing module but
278006f32e7eSjoerg  * keeps it alive.
278106f32e7eSjoerg  *
278206f32e7eSjoerg  * @see llvm::GlobalIFunc::removeFromParent()
278306f32e7eSjoerg  */
278406f32e7eSjoerg void LLVMRemoveGlobalIFunc(LLVMValueRef IFunc);
278506f32e7eSjoerg 
278606f32e7eSjoerg /**
278706f32e7eSjoerg  * @}
278806f32e7eSjoerg  */
278906f32e7eSjoerg 
279006f32e7eSjoerg /**
279106f32e7eSjoerg  * @}
279206f32e7eSjoerg  */
279306f32e7eSjoerg 
279406f32e7eSjoerg /**
279506f32e7eSjoerg  * @}
279606f32e7eSjoerg  */
279706f32e7eSjoerg 
279806f32e7eSjoerg /**
279906f32e7eSjoerg  * @}
280006f32e7eSjoerg  */
280106f32e7eSjoerg 
280206f32e7eSjoerg /**
280306f32e7eSjoerg  * @defgroup LLVMCCoreValueMetadata Metadata
280406f32e7eSjoerg  *
280506f32e7eSjoerg  * @{
280606f32e7eSjoerg  */
280706f32e7eSjoerg 
280806f32e7eSjoerg /**
280906f32e7eSjoerg  * Create an MDString value from a given string value.
281006f32e7eSjoerg  *
281106f32e7eSjoerg  * The MDString value does not take ownership of the given string, it remains
281206f32e7eSjoerg  * the responsibility of the caller to free it.
281306f32e7eSjoerg  *
281406f32e7eSjoerg  * @see llvm::MDString::get()
281506f32e7eSjoerg  */
281606f32e7eSjoerg LLVMMetadataRef LLVMMDStringInContext2(LLVMContextRef C, const char *Str,
281706f32e7eSjoerg                                        size_t SLen);
281806f32e7eSjoerg 
281906f32e7eSjoerg /**
282006f32e7eSjoerg  * Create an MDNode value with the given array of operands.
282106f32e7eSjoerg  *
282206f32e7eSjoerg  * @see llvm::MDNode::get()
282306f32e7eSjoerg  */
282406f32e7eSjoerg LLVMMetadataRef LLVMMDNodeInContext2(LLVMContextRef C, LLVMMetadataRef *MDs,
282506f32e7eSjoerg                                      size_t Count);
282606f32e7eSjoerg 
282706f32e7eSjoerg /**
282806f32e7eSjoerg  * Obtain a Metadata as a Value.
282906f32e7eSjoerg  */
283006f32e7eSjoerg LLVMValueRef LLVMMetadataAsValue(LLVMContextRef C, LLVMMetadataRef MD);
283106f32e7eSjoerg 
283206f32e7eSjoerg /**
283306f32e7eSjoerg  * Obtain a Value as a Metadata.
283406f32e7eSjoerg  */
283506f32e7eSjoerg LLVMMetadataRef LLVMValueAsMetadata(LLVMValueRef Val);
283606f32e7eSjoerg 
283706f32e7eSjoerg /**
283806f32e7eSjoerg  * Obtain the underlying string from a MDString value.
283906f32e7eSjoerg  *
284006f32e7eSjoerg  * @param V Instance to obtain string from.
284106f32e7eSjoerg  * @param Length Memory address which will hold length of returned string.
284206f32e7eSjoerg  * @return String data in MDString.
284306f32e7eSjoerg  */
284406f32e7eSjoerg const char *LLVMGetMDString(LLVMValueRef V, unsigned *Length);
284506f32e7eSjoerg 
284606f32e7eSjoerg /**
284706f32e7eSjoerg  * Obtain the number of operands from an MDNode value.
284806f32e7eSjoerg  *
284906f32e7eSjoerg  * @param V MDNode to get number of operands from.
285006f32e7eSjoerg  * @return Number of operands of the MDNode.
285106f32e7eSjoerg  */
285206f32e7eSjoerg unsigned LLVMGetMDNodeNumOperands(LLVMValueRef V);
285306f32e7eSjoerg 
285406f32e7eSjoerg /**
285506f32e7eSjoerg  * Obtain the given MDNode's operands.
285606f32e7eSjoerg  *
285706f32e7eSjoerg  * The passed LLVMValueRef pointer should point to enough memory to hold all of
285806f32e7eSjoerg  * the operands of the given MDNode (see LLVMGetMDNodeNumOperands) as
285906f32e7eSjoerg  * LLVMValueRefs. This memory will be populated with the LLVMValueRefs of the
286006f32e7eSjoerg  * MDNode's operands.
286106f32e7eSjoerg  *
286206f32e7eSjoerg  * @param V MDNode to get the operands from.
286306f32e7eSjoerg  * @param Dest Destination array for operands.
286406f32e7eSjoerg  */
286506f32e7eSjoerg void LLVMGetMDNodeOperands(LLVMValueRef V, LLVMValueRef *Dest);
286606f32e7eSjoerg 
286706f32e7eSjoerg /** Deprecated: Use LLVMMDStringInContext2 instead. */
286806f32e7eSjoerg LLVMValueRef LLVMMDStringInContext(LLVMContextRef C, const char *Str,
286906f32e7eSjoerg                                    unsigned SLen);
287006f32e7eSjoerg /** Deprecated: Use LLVMMDStringInContext2 instead. */
287106f32e7eSjoerg LLVMValueRef LLVMMDString(const char *Str, unsigned SLen);
287206f32e7eSjoerg /** Deprecated: Use LLVMMDNodeInContext2 instead. */
287306f32e7eSjoerg LLVMValueRef LLVMMDNodeInContext(LLVMContextRef C, LLVMValueRef *Vals,
287406f32e7eSjoerg                                  unsigned Count);
287506f32e7eSjoerg /** Deprecated: Use LLVMMDNodeInContext2 instead. */
287606f32e7eSjoerg LLVMValueRef LLVMMDNode(LLVMValueRef *Vals, unsigned Count);
287706f32e7eSjoerg 
287806f32e7eSjoerg /**
287906f32e7eSjoerg  * @}
288006f32e7eSjoerg  */
288106f32e7eSjoerg 
288206f32e7eSjoerg /**
288306f32e7eSjoerg  * @defgroup LLVMCCoreValueBasicBlock Basic Block
288406f32e7eSjoerg  *
288506f32e7eSjoerg  * A basic block represents a single entry single exit section of code.
288606f32e7eSjoerg  * Basic blocks contain a list of instructions which form the body of
288706f32e7eSjoerg  * the block.
288806f32e7eSjoerg  *
288906f32e7eSjoerg  * Basic blocks belong to functions. They have the type of label.
289006f32e7eSjoerg  *
289106f32e7eSjoerg  * Basic blocks are themselves values. However, the C API models them as
289206f32e7eSjoerg  * LLVMBasicBlockRef.
289306f32e7eSjoerg  *
289406f32e7eSjoerg  * @see llvm::BasicBlock
289506f32e7eSjoerg  *
289606f32e7eSjoerg  * @{
289706f32e7eSjoerg  */
289806f32e7eSjoerg 
289906f32e7eSjoerg /**
290006f32e7eSjoerg  * Convert a basic block instance to a value type.
290106f32e7eSjoerg  */
290206f32e7eSjoerg LLVMValueRef LLVMBasicBlockAsValue(LLVMBasicBlockRef BB);
290306f32e7eSjoerg 
290406f32e7eSjoerg /**
290506f32e7eSjoerg  * Determine whether an LLVMValueRef is itself a basic block.
290606f32e7eSjoerg  */
290706f32e7eSjoerg LLVMBool LLVMValueIsBasicBlock(LLVMValueRef Val);
290806f32e7eSjoerg 
290906f32e7eSjoerg /**
291006f32e7eSjoerg  * Convert an LLVMValueRef to an LLVMBasicBlockRef instance.
291106f32e7eSjoerg  */
291206f32e7eSjoerg LLVMBasicBlockRef LLVMValueAsBasicBlock(LLVMValueRef Val);
291306f32e7eSjoerg 
291406f32e7eSjoerg /**
291506f32e7eSjoerg  * Obtain the string name of a basic block.
291606f32e7eSjoerg  */
291706f32e7eSjoerg const char *LLVMGetBasicBlockName(LLVMBasicBlockRef BB);
291806f32e7eSjoerg 
291906f32e7eSjoerg /**
292006f32e7eSjoerg  * Obtain the function to which a basic block belongs.
292106f32e7eSjoerg  *
292206f32e7eSjoerg  * @see llvm::BasicBlock::getParent()
292306f32e7eSjoerg  */
292406f32e7eSjoerg LLVMValueRef LLVMGetBasicBlockParent(LLVMBasicBlockRef BB);
292506f32e7eSjoerg 
292606f32e7eSjoerg /**
292706f32e7eSjoerg  * Obtain the terminator instruction for a basic block.
292806f32e7eSjoerg  *
292906f32e7eSjoerg  * If the basic block does not have a terminator (it is not well-formed
293006f32e7eSjoerg  * if it doesn't), then NULL is returned.
293106f32e7eSjoerg  *
293206f32e7eSjoerg  * The returned LLVMValueRef corresponds to an llvm::Instruction.
293306f32e7eSjoerg  *
293406f32e7eSjoerg  * @see llvm::BasicBlock::getTerminator()
293506f32e7eSjoerg  */
293606f32e7eSjoerg LLVMValueRef LLVMGetBasicBlockTerminator(LLVMBasicBlockRef BB);
293706f32e7eSjoerg 
293806f32e7eSjoerg /**
293906f32e7eSjoerg  * Obtain the number of basic blocks in a function.
294006f32e7eSjoerg  *
294106f32e7eSjoerg  * @param Fn Function value to operate on.
294206f32e7eSjoerg  */
294306f32e7eSjoerg unsigned LLVMCountBasicBlocks(LLVMValueRef Fn);
294406f32e7eSjoerg 
294506f32e7eSjoerg /**
294606f32e7eSjoerg  * Obtain all of the basic blocks in a function.
294706f32e7eSjoerg  *
294806f32e7eSjoerg  * This operates on a function value. The BasicBlocks parameter is a
294906f32e7eSjoerg  * pointer to a pre-allocated array of LLVMBasicBlockRef of at least
295006f32e7eSjoerg  * LLVMCountBasicBlocks() in length. This array is populated with
295106f32e7eSjoerg  * LLVMBasicBlockRef instances.
295206f32e7eSjoerg  */
295306f32e7eSjoerg void LLVMGetBasicBlocks(LLVMValueRef Fn, LLVMBasicBlockRef *BasicBlocks);
295406f32e7eSjoerg 
295506f32e7eSjoerg /**
295606f32e7eSjoerg  * Obtain the first basic block in a function.
295706f32e7eSjoerg  *
295806f32e7eSjoerg  * The returned basic block can be used as an iterator. You will likely
295906f32e7eSjoerg  * eventually call into LLVMGetNextBasicBlock() with it.
296006f32e7eSjoerg  *
296106f32e7eSjoerg  * @see llvm::Function::begin()
296206f32e7eSjoerg  */
296306f32e7eSjoerg LLVMBasicBlockRef LLVMGetFirstBasicBlock(LLVMValueRef Fn);
296406f32e7eSjoerg 
296506f32e7eSjoerg /**
296606f32e7eSjoerg  * Obtain the last basic block in a function.
296706f32e7eSjoerg  *
296806f32e7eSjoerg  * @see llvm::Function::end()
296906f32e7eSjoerg  */
297006f32e7eSjoerg LLVMBasicBlockRef LLVMGetLastBasicBlock(LLVMValueRef Fn);
297106f32e7eSjoerg 
297206f32e7eSjoerg /**
297306f32e7eSjoerg  * Advance a basic block iterator.
297406f32e7eSjoerg  */
297506f32e7eSjoerg LLVMBasicBlockRef LLVMGetNextBasicBlock(LLVMBasicBlockRef BB);
297606f32e7eSjoerg 
297706f32e7eSjoerg /**
297806f32e7eSjoerg  * Go backwards in a basic block iterator.
297906f32e7eSjoerg  */
298006f32e7eSjoerg LLVMBasicBlockRef LLVMGetPreviousBasicBlock(LLVMBasicBlockRef BB);
298106f32e7eSjoerg 
298206f32e7eSjoerg /**
298306f32e7eSjoerg  * Obtain the basic block that corresponds to the entry point of a
298406f32e7eSjoerg  * function.
298506f32e7eSjoerg  *
298606f32e7eSjoerg  * @see llvm::Function::getEntryBlock()
298706f32e7eSjoerg  */
298806f32e7eSjoerg LLVMBasicBlockRef LLVMGetEntryBasicBlock(LLVMValueRef Fn);
298906f32e7eSjoerg 
299006f32e7eSjoerg /**
299106f32e7eSjoerg  * Insert the given basic block after the insertion point of the given builder.
299206f32e7eSjoerg  *
299306f32e7eSjoerg  * The insertion point must be valid.
299406f32e7eSjoerg  *
299506f32e7eSjoerg  * @see llvm::Function::BasicBlockListType::insertAfter()
299606f32e7eSjoerg  */
299706f32e7eSjoerg void LLVMInsertExistingBasicBlockAfterInsertBlock(LLVMBuilderRef Builder,
299806f32e7eSjoerg                                                   LLVMBasicBlockRef BB);
299906f32e7eSjoerg 
300006f32e7eSjoerg /**
300106f32e7eSjoerg  * Append the given basic block to the basic block list of the given function.
300206f32e7eSjoerg  *
300306f32e7eSjoerg  * @see llvm::Function::BasicBlockListType::push_back()
300406f32e7eSjoerg  */
300506f32e7eSjoerg void LLVMAppendExistingBasicBlock(LLVMValueRef Fn,
300606f32e7eSjoerg                                   LLVMBasicBlockRef BB);
300706f32e7eSjoerg 
300806f32e7eSjoerg /**
300906f32e7eSjoerg  * Create a new basic block without inserting it into a function.
301006f32e7eSjoerg  *
301106f32e7eSjoerg  * @see llvm::BasicBlock::Create()
301206f32e7eSjoerg  */
301306f32e7eSjoerg LLVMBasicBlockRef LLVMCreateBasicBlockInContext(LLVMContextRef C,
301406f32e7eSjoerg                                                 const char *Name);
301506f32e7eSjoerg 
301606f32e7eSjoerg /**
301706f32e7eSjoerg  * Append a basic block to the end of a function.
301806f32e7eSjoerg  *
301906f32e7eSjoerg  * @see llvm::BasicBlock::Create()
302006f32e7eSjoerg  */
302106f32e7eSjoerg LLVMBasicBlockRef LLVMAppendBasicBlockInContext(LLVMContextRef C,
302206f32e7eSjoerg                                                 LLVMValueRef Fn,
302306f32e7eSjoerg                                                 const char *Name);
302406f32e7eSjoerg 
302506f32e7eSjoerg /**
302606f32e7eSjoerg  * Append a basic block to the end of a function using the global
302706f32e7eSjoerg  * context.
302806f32e7eSjoerg  *
302906f32e7eSjoerg  * @see llvm::BasicBlock::Create()
303006f32e7eSjoerg  */
303106f32e7eSjoerg LLVMBasicBlockRef LLVMAppendBasicBlock(LLVMValueRef Fn, const char *Name);
303206f32e7eSjoerg 
303306f32e7eSjoerg /**
303406f32e7eSjoerg  * Insert a basic block in a function before another basic block.
303506f32e7eSjoerg  *
303606f32e7eSjoerg  * The function to add to is determined by the function of the
303706f32e7eSjoerg  * passed basic block.
303806f32e7eSjoerg  *
303906f32e7eSjoerg  * @see llvm::BasicBlock::Create()
304006f32e7eSjoerg  */
304106f32e7eSjoerg LLVMBasicBlockRef LLVMInsertBasicBlockInContext(LLVMContextRef C,
304206f32e7eSjoerg                                                 LLVMBasicBlockRef BB,
304306f32e7eSjoerg                                                 const char *Name);
304406f32e7eSjoerg 
304506f32e7eSjoerg /**
304606f32e7eSjoerg  * Insert a basic block in a function using the global context.
304706f32e7eSjoerg  *
304806f32e7eSjoerg  * @see llvm::BasicBlock::Create()
304906f32e7eSjoerg  */
305006f32e7eSjoerg LLVMBasicBlockRef LLVMInsertBasicBlock(LLVMBasicBlockRef InsertBeforeBB,
305106f32e7eSjoerg                                        const char *Name);
305206f32e7eSjoerg 
305306f32e7eSjoerg /**
305406f32e7eSjoerg  * Remove a basic block from a function and delete it.
305506f32e7eSjoerg  *
305606f32e7eSjoerg  * This deletes the basic block from its containing function and deletes
305706f32e7eSjoerg  * the basic block itself.
305806f32e7eSjoerg  *
305906f32e7eSjoerg  * @see llvm::BasicBlock::eraseFromParent()
306006f32e7eSjoerg  */
306106f32e7eSjoerg void LLVMDeleteBasicBlock(LLVMBasicBlockRef BB);
306206f32e7eSjoerg 
306306f32e7eSjoerg /**
306406f32e7eSjoerg  * Remove a basic block from a function.
306506f32e7eSjoerg  *
306606f32e7eSjoerg  * This deletes the basic block from its containing function but keep
306706f32e7eSjoerg  * the basic block alive.
306806f32e7eSjoerg  *
306906f32e7eSjoerg  * @see llvm::BasicBlock::removeFromParent()
307006f32e7eSjoerg  */
307106f32e7eSjoerg void LLVMRemoveBasicBlockFromParent(LLVMBasicBlockRef BB);
307206f32e7eSjoerg 
307306f32e7eSjoerg /**
307406f32e7eSjoerg  * Move a basic block to before another one.
307506f32e7eSjoerg  *
307606f32e7eSjoerg  * @see llvm::BasicBlock::moveBefore()
307706f32e7eSjoerg  */
307806f32e7eSjoerg void LLVMMoveBasicBlockBefore(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos);
307906f32e7eSjoerg 
308006f32e7eSjoerg /**
308106f32e7eSjoerg  * Move a basic block to after another one.
308206f32e7eSjoerg  *
308306f32e7eSjoerg  * @see llvm::BasicBlock::moveAfter()
308406f32e7eSjoerg  */
308506f32e7eSjoerg void LLVMMoveBasicBlockAfter(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos);
308606f32e7eSjoerg 
308706f32e7eSjoerg /**
308806f32e7eSjoerg  * Obtain the first instruction in a basic block.
308906f32e7eSjoerg  *
309006f32e7eSjoerg  * The returned LLVMValueRef corresponds to a llvm::Instruction
309106f32e7eSjoerg  * instance.
309206f32e7eSjoerg  */
309306f32e7eSjoerg LLVMValueRef LLVMGetFirstInstruction(LLVMBasicBlockRef BB);
309406f32e7eSjoerg 
309506f32e7eSjoerg /**
309606f32e7eSjoerg  * Obtain the last instruction in a basic block.
309706f32e7eSjoerg  *
309806f32e7eSjoerg  * The returned LLVMValueRef corresponds to an LLVM:Instruction.
309906f32e7eSjoerg  */
310006f32e7eSjoerg LLVMValueRef LLVMGetLastInstruction(LLVMBasicBlockRef BB);
310106f32e7eSjoerg 
310206f32e7eSjoerg /**
310306f32e7eSjoerg  * @}
310406f32e7eSjoerg  */
310506f32e7eSjoerg 
310606f32e7eSjoerg /**
310706f32e7eSjoerg  * @defgroup LLVMCCoreValueInstruction Instructions
310806f32e7eSjoerg  *
310906f32e7eSjoerg  * Functions in this group relate to the inspection and manipulation of
311006f32e7eSjoerg  * individual instructions.
311106f32e7eSjoerg  *
311206f32e7eSjoerg  * In the C++ API, an instruction is modeled by llvm::Instruction. This
311306f32e7eSjoerg  * class has a large number of descendents. llvm::Instruction is a
311406f32e7eSjoerg  * llvm::Value and in the C API, instructions are modeled by
311506f32e7eSjoerg  * LLVMValueRef.
311606f32e7eSjoerg  *
311706f32e7eSjoerg  * This group also contains sub-groups which operate on specific
311806f32e7eSjoerg  * llvm::Instruction types, e.g. llvm::CallInst.
311906f32e7eSjoerg  *
312006f32e7eSjoerg  * @{
312106f32e7eSjoerg  */
312206f32e7eSjoerg 
312306f32e7eSjoerg /**
312406f32e7eSjoerg  * Determine whether an instruction has any metadata attached.
312506f32e7eSjoerg  */
312606f32e7eSjoerg int LLVMHasMetadata(LLVMValueRef Val);
312706f32e7eSjoerg 
312806f32e7eSjoerg /**
312906f32e7eSjoerg  * Return metadata associated with an instruction value.
313006f32e7eSjoerg  */
313106f32e7eSjoerg LLVMValueRef LLVMGetMetadata(LLVMValueRef Val, unsigned KindID);
313206f32e7eSjoerg 
313306f32e7eSjoerg /**
313406f32e7eSjoerg  * Set metadata associated with an instruction value.
313506f32e7eSjoerg  */
313606f32e7eSjoerg void LLVMSetMetadata(LLVMValueRef Val, unsigned KindID, LLVMValueRef Node);
313706f32e7eSjoerg 
313806f32e7eSjoerg /**
313906f32e7eSjoerg  * Returns the metadata associated with an instruction value, but filters out
314006f32e7eSjoerg  * all the debug locations.
314106f32e7eSjoerg  *
314206f32e7eSjoerg  * @see llvm::Instruction::getAllMetadataOtherThanDebugLoc()
314306f32e7eSjoerg  */
314406f32e7eSjoerg LLVMValueMetadataEntry *
314506f32e7eSjoerg LLVMInstructionGetAllMetadataOtherThanDebugLoc(LLVMValueRef Instr,
314606f32e7eSjoerg                                                size_t *NumEntries);
314706f32e7eSjoerg 
314806f32e7eSjoerg /**
314906f32e7eSjoerg  * Obtain the basic block to which an instruction belongs.
315006f32e7eSjoerg  *
315106f32e7eSjoerg  * @see llvm::Instruction::getParent()
315206f32e7eSjoerg  */
315306f32e7eSjoerg LLVMBasicBlockRef LLVMGetInstructionParent(LLVMValueRef Inst);
315406f32e7eSjoerg 
315506f32e7eSjoerg /**
315606f32e7eSjoerg  * Obtain the instruction that occurs after the one specified.
315706f32e7eSjoerg  *
315806f32e7eSjoerg  * The next instruction will be from the same basic block.
315906f32e7eSjoerg  *
316006f32e7eSjoerg  * If this is the last instruction in a basic block, NULL will be
316106f32e7eSjoerg  * returned.
316206f32e7eSjoerg  */
316306f32e7eSjoerg LLVMValueRef LLVMGetNextInstruction(LLVMValueRef Inst);
316406f32e7eSjoerg 
316506f32e7eSjoerg /**
316606f32e7eSjoerg  * Obtain the instruction that occurred before this one.
316706f32e7eSjoerg  *
316806f32e7eSjoerg  * If the instruction is the first instruction in a basic block, NULL
316906f32e7eSjoerg  * will be returned.
317006f32e7eSjoerg  */
317106f32e7eSjoerg LLVMValueRef LLVMGetPreviousInstruction(LLVMValueRef Inst);
317206f32e7eSjoerg 
317306f32e7eSjoerg /**
317406f32e7eSjoerg  * Remove and delete an instruction.
317506f32e7eSjoerg  *
317606f32e7eSjoerg  * The instruction specified is removed from its containing building
317706f32e7eSjoerg  * block but is kept alive.
317806f32e7eSjoerg  *
317906f32e7eSjoerg  * @see llvm::Instruction::removeFromParent()
318006f32e7eSjoerg  */
318106f32e7eSjoerg void LLVMInstructionRemoveFromParent(LLVMValueRef Inst);
318206f32e7eSjoerg 
318306f32e7eSjoerg /**
318406f32e7eSjoerg  * Remove and delete an instruction.
318506f32e7eSjoerg  *
318606f32e7eSjoerg  * The instruction specified is removed from its containing building
318706f32e7eSjoerg  * block and then deleted.
318806f32e7eSjoerg  *
318906f32e7eSjoerg  * @see llvm::Instruction::eraseFromParent()
319006f32e7eSjoerg  */
319106f32e7eSjoerg void LLVMInstructionEraseFromParent(LLVMValueRef Inst);
319206f32e7eSjoerg 
319306f32e7eSjoerg /**
319406f32e7eSjoerg  * Obtain the code opcode for an individual instruction.
319506f32e7eSjoerg  *
319606f32e7eSjoerg  * @see llvm::Instruction::getOpCode()
319706f32e7eSjoerg  */
319806f32e7eSjoerg LLVMOpcode LLVMGetInstructionOpcode(LLVMValueRef Inst);
319906f32e7eSjoerg 
320006f32e7eSjoerg /**
320106f32e7eSjoerg  * Obtain the predicate of an instruction.
320206f32e7eSjoerg  *
320306f32e7eSjoerg  * This is only valid for instructions that correspond to llvm::ICmpInst
320406f32e7eSjoerg  * or llvm::ConstantExpr whose opcode is llvm::Instruction::ICmp.
320506f32e7eSjoerg  *
320606f32e7eSjoerg  * @see llvm::ICmpInst::getPredicate()
320706f32e7eSjoerg  */
320806f32e7eSjoerg LLVMIntPredicate LLVMGetICmpPredicate(LLVMValueRef Inst);
320906f32e7eSjoerg 
321006f32e7eSjoerg /**
321106f32e7eSjoerg  * Obtain the float predicate of an instruction.
321206f32e7eSjoerg  *
321306f32e7eSjoerg  * This is only valid for instructions that correspond to llvm::FCmpInst
321406f32e7eSjoerg  * or llvm::ConstantExpr whose opcode is llvm::Instruction::FCmp.
321506f32e7eSjoerg  *
321606f32e7eSjoerg  * @see llvm::FCmpInst::getPredicate()
321706f32e7eSjoerg  */
321806f32e7eSjoerg LLVMRealPredicate LLVMGetFCmpPredicate(LLVMValueRef Inst);
321906f32e7eSjoerg 
322006f32e7eSjoerg /**
322106f32e7eSjoerg  * Create a copy of 'this' instruction that is identical in all ways
322206f32e7eSjoerg  * except the following:
322306f32e7eSjoerg  *   * The instruction has no parent
322406f32e7eSjoerg  *   * The instruction has no name
322506f32e7eSjoerg  *
322606f32e7eSjoerg  * @see llvm::Instruction::clone()
322706f32e7eSjoerg  */
322806f32e7eSjoerg LLVMValueRef LLVMInstructionClone(LLVMValueRef Inst);
322906f32e7eSjoerg 
323006f32e7eSjoerg /**
323106f32e7eSjoerg  * Determine whether an instruction is a terminator. This routine is named to
323206f32e7eSjoerg  * be compatible with historical functions that did this by querying the
323306f32e7eSjoerg  * underlying C++ type.
323406f32e7eSjoerg  *
323506f32e7eSjoerg  * @see llvm::Instruction::isTerminator()
323606f32e7eSjoerg  */
323706f32e7eSjoerg LLVMValueRef LLVMIsATerminatorInst(LLVMValueRef Inst);
323806f32e7eSjoerg 
323906f32e7eSjoerg /**
324006f32e7eSjoerg  * @defgroup LLVMCCoreValueInstructionCall Call Sites and Invocations
324106f32e7eSjoerg  *
324206f32e7eSjoerg  * Functions in this group apply to instructions that refer to call
324306f32e7eSjoerg  * sites and invocations. These correspond to C++ types in the
324406f32e7eSjoerg  * llvm::CallInst class tree.
324506f32e7eSjoerg  *
324606f32e7eSjoerg  * @{
324706f32e7eSjoerg  */
324806f32e7eSjoerg 
324906f32e7eSjoerg /**
325006f32e7eSjoerg  * Obtain the argument count for a call instruction.
325106f32e7eSjoerg  *
325206f32e7eSjoerg  * This expects an LLVMValueRef that corresponds to a llvm::CallInst,
325306f32e7eSjoerg  * llvm::InvokeInst, or llvm:FuncletPadInst.
325406f32e7eSjoerg  *
325506f32e7eSjoerg  * @see llvm::CallInst::getNumArgOperands()
325606f32e7eSjoerg  * @see llvm::InvokeInst::getNumArgOperands()
325706f32e7eSjoerg  * @see llvm::FuncletPadInst::getNumArgOperands()
325806f32e7eSjoerg  */
325906f32e7eSjoerg unsigned LLVMGetNumArgOperands(LLVMValueRef Instr);
326006f32e7eSjoerg 
326106f32e7eSjoerg /**
326206f32e7eSjoerg  * Set the calling convention for a call instruction.
326306f32e7eSjoerg  *
326406f32e7eSjoerg  * This expects an LLVMValueRef that corresponds to a llvm::CallInst or
326506f32e7eSjoerg  * llvm::InvokeInst.
326606f32e7eSjoerg  *
326706f32e7eSjoerg  * @see llvm::CallInst::setCallingConv()
326806f32e7eSjoerg  * @see llvm::InvokeInst::setCallingConv()
326906f32e7eSjoerg  */
327006f32e7eSjoerg void LLVMSetInstructionCallConv(LLVMValueRef Instr, unsigned CC);
327106f32e7eSjoerg 
327206f32e7eSjoerg /**
327306f32e7eSjoerg  * Obtain the calling convention for a call instruction.
327406f32e7eSjoerg  *
327506f32e7eSjoerg  * This is the opposite of LLVMSetInstructionCallConv(). Reads its
327606f32e7eSjoerg  * usage.
327706f32e7eSjoerg  *
327806f32e7eSjoerg  * @see LLVMSetInstructionCallConv()
327906f32e7eSjoerg  */
328006f32e7eSjoerg unsigned LLVMGetInstructionCallConv(LLVMValueRef Instr);
328106f32e7eSjoerg 
328206f32e7eSjoerg void LLVMSetInstrParamAlignment(LLVMValueRef Instr, unsigned index,
328306f32e7eSjoerg                                 unsigned Align);
328406f32e7eSjoerg 
328506f32e7eSjoerg void LLVMAddCallSiteAttribute(LLVMValueRef C, LLVMAttributeIndex Idx,
328606f32e7eSjoerg                               LLVMAttributeRef A);
328706f32e7eSjoerg unsigned LLVMGetCallSiteAttributeCount(LLVMValueRef C, LLVMAttributeIndex Idx);
328806f32e7eSjoerg void LLVMGetCallSiteAttributes(LLVMValueRef C, LLVMAttributeIndex Idx,
328906f32e7eSjoerg                                LLVMAttributeRef *Attrs);
329006f32e7eSjoerg LLVMAttributeRef LLVMGetCallSiteEnumAttribute(LLVMValueRef C,
329106f32e7eSjoerg                                               LLVMAttributeIndex Idx,
329206f32e7eSjoerg                                               unsigned KindID);
329306f32e7eSjoerg LLVMAttributeRef LLVMGetCallSiteStringAttribute(LLVMValueRef C,
329406f32e7eSjoerg                                                 LLVMAttributeIndex Idx,
329506f32e7eSjoerg                                                 const char *K, unsigned KLen);
329606f32e7eSjoerg void LLVMRemoveCallSiteEnumAttribute(LLVMValueRef C, LLVMAttributeIndex Idx,
329706f32e7eSjoerg                                      unsigned KindID);
329806f32e7eSjoerg void LLVMRemoveCallSiteStringAttribute(LLVMValueRef C, LLVMAttributeIndex Idx,
329906f32e7eSjoerg                                        const char *K, unsigned KLen);
330006f32e7eSjoerg 
330106f32e7eSjoerg /**
330206f32e7eSjoerg  * Obtain the function type called by this instruction.
330306f32e7eSjoerg  *
330406f32e7eSjoerg  * @see llvm::CallBase::getFunctionType()
330506f32e7eSjoerg  */
330606f32e7eSjoerg LLVMTypeRef LLVMGetCalledFunctionType(LLVMValueRef C);
330706f32e7eSjoerg 
330806f32e7eSjoerg /**
330906f32e7eSjoerg  * Obtain the pointer to the function invoked by this instruction.
331006f32e7eSjoerg  *
331106f32e7eSjoerg  * This expects an LLVMValueRef that corresponds to a llvm::CallInst or
331206f32e7eSjoerg  * llvm::InvokeInst.
331306f32e7eSjoerg  *
3314*da58b97aSjoerg  * @see llvm::CallInst::getCalledOperand()
3315*da58b97aSjoerg  * @see llvm::InvokeInst::getCalledOperand()
331606f32e7eSjoerg  */
331706f32e7eSjoerg LLVMValueRef LLVMGetCalledValue(LLVMValueRef Instr);
331806f32e7eSjoerg 
331906f32e7eSjoerg /**
332006f32e7eSjoerg  * Obtain whether a call instruction is a tail call.
332106f32e7eSjoerg  *
332206f32e7eSjoerg  * This only works on llvm::CallInst instructions.
332306f32e7eSjoerg  *
332406f32e7eSjoerg  * @see llvm::CallInst::isTailCall()
332506f32e7eSjoerg  */
332606f32e7eSjoerg LLVMBool LLVMIsTailCall(LLVMValueRef CallInst);
332706f32e7eSjoerg 
332806f32e7eSjoerg /**
332906f32e7eSjoerg  * Set whether a call instruction is a tail call.
333006f32e7eSjoerg  *
333106f32e7eSjoerg  * This only works on llvm::CallInst instructions.
333206f32e7eSjoerg  *
333306f32e7eSjoerg  * @see llvm::CallInst::setTailCall()
333406f32e7eSjoerg  */
333506f32e7eSjoerg void LLVMSetTailCall(LLVMValueRef CallInst, LLVMBool IsTailCall);
333606f32e7eSjoerg 
333706f32e7eSjoerg /**
333806f32e7eSjoerg  * Return the normal destination basic block.
333906f32e7eSjoerg  *
334006f32e7eSjoerg  * This only works on llvm::InvokeInst instructions.
334106f32e7eSjoerg  *
334206f32e7eSjoerg  * @see llvm::InvokeInst::getNormalDest()
334306f32e7eSjoerg  */
334406f32e7eSjoerg LLVMBasicBlockRef LLVMGetNormalDest(LLVMValueRef InvokeInst);
334506f32e7eSjoerg 
334606f32e7eSjoerg /**
334706f32e7eSjoerg  * Return the unwind destination basic block.
334806f32e7eSjoerg  *
334906f32e7eSjoerg  * Works on llvm::InvokeInst, llvm::CleanupReturnInst, and
335006f32e7eSjoerg  * llvm::CatchSwitchInst instructions.
335106f32e7eSjoerg  *
335206f32e7eSjoerg  * @see llvm::InvokeInst::getUnwindDest()
335306f32e7eSjoerg  * @see llvm::CleanupReturnInst::getUnwindDest()
335406f32e7eSjoerg  * @see llvm::CatchSwitchInst::getUnwindDest()
335506f32e7eSjoerg  */
335606f32e7eSjoerg LLVMBasicBlockRef LLVMGetUnwindDest(LLVMValueRef InvokeInst);
335706f32e7eSjoerg 
335806f32e7eSjoerg /**
335906f32e7eSjoerg  * Set the normal destination basic block.
336006f32e7eSjoerg  *
336106f32e7eSjoerg  * This only works on llvm::InvokeInst instructions.
336206f32e7eSjoerg  *
336306f32e7eSjoerg  * @see llvm::InvokeInst::setNormalDest()
336406f32e7eSjoerg  */
336506f32e7eSjoerg void LLVMSetNormalDest(LLVMValueRef InvokeInst, LLVMBasicBlockRef B);
336606f32e7eSjoerg 
336706f32e7eSjoerg /**
336806f32e7eSjoerg  * Set the unwind destination basic block.
336906f32e7eSjoerg  *
337006f32e7eSjoerg  * Works on llvm::InvokeInst, llvm::CleanupReturnInst, and
337106f32e7eSjoerg  * llvm::CatchSwitchInst instructions.
337206f32e7eSjoerg  *
337306f32e7eSjoerg  * @see llvm::InvokeInst::setUnwindDest()
337406f32e7eSjoerg  * @see llvm::CleanupReturnInst::setUnwindDest()
337506f32e7eSjoerg  * @see llvm::CatchSwitchInst::setUnwindDest()
337606f32e7eSjoerg  */
337706f32e7eSjoerg void LLVMSetUnwindDest(LLVMValueRef InvokeInst, LLVMBasicBlockRef B);
337806f32e7eSjoerg 
337906f32e7eSjoerg /**
338006f32e7eSjoerg  * @}
338106f32e7eSjoerg  */
338206f32e7eSjoerg 
338306f32e7eSjoerg /**
338406f32e7eSjoerg  * @defgroup LLVMCCoreValueInstructionTerminator Terminators
338506f32e7eSjoerg  *
338606f32e7eSjoerg  * Functions in this group only apply to instructions for which
338706f32e7eSjoerg  * LLVMIsATerminatorInst returns true.
338806f32e7eSjoerg  *
338906f32e7eSjoerg  * @{
339006f32e7eSjoerg  */
339106f32e7eSjoerg 
339206f32e7eSjoerg /**
339306f32e7eSjoerg  * Return the number of successors that this terminator has.
339406f32e7eSjoerg  *
339506f32e7eSjoerg  * @see llvm::Instruction::getNumSuccessors
339606f32e7eSjoerg  */
339706f32e7eSjoerg unsigned LLVMGetNumSuccessors(LLVMValueRef Term);
339806f32e7eSjoerg 
339906f32e7eSjoerg /**
340006f32e7eSjoerg  * Return the specified successor.
340106f32e7eSjoerg  *
340206f32e7eSjoerg  * @see llvm::Instruction::getSuccessor
340306f32e7eSjoerg  */
340406f32e7eSjoerg LLVMBasicBlockRef LLVMGetSuccessor(LLVMValueRef Term, unsigned i);
340506f32e7eSjoerg 
340606f32e7eSjoerg /**
340706f32e7eSjoerg  * Update the specified successor to point at the provided block.
340806f32e7eSjoerg  *
340906f32e7eSjoerg  * @see llvm::Instruction::setSuccessor
341006f32e7eSjoerg  */
341106f32e7eSjoerg void LLVMSetSuccessor(LLVMValueRef Term, unsigned i, LLVMBasicBlockRef block);
341206f32e7eSjoerg 
341306f32e7eSjoerg /**
341406f32e7eSjoerg  * Return if a branch is conditional.
341506f32e7eSjoerg  *
341606f32e7eSjoerg  * This only works on llvm::BranchInst instructions.
341706f32e7eSjoerg  *
341806f32e7eSjoerg  * @see llvm::BranchInst::isConditional
341906f32e7eSjoerg  */
342006f32e7eSjoerg LLVMBool LLVMIsConditional(LLVMValueRef Branch);
342106f32e7eSjoerg 
342206f32e7eSjoerg /**
342306f32e7eSjoerg  * Return the condition of a branch instruction.
342406f32e7eSjoerg  *
342506f32e7eSjoerg  * This only works on llvm::BranchInst instructions.
342606f32e7eSjoerg  *
342706f32e7eSjoerg  * @see llvm::BranchInst::getCondition
342806f32e7eSjoerg  */
342906f32e7eSjoerg LLVMValueRef LLVMGetCondition(LLVMValueRef Branch);
343006f32e7eSjoerg 
343106f32e7eSjoerg /**
343206f32e7eSjoerg  * Set the condition of a branch instruction.
343306f32e7eSjoerg  *
343406f32e7eSjoerg  * This only works on llvm::BranchInst instructions.
343506f32e7eSjoerg  *
343606f32e7eSjoerg  * @see llvm::BranchInst::setCondition
343706f32e7eSjoerg  */
343806f32e7eSjoerg void LLVMSetCondition(LLVMValueRef Branch, LLVMValueRef Cond);
343906f32e7eSjoerg 
344006f32e7eSjoerg /**
344106f32e7eSjoerg  * Obtain the default destination basic block of a switch instruction.
344206f32e7eSjoerg  *
344306f32e7eSjoerg  * This only works on llvm::SwitchInst instructions.
344406f32e7eSjoerg  *
344506f32e7eSjoerg  * @see llvm::SwitchInst::getDefaultDest()
344606f32e7eSjoerg  */
344706f32e7eSjoerg LLVMBasicBlockRef LLVMGetSwitchDefaultDest(LLVMValueRef SwitchInstr);
344806f32e7eSjoerg 
344906f32e7eSjoerg /**
345006f32e7eSjoerg  * @}
345106f32e7eSjoerg  */
345206f32e7eSjoerg 
345306f32e7eSjoerg /**
345406f32e7eSjoerg  * @defgroup LLVMCCoreValueInstructionAlloca Allocas
345506f32e7eSjoerg  *
345606f32e7eSjoerg  * Functions in this group only apply to instructions that map to
345706f32e7eSjoerg  * llvm::AllocaInst instances.
345806f32e7eSjoerg  *
345906f32e7eSjoerg  * @{
346006f32e7eSjoerg  */
346106f32e7eSjoerg 
346206f32e7eSjoerg /**
346306f32e7eSjoerg  * Obtain the type that is being allocated by the alloca instruction.
346406f32e7eSjoerg  */
346506f32e7eSjoerg LLVMTypeRef LLVMGetAllocatedType(LLVMValueRef Alloca);
346606f32e7eSjoerg 
346706f32e7eSjoerg /**
346806f32e7eSjoerg  * @}
346906f32e7eSjoerg  */
347006f32e7eSjoerg 
347106f32e7eSjoerg /**
347206f32e7eSjoerg  * @defgroup LLVMCCoreValueInstructionGetElementPointer GEPs
347306f32e7eSjoerg  *
347406f32e7eSjoerg  * Functions in this group only apply to instructions that map to
347506f32e7eSjoerg  * llvm::GetElementPtrInst instances.
347606f32e7eSjoerg  *
347706f32e7eSjoerg  * @{
347806f32e7eSjoerg  */
347906f32e7eSjoerg 
348006f32e7eSjoerg /**
348106f32e7eSjoerg  * Check whether the given GEP instruction is inbounds.
348206f32e7eSjoerg  */
348306f32e7eSjoerg LLVMBool LLVMIsInBounds(LLVMValueRef GEP);
348406f32e7eSjoerg 
348506f32e7eSjoerg /**
348606f32e7eSjoerg  * Set the given GEP instruction to be inbounds or not.
348706f32e7eSjoerg  */
348806f32e7eSjoerg void LLVMSetIsInBounds(LLVMValueRef GEP, LLVMBool InBounds);
348906f32e7eSjoerg 
349006f32e7eSjoerg /**
349106f32e7eSjoerg  * @}
349206f32e7eSjoerg  */
349306f32e7eSjoerg 
349406f32e7eSjoerg /**
349506f32e7eSjoerg  * @defgroup LLVMCCoreValueInstructionPHINode PHI Nodes
349606f32e7eSjoerg  *
349706f32e7eSjoerg  * Functions in this group only apply to instructions that map to
349806f32e7eSjoerg  * llvm::PHINode instances.
349906f32e7eSjoerg  *
350006f32e7eSjoerg  * @{
350106f32e7eSjoerg  */
350206f32e7eSjoerg 
350306f32e7eSjoerg /**
350406f32e7eSjoerg  * Add an incoming value to the end of a PHI list.
350506f32e7eSjoerg  */
350606f32e7eSjoerg void LLVMAddIncoming(LLVMValueRef PhiNode, LLVMValueRef *IncomingValues,
350706f32e7eSjoerg                      LLVMBasicBlockRef *IncomingBlocks, unsigned Count);
350806f32e7eSjoerg 
350906f32e7eSjoerg /**
351006f32e7eSjoerg  * Obtain the number of incoming basic blocks to a PHI node.
351106f32e7eSjoerg  */
351206f32e7eSjoerg unsigned LLVMCountIncoming(LLVMValueRef PhiNode);
351306f32e7eSjoerg 
351406f32e7eSjoerg /**
351506f32e7eSjoerg  * Obtain an incoming value to a PHI node as an LLVMValueRef.
351606f32e7eSjoerg  */
351706f32e7eSjoerg LLVMValueRef LLVMGetIncomingValue(LLVMValueRef PhiNode, unsigned Index);
351806f32e7eSjoerg 
351906f32e7eSjoerg /**
352006f32e7eSjoerg  * Obtain an incoming value to a PHI node as an LLVMBasicBlockRef.
352106f32e7eSjoerg  */
352206f32e7eSjoerg LLVMBasicBlockRef LLVMGetIncomingBlock(LLVMValueRef PhiNode, unsigned Index);
352306f32e7eSjoerg 
352406f32e7eSjoerg /**
352506f32e7eSjoerg  * @}
352606f32e7eSjoerg  */
352706f32e7eSjoerg 
352806f32e7eSjoerg /**
352906f32e7eSjoerg  * @defgroup LLVMCCoreValueInstructionExtractValue ExtractValue
353006f32e7eSjoerg  * @defgroup LLVMCCoreValueInstructionInsertValue InsertValue
353106f32e7eSjoerg  *
353206f32e7eSjoerg  * Functions in this group only apply to instructions that map to
353306f32e7eSjoerg  * llvm::ExtractValue and llvm::InsertValue instances.
353406f32e7eSjoerg  *
353506f32e7eSjoerg  * @{
353606f32e7eSjoerg  */
353706f32e7eSjoerg 
353806f32e7eSjoerg /**
353906f32e7eSjoerg  * Obtain the number of indices.
354006f32e7eSjoerg  * NB: This also works on GEP.
354106f32e7eSjoerg  */
354206f32e7eSjoerg unsigned LLVMGetNumIndices(LLVMValueRef Inst);
354306f32e7eSjoerg 
354406f32e7eSjoerg /**
354506f32e7eSjoerg  * Obtain the indices as an array.
354606f32e7eSjoerg  */
354706f32e7eSjoerg const unsigned *LLVMGetIndices(LLVMValueRef Inst);
354806f32e7eSjoerg 
354906f32e7eSjoerg /**
355006f32e7eSjoerg  * @}
355106f32e7eSjoerg  */
355206f32e7eSjoerg 
355306f32e7eSjoerg /**
355406f32e7eSjoerg  * @}
355506f32e7eSjoerg  */
355606f32e7eSjoerg 
355706f32e7eSjoerg /**
355806f32e7eSjoerg  * @}
355906f32e7eSjoerg  */
356006f32e7eSjoerg 
356106f32e7eSjoerg /**
356206f32e7eSjoerg  * @defgroup LLVMCCoreInstructionBuilder Instruction Builders
356306f32e7eSjoerg  *
356406f32e7eSjoerg  * An instruction builder represents a point within a basic block and is
356506f32e7eSjoerg  * the exclusive means of building instructions using the C interface.
356606f32e7eSjoerg  *
356706f32e7eSjoerg  * @{
356806f32e7eSjoerg  */
356906f32e7eSjoerg 
357006f32e7eSjoerg LLVMBuilderRef LLVMCreateBuilderInContext(LLVMContextRef C);
357106f32e7eSjoerg LLVMBuilderRef LLVMCreateBuilder(void);
357206f32e7eSjoerg void LLVMPositionBuilder(LLVMBuilderRef Builder, LLVMBasicBlockRef Block,
357306f32e7eSjoerg                          LLVMValueRef Instr);
357406f32e7eSjoerg void LLVMPositionBuilderBefore(LLVMBuilderRef Builder, LLVMValueRef Instr);
357506f32e7eSjoerg void LLVMPositionBuilderAtEnd(LLVMBuilderRef Builder, LLVMBasicBlockRef Block);
357606f32e7eSjoerg LLVMBasicBlockRef LLVMGetInsertBlock(LLVMBuilderRef Builder);
357706f32e7eSjoerg void LLVMClearInsertionPosition(LLVMBuilderRef Builder);
357806f32e7eSjoerg void LLVMInsertIntoBuilder(LLVMBuilderRef Builder, LLVMValueRef Instr);
357906f32e7eSjoerg void LLVMInsertIntoBuilderWithName(LLVMBuilderRef Builder, LLVMValueRef Instr,
358006f32e7eSjoerg                                    const char *Name);
358106f32e7eSjoerg void LLVMDisposeBuilder(LLVMBuilderRef Builder);
358206f32e7eSjoerg 
358306f32e7eSjoerg /* Metadata */
358406f32e7eSjoerg 
358506f32e7eSjoerg /**
358606f32e7eSjoerg  * Get location information used by debugging information.
358706f32e7eSjoerg  *
358806f32e7eSjoerg  * @see llvm::IRBuilder::getCurrentDebugLocation()
358906f32e7eSjoerg  */
359006f32e7eSjoerg LLVMMetadataRef LLVMGetCurrentDebugLocation2(LLVMBuilderRef Builder);
359106f32e7eSjoerg 
359206f32e7eSjoerg /**
359306f32e7eSjoerg  * Set location information used by debugging information.
359406f32e7eSjoerg  *
359506f32e7eSjoerg  * To clear the location metadata of the given instruction, pass NULL to \p Loc.
359606f32e7eSjoerg  *
359706f32e7eSjoerg  * @see llvm::IRBuilder::SetCurrentDebugLocation()
359806f32e7eSjoerg  */
359906f32e7eSjoerg void LLVMSetCurrentDebugLocation2(LLVMBuilderRef Builder, LLVMMetadataRef Loc);
360006f32e7eSjoerg 
360106f32e7eSjoerg /**
360206f32e7eSjoerg  * Attempts to set the debug location for the given instruction using the
360306f32e7eSjoerg  * current debug location for the given builder.  If the builder has no current
360406f32e7eSjoerg  * debug location, this function is a no-op.
360506f32e7eSjoerg  *
360606f32e7eSjoerg  * @see llvm::IRBuilder::SetInstDebugLocation()
360706f32e7eSjoerg  */
360806f32e7eSjoerg void LLVMSetInstDebugLocation(LLVMBuilderRef Builder, LLVMValueRef Inst);
360906f32e7eSjoerg 
361006f32e7eSjoerg /**
361106f32e7eSjoerg  * Get the dafult floating-point math metadata for a given builder.
361206f32e7eSjoerg  *
361306f32e7eSjoerg  * @see llvm::IRBuilder::getDefaultFPMathTag()
361406f32e7eSjoerg  */
361506f32e7eSjoerg LLVMMetadataRef LLVMBuilderGetDefaultFPMathTag(LLVMBuilderRef Builder);
361606f32e7eSjoerg 
361706f32e7eSjoerg /**
361806f32e7eSjoerg  * Set the default floating-point math metadata for the given builder.
361906f32e7eSjoerg  *
362006f32e7eSjoerg  * To clear the metadata, pass NULL to \p FPMathTag.
362106f32e7eSjoerg  *
362206f32e7eSjoerg  * @see llvm::IRBuilder::setDefaultFPMathTag()
362306f32e7eSjoerg  */
362406f32e7eSjoerg void LLVMBuilderSetDefaultFPMathTag(LLVMBuilderRef Builder,
362506f32e7eSjoerg                                     LLVMMetadataRef FPMathTag);
362606f32e7eSjoerg 
362706f32e7eSjoerg /**
362806f32e7eSjoerg  * Deprecated: Passing the NULL location will crash.
362906f32e7eSjoerg  * Use LLVMGetCurrentDebugLocation2 instead.
363006f32e7eSjoerg  */
363106f32e7eSjoerg void LLVMSetCurrentDebugLocation(LLVMBuilderRef Builder, LLVMValueRef L);
363206f32e7eSjoerg /**
363306f32e7eSjoerg  * Deprecated: Returning the NULL location will crash.
363406f32e7eSjoerg  * Use LLVMGetCurrentDebugLocation2 instead.
363506f32e7eSjoerg  */
363606f32e7eSjoerg LLVMValueRef LLVMGetCurrentDebugLocation(LLVMBuilderRef Builder);
363706f32e7eSjoerg 
363806f32e7eSjoerg /* Terminators */
363906f32e7eSjoerg LLVMValueRef LLVMBuildRetVoid(LLVMBuilderRef);
364006f32e7eSjoerg LLVMValueRef LLVMBuildRet(LLVMBuilderRef, LLVMValueRef V);
364106f32e7eSjoerg LLVMValueRef LLVMBuildAggregateRet(LLVMBuilderRef, LLVMValueRef *RetVals,
364206f32e7eSjoerg                                    unsigned N);
364306f32e7eSjoerg LLVMValueRef LLVMBuildBr(LLVMBuilderRef, LLVMBasicBlockRef Dest);
364406f32e7eSjoerg LLVMValueRef LLVMBuildCondBr(LLVMBuilderRef, LLVMValueRef If,
364506f32e7eSjoerg                              LLVMBasicBlockRef Then, LLVMBasicBlockRef Else);
364606f32e7eSjoerg LLVMValueRef LLVMBuildSwitch(LLVMBuilderRef, LLVMValueRef V,
364706f32e7eSjoerg                              LLVMBasicBlockRef Else, unsigned NumCases);
364806f32e7eSjoerg LLVMValueRef LLVMBuildIndirectBr(LLVMBuilderRef B, LLVMValueRef Addr,
364906f32e7eSjoerg                                  unsigned NumDests);
365006f32e7eSjoerg // LLVMBuildInvoke is deprecated in favor of LLVMBuildInvoke2, in preparation
365106f32e7eSjoerg // for opaque pointer types.
365206f32e7eSjoerg LLVMValueRef LLVMBuildInvoke(LLVMBuilderRef, LLVMValueRef Fn,
365306f32e7eSjoerg                              LLVMValueRef *Args, unsigned NumArgs,
365406f32e7eSjoerg                              LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch,
365506f32e7eSjoerg                              const char *Name);
365606f32e7eSjoerg LLVMValueRef LLVMBuildInvoke2(LLVMBuilderRef, LLVMTypeRef Ty, LLVMValueRef Fn,
365706f32e7eSjoerg                               LLVMValueRef *Args, unsigned NumArgs,
365806f32e7eSjoerg                               LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch,
365906f32e7eSjoerg                               const char *Name);
366006f32e7eSjoerg LLVMValueRef LLVMBuildUnreachable(LLVMBuilderRef);
366106f32e7eSjoerg 
366206f32e7eSjoerg /* Exception Handling */
366306f32e7eSjoerg LLVMValueRef LLVMBuildResume(LLVMBuilderRef B, LLVMValueRef Exn);
366406f32e7eSjoerg LLVMValueRef LLVMBuildLandingPad(LLVMBuilderRef B, LLVMTypeRef Ty,
366506f32e7eSjoerg                                  LLVMValueRef PersFn, unsigned NumClauses,
366606f32e7eSjoerg                                  const char *Name);
366706f32e7eSjoerg LLVMValueRef LLVMBuildCleanupRet(LLVMBuilderRef B, LLVMValueRef CatchPad,
366806f32e7eSjoerg                                  LLVMBasicBlockRef BB);
366906f32e7eSjoerg LLVMValueRef LLVMBuildCatchRet(LLVMBuilderRef B, LLVMValueRef CatchPad,
367006f32e7eSjoerg                                LLVMBasicBlockRef BB);
367106f32e7eSjoerg LLVMValueRef LLVMBuildCatchPad(LLVMBuilderRef B, LLVMValueRef ParentPad,
367206f32e7eSjoerg                                LLVMValueRef *Args, unsigned NumArgs,
367306f32e7eSjoerg                                const char *Name);
367406f32e7eSjoerg LLVMValueRef LLVMBuildCleanupPad(LLVMBuilderRef B, LLVMValueRef ParentPad,
367506f32e7eSjoerg                                  LLVMValueRef *Args, unsigned NumArgs,
367606f32e7eSjoerg                                  const char *Name);
367706f32e7eSjoerg LLVMValueRef LLVMBuildCatchSwitch(LLVMBuilderRef B, LLVMValueRef ParentPad,
367806f32e7eSjoerg                                   LLVMBasicBlockRef UnwindBB,
367906f32e7eSjoerg                                   unsigned NumHandlers, const char *Name);
368006f32e7eSjoerg 
368106f32e7eSjoerg /* Add a case to the switch instruction */
368206f32e7eSjoerg void LLVMAddCase(LLVMValueRef Switch, LLVMValueRef OnVal,
368306f32e7eSjoerg                  LLVMBasicBlockRef Dest);
368406f32e7eSjoerg 
368506f32e7eSjoerg /* Add a destination to the indirectbr instruction */
368606f32e7eSjoerg void LLVMAddDestination(LLVMValueRef IndirectBr, LLVMBasicBlockRef Dest);
368706f32e7eSjoerg 
368806f32e7eSjoerg /* Get the number of clauses on the landingpad instruction */
368906f32e7eSjoerg unsigned LLVMGetNumClauses(LLVMValueRef LandingPad);
369006f32e7eSjoerg 
3691*da58b97aSjoerg /* Get the value of the clause at index Idx on the landingpad instruction */
369206f32e7eSjoerg LLVMValueRef LLVMGetClause(LLVMValueRef LandingPad, unsigned Idx);
369306f32e7eSjoerg 
369406f32e7eSjoerg /* Add a catch or filter clause to the landingpad instruction */
369506f32e7eSjoerg void LLVMAddClause(LLVMValueRef LandingPad, LLVMValueRef ClauseVal);
369606f32e7eSjoerg 
369706f32e7eSjoerg /* Get the 'cleanup' flag in the landingpad instruction */
369806f32e7eSjoerg LLVMBool LLVMIsCleanup(LLVMValueRef LandingPad);
369906f32e7eSjoerg 
370006f32e7eSjoerg /* Set the 'cleanup' flag in the landingpad instruction */
370106f32e7eSjoerg void LLVMSetCleanup(LLVMValueRef LandingPad, LLVMBool Val);
370206f32e7eSjoerg 
370306f32e7eSjoerg /* Add a destination to the catchswitch instruction */
370406f32e7eSjoerg void LLVMAddHandler(LLVMValueRef CatchSwitch, LLVMBasicBlockRef Dest);
370506f32e7eSjoerg 
370606f32e7eSjoerg /* Get the number of handlers on the catchswitch instruction */
370706f32e7eSjoerg unsigned LLVMGetNumHandlers(LLVMValueRef CatchSwitch);
370806f32e7eSjoerg 
370906f32e7eSjoerg /**
371006f32e7eSjoerg  * Obtain the basic blocks acting as handlers for a catchswitch instruction.
371106f32e7eSjoerg  *
371206f32e7eSjoerg  * The Handlers parameter should point to a pre-allocated array of
371306f32e7eSjoerg  * LLVMBasicBlockRefs at least LLVMGetNumHandlers() large. On return, the
371406f32e7eSjoerg  * first LLVMGetNumHandlers() entries in the array will be populated
371506f32e7eSjoerg  * with LLVMBasicBlockRef instances.
371606f32e7eSjoerg  *
371706f32e7eSjoerg  * @param CatchSwitch The catchswitch instruction to operate on.
371806f32e7eSjoerg  * @param Handlers Memory address of an array to be filled with basic blocks.
371906f32e7eSjoerg  */
372006f32e7eSjoerg void LLVMGetHandlers(LLVMValueRef CatchSwitch, LLVMBasicBlockRef *Handlers);
372106f32e7eSjoerg 
372206f32e7eSjoerg /* Funclets */
372306f32e7eSjoerg 
372406f32e7eSjoerg /* Get the number of funcletpad arguments. */
372506f32e7eSjoerg LLVMValueRef LLVMGetArgOperand(LLVMValueRef Funclet, unsigned i);
372606f32e7eSjoerg 
372706f32e7eSjoerg /* Set a funcletpad argument at the given index. */
372806f32e7eSjoerg void LLVMSetArgOperand(LLVMValueRef Funclet, unsigned i, LLVMValueRef value);
372906f32e7eSjoerg 
373006f32e7eSjoerg /**
373106f32e7eSjoerg  * Get the parent catchswitch instruction of a catchpad instruction.
373206f32e7eSjoerg  *
373306f32e7eSjoerg  * This only works on llvm::CatchPadInst instructions.
373406f32e7eSjoerg  *
373506f32e7eSjoerg  * @see llvm::CatchPadInst::getCatchSwitch()
373606f32e7eSjoerg  */
373706f32e7eSjoerg LLVMValueRef LLVMGetParentCatchSwitch(LLVMValueRef CatchPad);
373806f32e7eSjoerg 
373906f32e7eSjoerg /**
374006f32e7eSjoerg  * Set the parent catchswitch instruction of a catchpad instruction.
374106f32e7eSjoerg  *
374206f32e7eSjoerg  * This only works on llvm::CatchPadInst instructions.
374306f32e7eSjoerg  *
374406f32e7eSjoerg  * @see llvm::CatchPadInst::setCatchSwitch()
374506f32e7eSjoerg  */
374606f32e7eSjoerg void LLVMSetParentCatchSwitch(LLVMValueRef CatchPad, LLVMValueRef CatchSwitch);
374706f32e7eSjoerg 
374806f32e7eSjoerg /* Arithmetic */
374906f32e7eSjoerg LLVMValueRef LLVMBuildAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
375006f32e7eSjoerg                           const char *Name);
375106f32e7eSjoerg LLVMValueRef LLVMBuildNSWAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
375206f32e7eSjoerg                              const char *Name);
375306f32e7eSjoerg LLVMValueRef LLVMBuildNUWAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
375406f32e7eSjoerg                              const char *Name);
375506f32e7eSjoerg LLVMValueRef LLVMBuildFAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
375606f32e7eSjoerg                            const char *Name);
375706f32e7eSjoerg LLVMValueRef LLVMBuildSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
375806f32e7eSjoerg                           const char *Name);
375906f32e7eSjoerg LLVMValueRef LLVMBuildNSWSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
376006f32e7eSjoerg                              const char *Name);
376106f32e7eSjoerg LLVMValueRef LLVMBuildNUWSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
376206f32e7eSjoerg                              const char *Name);
376306f32e7eSjoerg LLVMValueRef LLVMBuildFSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
376406f32e7eSjoerg                            const char *Name);
376506f32e7eSjoerg LLVMValueRef LLVMBuildMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
376606f32e7eSjoerg                           const char *Name);
376706f32e7eSjoerg LLVMValueRef LLVMBuildNSWMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
376806f32e7eSjoerg                              const char *Name);
376906f32e7eSjoerg LLVMValueRef LLVMBuildNUWMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
377006f32e7eSjoerg                              const char *Name);
377106f32e7eSjoerg LLVMValueRef LLVMBuildFMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
377206f32e7eSjoerg                            const char *Name);
377306f32e7eSjoerg LLVMValueRef LLVMBuildUDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
377406f32e7eSjoerg                            const char *Name);
377506f32e7eSjoerg LLVMValueRef LLVMBuildExactUDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
377606f32e7eSjoerg                                 const char *Name);
377706f32e7eSjoerg LLVMValueRef LLVMBuildSDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
377806f32e7eSjoerg                            const char *Name);
377906f32e7eSjoerg LLVMValueRef LLVMBuildExactSDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
378006f32e7eSjoerg                                 const char *Name);
378106f32e7eSjoerg LLVMValueRef LLVMBuildFDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
378206f32e7eSjoerg                            const char *Name);
378306f32e7eSjoerg LLVMValueRef LLVMBuildURem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
378406f32e7eSjoerg                            const char *Name);
378506f32e7eSjoerg LLVMValueRef LLVMBuildSRem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
378606f32e7eSjoerg                            const char *Name);
378706f32e7eSjoerg LLVMValueRef LLVMBuildFRem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
378806f32e7eSjoerg                            const char *Name);
378906f32e7eSjoerg LLVMValueRef LLVMBuildShl(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
379006f32e7eSjoerg                            const char *Name);
379106f32e7eSjoerg LLVMValueRef LLVMBuildLShr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
379206f32e7eSjoerg                            const char *Name);
379306f32e7eSjoerg LLVMValueRef LLVMBuildAShr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
379406f32e7eSjoerg                            const char *Name);
379506f32e7eSjoerg LLVMValueRef LLVMBuildAnd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
379606f32e7eSjoerg                           const char *Name);
379706f32e7eSjoerg LLVMValueRef LLVMBuildOr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
379806f32e7eSjoerg                           const char *Name);
379906f32e7eSjoerg LLVMValueRef LLVMBuildXor(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
380006f32e7eSjoerg                           const char *Name);
380106f32e7eSjoerg LLVMValueRef LLVMBuildBinOp(LLVMBuilderRef B, LLVMOpcode Op,
380206f32e7eSjoerg                             LLVMValueRef LHS, LLVMValueRef RHS,
380306f32e7eSjoerg                             const char *Name);
380406f32e7eSjoerg LLVMValueRef LLVMBuildNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name);
380506f32e7eSjoerg LLVMValueRef LLVMBuildNSWNeg(LLVMBuilderRef B, LLVMValueRef V,
380606f32e7eSjoerg                              const char *Name);
380706f32e7eSjoerg LLVMValueRef LLVMBuildNUWNeg(LLVMBuilderRef B, LLVMValueRef V,
380806f32e7eSjoerg                              const char *Name);
380906f32e7eSjoerg LLVMValueRef LLVMBuildFNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name);
381006f32e7eSjoerg LLVMValueRef LLVMBuildNot(LLVMBuilderRef, LLVMValueRef V, const char *Name);
381106f32e7eSjoerg 
381206f32e7eSjoerg /* Memory */
381306f32e7eSjoerg LLVMValueRef LLVMBuildMalloc(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
381406f32e7eSjoerg LLVMValueRef LLVMBuildArrayMalloc(LLVMBuilderRef, LLVMTypeRef Ty,
381506f32e7eSjoerg                                   LLVMValueRef Val, const char *Name);
381606f32e7eSjoerg 
381706f32e7eSjoerg /**
381806f32e7eSjoerg  * Creates and inserts a memset to the specified pointer and the
381906f32e7eSjoerg  * specified value.
382006f32e7eSjoerg  *
382106f32e7eSjoerg  * @see llvm::IRRBuilder::CreateMemSet()
382206f32e7eSjoerg  */
382306f32e7eSjoerg LLVMValueRef LLVMBuildMemSet(LLVMBuilderRef B, LLVMValueRef Ptr,
382406f32e7eSjoerg                              LLVMValueRef Val, LLVMValueRef Len,
382506f32e7eSjoerg                              unsigned Align);
382606f32e7eSjoerg /**
382706f32e7eSjoerg  * Creates and inserts a memcpy between the specified pointers.
382806f32e7eSjoerg  *
382906f32e7eSjoerg  * @see llvm::IRRBuilder::CreateMemCpy()
383006f32e7eSjoerg  */
383106f32e7eSjoerg LLVMValueRef LLVMBuildMemCpy(LLVMBuilderRef B,
383206f32e7eSjoerg                              LLVMValueRef Dst, unsigned DstAlign,
383306f32e7eSjoerg                              LLVMValueRef Src, unsigned SrcAlign,
383406f32e7eSjoerg                              LLVMValueRef Size);
383506f32e7eSjoerg /**
383606f32e7eSjoerg  * Creates and inserts a memmove between the specified pointers.
383706f32e7eSjoerg  *
383806f32e7eSjoerg  * @see llvm::IRRBuilder::CreateMemMove()
383906f32e7eSjoerg  */
384006f32e7eSjoerg LLVMValueRef LLVMBuildMemMove(LLVMBuilderRef B,
384106f32e7eSjoerg                               LLVMValueRef Dst, unsigned DstAlign,
384206f32e7eSjoerg                               LLVMValueRef Src, unsigned SrcAlign,
384306f32e7eSjoerg                               LLVMValueRef Size);
384406f32e7eSjoerg 
384506f32e7eSjoerg LLVMValueRef LLVMBuildAlloca(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
384606f32e7eSjoerg LLVMValueRef LLVMBuildArrayAlloca(LLVMBuilderRef, LLVMTypeRef Ty,
384706f32e7eSjoerg                                   LLVMValueRef Val, const char *Name);
384806f32e7eSjoerg LLVMValueRef LLVMBuildFree(LLVMBuilderRef, LLVMValueRef PointerVal);
384906f32e7eSjoerg // LLVMBuildLoad is deprecated in favor of LLVMBuildLoad2, in preparation for
385006f32e7eSjoerg // opaque pointer types.
385106f32e7eSjoerg LLVMValueRef LLVMBuildLoad(LLVMBuilderRef, LLVMValueRef PointerVal,
385206f32e7eSjoerg                            const char *Name);
385306f32e7eSjoerg LLVMValueRef LLVMBuildLoad2(LLVMBuilderRef, LLVMTypeRef Ty,
385406f32e7eSjoerg                             LLVMValueRef PointerVal, const char *Name);
385506f32e7eSjoerg LLVMValueRef LLVMBuildStore(LLVMBuilderRef, LLVMValueRef Val, LLVMValueRef Ptr);
385606f32e7eSjoerg // LLVMBuildGEP, LLVMBuildInBoundsGEP, and LLVMBuildStructGEP are deprecated in
385706f32e7eSjoerg // favor of LLVMBuild*GEP2, in preparation for opaque pointer types.
385806f32e7eSjoerg LLVMValueRef LLVMBuildGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
385906f32e7eSjoerg                           LLVMValueRef *Indices, unsigned NumIndices,
386006f32e7eSjoerg                           const char *Name);
386106f32e7eSjoerg LLVMValueRef LLVMBuildInBoundsGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
386206f32e7eSjoerg                                   LLVMValueRef *Indices, unsigned NumIndices,
386306f32e7eSjoerg                                   const char *Name);
386406f32e7eSjoerg LLVMValueRef LLVMBuildStructGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
386506f32e7eSjoerg                                 unsigned Idx, const char *Name);
386606f32e7eSjoerg LLVMValueRef LLVMBuildGEP2(LLVMBuilderRef B, LLVMTypeRef Ty,
386706f32e7eSjoerg                            LLVMValueRef Pointer, LLVMValueRef *Indices,
386806f32e7eSjoerg                            unsigned NumIndices, const char *Name);
386906f32e7eSjoerg LLVMValueRef LLVMBuildInBoundsGEP2(LLVMBuilderRef B, LLVMTypeRef Ty,
387006f32e7eSjoerg                                    LLVMValueRef Pointer, LLVMValueRef *Indices,
387106f32e7eSjoerg                                    unsigned NumIndices, const char *Name);
387206f32e7eSjoerg LLVMValueRef LLVMBuildStructGEP2(LLVMBuilderRef B, LLVMTypeRef Ty,
387306f32e7eSjoerg                                  LLVMValueRef Pointer, unsigned Idx,
387406f32e7eSjoerg                                  const char *Name);
387506f32e7eSjoerg LLVMValueRef LLVMBuildGlobalString(LLVMBuilderRef B, const char *Str,
387606f32e7eSjoerg                                    const char *Name);
387706f32e7eSjoerg LLVMValueRef LLVMBuildGlobalStringPtr(LLVMBuilderRef B, const char *Str,
387806f32e7eSjoerg                                       const char *Name);
387906f32e7eSjoerg LLVMBool LLVMGetVolatile(LLVMValueRef MemoryAccessInst);
388006f32e7eSjoerg void LLVMSetVolatile(LLVMValueRef MemoryAccessInst, LLVMBool IsVolatile);
388106f32e7eSjoerg LLVMBool LLVMGetWeak(LLVMValueRef CmpXchgInst);
388206f32e7eSjoerg void LLVMSetWeak(LLVMValueRef CmpXchgInst, LLVMBool IsWeak);
388306f32e7eSjoerg LLVMAtomicOrdering LLVMGetOrdering(LLVMValueRef MemoryAccessInst);
388406f32e7eSjoerg void LLVMSetOrdering(LLVMValueRef MemoryAccessInst, LLVMAtomicOrdering Ordering);
388506f32e7eSjoerg LLVMAtomicRMWBinOp LLVMGetAtomicRMWBinOp(LLVMValueRef AtomicRMWInst);
388606f32e7eSjoerg void LLVMSetAtomicRMWBinOp(LLVMValueRef AtomicRMWInst, LLVMAtomicRMWBinOp BinOp);
388706f32e7eSjoerg 
388806f32e7eSjoerg /* Casts */
388906f32e7eSjoerg LLVMValueRef LLVMBuildTrunc(LLVMBuilderRef, LLVMValueRef Val,
389006f32e7eSjoerg                             LLVMTypeRef DestTy, const char *Name);
389106f32e7eSjoerg LLVMValueRef LLVMBuildZExt(LLVMBuilderRef, LLVMValueRef Val,
389206f32e7eSjoerg                            LLVMTypeRef DestTy, const char *Name);
389306f32e7eSjoerg LLVMValueRef LLVMBuildSExt(LLVMBuilderRef, LLVMValueRef Val,
389406f32e7eSjoerg                            LLVMTypeRef DestTy, const char *Name);
389506f32e7eSjoerg LLVMValueRef LLVMBuildFPToUI(LLVMBuilderRef, LLVMValueRef Val,
389606f32e7eSjoerg                              LLVMTypeRef DestTy, const char *Name);
389706f32e7eSjoerg LLVMValueRef LLVMBuildFPToSI(LLVMBuilderRef, LLVMValueRef Val,
389806f32e7eSjoerg                              LLVMTypeRef DestTy, const char *Name);
389906f32e7eSjoerg LLVMValueRef LLVMBuildUIToFP(LLVMBuilderRef, LLVMValueRef Val,
390006f32e7eSjoerg                              LLVMTypeRef DestTy, const char *Name);
390106f32e7eSjoerg LLVMValueRef LLVMBuildSIToFP(LLVMBuilderRef, LLVMValueRef Val,
390206f32e7eSjoerg                              LLVMTypeRef DestTy, const char *Name);
390306f32e7eSjoerg LLVMValueRef LLVMBuildFPTrunc(LLVMBuilderRef, LLVMValueRef Val,
390406f32e7eSjoerg                               LLVMTypeRef DestTy, const char *Name);
390506f32e7eSjoerg LLVMValueRef LLVMBuildFPExt(LLVMBuilderRef, LLVMValueRef Val,
390606f32e7eSjoerg                             LLVMTypeRef DestTy, const char *Name);
390706f32e7eSjoerg LLVMValueRef LLVMBuildPtrToInt(LLVMBuilderRef, LLVMValueRef Val,
390806f32e7eSjoerg                                LLVMTypeRef DestTy, const char *Name);
390906f32e7eSjoerg LLVMValueRef LLVMBuildIntToPtr(LLVMBuilderRef, LLVMValueRef Val,
391006f32e7eSjoerg                                LLVMTypeRef DestTy, const char *Name);
391106f32e7eSjoerg LLVMValueRef LLVMBuildBitCast(LLVMBuilderRef, LLVMValueRef Val,
391206f32e7eSjoerg                               LLVMTypeRef DestTy, const char *Name);
391306f32e7eSjoerg LLVMValueRef LLVMBuildAddrSpaceCast(LLVMBuilderRef, LLVMValueRef Val,
391406f32e7eSjoerg                                     LLVMTypeRef DestTy, const char *Name);
391506f32e7eSjoerg LLVMValueRef LLVMBuildZExtOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
391606f32e7eSjoerg                                     LLVMTypeRef DestTy, const char *Name);
391706f32e7eSjoerg LLVMValueRef LLVMBuildSExtOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
391806f32e7eSjoerg                                     LLVMTypeRef DestTy, const char *Name);
391906f32e7eSjoerg LLVMValueRef LLVMBuildTruncOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
392006f32e7eSjoerg                                      LLVMTypeRef DestTy, const char *Name);
392106f32e7eSjoerg LLVMValueRef LLVMBuildCast(LLVMBuilderRef B, LLVMOpcode Op, LLVMValueRef Val,
392206f32e7eSjoerg                            LLVMTypeRef DestTy, const char *Name);
392306f32e7eSjoerg LLVMValueRef LLVMBuildPointerCast(LLVMBuilderRef, LLVMValueRef Val,
392406f32e7eSjoerg                                   LLVMTypeRef DestTy, const char *Name);
392506f32e7eSjoerg LLVMValueRef LLVMBuildIntCast2(LLVMBuilderRef, LLVMValueRef Val,
392606f32e7eSjoerg                                LLVMTypeRef DestTy, LLVMBool IsSigned,
392706f32e7eSjoerg                                const char *Name);
392806f32e7eSjoerg LLVMValueRef LLVMBuildFPCast(LLVMBuilderRef, LLVMValueRef Val,
392906f32e7eSjoerg                              LLVMTypeRef DestTy, const char *Name);
393006f32e7eSjoerg 
393106f32e7eSjoerg /** Deprecated: This cast is always signed. Use LLVMBuildIntCast2 instead. */
393206f32e7eSjoerg LLVMValueRef LLVMBuildIntCast(LLVMBuilderRef, LLVMValueRef Val, /*Signed cast!*/
393306f32e7eSjoerg                               LLVMTypeRef DestTy, const char *Name);
393406f32e7eSjoerg 
393506f32e7eSjoerg /* Comparisons */
393606f32e7eSjoerg LLVMValueRef LLVMBuildICmp(LLVMBuilderRef, LLVMIntPredicate Op,
393706f32e7eSjoerg                            LLVMValueRef LHS, LLVMValueRef RHS,
393806f32e7eSjoerg                            const char *Name);
393906f32e7eSjoerg LLVMValueRef LLVMBuildFCmp(LLVMBuilderRef, LLVMRealPredicate Op,
394006f32e7eSjoerg                            LLVMValueRef LHS, LLVMValueRef RHS,
394106f32e7eSjoerg                            const char *Name);
394206f32e7eSjoerg 
394306f32e7eSjoerg /* Miscellaneous instructions */
394406f32e7eSjoerg LLVMValueRef LLVMBuildPhi(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
394506f32e7eSjoerg // LLVMBuildCall is deprecated in favor of LLVMBuildCall2, in preparation for
394606f32e7eSjoerg // opaque pointer types.
394706f32e7eSjoerg LLVMValueRef LLVMBuildCall(LLVMBuilderRef, LLVMValueRef Fn,
394806f32e7eSjoerg                            LLVMValueRef *Args, unsigned NumArgs,
394906f32e7eSjoerg                            const char *Name);
395006f32e7eSjoerg LLVMValueRef LLVMBuildCall2(LLVMBuilderRef, LLVMTypeRef, LLVMValueRef Fn,
395106f32e7eSjoerg                             LLVMValueRef *Args, unsigned NumArgs,
395206f32e7eSjoerg                             const char *Name);
395306f32e7eSjoerg LLVMValueRef LLVMBuildSelect(LLVMBuilderRef, LLVMValueRef If,
395406f32e7eSjoerg                              LLVMValueRef Then, LLVMValueRef Else,
395506f32e7eSjoerg                              const char *Name);
395606f32e7eSjoerg LLVMValueRef LLVMBuildVAArg(LLVMBuilderRef, LLVMValueRef List, LLVMTypeRef Ty,
395706f32e7eSjoerg                             const char *Name);
395806f32e7eSjoerg LLVMValueRef LLVMBuildExtractElement(LLVMBuilderRef, LLVMValueRef VecVal,
395906f32e7eSjoerg                                      LLVMValueRef Index, const char *Name);
396006f32e7eSjoerg LLVMValueRef LLVMBuildInsertElement(LLVMBuilderRef, LLVMValueRef VecVal,
396106f32e7eSjoerg                                     LLVMValueRef EltVal, LLVMValueRef Index,
396206f32e7eSjoerg                                     const char *Name);
396306f32e7eSjoerg LLVMValueRef LLVMBuildShuffleVector(LLVMBuilderRef, LLVMValueRef V1,
396406f32e7eSjoerg                                     LLVMValueRef V2, LLVMValueRef Mask,
396506f32e7eSjoerg                                     const char *Name);
396606f32e7eSjoerg LLVMValueRef LLVMBuildExtractValue(LLVMBuilderRef, LLVMValueRef AggVal,
396706f32e7eSjoerg                                    unsigned Index, const char *Name);
396806f32e7eSjoerg LLVMValueRef LLVMBuildInsertValue(LLVMBuilderRef, LLVMValueRef AggVal,
396906f32e7eSjoerg                                   LLVMValueRef EltVal, unsigned Index,
397006f32e7eSjoerg                                   const char *Name);
3971*da58b97aSjoerg LLVMValueRef LLVMBuildFreeze(LLVMBuilderRef, LLVMValueRef Val,
3972*da58b97aSjoerg                              const char *Name);
397306f32e7eSjoerg 
397406f32e7eSjoerg LLVMValueRef LLVMBuildIsNull(LLVMBuilderRef, LLVMValueRef Val,
397506f32e7eSjoerg                              const char *Name);
397606f32e7eSjoerg LLVMValueRef LLVMBuildIsNotNull(LLVMBuilderRef, LLVMValueRef Val,
397706f32e7eSjoerg                                 const char *Name);
397806f32e7eSjoerg LLVMValueRef LLVMBuildPtrDiff(LLVMBuilderRef, LLVMValueRef LHS,
397906f32e7eSjoerg                               LLVMValueRef RHS, const char *Name);
398006f32e7eSjoerg LLVMValueRef LLVMBuildFence(LLVMBuilderRef B, LLVMAtomicOrdering ordering,
398106f32e7eSjoerg                             LLVMBool singleThread, const char *Name);
398206f32e7eSjoerg LLVMValueRef LLVMBuildAtomicRMW(LLVMBuilderRef B, LLVMAtomicRMWBinOp op,
398306f32e7eSjoerg                                 LLVMValueRef PTR, LLVMValueRef Val,
398406f32e7eSjoerg                                 LLVMAtomicOrdering ordering,
398506f32e7eSjoerg                                 LLVMBool singleThread);
398606f32e7eSjoerg LLVMValueRef LLVMBuildAtomicCmpXchg(LLVMBuilderRef B, LLVMValueRef Ptr,
398706f32e7eSjoerg                                     LLVMValueRef Cmp, LLVMValueRef New,
398806f32e7eSjoerg                                     LLVMAtomicOrdering SuccessOrdering,
398906f32e7eSjoerg                                     LLVMAtomicOrdering FailureOrdering,
399006f32e7eSjoerg                                     LLVMBool SingleThread);
399106f32e7eSjoerg 
3992*da58b97aSjoerg /**
3993*da58b97aSjoerg  * Get the number of elements in the mask of a ShuffleVector instruction.
3994*da58b97aSjoerg  */
3995*da58b97aSjoerg unsigned LLVMGetNumMaskElements(LLVMValueRef ShuffleVectorInst);
3996*da58b97aSjoerg 
3997*da58b97aSjoerg /**
3998*da58b97aSjoerg  * \returns a constant that specifies that the result of a \c ShuffleVectorInst
3999*da58b97aSjoerg  * is undefined.
4000*da58b97aSjoerg  */
4001*da58b97aSjoerg int LLVMGetUndefMaskElem(void);
4002*da58b97aSjoerg 
4003*da58b97aSjoerg /**
4004*da58b97aSjoerg  * Get the mask value at position Elt in the mask of a ShuffleVector
4005*da58b97aSjoerg  * instruction.
4006*da58b97aSjoerg  *
4007*da58b97aSjoerg  * \Returns the result of \c LLVMGetUndefMaskElem() if the mask value is undef
4008*da58b97aSjoerg  * at that position.
4009*da58b97aSjoerg  */
4010*da58b97aSjoerg int LLVMGetMaskValue(LLVMValueRef ShuffleVectorInst, unsigned Elt);
4011*da58b97aSjoerg 
401206f32e7eSjoerg LLVMBool LLVMIsAtomicSingleThread(LLVMValueRef AtomicInst);
401306f32e7eSjoerg void LLVMSetAtomicSingleThread(LLVMValueRef AtomicInst, LLVMBool SingleThread);
401406f32e7eSjoerg 
401506f32e7eSjoerg LLVMAtomicOrdering LLVMGetCmpXchgSuccessOrdering(LLVMValueRef CmpXchgInst);
401606f32e7eSjoerg void LLVMSetCmpXchgSuccessOrdering(LLVMValueRef CmpXchgInst,
401706f32e7eSjoerg                                    LLVMAtomicOrdering Ordering);
401806f32e7eSjoerg LLVMAtomicOrdering LLVMGetCmpXchgFailureOrdering(LLVMValueRef CmpXchgInst);
401906f32e7eSjoerg void LLVMSetCmpXchgFailureOrdering(LLVMValueRef CmpXchgInst,
402006f32e7eSjoerg                                    LLVMAtomicOrdering Ordering);
402106f32e7eSjoerg 
402206f32e7eSjoerg /**
402306f32e7eSjoerg  * @}
402406f32e7eSjoerg  */
402506f32e7eSjoerg 
402606f32e7eSjoerg /**
402706f32e7eSjoerg  * @defgroup LLVMCCoreModuleProvider Module Providers
402806f32e7eSjoerg  *
402906f32e7eSjoerg  * @{
403006f32e7eSjoerg  */
403106f32e7eSjoerg 
403206f32e7eSjoerg /**
403306f32e7eSjoerg  * Changes the type of M so it can be passed to FunctionPassManagers and the
403406f32e7eSjoerg  * JIT.  They take ModuleProviders for historical reasons.
403506f32e7eSjoerg  */
403606f32e7eSjoerg LLVMModuleProviderRef
403706f32e7eSjoerg LLVMCreateModuleProviderForExistingModule(LLVMModuleRef M);
403806f32e7eSjoerg 
403906f32e7eSjoerg /**
404006f32e7eSjoerg  * Destroys the module M.
404106f32e7eSjoerg  */
404206f32e7eSjoerg void LLVMDisposeModuleProvider(LLVMModuleProviderRef M);
404306f32e7eSjoerg 
404406f32e7eSjoerg /**
404506f32e7eSjoerg  * @}
404606f32e7eSjoerg  */
404706f32e7eSjoerg 
404806f32e7eSjoerg /**
404906f32e7eSjoerg  * @defgroup LLVMCCoreMemoryBuffers Memory Buffers
405006f32e7eSjoerg  *
405106f32e7eSjoerg  * @{
405206f32e7eSjoerg  */
405306f32e7eSjoerg 
405406f32e7eSjoerg LLVMBool LLVMCreateMemoryBufferWithContentsOfFile(const char *Path,
405506f32e7eSjoerg                                                   LLVMMemoryBufferRef *OutMemBuf,
405606f32e7eSjoerg                                                   char **OutMessage);
405706f32e7eSjoerg LLVMBool LLVMCreateMemoryBufferWithSTDIN(LLVMMemoryBufferRef *OutMemBuf,
405806f32e7eSjoerg                                          char **OutMessage);
405906f32e7eSjoerg LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRange(const char *InputData,
406006f32e7eSjoerg                                                           size_t InputDataLength,
406106f32e7eSjoerg                                                           const char *BufferName,
406206f32e7eSjoerg                                                           LLVMBool RequiresNullTerminator);
406306f32e7eSjoerg LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRangeCopy(const char *InputData,
406406f32e7eSjoerg                                                               size_t InputDataLength,
406506f32e7eSjoerg                                                               const char *BufferName);
406606f32e7eSjoerg const char *LLVMGetBufferStart(LLVMMemoryBufferRef MemBuf);
406706f32e7eSjoerg size_t LLVMGetBufferSize(LLVMMemoryBufferRef MemBuf);
406806f32e7eSjoerg void LLVMDisposeMemoryBuffer(LLVMMemoryBufferRef MemBuf);
406906f32e7eSjoerg 
407006f32e7eSjoerg /**
407106f32e7eSjoerg  * @}
407206f32e7eSjoerg  */
407306f32e7eSjoerg 
407406f32e7eSjoerg /**
407506f32e7eSjoerg  * @defgroup LLVMCCorePassRegistry Pass Registry
407606f32e7eSjoerg  *
407706f32e7eSjoerg  * @{
407806f32e7eSjoerg  */
407906f32e7eSjoerg 
408006f32e7eSjoerg /** Return the global pass registry, for use with initialization functions.
408106f32e7eSjoerg     @see llvm::PassRegistry::getPassRegistry */
408206f32e7eSjoerg LLVMPassRegistryRef LLVMGetGlobalPassRegistry(void);
408306f32e7eSjoerg 
408406f32e7eSjoerg /**
408506f32e7eSjoerg  * @}
408606f32e7eSjoerg  */
408706f32e7eSjoerg 
408806f32e7eSjoerg /**
408906f32e7eSjoerg  * @defgroup LLVMCCorePassManagers Pass Managers
409006f32e7eSjoerg  *
409106f32e7eSjoerg  * @{
409206f32e7eSjoerg  */
409306f32e7eSjoerg 
409406f32e7eSjoerg /** Constructs a new whole-module pass pipeline. This type of pipeline is
409506f32e7eSjoerg     suitable for link-time optimization and whole-module transformations.
409606f32e7eSjoerg     @see llvm::PassManager::PassManager */
409706f32e7eSjoerg LLVMPassManagerRef LLVMCreatePassManager(void);
409806f32e7eSjoerg 
409906f32e7eSjoerg /** Constructs a new function-by-function pass pipeline over the module
410006f32e7eSjoerg     provider. It does not take ownership of the module provider. This type of
410106f32e7eSjoerg     pipeline is suitable for code generation and JIT compilation tasks.
410206f32e7eSjoerg     @see llvm::FunctionPassManager::FunctionPassManager */
410306f32e7eSjoerg LLVMPassManagerRef LLVMCreateFunctionPassManagerForModule(LLVMModuleRef M);
410406f32e7eSjoerg 
410506f32e7eSjoerg /** Deprecated: Use LLVMCreateFunctionPassManagerForModule instead. */
410606f32e7eSjoerg LLVMPassManagerRef LLVMCreateFunctionPassManager(LLVMModuleProviderRef MP);
410706f32e7eSjoerg 
410806f32e7eSjoerg /** Initializes, executes on the provided module, and finalizes all of the
410906f32e7eSjoerg     passes scheduled in the pass manager. Returns 1 if any of the passes
411006f32e7eSjoerg     modified the module, 0 otherwise.
411106f32e7eSjoerg     @see llvm::PassManager::run(Module&) */
411206f32e7eSjoerg LLVMBool LLVMRunPassManager(LLVMPassManagerRef PM, LLVMModuleRef M);
411306f32e7eSjoerg 
411406f32e7eSjoerg /** Initializes all of the function passes scheduled in the function pass
411506f32e7eSjoerg     manager. Returns 1 if any of the passes modified the module, 0 otherwise.
411606f32e7eSjoerg     @see llvm::FunctionPassManager::doInitialization */
411706f32e7eSjoerg LLVMBool LLVMInitializeFunctionPassManager(LLVMPassManagerRef FPM);
411806f32e7eSjoerg 
411906f32e7eSjoerg /** Executes all of the function passes scheduled in the function pass manager
412006f32e7eSjoerg     on the provided function. Returns 1 if any of the passes modified the
412106f32e7eSjoerg     function, false otherwise.
412206f32e7eSjoerg     @see llvm::FunctionPassManager::run(Function&) */
412306f32e7eSjoerg LLVMBool LLVMRunFunctionPassManager(LLVMPassManagerRef FPM, LLVMValueRef F);
412406f32e7eSjoerg 
412506f32e7eSjoerg /** Finalizes all of the function passes scheduled in the function pass
412606f32e7eSjoerg     manager. Returns 1 if any of the passes modified the module, 0 otherwise.
412706f32e7eSjoerg     @see llvm::FunctionPassManager::doFinalization */
412806f32e7eSjoerg LLVMBool LLVMFinalizeFunctionPassManager(LLVMPassManagerRef FPM);
412906f32e7eSjoerg 
413006f32e7eSjoerg /** Frees the memory of a pass pipeline. For function pipelines, does not free
413106f32e7eSjoerg     the module provider.
413206f32e7eSjoerg     @see llvm::PassManagerBase::~PassManagerBase. */
413306f32e7eSjoerg void LLVMDisposePassManager(LLVMPassManagerRef PM);
413406f32e7eSjoerg 
413506f32e7eSjoerg /**
413606f32e7eSjoerg  * @}
413706f32e7eSjoerg  */
413806f32e7eSjoerg 
413906f32e7eSjoerg /**
414006f32e7eSjoerg  * @defgroup LLVMCCoreThreading Threading
414106f32e7eSjoerg  *
414206f32e7eSjoerg  * Handle the structures needed to make LLVM safe for multithreading.
414306f32e7eSjoerg  *
414406f32e7eSjoerg  * @{
414506f32e7eSjoerg  */
414606f32e7eSjoerg 
414706f32e7eSjoerg /** Deprecated: Multi-threading can only be enabled/disabled with the compile
414806f32e7eSjoerg     time define LLVM_ENABLE_THREADS.  This function always returns
414906f32e7eSjoerg     LLVMIsMultithreaded(). */
415006f32e7eSjoerg LLVMBool LLVMStartMultithreaded(void);
415106f32e7eSjoerg 
415206f32e7eSjoerg /** Deprecated: Multi-threading can only be enabled/disabled with the compile
415306f32e7eSjoerg     time define LLVM_ENABLE_THREADS. */
415406f32e7eSjoerg void LLVMStopMultithreaded(void);
415506f32e7eSjoerg 
415606f32e7eSjoerg /** Check whether LLVM is executing in thread-safe mode or not.
415706f32e7eSjoerg     @see llvm::llvm_is_multithreaded */
415806f32e7eSjoerg LLVMBool LLVMIsMultithreaded(void);
415906f32e7eSjoerg 
416006f32e7eSjoerg /**
416106f32e7eSjoerg  * @}
416206f32e7eSjoerg  */
416306f32e7eSjoerg 
416406f32e7eSjoerg /**
416506f32e7eSjoerg  * @}
416606f32e7eSjoerg  */
416706f32e7eSjoerg 
416806f32e7eSjoerg /**
416906f32e7eSjoerg  * @}
417006f32e7eSjoerg  */
417106f32e7eSjoerg 
4172*da58b97aSjoerg LLVM_C_EXTERN_C_END
417306f32e7eSjoerg 
417406f32e7eSjoerg #endif /* LLVM_C_CORE_H */
4175