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