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