Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 1 | /*===-- llvm-c/Core.h - Core Library C Interface ------------------*- C -*-===*\ |
| 2 | |* *| |
Chandler Carruth | 2946cd7 | 2019-01-19 08:50:56 +0000 | [diff] [blame] | 3 | |* Part of the LLVM Project, under the Apache License v2.0 with LLVM *| |
| 4 | |* Exceptions. *| |
| 5 | |* See https://llvm.org/LICENSE.txt for license information. *| |
| 6 | |* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *| |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 7 | |* *| |
| 8 | |*===----------------------------------------------------------------------===*| |
| 9 | |* *| |
| 10 | |* This header declares the C interface to libLLVMCore.a, which implements *| |
| 11 | |* the LLVM intermediate representation. *| |
| 12 | |* *| |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 13 | \*===----------------------------------------------------------------------===*/ |
| 14 | |
| 15 | #ifndef LLVM_C_CORE_H |
| 16 | #define LLVM_C_CORE_H |
| 17 | |
Eric Christopher | a6b9600 | 2015-12-18 01:46:52 +0000 | [diff] [blame] | 18 | #include "llvm-c/ErrorHandling.h" |
Duncan P. N. Exon Smith | 8c48405 | 2019-11-14 13:57:57 -0800 | [diff] [blame] | 19 | #include "llvm-c/ExternC.h" |
Eric Christopher | a6b9600 | 2015-12-18 01:46:52 +0000 | [diff] [blame] | 20 | #include "llvm-c/Types.h" |
Erick Tryzelaar | dd99135 | 2009-08-16 23:36:46 +0000 | [diff] [blame] | 21 | |
Duncan P. N. Exon Smith | 8c48405 | 2019-11-14 13:57:57 -0800 | [diff] [blame] | 22 | LLVM_C_EXTERN_C_BEGIN |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 23 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 24 | /** |
| 25 | * @defgroup LLVMC LLVM-C: C interface to LLVM |
| 26 | * |
| 27 | * This module exposes parts of the LLVM library as a C API. |
| 28 | * |
| 29 | * @{ |
| 30 | */ |
| 31 | |
| 32 | /** |
| 33 | * @defgroup LLVMCTransforms Transforms |
| 34 | */ |
| 35 | |
| 36 | /** |
| 37 | * @defgroup LLVMCCore Core |
| 38 | * |
| 39 | * This modules provide an interface to libLLVMCore, which implements |
| 40 | * the LLVM intermediate representation as well as other related types |
| 41 | * and utilities. |
| 42 | * |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 43 | * Many exotic languages can interoperate with C code but have a harder time |
| 44 | * with C++ due to name mangling. So in addition to C, this interface enables |
| 45 | * tools written in such languages. |
| 46 | * |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 47 | * @{ |
| 48 | */ |
| 49 | |
| 50 | /** |
| 51 | * @defgroup LLVMCCoreTypes Types and Enumerations |
| 52 | * |
| 53 | * @{ |
| 54 | */ |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 55 | |
Cameron McInally | cbde0d9 | 2018-11-13 18:15:47 +0000 | [diff] [blame] | 56 | /// External users depend on the following values being stable. It is not safe |
| 57 | /// to reorder them. |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 58 | typedef enum { |
Bill Wendling | da52cec | 2010-02-15 20:53:17 +0000 | [diff] [blame] | 59 | /* Terminator Instructions */ |
Chris Lattner | 40cf28d | 2009-10-12 04:01:02 +0000 | [diff] [blame] | 60 | LLVMRet = 1, |
| 61 | LLVMBr = 2, |
| 62 | LLVMSwitch = 3, |
Bill Wendling | 07d6d76 | 2010-02-15 20:50:51 +0000 | [diff] [blame] | 63 | LLVMIndirectBr = 4, |
| 64 | LLVMInvoke = 5, |
Bill Wendling | 46ffaa9 | 2011-08-02 06:20:17 +0000 | [diff] [blame] | 65 | /* removed 6 due to API changes */ |
Bill Wendling | 2641d13 | 2011-07-27 21:00:28 +0000 | [diff] [blame] | 66 | LLVMUnreachable = 7, |
Craig Topper | 784929d | 2019-02-08 20:48:56 +0000 | [diff] [blame] | 67 | LLVMCallBr = 67, |
Bill Wendling | 07d6d76 | 2010-02-15 20:50:51 +0000 | [diff] [blame] | 68 | |
Cameron McInally | cbde0d9 | 2018-11-13 18:15:47 +0000 | [diff] [blame] | 69 | /* Standard Unary Operators */ |
| 70 | LLVMFNeg = 66, |
| 71 | |
Bill Wendling | da52cec | 2010-02-15 20:53:17 +0000 | [diff] [blame] | 72 | /* Standard Binary Operators */ |
Bill Wendling | 2641d13 | 2011-07-27 21:00:28 +0000 | [diff] [blame] | 73 | LLVMAdd = 8, |
| 74 | LLVMFAdd = 9, |
| 75 | LLVMSub = 10, |
| 76 | LLVMFSub = 11, |
| 77 | LLVMMul = 12, |
| 78 | LLVMFMul = 13, |
| 79 | LLVMUDiv = 14, |
| 80 | LLVMSDiv = 15, |
| 81 | LLVMFDiv = 16, |
| 82 | LLVMURem = 17, |
| 83 | LLVMSRem = 18, |
| 84 | LLVMFRem = 19, |
Bill Wendling | 07d6d76 | 2010-02-15 20:50:51 +0000 | [diff] [blame] | 85 | |
Bill Wendling | da52cec | 2010-02-15 20:53:17 +0000 | [diff] [blame] | 86 | /* Logical Operators */ |
Bill Wendling | 2641d13 | 2011-07-27 21:00:28 +0000 | [diff] [blame] | 87 | LLVMShl = 20, |
| 88 | LLVMLShr = 21, |
| 89 | LLVMAShr = 22, |
| 90 | LLVMAnd = 23, |
| 91 | LLVMOr = 24, |
| 92 | LLVMXor = 25, |
Bill Wendling | 07d6d76 | 2010-02-15 20:50:51 +0000 | [diff] [blame] | 93 | |
Bill Wendling | da52cec | 2010-02-15 20:53:17 +0000 | [diff] [blame] | 94 | /* Memory Operators */ |
Bill Wendling | 2641d13 | 2011-07-27 21:00:28 +0000 | [diff] [blame] | 95 | LLVMAlloca = 26, |
| 96 | LLVMLoad = 27, |
| 97 | LLVMStore = 28, |
| 98 | LLVMGetElementPtr = 29, |
Bill Wendling | 07d6d76 | 2010-02-15 20:50:51 +0000 | [diff] [blame] | 99 | |
Bill Wendling | da52cec | 2010-02-15 20:53:17 +0000 | [diff] [blame] | 100 | /* Cast Operators */ |
Bill Wendling | 2641d13 | 2011-07-27 21:00:28 +0000 | [diff] [blame] | 101 | LLVMTrunc = 30, |
| 102 | LLVMZExt = 31, |
| 103 | LLVMSExt = 32, |
| 104 | LLVMFPToUI = 33, |
| 105 | LLVMFPToSI = 34, |
| 106 | LLVMUIToFP = 35, |
| 107 | LLVMSIToFP = 36, |
| 108 | LLVMFPTrunc = 37, |
| 109 | LLVMFPExt = 38, |
| 110 | LLVMPtrToInt = 39, |
| 111 | LLVMIntToPtr = 40, |
| 112 | LLVMBitCast = 41, |
Matt Arsenault | b03bd4d | 2013-11-15 01:34:59 +0000 | [diff] [blame] | 113 | LLVMAddrSpaceCast = 60, |
Bill Wendling | 07d6d76 | 2010-02-15 20:50:51 +0000 | [diff] [blame] | 114 | |
Bill Wendling | da52cec | 2010-02-15 20:53:17 +0000 | [diff] [blame] | 115 | /* Other Operators */ |
Bill Wendling | 2641d13 | 2011-07-27 21:00:28 +0000 | [diff] [blame] | 116 | LLVMICmp = 42, |
| 117 | LLVMFCmp = 43, |
| 118 | LLVMPHI = 44, |
| 119 | LLVMCall = 45, |
| 120 | LLVMSelect = 46, |
Torok Edwin | 05dc9d6 | 2011-10-06 12:39:34 +0000 | [diff] [blame] | 121 | LLVMUserOp1 = 47, |
| 122 | LLVMUserOp2 = 48, |
Bill Wendling | 2641d13 | 2011-07-27 21:00:28 +0000 | [diff] [blame] | 123 | LLVMVAArg = 49, |
| 124 | LLVMExtractElement = 50, |
| 125 | LLVMInsertElement = 51, |
| 126 | LLVMShuffleVector = 52, |
| 127 | LLVMExtractValue = 53, |
| 128 | LLVMInsertValue = 54, |
aqjune | e87d716 | 2019-11-07 01:17:49 +0900 | [diff] [blame] | 129 | LLVMFreeze = 68, |
Eli Friedman | 4fc946c | 2011-07-27 18:59:19 +0000 | [diff] [blame] | 130 | |
| 131 | /* Atomic operators */ |
Bill Wendling | 2641d13 | 2011-07-27 21:00:28 +0000 | [diff] [blame] | 132 | LLVMFence = 55, |
Eli Friedman | c9a551e | 2011-07-28 21:48:00 +0000 | [diff] [blame] | 133 | LLVMAtomicCmpXchg = 56, |
Bill Wendling | f891bf8 | 2011-07-31 06:30:59 +0000 | [diff] [blame] | 134 | LLVMAtomicRMW = 57, |
| 135 | |
| 136 | /* Exception Handling Operators */ |
Bill Wendling | fae1475 | 2011-08-12 20:24:12 +0000 | [diff] [blame] | 137 | LLVMResume = 58, |
David Majnemer | 654e130 | 2015-07-31 17:58:14 +0000 | [diff] [blame] | 138 | LLVMLandingPad = 59, |
| 139 | LLVMCleanupRet = 61, |
| 140 | LLVMCatchRet = 62, |
Joseph Tremoulet | 9ce71f7 | 2015-09-03 09:09:43 +0000 | [diff] [blame] | 141 | LLVMCatchPad = 63, |
David Majnemer | bbfc721 | 2015-12-14 18:34:23 +0000 | [diff] [blame] | 142 | LLVMCleanupPad = 64, |
| 143 | LLVMCatchSwitch = 65 |
Chris Lattner | 40cf28d | 2009-10-12 04:01:02 +0000 | [diff] [blame] | 144 | } LLVMOpcode; |
| 145 | |
| 146 | typedef enum { |
Christopher Tetreault | 015e297 | 2020-05-15 10:45:42 -0700 | [diff] [blame] | 147 | LLVMVoidTypeKind, /**< type with no size */ |
| 148 | LLVMHalfTypeKind, /**< 16 bit floating point type */ |
Christopher Tetreault | 015e297 | 2020-05-15 10:45:42 -0700 | [diff] [blame] | 149 | LLVMFloatTypeKind, /**< 32 bit floating point type */ |
| 150 | LLVMDoubleTypeKind, /**< 64 bit floating point type */ |
| 151 | LLVMX86_FP80TypeKind, /**< 80 bit floating point type (X87) */ |
| 152 | LLVMFP128TypeKind, /**< 128 bit floating point type (112-bit mantissa)*/ |
| 153 | LLVMPPC_FP128TypeKind, /**< 128 bit floating point type (two 64-bits) */ |
| 154 | LLVMLabelTypeKind, /**< Labels */ |
| 155 | LLVMIntegerTypeKind, /**< Arbitrary bit width integers */ |
| 156 | LLVMFunctionTypeKind, /**< Functions */ |
| 157 | LLVMStructTypeKind, /**< Structures */ |
| 158 | LLVMArrayTypeKind, /**< Arrays */ |
| 159 | LLVMPointerTypeKind, /**< Pointers */ |
| 160 | LLVMVectorTypeKind, /**< Fixed width SIMD vector type */ |
| 161 | LLVMMetadataTypeKind, /**< Metadata */ |
| 162 | LLVMX86_MMXTypeKind, /**< X86 MMX */ |
| 163 | LLVMTokenTypeKind, /**< Tokens */ |
Ties Stuij | 9dda41e | 2020-06-18 23:57:32 +0100 | [diff] [blame] | 164 | LLVMScalableVectorTypeKind, /**< Scalable SIMD vector type */ |
| 165 | LLVMBFloatTypeKind /**< 16 bit brain floating point type */ |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 166 | } LLVMTypeKind; |
| 167 | |
| 168 | typedef enum { |
Gordon Henriksen | 4a4d735 | 2007-12-30 17:46:33 +0000 | [diff] [blame] | 169 | LLVMExternalLinkage, /**< Externally visible function */ |
Chris Lattner | 2dba0f0 | 2009-04-13 06:25:37 +0000 | [diff] [blame] | 170 | LLVMAvailableExternallyLinkage, |
Duncan Sands | 12da8ce | 2009-03-07 15:45:40 +0000 | [diff] [blame] | 171 | LLVMLinkOnceAnyLinkage, /**< Keep one copy of function when linking (inline)*/ |
| 172 | LLVMLinkOnceODRLinkage, /**< Same, but only replaced by something |
| 173 | equivalent. */ |
Rafael Espindola | 716e740 | 2013-11-01 17:09:14 +0000 | [diff] [blame] | 174 | LLVMLinkOnceODRAutoHideLinkage, /**< Obsolete */ |
Duncan Sands | 12da8ce | 2009-03-07 15:45:40 +0000 | [diff] [blame] | 175 | LLVMWeakAnyLinkage, /**< Keep one copy of function when linking (weak) */ |
| 176 | LLVMWeakODRLinkage, /**< Same, but only replaced by something |
| 177 | equivalent. */ |
Gordon Henriksen | 4a4d735 | 2007-12-30 17:46:33 +0000 | [diff] [blame] | 178 | LLVMAppendingLinkage, /**< Special purpose, only applies to global arrays */ |
| 179 | LLVMInternalLinkage, /**< Rename collisions when linking (static |
| 180 | functions) */ |
Duncan Sands | 12da8ce | 2009-03-07 15:45:40 +0000 | [diff] [blame] | 181 | LLVMPrivateLinkage, /**< Like Internal, but omit from symbol table */ |
Nico Rieck | 7157bb7 | 2014-01-14 15:22:47 +0000 | [diff] [blame] | 182 | LLVMDLLImportLinkage, /**< Obsolete */ |
| 183 | LLVMDLLExportLinkage, /**< Obsolete */ |
Duncan Sands | e288105 | 2009-03-11 08:08:06 +0000 | [diff] [blame] | 184 | LLVMExternalWeakLinkage,/**< ExternalWeak linkage description */ |
Jeffrey Yasskin | 091217b | 2010-01-27 20:34:15 +0000 | [diff] [blame] | 185 | LLVMGhostLinkage, /**< Obsolete */ |
Bill Wendling | 002b167 | 2009-07-20 18:22:52 +0000 | [diff] [blame] | 186 | LLVMCommonLinkage, /**< Tentative definitions */ |
Bill Wendling | 03bcd6e | 2010-07-01 21:55:59 +0000 | [diff] [blame] | 187 | LLVMLinkerPrivateLinkage, /**< Like Private, but linker removes. */ |
Bill Wendling | 34bc34e | 2012-08-17 18:33:14 +0000 | [diff] [blame] | 188 | LLVMLinkerPrivateWeakLinkage /**< Like LinkerPrivate, but is weak. */ |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 189 | } LLVMLinkage; |
| 190 | |
| 191 | typedef enum { |
Gordon Henriksen | 4a4d735 | 2007-12-30 17:46:33 +0000 | [diff] [blame] | 192 | LLVMDefaultVisibility, /**< The GV is visible */ |
| 193 | LLVMHiddenVisibility, /**< The GV is hidden */ |
| 194 | LLVMProtectedVisibility /**< The GV is protected */ |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 195 | } LLVMVisibility; |
| 196 | |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 197 | typedef enum { |
Robert Widmann | 4bb481b | 2018-03-14 06:45:51 +0000 | [diff] [blame] | 198 | LLVMNoUnnamedAddr, /**< Address of the GV is significant. */ |
| 199 | LLVMLocalUnnamedAddr, /**< Address of the GV is locally insignificant. */ |
| 200 | LLVMGlobalUnnamedAddr /**< Address of the GV is globally insignificant. */ |
| 201 | } LLVMUnnamedAddr; |
| 202 | |
| 203 | typedef enum { |
Reid Kleckner | 2fae26f | 2014-03-05 02:34:23 +0000 | [diff] [blame] | 204 | LLVMDefaultStorageClass = 0, |
| 205 | LLVMDLLImportStorageClass = 1, /**< Function to be imported from DLL. */ |
| 206 | LLVMDLLExportStorageClass = 2 /**< Function to be accessible from DLL. */ |
| 207 | } LLVMDLLStorageClass; |
| 208 | |
| 209 | typedef enum { |
Robert Widmann | 1e989de | 2018-04-06 04:02:39 +0000 | [diff] [blame] | 210 | LLVMCCallConv = 0, |
| 211 | LLVMFastCallConv = 8, |
| 212 | LLVMColdCallConv = 9, |
| 213 | LLVMGHCCallConv = 10, |
| 214 | LLVMHiPECallConv = 11, |
| 215 | LLVMWebKitJSCallConv = 12, |
| 216 | LLVMAnyRegCallConv = 13, |
| 217 | LLVMPreserveMostCallConv = 14, |
| 218 | LLVMPreserveAllCallConv = 15, |
| 219 | LLVMSwiftCallConv = 16, |
| 220 | LLVMCXXFASTTLSCallConv = 17, |
| 221 | LLVMX86StdcallCallConv = 64, |
| 222 | LLVMX86FastcallCallConv = 65, |
| 223 | LLVMARMAPCSCallConv = 66, |
| 224 | LLVMARMAAPCSCallConv = 67, |
| 225 | LLVMARMAAPCSVFPCallConv = 68, |
| 226 | LLVMMSP430INTRCallConv = 69, |
| 227 | LLVMX86ThisCallCallConv = 70, |
| 228 | LLVMPTXKernelCallConv = 71, |
| 229 | LLVMPTXDeviceCallConv = 72, |
| 230 | LLVMSPIRFUNCCallConv = 75, |
| 231 | LLVMSPIRKERNELCallConv = 76, |
| 232 | LLVMIntelOCLBICallConv = 77, |
| 233 | LLVMX8664SysVCallConv = 78, |
| 234 | LLVMWin64CallConv = 79, |
| 235 | LLVMX86VectorCallCallConv = 80, |
| 236 | LLVMHHVMCallConv = 81, |
| 237 | LLVMHHVMCCallConv = 82, |
| 238 | LLVMX86INTRCallConv = 83, |
| 239 | LLVMAVRINTRCallConv = 84, |
| 240 | LLVMAVRSIGNALCallConv = 85, |
| 241 | LLVMAVRBUILTINCallConv = 86, |
| 242 | LLVMAMDGPUVSCallConv = 87, |
| 243 | LLVMAMDGPUGSCallConv = 88, |
| 244 | LLVMAMDGPUPSCallConv = 89, |
| 245 | LLVMAMDGPUCSCallConv = 90, |
| 246 | LLVMAMDGPUKERNELCallConv = 91, |
| 247 | LLVMX86RegCallCallConv = 92, |
| 248 | LLVMAMDGPUHSCallConv = 93, |
| 249 | LLVMMSP430BUILTINCallConv = 94, |
| 250 | LLVMAMDGPULSCallConv = 95, |
| 251 | LLVMAMDGPUESCallConv = 96 |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 252 | } LLVMCallConv; |
| 253 | |
| 254 | typedef enum { |
Peter Zotov | 3e4561c | 2016-04-06 22:21:29 +0000 | [diff] [blame] | 255 | LLVMArgumentValueKind, |
| 256 | LLVMBasicBlockValueKind, |
| 257 | LLVMMemoryUseValueKind, |
| 258 | LLVMMemoryDefValueKind, |
| 259 | LLVMMemoryPhiValueKind, |
| 260 | |
| 261 | LLVMFunctionValueKind, |
| 262 | LLVMGlobalAliasValueKind, |
Dmitry Polukhin | a1feff7 | 2016-04-07 12:32:19 +0000 | [diff] [blame] | 263 | LLVMGlobalIFuncValueKind, |
Peter Zotov | 3e4561c | 2016-04-06 22:21:29 +0000 | [diff] [blame] | 264 | LLVMGlobalVariableValueKind, |
| 265 | LLVMBlockAddressValueKind, |
| 266 | LLVMConstantExprValueKind, |
| 267 | LLVMConstantArrayValueKind, |
| 268 | LLVMConstantStructValueKind, |
| 269 | LLVMConstantVectorValueKind, |
| 270 | |
| 271 | LLVMUndefValueValueKind, |
Zhengyang Liu | 75f50e1 | 2020-11-24 14:55:24 -0700 | [diff] [blame] | 272 | LLVMPoisonValueValueKind, |
Peter Zotov | 3e4561c | 2016-04-06 22:21:29 +0000 | [diff] [blame] | 273 | LLVMConstantAggregateZeroValueKind, |
| 274 | LLVMConstantDataArrayValueKind, |
| 275 | LLVMConstantDataVectorValueKind, |
| 276 | LLVMConstantIntValueKind, |
| 277 | LLVMConstantFPValueKind, |
| 278 | LLVMConstantPointerNullValueKind, |
| 279 | LLVMConstantTokenNoneValueKind, |
| 280 | |
| 281 | LLVMMetadataAsValueValueKind, |
| 282 | LLVMInlineAsmValueKind, |
| 283 | |
| 284 | LLVMInstructionValueKind, |
| 285 | } LLVMValueKind; |
| 286 | |
| 287 | typedef enum { |
Gordon Henriksen | 4a4d735 | 2007-12-30 17:46:33 +0000 | [diff] [blame] | 288 | LLVMIntEQ = 32, /**< equal */ |
| 289 | LLVMIntNE, /**< not equal */ |
| 290 | LLVMIntUGT, /**< unsigned greater than */ |
| 291 | LLVMIntUGE, /**< unsigned greater or equal */ |
| 292 | LLVMIntULT, /**< unsigned less than */ |
| 293 | LLVMIntULE, /**< unsigned less or equal */ |
| 294 | LLVMIntSGT, /**< signed greater than */ |
| 295 | LLVMIntSGE, /**< signed greater or equal */ |
| 296 | LLVMIntSLT, /**< signed less than */ |
| 297 | LLVMIntSLE /**< signed less or equal */ |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 298 | } LLVMIntPredicate; |
| 299 | |
| 300 | typedef enum { |
Gordon Henriksen | 4a4d735 | 2007-12-30 17:46:33 +0000 | [diff] [blame] | 301 | LLVMRealPredicateFalse, /**< Always false (always folded) */ |
| 302 | LLVMRealOEQ, /**< True if ordered and equal */ |
| 303 | LLVMRealOGT, /**< True if ordered and greater than */ |
| 304 | LLVMRealOGE, /**< True if ordered and greater than or equal */ |
| 305 | LLVMRealOLT, /**< True if ordered and less than */ |
| 306 | LLVMRealOLE, /**< True if ordered and less than or equal */ |
| 307 | LLVMRealONE, /**< True if ordered and operands are unequal */ |
| 308 | LLVMRealORD, /**< True if ordered (no nans) */ |
| 309 | LLVMRealUNO, /**< True if unordered: isnan(X) | isnan(Y) */ |
| 310 | LLVMRealUEQ, /**< True if unordered or equal */ |
| 311 | LLVMRealUGT, /**< True if unordered or greater than */ |
| 312 | LLVMRealUGE, /**< True if unordered, greater than, or equal */ |
| 313 | LLVMRealULT, /**< True if unordered or less than */ |
| 314 | LLVMRealULE, /**< True if unordered, less than, or equal */ |
| 315 | LLVMRealUNE, /**< True if unordered or not equal */ |
| 316 | LLVMRealPredicateTrue /**< Always true (always folded) */ |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 317 | } LLVMRealPredicate; |
| 318 | |
Bill Wendling | fae1475 | 2011-08-12 20:24:12 +0000 | [diff] [blame] | 319 | typedef enum { |
| 320 | LLVMLandingPadCatch, /**< A catch clause */ |
| 321 | LLVMLandingPadFilter /**< A filter clause */ |
| 322 | } LLVMLandingPadClauseTy; |
| 323 | |
Hans Wennborg | 5ff7120 | 2013-04-16 08:58:59 +0000 | [diff] [blame] | 324 | typedef enum { |
| 325 | LLVMNotThreadLocal = 0, |
| 326 | LLVMGeneralDynamicTLSModel, |
| 327 | LLVMLocalDynamicTLSModel, |
| 328 | LLVMInitialExecTLSModel, |
| 329 | LLVMLocalExecTLSModel |
| 330 | } LLVMThreadLocalMode; |
| 331 | |
Carlo Kok | da0ac72 | 2013-04-23 13:45:37 +0000 | [diff] [blame] | 332 | typedef enum { |
Carlo Kok | 8c6719b | 2013-04-23 13:21:19 +0000 | [diff] [blame] | 333 | LLVMAtomicOrderingNotAtomic = 0, /**< A load or store which is not atomic */ |
| 334 | LLVMAtomicOrderingUnordered = 1, /**< Lowest level of atomicity, guarantees |
| 335 | somewhat sane results, lock free. */ |
NAKAMURA Takumi | a3a8135 | 2013-10-23 17:56:29 +0000 | [diff] [blame] | 336 | LLVMAtomicOrderingMonotonic = 2, /**< guarantees that if you take all the |
| 337 | operations affecting a specific address, |
Carlo Kok | 8c6719b | 2013-04-23 13:21:19 +0000 | [diff] [blame] | 338 | a consistent ordering exists */ |
NAKAMURA Takumi | a3a8135 | 2013-10-23 17:56:29 +0000 | [diff] [blame] | 339 | LLVMAtomicOrderingAcquire = 4, /**< Acquire provides a barrier of the sort |
| 340 | necessary to acquire a lock to access other |
Carlo Kok | 8c6719b | 2013-04-23 13:21:19 +0000 | [diff] [blame] | 341 | memory with normal loads and stores. */ |
NAKAMURA Takumi | a3a8135 | 2013-10-23 17:56:29 +0000 | [diff] [blame] | 342 | LLVMAtomicOrderingRelease = 5, /**< Release is similar to Acquire, but with |
| 343 | a barrier of the sort necessary to release |
Carlo Kok | 8c6719b | 2013-04-23 13:21:19 +0000 | [diff] [blame] | 344 | a lock. */ |
NAKAMURA Takumi | a3a8135 | 2013-10-23 17:56:29 +0000 | [diff] [blame] | 345 | LLVMAtomicOrderingAcquireRelease = 6, /**< provides both an Acquire and a |
| 346 | Release barrier (for fences and |
Carlo Kok | 8c6719b | 2013-04-23 13:21:19 +0000 | [diff] [blame] | 347 | operations which both read and write |
| 348 | memory). */ |
NAKAMURA Takumi | a3a8135 | 2013-10-23 17:56:29 +0000 | [diff] [blame] | 349 | LLVMAtomicOrderingSequentiallyConsistent = 7 /**< provides Acquire semantics |
| 350 | for loads and Release |
| 351 | semantics for stores. |
| 352 | Additionally, it guarantees |
| 353 | that a total ordering exists |
| 354 | between all |
| 355 | SequentiallyConsistent |
Carlo Kok | 8c6719b | 2013-04-23 13:21:19 +0000 | [diff] [blame] | 356 | operations. */ |
Carlo Kok | da0ac72 | 2013-04-23 13:45:37 +0000 | [diff] [blame] | 357 | } LLVMAtomicOrdering; |
Carlo Kok | 8c6719b | 2013-04-23 13:21:19 +0000 | [diff] [blame] | 358 | |
Carlo Kok | da0ac72 | 2013-04-23 13:45:37 +0000 | [diff] [blame] | 359 | typedef enum { |
Carlo Kok | 8c6719b | 2013-04-23 13:21:19 +0000 | [diff] [blame] | 360 | LLVMAtomicRMWBinOpXchg, /**< Set the new value and return the one old */ |
| 361 | LLVMAtomicRMWBinOpAdd, /**< Add a value and return the old one */ |
| 362 | LLVMAtomicRMWBinOpSub, /**< Subtract a value and return the old one */ |
| 363 | LLVMAtomicRMWBinOpAnd, /**< And a value and return the old one */ |
| 364 | LLVMAtomicRMWBinOpNand, /**< Not-And a value and return the old one */ |
| 365 | LLVMAtomicRMWBinOpOr, /**< OR a value and return the old one */ |
| 366 | LLVMAtomicRMWBinOpXor, /**< Xor a value and return the old one */ |
| 367 | LLVMAtomicRMWBinOpMax, /**< Sets the value if it's greater than the |
NAKAMURA Takumi | a3a8135 | 2013-10-23 17:56:29 +0000 | [diff] [blame] | 368 | original using a signed comparison and return |
Carlo Kok | 8c6719b | 2013-04-23 13:21:19 +0000 | [diff] [blame] | 369 | the old one */ |
| 370 | LLVMAtomicRMWBinOpMin, /**< Sets the value if it's Smaller than the |
NAKAMURA Takumi | a3a8135 | 2013-10-23 17:56:29 +0000 | [diff] [blame] | 371 | original using a signed comparison and return |
Carlo Kok | 8c6719b | 2013-04-23 13:21:19 +0000 | [diff] [blame] | 372 | the old one */ |
| 373 | LLVMAtomicRMWBinOpUMax, /**< Sets the value if it's greater than the |
NAKAMURA Takumi | a3a8135 | 2013-10-23 17:56:29 +0000 | [diff] [blame] | 374 | original using an unsigned comparison and return |
Carlo Kok | 8c6719b | 2013-04-23 13:21:19 +0000 | [diff] [blame] | 375 | the old one */ |
Nick Lewycky | f57e968 | 2019-09-26 00:58:55 +0000 | [diff] [blame] | 376 | LLVMAtomicRMWBinOpUMin, /**< Sets the value if it's greater than the |
| 377 | original using an unsigned comparison and return |
| 378 | the old one */ |
| 379 | LLVMAtomicRMWBinOpFAdd, /**< Add a floating point value and return the |
| 380 | old one */ |
| 381 | LLVMAtomicRMWBinOpFSub /**< Subtract a floating point value and return the |
| 382 | old one */ |
Carlo Kok | da0ac72 | 2013-04-23 13:45:37 +0000 | [diff] [blame] | 383 | } LLVMAtomicRMWBinOp; |
Carlo Kok | 8c6719b | 2013-04-23 13:21:19 +0000 | [diff] [blame] | 384 | |
Tom Stellard | 1580dc7 | 2014-04-16 17:45:04 +0000 | [diff] [blame] | 385 | typedef enum { |
| 386 | LLVMDSError, |
| 387 | LLVMDSWarning, |
| 388 | LLVMDSRemark, |
| 389 | LLVMDSNote |
| 390 | } LLVMDiagnosticSeverity; |
| 391 | |
Robert Widmann | f108d57 | 2018-04-06 02:31:29 +0000 | [diff] [blame] | 392 | typedef enum { |
| 393 | LLVMInlineAsmDialectATT, |
| 394 | LLVMInlineAsmDialectIntel |
| 395 | } LLVMInlineAsmDialect; |
| 396 | |
Robert Widmann | bce36770 | 2018-05-14 08:09:00 +0000 | [diff] [blame] | 397 | typedef enum { |
| 398 | /** |
| 399 | * Emits an error if two values disagree, otherwise the resulting value is |
| 400 | * that of the operands. |
| 401 | * |
| 402 | * @see Module::ModFlagBehavior::Error |
| 403 | */ |
| 404 | LLVMModuleFlagBehaviorError, |
| 405 | /** |
| 406 | * Emits a warning if two values disagree. The result value will be the |
| 407 | * operand for the flag from the first module being linked. |
| 408 | * |
| 409 | * @see Module::ModFlagBehavior::Warning |
| 410 | */ |
| 411 | LLVMModuleFlagBehaviorWarning, |
| 412 | /** |
| 413 | * Adds a requirement that another module flag be present and have a |
| 414 | * specified value after linking is performed. The value must be a metadata |
| 415 | * pair, where the first element of the pair is the ID of the module flag |
| 416 | * to be restricted, and the second element of the pair is the value the |
| 417 | * module flag should be restricted to. This behavior can be used to |
| 418 | * restrict the allowable results (via triggering of an error) of linking |
| 419 | * IDs with the **Override** behavior. |
| 420 | * |
| 421 | * @see Module::ModFlagBehavior::Require |
| 422 | */ |
| 423 | LLVMModuleFlagBehaviorRequire, |
| 424 | /** |
| 425 | * Uses the specified value, regardless of the behavior or value of the |
| 426 | * other module. If both modules specify **Override**, but the values |
| 427 | * differ, an error will be emitted. |
| 428 | * |
| 429 | * @see Module::ModFlagBehavior::Override |
| 430 | */ |
| 431 | LLVMModuleFlagBehaviorOverride, |
| 432 | /** |
| 433 | * Appends the two values, which are required to be metadata nodes. |
| 434 | * |
| 435 | * @see Module::ModFlagBehavior::Append |
| 436 | */ |
| 437 | LLVMModuleFlagBehaviorAppend, |
| 438 | /** |
| 439 | * Appends the two values, which are required to be metadata |
| 440 | * nodes. However, duplicate entries in the second list are dropped |
| 441 | * during the append operation. |
| 442 | * |
| 443 | * @see Module::ModFlagBehavior::AppendUnique |
| 444 | */ |
| 445 | LLVMModuleFlagBehaviorAppendUnique, |
| 446 | } LLVMModuleFlagBehavior; |
| 447 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 448 | /** |
Amaury Sechet | 5db224e | 2016-06-12 06:17:24 +0000 | [diff] [blame] | 449 | * Attribute index are either LLVMAttributeReturnIndex, |
| 450 | * LLVMAttributeFunctionIndex or a parameter number from 1 to N. |
| 451 | */ |
| 452 | enum { |
| 453 | LLVMAttributeReturnIndex = 0U, |
| 454 | // ISO C restricts enumerator values to range of 'int' |
| 455 | // (4294967295 is too large) |
| 456 | // LLVMAttributeFunctionIndex = ~0U, |
| 457 | LLVMAttributeFunctionIndex = -1, |
| 458 | }; |
| 459 | |
| 460 | typedef unsigned LLVMAttributeIndex; |
| 461 | |
| 462 | /** |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 463 | * @} |
| 464 | */ |
| 465 | |
Nick Lewycky | 0db2654 | 2011-05-15 07:20:34 +0000 | [diff] [blame] | 466 | void LLVMInitializeCore(LLVMPassRegistryRef R); |
| 467 | |
Duncan Sands | 1cba0a8 | 2013-02-17 16:35:51 +0000 | [diff] [blame] | 468 | /** Deallocate and destroy all ManagedStatic variables. |
| 469 | @see llvm::llvm_shutdown |
| 470 | @see ManagedStatic */ |
Benjamin Kramer | 325ec89 | 2013-10-23 16:57:34 +0000 | [diff] [blame] | 471 | void LLVMShutdown(void); |
Duncan Sands | 1cba0a8 | 2013-02-17 16:35:51 +0000 | [diff] [blame] | 472 | |
Gordon Henriksen | 34eb6d8 | 2007-12-19 22:30:40 +0000 | [diff] [blame] | 473 | /*===-- Error handling ----------------------------------------------------===*/ |
| 474 | |
Filip Pizlo | 3fdbaff | 2013-05-22 02:46:43 +0000 | [diff] [blame] | 475 | char *LLVMCreateMessage(const char *Message); |
Gordon Henriksen | 34eb6d8 | 2007-12-19 22:30:40 +0000 | [diff] [blame] | 476 | void LLVMDisposeMessage(char *Message); |
| 477 | |
Filip Pizlo | 9f50ccd | 2013-11-03 00:29:47 +0000 | [diff] [blame] | 478 | /** |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 479 | * @defgroup LLVMCCoreContext Contexts |
| 480 | * |
| 481 | * Contexts are execution states for the core LLVM IR system. |
| 482 | * |
| 483 | * Most types are tied to a context instance. Multiple contexts can |
| 484 | * exist simultaneously. A single context is not thread safe. However, |
| 485 | * different contexts can execute on different threads simultaneously. |
| 486 | * |
| 487 | * @{ |
| 488 | */ |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 489 | |
Tom Stellard | 1580dc7 | 2014-04-16 17:45:04 +0000 | [diff] [blame] | 490 | typedef void (*LLVMDiagnosticHandler)(LLVMDiagnosticInfoRef, void *); |
Juergen Ributzka | 34390c7 | 2014-05-16 02:33:15 +0000 | [diff] [blame] | 491 | typedef void (*LLVMYieldCallback)(LLVMContextRef, void *); |
Tom Stellard | 1580dc7 | 2014-04-16 17:45:04 +0000 | [diff] [blame] | 492 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 493 | /** |
| 494 | * Create a new context. |
| 495 | * |
| 496 | * Every call to this function should be paired with a call to |
| 497 | * LLVMContextDispose() or the context will leak memory. |
| 498 | */ |
Erick Tryzelaar | f34cb0c | 2009-08-30 23:38:06 +0000 | [diff] [blame] | 499 | LLVMContextRef LLVMContextCreate(void); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 500 | |
| 501 | /** |
| 502 | * Obtain the global context instance. |
| 503 | */ |
Erick Tryzelaar | f34cb0c | 2009-08-30 23:38:06 +0000 | [diff] [blame] | 504 | LLVMContextRef LLVMGetGlobalContext(void); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 505 | |
| 506 | /** |
Tom Stellard | 1580dc7 | 2014-04-16 17:45:04 +0000 | [diff] [blame] | 507 | * Set the diagnostic handler for this context. |
| 508 | */ |
| 509 | void LLVMContextSetDiagnosticHandler(LLVMContextRef C, |
| 510 | LLVMDiagnosticHandler Handler, |
| 511 | void *DiagnosticContext); |
| 512 | |
| 513 | /** |
Jeroen Ketema | ad659c3 | 2016-04-08 09:19:02 +0000 | [diff] [blame] | 514 | * Get the diagnostic handler of this context. |
| 515 | */ |
| 516 | LLVMDiagnosticHandler LLVMContextGetDiagnosticHandler(LLVMContextRef C); |
| 517 | |
| 518 | /** |
| 519 | * Get the diagnostic context of this context. |
| 520 | */ |
| 521 | void *LLVMContextGetDiagnosticContext(LLVMContextRef C); |
| 522 | |
| 523 | /** |
Juergen Ributzka | 34390c7 | 2014-05-16 02:33:15 +0000 | [diff] [blame] | 524 | * Set the yield callback function for this context. |
| 525 | * |
| 526 | * @see LLVMContext::setYieldCallback() |
| 527 | */ |
| 528 | void LLVMContextSetYieldCallback(LLVMContextRef C, LLVMYieldCallback Callback, |
| 529 | void *OpaqueHandle); |
| 530 | |
| 531 | /** |
Robert Widmann | 5d1dfa3 | 2019-01-01 18:56:51 +0000 | [diff] [blame] | 532 | * Retrieve whether the given context is set to discard all value names. |
| 533 | * |
| 534 | * @see LLVMContext::shouldDiscardValueNames() |
| 535 | */ |
Robert Widmann | db5b537 | 2019-01-01 19:03:37 +0000 | [diff] [blame] | 536 | LLVMBool LLVMContextShouldDiscardValueNames(LLVMContextRef C); |
Robert Widmann | 5d1dfa3 | 2019-01-01 18:56:51 +0000 | [diff] [blame] | 537 | |
| 538 | /** |
| 539 | * Set whether the given context discards all value names. |
| 540 | * |
| 541 | * If true, only the names of GlobalValue objects will be available in the IR. |
| 542 | * This can be used to save memory and runtime, especially in release mode. |
| 543 | * |
| 544 | * @see LLVMContext::setDiscardValueNames() |
| 545 | */ |
Robert Widmann | db5b537 | 2019-01-01 19:03:37 +0000 | [diff] [blame] | 546 | void LLVMContextSetDiscardValueNames(LLVMContextRef C, LLVMBool Discard); |
Robert Widmann | 5d1dfa3 | 2019-01-01 18:56:51 +0000 | [diff] [blame] | 547 | |
| 548 | /** |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 549 | * Destroy a context instance. |
| 550 | * |
| 551 | * This should be called for every call to LLVMContextCreate() or memory |
| 552 | * will be leaked. |
| 553 | */ |
Owen Anderson | 6773d38 | 2009-07-01 16:58:40 +0000 | [diff] [blame] | 554 | void LLVMContextDispose(LLVMContextRef C); |
| 555 | |
Tom Stellard | 1580dc7 | 2014-04-16 17:45:04 +0000 | [diff] [blame] | 556 | /** |
| 557 | * Return a string representation of the DiagnosticInfo. Use |
| 558 | * LLVMDisposeMessage to free the string. |
| 559 | * |
| 560 | * @see DiagnosticInfo::print() |
| 561 | */ |
| 562 | char *LLVMGetDiagInfoDescription(LLVMDiagnosticInfoRef DI); |
| 563 | |
| 564 | /** |
| 565 | * Return an enum LLVMDiagnosticSeverity. |
| 566 | * |
| 567 | * @see DiagnosticInfo::getSeverity() |
| 568 | */ |
| 569 | LLVMDiagnosticSeverity LLVMGetDiagInfoSeverity(LLVMDiagnosticInfoRef DI); |
| 570 | |
Amaury Sechet | 56f056c | 2016-04-04 22:00:25 +0000 | [diff] [blame] | 571 | unsigned LLVMGetMDKindIDInContext(LLVMContextRef C, const char *Name, |
Erick Tryzelaar | d8531fa | 2010-02-28 09:45:59 +0000 | [diff] [blame] | 572 | unsigned SLen); |
Amaury Sechet | 56f056c | 2016-04-04 22:00:25 +0000 | [diff] [blame] | 573 | unsigned LLVMGetMDKindID(const char *Name, unsigned SLen); |
Erick Tryzelaar | d8531fa | 2010-02-28 09:45:59 +0000 | [diff] [blame] | 574 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 575 | /** |
Amaury Sechet | 5db224e | 2016-06-12 06:17:24 +0000 | [diff] [blame] | 576 | * Return an unique id given the name of a enum attribute, |
Amaury Sechet | 60b3145 | 2016-04-20 01:02:12 +0000 | [diff] [blame] | 577 | * or 0 if no attribute by that name exists. |
| 578 | * |
| 579 | * See http://llvm.org/docs/LangRef.html#parameter-attributes |
| 580 | * and http://llvm.org/docs/LangRef.html#function-attributes |
| 581 | * for the list of available attributes. |
| 582 | * |
| 583 | * NB: Attribute names and/or id are subject to change without |
| 584 | * going through the C API deprecation cycle. |
| 585 | */ |
Amaury Sechet | 5db224e | 2016-06-12 06:17:24 +0000 | [diff] [blame] | 586 | unsigned LLVMGetEnumAttributeKindForName(const char *Name, size_t SLen); |
Amaury Sechet | 48b0665 | 2016-06-12 07:56:21 +0000 | [diff] [blame] | 587 | unsigned LLVMGetLastEnumAttributeKind(void); |
Amaury Sechet | 5db224e | 2016-06-12 06:17:24 +0000 | [diff] [blame] | 588 | |
| 589 | /** |
| 590 | * Create an enum attribute. |
| 591 | */ |
| 592 | LLVMAttributeRef LLVMCreateEnumAttribute(LLVMContextRef C, unsigned KindID, |
| 593 | uint64_t Val); |
| 594 | |
| 595 | /** |
| 596 | * Get the unique id corresponding to the enum attribute |
| 597 | * passed as argument. |
| 598 | */ |
| 599 | unsigned LLVMGetEnumAttributeKind(LLVMAttributeRef A); |
| 600 | |
| 601 | /** |
| 602 | * Get the enum attribute's value. 0 is returned if none exists. |
| 603 | */ |
| 604 | uint64_t LLVMGetEnumAttributeValue(LLVMAttributeRef A); |
| 605 | |
| 606 | /** |
| 607 | * Create a string attribute. |
| 608 | */ |
| 609 | LLVMAttributeRef LLVMCreateStringAttribute(LLVMContextRef C, |
| 610 | const char *K, unsigned KLength, |
| 611 | const char *V, unsigned VLength); |
| 612 | |
| 613 | /** |
| 614 | * Get the string attribute's kind. |
| 615 | */ |
| 616 | const char *LLVMGetStringAttributeKind(LLVMAttributeRef A, unsigned *Length); |
| 617 | |
| 618 | /** |
| 619 | * Get the string attribute's value. |
| 620 | */ |
| 621 | const char *LLVMGetStringAttributeValue(LLVMAttributeRef A, unsigned *Length); |
| 622 | |
| 623 | /** |
| 624 | * Check for the different types of attributes. |
| 625 | */ |
| 626 | LLVMBool LLVMIsEnumAttribute(LLVMAttributeRef A); |
| 627 | LLVMBool LLVMIsStringAttribute(LLVMAttributeRef A); |
Amaury Sechet | 60b3145 | 2016-04-20 01:02:12 +0000 | [diff] [blame] | 628 | |
| 629 | /** |
Nick Lewycky | fe43168 | 2020-11-30 11:34:12 -0800 | [diff] [blame] | 630 | * Obtain a Type from a context by its registered name. |
| 631 | */ |
| 632 | LLVMTypeRef LLVMGetTypeByName2(LLVMContextRef C, const char *Name); |
| 633 | |
| 634 | /** |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 635 | * @} |
| 636 | */ |
| 637 | |
Gregory Szorc | 52d2660 | 2012-03-21 07:28:27 +0000 | [diff] [blame] | 638 | /** |
| 639 | * @defgroup LLVMCCoreModule Modules |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 640 | * |
Daniel Dunbar | 06b9f9e | 2013-08-16 23:30:19 +0000 | [diff] [blame] | 641 | * Modules represent the top-level structure in an LLVM program. An LLVM |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 642 | * module is effectively a translation unit or a collection of |
| 643 | * translation units merged together. |
| 644 | * |
| 645 | * @{ |
| 646 | */ |
| 647 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 648 | /** |
| 649 | * Create a new, empty module in the global context. |
| 650 | * |
| 651 | * This is equivalent to calling LLVMModuleCreateWithNameInContext with |
| 652 | * LLVMGetGlobalContext() as the context parameter. |
| 653 | * |
| 654 | * Every invocation should be paired with LLVMDisposeModule() or memory |
| 655 | * will be leaked. |
| 656 | */ |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 657 | LLVMModuleRef LLVMModuleCreateWithName(const char *ModuleID); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 658 | |
| 659 | /** |
| 660 | * Create a new, empty module in a specific context. |
| 661 | * |
| 662 | * Every invocation should be paired with LLVMDisposeModule() or memory |
| 663 | * will be leaked. |
| 664 | */ |
Owen Anderson | 31d44e4 | 2009-07-02 07:17:57 +0000 | [diff] [blame] | 665 | LLVMModuleRef LLVMModuleCreateWithNameInContext(const char *ModuleID, |
| 666 | LLVMContextRef C); |
Tom Stellard | 0a4e9a3 | 2014-10-01 17:14:57 +0000 | [diff] [blame] | 667 | /** |
| 668 | * Return an exact copy of the specified module. |
| 669 | */ |
| 670 | LLVMModuleRef LLVMCloneModule(LLVMModuleRef M); |
Gordon Henriksen | a49d435 | 2008-03-07 19:13:06 +0000 | [diff] [blame] | 671 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 672 | /** |
| 673 | * Destroy a module instance. |
| 674 | * |
| 675 | * This must be called for every created module or memory will be |
| 676 | * leaked. |
| 677 | */ |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 678 | void LLVMDisposeModule(LLVMModuleRef M); |
| 679 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 680 | /** |
Peter Zotov | 0a2fa0a | 2016-04-05 13:56:59 +0000 | [diff] [blame] | 681 | * Obtain the identifier of a module. |
| 682 | * |
| 683 | * @param M Module to obtain identifier of |
| 684 | * @param Len Out parameter which holds the length of the returned string. |
| 685 | * @return The identifier of M. |
| 686 | * @see Module::getModuleIdentifier() |
| 687 | */ |
| 688 | const char *LLVMGetModuleIdentifier(LLVMModuleRef M, size_t *Len); |
| 689 | |
| 690 | /** |
| 691 | * Set the identifier of a module to a string Ident with length Len. |
| 692 | * |
| 693 | * @param M The module to set identifier |
| 694 | * @param Ident The string to set M's identifier to |
| 695 | * @param Len Length of Ident |
| 696 | * @see Module::setModuleIdentifier() |
| 697 | */ |
| 698 | void LLVMSetModuleIdentifier(LLVMModuleRef M, const char *Ident, size_t Len); |
| 699 | |
| 700 | /** |
Robert Widmann | 490a580 | 2018-01-30 21:34:29 +0000 | [diff] [blame] | 701 | * Obtain the module's original source file name. |
| 702 | * |
| 703 | * @param M Module to obtain the name of |
| 704 | * @param Len Out parameter which holds the length of the returned string |
| 705 | * @return The original source file name of M |
| 706 | * @see Module::getSourceFileName() |
| 707 | */ |
| 708 | const char *LLVMGetSourceFileName(LLVMModuleRef M, size_t *Len); |
| 709 | |
| 710 | /** |
| 711 | * Set the original source file name of a module to a string Name with length |
| 712 | * Len. |
| 713 | * |
| 714 | * @param M The module to set the source file name of |
| 715 | * @param Name The string to set M's source file name to |
| 716 | * @param Len Length of Name |
| 717 | * @see Module::setSourceFileName() |
| 718 | */ |
| 719 | void LLVMSetSourceFileName(LLVMModuleRef M, const char *Name, size_t Len); |
| 720 | |
| 721 | /** |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 722 | * Obtain the data layout for a module. |
| 723 | * |
Amaury Sechet | f3549c4 | 2016-02-16 00:23:52 +0000 | [diff] [blame] | 724 | * @see Module::getDataLayoutStr() |
| 725 | * |
| 726 | * LLVMGetDataLayout is DEPRECATED, as the name is not only incorrect, |
| 727 | * but match the name of another method on the module. Prefer the use |
| 728 | * of LLVMGetDataLayoutStr, which is not ambiguous. |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 729 | */ |
Amaury Sechet | f3549c4 | 2016-02-16 00:23:52 +0000 | [diff] [blame] | 730 | const char *LLVMGetDataLayoutStr(LLVMModuleRef M); |
Gordon Henriksen | 05568bb | 2007-12-27 20:13:47 +0000 | [diff] [blame] | 731 | const char *LLVMGetDataLayout(LLVMModuleRef M); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 732 | |
| 733 | /** |
| 734 | * Set the data layout for a module. |
| 735 | * |
| 736 | * @see Module::setDataLayout() |
| 737 | */ |
Amaury Sechet | 6ada31c | 2016-02-15 23:40:06 +0000 | [diff] [blame] | 738 | void LLVMSetDataLayout(LLVMModuleRef M, const char *DataLayoutStr); |
Gordon Henriksen | 05568bb | 2007-12-27 20:13:47 +0000 | [diff] [blame] | 739 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 740 | /** |
| 741 | * Obtain the target triple for a module. |
| 742 | * |
| 743 | * @see Module::getTargetTriple() |
| 744 | */ |
Gordon Henriksen | 05568bb | 2007-12-27 20:13:47 +0000 | [diff] [blame] | 745 | const char *LLVMGetTarget(LLVMModuleRef M); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 746 | |
| 747 | /** |
| 748 | * Set the target triple for a module. |
| 749 | * |
| 750 | * @see Module::setTargetTriple() |
| 751 | */ |
Gordon Henriksen | 05568bb | 2007-12-27 20:13:47 +0000 | [diff] [blame] | 752 | void LLVMSetTarget(LLVMModuleRef M, const char *Triple); |
| 753 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 754 | /** |
Robert Widmann | bce36770 | 2018-05-14 08:09:00 +0000 | [diff] [blame] | 755 | * Returns the module flags as an array of flag-key-value triples. The caller |
| 756 | * is responsible for freeing this array by calling |
| 757 | * \c LLVMDisposeModuleFlagsMetadata. |
| 758 | * |
| 759 | * @see Module::getModuleFlagsMetadata() |
| 760 | */ |
| 761 | LLVMModuleFlagEntry *LLVMCopyModuleFlagsMetadata(LLVMModuleRef M, size_t *Len); |
| 762 | |
| 763 | /** |
| 764 | * Destroys module flags metadata entries. |
| 765 | */ |
| 766 | void LLVMDisposeModuleFlagsMetadata(LLVMModuleFlagEntry *Entries); |
| 767 | |
| 768 | /** |
| 769 | * Returns the flag behavior for a module flag entry at a specific index. |
| 770 | * |
| 771 | * @see Module::ModuleFlagEntry::Behavior |
| 772 | */ |
| 773 | LLVMModuleFlagBehavior |
| 774 | LLVMModuleFlagEntriesGetFlagBehavior(LLVMModuleFlagEntry *Entries, |
| 775 | unsigned Index); |
| 776 | |
| 777 | /** |
| 778 | * Returns the key for a module flag entry at a specific index. |
| 779 | * |
| 780 | * @see Module::ModuleFlagEntry::Key |
| 781 | */ |
| 782 | const char *LLVMModuleFlagEntriesGetKey(LLVMModuleFlagEntry *Entries, |
| 783 | unsigned Index, size_t *Len); |
| 784 | |
| 785 | /** |
| 786 | * Returns the metadata for a module flag entry at a specific index. |
| 787 | * |
| 788 | * @see Module::ModuleFlagEntry::Val |
| 789 | */ |
| 790 | LLVMMetadataRef LLVMModuleFlagEntriesGetMetadata(LLVMModuleFlagEntry *Entries, |
| 791 | unsigned Index); |
| 792 | |
| 793 | /** |
| 794 | * Add a module-level flag to the module-level flags metadata if it doesn't |
| 795 | * already exist. |
| 796 | * |
| 797 | * @see Module::getModuleFlag() |
| 798 | */ |
| 799 | LLVMMetadataRef LLVMGetModuleFlag(LLVMModuleRef M, |
| 800 | const char *Key, size_t KeyLen); |
| 801 | |
| 802 | /** |
| 803 | * Add a module-level flag to the module-level flags metadata if it doesn't |
| 804 | * already exist. |
| 805 | * |
| 806 | * @see Module::addModuleFlag() |
| 807 | */ |
| 808 | void LLVMAddModuleFlag(LLVMModuleRef M, LLVMModuleFlagBehavior Behavior, |
| 809 | const char *Key, size_t KeyLen, |
| 810 | LLVMMetadataRef Val); |
| 811 | |
| 812 | /** |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 813 | * Dump a representation of a module to stderr. |
| 814 | * |
| 815 | * @see Module::dump() |
| 816 | */ |
Gordon Henriksen | 6c6075e | 2008-03-14 23:58:56 +0000 | [diff] [blame] | 817 | void LLVMDumpModule(LLVMModuleRef M); |
| 818 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 819 | /** |
Hans Wennborg | b7ef2fe | 2012-05-09 16:54:17 +0000 | [diff] [blame] | 820 | * Print a representation of a module to a file. The ErrorMessage needs to be |
| 821 | * disposed with LLVMDisposeMessage. Returns 0 on success, 1 otherwise. |
| 822 | * |
| 823 | * @see Module::print() |
| 824 | */ |
| 825 | LLVMBool LLVMPrintModuleToFile(LLVMModuleRef M, const char *Filename, |
| 826 | char **ErrorMessage); |
| 827 | |
| 828 | /** |
Anders Waldenborg | 84355db | 2013-10-16 18:00:54 +0000 | [diff] [blame] | 829 | * Return a string representation of the module. Use |
| 830 | * LLVMDisposeMessage to free the string. |
| 831 | * |
| 832 | * @see Module::print() |
| 833 | */ |
| 834 | char *LLVMPrintModuleToString(LLVMModuleRef M); |
| 835 | |
| 836 | /** |
Robert Widmann | f108d57 | 2018-04-06 02:31:29 +0000 | [diff] [blame] | 837 | * Get inline assembly for a module. |
| 838 | * |
| 839 | * @see Module::getModuleInlineAsm() |
| 840 | */ |
| 841 | const char *LLVMGetModuleInlineAsm(LLVMModuleRef M, size_t *Len); |
| 842 | |
| 843 | /** |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 844 | * Set inline assembly for a module. |
| 845 | * |
| 846 | * @see Module::setModuleInlineAsm() |
| 847 | */ |
Robert Widmann | f108d57 | 2018-04-06 02:31:29 +0000 | [diff] [blame] | 848 | void LLVMSetModuleInlineAsm2(LLVMModuleRef M, const char *Asm, size_t Len); |
| 849 | |
| 850 | /** |
| 851 | * Append inline assembly to a module. |
| 852 | * |
| 853 | * @see Module::appendModuleInlineAsm() |
| 854 | */ |
| 855 | void LLVMAppendModuleInlineAsm(LLVMModuleRef M, const char *Asm, size_t Len); |
| 856 | |
| 857 | /** |
| 858 | * Create the specified uniqued inline asm string. |
| 859 | * |
| 860 | * @see InlineAsm::get() |
| 861 | */ |
| 862 | LLVMValueRef LLVMGetInlineAsm(LLVMTypeRef Ty, |
| 863 | char *AsmString, size_t AsmStringSize, |
| 864 | char *Constraints, size_t ConstraintsSize, |
| 865 | LLVMBool HasSideEffects, LLVMBool IsAlignStack, |
| 866 | LLVMInlineAsmDialect Dialect); |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 867 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 868 | /** |
| 869 | * Obtain the context to which this module is associated. |
| 870 | * |
| 871 | * @see Module::getContext() |
| 872 | */ |
Chris Lattner | a7e04b0 | 2010-11-28 20:03:44 +0000 | [diff] [blame] | 873 | LLVMContextRef LLVMGetModuleContext(LLVMModuleRef M); |
| 874 | |
Nick Lewycky | fe43168 | 2020-11-30 11:34:12 -0800 | [diff] [blame] | 875 | /** Deprecated: Use LLVMGetTypeByName2 instead. */ |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 876 | LLVMTypeRef LLVMGetTypeByName(LLVMModuleRef M, const char *Name); |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 877 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 878 | /** |
Robert Widmann | 0a35b76 | 2018-08-30 17:09:43 +0000 | [diff] [blame] | 879 | * Obtain an iterator to the first NamedMDNode in a Module. |
| 880 | * |
| 881 | * @see llvm::Module::named_metadata_begin() |
| 882 | */ |
| 883 | LLVMNamedMDNodeRef LLVMGetFirstNamedMetadata(LLVMModuleRef M); |
| 884 | |
| 885 | /** |
| 886 | * Obtain an iterator to the last NamedMDNode in a Module. |
| 887 | * |
| 888 | * @see llvm::Module::named_metadata_end() |
| 889 | */ |
| 890 | LLVMNamedMDNodeRef LLVMGetLastNamedMetadata(LLVMModuleRef M); |
| 891 | |
| 892 | /** |
| 893 | * Advance a NamedMDNode iterator to the next NamedMDNode. |
| 894 | * |
| 895 | * Returns NULL if the iterator was already at the end and there are no more |
| 896 | * named metadata nodes. |
| 897 | */ |
| 898 | LLVMNamedMDNodeRef LLVMGetNextNamedMetadata(LLVMNamedMDNodeRef NamedMDNode); |
| 899 | |
| 900 | /** |
| 901 | * Decrement a NamedMDNode iterator to the previous NamedMDNode. |
| 902 | * |
| 903 | * Returns NULL if the iterator was already at the beginning and there are |
| 904 | * no previous named metadata nodes. |
| 905 | */ |
| 906 | LLVMNamedMDNodeRef LLVMGetPreviousNamedMetadata(LLVMNamedMDNodeRef NamedMDNode); |
| 907 | |
| 908 | /** |
| 909 | * Retrieve a NamedMDNode with the given name, returning NULL if no such |
| 910 | * node exists. |
| 911 | * |
| 912 | * @see llvm::Module::getNamedMetadata() |
| 913 | */ |
| 914 | LLVMNamedMDNodeRef LLVMGetNamedMetadata(LLVMModuleRef M, |
| 915 | const char *Name, size_t NameLen); |
| 916 | |
| 917 | /** |
| 918 | * Retrieve a NamedMDNode with the given name, creating a new node if no such |
| 919 | * node exists. |
| 920 | * |
| 921 | * @see llvm::Module::getOrInsertNamedMetadata() |
| 922 | */ |
| 923 | LLVMNamedMDNodeRef LLVMGetOrInsertNamedMetadata(LLVMModuleRef M, |
| 924 | const char *Name, |
| 925 | size_t NameLen); |
| 926 | |
| 927 | /** |
| 928 | * Retrieve the name of a NamedMDNode. |
| 929 | * |
| 930 | * @see llvm::NamedMDNode::getName() |
| 931 | */ |
| 932 | const char *LLVMGetNamedMetadataName(LLVMNamedMDNodeRef NamedMD, |
| 933 | size_t *NameLen); |
| 934 | |
| 935 | /** |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 936 | * Obtain the number of operands for named metadata in a module. |
| 937 | * |
| 938 | * @see llvm::Module::getNamedMetadata() |
| 939 | */ |
Amaury Sechet | b130f43 | 2016-04-23 00:12:45 +0000 | [diff] [blame] | 940 | unsigned LLVMGetNamedMetadataNumOperands(LLVMModuleRef M, const char *Name); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 941 | |
| 942 | /** |
| 943 | * Obtain the named metadata operands for a module. |
| 944 | * |
| 945 | * The passed LLVMValueRef pointer should refer to an array of |
| 946 | * LLVMValueRef at least LLVMGetNamedMetadataNumOperands long. This |
| 947 | * array will be populated with the LLVMValueRef instances. Each |
| 948 | * instance corresponds to a llvm::MDNode. |
| 949 | * |
| 950 | * @see llvm::Module::getNamedMetadata() |
| 951 | * @see llvm::MDNode::getOperand() |
| 952 | */ |
Amaury Sechet | b130f43 | 2016-04-23 00:12:45 +0000 | [diff] [blame] | 953 | void LLVMGetNamedMetadataOperands(LLVMModuleRef M, const char *Name, |
| 954 | LLVMValueRef *Dest); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 955 | |
| 956 | /** |
| 957 | * Add an operand to named metadata. |
| 958 | * |
| 959 | * @see llvm::Module::getNamedMetadata() |
| 960 | * @see llvm::MDNode::addOperand() |
| 961 | */ |
Amaury Sechet | b130f43 | 2016-04-23 00:12:45 +0000 | [diff] [blame] | 962 | void LLVMAddNamedMetadataOperand(LLVMModuleRef M, const char *Name, |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 963 | LLVMValueRef Val); |
| 964 | |
Gregory Szorc | 52d2660 | 2012-03-21 07:28:27 +0000 | [diff] [blame] | 965 | /** |
Saleem Abdulrasool | 0d1cbcc | 2018-10-10 23:53:12 +0000 | [diff] [blame] | 966 | * Return the directory of the debug location for this value, which must be |
| 967 | * an llvm::Instruction, llvm::GlobalVariable, or llvm::Function. |
| 968 | * |
| 969 | * @see llvm::Instruction::getDebugLoc() |
| 970 | * @see llvm::GlobalVariable::getDebugInfo() |
| 971 | * @see llvm::Function::getSubprogram() |
| 972 | */ |
| 973 | const char *LLVMGetDebugLocDirectory(LLVMValueRef Val, unsigned *Length); |
| 974 | |
| 975 | /** |
| 976 | * Return the filename of the debug location for this value, which must be |
| 977 | * an llvm::Instruction, llvm::GlobalVariable, or llvm::Function. |
| 978 | * |
| 979 | * @see llvm::Instruction::getDebugLoc() |
| 980 | * @see llvm::GlobalVariable::getDebugInfo() |
| 981 | * @see llvm::Function::getSubprogram() |
| 982 | */ |
| 983 | const char *LLVMGetDebugLocFilename(LLVMValueRef Val, unsigned *Length); |
| 984 | |
| 985 | /** |
| 986 | * Return the line number of the debug location for this value, which must be |
| 987 | * an llvm::Instruction, llvm::GlobalVariable, or llvm::Function. |
| 988 | * |
| 989 | * @see llvm::Instruction::getDebugLoc() |
| 990 | * @see llvm::GlobalVariable::getDebugInfo() |
| 991 | * @see llvm::Function::getSubprogram() |
| 992 | */ |
| 993 | unsigned LLVMGetDebugLocLine(LLVMValueRef Val); |
| 994 | |
| 995 | /** |
| 996 | * Return the column number of the debug location for this value, which must be |
| 997 | * an llvm::Instruction. |
| 998 | * |
| 999 | * @see llvm::Instruction::getDebugLoc() |
| 1000 | */ |
| 1001 | unsigned LLVMGetDebugLocColumn(LLVMValueRef Val); |
| 1002 | |
| 1003 | /** |
Gregory Szorc | 52d2660 | 2012-03-21 07:28:27 +0000 | [diff] [blame] | 1004 | * Add a function to a module under a specified name. |
| 1005 | * |
| 1006 | * @see llvm::Function::Create() |
| 1007 | */ |
| 1008 | LLVMValueRef LLVMAddFunction(LLVMModuleRef M, const char *Name, |
| 1009 | LLVMTypeRef FunctionTy); |
| 1010 | |
| 1011 | /** |
| 1012 | * Obtain a Function value from a Module by its name. |
| 1013 | * |
| 1014 | * The returned value corresponds to a llvm::Function value. |
| 1015 | * |
| 1016 | * @see llvm::Module::getFunction() |
| 1017 | */ |
| 1018 | LLVMValueRef LLVMGetNamedFunction(LLVMModuleRef M, const char *Name); |
| 1019 | |
| 1020 | /** |
| 1021 | * Obtain an iterator to the first Function in a Module. |
| 1022 | * |
| 1023 | * @see llvm::Module::begin() |
| 1024 | */ |
| 1025 | LLVMValueRef LLVMGetFirstFunction(LLVMModuleRef M); |
| 1026 | |
| 1027 | /** |
| 1028 | * Obtain an iterator to the last Function in a Module. |
| 1029 | * |
| 1030 | * @see llvm::Module::end() |
| 1031 | */ |
| 1032 | LLVMValueRef LLVMGetLastFunction(LLVMModuleRef M); |
| 1033 | |
| 1034 | /** |
| 1035 | * Advance a Function iterator to the next Function. |
| 1036 | * |
| 1037 | * Returns NULL if the iterator was already at the end and there are no more |
| 1038 | * functions. |
| 1039 | */ |
| 1040 | LLVMValueRef LLVMGetNextFunction(LLVMValueRef Fn); |
| 1041 | |
| 1042 | /** |
| 1043 | * Decrement a Function iterator to the previous Function. |
| 1044 | * |
| 1045 | * Returns NULL if the iterator was already at the beginning and there are |
| 1046 | * no previous functions. |
| 1047 | */ |
| 1048 | LLVMValueRef LLVMGetPreviousFunction(LLVMValueRef Fn); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1049 | |
Robert Widmann | f108d57 | 2018-04-06 02:31:29 +0000 | [diff] [blame] | 1050 | /** Deprecated: Use LLVMSetModuleInlineAsm2 instead. */ |
| 1051 | void LLVMSetModuleInlineAsm(LLVMModuleRef M, const char *Asm); |
| 1052 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1053 | /** |
| 1054 | * @} |
| 1055 | */ |
| 1056 | |
| 1057 | /** |
| 1058 | * @defgroup LLVMCCoreType Types |
| 1059 | * |
| 1060 | * Types represent the type of a value. |
| 1061 | * |
| 1062 | * Types are associated with a context instance. The context internally |
| 1063 | * deduplicates types so there is only 1 instance of a specific type |
| 1064 | * alive at a time. In other words, a unique type is shared among all |
| 1065 | * consumers within a context. |
| 1066 | * |
| 1067 | * A Type in the C API corresponds to llvm::Type. |
| 1068 | * |
| 1069 | * Types have the following hierarchy: |
| 1070 | * |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 1071 | * types: |
| 1072 | * integer type |
| 1073 | * real type |
| 1074 | * function type |
| 1075 | * sequence types: |
| 1076 | * array type |
| 1077 | * pointer type |
| 1078 | * vector type |
| 1079 | * void type |
| 1080 | * label type |
| 1081 | * opaque type |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1082 | * |
| 1083 | * @{ |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 1084 | */ |
| 1085 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1086 | /** |
| 1087 | * Obtain the enumerated type of a Type instance. |
| 1088 | * |
| 1089 | * @see llvm::Type:getTypeID() |
| 1090 | */ |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 1091 | LLVMTypeKind LLVMGetTypeKind(LLVMTypeRef Ty); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1092 | |
| 1093 | /** |
| 1094 | * Whether the type has a known size. |
| 1095 | * |
| 1096 | * Things that don't have a size are abstract types, labels, and void.a |
| 1097 | * |
| 1098 | * @see llvm::Type::isSized() |
| 1099 | */ |
Torok Edwin | 1cd9ade | 2011-10-06 12:13:28 +0000 | [diff] [blame] | 1100 | LLVMBool LLVMTypeIsSized(LLVMTypeRef Ty); |
Gordon Henriksen | a49d435 | 2008-03-07 19:13:06 +0000 | [diff] [blame] | 1101 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1102 | /** |
| 1103 | * Obtain the context to which this type instance is associated. |
| 1104 | * |
| 1105 | * @see llvm::Type::getContext() |
| 1106 | */ |
Erick Tryzelaar | 262332f | 2009-08-14 00:01:31 +0000 | [diff] [blame] | 1107 | LLVMContextRef LLVMGetTypeContext(LLVMTypeRef Ty); |
| 1108 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1109 | /** |
Anders Waldenborg | b822cff | 2013-10-16 21:30:25 +0000 | [diff] [blame] | 1110 | * Dump a representation of a type to stderr. |
| 1111 | * |
| 1112 | * @see llvm::Type::dump() |
| 1113 | */ |
| 1114 | void LLVMDumpType(LLVMTypeRef Val); |
| 1115 | |
| 1116 | /** |
Anders Waldenborg | 47b3bd3 | 2013-10-22 06:58:34 +0000 | [diff] [blame] | 1117 | * Return a string representation of the type. Use |
| 1118 | * LLVMDisposeMessage to free the string. |
| 1119 | * |
| 1120 | * @see llvm::Type::print() |
| 1121 | */ |
| 1122 | char *LLVMPrintTypeToString(LLVMTypeRef Val); |
| 1123 | |
| 1124 | /** |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1125 | * @defgroup LLVMCCoreTypeInt Integer Types |
| 1126 | * |
| 1127 | * Functions in this section operate on integer types. |
| 1128 | * |
| 1129 | * @{ |
| 1130 | */ |
| 1131 | |
| 1132 | /** |
| 1133 | * Obtain an integer type from a context with specified bit width. |
| 1134 | */ |
Erick Tryzelaar | 262332f | 2009-08-14 00:01:31 +0000 | [diff] [blame] | 1135 | LLVMTypeRef LLVMInt1TypeInContext(LLVMContextRef C); |
| 1136 | LLVMTypeRef LLVMInt8TypeInContext(LLVMContextRef C); |
| 1137 | LLVMTypeRef LLVMInt16TypeInContext(LLVMContextRef C); |
| 1138 | LLVMTypeRef LLVMInt32TypeInContext(LLVMContextRef C); |
| 1139 | LLVMTypeRef LLVMInt64TypeInContext(LLVMContextRef C); |
Eugene Zelenko | ffec81c | 2015-11-04 22:32:32 +0000 | [diff] [blame] | 1140 | LLVMTypeRef LLVMInt128TypeInContext(LLVMContextRef C); |
Erick Tryzelaar | 262332f | 2009-08-14 00:01:31 +0000 | [diff] [blame] | 1141 | LLVMTypeRef LLVMIntTypeInContext(LLVMContextRef C, unsigned NumBits); |
| 1142 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1143 | /** |
| 1144 | * Obtain an integer type from the global context with a specified bit |
| 1145 | * width. |
| 1146 | */ |
Gordon Henriksen | a735a9c | 2008-05-04 12:55:34 +0000 | [diff] [blame] | 1147 | LLVMTypeRef LLVMInt1Type(void); |
| 1148 | LLVMTypeRef LLVMInt8Type(void); |
| 1149 | LLVMTypeRef LLVMInt16Type(void); |
| 1150 | LLVMTypeRef LLVMInt32Type(void); |
| 1151 | LLVMTypeRef LLVMInt64Type(void); |
Eugene Zelenko | ffec81c | 2015-11-04 22:32:32 +0000 | [diff] [blame] | 1152 | LLVMTypeRef LLVMInt128Type(void); |
Gordon Henriksen | ed7beaa | 2007-10-06 16:05:20 +0000 | [diff] [blame] | 1153 | LLVMTypeRef LLVMIntType(unsigned NumBits); |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 1154 | unsigned LLVMGetIntTypeWidth(LLVMTypeRef IntegerTy); |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 1155 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1156 | /** |
| 1157 | * @} |
| 1158 | */ |
| 1159 | |
| 1160 | /** |
| 1161 | * @defgroup LLVMCCoreTypeFloat Floating Point Types |
| 1162 | * |
| 1163 | * @{ |
| 1164 | */ |
| 1165 | |
| 1166 | /** |
| 1167 | * Obtain a 16-bit floating point type from a context. |
| 1168 | */ |
Dan Gohman | 518cda4 | 2011-12-17 00:04:22 +0000 | [diff] [blame] | 1169 | LLVMTypeRef LLVMHalfTypeInContext(LLVMContextRef C); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1170 | |
| 1171 | /** |
Ties Stuij | 8c24f33 | 2020-03-31 23:49:38 +0100 | [diff] [blame] | 1172 | * Obtain a 16-bit brain floating point type from a context. |
| 1173 | */ |
| 1174 | LLVMTypeRef LLVMBFloatTypeInContext(LLVMContextRef C); |
| 1175 | |
| 1176 | /** |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1177 | * Obtain a 32-bit floating point type from a context. |
| 1178 | */ |
Erick Tryzelaar | 262332f | 2009-08-14 00:01:31 +0000 | [diff] [blame] | 1179 | LLVMTypeRef LLVMFloatTypeInContext(LLVMContextRef C); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1180 | |
| 1181 | /** |
| 1182 | * Obtain a 64-bit floating point type from a context. |
| 1183 | */ |
Erick Tryzelaar | 262332f | 2009-08-14 00:01:31 +0000 | [diff] [blame] | 1184 | LLVMTypeRef LLVMDoubleTypeInContext(LLVMContextRef C); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1185 | |
| 1186 | /** |
| 1187 | * Obtain a 80-bit floating point type (X87) from a context. |
| 1188 | */ |
Erick Tryzelaar | 262332f | 2009-08-14 00:01:31 +0000 | [diff] [blame] | 1189 | LLVMTypeRef LLVMX86FP80TypeInContext(LLVMContextRef C); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1190 | |
| 1191 | /** |
| 1192 | * Obtain a 128-bit floating point type (112-bit mantissa) from a |
| 1193 | * context. |
| 1194 | */ |
Erick Tryzelaar | 262332f | 2009-08-14 00:01:31 +0000 | [diff] [blame] | 1195 | LLVMTypeRef LLVMFP128TypeInContext(LLVMContextRef C); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1196 | |
| 1197 | /** |
| 1198 | * Obtain a 128-bit floating point type (two 64-bits) from a context. |
| 1199 | */ |
Erick Tryzelaar | 262332f | 2009-08-14 00:01:31 +0000 | [diff] [blame] | 1200 | LLVMTypeRef LLVMPPCFP128TypeInContext(LLVMContextRef C); |
| 1201 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1202 | /** |
| 1203 | * Obtain a floating point type from the global context. |
| 1204 | * |
| 1205 | * These map to the functions in this group of the same name. |
| 1206 | */ |
Dan Gohman | 518cda4 | 2011-12-17 00:04:22 +0000 | [diff] [blame] | 1207 | LLVMTypeRef LLVMHalfType(void); |
Ties Stuij | 8c24f33 | 2020-03-31 23:49:38 +0100 | [diff] [blame] | 1208 | LLVMTypeRef LLVMBFloatType(void); |
Gordon Henriksen | a735a9c | 2008-05-04 12:55:34 +0000 | [diff] [blame] | 1209 | LLVMTypeRef LLVMFloatType(void); |
| 1210 | LLVMTypeRef LLVMDoubleType(void); |
| 1211 | LLVMTypeRef LLVMX86FP80Type(void); |
| 1212 | LLVMTypeRef LLVMFP128Type(void); |
| 1213 | LLVMTypeRef LLVMPPCFP128Type(void); |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 1214 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1215 | /** |
| 1216 | * @} |
| 1217 | */ |
| 1218 | |
| 1219 | /** |
| 1220 | * @defgroup LLVMCCoreTypeFunction Function Types |
| 1221 | * |
| 1222 | * @{ |
| 1223 | */ |
| 1224 | |
| 1225 | /** |
| 1226 | * Obtain a function type consisting of a specified signature. |
| 1227 | * |
| 1228 | * The function is defined as a tuple of a return Type, a list of |
| 1229 | * parameter types, and whether the function is variadic. |
| 1230 | */ |
Gordon Henriksen | ed7beaa | 2007-10-06 16:05:20 +0000 | [diff] [blame] | 1231 | LLVMTypeRef LLVMFunctionType(LLVMTypeRef ReturnType, |
| 1232 | LLVMTypeRef *ParamTypes, unsigned ParamCount, |
Chris Lattner | 25963c6 | 2010-01-09 22:27:07 +0000 | [diff] [blame] | 1233 | LLVMBool IsVarArg); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1234 | |
| 1235 | /** |
| 1236 | * Returns whether a function type is variadic. |
| 1237 | */ |
Chris Lattner | 25963c6 | 2010-01-09 22:27:07 +0000 | [diff] [blame] | 1238 | LLVMBool LLVMIsFunctionVarArg(LLVMTypeRef FunctionTy); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1239 | |
| 1240 | /** |
| 1241 | * Obtain the Type this function Type returns. |
| 1242 | */ |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 1243 | LLVMTypeRef LLVMGetReturnType(LLVMTypeRef FunctionTy); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1244 | |
| 1245 | /** |
| 1246 | * Obtain the number of parameters this function accepts. |
| 1247 | */ |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 1248 | unsigned LLVMCountParamTypes(LLVMTypeRef FunctionTy); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1249 | |
| 1250 | /** |
| 1251 | * Obtain the types of a function's parameters. |
| 1252 | * |
| 1253 | * The Dest parameter should point to a pre-allocated array of |
| 1254 | * LLVMTypeRef at least LLVMCountParamTypes() large. On return, the |
| 1255 | * first LLVMCountParamTypes() entries in the array will be populated |
| 1256 | * with LLVMTypeRef instances. |
| 1257 | * |
| 1258 | * @param FunctionTy The function type to operate on. |
| 1259 | * @param Dest Memory address of an array to be filled with result. |
| 1260 | */ |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 1261 | void LLVMGetParamTypes(LLVMTypeRef FunctionTy, LLVMTypeRef *Dest); |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 1262 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1263 | /** |
| 1264 | * @} |
| 1265 | */ |
| 1266 | |
| 1267 | /** |
| 1268 | * @defgroup LLVMCCoreTypeStruct Structure Types |
| 1269 | * |
| 1270 | * These functions relate to LLVMTypeRef instances. |
| 1271 | * |
| 1272 | * @see llvm::StructType |
| 1273 | * |
| 1274 | * @{ |
| 1275 | */ |
| 1276 | |
| 1277 | /** |
| 1278 | * Create a new structure type in a context. |
| 1279 | * |
| 1280 | * A structure is specified by a list of inner elements/types and |
| 1281 | * whether these can be packed together. |
| 1282 | * |
| 1283 | * @see llvm::StructType::create() |
| 1284 | */ |
Erick Tryzelaar | 262332f | 2009-08-14 00:01:31 +0000 | [diff] [blame] | 1285 | LLVMTypeRef LLVMStructTypeInContext(LLVMContextRef C, LLVMTypeRef *ElementTypes, |
Chris Lattner | 25963c6 | 2010-01-09 22:27:07 +0000 | [diff] [blame] | 1286 | unsigned ElementCount, LLVMBool Packed); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1287 | |
| 1288 | /** |
| 1289 | * Create a new structure type in the global context. |
| 1290 | * |
| 1291 | * @see llvm::StructType::create() |
| 1292 | */ |
Gordon Henriksen | ed7beaa | 2007-10-06 16:05:20 +0000 | [diff] [blame] | 1293 | LLVMTypeRef LLVMStructType(LLVMTypeRef *ElementTypes, unsigned ElementCount, |
Chris Lattner | 25963c6 | 2010-01-09 22:27:07 +0000 | [diff] [blame] | 1294 | LLVMBool Packed); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1295 | |
| 1296 | /** |
| 1297 | * Create an empty structure in a context having a specified name. |
| 1298 | * |
| 1299 | * @see llvm::StructType::create() |
| 1300 | */ |
Chris Lattner | e71ccde | 2011-07-14 05:53:17 +0000 | [diff] [blame] | 1301 | LLVMTypeRef LLVMStructCreateNamed(LLVMContextRef C, const char *Name); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1302 | |
| 1303 | /** |
| 1304 | * Obtain the name of a structure. |
| 1305 | * |
| 1306 | * @see llvm::StructType::getName() |
| 1307 | */ |
Torok Edwin | 0d5f6ae | 2011-10-06 12:12:50 +0000 | [diff] [blame] | 1308 | const char *LLVMGetStructName(LLVMTypeRef Ty); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1309 | |
| 1310 | /** |
| 1311 | * Set the contents of a structure type. |
| 1312 | * |
| 1313 | * @see llvm::StructType::setBody() |
| 1314 | */ |
Chris Lattner | e71ccde | 2011-07-14 05:53:17 +0000 | [diff] [blame] | 1315 | void LLVMStructSetBody(LLVMTypeRef StructTy, LLVMTypeRef *ElementTypes, |
| 1316 | unsigned ElementCount, LLVMBool Packed); |
| 1317 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1318 | /** |
| 1319 | * Get the number of elements defined inside the structure. |
| 1320 | * |
| 1321 | * @see llvm::StructType::getNumElements() |
| 1322 | */ |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 1323 | unsigned LLVMCountStructElementTypes(LLVMTypeRef StructTy); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1324 | |
| 1325 | /** |
| 1326 | * Get the elements within a structure. |
| 1327 | * |
| 1328 | * The function is passed the address of a pre-allocated array of |
| 1329 | * LLVMTypeRef at least LLVMCountStructElementTypes() long. After |
| 1330 | * invocation, this array will be populated with the structure's |
| 1331 | * elements. The objects in the destination array will have a lifetime |
| 1332 | * of the structure type itself, which is the lifetime of the context it |
| 1333 | * is contained in. |
| 1334 | */ |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 1335 | void LLVMGetStructElementTypes(LLVMTypeRef StructTy, LLVMTypeRef *Dest); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1336 | |
| 1337 | /** |
Peter Zotov | c164a3f | 2015-06-04 09:09:53 +0000 | [diff] [blame] | 1338 | * Get the type of the element at a given index in the structure. |
| 1339 | * |
| 1340 | * @see llvm::StructType::getTypeAtIndex() |
| 1341 | */ |
| 1342 | LLVMTypeRef LLVMStructGetTypeAtIndex(LLVMTypeRef StructTy, unsigned i); |
| 1343 | |
| 1344 | /** |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1345 | * Determine whether a structure is packed. |
| 1346 | * |
| 1347 | * @see llvm::StructType::isPacked() |
| 1348 | */ |
Chris Lattner | 25963c6 | 2010-01-09 22:27:07 +0000 | [diff] [blame] | 1349 | LLVMBool LLVMIsPackedStruct(LLVMTypeRef StructTy); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1350 | |
| 1351 | /** |
| 1352 | * Determine whether a structure is opaque. |
| 1353 | * |
| 1354 | * @see llvm::StructType::isOpaque() |
| 1355 | */ |
Chris Lattner | 17cf05b | 2011-07-14 16:20:28 +0000 | [diff] [blame] | 1356 | LLVMBool LLVMIsOpaqueStruct(LLVMTypeRef StructTy); |
| 1357 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1358 | /** |
whitequark | b486107 | 2018-09-18 01:47:37 +0000 | [diff] [blame] | 1359 | * Determine whether a structure is literal. |
| 1360 | * |
| 1361 | * @see llvm::StructType::isLiteral() |
| 1362 | */ |
| 1363 | LLVMBool LLVMIsLiteralStruct(LLVMTypeRef StructTy); |
| 1364 | |
| 1365 | /** |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1366 | * @} |
| 1367 | */ |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 1368 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1369 | /** |
| 1370 | * @defgroup LLVMCCoreTypeSequential Sequential Types |
| 1371 | * |
| 1372 | * Sequential types represents "arrays" of types. This is a super class |
| 1373 | * for array, vector, and pointer types. |
| 1374 | * |
| 1375 | * @{ |
| 1376 | */ |
| 1377 | |
| 1378 | /** |
| 1379 | * Obtain the type of elements within a sequential type. |
| 1380 | * |
| 1381 | * This works on array, vector, and pointer types. |
| 1382 | * |
| 1383 | * @see llvm::SequentialType::getElementType() |
| 1384 | */ |
| 1385 | LLVMTypeRef LLVMGetElementType(LLVMTypeRef Ty); |
| 1386 | |
| 1387 | /** |
whitequark | f6059fd | 2017-06-05 11:49:52 +0000 | [diff] [blame] | 1388 | * Returns type's subtypes |
| 1389 | * |
| 1390 | * @see llvm::Type::subtypes() |
| 1391 | */ |
| 1392 | void LLVMGetSubtypes(LLVMTypeRef Tp, LLVMTypeRef *Arr); |
| 1393 | |
| 1394 | /** |
| 1395 | * Return the number of types in the derived type. |
| 1396 | * |
| 1397 | * @see llvm::Type::getNumContainedTypes() |
| 1398 | */ |
| 1399 | unsigned LLVMGetNumContainedTypes(LLVMTypeRef Tp); |
| 1400 | |
| 1401 | /** |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1402 | * Create a fixed size array type that refers to a specific type. |
| 1403 | * |
| 1404 | * The created type will exist in the context that its element type |
| 1405 | * exists in. |
| 1406 | * |
| 1407 | * @see llvm::ArrayType::get() |
| 1408 | */ |
Gordon Henriksen | ed7beaa | 2007-10-06 16:05:20 +0000 | [diff] [blame] | 1409 | LLVMTypeRef LLVMArrayType(LLVMTypeRef ElementType, unsigned ElementCount); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1410 | |
| 1411 | /** |
| 1412 | * Obtain the length of an array type. |
| 1413 | * |
| 1414 | * This only works on types that represent arrays. |
| 1415 | * |
| 1416 | * @see llvm::ArrayType::getNumElements() |
| 1417 | */ |
| 1418 | unsigned LLVMGetArrayLength(LLVMTypeRef ArrayTy); |
| 1419 | |
| 1420 | /** |
| 1421 | * Create a pointer type that points to a defined type. |
| 1422 | * |
| 1423 | * The created type will exist in the context that its pointee type |
| 1424 | * exists in. |
| 1425 | * |
| 1426 | * @see llvm::PointerType::get() |
| 1427 | */ |
Gordon Henriksen | 5a3fe03 | 2007-12-17 16:08:32 +0000 | [diff] [blame] | 1428 | LLVMTypeRef LLVMPointerType(LLVMTypeRef ElementType, unsigned AddressSpace); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1429 | |
| 1430 | /** |
| 1431 | * Obtain the address space of a pointer type. |
| 1432 | * |
| 1433 | * This only works on types that represent pointers. |
| 1434 | * |
| 1435 | * @see llvm::PointerType::getAddressSpace() |
| 1436 | */ |
| 1437 | unsigned LLVMGetPointerAddressSpace(LLVMTypeRef PointerTy); |
| 1438 | |
| 1439 | /** |
| 1440 | * Create a vector type that contains a defined type and has a specific |
| 1441 | * number of elements. |
| 1442 | * |
| 1443 | * The created type will exist in the context thats its element type |
| 1444 | * exists in. |
| 1445 | * |
| 1446 | * @see llvm::VectorType::get() |
| 1447 | */ |
Gordon Henriksen | ed7beaa | 2007-10-06 16:05:20 +0000 | [diff] [blame] | 1448 | LLVMTypeRef LLVMVectorType(LLVMTypeRef ElementType, unsigned ElementCount); |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 1449 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1450 | /** |
Craig Disselkoen | c378384 | 2020-10-28 16:48:22 -0400 | [diff] [blame] | 1451 | * Create a vector type that contains a defined type and has a scalable |
| 1452 | * number of elements. |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1453 | * |
Craig Disselkoen | c378384 | 2020-10-28 16:48:22 -0400 | [diff] [blame] | 1454 | * The created type will exist in the context thats its element type |
| 1455 | * exists in. |
| 1456 | * |
| 1457 | * @see llvm::ScalableVectorType::get() |
| 1458 | */ |
| 1459 | LLVMTypeRef LLVMScalableVectorType(LLVMTypeRef ElementType, |
| 1460 | unsigned ElementCount); |
| 1461 | |
| 1462 | /** |
| 1463 | * Obtain the (possibly scalable) number of elements in a vector type. |
| 1464 | * |
| 1465 | * This only works on types that represent vectors (fixed or scalable). |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1466 | * |
| 1467 | * @see llvm::VectorType::getNumElements() |
| 1468 | */ |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 1469 | unsigned LLVMGetVectorSize(LLVMTypeRef VectorTy); |
| 1470 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1471 | /** |
| 1472 | * @} |
| 1473 | */ |
| 1474 | |
| 1475 | /** |
| 1476 | * @defgroup LLVMCCoreTypeOther Other Types |
| 1477 | * |
| 1478 | * @{ |
| 1479 | */ |
| 1480 | |
| 1481 | /** |
| 1482 | * Create a void type in a context. |
| 1483 | */ |
Erick Tryzelaar | 262332f | 2009-08-14 00:01:31 +0000 | [diff] [blame] | 1484 | LLVMTypeRef LLVMVoidTypeInContext(LLVMContextRef C); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1485 | |
| 1486 | /** |
| 1487 | * Create a label type in a context. |
| 1488 | */ |
Erick Tryzelaar | 262332f | 2009-08-14 00:01:31 +0000 | [diff] [blame] | 1489 | LLVMTypeRef LLVMLabelTypeInContext(LLVMContextRef C); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1490 | |
| 1491 | /** |
| 1492 | * Create a X86 MMX type in a context. |
| 1493 | */ |
Dale Johannesen | 95b67af | 2010-09-10 21:58:02 +0000 | [diff] [blame] | 1494 | LLVMTypeRef LLVMX86MMXTypeInContext(LLVMContextRef C); |
Erick Tryzelaar | 262332f | 2009-08-14 00:01:31 +0000 | [diff] [blame] | 1495 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1496 | /** |
whitequark | 131f98f | 2017-10-27 11:51:40 +0000 | [diff] [blame] | 1497 | * Create a token type in a context. |
| 1498 | */ |
| 1499 | LLVMTypeRef LLVMTokenTypeInContext(LLVMContextRef C); |
| 1500 | |
| 1501 | /** |
| 1502 | * Create a metadata type in a context. |
| 1503 | */ |
| 1504 | LLVMTypeRef LLVMMetadataTypeInContext(LLVMContextRef C); |
| 1505 | |
| 1506 | /** |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1507 | * These are similar to the above functions except they operate on the |
| 1508 | * global context. |
| 1509 | */ |
Gordon Henriksen | a735a9c | 2008-05-04 12:55:34 +0000 | [diff] [blame] | 1510 | LLVMTypeRef LLVMVoidType(void); |
| 1511 | LLVMTypeRef LLVMLabelType(void); |
Dale Johannesen | 95b67af | 2010-09-10 21:58:02 +0000 | [diff] [blame] | 1512 | LLVMTypeRef LLVMX86MMXType(void); |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 1513 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1514 | /** |
| 1515 | * @} |
| 1516 | */ |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 1517 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1518 | /** |
| 1519 | * @} |
| 1520 | */ |
| 1521 | |
| 1522 | /** |
| 1523 | * @defgroup LLVMCCoreValues Values |
| 1524 | * |
| 1525 | * The bulk of LLVM's object model consists of values, which comprise a very |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 1526 | * rich type hierarchy. |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1527 | * |
| 1528 | * LLVMValueRef essentially represents llvm::Value. There is a rich |
| 1529 | * hierarchy of classes within this type. Depending on the instance |
Eli Bendersky | c52863c | 2012-08-10 18:30:44 +0000 | [diff] [blame] | 1530 | * obtained, not all APIs are available. |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1531 | * |
Daniel Dunbar | 06b9f9e | 2013-08-16 23:30:19 +0000 | [diff] [blame] | 1532 | * Callers can determine the type of an LLVMValueRef by calling the |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1533 | * LLVMIsA* family of functions (e.g. LLVMIsAArgument()). These |
| 1534 | * functions are defined by a macro, so it isn't obvious which are |
| 1535 | * available by looking at the Doxygen source code. Instead, look at the |
| 1536 | * source definition of LLVM_FOR_EACH_VALUE_SUBCLASS and note the list |
| 1537 | * of value names given. These value names also correspond to classes in |
| 1538 | * the llvm::Value hierarchy. |
| 1539 | * |
| 1540 | * @{ |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 1541 | */ |
| 1542 | |
Gordon Henriksen | 29e3894 | 2008-12-19 18:39:45 +0000 | [diff] [blame] | 1543 | #define LLVM_FOR_EACH_VALUE_SUBCLASS(macro) \ |
| 1544 | macro(Argument) \ |
| 1545 | macro(BasicBlock) \ |
| 1546 | macro(InlineAsm) \ |
| 1547 | macro(User) \ |
| 1548 | macro(Constant) \ |
Torok Edwin | d09b757 | 2011-10-14 20:37:56 +0000 | [diff] [blame] | 1549 | macro(BlockAddress) \ |
Gordon Henriksen | 29e3894 | 2008-12-19 18:39:45 +0000 | [diff] [blame] | 1550 | macro(ConstantAggregateZero) \ |
| 1551 | macro(ConstantArray) \ |
Peter Zotov | ae0344b | 2013-11-05 12:55:37 +0000 | [diff] [blame] | 1552 | macro(ConstantDataSequential) \ |
| 1553 | macro(ConstantDataArray) \ |
| 1554 | macro(ConstantDataVector) \ |
Gordon Henriksen | 29e3894 | 2008-12-19 18:39:45 +0000 | [diff] [blame] | 1555 | macro(ConstantExpr) \ |
| 1556 | macro(ConstantFP) \ |
| 1557 | macro(ConstantInt) \ |
| 1558 | macro(ConstantPointerNull) \ |
| 1559 | macro(ConstantStruct) \ |
David Majnemer | f0f224d | 2015-11-11 21:57:16 +0000 | [diff] [blame] | 1560 | macro(ConstantTokenNone) \ |
Gordon Henriksen | 29e3894 | 2008-12-19 18:39:45 +0000 | [diff] [blame] | 1561 | macro(ConstantVector) \ |
| 1562 | macro(GlobalValue) \ |
Gordon Henriksen | 29e3894 | 2008-12-19 18:39:45 +0000 | [diff] [blame] | 1563 | macro(GlobalAlias) \ |
whitequark | d299b2c | 2018-09-18 00:01:12 +0000 | [diff] [blame] | 1564 | macro(GlobalIFunc) \ |
Rafael Espindola | 99e05cf | 2014-05-13 18:45:48 +0000 | [diff] [blame] | 1565 | macro(GlobalObject) \ |
| 1566 | macro(Function) \ |
| 1567 | macro(GlobalVariable) \ |
Gordon Henriksen | 29e3894 | 2008-12-19 18:39:45 +0000 | [diff] [blame] | 1568 | macro(UndefValue) \ |
Zhengyang Liu | 75f50e1 | 2020-11-24 14:55:24 -0700 | [diff] [blame] | 1569 | macro(PoisonValue) \ |
Gordon Henriksen | 29e3894 | 2008-12-19 18:39:45 +0000 | [diff] [blame] | 1570 | macro(Instruction) \ |
Cameron McInally | 60786f9 | 2019-10-07 21:33:39 +0000 | [diff] [blame] | 1571 | macro(UnaryOperator) \ |
Gordon Henriksen | 29e3894 | 2008-12-19 18:39:45 +0000 | [diff] [blame] | 1572 | macro(BinaryOperator) \ |
| 1573 | macro(CallInst) \ |
| 1574 | macro(IntrinsicInst) \ |
| 1575 | macro(DbgInfoIntrinsic) \ |
Hsiangkai Wang | ef72e48 | 2018-08-06 03:59:47 +0000 | [diff] [blame] | 1576 | macro(DbgVariableIntrinsic) \ |
| 1577 | macro(DbgDeclareInst) \ |
| 1578 | macro(DbgLabelInst) \ |
Gordon Henriksen | 29e3894 | 2008-12-19 18:39:45 +0000 | [diff] [blame] | 1579 | macro(MemIntrinsic) \ |
| 1580 | macro(MemCpyInst) \ |
| 1581 | macro(MemMoveInst) \ |
| 1582 | macro(MemSetInst) \ |
| 1583 | macro(CmpInst) \ |
Torok Edwin | d09b757 | 2011-10-14 20:37:56 +0000 | [diff] [blame] | 1584 | macro(FCmpInst) \ |
| 1585 | macro(ICmpInst) \ |
Gordon Henriksen | 29e3894 | 2008-12-19 18:39:45 +0000 | [diff] [blame] | 1586 | macro(ExtractElementInst) \ |
| 1587 | macro(GetElementPtrInst) \ |
| 1588 | macro(InsertElementInst) \ |
| 1589 | macro(InsertValueInst) \ |
Bill Wendling | fae1475 | 2011-08-12 20:24:12 +0000 | [diff] [blame] | 1590 | macro(LandingPadInst) \ |
Gordon Henriksen | 29e3894 | 2008-12-19 18:39:45 +0000 | [diff] [blame] | 1591 | macro(PHINode) \ |
| 1592 | macro(SelectInst) \ |
| 1593 | macro(ShuffleVectorInst) \ |
| 1594 | macro(StoreInst) \ |
Chandler Carruth | 7c80c3a | 2018-10-18 23:03:55 +0000 | [diff] [blame] | 1595 | macro(BranchInst) \ |
| 1596 | macro(IndirectBrInst) \ |
| 1597 | macro(InvokeInst) \ |
| 1598 | macro(ReturnInst) \ |
| 1599 | macro(SwitchInst) \ |
| 1600 | macro(UnreachableInst) \ |
| 1601 | macro(ResumeInst) \ |
| 1602 | macro(CleanupReturnInst) \ |
| 1603 | macro(CatchReturnInst) \ |
Nick Lewycky | f57e968 | 2019-09-26 00:58:55 +0000 | [diff] [blame] | 1604 | macro(CatchSwitchInst) \ |
| 1605 | macro(CallBrInst) \ |
David Majnemer | 8a1c45d | 2015-12-12 05:38:55 +0000 | [diff] [blame] | 1606 | macro(FuncletPadInst) \ |
| 1607 | macro(CatchPadInst) \ |
| 1608 | macro(CleanupPadInst) \ |
Duncan Sands | 5e37e99 | 2013-05-06 08:55:45 +0000 | [diff] [blame] | 1609 | macro(UnaryInstruction) \ |
| 1610 | macro(AllocaInst) \ |
| 1611 | macro(CastInst) \ |
Matt Arsenault | b03bd4d | 2013-11-15 01:34:59 +0000 | [diff] [blame] | 1612 | macro(AddrSpaceCastInst) \ |
Duncan Sands | 5e37e99 | 2013-05-06 08:55:45 +0000 | [diff] [blame] | 1613 | macro(BitCastInst) \ |
| 1614 | macro(FPExtInst) \ |
| 1615 | macro(FPToSIInst) \ |
| 1616 | macro(FPToUIInst) \ |
| 1617 | macro(FPTruncInst) \ |
| 1618 | macro(IntToPtrInst) \ |
| 1619 | macro(PtrToIntInst) \ |
| 1620 | macro(SExtInst) \ |
| 1621 | macro(SIToFPInst) \ |
| 1622 | macro(TruncInst) \ |
| 1623 | macro(UIToFPInst) \ |
| 1624 | macro(ZExtInst) \ |
| 1625 | macro(ExtractValueInst) \ |
| 1626 | macro(LoadInst) \ |
Nick Lewycky | f57e968 | 2019-09-26 00:58:55 +0000 | [diff] [blame] | 1627 | macro(VAArgInst) \ |
aqjune | e87d716 | 2019-11-07 01:17:49 +0900 | [diff] [blame] | 1628 | macro(FreezeInst) \ |
Nick Lewycky | f57e968 | 2019-09-26 00:58:55 +0000 | [diff] [blame] | 1629 | macro(AtomicCmpXchgInst) \ |
| 1630 | macro(AtomicRMWInst) \ |
| 1631 | macro(FenceInst) |
Gordon Henriksen | 29e3894 | 2008-12-19 18:39:45 +0000 | [diff] [blame] | 1632 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1633 | /** |
| 1634 | * @defgroup LLVMCCoreValueGeneral General APIs |
| 1635 | * |
| 1636 | * Functions in this section work on all LLVMValueRef instances, |
| 1637 | * regardless of their sub-type. They correspond to functions available |
| 1638 | * on llvm::Value. |
| 1639 | * |
| 1640 | * @{ |
| 1641 | */ |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 1642 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1643 | /** |
| 1644 | * Obtain the type of a value. |
| 1645 | * |
| 1646 | * @see llvm::Value::getType() |
| 1647 | */ |
| 1648 | LLVMTypeRef LLVMTypeOf(LLVMValueRef Val); |
| 1649 | |
| 1650 | /** |
Peter Zotov | 3e4561c | 2016-04-06 22:21:29 +0000 | [diff] [blame] | 1651 | * Obtain the enumerated type of a Value instance. |
| 1652 | * |
| 1653 | * @see llvm::Value::getValueID() |
| 1654 | */ |
| 1655 | LLVMValueKind LLVMGetValueKind(LLVMValueRef Val); |
| 1656 | |
| 1657 | /** |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1658 | * Obtain the string name of a value. |
| 1659 | * |
| 1660 | * @see llvm::Value::getName() |
| 1661 | */ |
Robert Widmann | 025c78f | 2018-05-19 15:08:36 +0000 | [diff] [blame] | 1662 | const char *LLVMGetValueName2(LLVMValueRef Val, size_t *Length); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1663 | |
| 1664 | /** |
| 1665 | * Set the string name of a value. |
| 1666 | * |
| 1667 | * @see llvm::Value::setName() |
| 1668 | */ |
Robert Widmann | 025c78f | 2018-05-19 15:08:36 +0000 | [diff] [blame] | 1669 | void LLVMSetValueName2(LLVMValueRef Val, const char *Name, size_t NameLen); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1670 | |
| 1671 | /** |
| 1672 | * Dump a representation of a value to stderr. |
| 1673 | * |
| 1674 | * @see llvm::Value::dump() |
| 1675 | */ |
| 1676 | void LLVMDumpValue(LLVMValueRef Val); |
| 1677 | |
| 1678 | /** |
Peter Zotov | cd93b37 | 2013-11-06 09:21:01 +0000 | [diff] [blame] | 1679 | * Return a string representation of the value. Use |
| 1680 | * LLVMDisposeMessage to free the string. |
| 1681 | * |
| 1682 | * @see llvm::Value::print() |
| 1683 | */ |
| 1684 | char *LLVMPrintValueToString(LLVMValueRef Val); |
| 1685 | |
| 1686 | /** |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1687 | * Replace all uses of a value with another one. |
| 1688 | * |
| 1689 | * @see llvm::Value::replaceAllUsesWith() |
| 1690 | */ |
| 1691 | void LLVMReplaceAllUsesWith(LLVMValueRef OldVal, LLVMValueRef NewVal); |
| 1692 | |
| 1693 | /** |
Amaury Sechet | 1c39507 | 2016-01-18 01:06:52 +0000 | [diff] [blame] | 1694 | * Determine whether the specified value instance is constant. |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1695 | */ |
| 1696 | LLVMBool LLVMIsConstant(LLVMValueRef Val); |
| 1697 | |
| 1698 | /** |
| 1699 | * Determine whether a value instance is undefined. |
| 1700 | */ |
| 1701 | LLVMBool LLVMIsUndef(LLVMValueRef Val); |
| 1702 | |
| 1703 | /** |
Zhengyang Liu | 75f50e1 | 2020-11-24 14:55:24 -0700 | [diff] [blame] | 1704 | * Determine whether a value instance is poisonous. |
| 1705 | */ |
| 1706 | LLVMBool LLVMIsPoison(LLVMValueRef Val); |
| 1707 | |
| 1708 | /** |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1709 | * Convert value instances between types. |
| 1710 | * |
Daniel Dunbar | 06b9f9e | 2013-08-16 23:30:19 +0000 | [diff] [blame] | 1711 | * Internally, an LLVMValueRef is "pinned" to a specific type. This |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1712 | * series of functions allows you to cast an instance to a specific |
| 1713 | * type. |
| 1714 | * |
| 1715 | * If the cast is not valid for the specified type, NULL is returned. |
| 1716 | * |
| 1717 | * @see llvm::dyn_cast_or_null<> |
| 1718 | */ |
Gordon Henriksen | 29e3894 | 2008-12-19 18:39:45 +0000 | [diff] [blame] | 1719 | #define LLVM_DECLARE_VALUE_CAST(name) \ |
| 1720 | LLVMValueRef LLVMIsA##name(LLVMValueRef Val); |
| 1721 | LLVM_FOR_EACH_VALUE_SUBCLASS(LLVM_DECLARE_VALUE_CAST) |
| 1722 | |
Duncan P. N. Exon Smith | 5bf8fef | 2014-12-09 18:38:53 +0000 | [diff] [blame] | 1723 | LLVMValueRef LLVMIsAMDNode(LLVMValueRef Val); |
| 1724 | LLVMValueRef LLVMIsAMDString(LLVMValueRef Val); |
| 1725 | |
Robert Widmann | 025c78f | 2018-05-19 15:08:36 +0000 | [diff] [blame] | 1726 | /** Deprecated: Use LLVMGetValueName2 instead. */ |
| 1727 | const char *LLVMGetValueName(LLVMValueRef Val); |
| 1728 | /** Deprecated: Use LLVMSetValueName2 instead. */ |
| 1729 | void LLVMSetValueName(LLVMValueRef Val, const char *Name); |
| 1730 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1731 | /** |
| 1732 | * @} |
| 1733 | */ |
| 1734 | |
| 1735 | /** |
| 1736 | * @defgroup LLVMCCoreValueUses Usage |
| 1737 | * |
| 1738 | * This module defines functions that allow you to inspect the uses of a |
| 1739 | * LLVMValueRef. |
| 1740 | * |
Daniel Dunbar | 06b9f9e | 2013-08-16 23:30:19 +0000 | [diff] [blame] | 1741 | * It is possible to obtain an LLVMUseRef for any LLVMValueRef instance. |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1742 | * Each LLVMUseRef (which corresponds to a llvm::Use instance) holds a |
| 1743 | * llvm::User and llvm::Value. |
| 1744 | * |
| 1745 | * @{ |
| 1746 | */ |
| 1747 | |
| 1748 | /** |
| 1749 | * Obtain the first use of a value. |
| 1750 | * |
| 1751 | * Uses are obtained in an iterator fashion. First, call this function |
| 1752 | * to obtain a reference to the first use. Then, call LLVMGetNextUse() |
Eli Bendersky | c52863c | 2012-08-10 18:30:44 +0000 | [diff] [blame] | 1753 | * on that instance and all subsequently obtained instances until |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1754 | * LLVMGetNextUse() returns NULL. |
| 1755 | * |
| 1756 | * @see llvm::Value::use_begin() |
| 1757 | */ |
Erick Tryzelaar | 9f9857e | 2010-03-02 20:32:28 +0000 | [diff] [blame] | 1758 | LLVMUseRef LLVMGetFirstUse(LLVMValueRef Val); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1759 | |
| 1760 | /** |
| 1761 | * Obtain the next use of a value. |
| 1762 | * |
| 1763 | * This effectively advances the iterator. It returns NULL if you are on |
| 1764 | * the final use and no more are available. |
| 1765 | */ |
Erick Tryzelaar | 9f9857e | 2010-03-02 20:32:28 +0000 | [diff] [blame] | 1766 | LLVMUseRef LLVMGetNextUse(LLVMUseRef U); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1767 | |
| 1768 | /** |
| 1769 | * Obtain the user value for a user. |
| 1770 | * |
| 1771 | * The returned value corresponds to a llvm::User type. |
| 1772 | * |
| 1773 | * @see llvm::Use::getUser() |
| 1774 | */ |
Erick Tryzelaar | 9f9857e | 2010-03-02 20:32:28 +0000 | [diff] [blame] | 1775 | LLVMValueRef LLVMGetUser(LLVMUseRef U); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1776 | |
| 1777 | /** |
| 1778 | * Obtain the value this use corresponds to. |
| 1779 | * |
| 1780 | * @see llvm::Use::get(). |
| 1781 | */ |
Erick Tryzelaar | 9f9857e | 2010-03-02 20:32:28 +0000 | [diff] [blame] | 1782 | LLVMValueRef LLVMGetUsedValue(LLVMUseRef U); |
Chris Lattner | 40cf28d | 2009-10-12 04:01:02 +0000 | [diff] [blame] | 1783 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1784 | /** |
| 1785 | * @} |
| 1786 | */ |
| 1787 | |
| 1788 | /** |
Gregory Szorc | 52d2660 | 2012-03-21 07:28:27 +0000 | [diff] [blame] | 1789 | * @defgroup LLVMCCoreValueUser User value |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1790 | * |
| 1791 | * Function in this group pertain to LLVMValueRef instances that descent |
| 1792 | * from llvm::User. This includes constants, instructions, and |
| 1793 | * operators. |
| 1794 | * |
| 1795 | * @{ |
| 1796 | */ |
| 1797 | |
| 1798 | /** |
| 1799 | * Obtain an operand at a specific index in a llvm::User value. |
| 1800 | * |
| 1801 | * @see llvm::User::getOperand() |
| 1802 | */ |
Chris Lattner | 40cf28d | 2009-10-12 04:01:02 +0000 | [diff] [blame] | 1803 | LLVMValueRef LLVMGetOperand(LLVMValueRef Val, unsigned Index); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1804 | |
| 1805 | /** |
Peter Zotov | b19f78f | 2014-08-12 02:55:40 +0000 | [diff] [blame] | 1806 | * Obtain the use of an operand at a specific index in a llvm::User value. |
| 1807 | * |
| 1808 | * @see llvm::User::getOperandUse() |
| 1809 | */ |
| 1810 | LLVMUseRef LLVMGetOperandUse(LLVMValueRef Val, unsigned Index); |
| 1811 | |
| 1812 | /** |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1813 | * Set an operand at a specific index in a llvm::User value. |
| 1814 | * |
| 1815 | * @see llvm::User::setOperand() |
| 1816 | */ |
Erick Tryzelaar | b4d4870 | 2010-08-20 14:51:22 +0000 | [diff] [blame] | 1817 | void LLVMSetOperand(LLVMValueRef User, unsigned Index, LLVMValueRef Val); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1818 | |
| 1819 | /** |
| 1820 | * Obtain the number of operands in a llvm::User value. |
| 1821 | * |
| 1822 | * @see llvm::User::getNumOperands() |
| 1823 | */ |
Erick Tryzelaar | b4d4870 | 2010-08-20 14:51:22 +0000 | [diff] [blame] | 1824 | int LLVMGetNumOperands(LLVMValueRef Val); |
Chris Lattner | 40cf28d | 2009-10-12 04:01:02 +0000 | [diff] [blame] | 1825 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1826 | /** |
| 1827 | * @} |
| 1828 | */ |
| 1829 | |
| 1830 | /** |
Gregory Szorc | 52d2660 | 2012-03-21 07:28:27 +0000 | [diff] [blame] | 1831 | * @defgroup LLVMCCoreValueConstant Constants |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1832 | * |
| 1833 | * This section contains APIs for interacting with LLVMValueRef that |
| 1834 | * correspond to llvm::Constant instances. |
| 1835 | * |
| 1836 | * These functions will work for any LLVMValueRef in the llvm::Constant |
| 1837 | * class hierarchy. |
| 1838 | * |
| 1839 | * @{ |
| 1840 | */ |
| 1841 | |
| 1842 | /** |
| 1843 | * Obtain a constant value referring to the null instance of a type. |
| 1844 | * |
| 1845 | * @see llvm::Constant::getNullValue() |
| 1846 | */ |
Gordon Henriksen | 1046c73 | 2007-10-06 15:11:06 +0000 | [diff] [blame] | 1847 | LLVMValueRef LLVMConstNull(LLVMTypeRef Ty); /* all zeroes */ |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1848 | |
| 1849 | /** |
| 1850 | * Obtain a constant value referring to the instance of a type |
| 1851 | * consisting of all ones. |
| 1852 | * |
| 1853 | * This is only valid for integer types. |
| 1854 | * |
| 1855 | * @see llvm::Constant::getAllOnesValue() |
| 1856 | */ |
| 1857 | LLVMValueRef LLVMConstAllOnes(LLVMTypeRef Ty); |
| 1858 | |
| 1859 | /** |
| 1860 | * Obtain a constant value referring to an undefined value of a type. |
| 1861 | * |
| 1862 | * @see llvm::UndefValue::get() |
| 1863 | */ |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 1864 | LLVMValueRef LLVMGetUndef(LLVMTypeRef Ty); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1865 | |
| 1866 | /** |
Zhengyang Liu | 75f50e1 | 2020-11-24 14:55:24 -0700 | [diff] [blame] | 1867 | * Obtain a constant value referring to a poison value of a type. |
| 1868 | * |
| 1869 | * @see llvm::PoisonValue::get() |
| 1870 | */ |
| 1871 | LLVMValueRef LLVMGetPoison(LLVMTypeRef Ty); |
| 1872 | |
| 1873 | /** |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1874 | * Determine whether a value instance is null. |
| 1875 | * |
| 1876 | * @see llvm::Constant::isNullValue() |
| 1877 | */ |
Chris Lattner | 25963c6 | 2010-01-09 22:27:07 +0000 | [diff] [blame] | 1878 | LLVMBool LLVMIsNull(LLVMValueRef Val); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1879 | |
| 1880 | /** |
| 1881 | * Obtain a constant that is a constant pointer pointing to NULL for a |
| 1882 | * specified type. |
| 1883 | */ |
Chris Lattner | 7f31824 | 2009-07-06 17:29:59 +0000 | [diff] [blame] | 1884 | LLVMValueRef LLVMConstPointerNull(LLVMTypeRef Ty); |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 1885 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1886 | /** |
| 1887 | * @defgroup LLVMCCoreValueConstantScalar Scalar constants |
| 1888 | * |
| 1889 | * Functions in this group model LLVMValueRef instances that correspond |
| 1890 | * to constants referring to scalar types. |
| 1891 | * |
| 1892 | * For integer types, the LLVMTypeRef parameter should correspond to a |
| 1893 | * llvm::IntegerType instance and the returned LLVMValueRef will |
| 1894 | * correspond to a llvm::ConstantInt. |
| 1895 | * |
| 1896 | * For floating point types, the LLVMTypeRef returned corresponds to a |
| 1897 | * llvm::ConstantFP. |
| 1898 | * |
| 1899 | * @{ |
| 1900 | */ |
Erick Tryzelaar | d8531fa | 2010-02-28 09:45:59 +0000 | [diff] [blame] | 1901 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1902 | /** |
| 1903 | * Obtain a constant value for an integer type. |
| 1904 | * |
| 1905 | * The returned value corresponds to a llvm::ConstantInt. |
| 1906 | * |
| 1907 | * @see llvm::ConstantInt::get() |
| 1908 | * |
| 1909 | * @param IntTy Integer type to obtain value of. |
| 1910 | * @param N The value the returned instance should refer to. |
| 1911 | * @param SignExtend Whether to sign extend the produced value. |
| 1912 | */ |
Gordon Henriksen | 1046c73 | 2007-10-06 15:11:06 +0000 | [diff] [blame] | 1913 | LLVMValueRef LLVMConstInt(LLVMTypeRef IntTy, unsigned long long N, |
Chris Lattner | 25963c6 | 2010-01-09 22:27:07 +0000 | [diff] [blame] | 1914 | LLVMBool SignExtend); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1915 | |
| 1916 | /** |
| 1917 | * Obtain a constant value for an integer of arbitrary precision. |
| 1918 | * |
| 1919 | * @see llvm::ConstantInt::get() |
| 1920 | */ |
Chris Lattner | 4329e07 | 2010-11-23 02:47:22 +0000 | [diff] [blame] | 1921 | LLVMValueRef LLVMConstIntOfArbitraryPrecision(LLVMTypeRef IntTy, |
| 1922 | unsigned NumWords, |
| 1923 | const uint64_t Words[]); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1924 | |
| 1925 | /** |
| 1926 | * Obtain a constant value for an integer parsed from a string. |
| 1927 | * |
| 1928 | * A similar API, LLVMConstIntOfStringAndSize is also available. If the |
| 1929 | * string's length is available, it is preferred to call that function |
| 1930 | * instead. |
| 1931 | * |
| 1932 | * @see llvm::ConstantInt::get() |
| 1933 | */ |
Erick Tryzelaar | dd99135 | 2009-08-16 23:36:46 +0000 | [diff] [blame] | 1934 | LLVMValueRef LLVMConstIntOfString(LLVMTypeRef IntTy, const char *Text, |
| 1935 | uint8_t Radix); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1936 | |
| 1937 | /** |
| 1938 | * Obtain a constant value for an integer parsed from a string with |
| 1939 | * specified length. |
| 1940 | * |
| 1941 | * @see llvm::ConstantInt::get() |
| 1942 | */ |
Erick Tryzelaar | dd99135 | 2009-08-16 23:36:46 +0000 | [diff] [blame] | 1943 | LLVMValueRef LLVMConstIntOfStringAndSize(LLVMTypeRef IntTy, const char *Text, |
| 1944 | unsigned SLen, uint8_t Radix); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1945 | |
| 1946 | /** |
| 1947 | * Obtain a constant value referring to a double floating point value. |
| 1948 | */ |
Gordon Henriksen | 1046c73 | 2007-10-06 15:11:06 +0000 | [diff] [blame] | 1949 | LLVMValueRef LLVMConstReal(LLVMTypeRef RealTy, double N); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1950 | |
| 1951 | /** |
| 1952 | * Obtain a constant for a floating point value parsed from a string. |
| 1953 | * |
| 1954 | * A similar API, LLVMConstRealOfStringAndSize is also available. It |
| 1955 | * should be used if the input string's length is known. |
| 1956 | */ |
Gordon Henriksen | 931e121 | 2008-02-02 01:07:50 +0000 | [diff] [blame] | 1957 | LLVMValueRef LLVMConstRealOfString(LLVMTypeRef RealTy, const char *Text); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1958 | |
| 1959 | /** |
| 1960 | * Obtain a constant for a floating point value parsed from a string. |
| 1961 | */ |
Erick Tryzelaar | dd99135 | 2009-08-16 23:36:46 +0000 | [diff] [blame] | 1962 | LLVMValueRef LLVMConstRealOfStringAndSize(LLVMTypeRef RealTy, const char *Text, |
| 1963 | unsigned SLen); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1964 | |
| 1965 | /** |
| 1966 | * Obtain the zero extended value for an integer constant value. |
| 1967 | * |
| 1968 | * @see llvm::ConstantInt::getZExtValue() |
| 1969 | */ |
Chris Lattner | 40cf28d | 2009-10-12 04:01:02 +0000 | [diff] [blame] | 1970 | unsigned long long LLVMConstIntGetZExtValue(LLVMValueRef ConstantVal); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1971 | |
| 1972 | /** |
| 1973 | * Obtain the sign extended value for an integer constant value. |
| 1974 | * |
| 1975 | * @see llvm::ConstantInt::getSExtValue() |
| 1976 | */ |
Chris Lattner | 40cf28d | 2009-10-12 04:01:02 +0000 | [diff] [blame] | 1977 | long long LLVMConstIntGetSExtValue(LLVMValueRef ConstantVal); |
Erick Tryzelaar | dd99135 | 2009-08-16 23:36:46 +0000 | [diff] [blame] | 1978 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1979 | /** |
Peter Zotov | 1d98e6d | 2014-10-28 19:46:44 +0000 | [diff] [blame] | 1980 | * Obtain the double value for an floating point constant value. |
| 1981 | * losesInfo indicates if some precision was lost in the conversion. |
| 1982 | * |
| 1983 | * @see llvm::ConstantFP::getDoubleValue |
| 1984 | */ |
| 1985 | double LLVMConstRealGetDouble(LLVMValueRef ConstantVal, LLVMBool *losesInfo); |
| 1986 | |
| 1987 | /** |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1988 | * @} |
| 1989 | */ |
| 1990 | |
| 1991 | /** |
Gregory Szorc | 52d2660 | 2012-03-21 07:28:27 +0000 | [diff] [blame] | 1992 | * @defgroup LLVMCCoreValueConstantComposite Composite Constants |
| 1993 | * |
| 1994 | * Functions in this group operate on composite constants. |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 1995 | * |
| 1996 | * @{ |
| 1997 | */ |
| 1998 | |
| 1999 | /** |
Gregory Szorc | 52d2660 | 2012-03-21 07:28:27 +0000 | [diff] [blame] | 2000 | * Create a ConstantDataSequential and initialize it with a string. |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 2001 | * |
Gregory Szorc | 52d2660 | 2012-03-21 07:28:27 +0000 | [diff] [blame] | 2002 | * @see llvm::ConstantDataArray::getString() |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 2003 | */ |
Erick Tryzelaar | 262332f | 2009-08-14 00:01:31 +0000 | [diff] [blame] | 2004 | LLVMValueRef LLVMConstStringInContext(LLVMContextRef C, const char *Str, |
Chris Lattner | 25963c6 | 2010-01-09 22:27:07 +0000 | [diff] [blame] | 2005 | unsigned Length, LLVMBool DontNullTerminate); |
Gregory Szorc | 52d2660 | 2012-03-21 07:28:27 +0000 | [diff] [blame] | 2006 | |
| 2007 | /** |
| 2008 | * Create a ConstantDataSequential with string content in the global context. |
| 2009 | * |
| 2010 | * This is the same as LLVMConstStringInContext except it operates on the |
| 2011 | * global context. |
| 2012 | * |
| 2013 | * @see LLVMConstStringInContext() |
| 2014 | * @see llvm::ConstantDataArray::getString() |
| 2015 | */ |
| 2016 | LLVMValueRef LLVMConstString(const char *Str, unsigned Length, |
| 2017 | LLVMBool DontNullTerminate); |
| 2018 | |
| 2019 | /** |
Peter Zotov | f9aa882 | 2014-08-03 23:54:16 +0000 | [diff] [blame] | 2020 | * Returns true if the specified constant is an array of i8. |
| 2021 | * |
| 2022 | * @see ConstantDataSequential::getAsString() |
| 2023 | */ |
| 2024 | LLVMBool LLVMIsConstantString(LLVMValueRef c); |
| 2025 | |
| 2026 | /** |
| 2027 | * Get the given constant data sequential as a string. |
| 2028 | * |
| 2029 | * @see ConstantDataSequential::getAsString() |
| 2030 | */ |
Amaury Sechet | 7c2883c | 2016-04-03 21:06:04 +0000 | [diff] [blame] | 2031 | const char *LLVMGetAsString(LLVMValueRef c, size_t *Length); |
Peter Zotov | f9aa882 | 2014-08-03 23:54:16 +0000 | [diff] [blame] | 2032 | |
| 2033 | /** |
Gregory Szorc | 52d2660 | 2012-03-21 07:28:27 +0000 | [diff] [blame] | 2034 | * Create an anonymous ConstantStruct with the specified values. |
| 2035 | * |
| 2036 | * @see llvm::ConstantStruct::getAnon() |
| 2037 | */ |
| 2038 | LLVMValueRef LLVMConstStructInContext(LLVMContextRef C, |
Erick Tryzelaar | 262332f | 2009-08-14 00:01:31 +0000 | [diff] [blame] | 2039 | LLVMValueRef *ConstantVals, |
Chris Lattner | 25963c6 | 2010-01-09 22:27:07 +0000 | [diff] [blame] | 2040 | unsigned Count, LLVMBool Packed); |
Erick Tryzelaar | 262332f | 2009-08-14 00:01:31 +0000 | [diff] [blame] | 2041 | |
Gregory Szorc | 52d2660 | 2012-03-21 07:28:27 +0000 | [diff] [blame] | 2042 | /** |
| 2043 | * Create a ConstantStruct in the global Context. |
| 2044 | * |
| 2045 | * This is the same as LLVMConstStructInContext except it operates on the |
| 2046 | * global Context. |
| 2047 | * |
| 2048 | * @see LLVMConstStructInContext() |
| 2049 | */ |
Gordon Henriksen | 1046c73 | 2007-10-06 15:11:06 +0000 | [diff] [blame] | 2050 | LLVMValueRef LLVMConstStruct(LLVMValueRef *ConstantVals, unsigned Count, |
Chris Lattner | 25963c6 | 2010-01-09 22:27:07 +0000 | [diff] [blame] | 2051 | LLVMBool Packed); |
Gregory Szorc | 52d2660 | 2012-03-21 07:28:27 +0000 | [diff] [blame] | 2052 | |
| 2053 | /** |
| 2054 | * Create a ConstantArray from values. |
| 2055 | * |
| 2056 | * @see llvm::ConstantArray::get() |
| 2057 | */ |
| 2058 | LLVMValueRef LLVMConstArray(LLVMTypeRef ElementTy, |
| 2059 | LLVMValueRef *ConstantVals, unsigned Length); |
| 2060 | |
| 2061 | /** |
| 2062 | * Create a non-anonymous ConstantStruct from values. |
| 2063 | * |
| 2064 | * @see llvm::ConstantStruct::get() |
| 2065 | */ |
Rafael Espindola | 784ad24 | 2011-07-14 19:09:08 +0000 | [diff] [blame] | 2066 | LLVMValueRef LLVMConstNamedStruct(LLVMTypeRef StructTy, |
| 2067 | LLVMValueRef *ConstantVals, |
| 2068 | unsigned Count); |
Gregory Szorc | 52d2660 | 2012-03-21 07:28:27 +0000 | [diff] [blame] | 2069 | |
| 2070 | /** |
Peter Zotov | f9aa882 | 2014-08-03 23:54:16 +0000 | [diff] [blame] | 2071 | * Get an element at specified index as a constant. |
| 2072 | * |
| 2073 | * @see ConstantDataSequential::getElementAsConstant() |
| 2074 | */ |
Amaury Sechet | 006ce63 | 2016-03-13 00:54:40 +0000 | [diff] [blame] | 2075 | LLVMValueRef LLVMGetElementAsConstant(LLVMValueRef C, unsigned idx); |
Peter Zotov | f9aa882 | 2014-08-03 23:54:16 +0000 | [diff] [blame] | 2076 | |
| 2077 | /** |
Gregory Szorc | 52d2660 | 2012-03-21 07:28:27 +0000 | [diff] [blame] | 2078 | * Create a ConstantVector from values. |
| 2079 | * |
| 2080 | * @see llvm::ConstantVector::get() |
| 2081 | */ |
Gordon Henriksen | 1046c73 | 2007-10-06 15:11:06 +0000 | [diff] [blame] | 2082 | LLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals, unsigned Size); |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 2083 | |
Gregory Szorc | 52d2660 | 2012-03-21 07:28:27 +0000 | [diff] [blame] | 2084 | /** |
| 2085 | * @} |
| 2086 | */ |
| 2087 | |
| 2088 | /** |
| 2089 | * @defgroup LLVMCCoreValueConstantExpressions Constant Expressions |
| 2090 | * |
| 2091 | * Functions in this group correspond to APIs on llvm::ConstantExpr. |
| 2092 | * |
| 2093 | * @see llvm::ConstantExpr. |
| 2094 | * |
| 2095 | * @{ |
| 2096 | */ |
Chris Lattner | 40cf28d | 2009-10-12 04:01:02 +0000 | [diff] [blame] | 2097 | LLVMOpcode LLVMGetConstOpcode(LLVMValueRef ConstantVal); |
Erick Tryzelaar | fd529d7 | 2009-08-19 08:36:49 +0000 | [diff] [blame] | 2098 | LLVMValueRef LLVMAlignOf(LLVMTypeRef Ty); |
Gordon Henriksen | 7ce3176 | 2007-10-06 14:29:36 +0000 | [diff] [blame] | 2099 | LLVMValueRef LLVMSizeOf(LLVMTypeRef Ty); |
| 2100 | LLVMValueRef LLVMConstNeg(LLVMValueRef ConstantVal); |
Erick Tryzelaar | 4c340c7 | 2010-02-28 05:51:43 +0000 | [diff] [blame] | 2101 | LLVMValueRef LLVMConstNSWNeg(LLVMValueRef ConstantVal); |
| 2102 | LLVMValueRef LLVMConstNUWNeg(LLVMValueRef ConstantVal); |
Erick Tryzelaar | 4cc690c | 2009-08-16 02:20:12 +0000 | [diff] [blame] | 2103 | LLVMValueRef LLVMConstFNeg(LLVMValueRef ConstantVal); |
Gordon Henriksen | 7ce3176 | 2007-10-06 14:29:36 +0000 | [diff] [blame] | 2104 | LLVMValueRef LLVMConstNot(LLVMValueRef ConstantVal); |
| 2105 | LLVMValueRef LLVMConstAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); |
Dan Gohman | e4ca02d | 2009-09-03 23:34:49 +0000 | [diff] [blame] | 2106 | LLVMValueRef LLVMConstNSWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); |
Erick Tryzelaar | 4c340c7 | 2010-02-28 05:51:43 +0000 | [diff] [blame] | 2107 | LLVMValueRef LLVMConstNUWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); |
Erick Tryzelaar | 4cc690c | 2009-08-16 02:20:12 +0000 | [diff] [blame] | 2108 | LLVMValueRef LLVMConstFAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); |
Gordon Henriksen | 7ce3176 | 2007-10-06 14:29:36 +0000 | [diff] [blame] | 2109 | LLVMValueRef LLVMConstSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); |
Erick Tryzelaar | 4c340c7 | 2010-02-28 05:51:43 +0000 | [diff] [blame] | 2110 | LLVMValueRef LLVMConstNSWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); |
| 2111 | LLVMValueRef LLVMConstNUWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); |
Erick Tryzelaar | 4cc690c | 2009-08-16 02:20:12 +0000 | [diff] [blame] | 2112 | LLVMValueRef LLVMConstFSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); |
Gordon Henriksen | 7ce3176 | 2007-10-06 14:29:36 +0000 | [diff] [blame] | 2113 | LLVMValueRef LLVMConstMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); |
Erick Tryzelaar | 4c340c7 | 2010-02-28 05:51:43 +0000 | [diff] [blame] | 2114 | LLVMValueRef LLVMConstNSWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); |
| 2115 | LLVMValueRef LLVMConstNUWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); |
Erick Tryzelaar | 4cc690c | 2009-08-16 02:20:12 +0000 | [diff] [blame] | 2116 | LLVMValueRef LLVMConstFMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); |
Gordon Henriksen | 7ce3176 | 2007-10-06 14:29:36 +0000 | [diff] [blame] | 2117 | LLVMValueRef LLVMConstUDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); |
Manuel Jacob | 49fafb1 | 2016-10-04 23:32:42 +0000 | [diff] [blame] | 2118 | LLVMValueRef LLVMConstExactUDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); |
Gordon Henriksen | 7ce3176 | 2007-10-06 14:29:36 +0000 | [diff] [blame] | 2119 | LLVMValueRef LLVMConstSDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); |
Dan Gohman | e4ca02d | 2009-09-03 23:34:49 +0000 | [diff] [blame] | 2120 | LLVMValueRef LLVMConstExactSDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); |
Gordon Henriksen | 7ce3176 | 2007-10-06 14:29:36 +0000 | [diff] [blame] | 2121 | LLVMValueRef LLVMConstFDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); |
| 2122 | LLVMValueRef LLVMConstURem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); |
| 2123 | LLVMValueRef LLVMConstSRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); |
| 2124 | LLVMValueRef LLVMConstFRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); |
| 2125 | LLVMValueRef LLVMConstAnd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); |
| 2126 | LLVMValueRef LLVMConstOr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); |
| 2127 | LLVMValueRef LLVMConstXor(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); |
| 2128 | LLVMValueRef LLVMConstICmp(LLVMIntPredicate Predicate, |
| 2129 | LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); |
| 2130 | LLVMValueRef LLVMConstFCmp(LLVMRealPredicate Predicate, |
| 2131 | LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); |
| 2132 | LLVMValueRef LLVMConstShl(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); |
| 2133 | LLVMValueRef LLVMConstLShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); |
| 2134 | LLVMValueRef LLVMConstAShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); |
| 2135 | LLVMValueRef LLVMConstGEP(LLVMValueRef ConstantVal, |
| 2136 | LLVMValueRef *ConstantIndices, unsigned NumIndices); |
James Y Knight | 544fa42 | 2019-01-14 21:39:35 +0000 | [diff] [blame] | 2137 | LLVMValueRef LLVMConstGEP2(LLVMTypeRef Ty, LLVMValueRef ConstantVal, |
| 2138 | LLVMValueRef *ConstantIndices, unsigned NumIndices); |
Dan Gohman | e4ca02d | 2009-09-03 23:34:49 +0000 | [diff] [blame] | 2139 | LLVMValueRef LLVMConstInBoundsGEP(LLVMValueRef ConstantVal, |
| 2140 | LLVMValueRef *ConstantIndices, |
| 2141 | unsigned NumIndices); |
James Y Knight | 544fa42 | 2019-01-14 21:39:35 +0000 | [diff] [blame] | 2142 | LLVMValueRef LLVMConstInBoundsGEP2(LLVMTypeRef Ty, LLVMValueRef ConstantVal, |
| 2143 | LLVMValueRef *ConstantIndices, |
| 2144 | unsigned NumIndices); |
Gordon Henriksen | 7ce3176 | 2007-10-06 14:29:36 +0000 | [diff] [blame] | 2145 | LLVMValueRef LLVMConstTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType); |
| 2146 | LLVMValueRef LLVMConstSExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType); |
| 2147 | LLVMValueRef LLVMConstZExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType); |
| 2148 | LLVMValueRef LLVMConstFPTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType); |
| 2149 | LLVMValueRef LLVMConstFPExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType); |
| 2150 | LLVMValueRef LLVMConstUIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType); |
| 2151 | LLVMValueRef LLVMConstSIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType); |
| 2152 | LLVMValueRef LLVMConstFPToUI(LLVMValueRef ConstantVal, LLVMTypeRef ToType); |
| 2153 | LLVMValueRef LLVMConstFPToSI(LLVMValueRef ConstantVal, LLVMTypeRef ToType); |
| 2154 | LLVMValueRef LLVMConstPtrToInt(LLVMValueRef ConstantVal, LLVMTypeRef ToType); |
| 2155 | LLVMValueRef LLVMConstIntToPtr(LLVMValueRef ConstantVal, LLVMTypeRef ToType); |
| 2156 | LLVMValueRef LLVMConstBitCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType); |
Matt Arsenault | b03bd4d | 2013-11-15 01:34:59 +0000 | [diff] [blame] | 2157 | LLVMValueRef LLVMConstAddrSpaceCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType); |
Erick Tryzelaar | 4cc690c | 2009-08-16 02:20:12 +0000 | [diff] [blame] | 2158 | LLVMValueRef LLVMConstZExtOrBitCast(LLVMValueRef ConstantVal, |
| 2159 | LLVMTypeRef ToType); |
| 2160 | LLVMValueRef LLVMConstSExtOrBitCast(LLVMValueRef ConstantVal, |
| 2161 | LLVMTypeRef ToType); |
| 2162 | LLVMValueRef LLVMConstTruncOrBitCast(LLVMValueRef ConstantVal, |
| 2163 | LLVMTypeRef ToType); |
| 2164 | LLVMValueRef LLVMConstPointerCast(LLVMValueRef ConstantVal, |
| 2165 | LLVMTypeRef ToType); |
| 2166 | LLVMValueRef LLVMConstIntCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType, |
Chris Lattner | 25963c6 | 2010-01-09 22:27:07 +0000 | [diff] [blame] | 2167 | LLVMBool isSigned); |
Erick Tryzelaar | 4cc690c | 2009-08-16 02:20:12 +0000 | [diff] [blame] | 2168 | LLVMValueRef LLVMConstFPCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType); |
Gordon Henriksen | 7ce3176 | 2007-10-06 14:29:36 +0000 | [diff] [blame] | 2169 | LLVMValueRef LLVMConstSelect(LLVMValueRef ConstantCondition, |
| 2170 | LLVMValueRef ConstantIfTrue, |
| 2171 | LLVMValueRef ConstantIfFalse); |
| 2172 | LLVMValueRef LLVMConstExtractElement(LLVMValueRef VectorConstant, |
| 2173 | LLVMValueRef IndexConstant); |
| 2174 | LLVMValueRef LLVMConstInsertElement(LLVMValueRef VectorConstant, |
| 2175 | LLVMValueRef ElementValueConstant, |
| 2176 | LLVMValueRef IndexConstant); |
| 2177 | LLVMValueRef LLVMConstShuffleVector(LLVMValueRef VectorAConstant, |
| 2178 | LLVMValueRef VectorBConstant, |
| 2179 | LLVMValueRef MaskConstant); |
Dan Gohman | d5104a5 | 2008-11-03 22:55:43 +0000 | [diff] [blame] | 2180 | LLVMValueRef LLVMConstExtractValue(LLVMValueRef AggConstant, unsigned *IdxList, |
| 2181 | unsigned NumIdx); |
| 2182 | LLVMValueRef LLVMConstInsertValue(LLVMValueRef AggConstant, |
| 2183 | LLVMValueRef ElementValueConstant, |
| 2184 | unsigned *IdxList, unsigned NumIdx); |
Robert Widmann | f108d57 | 2018-04-06 02:31:29 +0000 | [diff] [blame] | 2185 | LLVMValueRef LLVMBlockAddress(LLVMValueRef F, LLVMBasicBlockRef BB); |
| 2186 | |
| 2187 | /** Deprecated: Use LLVMGetInlineAsm instead. */ |
Chris Lattner | 25963c6 | 2010-01-09 22:27:07 +0000 | [diff] [blame] | 2188 | LLVMValueRef LLVMConstInlineAsm(LLVMTypeRef Ty, |
Chris Lattner | 3d1f552 | 2008-12-17 21:39:50 +0000 | [diff] [blame] | 2189 | const char *AsmString, const char *Constraints, |
Chris Lattner | 25963c6 | 2010-01-09 22:27:07 +0000 | [diff] [blame] | 2190 | LLVMBool HasSideEffects, LLVMBool IsAlignStack); |
Gordon Henriksen | 7ce3176 | 2007-10-06 14:29:36 +0000 | [diff] [blame] | 2191 | |
Gregory Szorc | 52d2660 | 2012-03-21 07:28:27 +0000 | [diff] [blame] | 2192 | /** |
| 2193 | * @} |
| 2194 | */ |
| 2195 | |
| 2196 | /** |
| 2197 | * @defgroup LLVMCCoreValueConstantGlobals Global Values |
| 2198 | * |
| 2199 | * This group contains functions that operate on global values. Functions in |
| 2200 | * this group relate to functions in the llvm::GlobalValue class tree. |
| 2201 | * |
| 2202 | * @see llvm::GlobalValue |
| 2203 | * |
| 2204 | * @{ |
| 2205 | */ |
| 2206 | |
Gordon Henriksen | 265f780 | 2008-03-19 01:11:35 +0000 | [diff] [blame] | 2207 | LLVMModuleRef LLVMGetGlobalParent(LLVMValueRef Global); |
Chris Lattner | 25963c6 | 2010-01-09 22:27:07 +0000 | [diff] [blame] | 2208 | LLVMBool LLVMIsDeclaration(LLVMValueRef Global); |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 2209 | LLVMLinkage LLVMGetLinkage(LLVMValueRef Global); |
| 2210 | void LLVMSetLinkage(LLVMValueRef Global, LLVMLinkage Linkage); |
| 2211 | const char *LLVMGetSection(LLVMValueRef Global); |
| 2212 | void LLVMSetSection(LLVMValueRef Global, const char *Section); |
| 2213 | LLVMVisibility LLVMGetVisibility(LLVMValueRef Global); |
| 2214 | void LLVMSetVisibility(LLVMValueRef Global, LLVMVisibility Viz); |
Reid Kleckner | 2fae26f | 2014-03-05 02:34:23 +0000 | [diff] [blame] | 2215 | LLVMDLLStorageClass LLVMGetDLLStorageClass(LLVMValueRef Global); |
| 2216 | void LLVMSetDLLStorageClass(LLVMValueRef Global, LLVMDLLStorageClass Class); |
Robert Widmann | 4bb481b | 2018-03-14 06:45:51 +0000 | [diff] [blame] | 2217 | LLVMUnnamedAddr LLVMGetUnnamedAddress(LLVMValueRef Global); |
| 2218 | void LLVMSetUnnamedAddress(LLVMValueRef Global, LLVMUnnamedAddr UnnamedAddr); |
| 2219 | |
Robert Widmann | e63a12c | 2018-09-28 20:54:29 +0000 | [diff] [blame] | 2220 | /** |
| 2221 | * Returns the "value type" of a global value. This differs from the formal |
| 2222 | * type of a global value which is always a pointer type. |
| 2223 | * |
| 2224 | * @see llvm::GlobalValue::getValueType() |
| 2225 | */ |
| 2226 | LLVMTypeRef LLVMGlobalGetValueType(LLVMValueRef Global); |
| 2227 | |
Robert Widmann | 4bb481b | 2018-03-14 06:45:51 +0000 | [diff] [blame] | 2228 | /** Deprecated: Use LLVMGetUnnamedAddress instead. */ |
Tim Northover | ad96d01 | 2014-03-10 19:24:35 +0000 | [diff] [blame] | 2229 | LLVMBool LLVMHasUnnamedAddr(LLVMValueRef Global); |
Robert Widmann | 4bb481b | 2018-03-14 06:45:51 +0000 | [diff] [blame] | 2230 | /** Deprecated: Use LLVMSetUnnamedAddress instead. */ |
Tim Northover | ad96d01 | 2014-03-10 19:24:35 +0000 | [diff] [blame] | 2231 | void LLVMSetUnnamedAddr(LLVMValueRef Global, LLVMBool HasUnnamedAddr); |
Anders Waldenborg | 213a63f | 2013-10-29 09:02:02 +0000 | [diff] [blame] | 2232 | |
| 2233 | /** |
| 2234 | * @defgroup LLVMCCoreValueWithAlignment Values with alignment |
| 2235 | * |
| 2236 | * Functions in this group only apply to values with alignment, i.e. |
| 2237 | * global variables, load and store instructions. |
| 2238 | */ |
| 2239 | |
| 2240 | /** |
| 2241 | * Obtain the preferred alignment of the value. |
Peter Zotov | 9f584e6 | 2014-03-05 05:05:34 +0000 | [diff] [blame] | 2242 | * @see llvm::AllocaInst::getAlignment() |
Anders Waldenborg | 213a63f | 2013-10-29 09:02:02 +0000 | [diff] [blame] | 2243 | * @see llvm::LoadInst::getAlignment() |
| 2244 | * @see llvm::StoreInst::getAlignment() |
| 2245 | * @see llvm::GlobalValue::getAlignment() |
| 2246 | */ |
| 2247 | unsigned LLVMGetAlignment(LLVMValueRef V); |
| 2248 | |
| 2249 | /** |
| 2250 | * Set the preferred alignment of the value. |
Peter Zotov | 9f584e6 | 2014-03-05 05:05:34 +0000 | [diff] [blame] | 2251 | * @see llvm::AllocaInst::setAlignment() |
Anders Waldenborg | 213a63f | 2013-10-29 09:02:02 +0000 | [diff] [blame] | 2252 | * @see llvm::LoadInst::setAlignment() |
| 2253 | * @see llvm::StoreInst::setAlignment() |
| 2254 | * @see llvm::GlobalValue::setAlignment() |
| 2255 | */ |
| 2256 | void LLVMSetAlignment(LLVMValueRef V, unsigned Bytes); |
| 2257 | |
| 2258 | /** |
Robert Widmann | 9cba4ec | 2018-09-28 15:35:18 +0000 | [diff] [blame] | 2259 | * Sets a metadata attachment, erasing the existing metadata attachment if |
| 2260 | * it already exists for the given kind. |
| 2261 | * |
| 2262 | * @see llvm::GlobalObject::setMetadata() |
| 2263 | */ |
| 2264 | void LLVMGlobalSetMetadata(LLVMValueRef Global, unsigned Kind, |
| 2265 | LLVMMetadataRef MD); |
| 2266 | |
| 2267 | /** |
| 2268 | * Erases a metadata attachment of the given kind if it exists. |
| 2269 | * |
| 2270 | * @see llvm::GlobalObject::eraseMetadata() |
| 2271 | */ |
| 2272 | void LLVMGlobalEraseMetadata(LLVMValueRef Global, unsigned Kind); |
| 2273 | |
| 2274 | /** |
| 2275 | * Removes all metadata attachments from this value. |
| 2276 | * |
| 2277 | * @see llvm::GlobalObject::clearMetadata() |
| 2278 | */ |
| 2279 | void LLVMGlobalClearMetadata(LLVMValueRef Global); |
| 2280 | |
| 2281 | /** |
| 2282 | * Retrieves an array of metadata entries representing the metadata attached to |
| 2283 | * this value. The caller is responsible for freeing this array by calling |
| 2284 | * \c LLVMDisposeValueMetadataEntries. |
| 2285 | * |
| 2286 | * @see llvm::GlobalObject::getAllMetadata() |
| 2287 | */ |
| 2288 | LLVMValueMetadataEntry *LLVMGlobalCopyAllMetadata(LLVMValueRef Value, |
| 2289 | size_t *NumEntries); |
| 2290 | |
| 2291 | /** |
| 2292 | * Destroys value metadata entries. |
| 2293 | */ |
| 2294 | void LLVMDisposeValueMetadataEntries(LLVMValueMetadataEntry *Entries); |
| 2295 | |
| 2296 | /** |
| 2297 | * Returns the kind of a value metadata entry at a specific index. |
| 2298 | */ |
| 2299 | unsigned LLVMValueMetadataEntriesGetKind(LLVMValueMetadataEntry *Entries, |
| 2300 | unsigned Index); |
| 2301 | |
| 2302 | /** |
| 2303 | * Returns the underlying metadata node of a value metadata entry at a |
| 2304 | * specific index. |
| 2305 | */ |
| 2306 | LLVMMetadataRef |
| 2307 | LLVMValueMetadataEntriesGetMetadata(LLVMValueMetadataEntry *Entries, |
| 2308 | unsigned Index); |
| 2309 | |
| 2310 | /** |
Amaury Sechet | 8355010 | 2016-02-14 08:58:49 +0000 | [diff] [blame] | 2311 | * @} |
| 2312 | */ |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 2313 | |
Gregory Szorc | 52d2660 | 2012-03-21 07:28:27 +0000 | [diff] [blame] | 2314 | /** |
| 2315 | * @defgroup LLVMCoreValueConstantGlobalVariable Global Variables |
| 2316 | * |
| 2317 | * This group contains functions that operate on global variable values. |
| 2318 | * |
| 2319 | * @see llvm::GlobalVariable |
| 2320 | * |
| 2321 | * @{ |
| 2322 | */ |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 2323 | LLVMValueRef LLVMAddGlobal(LLVMModuleRef M, LLVMTypeRef Ty, const char *Name); |
Erick Tryzelaar | 06894b3 | 2010-02-28 09:46:13 +0000 | [diff] [blame] | 2324 | LLVMValueRef LLVMAddGlobalInAddressSpace(LLVMModuleRef M, LLVMTypeRef Ty, |
| 2325 | const char *Name, |
| 2326 | unsigned AddressSpace); |
Gordon Henriksen | 783f7bb | 2007-10-08 03:45:09 +0000 | [diff] [blame] | 2327 | LLVMValueRef LLVMGetNamedGlobal(LLVMModuleRef M, const char *Name); |
Gordon Henriksen | 07a45f4 | 2008-03-23 22:21:29 +0000 | [diff] [blame] | 2328 | LLVMValueRef LLVMGetFirstGlobal(LLVMModuleRef M); |
| 2329 | LLVMValueRef LLVMGetLastGlobal(LLVMModuleRef M); |
| 2330 | LLVMValueRef LLVMGetNextGlobal(LLVMValueRef GlobalVar); |
| 2331 | LLVMValueRef LLVMGetPreviousGlobal(LLVMValueRef GlobalVar); |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 2332 | void LLVMDeleteGlobal(LLVMValueRef GlobalVar); |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 2333 | LLVMValueRef LLVMGetInitializer(LLVMValueRef GlobalVar); |
| 2334 | void LLVMSetInitializer(LLVMValueRef GlobalVar, LLVMValueRef ConstantVal); |
Chris Lattner | 25963c6 | 2010-01-09 22:27:07 +0000 | [diff] [blame] | 2335 | LLVMBool LLVMIsThreadLocal(LLVMValueRef GlobalVar); |
| 2336 | void LLVMSetThreadLocal(LLVMValueRef GlobalVar, LLVMBool IsThreadLocal); |
| 2337 | LLVMBool LLVMIsGlobalConstant(LLVMValueRef GlobalVar); |
| 2338 | void LLVMSetGlobalConstant(LLVMValueRef GlobalVar, LLVMBool IsConstant); |
Hans Wennborg | 5ff7120 | 2013-04-16 08:58:59 +0000 | [diff] [blame] | 2339 | LLVMThreadLocalMode LLVMGetThreadLocalMode(LLVMValueRef GlobalVar); |
| 2340 | void LLVMSetThreadLocalMode(LLVMValueRef GlobalVar, LLVMThreadLocalMode Mode); |
| 2341 | LLVMBool LLVMIsExternallyInitialized(LLVMValueRef GlobalVar); |
| 2342 | void LLVMSetExternallyInitialized(LLVMValueRef GlobalVar, LLVMBool IsExtInit); |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 2343 | |
Gregory Szorc | 52d2660 | 2012-03-21 07:28:27 +0000 | [diff] [blame] | 2344 | /** |
| 2345 | * @} |
| 2346 | */ |
| 2347 | |
| 2348 | /** |
| 2349 | * @defgroup LLVMCoreValueConstantGlobalAlias Global Aliases |
| 2350 | * |
| 2351 | * This group contains function that operate on global alias values. |
| 2352 | * |
| 2353 | * @see llvm::GlobalAlias |
| 2354 | * |
| 2355 | * @{ |
| 2356 | */ |
Chris Lattner | 3d1f552 | 2008-12-17 21:39:50 +0000 | [diff] [blame] | 2357 | LLVMValueRef LLVMAddAlias(LLVMModuleRef M, LLVMTypeRef Ty, LLVMValueRef Aliasee, |
| 2358 | const char *Name); |
| 2359 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 2360 | /** |
Robert Widmann | 360d6e3 | 2018-05-20 23:49:08 +0000 | [diff] [blame] | 2361 | * Obtain a GlobalAlias value from a Module by its name. |
| 2362 | * |
| 2363 | * The returned value corresponds to a llvm::GlobalAlias value. |
| 2364 | * |
| 2365 | * @see llvm::Module::getNamedAlias() |
| 2366 | */ |
| 2367 | LLVMValueRef LLVMGetNamedGlobalAlias(LLVMModuleRef M, |
| 2368 | const char *Name, size_t NameLen); |
| 2369 | |
| 2370 | /** |
| 2371 | * Obtain an iterator to the first GlobalAlias in a Module. |
| 2372 | * |
| 2373 | * @see llvm::Module::alias_begin() |
| 2374 | */ |
| 2375 | LLVMValueRef LLVMGetFirstGlobalAlias(LLVMModuleRef M); |
| 2376 | |
| 2377 | /** |
| 2378 | * Obtain an iterator to the last GlobalAlias in a Module. |
| 2379 | * |
| 2380 | * @see llvm::Module::alias_end() |
| 2381 | */ |
| 2382 | LLVMValueRef LLVMGetLastGlobalAlias(LLVMModuleRef M); |
| 2383 | |
| 2384 | /** |
| 2385 | * Advance a GlobalAlias iterator to the next GlobalAlias. |
| 2386 | * |
| 2387 | * Returns NULL if the iterator was already at the end and there are no more |
| 2388 | * global aliases. |
| 2389 | */ |
| 2390 | LLVMValueRef LLVMGetNextGlobalAlias(LLVMValueRef GA); |
| 2391 | |
| 2392 | /** |
| 2393 | * Decrement a GlobalAlias iterator to the previous GlobalAlias. |
| 2394 | * |
| 2395 | * Returns NULL if the iterator was already at the beginning and there are |
| 2396 | * no previous global aliases. |
| 2397 | */ |
| 2398 | LLVMValueRef LLVMGetPreviousGlobalAlias(LLVMValueRef GA); |
| 2399 | |
| 2400 | /** |
| 2401 | * Retrieve the target value of an alias. |
| 2402 | */ |
| 2403 | LLVMValueRef LLVMAliasGetAliasee(LLVMValueRef Alias); |
| 2404 | |
| 2405 | /** |
| 2406 | * Set the target value of an alias. |
| 2407 | */ |
| 2408 | void LLVMAliasSetAliasee(LLVMValueRef Alias, LLVMValueRef Aliasee); |
| 2409 | |
| 2410 | /** |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 2411 | * @} |
| 2412 | */ |
| 2413 | |
| 2414 | /** |
| 2415 | * @defgroup LLVMCCoreValueFunction Function values |
| 2416 | * |
| 2417 | * Functions in this group operate on LLVMValueRef instances that |
| 2418 | * correspond to llvm::Function instances. |
| 2419 | * |
| 2420 | * @see llvm::Function |
| 2421 | * |
| 2422 | * @{ |
| 2423 | */ |
| 2424 | |
| 2425 | /** |
| 2426 | * Remove a function from its containing module and deletes it. |
| 2427 | * |
| 2428 | * @see llvm::Function::eraseFromParent() |
| 2429 | */ |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 2430 | void LLVMDeleteFunction(LLVMValueRef Fn); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 2431 | |
| 2432 | /** |
Amaury Sechet | e39e853 | 2016-02-18 20:38:32 +0000 | [diff] [blame] | 2433 | * Check whether the given function has a personality function. |
| 2434 | * |
| 2435 | * @see llvm::Function::hasPersonalityFn() |
| 2436 | */ |
| 2437 | LLVMBool LLVMHasPersonalityFn(LLVMValueRef Fn); |
| 2438 | |
| 2439 | /** |
Andrew Wilkins | 3bdfc1c | 2015-07-14 01:23:06 +0000 | [diff] [blame] | 2440 | * Obtain the personality function attached to the function. |
| 2441 | * |
| 2442 | * @see llvm::Function::getPersonalityFn() |
| 2443 | */ |
| 2444 | LLVMValueRef LLVMGetPersonalityFn(LLVMValueRef Fn); |
| 2445 | |
| 2446 | /** |
| 2447 | * Set the personality function attached to the function. |
| 2448 | * |
| 2449 | * @see llvm::Function::setPersonalityFn() |
| 2450 | */ |
| 2451 | void LLVMSetPersonalityFn(LLVMValueRef Fn, LLVMValueRef PersonalityFn); |
| 2452 | |
| 2453 | /** |
Robert Widmann | 9d94a68 | 2019-03-25 20:58:58 +0000 | [diff] [blame] | 2454 | * Obtain the intrinsic ID number which matches the given function name. |
| 2455 | * |
| 2456 | * @see llvm::Function::lookupIntrinsicID() |
| 2457 | */ |
| 2458 | unsigned LLVMLookupIntrinsicID(const char *Name, size_t NameLen); |
| 2459 | |
| 2460 | /** |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 2461 | * Obtain the ID number from a function instance. |
| 2462 | * |
| 2463 | * @see llvm::Function::getIntrinsicID() |
| 2464 | */ |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 2465 | unsigned LLVMGetIntrinsicID(LLVMValueRef Fn); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 2466 | |
| 2467 | /** |
Robert Widmann | d36f3b0 | 2018-11-06 01:38:14 +0000 | [diff] [blame] | 2468 | * Create or insert the declaration of an intrinsic. For overloaded intrinsics, |
| 2469 | * parameter types must be provided to uniquely identify an overload. |
| 2470 | * |
| 2471 | * @see llvm::Intrinsic::getDeclaration() |
| 2472 | */ |
| 2473 | LLVMValueRef LLVMGetIntrinsicDeclaration(LLVMModuleRef Mod, |
| 2474 | unsigned ID, |
| 2475 | LLVMTypeRef *ParamTypes, |
| 2476 | size_t ParamCount); |
| 2477 | |
| 2478 | /** |
| 2479 | * Retrieves the type of an intrinsic. For overloaded intrinsics, parameter |
| 2480 | * types must be provided to uniquely identify an overload. |
| 2481 | * |
| 2482 | * @see llvm::Intrinsic::getType() |
| 2483 | */ |
| 2484 | LLVMTypeRef LLVMIntrinsicGetType(LLVMContextRef Ctx, unsigned ID, |
| 2485 | LLVMTypeRef *ParamTypes, size_t ParamCount); |
| 2486 | |
| 2487 | /** |
| 2488 | * Retrieves the name of an intrinsic. |
| 2489 | * |
| 2490 | * @see llvm::Intrinsic::getName() |
| 2491 | */ |
| 2492 | const char *LLVMIntrinsicGetName(unsigned ID, size_t *NameLength); |
| 2493 | |
| 2494 | /** |
| 2495 | * Copies the name of an overloaded intrinsic identified by a given list of |
| 2496 | * parameter types. |
| 2497 | * |
| 2498 | * Unlike LLVMIntrinsicGetName, the caller is responsible for freeing the |
| 2499 | * returned string. |
| 2500 | * |
| 2501 | * @see llvm::Intrinsic::getName() |
| 2502 | */ |
| 2503 | const char *LLVMIntrinsicCopyOverloadedName(unsigned ID, |
| 2504 | LLVMTypeRef *ParamTypes, |
| 2505 | size_t ParamCount, |
| 2506 | size_t *NameLength); |
| 2507 | |
| 2508 | /** |
| 2509 | * Obtain if the intrinsic identified by the given ID is overloaded. |
| 2510 | * |
| 2511 | * @see llvm::Intrinsic::isOverloaded() |
| 2512 | */ |
| 2513 | LLVMBool LLVMIntrinsicIsOverloaded(unsigned ID); |
| 2514 | |
| 2515 | /** |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 2516 | * Obtain the calling function of a function. |
| 2517 | * |
| 2518 | * The returned value corresponds to the LLVMCallConv enumeration. |
| 2519 | * |
| 2520 | * @see llvm::Function::getCallingConv() |
| 2521 | */ |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 2522 | unsigned LLVMGetFunctionCallConv(LLVMValueRef Fn); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 2523 | |
| 2524 | /** |
| 2525 | * Set the calling convention of a function. |
| 2526 | * |
| 2527 | * @see llvm::Function::setCallingConv() |
| 2528 | * |
| 2529 | * @param Fn Function to operate on |
| 2530 | * @param CC LLVMCallConv to set calling convention to |
| 2531 | */ |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 2532 | void LLVMSetFunctionCallConv(LLVMValueRef Fn, unsigned CC); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 2533 | |
| 2534 | /** |
| 2535 | * Obtain the name of the garbage collector to use during code |
| 2536 | * generation. |
| 2537 | * |
| 2538 | * @see llvm::Function::getGC() |
| 2539 | */ |
Gordon Henriksen | d930f91 | 2008-08-17 18:44:35 +0000 | [diff] [blame] | 2540 | const char *LLVMGetGC(LLVMValueRef Fn); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 2541 | |
| 2542 | /** |
| 2543 | * Define the garbage collector to use during code generation. |
| 2544 | * |
| 2545 | * @see llvm::Function::setGC() |
| 2546 | */ |
Gordon Henriksen | d930f91 | 2008-08-17 18:44:35 +0000 | [diff] [blame] | 2547 | void LLVMSetGC(LLVMValueRef Fn, const char *Name); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 2548 | |
| 2549 | /** |
| 2550 | * Add an attribute to a function. |
| 2551 | * |
| 2552 | * @see llvm::Function::addAttribute() |
| 2553 | */ |
Amaury Sechet | 5db224e | 2016-06-12 06:17:24 +0000 | [diff] [blame] | 2554 | void LLVMAddAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx, |
| 2555 | LLVMAttributeRef A); |
Amaury Sechet | 17b67cd | 2016-07-21 04:25:06 +0000 | [diff] [blame] | 2556 | unsigned LLVMGetAttributeCountAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx); |
| 2557 | void LLVMGetAttributesAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx, |
| 2558 | LLVMAttributeRef *Attrs); |
Amaury Sechet | 5db224e | 2016-06-12 06:17:24 +0000 | [diff] [blame] | 2559 | LLVMAttributeRef LLVMGetEnumAttributeAtIndex(LLVMValueRef F, |
| 2560 | LLVMAttributeIndex Idx, |
| 2561 | unsigned KindID); |
Amaury Sechet | 6100adf | 2016-06-15 17:50:39 +0000 | [diff] [blame] | 2562 | LLVMAttributeRef LLVMGetStringAttributeAtIndex(LLVMValueRef F, |
| 2563 | LLVMAttributeIndex Idx, |
| 2564 | const char *K, unsigned KLen); |
Amaury Sechet | 5db224e | 2016-06-12 06:17:24 +0000 | [diff] [blame] | 2565 | void LLVMRemoveEnumAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx, |
| 2566 | unsigned KindID); |
Amaury Sechet | 6100adf | 2016-06-15 17:50:39 +0000 | [diff] [blame] | 2567 | void LLVMRemoveStringAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx, |
| 2568 | const char *K, unsigned KLen); |
Amaury Sechet | 5db224e | 2016-06-12 06:17:24 +0000 | [diff] [blame] | 2569 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 2570 | /** |
Nick Lewycky | c3890d2 | 2015-07-29 22:32:47 +0000 | [diff] [blame] | 2571 | * Add a target-dependent attribute to a function |
Tom Stellard | e8f35e1 | 2013-04-16 23:12:43 +0000 | [diff] [blame] | 2572 | * @see llvm::AttrBuilder::addAttribute() |
| 2573 | */ |
| 2574 | void LLVMAddTargetDependentFunctionAttr(LLVMValueRef Fn, const char *A, |
| 2575 | const char *V); |
| 2576 | |
| 2577 | /** |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 2578 | * @defgroup LLVMCCoreValueFunctionParameters Function Parameters |
| 2579 | * |
| 2580 | * Functions in this group relate to arguments/parameters on functions. |
| 2581 | * |
| 2582 | * Functions in this group expect LLVMValueRef instances that correspond |
| 2583 | * to llvm::Function instances. |
| 2584 | * |
| 2585 | * @{ |
| 2586 | */ |
| 2587 | |
| 2588 | /** |
| 2589 | * Obtain the number of parameters in a function. |
| 2590 | * |
| 2591 | * @see llvm::Function::arg_size() |
| 2592 | */ |
Gordon Henriksen | 265f780 | 2008-03-19 01:11:35 +0000 | [diff] [blame] | 2593 | unsigned LLVMCountParams(LLVMValueRef Fn); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 2594 | |
| 2595 | /** |
| 2596 | * Obtain the parameters in a function. |
| 2597 | * |
| 2598 | * The takes a pointer to a pre-allocated array of LLVMValueRef that is |
| 2599 | * at least LLVMCountParams() long. This array will be filled with |
| 2600 | * LLVMValueRef instances which correspond to the parameters the |
| 2601 | * function receives. Each LLVMValueRef corresponds to a llvm::Argument |
| 2602 | * instance. |
| 2603 | * |
| 2604 | * @see llvm::Function::arg_begin() |
| 2605 | */ |
Gordon Henriksen | 265f780 | 2008-03-19 01:11:35 +0000 | [diff] [blame] | 2606 | void LLVMGetParams(LLVMValueRef Fn, LLVMValueRef *Params); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 2607 | |
| 2608 | /** |
| 2609 | * Obtain the parameter at the specified index. |
| 2610 | * |
| 2611 | * Parameters are indexed from 0. |
| 2612 | * |
| 2613 | * @see llvm::Function::arg_begin() |
| 2614 | */ |
Gordon Henriksen | 265f780 | 2008-03-19 01:11:35 +0000 | [diff] [blame] | 2615 | LLVMValueRef LLVMGetParam(LLVMValueRef Fn, unsigned Index); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 2616 | |
| 2617 | /** |
| 2618 | * Obtain the function to which this argument belongs. |
| 2619 | * |
Daniel Dunbar | 06b9f9e | 2013-08-16 23:30:19 +0000 | [diff] [blame] | 2620 | * Unlike other functions in this group, this one takes an LLVMValueRef |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 2621 | * that corresponds to a llvm::Attribute. |
| 2622 | * |
| 2623 | * The returned LLVMValueRef is the llvm::Function to which this |
| 2624 | * argument belongs. |
| 2625 | */ |
Gordon Henriksen | 265f780 | 2008-03-19 01:11:35 +0000 | [diff] [blame] | 2626 | LLVMValueRef LLVMGetParamParent(LLVMValueRef Inst); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 2627 | |
| 2628 | /** |
| 2629 | * Obtain the first parameter to a function. |
| 2630 | * |
| 2631 | * @see llvm::Function::arg_begin() |
| 2632 | */ |
Gordon Henriksen | 07a45f4 | 2008-03-23 22:21:29 +0000 | [diff] [blame] | 2633 | LLVMValueRef LLVMGetFirstParam(LLVMValueRef Fn); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 2634 | |
| 2635 | /** |
| 2636 | * Obtain the last parameter to a function. |
| 2637 | * |
| 2638 | * @see llvm::Function::arg_end() |
| 2639 | */ |
Gordon Henriksen | 07a45f4 | 2008-03-23 22:21:29 +0000 | [diff] [blame] | 2640 | LLVMValueRef LLVMGetLastParam(LLVMValueRef Fn); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 2641 | |
| 2642 | /** |
| 2643 | * Obtain the next parameter to a function. |
| 2644 | * |
Daniel Dunbar | 06b9f9e | 2013-08-16 23:30:19 +0000 | [diff] [blame] | 2645 | * This takes an LLVMValueRef obtained from LLVMGetFirstParam() (which is |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 2646 | * actually a wrapped iterator) and obtains the next parameter from the |
| 2647 | * underlying iterator. |
| 2648 | */ |
Gordon Henriksen | 07a45f4 | 2008-03-23 22:21:29 +0000 | [diff] [blame] | 2649 | LLVMValueRef LLVMGetNextParam(LLVMValueRef Arg); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 2650 | |
| 2651 | /** |
| 2652 | * Obtain the previous parameter to a function. |
| 2653 | * |
| 2654 | * This is the opposite of LLVMGetNextParam(). |
| 2655 | */ |
Gordon Henriksen | 07a45f4 | 2008-03-23 22:21:29 +0000 | [diff] [blame] | 2656 | LLVMValueRef LLVMGetPreviousParam(LLVMValueRef Arg); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 2657 | |
| 2658 | /** |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 2659 | * Set the alignment for a function parameter. |
| 2660 | * |
| 2661 | * @see llvm::Argument::addAttr() |
Bill Wendling | 50d2784 | 2012-10-15 20:35:56 +0000 | [diff] [blame] | 2662 | * @see llvm::AttrBuilder::addAlignmentAttr() |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 2663 | */ |
Amaury Sechet | 81243a7 | 2016-05-01 01:42:34 +0000 | [diff] [blame] | 2664 | void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned Align); |
Gordon Henriksen | 265f780 | 2008-03-19 01:11:35 +0000 | [diff] [blame] | 2665 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 2666 | /** |
| 2667 | * @} |
| 2668 | */ |
| 2669 | |
| 2670 | /** |
Robert Widmann | d5444cc | 2019-02-05 18:05:44 +0000 | [diff] [blame] | 2671 | * @defgroup LLVMCCoreValueGlobalIFunc IFuncs |
| 2672 | * |
| 2673 | * Functions in this group relate to indirect functions. |
| 2674 | * |
| 2675 | * Functions in this group expect LLVMValueRef instances that correspond |
| 2676 | * to llvm::GlobalIFunc instances. |
| 2677 | * |
| 2678 | * @{ |
| 2679 | */ |
| 2680 | |
| 2681 | /** |
| 2682 | * Add a global indirect function to a module under a specified name. |
| 2683 | * |
| 2684 | * @see llvm::GlobalIFunc::create() |
| 2685 | */ |
| 2686 | LLVMValueRef LLVMAddGlobalIFunc(LLVMModuleRef M, |
| 2687 | const char *Name, size_t NameLen, |
| 2688 | LLVMTypeRef Ty, unsigned AddrSpace, |
| 2689 | LLVMValueRef Resolver); |
| 2690 | |
| 2691 | /** |
| 2692 | * Obtain a GlobalIFunc value from a Module by its name. |
| 2693 | * |
| 2694 | * The returned value corresponds to a llvm::GlobalIFunc value. |
| 2695 | * |
| 2696 | * @see llvm::Module::getNamedIFunc() |
| 2697 | */ |
| 2698 | LLVMValueRef LLVMGetNamedGlobalIFunc(LLVMModuleRef M, |
| 2699 | const char *Name, size_t NameLen); |
| 2700 | |
| 2701 | /** |
| 2702 | * Obtain an iterator to the first GlobalIFunc in a Module. |
| 2703 | * |
| 2704 | * @see llvm::Module::ifunc_begin() |
| 2705 | */ |
| 2706 | LLVMValueRef LLVMGetFirstGlobalIFunc(LLVMModuleRef M); |
| 2707 | |
| 2708 | /** |
| 2709 | * Obtain an iterator to the last GlobalIFunc in a Module. |
| 2710 | * |
| 2711 | * @see llvm::Module::ifunc_end() |
| 2712 | */ |
| 2713 | LLVMValueRef LLVMGetLastGlobalIFunc(LLVMModuleRef M); |
| 2714 | |
| 2715 | /** |
| 2716 | * Advance a GlobalIFunc iterator to the next GlobalIFunc. |
| 2717 | * |
| 2718 | * Returns NULL if the iterator was already at the end and there are no more |
| 2719 | * global aliases. |
| 2720 | */ |
| 2721 | LLVMValueRef LLVMGetNextGlobalIFunc(LLVMValueRef IFunc); |
| 2722 | |
| 2723 | /** |
| 2724 | * Decrement a GlobalIFunc iterator to the previous GlobalIFunc. |
| 2725 | * |
| 2726 | * Returns NULL if the iterator was already at the beginning and there are |
| 2727 | * no previous global aliases. |
| 2728 | */ |
| 2729 | LLVMValueRef LLVMGetPreviousGlobalIFunc(LLVMValueRef IFunc); |
Jim Lin | 466f884 | 2020-02-18 10:48:38 +0800 | [diff] [blame] | 2730 | |
Robert Widmann | d5444cc | 2019-02-05 18:05:44 +0000 | [diff] [blame] | 2731 | /** |
| 2732 | * Retrieves the resolver function associated with this indirect function, or |
| 2733 | * NULL if it doesn't not exist. |
| 2734 | * |
| 2735 | * @see llvm::GlobalIFunc::getResolver() |
| 2736 | */ |
| 2737 | LLVMValueRef LLVMGetGlobalIFuncResolver(LLVMValueRef IFunc); |
| 2738 | |
| 2739 | /** |
| 2740 | * Sets the resolver function associated with this indirect function. |
| 2741 | * |
| 2742 | * @see llvm::GlobalIFunc::setResolver() |
| 2743 | */ |
| 2744 | void LLVMSetGlobalIFuncResolver(LLVMValueRef IFunc, LLVMValueRef Resolver); |
| 2745 | |
| 2746 | /** |
| 2747 | * Remove a global indirect function from its parent module and delete it. |
| 2748 | * |
| 2749 | * @see llvm::GlobalIFunc::eraseFromParent() |
| 2750 | */ |
| 2751 | void LLVMEraseGlobalIFunc(LLVMValueRef IFunc); |
| 2752 | |
| 2753 | /** |
| 2754 | * Remove a global indirect function from its parent module. |
| 2755 | * |
| 2756 | * This unlinks the global indirect function from its containing module but |
| 2757 | * keeps it alive. |
| 2758 | * |
| 2759 | * @see llvm::GlobalIFunc::removeFromParent() |
| 2760 | */ |
| 2761 | void LLVMRemoveGlobalIFunc(LLVMValueRef IFunc); |
| 2762 | |
| 2763 | /** |
| 2764 | * @} |
| 2765 | */ |
| 2766 | |
| 2767 | /** |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 2768 | * @} |
| 2769 | */ |
| 2770 | |
| 2771 | /** |
Gregory Szorc | 52d2660 | 2012-03-21 07:28:27 +0000 | [diff] [blame] | 2772 | * @} |
| 2773 | */ |
| 2774 | |
| 2775 | /** |
| 2776 | * @} |
| 2777 | */ |
| 2778 | |
| 2779 | /** |
| 2780 | * @defgroup LLVMCCoreValueMetadata Metadata |
| 2781 | * |
| 2782 | * @{ |
| 2783 | */ |
| 2784 | |
| 2785 | /** |
Robert Widmann | 09c5b88 | 2019-04-24 17:05:08 +0000 | [diff] [blame] | 2786 | * Create an MDString value from a given string value. |
Gregory Szorc | 52d2660 | 2012-03-21 07:28:27 +0000 | [diff] [blame] | 2787 | * |
Robert Widmann | 09c5b88 | 2019-04-24 17:05:08 +0000 | [diff] [blame] | 2788 | * The MDString value does not take ownership of the given string, it remains |
| 2789 | * the responsibility of the caller to free it. |
Gregory Szorc | 52d2660 | 2012-03-21 07:28:27 +0000 | [diff] [blame] | 2790 | * |
Robert Widmann | 09c5b88 | 2019-04-24 17:05:08 +0000 | [diff] [blame] | 2791 | * @see llvm::MDString::get() |
Gregory Szorc | 52d2660 | 2012-03-21 07:28:27 +0000 | [diff] [blame] | 2792 | */ |
Robert Widmann | 09c5b88 | 2019-04-24 17:05:08 +0000 | [diff] [blame] | 2793 | LLVMMetadataRef LLVMMDStringInContext2(LLVMContextRef C, const char *Str, |
| 2794 | size_t SLen); |
Gregory Szorc | 52d2660 | 2012-03-21 07:28:27 +0000 | [diff] [blame] | 2795 | |
| 2796 | /** |
Robert Widmann | 09c5b88 | 2019-04-24 17:05:08 +0000 | [diff] [blame] | 2797 | * Create an MDNode value with the given array of operands. |
Gregory Szorc | 52d2660 | 2012-03-21 07:28:27 +0000 | [diff] [blame] | 2798 | * |
Robert Widmann | 09c5b88 | 2019-04-24 17:05:08 +0000 | [diff] [blame] | 2799 | * @see llvm::MDNode::get() |
Gregory Szorc | 52d2660 | 2012-03-21 07:28:27 +0000 | [diff] [blame] | 2800 | */ |
Robert Widmann | 09c5b88 | 2019-04-24 17:05:08 +0000 | [diff] [blame] | 2801 | LLVMMetadataRef LLVMMDNodeInContext2(LLVMContextRef C, LLVMMetadataRef *MDs, |
| 2802 | size_t Count); |
Gregory Szorc | 52d2660 | 2012-03-21 07:28:27 +0000 | [diff] [blame] | 2803 | |
| 2804 | /** |
Amaury Sechet | f842975 | 2017-04-17 11:52:54 +0000 | [diff] [blame] | 2805 | * Obtain a Metadata as a Value. |
| 2806 | */ |
| 2807 | LLVMValueRef LLVMMetadataAsValue(LLVMContextRef C, LLVMMetadataRef MD); |
| 2808 | |
| 2809 | /** |
| 2810 | * Obtain a Value as a Metadata. |
| 2811 | */ |
| 2812 | LLVMMetadataRef LLVMValueAsMetadata(LLVMValueRef Val); |
| 2813 | |
| 2814 | /** |
Gregory Szorc | 52d2660 | 2012-03-21 07:28:27 +0000 | [diff] [blame] | 2815 | * Obtain the underlying string from a MDString value. |
| 2816 | * |
| 2817 | * @param V Instance to obtain string from. |
NAKAMURA Takumi | e4a7705 | 2016-04-04 11:54:48 +0000 | [diff] [blame] | 2818 | * @param Length Memory address which will hold length of returned string. |
Gregory Szorc | 52d2660 | 2012-03-21 07:28:27 +0000 | [diff] [blame] | 2819 | * @return String data in MDString. |
| 2820 | */ |
Amaury Sechet | 7c2883c | 2016-04-03 21:06:04 +0000 | [diff] [blame] | 2821 | const char *LLVMGetMDString(LLVMValueRef V, unsigned *Length); |
Gregory Szorc | 52d2660 | 2012-03-21 07:28:27 +0000 | [diff] [blame] | 2822 | |
| 2823 | /** |
Duncan Sands | 12ccbe7 | 2012-09-19 20:29:39 +0000 | [diff] [blame] | 2824 | * Obtain the number of operands from an MDNode value. |
| 2825 | * |
| 2826 | * @param V MDNode to get number of operands from. |
| 2827 | * @return Number of operands of the MDNode. |
| 2828 | */ |
| 2829 | unsigned LLVMGetMDNodeNumOperands(LLVMValueRef V); |
| 2830 | |
| 2831 | /** |
| 2832 | * Obtain the given MDNode's operands. |
| 2833 | * |
| 2834 | * The passed LLVMValueRef pointer should point to enough memory to hold all of |
| 2835 | * the operands of the given MDNode (see LLVMGetMDNodeNumOperands) as |
| 2836 | * LLVMValueRefs. This memory will be populated with the LLVMValueRefs of the |
| 2837 | * MDNode's operands. |
| 2838 | * |
| 2839 | * @param V MDNode to get the operands from. |
| 2840 | * @param Dest Destination array for operands. |
| 2841 | */ |
| 2842 | void LLVMGetMDNodeOperands(LLVMValueRef V, LLVMValueRef *Dest); |
| 2843 | |
Robert Widmann | 09c5b88 | 2019-04-24 17:05:08 +0000 | [diff] [blame] | 2844 | /** Deprecated: Use LLVMMDStringInContext2 instead. */ |
| 2845 | LLVMValueRef LLVMMDStringInContext(LLVMContextRef C, const char *Str, |
| 2846 | unsigned SLen); |
| 2847 | /** Deprecated: Use LLVMMDStringInContext2 instead. */ |
| 2848 | LLVMValueRef LLVMMDString(const char *Str, unsigned SLen); |
| 2849 | /** Deprecated: Use LLVMMDNodeInContext2 instead. */ |
| 2850 | LLVMValueRef LLVMMDNodeInContext(LLVMContextRef C, LLVMValueRef *Vals, |
| 2851 | unsigned Count); |
| 2852 | /** Deprecated: Use LLVMMDNodeInContext2 instead. */ |
| 2853 | LLVMValueRef LLVMMDNode(LLVMValueRef *Vals, unsigned Count); |
| 2854 | |
Duncan Sands | 12ccbe7 | 2012-09-19 20:29:39 +0000 | [diff] [blame] | 2855 | /** |
Gregory Szorc | 52d2660 | 2012-03-21 07:28:27 +0000 | [diff] [blame] | 2856 | * @} |
| 2857 | */ |
| 2858 | |
| 2859 | /** |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 2860 | * @defgroup LLVMCCoreValueBasicBlock Basic Block |
| 2861 | * |
| 2862 | * A basic block represents a single entry single exit section of code. |
| 2863 | * Basic blocks contain a list of instructions which form the body of |
| 2864 | * the block. |
| 2865 | * |
| 2866 | * Basic blocks belong to functions. They have the type of label. |
| 2867 | * |
| 2868 | * Basic blocks are themselves values. However, the C API models them as |
| 2869 | * LLVMBasicBlockRef. |
| 2870 | * |
| 2871 | * @see llvm::BasicBlock |
| 2872 | * |
| 2873 | * @{ |
| 2874 | */ |
| 2875 | |
| 2876 | /** |
| 2877 | * Convert a basic block instance to a value type. |
| 2878 | */ |
Gordon Henriksen | 07a45f4 | 2008-03-23 22:21:29 +0000 | [diff] [blame] | 2879 | LLVMValueRef LLVMBasicBlockAsValue(LLVMBasicBlockRef BB); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 2880 | |
| 2881 | /** |
Daniel Dunbar | 06b9f9e | 2013-08-16 23:30:19 +0000 | [diff] [blame] | 2882 | * Determine whether an LLVMValueRef is itself a basic block. |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 2883 | */ |
Chris Lattner | 25963c6 | 2010-01-09 22:27:07 +0000 | [diff] [blame] | 2884 | LLVMBool LLVMValueIsBasicBlock(LLVMValueRef Val); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 2885 | |
| 2886 | /** |
Daniel Dunbar | 06b9f9e | 2013-08-16 23:30:19 +0000 | [diff] [blame] | 2887 | * Convert an LLVMValueRef to an LLVMBasicBlockRef instance. |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 2888 | */ |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 2889 | LLVMBasicBlockRef LLVMValueAsBasicBlock(LLVMValueRef Val); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 2890 | |
| 2891 | /** |
Amaury Sechet | a82042e | 2016-02-09 22:36:41 +0000 | [diff] [blame] | 2892 | * Obtain the string name of a basic block. |
| 2893 | */ |
| 2894 | const char *LLVMGetBasicBlockName(LLVMBasicBlockRef BB); |
| 2895 | |
| 2896 | /** |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 2897 | * Obtain the function to which a basic block belongs. |
| 2898 | * |
| 2899 | * @see llvm::BasicBlock::getParent() |
| 2900 | */ |
Gordon Henriksen | 07a45f4 | 2008-03-23 22:21:29 +0000 | [diff] [blame] | 2901 | LLVMValueRef LLVMGetBasicBlockParent(LLVMBasicBlockRef BB); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 2902 | |
| 2903 | /** |
| 2904 | * Obtain the terminator instruction for a basic block. |
| 2905 | * |
| 2906 | * If the basic block does not have a terminator (it is not well-formed |
| 2907 | * if it doesn't), then NULL is returned. |
| 2908 | * |
Chandler Carruth | 7c80c3a | 2018-10-18 23:03:55 +0000 | [diff] [blame] | 2909 | * The returned LLVMValueRef corresponds to an llvm::Instruction. |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 2910 | * |
| 2911 | * @see llvm::BasicBlock::getTerminator() |
| 2912 | */ |
Nate Begeman | 43c322b | 2011-08-23 20:27:46 +0000 | [diff] [blame] | 2913 | LLVMValueRef LLVMGetBasicBlockTerminator(LLVMBasicBlockRef BB); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 2914 | |
| 2915 | /** |
| 2916 | * Obtain the number of basic blocks in a function. |
| 2917 | * |
| 2918 | * @param Fn Function value to operate on. |
| 2919 | */ |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 2920 | unsigned LLVMCountBasicBlocks(LLVMValueRef Fn); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 2921 | |
| 2922 | /** |
| 2923 | * Obtain all of the basic blocks in a function. |
| 2924 | * |
| 2925 | * This operates on a function value. The BasicBlocks parameter is a |
| 2926 | * pointer to a pre-allocated array of LLVMBasicBlockRef of at least |
| 2927 | * LLVMCountBasicBlocks() in length. This array is populated with |
| 2928 | * LLVMBasicBlockRef instances. |
| 2929 | */ |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 2930 | void LLVMGetBasicBlocks(LLVMValueRef Fn, LLVMBasicBlockRef *BasicBlocks); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 2931 | |
| 2932 | /** |
| 2933 | * Obtain the first basic block in a function. |
| 2934 | * |
| 2935 | * The returned basic block can be used as an iterator. You will likely |
| 2936 | * eventually call into LLVMGetNextBasicBlock() with it. |
| 2937 | * |
| 2938 | * @see llvm::Function::begin() |
| 2939 | */ |
Gordon Henriksen | 054817c | 2008-03-19 03:47:18 +0000 | [diff] [blame] | 2940 | LLVMBasicBlockRef LLVMGetFirstBasicBlock(LLVMValueRef Fn); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 2941 | |
| 2942 | /** |
| 2943 | * Obtain the last basic block in a function. |
| 2944 | * |
| 2945 | * @see llvm::Function::end() |
| 2946 | */ |
Gordon Henriksen | 054817c | 2008-03-19 03:47:18 +0000 | [diff] [blame] | 2947 | LLVMBasicBlockRef LLVMGetLastBasicBlock(LLVMValueRef Fn); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 2948 | |
| 2949 | /** |
| 2950 | * Advance a basic block iterator. |
| 2951 | */ |
Gordon Henriksen | 054817c | 2008-03-19 03:47:18 +0000 | [diff] [blame] | 2952 | LLVMBasicBlockRef LLVMGetNextBasicBlock(LLVMBasicBlockRef BB); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 2953 | |
| 2954 | /** |
| 2955 | * Go backwards in a basic block iterator. |
| 2956 | */ |
Gordon Henriksen | 054817c | 2008-03-19 03:47:18 +0000 | [diff] [blame] | 2957 | LLVMBasicBlockRef LLVMGetPreviousBasicBlock(LLVMBasicBlockRef BB); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 2958 | |
| 2959 | /** |
| 2960 | * Obtain the basic block that corresponds to the entry point of a |
| 2961 | * function. |
| 2962 | * |
| 2963 | * @see llvm::Function::getEntryBlock() |
| 2964 | */ |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 2965 | LLVMBasicBlockRef LLVMGetEntryBasicBlock(LLVMValueRef Fn); |
Erick Tryzelaar | 262332f | 2009-08-14 00:01:31 +0000 | [diff] [blame] | 2966 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 2967 | /** |
Robert Widmann | b4baa56 | 2019-04-05 20:32:43 +0000 | [diff] [blame] | 2968 | * Insert the given basic block after the insertion point of the given builder. |
| 2969 | * |
| 2970 | * The insertion point must be valid. |
| 2971 | * |
| 2972 | * @see llvm::Function::BasicBlockListType::insertAfter() |
| 2973 | */ |
| 2974 | void LLVMInsertExistingBasicBlockAfterInsertBlock(LLVMBuilderRef Builder, |
| 2975 | LLVMBasicBlockRef BB); |
| 2976 | |
| 2977 | /** |
| 2978 | * Append the given basic block to the basic block list of the given function. |
| 2979 | * |
| 2980 | * @see llvm::Function::BasicBlockListType::push_back() |
| 2981 | */ |
| 2982 | void LLVMAppendExistingBasicBlock(LLVMValueRef Fn, |
| 2983 | LLVMBasicBlockRef BB); |
Jim Lin | 466f884 | 2020-02-18 10:48:38 +0800 | [diff] [blame] | 2984 | |
Robert Widmann | b4baa56 | 2019-04-05 20:32:43 +0000 | [diff] [blame] | 2985 | /** |
Robert Widmann | 616ed17 | 2019-01-08 06:24:19 +0000 | [diff] [blame] | 2986 | * Create a new basic block without inserting it into a function. |
| 2987 | * |
| 2988 | * @see llvm::BasicBlock::Create() |
| 2989 | */ |
| 2990 | LLVMBasicBlockRef LLVMCreateBasicBlockInContext(LLVMContextRef C, |
James Y Knight | 68729f9 | 2019-01-14 17:16:55 +0000 | [diff] [blame] | 2991 | const char *Name); |
Robert Widmann | 616ed17 | 2019-01-08 06:24:19 +0000 | [diff] [blame] | 2992 | |
| 2993 | /** |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 2994 | * Append a basic block to the end of a function. |
| 2995 | * |
| 2996 | * @see llvm::BasicBlock::Create() |
| 2997 | */ |
Erick Tryzelaar | 262332f | 2009-08-14 00:01:31 +0000 | [diff] [blame] | 2998 | LLVMBasicBlockRef LLVMAppendBasicBlockInContext(LLVMContextRef C, |
| 2999 | LLVMValueRef Fn, |
| 3000 | const char *Name); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 3001 | |
| 3002 | /** |
| 3003 | * Append a basic block to the end of a function using the global |
| 3004 | * context. |
| 3005 | * |
| 3006 | * @see llvm::BasicBlock::Create() |
| 3007 | */ |
| 3008 | LLVMBasicBlockRef LLVMAppendBasicBlock(LLVMValueRef Fn, const char *Name); |
| 3009 | |
| 3010 | /** |
| 3011 | * Insert a basic block in a function before another basic block. |
| 3012 | * |
| 3013 | * The function to add to is determined by the function of the |
| 3014 | * passed basic block. |
| 3015 | * |
| 3016 | * @see llvm::BasicBlock::Create() |
| 3017 | */ |
Erick Tryzelaar | 262332f | 2009-08-14 00:01:31 +0000 | [diff] [blame] | 3018 | LLVMBasicBlockRef LLVMInsertBasicBlockInContext(LLVMContextRef C, |
| 3019 | LLVMBasicBlockRef BB, |
| 3020 | const char *Name); |
| 3021 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 3022 | /** |
| 3023 | * Insert a basic block in a function using the global context. |
| 3024 | * |
| 3025 | * @see llvm::BasicBlock::Create() |
| 3026 | */ |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 3027 | LLVMBasicBlockRef LLVMInsertBasicBlock(LLVMBasicBlockRef InsertBeforeBB, |
| 3028 | const char *Name); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 3029 | |
| 3030 | /** |
| 3031 | * Remove a basic block from a function and delete it. |
| 3032 | * |
| 3033 | * This deletes the basic block from its containing function and deletes |
| 3034 | * the basic block itself. |
| 3035 | * |
| 3036 | * @see llvm::BasicBlock::eraseFromParent() |
| 3037 | */ |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 3038 | void LLVMDeleteBasicBlock(LLVMBasicBlockRef BB); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 3039 | |
| 3040 | /** |
| 3041 | * Remove a basic block from a function. |
| 3042 | * |
| 3043 | * This deletes the basic block from its containing function but keep |
| 3044 | * the basic block alive. |
| 3045 | * |
| 3046 | * @see llvm::BasicBlock::removeFromParent() |
| 3047 | */ |
Nate Begeman | 43c322b | 2011-08-23 20:27:46 +0000 | [diff] [blame] | 3048 | void LLVMRemoveBasicBlockFromParent(LLVMBasicBlockRef BB); |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 3049 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 3050 | /** |
| 3051 | * Move a basic block to before another one. |
| 3052 | * |
| 3053 | * @see llvm::BasicBlock::moveBefore() |
| 3054 | */ |
Duncan Sands | b1d61aa | 2010-07-19 15:31:07 +0000 | [diff] [blame] | 3055 | void LLVMMoveBasicBlockBefore(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 3056 | |
| 3057 | /** |
| 3058 | * Move a basic block to after another one. |
| 3059 | * |
| 3060 | * @see llvm::BasicBlock::moveAfter() |
| 3061 | */ |
Duncan Sands | b1d61aa | 2010-07-19 15:31:07 +0000 | [diff] [blame] | 3062 | void LLVMMoveBasicBlockAfter(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos); |
| 3063 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 3064 | /** |
| 3065 | * Obtain the first instruction in a basic block. |
| 3066 | * |
| 3067 | * The returned LLVMValueRef corresponds to a llvm::Instruction |
| 3068 | * instance. |
| 3069 | */ |
Gordon Henriksen | 054817c | 2008-03-19 03:47:18 +0000 | [diff] [blame] | 3070 | LLVMValueRef LLVMGetFirstInstruction(LLVMBasicBlockRef BB); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 3071 | |
| 3072 | /** |
| 3073 | * Obtain the last instruction in a basic block. |
| 3074 | * |
Daniel Dunbar | 06b9f9e | 2013-08-16 23:30:19 +0000 | [diff] [blame] | 3075 | * The returned LLVMValueRef corresponds to an LLVM:Instruction. |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 3076 | */ |
Gordon Henriksen | 054817c | 2008-03-19 03:47:18 +0000 | [diff] [blame] | 3077 | LLVMValueRef LLVMGetLastInstruction(LLVMBasicBlockRef BB); |
Nate Begeman | 43c322b | 2011-08-23 20:27:46 +0000 | [diff] [blame] | 3078 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 3079 | /** |
| 3080 | * @} |
| 3081 | */ |
| 3082 | |
| 3083 | /** |
| 3084 | * @defgroup LLVMCCoreValueInstruction Instructions |
| 3085 | * |
| 3086 | * Functions in this group relate to the inspection and manipulation of |
| 3087 | * individual instructions. |
| 3088 | * |
| 3089 | * In the C++ API, an instruction is modeled by llvm::Instruction. This |
| 3090 | * class has a large number of descendents. llvm::Instruction is a |
| 3091 | * llvm::Value and in the C API, instructions are modeled by |
| 3092 | * LLVMValueRef. |
| 3093 | * |
| 3094 | * This group also contains sub-groups which operate on specific |
| 3095 | * llvm::Instruction types, e.g. llvm::CallInst. |
| 3096 | * |
| 3097 | * @{ |
| 3098 | */ |
| 3099 | |
| 3100 | /** |
| 3101 | * Determine whether an instruction has any metadata attached. |
| 3102 | */ |
| 3103 | int LLVMHasMetadata(LLVMValueRef Val); |
| 3104 | |
| 3105 | /** |
| 3106 | * Return metadata associated with an instruction value. |
| 3107 | */ |
| 3108 | LLVMValueRef LLVMGetMetadata(LLVMValueRef Val, unsigned KindID); |
| 3109 | |
| 3110 | /** |
| 3111 | * Set metadata associated with an instruction value. |
| 3112 | */ |
| 3113 | void LLVMSetMetadata(LLVMValueRef Val, unsigned KindID, LLVMValueRef Node); |
| 3114 | |
| 3115 | /** |
Robert Widmann | 9cba4ec | 2018-09-28 15:35:18 +0000 | [diff] [blame] | 3116 | * Returns the metadata associated with an instruction value, but filters out |
| 3117 | * all the debug locations. |
| 3118 | * |
| 3119 | * @see llvm::Instruction::getAllMetadataOtherThanDebugLoc() |
| 3120 | */ |
| 3121 | LLVMValueMetadataEntry * |
| 3122 | LLVMInstructionGetAllMetadataOtherThanDebugLoc(LLVMValueRef Instr, |
| 3123 | size_t *NumEntries); |
| 3124 | |
| 3125 | /** |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 3126 | * Obtain the basic block to which an instruction belongs. |
| 3127 | * |
| 3128 | * @see llvm::Instruction::getParent() |
| 3129 | */ |
Nate Begeman | 43c322b | 2011-08-23 20:27:46 +0000 | [diff] [blame] | 3130 | LLVMBasicBlockRef LLVMGetInstructionParent(LLVMValueRef Inst); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 3131 | |
| 3132 | /** |
| 3133 | * Obtain the instruction that occurs after the one specified. |
| 3134 | * |
| 3135 | * The next instruction will be from the same basic block. |
| 3136 | * |
| 3137 | * If this is the last instruction in a basic block, NULL will be |
| 3138 | * returned. |
| 3139 | */ |
Gordon Henriksen | 054817c | 2008-03-19 03:47:18 +0000 | [diff] [blame] | 3140 | LLVMValueRef LLVMGetNextInstruction(LLVMValueRef Inst); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 3141 | |
| 3142 | /** |
Benjamin Kramer | bde9176 | 2012-06-02 10:20:22 +0000 | [diff] [blame] | 3143 | * Obtain the instruction that occurred before this one. |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 3144 | * |
| 3145 | * If the instruction is the first instruction in a basic block, NULL |
| 3146 | * will be returned. |
| 3147 | */ |
Gordon Henriksen | 054817c | 2008-03-19 03:47:18 +0000 | [diff] [blame] | 3148 | LLVMValueRef LLVMGetPreviousInstruction(LLVMValueRef Inst); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 3149 | |
| 3150 | /** |
| 3151 | * Remove and delete an instruction. |
| 3152 | * |
| 3153 | * The instruction specified is removed from its containing building |
Amaury Sechet | 2f43208 | 2016-02-11 21:37:54 +0000 | [diff] [blame] | 3154 | * block but is kept alive. |
| 3155 | * |
| 3156 | * @see llvm::Instruction::removeFromParent() |
| 3157 | */ |
| 3158 | void LLVMInstructionRemoveFromParent(LLVMValueRef Inst); |
| 3159 | |
| 3160 | /** |
| 3161 | * Remove and delete an instruction. |
| 3162 | * |
| 3163 | * The instruction specified is removed from its containing building |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 3164 | * block and then deleted. |
| 3165 | * |
| 3166 | * @see llvm::Instruction::eraseFromParent() |
| 3167 | */ |
Devang Patel | dbebc6f | 2011-10-03 20:59:18 +0000 | [diff] [blame] | 3168 | void LLVMInstructionEraseFromParent(LLVMValueRef Inst); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 3169 | |
| 3170 | /** |
| 3171 | * Obtain the code opcode for an individual instruction. |
| 3172 | * |
| 3173 | * @see llvm::Instruction::getOpCode() |
| 3174 | */ |
Eric Christopher | a6b9600 | 2015-12-18 01:46:52 +0000 | [diff] [blame] | 3175 | LLVMOpcode LLVMGetInstructionOpcode(LLVMValueRef Inst); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 3176 | |
| 3177 | /** |
| 3178 | * Obtain the predicate of an instruction. |
| 3179 | * |
| 3180 | * This is only valid for instructions that correspond to llvm::ICmpInst |
| 3181 | * or llvm::ConstantExpr whose opcode is llvm::Instruction::ICmp. |
| 3182 | * |
| 3183 | * @see llvm::ICmpInst::getPredicate() |
| 3184 | */ |
Torok Edwin | 60c40de | 2011-10-06 12:13:20 +0000 | [diff] [blame] | 3185 | LLVMIntPredicate LLVMGetICmpPredicate(LLVMValueRef Inst); |
Gordon Henriksen | 265f780 | 2008-03-19 01:11:35 +0000 | [diff] [blame] | 3186 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 3187 | /** |
Peter Zotov | 1d98e6d | 2014-10-28 19:46:44 +0000 | [diff] [blame] | 3188 | * Obtain the float predicate of an instruction. |
| 3189 | * |
| 3190 | * This is only valid for instructions that correspond to llvm::FCmpInst |
| 3191 | * or llvm::ConstantExpr whose opcode is llvm::Instruction::FCmp. |
| 3192 | * |
| 3193 | * @see llvm::FCmpInst::getPredicate() |
| 3194 | */ |
| 3195 | LLVMRealPredicate LLVMGetFCmpPredicate(LLVMValueRef Inst); |
| 3196 | |
| 3197 | /** |
Peter Zotov | aff492c | 2014-10-17 01:02:34 +0000 | [diff] [blame] | 3198 | * Create a copy of 'this' instruction that is identical in all ways |
| 3199 | * except the following: |
| 3200 | * * The instruction has no parent |
| 3201 | * * The instruction has no name |
| 3202 | * |
| 3203 | * @see llvm::Instruction::clone() |
| 3204 | */ |
| 3205 | LLVMValueRef LLVMInstructionClone(LLVMValueRef Inst); |
| 3206 | |
| 3207 | /** |
Chandler Carruth | 7c80c3a | 2018-10-18 23:03:55 +0000 | [diff] [blame] | 3208 | * Determine whether an instruction is a terminator. This routine is named to |
| 3209 | * be compatible with historical functions that did this by querying the |
| 3210 | * underlying C++ type. |
| 3211 | * |
| 3212 | * @see llvm::Instruction::isTerminator() |
| 3213 | */ |
| 3214 | LLVMValueRef LLVMIsATerminatorInst(LLVMValueRef Inst); |
| 3215 | |
| 3216 | /** |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 3217 | * @defgroup LLVMCCoreValueInstructionCall Call Sites and Invocations |
| 3218 | * |
| 3219 | * Functions in this group apply to instructions that refer to call |
| 3220 | * sites and invocations. These correspond to C++ types in the |
| 3221 | * llvm::CallInst class tree. |
| 3222 | * |
| 3223 | * @{ |
| 3224 | */ |
| 3225 | |
| 3226 | /** |
Amaury Sechet | 5c7b3af | 2016-02-10 00:09:37 +0000 | [diff] [blame] | 3227 | * Obtain the argument count for a call instruction. |
| 3228 | * |
Robert Widmann | 478fce9 | 2018-03-30 17:49:53 +0000 | [diff] [blame] | 3229 | * This expects an LLVMValueRef that corresponds to a llvm::CallInst, |
| 3230 | * llvm::InvokeInst, or llvm:FuncletPadInst. |
Amaury Sechet | 5c7b3af | 2016-02-10 00:09:37 +0000 | [diff] [blame] | 3231 | * |
| 3232 | * @see llvm::CallInst::getNumArgOperands() |
| 3233 | * @see llvm::InvokeInst::getNumArgOperands() |
Robert Widmann | 478fce9 | 2018-03-30 17:49:53 +0000 | [diff] [blame] | 3234 | * @see llvm::FuncletPadInst::getNumArgOperands() |
Amaury Sechet | 5c7b3af | 2016-02-10 00:09:37 +0000 | [diff] [blame] | 3235 | */ |
| 3236 | unsigned LLVMGetNumArgOperands(LLVMValueRef Instr); |
| 3237 | |
| 3238 | /** |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 3239 | * Set the calling convention for a call instruction. |
| 3240 | * |
| 3241 | * This expects an LLVMValueRef that corresponds to a llvm::CallInst or |
| 3242 | * llvm::InvokeInst. |
| 3243 | * |
| 3244 | * @see llvm::CallInst::setCallingConv() |
| 3245 | * @see llvm::InvokeInst::setCallingConv() |
| 3246 | */ |
Gordon Henriksen | 1158c53 | 2007-12-29 20:45:00 +0000 | [diff] [blame] | 3247 | void LLVMSetInstructionCallConv(LLVMValueRef Instr, unsigned CC); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 3248 | |
| 3249 | /** |
| 3250 | * Obtain the calling convention for a call instruction. |
| 3251 | * |
| 3252 | * This is the opposite of LLVMSetInstructionCallConv(). Reads its |
| 3253 | * usage. |
| 3254 | * |
| 3255 | * @see LLVMSetInstructionCallConv() |
| 3256 | */ |
Gordon Henriksen | 1158c53 | 2007-12-29 20:45:00 +0000 | [diff] [blame] | 3257 | unsigned LLVMGetInstructionCallConv(LLVMValueRef Instr); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 3258 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 3259 | void LLVMSetInstrParamAlignment(LLVMValueRef Instr, unsigned index, |
Amaury Sechet | 81243a7 | 2016-05-01 01:42:34 +0000 | [diff] [blame] | 3260 | unsigned Align); |
Gordon Henriksen | 1158c53 | 2007-12-29 20:45:00 +0000 | [diff] [blame] | 3261 | |
Amaury Sechet | a65a237 | 2016-06-15 05:14:29 +0000 | [diff] [blame] | 3262 | void LLVMAddCallSiteAttribute(LLVMValueRef C, LLVMAttributeIndex Idx, |
| 3263 | LLVMAttributeRef A); |
Amaury Sechet | 17b67cd | 2016-07-21 04:25:06 +0000 | [diff] [blame] | 3264 | unsigned LLVMGetCallSiteAttributeCount(LLVMValueRef C, LLVMAttributeIndex Idx); |
| 3265 | void LLVMGetCallSiteAttributes(LLVMValueRef C, LLVMAttributeIndex Idx, |
| 3266 | LLVMAttributeRef *Attrs); |
Amaury Sechet | a65a237 | 2016-06-15 05:14:29 +0000 | [diff] [blame] | 3267 | LLVMAttributeRef LLVMGetCallSiteEnumAttribute(LLVMValueRef C, |
| 3268 | LLVMAttributeIndex Idx, |
| 3269 | unsigned KindID); |
Amaury Sechet | 6100adf | 2016-06-15 17:50:39 +0000 | [diff] [blame] | 3270 | LLVMAttributeRef LLVMGetCallSiteStringAttribute(LLVMValueRef C, |
| 3271 | LLVMAttributeIndex Idx, |
| 3272 | const char *K, unsigned KLen); |
Amaury Sechet | a65a237 | 2016-06-15 05:14:29 +0000 | [diff] [blame] | 3273 | void LLVMRemoveCallSiteEnumAttribute(LLVMValueRef C, LLVMAttributeIndex Idx, |
| 3274 | unsigned KindID); |
Amaury Sechet | 6100adf | 2016-06-15 17:50:39 +0000 | [diff] [blame] | 3275 | void LLVMRemoveCallSiteStringAttribute(LLVMValueRef C, LLVMAttributeIndex Idx, |
| 3276 | const char *K, unsigned KLen); |
Amaury Sechet | a65a237 | 2016-06-15 05:14:29 +0000 | [diff] [blame] | 3277 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 3278 | /** |
James Y Knight | f956390 | 2019-01-14 21:37:42 +0000 | [diff] [blame] | 3279 | * Obtain the function type called by this instruction. |
| 3280 | * |
| 3281 | * @see llvm::CallBase::getFunctionType() |
| 3282 | */ |
| 3283 | LLVMTypeRef LLVMGetCalledFunctionType(LLVMValueRef C); |
| 3284 | |
| 3285 | /** |
Amaury Sechet | 5c7b3af | 2016-02-10 00:09:37 +0000 | [diff] [blame] | 3286 | * Obtain the pointer to the function invoked by this instruction. |
| 3287 | * |
| 3288 | * This expects an LLVMValueRef that corresponds to a llvm::CallInst or |
| 3289 | * llvm::InvokeInst. |
| 3290 | * |
Craig Topper | a58b62b | 2020-04-27 20:15:59 -0700 | [diff] [blame] | 3291 | * @see llvm::CallInst::getCalledOperand() |
| 3292 | * @see llvm::InvokeInst::getCalledOperand() |
Amaury Sechet | 5c7b3af | 2016-02-10 00:09:37 +0000 | [diff] [blame] | 3293 | */ |
| 3294 | LLVMValueRef LLVMGetCalledValue(LLVMValueRef Instr); |
| 3295 | |
| 3296 | /** |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 3297 | * Obtain whether a call instruction is a tail call. |
| 3298 | * |
| 3299 | * This only works on llvm::CallInst instructions. |
| 3300 | * |
| 3301 | * @see llvm::CallInst::isTailCall() |
| 3302 | */ |
Chris Lattner | 25963c6 | 2010-01-09 22:27:07 +0000 | [diff] [blame] | 3303 | LLVMBool LLVMIsTailCall(LLVMValueRef CallInst); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 3304 | |
| 3305 | /** |
| 3306 | * Set whether a call instruction is a tail call. |
| 3307 | * |
| 3308 | * This only works on llvm::CallInst instructions. |
| 3309 | * |
| 3310 | * @see llvm::CallInst::setTailCall() |
| 3311 | */ |
Chris Lattner | 25963c6 | 2010-01-09 22:27:07 +0000 | [diff] [blame] | 3312 | void LLVMSetTailCall(LLVMValueRef CallInst, LLVMBool IsTailCall); |
Gordon Henriksen | eeb6537 | 2008-08-30 16:34:54 +0000 | [diff] [blame] | 3313 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 3314 | /** |
Amaury Sechet | e39e853 | 2016-02-18 20:38:32 +0000 | [diff] [blame] | 3315 | * Return the normal destination basic block. |
| 3316 | * |
| 3317 | * This only works on llvm::InvokeInst instructions. |
| 3318 | * |
| 3319 | * @see llvm::InvokeInst::getNormalDest() |
| 3320 | */ |
| 3321 | LLVMBasicBlockRef LLVMGetNormalDest(LLVMValueRef InvokeInst); |
| 3322 | |
| 3323 | /** |
| 3324 | * Return the unwind destination basic block. |
| 3325 | * |
Robert Widmann | 478fce9 | 2018-03-30 17:49:53 +0000 | [diff] [blame] | 3326 | * Works on llvm::InvokeInst, llvm::CleanupReturnInst, and |
| 3327 | * llvm::CatchSwitchInst instructions. |
Amaury Sechet | e39e853 | 2016-02-18 20:38:32 +0000 | [diff] [blame] | 3328 | * |
| 3329 | * @see llvm::InvokeInst::getUnwindDest() |
Robert Widmann | 478fce9 | 2018-03-30 17:49:53 +0000 | [diff] [blame] | 3330 | * @see llvm::CleanupReturnInst::getUnwindDest() |
| 3331 | * @see llvm::CatchSwitchInst::getUnwindDest() |
Amaury Sechet | e39e853 | 2016-02-18 20:38:32 +0000 | [diff] [blame] | 3332 | */ |
| 3333 | LLVMBasicBlockRef LLVMGetUnwindDest(LLVMValueRef InvokeInst); |
| 3334 | |
| 3335 | /** |
| 3336 | * Set the normal destination basic block. |
| 3337 | * |
| 3338 | * This only works on llvm::InvokeInst instructions. |
| 3339 | * |
| 3340 | * @see llvm::InvokeInst::setNormalDest() |
| 3341 | */ |
| 3342 | void LLVMSetNormalDest(LLVMValueRef InvokeInst, LLVMBasicBlockRef B); |
| 3343 | |
| 3344 | /** |
| 3345 | * Set the unwind destination basic block. |
| 3346 | * |
Robert Widmann | 478fce9 | 2018-03-30 17:49:53 +0000 | [diff] [blame] | 3347 | * Works on llvm::InvokeInst, llvm::CleanupReturnInst, and |
| 3348 | * llvm::CatchSwitchInst instructions. |
Amaury Sechet | e39e853 | 2016-02-18 20:38:32 +0000 | [diff] [blame] | 3349 | * |
| 3350 | * @see llvm::InvokeInst::setUnwindDest() |
Robert Widmann | 478fce9 | 2018-03-30 17:49:53 +0000 | [diff] [blame] | 3351 | * @see llvm::CleanupReturnInst::setUnwindDest() |
| 3352 | * @see llvm::CatchSwitchInst::setUnwindDest() |
Amaury Sechet | e39e853 | 2016-02-18 20:38:32 +0000 | [diff] [blame] | 3353 | */ |
| 3354 | void LLVMSetUnwindDest(LLVMValueRef InvokeInst, LLVMBasicBlockRef B); |
| 3355 | |
| 3356 | /** |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 3357 | * @} |
| 3358 | */ |
| 3359 | |
| 3360 | /** |
Peter Zotov | 2481c75 | 2014-10-28 19:46:56 +0000 | [diff] [blame] | 3361 | * @defgroup LLVMCCoreValueInstructionTerminator Terminators |
| 3362 | * |
Chandler Carruth | 7c80c3a | 2018-10-18 23:03:55 +0000 | [diff] [blame] | 3363 | * Functions in this group only apply to instructions for which |
| 3364 | * LLVMIsATerminatorInst returns true. |
Peter Zotov | 2481c75 | 2014-10-28 19:46:56 +0000 | [diff] [blame] | 3365 | * |
| 3366 | * @{ |
| 3367 | */ |
| 3368 | |
| 3369 | /** |
| 3370 | * Return the number of successors that this terminator has. |
| 3371 | * |
Chandler Carruth | 7c80c3a | 2018-10-18 23:03:55 +0000 | [diff] [blame] | 3372 | * @see llvm::Instruction::getNumSuccessors |
Peter Zotov | 2481c75 | 2014-10-28 19:46:56 +0000 | [diff] [blame] | 3373 | */ |
| 3374 | unsigned LLVMGetNumSuccessors(LLVMValueRef Term); |
| 3375 | |
| 3376 | /** |
| 3377 | * Return the specified successor. |
| 3378 | * |
Chandler Carruth | 7c80c3a | 2018-10-18 23:03:55 +0000 | [diff] [blame] | 3379 | * @see llvm::Instruction::getSuccessor |
Peter Zotov | 2481c75 | 2014-10-28 19:46:56 +0000 | [diff] [blame] | 3380 | */ |
| 3381 | LLVMBasicBlockRef LLVMGetSuccessor(LLVMValueRef Term, unsigned i); |
| 3382 | |
| 3383 | /** |
| 3384 | * Update the specified successor to point at the provided block. |
| 3385 | * |
Chandler Carruth | 7c80c3a | 2018-10-18 23:03:55 +0000 | [diff] [blame] | 3386 | * @see llvm::Instruction::setSuccessor |
Peter Zotov | 2481c75 | 2014-10-28 19:46:56 +0000 | [diff] [blame] | 3387 | */ |
| 3388 | void LLVMSetSuccessor(LLVMValueRef Term, unsigned i, LLVMBasicBlockRef block); |
| 3389 | |
| 3390 | /** |
| 3391 | * Return if a branch is conditional. |
| 3392 | * |
| 3393 | * This only works on llvm::BranchInst instructions. |
| 3394 | * |
| 3395 | * @see llvm::BranchInst::isConditional |
| 3396 | */ |
| 3397 | LLVMBool LLVMIsConditional(LLVMValueRef Branch); |
| 3398 | |
| 3399 | /** |
| 3400 | * Return the condition of a branch instruction. |
| 3401 | * |
| 3402 | * This only works on llvm::BranchInst instructions. |
| 3403 | * |
| 3404 | * @see llvm::BranchInst::getCondition |
| 3405 | */ |
| 3406 | LLVMValueRef LLVMGetCondition(LLVMValueRef Branch); |
| 3407 | |
| 3408 | /** |
| 3409 | * Set the condition of a branch instruction. |
| 3410 | * |
| 3411 | * This only works on llvm::BranchInst instructions. |
| 3412 | * |
| 3413 | * @see llvm::BranchInst::setCondition |
| 3414 | */ |
| 3415 | void LLVMSetCondition(LLVMValueRef Branch, LLVMValueRef Cond); |
| 3416 | |
| 3417 | /** |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 3418 | * Obtain the default destination basic block of a switch instruction. |
| 3419 | * |
| 3420 | * This only works on llvm::SwitchInst instructions. |
| 3421 | * |
| 3422 | * @see llvm::SwitchInst::getDefaultDest() |
| 3423 | */ |
Nate Begeman | 43c322b | 2011-08-23 20:27:46 +0000 | [diff] [blame] | 3424 | LLVMBasicBlockRef LLVMGetSwitchDefaultDest(LLVMValueRef SwitchInstr); |
| 3425 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 3426 | /** |
Peter Zotov | 2481c75 | 2014-10-28 19:46:56 +0000 | [diff] [blame] | 3427 | * @} |
| 3428 | */ |
| 3429 | |
| 3430 | /** |
Amaury Sechet | 1dcf577 | 2016-02-09 22:50:53 +0000 | [diff] [blame] | 3431 | * @defgroup LLVMCCoreValueInstructionAlloca Allocas |
| 3432 | * |
| 3433 | * Functions in this group only apply to instructions that map to |
| 3434 | * llvm::AllocaInst instances. |
| 3435 | * |
| 3436 | * @{ |
| 3437 | */ |
| 3438 | |
| 3439 | /** |
| 3440 | * Obtain the type that is being allocated by the alloca instruction. |
| 3441 | */ |
| 3442 | LLVMTypeRef LLVMGetAllocatedType(LLVMValueRef Alloca); |
| 3443 | |
| 3444 | /** |
| 3445 | * @} |
| 3446 | */ |
| 3447 | |
| 3448 | /** |
Amaury Sechet | 053ac45 | 2016-02-17 22:51:03 +0000 | [diff] [blame] | 3449 | * @defgroup LLVMCCoreValueInstructionGetElementPointer GEPs |
| 3450 | * |
| 3451 | * Functions in this group only apply to instructions that map to |
| 3452 | * llvm::GetElementPtrInst instances. |
| 3453 | * |
| 3454 | * @{ |
| 3455 | */ |
| 3456 | |
| 3457 | /** |
| 3458 | * Check whether the given GEP instruction is inbounds. |
| 3459 | */ |
| 3460 | LLVMBool LLVMIsInBounds(LLVMValueRef GEP); |
| 3461 | |
| 3462 | /** |
| 3463 | * Set the given GEP instruction to be inbounds or not. |
| 3464 | */ |
Amaury Sechet | 8a367d4 | 2016-05-01 02:23:14 +0000 | [diff] [blame] | 3465 | void LLVMSetIsInBounds(LLVMValueRef GEP, LLVMBool InBounds); |
Amaury Sechet | 053ac45 | 2016-02-17 22:51:03 +0000 | [diff] [blame] | 3466 | |
| 3467 | /** |
| 3468 | * @} |
| 3469 | */ |
| 3470 | |
| 3471 | /** |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 3472 | * @defgroup LLVMCCoreValueInstructionPHINode PHI Nodes |
| 3473 | * |
| 3474 | * Functions in this group only apply to instructions that map to |
| 3475 | * llvm::PHINode instances. |
| 3476 | * |
| 3477 | * @{ |
| 3478 | */ |
| 3479 | |
| 3480 | /** |
| 3481 | * Add an incoming value to the end of a PHI list. |
| 3482 | */ |
Gordon Henriksen | 44dd8fb | 2007-10-08 18:14:39 +0000 | [diff] [blame] | 3483 | void LLVMAddIncoming(LLVMValueRef PhiNode, LLVMValueRef *IncomingValues, |
| 3484 | LLVMBasicBlockRef *IncomingBlocks, unsigned Count); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 3485 | |
| 3486 | /** |
| 3487 | * Obtain the number of incoming basic blocks to a PHI node. |
| 3488 | */ |
Gordon Henriksen | 44dd8fb | 2007-10-08 18:14:39 +0000 | [diff] [blame] | 3489 | unsigned LLVMCountIncoming(LLVMValueRef PhiNode); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 3490 | |
| 3491 | /** |
Daniel Dunbar | 06b9f9e | 2013-08-16 23:30:19 +0000 | [diff] [blame] | 3492 | * Obtain an incoming value to a PHI node as an LLVMValueRef. |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 3493 | */ |
Gordon Henriksen | 44dd8fb | 2007-10-08 18:14:39 +0000 | [diff] [blame] | 3494 | LLVMValueRef LLVMGetIncomingValue(LLVMValueRef PhiNode, unsigned Index); |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 3495 | |
| 3496 | /** |
Daniel Dunbar | 06b9f9e | 2013-08-16 23:30:19 +0000 | [diff] [blame] | 3497 | * Obtain an incoming value to a PHI node as an LLVMBasicBlockRef. |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 3498 | */ |
Gordon Henriksen | 44dd8fb | 2007-10-08 18:14:39 +0000 | [diff] [blame] | 3499 | LLVMBasicBlockRef LLVMGetIncomingBlock(LLVMValueRef PhiNode, unsigned Index); |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 3500 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 3501 | /** |
| 3502 | * @} |
| 3503 | */ |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 3504 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 3505 | /** |
Amaury Sechet | aad9353 | 2016-02-10 00:38:50 +0000 | [diff] [blame] | 3506 | * @defgroup LLVMCCoreValueInstructionExtractValue ExtractValue |
| 3507 | * @defgroup LLVMCCoreValueInstructionInsertValue InsertValue |
| 3508 | * |
| 3509 | * Functions in this group only apply to instructions that map to |
| 3510 | * llvm::ExtractValue and llvm::InsertValue instances. |
| 3511 | * |
| 3512 | * @{ |
| 3513 | */ |
| 3514 | |
| 3515 | /** |
| 3516 | * Obtain the number of indices. |
Amaury Sechet | 053ac45 | 2016-02-17 22:51:03 +0000 | [diff] [blame] | 3517 | * NB: This also works on GEP. |
Amaury Sechet | aad9353 | 2016-02-10 00:38:50 +0000 | [diff] [blame] | 3518 | */ |
| 3519 | unsigned LLVMGetNumIndices(LLVMValueRef Inst); |
| 3520 | |
| 3521 | /** |
| 3522 | * Obtain the indices as an array. |
| 3523 | */ |
| 3524 | const unsigned *LLVMGetIndices(LLVMValueRef Inst); |
| 3525 | |
| 3526 | /** |
| 3527 | * @} |
| 3528 | */ |
| 3529 | |
| 3530 | /** |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 3531 | * @} |
| 3532 | */ |
| 3533 | |
| 3534 | /** |
| 3535 | * @} |
| 3536 | */ |
| 3537 | |
| 3538 | /** |
| 3539 | * @defgroup LLVMCCoreInstructionBuilder Instruction Builders |
| 3540 | * |
| 3541 | * An instruction builder represents a point within a basic block and is |
| 3542 | * the exclusive means of building instructions using the C interface. |
| 3543 | * |
| 3544 | * @{ |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 3545 | */ |
| 3546 | |
Erick Tryzelaar | 262332f | 2009-08-14 00:01:31 +0000 | [diff] [blame] | 3547 | LLVMBuilderRef LLVMCreateBuilderInContext(LLVMContextRef C); |
Gordon Henriksen | a735a9c | 2008-05-04 12:55:34 +0000 | [diff] [blame] | 3548 | LLVMBuilderRef LLVMCreateBuilder(void); |
Gordon Henriksen | 054817c | 2008-03-19 03:47:18 +0000 | [diff] [blame] | 3549 | void LLVMPositionBuilder(LLVMBuilderRef Builder, LLVMBasicBlockRef Block, |
| 3550 | LLVMValueRef Instr); |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 3551 | void LLVMPositionBuilderBefore(LLVMBuilderRef Builder, LLVMValueRef Instr); |
| 3552 | void LLVMPositionBuilderAtEnd(LLVMBuilderRef Builder, LLVMBasicBlockRef Block); |
Gordon Henriksen | 265f780 | 2008-03-19 01:11:35 +0000 | [diff] [blame] | 3553 | LLVMBasicBlockRef LLVMGetInsertBlock(LLVMBuilderRef Builder); |
Chris Lattner | 3d1f552 | 2008-12-17 21:39:50 +0000 | [diff] [blame] | 3554 | void LLVMClearInsertionPosition(LLVMBuilderRef Builder); |
| 3555 | void LLVMInsertIntoBuilder(LLVMBuilderRef Builder, LLVMValueRef Instr); |
Erick Tryzelaar | 9813bea | 2009-08-16 02:20:57 +0000 | [diff] [blame] | 3556 | void LLVMInsertIntoBuilderWithName(LLVMBuilderRef Builder, LLVMValueRef Instr, |
| 3557 | const char *Name); |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 3558 | void LLVMDisposeBuilder(LLVMBuilderRef Builder); |
| 3559 | |
Erick Tryzelaar | d8531fa | 2010-02-28 09:45:59 +0000 | [diff] [blame] | 3560 | /* Metadata */ |
Robert Widmann | cce4741 | 2019-04-10 14:19:05 +0000 | [diff] [blame] | 3561 | |
| 3562 | /** |
| 3563 | * Get location information used by debugging information. |
| 3564 | * |
| 3565 | * @see llvm::IRBuilder::getCurrentDebugLocation() |
| 3566 | */ |
| 3567 | LLVMMetadataRef LLVMGetCurrentDebugLocation2(LLVMBuilderRef Builder); |
| 3568 | |
| 3569 | /** |
| 3570 | * Set location information used by debugging information. |
| 3571 | * |
| 3572 | * To clear the location metadata of the given instruction, pass NULL to \p Loc. |
| 3573 | * |
| 3574 | * @see llvm::IRBuilder::SetCurrentDebugLocation() |
| 3575 | */ |
| 3576 | void LLVMSetCurrentDebugLocation2(LLVMBuilderRef Builder, LLVMMetadataRef Loc); |
| 3577 | |
| 3578 | /** |
| 3579 | * Attempts to set the debug location for the given instruction using the |
| 3580 | * current debug location for the given builder. If the builder has no current |
| 3581 | * debug location, this function is a no-op. |
| 3582 | * |
| 3583 | * @see llvm::IRBuilder::SetInstDebugLocation() |
| 3584 | */ |
Sam McCall | 71660b0 | 2019-04-10 13:29:37 +0000 | [diff] [blame] | 3585 | void LLVMSetInstDebugLocation(LLVMBuilderRef Builder, LLVMValueRef Inst); |
Robert Widmann | ff8febc | 2019-04-22 13:13:22 +0000 | [diff] [blame] | 3586 | |
| 3587 | /** |
| 3588 | * Get the dafult floating-point math metadata for a given builder. |
| 3589 | * |
| 3590 | * @see llvm::IRBuilder::getDefaultFPMathTag() |
| 3591 | */ |
| 3592 | LLVMMetadataRef LLVMBuilderGetDefaultFPMathTag(LLVMBuilderRef Builder); |
| 3593 | |
| 3594 | /** |
| 3595 | * Set the default floating-point math metadata for the given builder. |
| 3596 | * |
| 3597 | * To clear the metadata, pass NULL to \p FPMathTag. |
| 3598 | * |
| 3599 | * @see llvm::IRBuilder::setDefaultFPMathTag() |
| 3600 | */ |
| 3601 | void LLVMBuilderSetDefaultFPMathTag(LLVMBuilderRef Builder, |
| 3602 | LLVMMetadataRef FPMathTag); |
| 3603 | |
Robert Widmann | cce4741 | 2019-04-10 14:19:05 +0000 | [diff] [blame] | 3604 | /** |
| 3605 | * Deprecated: Passing the NULL location will crash. |
| 3606 | * Use LLVMGetCurrentDebugLocation2 instead. |
| 3607 | */ |
| 3608 | void LLVMSetCurrentDebugLocation(LLVMBuilderRef Builder, LLVMValueRef L); |
| 3609 | /** |
| 3610 | * Deprecated: Returning the NULL location will crash. |
| 3611 | * Use LLVMGetCurrentDebugLocation2 instead. |
| 3612 | */ |
| 3613 | LLVMValueRef LLVMGetCurrentDebugLocation(LLVMBuilderRef Builder); |
Erick Tryzelaar | d8531fa | 2010-02-28 09:45:59 +0000 | [diff] [blame] | 3614 | |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 3615 | /* Terminators */ |
| 3616 | LLVMValueRef LLVMBuildRetVoid(LLVMBuilderRef); |
| 3617 | LLVMValueRef LLVMBuildRet(LLVMBuilderRef, LLVMValueRef V); |
Erick Tryzelaar | fd529d7 | 2009-08-19 08:36:49 +0000 | [diff] [blame] | 3618 | LLVMValueRef LLVMBuildAggregateRet(LLVMBuilderRef, LLVMValueRef *RetVals, |
Erick Tryzelaar | 3045b8b | 2009-08-16 02:19:59 +0000 | [diff] [blame] | 3619 | unsigned N); |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 3620 | LLVMValueRef LLVMBuildBr(LLVMBuilderRef, LLVMBasicBlockRef Dest); |
| 3621 | LLVMValueRef LLVMBuildCondBr(LLVMBuilderRef, LLVMValueRef If, |
| 3622 | LLVMBasicBlockRef Then, LLVMBasicBlockRef Else); |
| 3623 | LLVMValueRef LLVMBuildSwitch(LLVMBuilderRef, LLVMValueRef V, |
| 3624 | LLVMBasicBlockRef Else, unsigned NumCases); |
Erick Tryzelaar | 0fb26ef | 2010-02-28 09:46:06 +0000 | [diff] [blame] | 3625 | LLVMValueRef LLVMBuildIndirectBr(LLVMBuilderRef B, LLVMValueRef Addr, |
| 3626 | unsigned NumDests); |
James Y Knight | eb2c4af | 2019-01-14 21:37:48 +0000 | [diff] [blame] | 3627 | // LLVMBuildInvoke is deprecated in favor of LLVMBuildInvoke2, in preparation |
| 3628 | // for opaque pointer types. |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 3629 | LLVMValueRef LLVMBuildInvoke(LLVMBuilderRef, LLVMValueRef Fn, |
| 3630 | LLVMValueRef *Args, unsigned NumArgs, |
| 3631 | LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch, |
| 3632 | const char *Name); |
James Y Knight | eb2c4af | 2019-01-14 21:37:48 +0000 | [diff] [blame] | 3633 | LLVMValueRef LLVMBuildInvoke2(LLVMBuilderRef, LLVMTypeRef Ty, LLVMValueRef Fn, |
| 3634 | LLVMValueRef *Args, unsigned NumArgs, |
| 3635 | LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch, |
| 3636 | const char *Name); |
Robert Widmann | 478fce9 | 2018-03-30 17:49:53 +0000 | [diff] [blame] | 3637 | LLVMValueRef LLVMBuildUnreachable(LLVMBuilderRef); |
| 3638 | |
| 3639 | /* Exception Handling */ |
| 3640 | LLVMValueRef LLVMBuildResume(LLVMBuilderRef B, LLVMValueRef Exn); |
Benjamin Kramer | 5a656883 | 2011-08-19 01:36:54 +0000 | [diff] [blame] | 3641 | LLVMValueRef LLVMBuildLandingPad(LLVMBuilderRef B, LLVMTypeRef Ty, |
Reid Kleckner | ef9828f | 2015-07-16 01:16:39 +0000 | [diff] [blame] | 3642 | LLVMValueRef PersFn, unsigned NumClauses, |
| 3643 | const char *Name); |
Robert Widmann | 478fce9 | 2018-03-30 17:49:53 +0000 | [diff] [blame] | 3644 | LLVMValueRef LLVMBuildCleanupRet(LLVMBuilderRef B, LLVMValueRef CatchPad, |
| 3645 | LLVMBasicBlockRef BB); |
| 3646 | LLVMValueRef LLVMBuildCatchRet(LLVMBuilderRef B, LLVMValueRef CatchPad, |
| 3647 | LLVMBasicBlockRef BB); |
| 3648 | LLVMValueRef LLVMBuildCatchPad(LLVMBuilderRef B, LLVMValueRef ParentPad, |
| 3649 | LLVMValueRef *Args, unsigned NumArgs, |
| 3650 | const char *Name); |
| 3651 | LLVMValueRef LLVMBuildCleanupPad(LLVMBuilderRef B, LLVMValueRef ParentPad, |
| 3652 | LLVMValueRef *Args, unsigned NumArgs, |
| 3653 | const char *Name); |
| 3654 | LLVMValueRef LLVMBuildCatchSwitch(LLVMBuilderRef B, LLVMValueRef ParentPad, |
| 3655 | LLVMBasicBlockRef UnwindBB, |
| 3656 | unsigned NumHandlers, const char *Name); |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 3657 | |
Gordon Henriksen | 097102c | 2008-01-01 05:50:53 +0000 | [diff] [blame] | 3658 | /* Add a case to the switch instruction */ |
| 3659 | void LLVMAddCase(LLVMValueRef Switch, LLVMValueRef OnVal, |
| 3660 | LLVMBasicBlockRef Dest); |
| 3661 | |
Erick Tryzelaar | 0fb26ef | 2010-02-28 09:46:06 +0000 | [diff] [blame] | 3662 | /* Add a destination to the indirectbr instruction */ |
| 3663 | void LLVMAddDestination(LLVMValueRef IndirectBr, LLVMBasicBlockRef Dest); |
| 3664 | |
Amaury Sechet | e39e853 | 2016-02-18 20:38:32 +0000 | [diff] [blame] | 3665 | /* Get the number of clauses on the landingpad instruction */ |
| 3666 | unsigned LLVMGetNumClauses(LLVMValueRef LandingPad); |
| 3667 | |
Craig Disselkoen | 51cad04 | 2020-09-25 14:34:23 -0700 | [diff] [blame] | 3668 | /* Get the value of the clause at index Idx on the landingpad instruction */ |
Amaury Sechet | e39e853 | 2016-02-18 20:38:32 +0000 | [diff] [blame] | 3669 | LLVMValueRef LLVMGetClause(LLVMValueRef LandingPad, unsigned Idx); |
| 3670 | |
Bill Wendling | fae1475 | 2011-08-12 20:24:12 +0000 | [diff] [blame] | 3671 | /* Add a catch or filter clause to the landingpad instruction */ |
| 3672 | void LLVMAddClause(LLVMValueRef LandingPad, LLVMValueRef ClauseVal); |
| 3673 | |
Amaury Sechet | e39e853 | 2016-02-18 20:38:32 +0000 | [diff] [blame] | 3674 | /* Get the 'cleanup' flag in the landingpad instruction */ |
| 3675 | LLVMBool LLVMIsCleanup(LLVMValueRef LandingPad); |
| 3676 | |
Bill Wendling | fae1475 | 2011-08-12 20:24:12 +0000 | [diff] [blame] | 3677 | /* Set the 'cleanup' flag in the landingpad instruction */ |
| 3678 | void LLVMSetCleanup(LLVMValueRef LandingPad, LLVMBool Val); |
| 3679 | |
Robert Widmann | 478fce9 | 2018-03-30 17:49:53 +0000 | [diff] [blame] | 3680 | /* Add a destination to the catchswitch instruction */ |
| 3681 | void LLVMAddHandler(LLVMValueRef CatchSwitch, LLVMBasicBlockRef Dest); |
| 3682 | |
| 3683 | /* Get the number of handlers on the catchswitch instruction */ |
| 3684 | unsigned LLVMGetNumHandlers(LLVMValueRef CatchSwitch); |
| 3685 | |
| 3686 | /** |
| 3687 | * Obtain the basic blocks acting as handlers for a catchswitch instruction. |
| 3688 | * |
| 3689 | * The Handlers parameter should point to a pre-allocated array of |
| 3690 | * LLVMBasicBlockRefs at least LLVMGetNumHandlers() large. On return, the |
| 3691 | * first LLVMGetNumHandlers() entries in the array will be populated |
| 3692 | * with LLVMBasicBlockRef instances. |
| 3693 | * |
| 3694 | * @param CatchSwitch The catchswitch instruction to operate on. |
| 3695 | * @param Handlers Memory address of an array to be filled with basic blocks. |
| 3696 | */ |
| 3697 | void LLVMGetHandlers(LLVMValueRef CatchSwitch, LLVMBasicBlockRef *Handlers); |
| 3698 | |
| 3699 | /* Funclets */ |
| 3700 | |
| 3701 | /* Get the number of funcletpad arguments. */ |
| 3702 | LLVMValueRef LLVMGetArgOperand(LLVMValueRef Funclet, unsigned i); |
| 3703 | |
| 3704 | /* Set a funcletpad argument at the given index. */ |
| 3705 | void LLVMSetArgOperand(LLVMValueRef Funclet, unsigned i, LLVMValueRef value); |
| 3706 | |
| 3707 | /** |
| 3708 | * Get the parent catchswitch instruction of a catchpad instruction. |
| 3709 | * |
| 3710 | * This only works on llvm::CatchPadInst instructions. |
| 3711 | * |
| 3712 | * @see llvm::CatchPadInst::getCatchSwitch() |
| 3713 | */ |
| 3714 | LLVMValueRef LLVMGetParentCatchSwitch(LLVMValueRef CatchPad); |
| 3715 | |
| 3716 | /** |
| 3717 | * Set the parent catchswitch instruction of a catchpad instruction. |
| 3718 | * |
| 3719 | * This only works on llvm::CatchPadInst instructions. |
| 3720 | * |
| 3721 | * @see llvm::CatchPadInst::setCatchSwitch() |
| 3722 | */ |
| 3723 | void LLVMSetParentCatchSwitch(LLVMValueRef CatchPad, LLVMValueRef CatchSwitch); |
| 3724 | |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 3725 | /* Arithmetic */ |
| 3726 | LLVMValueRef LLVMBuildAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, |
| 3727 | const char *Name); |
Erick Tryzelaar | 3045b8b | 2009-08-16 02:19:59 +0000 | [diff] [blame] | 3728 | LLVMValueRef LLVMBuildNSWAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, |
| 3729 | const char *Name); |
Erick Tryzelaar | 4c340c7 | 2010-02-28 05:51:43 +0000 | [diff] [blame] | 3730 | LLVMValueRef LLVMBuildNUWAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, |
| 3731 | const char *Name); |
Erick Tryzelaar | 3045b8b | 2009-08-16 02:19:59 +0000 | [diff] [blame] | 3732 | LLVMValueRef LLVMBuildFAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, |
| 3733 | const char *Name); |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 3734 | LLVMValueRef LLVMBuildSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, |
| 3735 | const char *Name); |
Erick Tryzelaar | 4c340c7 | 2010-02-28 05:51:43 +0000 | [diff] [blame] | 3736 | LLVMValueRef LLVMBuildNSWSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, |
| 3737 | const char *Name); |
| 3738 | LLVMValueRef LLVMBuildNUWSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, |
| 3739 | const char *Name); |
Erick Tryzelaar | 3045b8b | 2009-08-16 02:19:59 +0000 | [diff] [blame] | 3740 | LLVMValueRef LLVMBuildFSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, |
| 3741 | const char *Name); |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 3742 | LLVMValueRef LLVMBuildMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, |
| 3743 | const char *Name); |
Erick Tryzelaar | 4c340c7 | 2010-02-28 05:51:43 +0000 | [diff] [blame] | 3744 | LLVMValueRef LLVMBuildNSWMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, |
| 3745 | const char *Name); |
| 3746 | LLVMValueRef LLVMBuildNUWMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, |
| 3747 | const char *Name); |
Erick Tryzelaar | 3045b8b | 2009-08-16 02:19:59 +0000 | [diff] [blame] | 3748 | LLVMValueRef LLVMBuildFMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, |
| 3749 | const char *Name); |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 3750 | LLVMValueRef LLVMBuildUDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, |
| 3751 | const char *Name); |
Manuel Jacob | 49fafb1 | 2016-10-04 23:32:42 +0000 | [diff] [blame] | 3752 | LLVMValueRef LLVMBuildExactUDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, |
| 3753 | const char *Name); |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 3754 | LLVMValueRef LLVMBuildSDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, |
| 3755 | const char *Name); |
Erick Tryzelaar | 3045b8b | 2009-08-16 02:19:59 +0000 | [diff] [blame] | 3756 | LLVMValueRef LLVMBuildExactSDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, |
| 3757 | const char *Name); |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 3758 | LLVMValueRef LLVMBuildFDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, |
| 3759 | const char *Name); |
| 3760 | LLVMValueRef LLVMBuildURem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, |
| 3761 | const char *Name); |
| 3762 | LLVMValueRef LLVMBuildSRem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, |
| 3763 | const char *Name); |
| 3764 | LLVMValueRef LLVMBuildFRem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, |
| 3765 | const char *Name); |
| 3766 | LLVMValueRef LLVMBuildShl(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, |
| 3767 | const char *Name); |
| 3768 | LLVMValueRef LLVMBuildLShr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, |
| 3769 | const char *Name); |
| 3770 | LLVMValueRef LLVMBuildAShr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, |
| 3771 | const char *Name); |
| 3772 | LLVMValueRef LLVMBuildAnd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, |
| 3773 | const char *Name); |
| 3774 | LLVMValueRef LLVMBuildOr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, |
| 3775 | const char *Name); |
| 3776 | LLVMValueRef LLVMBuildXor(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, |
| 3777 | const char *Name); |
Erick Tryzelaar | 3183179 | 2010-02-28 05:51:27 +0000 | [diff] [blame] | 3778 | LLVMValueRef LLVMBuildBinOp(LLVMBuilderRef B, LLVMOpcode Op, |
| 3779 | LLVMValueRef LHS, LLVMValueRef RHS, |
| 3780 | const char *Name); |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 3781 | LLVMValueRef LLVMBuildNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name); |
Erick Tryzelaar | 4c340c7 | 2010-02-28 05:51:43 +0000 | [diff] [blame] | 3782 | LLVMValueRef LLVMBuildNSWNeg(LLVMBuilderRef B, LLVMValueRef V, |
| 3783 | const char *Name); |
| 3784 | LLVMValueRef LLVMBuildNUWNeg(LLVMBuilderRef B, LLVMValueRef V, |
| 3785 | const char *Name); |
Dan Gohman | f919bd6 | 2009-09-28 21:51:41 +0000 | [diff] [blame] | 3786 | LLVMValueRef LLVMBuildFNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name); |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 3787 | LLVMValueRef LLVMBuildNot(LLVMBuilderRef, LLVMValueRef V, const char *Name); |
| 3788 | |
| 3789 | /* Memory */ |
| 3790 | LLVMValueRef LLVMBuildMalloc(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name); |
| 3791 | LLVMValueRef LLVMBuildArrayMalloc(LLVMBuilderRef, LLVMTypeRef Ty, |
| 3792 | LLVMValueRef Val, const char *Name); |
Robert Widmann | 98640f8 | 2018-10-29 15:31:40 +0000 | [diff] [blame] | 3793 | |
| 3794 | /** |
Jim Lin | 466f884 | 2020-02-18 10:48:38 +0800 | [diff] [blame] | 3795 | * Creates and inserts a memset to the specified pointer and the |
Robert Widmann | 98640f8 | 2018-10-29 15:31:40 +0000 | [diff] [blame] | 3796 | * specified value. |
| 3797 | * |
| 3798 | * @see llvm::IRRBuilder::CreateMemSet() |
| 3799 | */ |
| 3800 | LLVMValueRef LLVMBuildMemSet(LLVMBuilderRef B, LLVMValueRef Ptr, |
| 3801 | LLVMValueRef Val, LLVMValueRef Len, |
| 3802 | unsigned Align); |
| 3803 | /** |
| 3804 | * Creates and inserts a memcpy between the specified pointers. |
| 3805 | * |
| 3806 | * @see llvm::IRRBuilder::CreateMemCpy() |
| 3807 | */ |
Jim Lin | 466f884 | 2020-02-18 10:48:38 +0800 | [diff] [blame] | 3808 | LLVMValueRef LLVMBuildMemCpy(LLVMBuilderRef B, |
Robert Widmann | 98640f8 | 2018-10-29 15:31:40 +0000 | [diff] [blame] | 3809 | LLVMValueRef Dst, unsigned DstAlign, |
| 3810 | LLVMValueRef Src, unsigned SrcAlign, |
| 3811 | LLVMValueRef Size); |
| 3812 | /** |
| 3813 | * Creates and inserts a memmove between the specified pointers. |
| 3814 | * |
| 3815 | * @see llvm::IRRBuilder::CreateMemMove() |
| 3816 | */ |
Jim Lin | 466f884 | 2020-02-18 10:48:38 +0800 | [diff] [blame] | 3817 | LLVMValueRef LLVMBuildMemMove(LLVMBuilderRef B, |
Robert Widmann | 98640f8 | 2018-10-29 15:31:40 +0000 | [diff] [blame] | 3818 | LLVMValueRef Dst, unsigned DstAlign, |
| 3819 | LLVMValueRef Src, unsigned SrcAlign, |
| 3820 | LLVMValueRef Size); |
| 3821 | |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 3822 | LLVMValueRef LLVMBuildAlloca(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name); |
| 3823 | LLVMValueRef LLVMBuildArrayAlloca(LLVMBuilderRef, LLVMTypeRef Ty, |
| 3824 | LLVMValueRef Val, const char *Name); |
| 3825 | LLVMValueRef LLVMBuildFree(LLVMBuilderRef, LLVMValueRef PointerVal); |
James Y Knight | 84c1dbd | 2019-01-14 21:37:53 +0000 | [diff] [blame] | 3826 | // LLVMBuildLoad is deprecated in favor of LLVMBuildLoad2, in preparation for |
| 3827 | // opaque pointer types. |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 3828 | LLVMValueRef LLVMBuildLoad(LLVMBuilderRef, LLVMValueRef PointerVal, |
| 3829 | const char *Name); |
James Y Knight | 84c1dbd | 2019-01-14 21:37:53 +0000 | [diff] [blame] | 3830 | LLVMValueRef LLVMBuildLoad2(LLVMBuilderRef, LLVMTypeRef Ty, |
| 3831 | LLVMValueRef PointerVal, const char *Name); |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 3832 | LLVMValueRef LLVMBuildStore(LLVMBuilderRef, LLVMValueRef Val, LLVMValueRef Ptr); |
James Y Knight | 544fa42 | 2019-01-14 21:39:35 +0000 | [diff] [blame] | 3833 | // LLVMBuildGEP, LLVMBuildInBoundsGEP, and LLVMBuildStructGEP are deprecated in |
| 3834 | // favor of LLVMBuild*GEP2, in preparation for opaque pointer types. |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 3835 | LLVMValueRef LLVMBuildGEP(LLVMBuilderRef B, LLVMValueRef Pointer, |
| 3836 | LLVMValueRef *Indices, unsigned NumIndices, |
| 3837 | const char *Name); |
Erick Tryzelaar | 3045b8b | 2009-08-16 02:19:59 +0000 | [diff] [blame] | 3838 | LLVMValueRef LLVMBuildInBoundsGEP(LLVMBuilderRef B, LLVMValueRef Pointer, |
| 3839 | LLVMValueRef *Indices, unsigned NumIndices, |
| 3840 | const char *Name); |
| 3841 | LLVMValueRef LLVMBuildStructGEP(LLVMBuilderRef B, LLVMValueRef Pointer, |
| 3842 | unsigned Idx, const char *Name); |
James Y Knight | 544fa42 | 2019-01-14 21:39:35 +0000 | [diff] [blame] | 3843 | LLVMValueRef LLVMBuildGEP2(LLVMBuilderRef B, LLVMTypeRef Ty, |
| 3844 | LLVMValueRef Pointer, LLVMValueRef *Indices, |
| 3845 | unsigned NumIndices, const char *Name); |
| 3846 | LLVMValueRef LLVMBuildInBoundsGEP2(LLVMBuilderRef B, LLVMTypeRef Ty, |
| 3847 | LLVMValueRef Pointer, LLVMValueRef *Indices, |
| 3848 | unsigned NumIndices, const char *Name); |
| 3849 | LLVMValueRef LLVMBuildStructGEP2(LLVMBuilderRef B, LLVMTypeRef Ty, |
| 3850 | LLVMValueRef Pointer, unsigned Idx, |
| 3851 | const char *Name); |
Erick Tryzelaar | 3045b8b | 2009-08-16 02:19:59 +0000 | [diff] [blame] | 3852 | LLVMValueRef LLVMBuildGlobalString(LLVMBuilderRef B, const char *Str, |
| 3853 | const char *Name); |
| 3854 | LLVMValueRef LLVMBuildGlobalStringPtr(LLVMBuilderRef B, const char *Str, |
| 3855 | const char *Name); |
Chris Lattner | 2cc6f9d | 2012-03-22 03:54:15 +0000 | [diff] [blame] | 3856 | LLVMBool LLVMGetVolatile(LLVMValueRef MemoryAccessInst); |
| 3857 | void LLVMSetVolatile(LLVMValueRef MemoryAccessInst, LLVMBool IsVolatile); |
Nick Lewycky | f57e968 | 2019-09-26 00:58:55 +0000 | [diff] [blame] | 3858 | LLVMBool LLVMGetWeak(LLVMValueRef CmpXchgInst); |
| 3859 | void LLVMSetWeak(LLVMValueRef CmpXchgInst, LLVMBool IsWeak); |
Andrew Wilkins | b7362ce | 2015-08-02 12:16:57 +0000 | [diff] [blame] | 3860 | LLVMAtomicOrdering LLVMGetOrdering(LLVMValueRef MemoryAccessInst); |
| 3861 | void LLVMSetOrdering(LLVMValueRef MemoryAccessInst, LLVMAtomicOrdering Ordering); |
Nick Lewycky | f57e968 | 2019-09-26 00:58:55 +0000 | [diff] [blame] | 3862 | LLVMAtomicRMWBinOp LLVMGetAtomicRMWBinOp(LLVMValueRef AtomicRMWInst); |
| 3863 | void LLVMSetAtomicRMWBinOp(LLVMValueRef AtomicRMWInst, LLVMAtomicRMWBinOp BinOp); |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 3864 | |
| 3865 | /* Casts */ |
| 3866 | LLVMValueRef LLVMBuildTrunc(LLVMBuilderRef, LLVMValueRef Val, |
| 3867 | LLVMTypeRef DestTy, const char *Name); |
| 3868 | LLVMValueRef LLVMBuildZExt(LLVMBuilderRef, LLVMValueRef Val, |
| 3869 | LLVMTypeRef DestTy, const char *Name); |
| 3870 | LLVMValueRef LLVMBuildSExt(LLVMBuilderRef, LLVMValueRef Val, |
| 3871 | LLVMTypeRef DestTy, const char *Name); |
| 3872 | LLVMValueRef LLVMBuildFPToUI(LLVMBuilderRef, LLVMValueRef Val, |
| 3873 | LLVMTypeRef DestTy, const char *Name); |
| 3874 | LLVMValueRef LLVMBuildFPToSI(LLVMBuilderRef, LLVMValueRef Val, |
| 3875 | LLVMTypeRef DestTy, const char *Name); |
| 3876 | LLVMValueRef LLVMBuildUIToFP(LLVMBuilderRef, LLVMValueRef Val, |
| 3877 | LLVMTypeRef DestTy, const char *Name); |
| 3878 | LLVMValueRef LLVMBuildSIToFP(LLVMBuilderRef, LLVMValueRef Val, |
| 3879 | LLVMTypeRef DestTy, const char *Name); |
| 3880 | LLVMValueRef LLVMBuildFPTrunc(LLVMBuilderRef, LLVMValueRef Val, |
| 3881 | LLVMTypeRef DestTy, const char *Name); |
| 3882 | LLVMValueRef LLVMBuildFPExt(LLVMBuilderRef, LLVMValueRef Val, |
| 3883 | LLVMTypeRef DestTy, const char *Name); |
| 3884 | LLVMValueRef LLVMBuildPtrToInt(LLVMBuilderRef, LLVMValueRef Val, |
| 3885 | LLVMTypeRef DestTy, const char *Name); |
| 3886 | LLVMValueRef LLVMBuildIntToPtr(LLVMBuilderRef, LLVMValueRef Val, |
| 3887 | LLVMTypeRef DestTy, const char *Name); |
| 3888 | LLVMValueRef LLVMBuildBitCast(LLVMBuilderRef, LLVMValueRef Val, |
| 3889 | LLVMTypeRef DestTy, const char *Name); |
Matt Arsenault | b03bd4d | 2013-11-15 01:34:59 +0000 | [diff] [blame] | 3890 | LLVMValueRef LLVMBuildAddrSpaceCast(LLVMBuilderRef, LLVMValueRef Val, |
| 3891 | LLVMTypeRef DestTy, const char *Name); |
Erick Tryzelaar | 3045b8b | 2009-08-16 02:19:59 +0000 | [diff] [blame] | 3892 | LLVMValueRef LLVMBuildZExtOrBitCast(LLVMBuilderRef, LLVMValueRef Val, |
| 3893 | LLVMTypeRef DestTy, const char *Name); |
| 3894 | LLVMValueRef LLVMBuildSExtOrBitCast(LLVMBuilderRef, LLVMValueRef Val, |
| 3895 | LLVMTypeRef DestTy, const char *Name); |
| 3896 | LLVMValueRef LLVMBuildTruncOrBitCast(LLVMBuilderRef, LLVMValueRef Val, |
| 3897 | LLVMTypeRef DestTy, const char *Name); |
Erick Tryzelaar | 3183179 | 2010-02-28 05:51:27 +0000 | [diff] [blame] | 3898 | LLVMValueRef LLVMBuildCast(LLVMBuilderRef B, LLVMOpcode Op, LLVMValueRef Val, |
| 3899 | LLVMTypeRef DestTy, const char *Name); |
Erick Tryzelaar | 3045b8b | 2009-08-16 02:19:59 +0000 | [diff] [blame] | 3900 | LLVMValueRef LLVMBuildPointerCast(LLVMBuilderRef, LLVMValueRef Val, |
| 3901 | LLVMTypeRef DestTy, const char *Name); |
Robert Widmann | 40dc48be | 2019-01-08 06:23:22 +0000 | [diff] [blame] | 3902 | LLVMValueRef LLVMBuildIntCast2(LLVMBuilderRef, LLVMValueRef Val, |
| 3903 | LLVMTypeRef DestTy, LLVMBool IsSigned, |
James Y Knight | 68729f9 | 2019-01-14 17:16:55 +0000 | [diff] [blame] | 3904 | const char *Name); |
Erick Tryzelaar | 3045b8b | 2009-08-16 02:19:59 +0000 | [diff] [blame] | 3905 | LLVMValueRef LLVMBuildFPCast(LLVMBuilderRef, LLVMValueRef Val, |
| 3906 | LLVMTypeRef DestTy, const char *Name); |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 3907 | |
Robert Widmann | 40dc48be | 2019-01-08 06:23:22 +0000 | [diff] [blame] | 3908 | /** Deprecated: This cast is always signed. Use LLVMBuildIntCast2 instead. */ |
| 3909 | LLVMValueRef LLVMBuildIntCast(LLVMBuilderRef, LLVMValueRef Val, /*Signed cast!*/ |
| 3910 | LLVMTypeRef DestTy, const char *Name); |
| 3911 | |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 3912 | /* Comparisons */ |
| 3913 | LLVMValueRef LLVMBuildICmp(LLVMBuilderRef, LLVMIntPredicate Op, |
| 3914 | LLVMValueRef LHS, LLVMValueRef RHS, |
| 3915 | const char *Name); |
| 3916 | LLVMValueRef LLVMBuildFCmp(LLVMBuilderRef, LLVMRealPredicate Op, |
| 3917 | LLVMValueRef LHS, LLVMValueRef RHS, |
| 3918 | const char *Name); |
| 3919 | |
| 3920 | /* Miscellaneous instructions */ |
| 3921 | LLVMValueRef LLVMBuildPhi(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name); |
James Y Knight | f956390 | 2019-01-14 21:37:42 +0000 | [diff] [blame] | 3922 | // LLVMBuildCall is deprecated in favor of LLVMBuildCall2, in preparation for |
| 3923 | // opaque pointer types. |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 3924 | LLVMValueRef LLVMBuildCall(LLVMBuilderRef, LLVMValueRef Fn, |
| 3925 | LLVMValueRef *Args, unsigned NumArgs, |
| 3926 | const char *Name); |
James Y Knight | f956390 | 2019-01-14 21:37:42 +0000 | [diff] [blame] | 3927 | LLVMValueRef LLVMBuildCall2(LLVMBuilderRef, LLVMTypeRef, LLVMValueRef Fn, |
| 3928 | LLVMValueRef *Args, unsigned NumArgs, |
| 3929 | const char *Name); |
Gordon Henriksen | c23b66c | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 3930 | LLVMValueRef LLVMBuildSelect(LLVMBuilderRef, LLVMValueRef If, |
| 3931 | LLVMValueRef Then, LLVMValueRef Else, |
| 3932 | const char *Name); |
| 3933 | LLVMValueRef LLVMBuildVAArg(LLVMBuilderRef, LLVMValueRef List, LLVMTypeRef Ty, |
| 3934 | const char *Name); |
| 3935 | LLVMValueRef LLVMBuildExtractElement(LLVMBuilderRef, LLVMValueRef VecVal, |
| 3936 | LLVMValueRef Index, const char *Name); |
| 3937 | LLVMValueRef LLVMBuildInsertElement(LLVMBuilderRef, LLVMValueRef VecVal, |
| 3938 | LLVMValueRef EltVal, LLVMValueRef Index, |
| 3939 | const char *Name); |
| 3940 | LLVMValueRef LLVMBuildShuffleVector(LLVMBuilderRef, LLVMValueRef V1, |
| 3941 | LLVMValueRef V2, LLVMValueRef Mask, |
| 3942 | const char *Name); |
Dan Gohman | d5104a5 | 2008-11-03 22:55:43 +0000 | [diff] [blame] | 3943 | LLVMValueRef LLVMBuildExtractValue(LLVMBuilderRef, LLVMValueRef AggVal, |
| 3944 | unsigned Index, const char *Name); |
| 3945 | LLVMValueRef LLVMBuildInsertValue(LLVMBuilderRef, LLVMValueRef AggVal, |
| 3946 | LLVMValueRef EltVal, unsigned Index, |
| 3947 | const char *Name); |
aqjune | e87d716 | 2019-11-07 01:17:49 +0900 | [diff] [blame] | 3948 | LLVMValueRef LLVMBuildFreeze(LLVMBuilderRef, LLVMValueRef Val, |
| 3949 | const char *Name); |
Gordon Henriksen | 76a0374 | 2007-09-18 03:18:57 +0000 | [diff] [blame] | 3950 | |
Erick Tryzelaar | 3045b8b | 2009-08-16 02:19:59 +0000 | [diff] [blame] | 3951 | LLVMValueRef LLVMBuildIsNull(LLVMBuilderRef, LLVMValueRef Val, |
| 3952 | const char *Name); |
| 3953 | LLVMValueRef LLVMBuildIsNotNull(LLVMBuilderRef, LLVMValueRef Val, |
| 3954 | const char *Name); |
| 3955 | LLVMValueRef LLVMBuildPtrDiff(LLVMBuilderRef, LLVMValueRef LHS, |
| 3956 | LLVMValueRef RHS, const char *Name); |
Filip Pizlo | 0d3f7ec | 2013-11-20 00:07:49 +0000 | [diff] [blame] | 3957 | LLVMValueRef LLVMBuildFence(LLVMBuilderRef B, LLVMAtomicOrdering ordering, |
| 3958 | LLVMBool singleThread, const char *Name); |
| 3959 | LLVMValueRef LLVMBuildAtomicRMW(LLVMBuilderRef B, LLVMAtomicRMWBinOp op, |
NAKAMURA Takumi | a3a8135 | 2013-10-23 17:56:29 +0000 | [diff] [blame] | 3960 | LLVMValueRef PTR, LLVMValueRef Val, |
| 3961 | LLVMAtomicOrdering ordering, |
Carlo Kok | 8c6719b | 2013-04-23 13:21:19 +0000 | [diff] [blame] | 3962 | LLVMBool singleThread); |
Mehdi Amini | 43165d9 | 2016-03-19 21:28:28 +0000 | [diff] [blame] | 3963 | LLVMValueRef LLVMBuildAtomicCmpXchg(LLVMBuilderRef B, LLVMValueRef Ptr, |
| 3964 | LLVMValueRef Cmp, LLVMValueRef New, |
| 3965 | LLVMAtomicOrdering SuccessOrdering, |
| 3966 | LLVMAtomicOrdering FailureOrdering, |
| 3967 | LLVMBool SingleThread); |
| 3968 | |
Craig Disselkoen | 51cad04 | 2020-09-25 14:34:23 -0700 | [diff] [blame] | 3969 | /** |
| 3970 | * Get the number of elements in the mask of a ShuffleVector instruction. |
| 3971 | */ |
| 3972 | unsigned LLVMGetNumMaskElements(LLVMValueRef ShuffleVectorInst); |
| 3973 | |
| 3974 | /** |
Robert Widmann | 55f7273 | 2020-09-26 17:32:38 -0600 | [diff] [blame] | 3975 | * \returns a constant that specifies that the result of a \c ShuffleVectorInst |
| 3976 | * is undefined. |
| 3977 | */ |
| 3978 | int LLVMGetUndefMaskElem(void); |
| 3979 | |
| 3980 | /** |
Craig Disselkoen | 51cad04 | 2020-09-25 14:34:23 -0700 | [diff] [blame] | 3981 | * Get the mask value at position Elt in the mask of a ShuffleVector |
Robert Widmann | 55f7273 | 2020-09-26 17:32:38 -0600 | [diff] [blame] | 3982 | * instruction. |
| 3983 | * |
| 3984 | * \Returns the result of \c LLVMGetUndefMaskElem() if the mask value is undef |
| 3985 | * at that position. |
Craig Disselkoen | 51cad04 | 2020-09-25 14:34:23 -0700 | [diff] [blame] | 3986 | */ |
| 3987 | int LLVMGetMaskValue(LLVMValueRef ShuffleVectorInst, unsigned Elt); |
Craig Disselkoen | 51cad04 | 2020-09-25 14:34:23 -0700 | [diff] [blame] | 3988 | |
Mehdi Amini | 43165d9 | 2016-03-19 21:28:28 +0000 | [diff] [blame] | 3989 | LLVMBool LLVMIsAtomicSingleThread(LLVMValueRef AtomicInst); |
| 3990 | void LLVMSetAtomicSingleThread(LLVMValueRef AtomicInst, LLVMBool SingleThread); |
| 3991 | |
| 3992 | LLVMAtomicOrdering LLVMGetCmpXchgSuccessOrdering(LLVMValueRef CmpXchgInst); |
| 3993 | void LLVMSetCmpXchgSuccessOrdering(LLVMValueRef CmpXchgInst, |
| 3994 | LLVMAtomicOrdering Ordering); |
| 3995 | LLVMAtomicOrdering LLVMGetCmpXchgFailureOrdering(LLVMValueRef CmpXchgInst); |
| 3996 | void LLVMSetCmpXchgFailureOrdering(LLVMValueRef CmpXchgInst, |
| 3997 | LLVMAtomicOrdering Ordering); |
Erick Tryzelaar | 3045b8b | 2009-08-16 02:19:59 +0000 | [diff] [blame] | 3998 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 3999 | /** |
| 4000 | * @} |
| 4001 | */ |
Gordon Henriksen | 34eb6d8 | 2007-12-19 22:30:40 +0000 | [diff] [blame] | 4002 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 4003 | /** |
| 4004 | * @defgroup LLVMCCoreModuleProvider Module Providers |
| 4005 | * |
| 4006 | * @{ |
| 4007 | */ |
Gordon Henriksen | 0a68fe2 | 2007-12-12 01:04:30 +0000 | [diff] [blame] | 4008 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 4009 | /** |
| 4010 | * Changes the type of M so it can be passed to FunctionPassManagers and the |
Jeffrey Yasskin | 091217b | 2010-01-27 20:34:15 +0000 | [diff] [blame] | 4011 | * JIT. They take ModuleProviders for historical reasons. |
Gordon Henriksen | 0a68fe2 | 2007-12-12 01:04:30 +0000 | [diff] [blame] | 4012 | */ |
| 4013 | LLVMModuleProviderRef |
| 4014 | LLVMCreateModuleProviderForExistingModule(LLVMModuleRef M); |
| 4015 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 4016 | /** |
| 4017 | * Destroys the module M. |
Gordon Henriksen | 0a68fe2 | 2007-12-12 01:04:30 +0000 | [diff] [blame] | 4018 | */ |
Jeffrey Yasskin | 091217b | 2010-01-27 20:34:15 +0000 | [diff] [blame] | 4019 | void LLVMDisposeModuleProvider(LLVMModuleProviderRef M); |
Gordon Henriksen | 0a68fe2 | 2007-12-12 01:04:30 +0000 | [diff] [blame] | 4020 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 4021 | /** |
| 4022 | * @} |
| 4023 | */ |
Gordon Henriksen | 34eb6d8 | 2007-12-19 22:30:40 +0000 | [diff] [blame] | 4024 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 4025 | /** |
| 4026 | * @defgroup LLVMCCoreMemoryBuffers Memory Buffers |
| 4027 | * |
| 4028 | * @{ |
| 4029 | */ |
Gordon Henriksen | 34eb6d8 | 2007-12-19 22:30:40 +0000 | [diff] [blame] | 4030 | |
Chris Lattner | 25963c6 | 2010-01-09 22:27:07 +0000 | [diff] [blame] | 4031 | LLVMBool LLVMCreateMemoryBufferWithContentsOfFile(const char *Path, |
| 4032 | LLVMMemoryBufferRef *OutMemBuf, |
| 4033 | char **OutMessage); |
| 4034 | LLVMBool LLVMCreateMemoryBufferWithSTDIN(LLVMMemoryBufferRef *OutMemBuf, |
| 4035 | char **OutMessage); |
Bill Wendling | 526276a | 2013-02-14 19:11:28 +0000 | [diff] [blame] | 4036 | LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRange(const char *InputData, |
| 4037 | size_t InputDataLength, |
| 4038 | const char *BufferName, |
Bill Wendling | c9baa96 | 2013-02-14 19:39:14 +0000 | [diff] [blame] | 4039 | LLVMBool RequiresNullTerminator); |
Bill Wendling | 526276a | 2013-02-14 19:11:28 +0000 | [diff] [blame] | 4040 | LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRangeCopy(const char *InputData, |
| 4041 | size_t InputDataLength, |
| 4042 | const char *BufferName); |
Tom Stellard | 62c0320 | 2013-04-18 19:50:53 +0000 | [diff] [blame] | 4043 | const char *LLVMGetBufferStart(LLVMMemoryBufferRef MemBuf); |
Tom Stellard | b7fb724 | 2013-04-16 23:12:51 +0000 | [diff] [blame] | 4044 | size_t LLVMGetBufferSize(LLVMMemoryBufferRef MemBuf); |
Gordon Henriksen | 34eb6d8 | 2007-12-19 22:30:40 +0000 | [diff] [blame] | 4045 | void LLVMDisposeMemoryBuffer(LLVMMemoryBufferRef MemBuf); |
| 4046 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 4047 | /** |
| 4048 | * @} |
| 4049 | */ |
| 4050 | |
| 4051 | /** |
| 4052 | * @defgroup LLVMCCorePassRegistry Pass Registry |
| 4053 | * |
| 4054 | * @{ |
| 4055 | */ |
Owen Anderson | 4698c5d | 2010-10-07 17:55:47 +0000 | [diff] [blame] | 4056 | |
| 4057 | /** Return the global pass registry, for use with initialization functions. |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 4058 | @see llvm::PassRegistry::getPassRegistry */ |
Owen Anderson | 4698c5d | 2010-10-07 17:55:47 +0000 | [diff] [blame] | 4059 | LLVMPassRegistryRef LLVMGetGlobalPassRegistry(void); |
Gordon Henriksen | 878114b | 2008-03-16 04:20:44 +0000 | [diff] [blame] | 4060 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 4061 | /** |
| 4062 | * @} |
| 4063 | */ |
| 4064 | |
| 4065 | /** |
| 4066 | * @defgroup LLVMCCorePassManagers Pass Managers |
| 4067 | * |
| 4068 | * @{ |
| 4069 | */ |
Gordon Henriksen | 878114b | 2008-03-16 04:20:44 +0000 | [diff] [blame] | 4070 | |
| 4071 | /** Constructs a new whole-module pass pipeline. This type of pipeline is |
| 4072 | suitable for link-time optimization and whole-module transformations. |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 4073 | @see llvm::PassManager::PassManager */ |
Gordon Henriksen | a735a9c | 2008-05-04 12:55:34 +0000 | [diff] [blame] | 4074 | LLVMPassManagerRef LLVMCreatePassManager(void); |
Gordon Henriksen | 878114b | 2008-03-16 04:20:44 +0000 | [diff] [blame] | 4075 | |
| 4076 | /** Constructs a new function-by-function pass pipeline over the module |
| 4077 | provider. It does not take ownership of the module provider. This type of |
| 4078 | pipeline is suitable for code generation and JIT compilation tasks. |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 4079 | @see llvm::FunctionPassManager::FunctionPassManager */ |
Erick Tryzelaar | ad0e0cb | 2010-03-02 23:58:54 +0000 | [diff] [blame] | 4080 | LLVMPassManagerRef LLVMCreateFunctionPassManagerForModule(LLVMModuleRef M); |
| 4081 | |
| 4082 | /** Deprecated: Use LLVMCreateFunctionPassManagerForModule instead. */ |
Gordon Henriksen | 878114b | 2008-03-16 04:20:44 +0000 | [diff] [blame] | 4083 | LLVMPassManagerRef LLVMCreateFunctionPassManager(LLVMModuleProviderRef MP); |
| 4084 | |
| 4085 | /** Initializes, executes on the provided module, and finalizes all of the |
| 4086 | passes scheduled in the pass manager. Returns 1 if any of the passes |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 4087 | modified the module, 0 otherwise. |
| 4088 | @see llvm::PassManager::run(Module&) */ |
Chris Lattner | 25963c6 | 2010-01-09 22:27:07 +0000 | [diff] [blame] | 4089 | LLVMBool LLVMRunPassManager(LLVMPassManagerRef PM, LLVMModuleRef M); |
Gordon Henriksen | 878114b | 2008-03-16 04:20:44 +0000 | [diff] [blame] | 4090 | |
| 4091 | /** Initializes all of the function passes scheduled in the function pass |
| 4092 | manager. Returns 1 if any of the passes modified the module, 0 otherwise. |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 4093 | @see llvm::FunctionPassManager::doInitialization */ |
Chris Lattner | 25963c6 | 2010-01-09 22:27:07 +0000 | [diff] [blame] | 4094 | LLVMBool LLVMInitializeFunctionPassManager(LLVMPassManagerRef FPM); |
Gordon Henriksen | 878114b | 2008-03-16 04:20:44 +0000 | [diff] [blame] | 4095 | |
| 4096 | /** Executes all of the function passes scheduled in the function pass manager |
| 4097 | on the provided function. Returns 1 if any of the passes modified the |
| 4098 | function, false otherwise. |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 4099 | @see llvm::FunctionPassManager::run(Function&) */ |
Chris Lattner | 25963c6 | 2010-01-09 22:27:07 +0000 | [diff] [blame] | 4100 | LLVMBool LLVMRunFunctionPassManager(LLVMPassManagerRef FPM, LLVMValueRef F); |
Gordon Henriksen | 878114b | 2008-03-16 04:20:44 +0000 | [diff] [blame] | 4101 | |
Hiroshi Inoue | 0909ca1 | 2018-01-26 08:15:29 +0000 | [diff] [blame] | 4102 | /** Finalizes all of the function passes scheduled in the function pass |
Gordon Henriksen | 878114b | 2008-03-16 04:20:44 +0000 | [diff] [blame] | 4103 | manager. Returns 1 if any of the passes modified the module, 0 otherwise. |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 4104 | @see llvm::FunctionPassManager::doFinalization */ |
Chris Lattner | 25963c6 | 2010-01-09 22:27:07 +0000 | [diff] [blame] | 4105 | LLVMBool LLVMFinalizeFunctionPassManager(LLVMPassManagerRef FPM); |
Gordon Henriksen | 878114b | 2008-03-16 04:20:44 +0000 | [diff] [blame] | 4106 | |
| 4107 | /** Frees the memory of a pass pipeline. For function pipelines, does not free |
| 4108 | the module provider. |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 4109 | @see llvm::PassManagerBase::~PassManagerBase. */ |
Gordon Henriksen | 878114b | 2008-03-16 04:20:44 +0000 | [diff] [blame] | 4110 | void LLVMDisposePassManager(LLVMPassManagerRef PM); |
| 4111 | |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 4112 | /** |
| 4113 | * @} |
| 4114 | */ |
| 4115 | |
| 4116 | /** |
Duncan Sands | 1cba0a8 | 2013-02-17 16:35:51 +0000 | [diff] [blame] | 4117 | * @defgroup LLVMCCoreThreading Threading |
| 4118 | * |
| 4119 | * Handle the structures needed to make LLVM safe for multithreading. |
| 4120 | * |
| 4121 | * @{ |
| 4122 | */ |
| 4123 | |
Chandler Carruth | 39cd216 | 2014-06-27 15:13:01 +0000 | [diff] [blame] | 4124 | /** Deprecated: Multi-threading can only be enabled/disabled with the compile |
| 4125 | time define LLVM_ENABLE_THREADS. This function always returns |
| 4126 | LLVMIsMultithreaded(). */ |
Benjamin Kramer | 325ec89 | 2013-10-23 16:57:34 +0000 | [diff] [blame] | 4127 | LLVMBool LLVMStartMultithreaded(void); |
Duncan Sands | 1cba0a8 | 2013-02-17 16:35:51 +0000 | [diff] [blame] | 4128 | |
Chandler Carruth | 39cd216 | 2014-06-27 15:13:01 +0000 | [diff] [blame] | 4129 | /** Deprecated: Multi-threading can only be enabled/disabled with the compile |
| 4130 | time define LLVM_ENABLE_THREADS. */ |
Benjamin Kramer | 325ec89 | 2013-10-23 16:57:34 +0000 | [diff] [blame] | 4131 | void LLVMStopMultithreaded(void); |
Duncan Sands | 1cba0a8 | 2013-02-17 16:35:51 +0000 | [diff] [blame] | 4132 | |
| 4133 | /** Check whether LLVM is executing in thread-safe mode or not. |
| 4134 | @see llvm::llvm_is_multithreaded */ |
Benjamin Kramer | 325ec89 | 2013-10-23 16:57:34 +0000 | [diff] [blame] | 4135 | LLVMBool LLVMIsMultithreaded(void); |
Duncan Sands | 1cba0a8 | 2013-02-17 16:35:51 +0000 | [diff] [blame] | 4136 | |
| 4137 | /** |
| 4138 | * @} |
| 4139 | */ |
| 4140 | |
| 4141 | /** |
Gregory Szorc | 34c863a | 2012-03-21 03:54:29 +0000 | [diff] [blame] | 4142 | * @} |
| 4143 | */ |
| 4144 | |
| 4145 | /** |
| 4146 | * @} |
| 4147 | */ |
Gordon Henriksen | 878114b | 2008-03-16 04:20:44 +0000 | [diff] [blame] | 4148 | |
Duncan P. N. Exon Smith | 8c48405 | 2019-11-14 13:57:57 -0800 | [diff] [blame] | 4149 | LLVM_C_EXTERN_C_END |
Gordon Henriksen | 7330acd | 2007-10-05 23:59:36 +0000 | [diff] [blame] | 4150 | |
Eugene Zelenko | ffec81c | 2015-11-04 22:32:32 +0000 | [diff] [blame] | 4151 | #endif /* LLVM_C_CORE_H */ |