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