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