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