| 1 | /*===-- llvm-c/Core.h - Core Library C Interface ------------------*- C -*-===*\ |
| 2 | |* *| |
| 3 | |* Part of the LLVM Project, under the Apache License v2.0 with LLVM *| |
| 4 | |* Exceptions. *| |
| 5 | |* See https://llvm.org/LICENSE.txt for license information. *| |
| 6 | |* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *| |
| 7 | |* *| |
| 8 | |*===----------------------------------------------------------------------===*| |
| 9 | |* *| |
| 10 | |* This header declares the C interface to libLLVMCore.a, which implements *| |
| 11 | |* the LLVM intermediate representation. *| |
| 12 | |* *| |
| 13 | \*===----------------------------------------------------------------------===*/ |
| 14 | |
| 15 | #ifndef LLVM_C_CORE_H |
| 16 | #define LLVM_C_CORE_H |
| 17 | |
| 18 | #include "llvm-c/Deprecated.h" |
| 19 | #include "llvm-c/ErrorHandling.h" |
| 20 | #include "llvm-c/ExternC.h" |
| 21 | #include "llvm-c/Visibility.h" |
| 22 | |
| 23 | #include "llvm-c/Types.h" |
| 24 | |
| 25 | LLVM_C_EXTERN_C_BEGIN |
| 26 | |
| 27 | /** |
| 28 | * @defgroup LLVMC LLVM-C: C interface to LLVM |
| 29 | * |
| 30 | * This module exposes parts of the LLVM library as a C API. |
| 31 | * |
| 32 | * @{ |
| 33 | */ |
| 34 | |
| 35 | /** |
| 36 | * @defgroup LLVMCTransforms Transforms |
| 37 | */ |
| 38 | |
| 39 | /** |
| 40 | * @defgroup LLVMCCore Core |
| 41 | * |
| 42 | * This modules provide an interface to libLLVMCore, which implements |
| 43 | * the LLVM intermediate representation as well as other related types |
| 44 | * and utilities. |
| 45 | * |
| 46 | * Many exotic languages can interoperate with C code but have a harder time |
| 47 | * with C++ due to name mangling. So in addition to C, this interface enables |
| 48 | * tools written in such languages. |
| 49 | * |
| 50 | * @{ |
| 51 | */ |
| 52 | |
| 53 | /** |
| 54 | * @defgroup LLVMCCoreTypes Types and Enumerations |
| 55 | * |
| 56 | * @{ |
| 57 | */ |
| 58 | |
| 59 | /// External users depend on the following values being stable. It is not safe |
| 60 | /// to reorder them. |
| 61 | typedef enum { |
| 62 | /* Terminator Instructions */ |
| 63 | LLVMRet = 1, |
| 64 | LLVMBr = 2, |
| 65 | LLVMSwitch = 3, |
| 66 | LLVMIndirectBr = 4, |
| 67 | LLVMInvoke = 5, |
| 68 | /* removed 6 due to API changes */ |
| 69 | LLVMUnreachable = 7, |
| 70 | LLVMCallBr = 67, |
| 71 | |
| 72 | /* Standard Unary Operators */ |
| 73 | LLVMFNeg = 66, |
| 74 | |
| 75 | /* Standard Binary Operators */ |
| 76 | LLVMAdd = 8, |
| 77 | LLVMFAdd = 9, |
| 78 | LLVMSub = 10, |
| 79 | LLVMFSub = 11, |
| 80 | LLVMMul = 12, |
| 81 | LLVMFMul = 13, |
| 82 | LLVMUDiv = 14, |
| 83 | LLVMSDiv = 15, |
| 84 | LLVMFDiv = 16, |
| 85 | LLVMURem = 17, |
| 86 | LLVMSRem = 18, |
| 87 | LLVMFRem = 19, |
| 88 | |
| 89 | /* Logical Operators */ |
| 90 | LLVMShl = 20, |
| 91 | LLVMLShr = 21, |
| 92 | LLVMAShr = 22, |
| 93 | LLVMAnd = 23, |
| 94 | LLVMOr = 24, |
| 95 | LLVMXor = 25, |
| 96 | |
| 97 | /* Memory Operators */ |
| 98 | LLVMAlloca = 26, |
| 99 | LLVMLoad = 27, |
| 100 | LLVMStore = 28, |
| 101 | LLVMGetElementPtr = 29, |
| 102 | |
| 103 | /* Cast Operators */ |
| 104 | LLVMTrunc = 30, |
| 105 | LLVMZExt = 31, |
| 106 | LLVMSExt = 32, |
| 107 | LLVMFPToUI = 33, |
| 108 | LLVMFPToSI = 34, |
| 109 | LLVMUIToFP = 35, |
| 110 | LLVMSIToFP = 36, |
| 111 | LLVMFPTrunc = 37, |
| 112 | LLVMFPExt = 38, |
| 113 | LLVMPtrToInt = 39, |
| 114 | LLVMPtrToAddr = 69, |
| 115 | LLVMIntToPtr = 40, |
| 116 | LLVMBitCast = 41, |
| 117 | LLVMAddrSpaceCast = 60, |
| 118 | |
| 119 | /* Other Operators */ |
| 120 | LLVMICmp = 42, |
| 121 | LLVMFCmp = 43, |
| 122 | LLVMPHI = 44, |
| 123 | LLVMCall = 45, |
| 124 | LLVMSelect = 46, |
| 125 | LLVMUserOp1 = 47, |
| 126 | LLVMUserOp2 = 48, |
| 127 | LLVMVAArg = 49, |
| 128 | = 50, |
| 129 | LLVMInsertElement = 51, |
| 130 | LLVMShuffleVector = 52, |
| 131 | = 53, |
| 132 | LLVMInsertValue = 54, |
| 133 | LLVMFreeze = 68, |
| 134 | |
| 135 | /* Atomic operators */ |
| 136 | LLVMFence = 55, |
| 137 | LLVMAtomicCmpXchg = 56, |
| 138 | LLVMAtomicRMW = 57, |
| 139 | |
| 140 | /* Exception Handling Operators */ |
| 141 | LLVMResume = 58, |
| 142 | LLVMLandingPad = 59, |
| 143 | LLVMCleanupRet = 61, |
| 144 | LLVMCatchRet = 62, |
| 145 | LLVMCatchPad = 63, |
| 146 | LLVMCleanupPad = 64, |
| 147 | LLVMCatchSwitch = 65 |
| 148 | } LLVMOpcode; |
| 149 | |
| 150 | typedef enum { |
| 151 | LLVMVoidTypeKind = 0, /**< type with no size */ |
| 152 | LLVMHalfTypeKind = 1, /**< 16 bit floating point type */ |
| 153 | LLVMFloatTypeKind = 2, /**< 32 bit floating point type */ |
| 154 | LLVMDoubleTypeKind = 3, /**< 64 bit floating point type */ |
| 155 | LLVMX86_FP80TypeKind = 4, /**< 80 bit floating point type (X87) */ |
| 156 | LLVMFP128TypeKind = 5, /**< 128 bit floating point type (112-bit mantissa)*/ |
| 157 | LLVMPPC_FP128TypeKind = 6, /**< 128 bit floating point type (two 64-bits) */ |
| 158 | LLVMLabelTypeKind = 7, /**< Labels */ |
| 159 | LLVMIntegerTypeKind = 8, /**< Arbitrary bit width integers */ |
| 160 | LLVMFunctionTypeKind = 9, /**< Functions */ |
| 161 | LLVMStructTypeKind = 10, /**< Structures */ |
| 162 | LLVMArrayTypeKind = 11, /**< Arrays */ |
| 163 | LLVMPointerTypeKind = 12, /**< Pointers */ |
| 164 | LLVMVectorTypeKind = 13, /**< Fixed width SIMD vector type */ |
| 165 | LLVMMetadataTypeKind = 14, /**< Metadata */ |
| 166 | /* 15 previously used by LLVMX86_MMXTypeKind */ |
| 167 | LLVMTokenTypeKind = 16, /**< Tokens */ |
| 168 | LLVMScalableVectorTypeKind = 17, /**< Scalable SIMD vector type */ |
| 169 | LLVMBFloatTypeKind = 18, /**< 16 bit brain floating point type */ |
| 170 | LLVMX86_AMXTypeKind = 19, /**< X86 AMX */ |
| 171 | LLVMTargetExtTypeKind = 20, /**< Target extension type */ |
| 172 | } LLVMTypeKind; |
| 173 | |
| 174 | typedef enum { |
| 175 | LLVMExternalLinkage, /**< Externally visible function */ |
| 176 | LLVMAvailableExternallyLinkage, |
| 177 | LLVMLinkOnceAnyLinkage, /**< Keep one copy of function when linking (inline)*/ |
| 178 | LLVMLinkOnceODRLinkage, /**< Same, but only replaced by something |
| 179 | equivalent. */ |
| 180 | LLVMLinkOnceODRAutoHideLinkage, /**< Obsolete */ |
| 181 | LLVMWeakAnyLinkage, /**< Keep one copy of function when linking (weak) */ |
| 182 | LLVMWeakODRLinkage, /**< Same, but only replaced by something |
| 183 | equivalent. */ |
| 184 | LLVMAppendingLinkage, /**< Special purpose, only applies to global arrays */ |
| 185 | LLVMInternalLinkage, /**< Rename collisions when linking (static |
| 186 | functions) */ |
| 187 | LLVMPrivateLinkage, /**< Like Internal, but omit from symbol table */ |
| 188 | LLVMDLLImportLinkage, /**< Obsolete */ |
| 189 | LLVMDLLExportLinkage, /**< Obsolete */ |
| 190 | LLVMExternalWeakLinkage,/**< ExternalWeak linkage description */ |
| 191 | LLVMGhostLinkage, /**< Obsolete */ |
| 192 | LLVMCommonLinkage, /**< Tentative definitions */ |
| 193 | LLVMLinkerPrivateLinkage, /**< Like Private, but linker removes. */ |
| 194 | LLVMLinkerPrivateWeakLinkage /**< Like LinkerPrivate, but is weak. */ |
| 195 | } LLVMLinkage; |
| 196 | |
| 197 | typedef enum { |
| 198 | LLVMDefaultVisibility, /**< The GV is visible */ |
| 199 | LLVMHiddenVisibility, /**< The GV is hidden */ |
| 200 | LLVMProtectedVisibility /**< The GV is protected */ |
| 201 | } LLVMVisibility; |
| 202 | |
| 203 | typedef enum { |
| 204 | LLVMNoUnnamedAddr, /**< Address of the GV is significant. */ |
| 205 | LLVMLocalUnnamedAddr, /**< Address of the GV is locally insignificant. */ |
| 206 | LLVMGlobalUnnamedAddr /**< Address of the GV is globally insignificant. */ |
| 207 | } LLVMUnnamedAddr; |
| 208 | |
| 209 | typedef enum { |
| 210 | LLVMDefaultStorageClass = 0, |
| 211 | LLVMDLLImportStorageClass = 1, /**< Function to be imported from DLL. */ |
| 212 | LLVMDLLExportStorageClass = 2 /**< Function to be accessible from DLL. */ |
| 213 | } LLVMDLLStorageClass; |
| 214 | |
| 215 | typedef enum { |
| 216 | LLVMCCallConv = 0, |
| 217 | LLVMFastCallConv = 8, |
| 218 | LLVMColdCallConv = 9, |
| 219 | LLVMGHCCallConv = 10, |
| 220 | LLVMHiPECallConv = 11, |
| 221 | LLVMAnyRegCallConv = 13, |
| 222 | LLVMPreserveMostCallConv = 14, |
| 223 | LLVMPreserveAllCallConv = 15, |
| 224 | LLVMSwiftCallConv = 16, |
| 225 | LLVMCXXFASTTLSCallConv = 17, |
| 226 | LLVMX86StdcallCallConv = 64, |
| 227 | LLVMX86FastcallCallConv = 65, |
| 228 | LLVMARMAPCSCallConv = 66, |
| 229 | LLVMARMAAPCSCallConv = 67, |
| 230 | LLVMARMAAPCSVFPCallConv = 68, |
| 231 | LLVMMSP430INTRCallConv = 69, |
| 232 | LLVMX86ThisCallCallConv = 70, |
| 233 | LLVMPTXKernelCallConv = 71, |
| 234 | LLVMPTXDeviceCallConv = 72, |
| 235 | LLVMSPIRFUNCCallConv = 75, |
| 236 | LLVMSPIRKERNELCallConv = 76, |
| 237 | LLVMIntelOCLBICallConv = 77, |
| 238 | LLVMX8664SysVCallConv = 78, |
| 239 | LLVMWin64CallConv = 79, |
| 240 | LLVMX86VectorCallCallConv = 80, |
| 241 | LLVMHHVMCallConv = 81, |
| 242 | LLVMHHVMCCallConv = 82, |
| 243 | LLVMX86INTRCallConv = 83, |
| 244 | LLVMAVRINTRCallConv = 84, |
| 245 | LLVMAVRSIGNALCallConv = 85, |
| 246 | LLVMAVRBUILTINCallConv = 86, |
| 247 | LLVMAMDGPUVSCallConv = 87, |
| 248 | LLVMAMDGPUGSCallConv = 88, |
| 249 | LLVMAMDGPUPSCallConv = 89, |
| 250 | LLVMAMDGPUCSCallConv = 90, |
| 251 | LLVMAMDGPUKERNELCallConv = 91, |
| 252 | LLVMX86RegCallCallConv = 92, |
| 253 | LLVMAMDGPUHSCallConv = 93, |
| 254 | LLVMMSP430BUILTINCallConv = 94, |
| 255 | LLVMAMDGPULSCallConv = 95, |
| 256 | LLVMAMDGPUESCallConv = 96 |
| 257 | } LLVMCallConv; |
| 258 | |
| 259 | typedef enum { |
| 260 | LLVMArgumentValueKind, |
| 261 | LLVMBasicBlockValueKind, |
| 262 | LLVMMemoryUseValueKind, |
| 263 | LLVMMemoryDefValueKind, |
| 264 | LLVMMemoryPhiValueKind, |
| 265 | |
| 266 | LLVMFunctionValueKind, |
| 267 | LLVMGlobalAliasValueKind, |
| 268 | LLVMGlobalIFuncValueKind, |
| 269 | LLVMGlobalVariableValueKind, |
| 270 | LLVMBlockAddressValueKind, |
| 271 | LLVMConstantExprValueKind, |
| 272 | LLVMConstantArrayValueKind, |
| 273 | LLVMConstantStructValueKind, |
| 274 | LLVMConstantVectorValueKind, |
| 275 | |
| 276 | LLVMUndefValueValueKind, |
| 277 | LLVMConstantAggregateZeroValueKind, |
| 278 | LLVMConstantDataArrayValueKind, |
| 279 | LLVMConstantDataVectorValueKind, |
| 280 | LLVMConstantIntValueKind, |
| 281 | LLVMConstantFPValueKind, |
| 282 | LLVMConstantPointerNullValueKind, |
| 283 | LLVMConstantTokenNoneValueKind, |
| 284 | |
| 285 | LLVMMetadataAsValueValueKind, |
| 286 | LLVMInlineAsmValueKind, |
| 287 | |
| 288 | LLVMInstructionValueKind, |
| 289 | LLVMPoisonValueValueKind, |
| 290 | LLVMConstantTargetNoneValueKind, |
| 291 | LLVMConstantPtrAuthValueKind, |
| 292 | } LLVMValueKind; |
| 293 | |
| 294 | typedef enum { |
| 295 | LLVMIntEQ = 32, /**< equal */ |
| 296 | LLVMIntNE, /**< not equal */ |
| 297 | LLVMIntUGT, /**< unsigned greater than */ |
| 298 | LLVMIntUGE, /**< unsigned greater or equal */ |
| 299 | LLVMIntULT, /**< unsigned less than */ |
| 300 | LLVMIntULE, /**< unsigned less or equal */ |
| 301 | LLVMIntSGT, /**< signed greater than */ |
| 302 | LLVMIntSGE, /**< signed greater or equal */ |
| 303 | LLVMIntSLT, /**< signed less than */ |
| 304 | LLVMIntSLE /**< signed less or equal */ |
| 305 | } LLVMIntPredicate; |
| 306 | |
| 307 | typedef enum { |
| 308 | LLVMRealPredicateFalse, /**< Always false (always folded) */ |
| 309 | LLVMRealOEQ, /**< True if ordered and equal */ |
| 310 | LLVMRealOGT, /**< True if ordered and greater than */ |
| 311 | LLVMRealOGE, /**< True if ordered and greater than or equal */ |
| 312 | LLVMRealOLT, /**< True if ordered and less than */ |
| 313 | LLVMRealOLE, /**< True if ordered and less than or equal */ |
| 314 | LLVMRealONE, /**< True if ordered and operands are unequal */ |
| 315 | LLVMRealORD, /**< True if ordered (no nans) */ |
| 316 | LLVMRealUNO, /**< True if unordered: isnan(X) | isnan(Y) */ |
| 317 | LLVMRealUEQ, /**< True if unordered or equal */ |
| 318 | LLVMRealUGT, /**< True if unordered or greater than */ |
| 319 | LLVMRealUGE, /**< True if unordered, greater than, or equal */ |
| 320 | LLVMRealULT, /**< True if unordered or less than */ |
| 321 | LLVMRealULE, /**< True if unordered, less than, or equal */ |
| 322 | LLVMRealUNE, /**< True if unordered or not equal */ |
| 323 | LLVMRealPredicateTrue /**< Always true (always folded) */ |
| 324 | } LLVMRealPredicate; |
| 325 | |
| 326 | typedef enum { |
| 327 | LLVMNotThreadLocal = 0, |
| 328 | LLVMGeneralDynamicTLSModel, |
| 329 | LLVMLocalDynamicTLSModel, |
| 330 | LLVMInitialExecTLSModel, |
| 331 | LLVMLocalExecTLSModel |
| 332 | } LLVMThreadLocalMode; |
| 333 | |
| 334 | typedef enum { |
| 335 | LLVMAtomicOrderingNotAtomic = 0, /**< A load or store which is not atomic */ |
| 336 | LLVMAtomicOrderingUnordered = 1, /**< Lowest level of atomicity, guarantees |
| 337 | somewhat sane results, lock free. */ |
| 338 | LLVMAtomicOrderingMonotonic = 2, /**< guarantees that if you take all the |
| 339 | operations affecting a specific address, |
| 340 | a consistent ordering exists */ |
| 341 | LLVMAtomicOrderingAcquire = 4, /**< Acquire provides a barrier of the sort |
| 342 | necessary to acquire a lock to access other |
| 343 | memory with normal loads and stores. */ |
| 344 | LLVMAtomicOrderingRelease = 5, /**< Release is similar to Acquire, but with |
| 345 | a barrier of the sort necessary to release |
| 346 | a lock. */ |
| 347 | LLVMAtomicOrderingAcquireRelease = 6, /**< provides both an Acquire and a |
| 348 | Release barrier (for fences and |
| 349 | operations which both read and write |
| 350 | memory). */ |
| 351 | LLVMAtomicOrderingSequentiallyConsistent = 7 /**< provides Acquire semantics |
| 352 | for loads and Release |
| 353 | semantics for stores. |
| 354 | Additionally, it guarantees |
| 355 | that a total ordering exists |
| 356 | between all |
| 357 | SequentiallyConsistent |
| 358 | operations. */ |
| 359 | } LLVMAtomicOrdering; |
| 360 | |
| 361 | typedef enum { |
| 362 | LLVMAtomicRMWBinOpXchg, /**< Set the new value and return the one old */ |
| 363 | LLVMAtomicRMWBinOpAdd, /**< Add a value and return the old one */ |
| 364 | LLVMAtomicRMWBinOpSub, /**< Subtract a value and return the old one */ |
| 365 | LLVMAtomicRMWBinOpAnd, /**< And a value and return the old one */ |
| 366 | LLVMAtomicRMWBinOpNand, /**< Not-And a value and return the old one */ |
| 367 | LLVMAtomicRMWBinOpOr, /**< OR a value and return the old one */ |
| 368 | LLVMAtomicRMWBinOpXor, /**< Xor a value and return the old one */ |
| 369 | LLVMAtomicRMWBinOpMax, /**< Sets the value if it's greater than the |
| 370 | original using a signed comparison and return |
| 371 | the old one */ |
| 372 | LLVMAtomicRMWBinOpMin, /**< Sets the value if it's Smaller than the |
| 373 | original using a signed comparison and return |
| 374 | the old one */ |
| 375 | LLVMAtomicRMWBinOpUMax, /**< Sets the value if it's greater than the |
| 376 | original using an unsigned comparison and return |
| 377 | the old one */ |
| 378 | LLVMAtomicRMWBinOpUMin, /**< Sets the value if it's greater than the |
| 379 | original using an unsigned comparison and return |
| 380 | the old one */ |
| 381 | LLVMAtomicRMWBinOpFAdd, /**< Add a floating point value and return the |
| 382 | old one */ |
| 383 | LLVMAtomicRMWBinOpFSub, /**< Subtract a floating point value and return the |
| 384 | old one */ |
| 385 | LLVMAtomicRMWBinOpFMax, /**< Sets the value if it's greater than the |
| 386 | original using an floating point comparison and |
| 387 | return the old one */ |
| 388 | LLVMAtomicRMWBinOpFMin, /**< Sets the value if it's smaller than the |
| 389 | original using an floating point comparison and |
| 390 | return the old one */ |
| 391 | LLVMAtomicRMWBinOpUIncWrap, /**< Increments the value, wrapping back to zero |
| 392 | when incremented above input value */ |
| 393 | LLVMAtomicRMWBinOpUDecWrap, /**< Decrements the value, wrapping back to |
| 394 | the input value when decremented below zero */ |
| 395 | LLVMAtomicRMWBinOpUSubCond, /**<Subtracts the value only if no unsigned |
| 396 | overflow */ |
| 397 | LLVMAtomicRMWBinOpUSubSat, /**<Subtracts the value, clamping to zero */ |
| 398 | LLVMAtomicRMWBinOpFMaximum, /**< Sets the value if it's greater than the |
| 399 | original using an floating point comparison and |
| 400 | return the old one */ |
| 401 | LLVMAtomicRMWBinOpFMinimum, /**< Sets the value if it's smaller than the |
| 402 | original using an floating point comparison and |
| 403 | return the old one */ |
| 404 | } LLVMAtomicRMWBinOp; |
| 405 | |
| 406 | typedef enum { |
| 407 | LLVMDSError, |
| 408 | LLVMDSWarning, |
| 409 | , |
| 410 | LLVMDSNote |
| 411 | } LLVMDiagnosticSeverity; |
| 412 | |
| 413 | typedef enum { |
| 414 | LLVMInlineAsmDialectATT, |
| 415 | LLVMInlineAsmDialectIntel |
| 416 | } LLVMInlineAsmDialect; |
| 417 | |
| 418 | typedef enum { |
| 419 | /** |
| 420 | * Emits an error if two values disagree, otherwise the resulting value is |
| 421 | * that of the operands. |
| 422 | * |
| 423 | * @see Module::ModFlagBehavior::Error |
| 424 | */ |
| 425 | LLVMModuleFlagBehaviorError, |
| 426 | /** |
| 427 | * Emits a warning if two values disagree. The result value will be the |
| 428 | * operand for the flag from the first module being linked. |
| 429 | * |
| 430 | * @see Module::ModFlagBehavior::Warning |
| 431 | */ |
| 432 | LLVMModuleFlagBehaviorWarning, |
| 433 | /** |
| 434 | * Adds a requirement that another module flag be present and have a |
| 435 | * specified value after linking is performed. The value must be a metadata |
| 436 | * pair, where the first element of the pair is the ID of the module flag |
| 437 | * to be restricted, and the second element of the pair is the value the |
| 438 | * module flag should be restricted to. This behavior can be used to |
| 439 | * restrict the allowable results (via triggering of an error) of linking |
| 440 | * IDs with the **Override** behavior. |
| 441 | * |
| 442 | * @see Module::ModFlagBehavior::Require |
| 443 | */ |
| 444 | LLVMModuleFlagBehaviorRequire, |
| 445 | /** |
| 446 | * Uses the specified value, regardless of the behavior or value of the |
| 447 | * other module. If both modules specify **Override**, but the values |
| 448 | * differ, an error will be emitted. |
| 449 | * |
| 450 | * @see Module::ModFlagBehavior::Override |
| 451 | */ |
| 452 | LLVMModuleFlagBehaviorOverride, |
| 453 | /** |
| 454 | * Appends the two values, which are required to be metadata nodes. |
| 455 | * |
| 456 | * @see Module::ModFlagBehavior::Append |
| 457 | */ |
| 458 | LLVMModuleFlagBehaviorAppend, |
| 459 | /** |
| 460 | * Appends the two values, which are required to be metadata |
| 461 | * nodes. However, duplicate entries in the second list are dropped |
| 462 | * during the append operation. |
| 463 | * |
| 464 | * @see Module::ModFlagBehavior::AppendUnique |
| 465 | */ |
| 466 | LLVMModuleFlagBehaviorAppendUnique, |
| 467 | } LLVMModuleFlagBehavior; |
| 468 | |
| 469 | /** |
| 470 | * Attribute index are either LLVMAttributeReturnIndex, |
| 471 | * LLVMAttributeFunctionIndex or a parameter number from 1 to N. |
| 472 | */ |
| 473 | enum { |
| 474 | LLVMAttributeReturnIndex = 0U, |
| 475 | // ISO C restricts enumerator values to range of 'int' |
| 476 | // (4294967295 is too large) |
| 477 | // LLVMAttributeFunctionIndex = ~0U, |
| 478 | LLVMAttributeFunctionIndex = -1, |
| 479 | }; |
| 480 | |
| 481 | typedef unsigned LLVMAttributeIndex; |
| 482 | |
| 483 | /** |
| 484 | * Tail call kind for LLVMSetTailCallKind and LLVMGetTailCallKind. |
| 485 | * |
| 486 | * Note that 'musttail' implies 'tail'. |
| 487 | * |
| 488 | * @see CallInst::TailCallKind |
| 489 | */ |
| 490 | typedef enum { |
| 491 | LLVMTailCallKindNone = 0, |
| 492 | LLVMTailCallKindTail = 1, |
| 493 | LLVMTailCallKindMustTail = 2, |
| 494 | LLVMTailCallKindNoTail = 3, |
| 495 | } LLVMTailCallKind; |
| 496 | |
| 497 | enum { |
| 498 | LLVMFastMathAllowReassoc = (1 << 0), |
| 499 | LLVMFastMathNoNaNs = (1 << 1), |
| 500 | LLVMFastMathNoInfs = (1 << 2), |
| 501 | LLVMFastMathNoSignedZeros = (1 << 3), |
| 502 | LLVMFastMathAllowReciprocal = (1 << 4), |
| 503 | LLVMFastMathAllowContract = (1 << 5), |
| 504 | LLVMFastMathApproxFunc = (1 << 6), |
| 505 | LLVMFastMathNone = 0, |
| 506 | LLVMFastMathAll = LLVMFastMathAllowReassoc | LLVMFastMathNoNaNs | |
| 507 | LLVMFastMathNoInfs | LLVMFastMathNoSignedZeros | |
| 508 | LLVMFastMathAllowReciprocal | LLVMFastMathAllowContract | |
| 509 | LLVMFastMathApproxFunc, |
| 510 | }; |
| 511 | |
| 512 | /** |
| 513 | * Flags to indicate what fast-math-style optimizations are allowed |
| 514 | * on operations. |
| 515 | * |
| 516 | * See https://llvm.org/docs/LangRef.html#fast-math-flags |
| 517 | */ |
| 518 | typedef unsigned LLVMFastMathFlags; |
| 519 | |
| 520 | enum { |
| 521 | LLVMGEPFlagInBounds = (1 << 0), |
| 522 | LLVMGEPFlagNUSW = (1 << 1), |
| 523 | LLVMGEPFlagNUW = (1 << 2), |
| 524 | }; |
| 525 | |
| 526 | /** |
| 527 | * Flags that constrain the allowed wrap semantics of a getelementptr |
| 528 | * instruction. |
| 529 | * |
| 530 | * See https://llvm.org/docs/LangRef.html#getelementptr-instruction |
| 531 | */ |
| 532 | typedef unsigned LLVMGEPNoWrapFlags; |
| 533 | |
| 534 | typedef enum { |
| 535 | LLVMDbgRecordLabel, |
| 536 | LLVMDbgRecordDeclare, |
| 537 | LLVMDbgRecordValue, |
| 538 | LLVMDbgRecordAssign, |
| 539 | } LLVMDbgRecordKind; |
| 540 | |
| 541 | /** |
| 542 | * @} |
| 543 | */ |
| 544 | |
| 545 | /** Deallocate and destroy all ManagedStatic variables. |
| 546 | @see llvm::llvm_shutdown |
| 547 | @see ManagedStatic */ |
| 548 | LLVM_C_ABI void LLVMShutdown(void); |
| 549 | |
| 550 | /*===-- Version query -----------------------------------------------------===*/ |
| 551 | |
| 552 | /** |
| 553 | * Return the major, minor, and patch version of LLVM |
| 554 | * |
| 555 | * The version components are returned via the function's three output |
| 556 | * parameters or skipped if a NULL pointer was supplied. |
| 557 | */ |
| 558 | LLVM_C_ABI void LLVMGetVersion(unsigned *Major, unsigned *Minor, |
| 559 | unsigned *Patch); |
| 560 | |
| 561 | /*===-- Error handling ----------------------------------------------------===*/ |
| 562 | |
| 563 | LLVM_C_ABI char *LLVMCreateMessage(const char *Message); |
| 564 | LLVM_C_ABI void LLVMDisposeMessage(char *Message); |
| 565 | |
| 566 | /** |
| 567 | * @defgroup LLVMCCoreContext Contexts |
| 568 | * |
| 569 | * Contexts are execution states for the core LLVM IR system. |
| 570 | * |
| 571 | * Most types are tied to a context instance. Multiple contexts can |
| 572 | * exist simultaneously. A single context is not thread safe. However, |
| 573 | * different contexts can execute on different threads simultaneously. |
| 574 | * |
| 575 | * @{ |
| 576 | */ |
| 577 | |
| 578 | typedef void (*LLVMDiagnosticHandler)(LLVMDiagnosticInfoRef, void *); |
| 579 | typedef void (*LLVMYieldCallback)(LLVMContextRef, void *); |
| 580 | |
| 581 | /** |
| 582 | * Create a new context. |
| 583 | * |
| 584 | * Every call to this function should be paired with a call to |
| 585 | * LLVMContextDispose() or the context will leak memory. |
| 586 | */ |
| 587 | LLVM_C_ABI LLVMContextRef LLVMContextCreate(void); |
| 588 | |
| 589 | /** |
| 590 | * Obtain the global context instance. |
| 591 | */ |
| 592 | LLVM_C_ABI |
| 593 | LLVM_ATTRIBUTE_C_DEPRECATED(LLVMContextRef LLVMGetGlobalContext(void), |
| 594 | "Use of the global context is deprecated, create " |
| 595 | "one using LLVMContextCreate instead" ); |
| 596 | |
| 597 | /** |
| 598 | * Set the diagnostic handler for this context. |
| 599 | */ |
| 600 | LLVM_C_ABI void LLVMContextSetDiagnosticHandler(LLVMContextRef C, |
| 601 | LLVMDiagnosticHandler Handler, |
| 602 | void *DiagnosticContext); |
| 603 | |
| 604 | /** |
| 605 | * Get the diagnostic handler of this context. |
| 606 | */ |
| 607 | LLVM_C_ABI LLVMDiagnosticHandler |
| 608 | LLVMContextGetDiagnosticHandler(LLVMContextRef C); |
| 609 | |
| 610 | /** |
| 611 | * Get the diagnostic context of this context. |
| 612 | */ |
| 613 | LLVM_C_ABI void *LLVMContextGetDiagnosticContext(LLVMContextRef C); |
| 614 | |
| 615 | /** |
| 616 | * Set the yield callback function for this context. |
| 617 | * |
| 618 | * @see LLVMContext::setYieldCallback() |
| 619 | */ |
| 620 | LLVM_C_ABI void LLVMContextSetYieldCallback(LLVMContextRef C, |
| 621 | LLVMYieldCallback Callback, |
| 622 | void *OpaqueHandle); |
| 623 | |
| 624 | /** |
| 625 | * Retrieve whether the given context is set to discard all value names. |
| 626 | * |
| 627 | * @see LLVMContext::shouldDiscardValueNames() |
| 628 | */ |
| 629 | LLVM_C_ABI LLVMBool LLVMContextShouldDiscardValueNames(LLVMContextRef C); |
| 630 | |
| 631 | /** |
| 632 | * Set whether the given context discards all value names. |
| 633 | * |
| 634 | * If true, only the names of GlobalValue objects will be available in the IR. |
| 635 | * This can be used to save memory and runtime, especially in release mode. |
| 636 | * |
| 637 | * @see LLVMContext::setDiscardValueNames() |
| 638 | */ |
| 639 | LLVM_C_ABI void LLVMContextSetDiscardValueNames(LLVMContextRef C, |
| 640 | LLVMBool Discard); |
| 641 | |
| 642 | /** |
| 643 | * Destroy a context instance. |
| 644 | * |
| 645 | * This should be called for every call to LLVMContextCreate() or memory |
| 646 | * will be leaked. |
| 647 | */ |
| 648 | LLVM_C_ABI void LLVMContextDispose(LLVMContextRef C); |
| 649 | |
| 650 | /** |
| 651 | * Return a string representation of the DiagnosticInfo. Use |
| 652 | * LLVMDisposeMessage to free the string. |
| 653 | * |
| 654 | * @see DiagnosticInfo::print() |
| 655 | */ |
| 656 | LLVM_C_ABI char *LLVMGetDiagInfoDescription(LLVMDiagnosticInfoRef DI); |
| 657 | |
| 658 | /** |
| 659 | * Return an enum LLVMDiagnosticSeverity. |
| 660 | * |
| 661 | * @see DiagnosticInfo::getSeverity() |
| 662 | */ |
| 663 | LLVM_C_ABI LLVMDiagnosticSeverity |
| 664 | LLVMGetDiagInfoSeverity(LLVMDiagnosticInfoRef DI); |
| 665 | |
| 666 | LLVM_C_ABI unsigned LLVMGetMDKindIDInContext(LLVMContextRef C, const char *Name, |
| 667 | unsigned SLen); |
| 668 | LLVM_C_ABI LLVM_ATTRIBUTE_C_DEPRECATED( |
| 669 | unsigned LLVMGetMDKindID(const char *Name, unsigned SLen), |
| 670 | "Use of the global context is deprecated, use LLVMGetMDKindIDInContext " |
| 671 | "instead" ); |
| 672 | |
| 673 | /** |
| 674 | * Maps a synchronization scope name to a ID unique within this context. |
| 675 | */ |
| 676 | LLVM_C_ABI unsigned LLVMGetSyncScopeID(LLVMContextRef C, const char *Name, |
| 677 | size_t SLen); |
| 678 | |
| 679 | /** |
| 680 | * Return an unique id given the name of a enum attribute, |
| 681 | * or 0 if no attribute by that name exists. |
| 682 | * |
| 683 | * See http://llvm.org/docs/LangRef.html#parameter-attributes |
| 684 | * and http://llvm.org/docs/LangRef.html#function-attributes |
| 685 | * for the list of available attributes. |
| 686 | * |
| 687 | * NB: Attribute names and/or id are subject to change without |
| 688 | * going through the C API deprecation cycle. |
| 689 | */ |
| 690 | LLVM_C_ABI unsigned LLVMGetEnumAttributeKindForName(const char *Name, |
| 691 | size_t SLen); |
| 692 | LLVM_C_ABI unsigned LLVMGetLastEnumAttributeKind(void); |
| 693 | |
| 694 | /** |
| 695 | * Create an enum attribute. |
| 696 | */ |
| 697 | LLVM_C_ABI LLVMAttributeRef LLVMCreateEnumAttribute(LLVMContextRef C, |
| 698 | unsigned KindID, |
| 699 | uint64_t Val); |
| 700 | |
| 701 | /** |
| 702 | * Get the unique id corresponding to the enum attribute |
| 703 | * passed as argument. |
| 704 | */ |
| 705 | LLVM_C_ABI unsigned LLVMGetEnumAttributeKind(LLVMAttributeRef A); |
| 706 | |
| 707 | /** |
| 708 | * Get the enum attribute's value. 0 is returned if none exists. |
| 709 | */ |
| 710 | LLVM_C_ABI uint64_t LLVMGetEnumAttributeValue(LLVMAttributeRef A); |
| 711 | |
| 712 | /** |
| 713 | * Create a type attribute |
| 714 | */ |
| 715 | LLVM_C_ABI LLVMAttributeRef LLVMCreateTypeAttribute(LLVMContextRef C, |
| 716 | unsigned KindID, |
| 717 | LLVMTypeRef type_ref); |
| 718 | |
| 719 | /** |
| 720 | * Get the type attribute's value. |
| 721 | */ |
| 722 | LLVM_C_ABI LLVMTypeRef LLVMGetTypeAttributeValue(LLVMAttributeRef A); |
| 723 | |
| 724 | /** |
| 725 | * Create a ConstantRange attribute. |
| 726 | * |
| 727 | * LowerWords and UpperWords need to be NumBits divided by 64 rounded up |
| 728 | * elements long. |
| 729 | */ |
| 730 | LLVM_C_ABI LLVMAttributeRef LLVMCreateConstantRangeAttribute( |
| 731 | LLVMContextRef C, unsigned KindID, unsigned NumBits, |
| 732 | const uint64_t LowerWords[], const uint64_t UpperWords[]); |
| 733 | |
| 734 | /** |
| 735 | * Create a string attribute. |
| 736 | */ |
| 737 | LLVM_C_ABI LLVMAttributeRef LLVMCreateStringAttribute(LLVMContextRef C, |
| 738 | const char *K, |
| 739 | unsigned KLength, |
| 740 | const char *V, |
| 741 | unsigned VLength); |
| 742 | |
| 743 | /** |
| 744 | * Get the string attribute's kind. |
| 745 | */ |
| 746 | LLVM_C_ABI const char *LLVMGetStringAttributeKind(LLVMAttributeRef A, |
| 747 | unsigned *Length); |
| 748 | |
| 749 | /** |
| 750 | * Get the string attribute's value. |
| 751 | */ |
| 752 | LLVM_C_ABI const char *LLVMGetStringAttributeValue(LLVMAttributeRef A, |
| 753 | unsigned *Length); |
| 754 | |
| 755 | /** |
| 756 | * Check for the different types of attributes. |
| 757 | */ |
| 758 | LLVM_C_ABI LLVMBool LLVMIsEnumAttribute(LLVMAttributeRef A); |
| 759 | LLVM_C_ABI LLVMBool LLVMIsStringAttribute(LLVMAttributeRef A); |
| 760 | LLVM_C_ABI LLVMBool LLVMIsTypeAttribute(LLVMAttributeRef A); |
| 761 | |
| 762 | /** |
| 763 | * Obtain a Type from a context by its registered name. |
| 764 | */ |
| 765 | LLVM_C_ABI LLVMTypeRef LLVMGetTypeByName2(LLVMContextRef C, const char *Name); |
| 766 | |
| 767 | /** |
| 768 | * @} |
| 769 | */ |
| 770 | |
| 771 | /** |
| 772 | * @defgroup LLVMCCoreModule Modules |
| 773 | * |
| 774 | * Modules represent the top-level structure in an LLVM program. An LLVM |
| 775 | * module is effectively a translation unit or a collection of |
| 776 | * translation units merged together. |
| 777 | * |
| 778 | * @{ |
| 779 | */ |
| 780 | |
| 781 | /** |
| 782 | * Create a new, empty module in the global context. |
| 783 | * |
| 784 | * This is equivalent to calling LLVMModuleCreateWithNameInContext with |
| 785 | * LLVMGetGlobalContext() as the context parameter. |
| 786 | * |
| 787 | * Every invocation should be paired with LLVMDisposeModule() or memory |
| 788 | * will be leaked. |
| 789 | */ |
| 790 | LLVM_C_ABI LLVM_ATTRIBUTE_C_DEPRECATED( |
| 791 | LLVMModuleRef LLVMModuleCreateWithName(const char *ModuleID), |
| 792 | "Use of the global context is deprecated, use " |
| 793 | "LLVMModuleCreateWithNameInContext instead" ); |
| 794 | |
| 795 | /** |
| 796 | * Create a new, empty module in a specific context. |
| 797 | * |
| 798 | * Every invocation should be paired with LLVMDisposeModule() or memory |
| 799 | * will be leaked. |
| 800 | */ |
| 801 | LLVM_C_ABI LLVMModuleRef LLVMModuleCreateWithNameInContext(const char *ModuleID, |
| 802 | LLVMContextRef C); |
| 803 | /** |
| 804 | * Return an exact copy of the specified module. |
| 805 | */ |
| 806 | LLVM_C_ABI LLVMModuleRef LLVMCloneModule(LLVMModuleRef M); |
| 807 | |
| 808 | /** |
| 809 | * Destroy a module instance. |
| 810 | * |
| 811 | * This must be called for every created module or memory will be |
| 812 | * leaked. |
| 813 | */ |
| 814 | LLVM_C_ABI void LLVMDisposeModule(LLVMModuleRef M); |
| 815 | |
| 816 | /** |
| 817 | * Soon to be deprecated. |
| 818 | * See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes |
| 819 | * |
| 820 | * Returns true if the module is in the new debug info mode which uses |
| 821 | * non-instruction debug records instead of debug intrinsics for variable |
| 822 | * location tracking. |
| 823 | */ |
| 824 | LLVM_C_ABI LLVMBool LLVMIsNewDbgInfoFormat(LLVMModuleRef M); |
| 825 | |
| 826 | /** |
| 827 | * Soon to be deprecated. |
| 828 | * See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes |
| 829 | * |
| 830 | * Convert module into desired debug info format. |
| 831 | */ |
| 832 | LLVM_C_ABI void LLVMSetIsNewDbgInfoFormat(LLVMModuleRef M, |
| 833 | LLVMBool UseNewFormat); |
| 834 | |
| 835 | /** |
| 836 | * Obtain the identifier of a module. |
| 837 | * |
| 838 | * @param M Module to obtain identifier of |
| 839 | * @param Len Out parameter which holds the length of the returned string. |
| 840 | * @return The identifier of M. |
| 841 | * @see Module::getModuleIdentifier() |
| 842 | */ |
| 843 | LLVM_C_ABI const char *LLVMGetModuleIdentifier(LLVMModuleRef M, size_t *Len); |
| 844 | |
| 845 | /** |
| 846 | * Set the identifier of a module to a string Ident with length Len. |
| 847 | * |
| 848 | * @param M The module to set identifier |
| 849 | * @param Ident The string to set M's identifier to |
| 850 | * @param Len Length of Ident |
| 851 | * @see Module::setModuleIdentifier() |
| 852 | */ |
| 853 | LLVM_C_ABI void LLVMSetModuleIdentifier(LLVMModuleRef M, const char *Ident, |
| 854 | size_t Len); |
| 855 | |
| 856 | /** |
| 857 | * Obtain the module's original source file name. |
| 858 | * |
| 859 | * @param M Module to obtain the name of |
| 860 | * @param Len Out parameter which holds the length of the returned string |
| 861 | * @return The original source file name of M |
| 862 | * @see Module::getSourceFileName() |
| 863 | */ |
| 864 | LLVM_C_ABI const char *LLVMGetSourceFileName(LLVMModuleRef M, size_t *Len); |
| 865 | |
| 866 | /** |
| 867 | * Set the original source file name of a module to a string Name with length |
| 868 | * Len. |
| 869 | * |
| 870 | * @param M The module to set the source file name of |
| 871 | * @param Name The string to set M's source file name to |
| 872 | * @param Len Length of Name |
| 873 | * @see Module::setSourceFileName() |
| 874 | */ |
| 875 | LLVM_C_ABI void LLVMSetSourceFileName(LLVMModuleRef M, const char *Name, |
| 876 | size_t Len); |
| 877 | |
| 878 | /** |
| 879 | * Obtain the data layout for a module. |
| 880 | * |
| 881 | * @see Module::getDataLayoutStr() |
| 882 | * |
| 883 | * LLVMGetDataLayout is DEPRECATED, as the name is not only incorrect, |
| 884 | * but match the name of another method on the module. Prefer the use |
| 885 | * of LLVMGetDataLayoutStr, which is not ambiguous. |
| 886 | */ |
| 887 | LLVM_C_ABI const char *LLVMGetDataLayoutStr(LLVMModuleRef M); |
| 888 | LLVM_C_ABI const char *LLVMGetDataLayout(LLVMModuleRef M); |
| 889 | |
| 890 | /** |
| 891 | * Set the data layout for a module. |
| 892 | * |
| 893 | * @see Module::setDataLayout() |
| 894 | */ |
| 895 | LLVM_C_ABI void LLVMSetDataLayout(LLVMModuleRef M, const char *DataLayoutStr); |
| 896 | |
| 897 | /** |
| 898 | * Obtain the target triple for a module. |
| 899 | * |
| 900 | * @see Module::getTargetTriple() |
| 901 | */ |
| 902 | LLVM_C_ABI const char *LLVMGetTarget(LLVMModuleRef M); |
| 903 | |
| 904 | /** |
| 905 | * Set the target triple for a module. |
| 906 | * |
| 907 | * @see Module::setTargetTriple() |
| 908 | */ |
| 909 | LLVM_C_ABI void LLVMSetTarget(LLVMModuleRef M, const char *Triple); |
| 910 | |
| 911 | /** |
| 912 | * Returns the module flags as an array of flag-key-value triples. The caller |
| 913 | * is responsible for freeing this array by calling |
| 914 | * \c LLVMDisposeModuleFlagsMetadata. |
| 915 | * |
| 916 | * @see Module::getModuleFlagsMetadata() |
| 917 | */ |
| 918 | LLVM_C_ABI LLVMModuleFlagEntry *LLVMCopyModuleFlagsMetadata(LLVMModuleRef M, |
| 919 | size_t *Len); |
| 920 | |
| 921 | /** |
| 922 | * Destroys module flags metadata entries. |
| 923 | */ |
| 924 | LLVM_C_ABI void LLVMDisposeModuleFlagsMetadata(LLVMModuleFlagEntry *Entries); |
| 925 | |
| 926 | /** |
| 927 | * Returns the flag behavior for a module flag entry at a specific index. |
| 928 | * |
| 929 | * @see Module::ModuleFlagEntry::Behavior |
| 930 | */ |
| 931 | LLVM_C_ABI LLVMModuleFlagBehavior LLVMModuleFlagEntriesGetFlagBehavior( |
| 932 | LLVMModuleFlagEntry *Entries, unsigned Index); |
| 933 | |
| 934 | /** |
| 935 | * Returns the key for a module flag entry at a specific index. |
| 936 | * |
| 937 | * @see Module::ModuleFlagEntry::Key |
| 938 | */ |
| 939 | LLVM_C_ABI const char *LLVMModuleFlagEntriesGetKey(LLVMModuleFlagEntry *Entries, |
| 940 | unsigned Index, size_t *Len); |
| 941 | |
| 942 | /** |
| 943 | * Returns the metadata for a module flag entry at a specific index. |
| 944 | * |
| 945 | * @see Module::ModuleFlagEntry::Val |
| 946 | */ |
| 947 | LLVM_C_ABI LLVMMetadataRef |
| 948 | LLVMModuleFlagEntriesGetMetadata(LLVMModuleFlagEntry *Entries, unsigned Index); |
| 949 | |
| 950 | /** |
| 951 | * Add a module-level flag to the module-level flags metadata if it doesn't |
| 952 | * already exist. |
| 953 | * |
| 954 | * @see Module::getModuleFlag() |
| 955 | */ |
| 956 | LLVM_C_ABI LLVMMetadataRef LLVMGetModuleFlag(LLVMModuleRef M, const char *Key, |
| 957 | size_t KeyLen); |
| 958 | |
| 959 | /** |
| 960 | * Add a module-level flag to the module-level flags metadata if it doesn't |
| 961 | * already exist. |
| 962 | * |
| 963 | * @see Module::addModuleFlag() |
| 964 | */ |
| 965 | LLVM_C_ABI void LLVMAddModuleFlag(LLVMModuleRef M, |
| 966 | LLVMModuleFlagBehavior Behavior, |
| 967 | const char *Key, size_t KeyLen, |
| 968 | LLVMMetadataRef Val); |
| 969 | |
| 970 | /** |
| 971 | * Dump a representation of a module to stderr. |
| 972 | * |
| 973 | * @see Module::dump() |
| 974 | */ |
| 975 | LLVM_C_ABI void LLVMDumpModule(LLVMModuleRef M); |
| 976 | |
| 977 | /** |
| 978 | * Print a representation of a module to a file. The ErrorMessage needs to be |
| 979 | * disposed with LLVMDisposeMessage. Returns 0 on success, 1 otherwise. |
| 980 | * |
| 981 | * @see Module::print() |
| 982 | */ |
| 983 | LLVM_C_ABI LLVMBool LLVMPrintModuleToFile(LLVMModuleRef M, const char *Filename, |
| 984 | char **ErrorMessage); |
| 985 | |
| 986 | /** |
| 987 | * Return a string representation of the module. Use |
| 988 | * LLVMDisposeMessage to free the string. |
| 989 | * |
| 990 | * @see Module::print() |
| 991 | */ |
| 992 | LLVM_C_ABI char *LLVMPrintModuleToString(LLVMModuleRef M); |
| 993 | |
| 994 | /** |
| 995 | * Get inline assembly for a module. |
| 996 | * |
| 997 | * @see Module::getModuleInlineAsm() |
| 998 | */ |
| 999 | LLVM_C_ABI const char *LLVMGetModuleInlineAsm(LLVMModuleRef M, size_t *Len); |
| 1000 | |
| 1001 | /** |
| 1002 | * Set inline assembly for a module. |
| 1003 | * |
| 1004 | * @see Module::setModuleInlineAsm() |
| 1005 | */ |
| 1006 | LLVM_C_ABI void LLVMSetModuleInlineAsm2(LLVMModuleRef M, const char *Asm, |
| 1007 | size_t Len); |
| 1008 | |
| 1009 | /** |
| 1010 | * Append inline assembly to a module. |
| 1011 | * |
| 1012 | * @see Module::appendModuleInlineAsm() |
| 1013 | */ |
| 1014 | LLVM_C_ABI void LLVMAppendModuleInlineAsm(LLVMModuleRef M, const char *Asm, |
| 1015 | size_t Len); |
| 1016 | |
| 1017 | /** |
| 1018 | * Create the specified uniqued inline asm string. |
| 1019 | * |
| 1020 | * @see InlineAsm::get() |
| 1021 | */ |
| 1022 | LLVM_C_ABI LLVMValueRef LLVMGetInlineAsm( |
| 1023 | LLVMTypeRef Ty, const char *AsmString, size_t AsmStringSize, |
| 1024 | const char *Constraints, size_t ConstraintsSize, LLVMBool HasSideEffects, |
| 1025 | LLVMBool IsAlignStack, LLVMInlineAsmDialect Dialect, LLVMBool CanThrow); |
| 1026 | |
| 1027 | /** |
| 1028 | * Get the template string used for an inline assembly snippet |
| 1029 | * |
| 1030 | */ |
| 1031 | LLVM_C_ABI const char *LLVMGetInlineAsmAsmString(LLVMValueRef InlineAsmVal, |
| 1032 | size_t *Len); |
| 1033 | |
| 1034 | /** |
| 1035 | * Get the raw constraint string for an inline assembly snippet |
| 1036 | * |
| 1037 | */ |
| 1038 | LLVM_C_ABI const char * |
| 1039 | LLVMGetInlineAsmConstraintString(LLVMValueRef InlineAsmVal, size_t *Len); |
| 1040 | |
| 1041 | /** |
| 1042 | * Get the dialect used by the inline asm snippet |
| 1043 | * |
| 1044 | */ |
| 1045 | LLVM_C_ABI LLVMInlineAsmDialect |
| 1046 | LLVMGetInlineAsmDialect(LLVMValueRef InlineAsmVal); |
| 1047 | |
| 1048 | /** |
| 1049 | * Get the function type of the inline assembly snippet. The same type that |
| 1050 | * was passed into LLVMGetInlineAsm originally |
| 1051 | * |
| 1052 | * @see LLVMGetInlineAsm |
| 1053 | * |
| 1054 | */ |
| 1055 | LLVM_C_ABI LLVMTypeRef LLVMGetInlineAsmFunctionType(LLVMValueRef InlineAsmVal); |
| 1056 | |
| 1057 | /** |
| 1058 | * Get if the inline asm snippet has side effects |
| 1059 | * |
| 1060 | */ |
| 1061 | LLVM_C_ABI LLVMBool LLVMGetInlineAsmHasSideEffects(LLVMValueRef InlineAsmVal); |
| 1062 | |
| 1063 | /** |
| 1064 | * Get if the inline asm snippet needs an aligned stack |
| 1065 | * |
| 1066 | */ |
| 1067 | LLVM_C_ABI LLVMBool |
| 1068 | LLVMGetInlineAsmNeedsAlignedStack(LLVMValueRef InlineAsmVal); |
| 1069 | |
| 1070 | /** |
| 1071 | * Get if the inline asm snippet may unwind the stack |
| 1072 | * |
| 1073 | */ |
| 1074 | LLVM_C_ABI LLVMBool LLVMGetInlineAsmCanUnwind(LLVMValueRef InlineAsmVal); |
| 1075 | |
| 1076 | /** |
| 1077 | * Obtain the context to which this module is associated. |
| 1078 | * |
| 1079 | * @see Module::getContext() |
| 1080 | */ |
| 1081 | LLVM_C_ABI LLVMContextRef LLVMGetModuleContext(LLVMModuleRef M); |
| 1082 | |
| 1083 | /** Deprecated: Use LLVMGetTypeByName2 instead. */ |
| 1084 | LLVM_C_ABI LLVMTypeRef LLVMGetTypeByName(LLVMModuleRef M, const char *Name); |
| 1085 | |
| 1086 | /** |
| 1087 | * Obtain an iterator to the first NamedMDNode in a Module. |
| 1088 | * |
| 1089 | * @see llvm::Module::named_metadata_begin() |
| 1090 | */ |
| 1091 | LLVM_C_ABI LLVMNamedMDNodeRef LLVMGetFirstNamedMetadata(LLVMModuleRef M); |
| 1092 | |
| 1093 | /** |
| 1094 | * Obtain an iterator to the last NamedMDNode in a Module. |
| 1095 | * |
| 1096 | * @see llvm::Module::named_metadata_end() |
| 1097 | */ |
| 1098 | LLVM_C_ABI LLVMNamedMDNodeRef LLVMGetLastNamedMetadata(LLVMModuleRef M); |
| 1099 | |
| 1100 | /** |
| 1101 | * Advance a NamedMDNode iterator to the next NamedMDNode. |
| 1102 | * |
| 1103 | * Returns NULL if the iterator was already at the end and there are no more |
| 1104 | * named metadata nodes. |
| 1105 | */ |
| 1106 | LLVM_C_ABI LLVMNamedMDNodeRef |
| 1107 | LLVMGetNextNamedMetadata(LLVMNamedMDNodeRef NamedMDNode); |
| 1108 | |
| 1109 | /** |
| 1110 | * Decrement a NamedMDNode iterator to the previous NamedMDNode. |
| 1111 | * |
| 1112 | * Returns NULL if the iterator was already at the beginning and there are |
| 1113 | * no previous named metadata nodes. |
| 1114 | */ |
| 1115 | LLVM_C_ABI LLVMNamedMDNodeRef |
| 1116 | LLVMGetPreviousNamedMetadata(LLVMNamedMDNodeRef NamedMDNode); |
| 1117 | |
| 1118 | /** |
| 1119 | * Retrieve a NamedMDNode with the given name, returning NULL if no such |
| 1120 | * node exists. |
| 1121 | * |
| 1122 | * @see llvm::Module::getNamedMetadata() |
| 1123 | */ |
| 1124 | LLVM_C_ABI LLVMNamedMDNodeRef LLVMGetNamedMetadata(LLVMModuleRef M, |
| 1125 | const char *Name, |
| 1126 | size_t NameLen); |
| 1127 | |
| 1128 | /** |
| 1129 | * Retrieve a NamedMDNode with the given name, creating a new node if no such |
| 1130 | * node exists. |
| 1131 | * |
| 1132 | * @see llvm::Module::getOrInsertNamedMetadata() |
| 1133 | */ |
| 1134 | LLVM_C_ABI LLVMNamedMDNodeRef LLVMGetOrInsertNamedMetadata(LLVMModuleRef M, |
| 1135 | const char *Name, |
| 1136 | size_t NameLen); |
| 1137 | |
| 1138 | /** |
| 1139 | * Retrieve the name of a NamedMDNode. |
| 1140 | * |
| 1141 | * @see llvm::NamedMDNode::getName() |
| 1142 | */ |
| 1143 | LLVM_C_ABI const char *LLVMGetNamedMetadataName(LLVMNamedMDNodeRef NamedMD, |
| 1144 | size_t *NameLen); |
| 1145 | |
| 1146 | /** |
| 1147 | * Obtain the number of operands for named metadata in a module. |
| 1148 | * |
| 1149 | * @see llvm::Module::getNamedMetadata() |
| 1150 | */ |
| 1151 | LLVM_C_ABI unsigned LLVMGetNamedMetadataNumOperands(LLVMModuleRef M, |
| 1152 | const char *Name); |
| 1153 | |
| 1154 | /** |
| 1155 | * Obtain the named metadata operands for a module. |
| 1156 | * |
| 1157 | * The passed LLVMValueRef pointer should refer to an array of |
| 1158 | * LLVMValueRef at least LLVMGetNamedMetadataNumOperands long. This |
| 1159 | * array will be populated with the LLVMValueRef instances. Each |
| 1160 | * instance corresponds to a llvm::MDNode. |
| 1161 | * |
| 1162 | * @see llvm::Module::getNamedMetadata() |
| 1163 | * @see llvm::MDNode::getOperand() |
| 1164 | */ |
| 1165 | LLVM_C_ABI void LLVMGetNamedMetadataOperands(LLVMModuleRef M, const char *Name, |
| 1166 | LLVMValueRef *Dest); |
| 1167 | |
| 1168 | /** |
| 1169 | * Add an operand to named metadata. |
| 1170 | * |
| 1171 | * @see llvm::Module::getNamedMetadata() |
| 1172 | * @see llvm::MDNode::addOperand() |
| 1173 | */ |
| 1174 | LLVM_C_ABI void LLVMAddNamedMetadataOperand(LLVMModuleRef M, const char *Name, |
| 1175 | LLVMValueRef Val); |
| 1176 | |
| 1177 | /** |
| 1178 | * Return the directory of the debug location for this value, which must be |
| 1179 | * an llvm::Instruction, llvm::GlobalVariable, or llvm::Function. |
| 1180 | * |
| 1181 | * @see llvm::Instruction::getDebugLoc() |
| 1182 | * @see llvm::GlobalVariable::getDebugInfo() |
| 1183 | * @see llvm::Function::getSubprogram() |
| 1184 | */ |
| 1185 | LLVM_C_ABI const char *LLVMGetDebugLocDirectory(LLVMValueRef Val, |
| 1186 | unsigned *Length); |
| 1187 | |
| 1188 | /** |
| 1189 | * Return the filename of the debug location for this value, which must be |
| 1190 | * an llvm::Instruction, llvm::GlobalVariable, or llvm::Function. |
| 1191 | * |
| 1192 | * @see llvm::Instruction::getDebugLoc() |
| 1193 | * @see llvm::GlobalVariable::getDebugInfo() |
| 1194 | * @see llvm::Function::getSubprogram() |
| 1195 | */ |
| 1196 | LLVM_C_ABI const char *LLVMGetDebugLocFilename(LLVMValueRef Val, |
| 1197 | unsigned *Length); |
| 1198 | |
| 1199 | /** |
| 1200 | * Return the line number of the debug location for this value, which must be |
| 1201 | * an llvm::Instruction, llvm::GlobalVariable, or llvm::Function. |
| 1202 | * |
| 1203 | * @see llvm::Instruction::getDebugLoc() |
| 1204 | * @see llvm::GlobalVariable::getDebugInfo() |
| 1205 | * @see llvm::Function::getSubprogram() |
| 1206 | */ |
| 1207 | LLVM_C_ABI unsigned LLVMGetDebugLocLine(LLVMValueRef Val); |
| 1208 | |
| 1209 | /** |
| 1210 | * Return the column number of the debug location for this value, which must be |
| 1211 | * an llvm::Instruction. |
| 1212 | * |
| 1213 | * @see llvm::Instruction::getDebugLoc() |
| 1214 | */ |
| 1215 | LLVM_C_ABI unsigned LLVMGetDebugLocColumn(LLVMValueRef Val); |
| 1216 | |
| 1217 | /** |
| 1218 | * Add a function to a module under a specified name. |
| 1219 | * |
| 1220 | * @see llvm::Function::Create() |
| 1221 | */ |
| 1222 | LLVM_C_ABI LLVMValueRef LLVMAddFunction(LLVMModuleRef M, const char *Name, |
| 1223 | LLVMTypeRef FunctionTy); |
| 1224 | |
| 1225 | /** |
| 1226 | * Obtain or insert a function into a module. |
| 1227 | * |
| 1228 | * If a function with the specified name already exists in the module, it |
| 1229 | * is returned. Otherwise, a new function is created in the module with the |
| 1230 | * specified name and type and is returned. |
| 1231 | * |
| 1232 | * The returned value corresponds to a llvm::Function instance. |
| 1233 | * |
| 1234 | * @see llvm::Module::getOrInsertFunction() |
| 1235 | */ |
| 1236 | LLVM_C_ABI LLVMValueRef LLVMGetOrInsertFunction(LLVMModuleRef M, |
| 1237 | const char *Name, |
| 1238 | size_t NameLen, |
| 1239 | LLVMTypeRef FunctionTy); |
| 1240 | |
| 1241 | /** |
| 1242 | * Obtain a Function value from a Module by its name. |
| 1243 | * |
| 1244 | * The returned value corresponds to a llvm::Function value. |
| 1245 | * |
| 1246 | * @see llvm::Module::getFunction() |
| 1247 | */ |
| 1248 | LLVM_C_ABI LLVMValueRef LLVMGetNamedFunction(LLVMModuleRef M, const char *Name); |
| 1249 | |
| 1250 | /** |
| 1251 | * Obtain a Function value from a Module by its name. |
| 1252 | * |
| 1253 | * The returned value corresponds to a llvm::Function value. |
| 1254 | * |
| 1255 | * @see llvm::Module::getFunction() |
| 1256 | */ |
| 1257 | LLVM_C_ABI LLVMValueRef LLVMGetNamedFunctionWithLength(LLVMModuleRef M, |
| 1258 | const char *Name, |
| 1259 | size_t Length); |
| 1260 | |
| 1261 | /** |
| 1262 | * Obtain an iterator to the first Function in a Module. |
| 1263 | * |
| 1264 | * @see llvm::Module::begin() |
| 1265 | */ |
| 1266 | LLVM_C_ABI LLVMValueRef LLVMGetFirstFunction(LLVMModuleRef M); |
| 1267 | |
| 1268 | /** |
| 1269 | * Obtain an iterator to the last Function in a Module. |
| 1270 | * |
| 1271 | * @see llvm::Module::end() |
| 1272 | */ |
| 1273 | LLVM_C_ABI LLVMValueRef LLVMGetLastFunction(LLVMModuleRef M); |
| 1274 | |
| 1275 | /** |
| 1276 | * Advance a Function iterator to the next Function. |
| 1277 | * |
| 1278 | * Returns NULL if the iterator was already at the end and there are no more |
| 1279 | * functions. |
| 1280 | */ |
| 1281 | LLVM_C_ABI LLVMValueRef LLVMGetNextFunction(LLVMValueRef Fn); |
| 1282 | |
| 1283 | /** |
| 1284 | * Decrement a Function iterator to the previous Function. |
| 1285 | * |
| 1286 | * Returns NULL if the iterator was already at the beginning and there are |
| 1287 | * no previous functions. |
| 1288 | */ |
| 1289 | LLVM_C_ABI LLVMValueRef LLVMGetPreviousFunction(LLVMValueRef Fn); |
| 1290 | |
| 1291 | /** Deprecated: Use LLVMSetModuleInlineAsm2 instead. */ |
| 1292 | LLVM_C_ABI void LLVMSetModuleInlineAsm(LLVMModuleRef M, const char *Asm); |
| 1293 | |
| 1294 | /** |
| 1295 | * @} |
| 1296 | */ |
| 1297 | |
| 1298 | /** |
| 1299 | * @defgroup LLVMCCoreType Types |
| 1300 | * |
| 1301 | * Types represent the type of a value. |
| 1302 | * |
| 1303 | * Types are associated with a context instance. The context internally |
| 1304 | * deduplicates types so there is only 1 instance of a specific type |
| 1305 | * alive at a time. In other words, a unique type is shared among all |
| 1306 | * consumers within a context. |
| 1307 | * |
| 1308 | * A Type in the C API corresponds to llvm::Type. |
| 1309 | * |
| 1310 | * Types have the following hierarchy: |
| 1311 | * |
| 1312 | * types: |
| 1313 | * integer type |
| 1314 | * real type |
| 1315 | * function type |
| 1316 | * sequence types: |
| 1317 | * array type |
| 1318 | * pointer type |
| 1319 | * vector type |
| 1320 | * void type |
| 1321 | * label type |
| 1322 | * opaque type |
| 1323 | * |
| 1324 | * @{ |
| 1325 | */ |
| 1326 | |
| 1327 | /** |
| 1328 | * Obtain the enumerated type of a Type instance. |
| 1329 | * |
| 1330 | * @see llvm::Type:getTypeID() |
| 1331 | */ |
| 1332 | LLVM_C_ABI LLVMTypeKind LLVMGetTypeKind(LLVMTypeRef Ty); |
| 1333 | |
| 1334 | /** |
| 1335 | * Whether the type has a known size. |
| 1336 | * |
| 1337 | * Things that don't have a size are abstract types, labels, and void.a |
| 1338 | * |
| 1339 | * @see llvm::Type::isSized() |
| 1340 | */ |
| 1341 | LLVM_C_ABI LLVMBool LLVMTypeIsSized(LLVMTypeRef Ty); |
| 1342 | |
| 1343 | /** |
| 1344 | * Obtain the context to which this type instance is associated. |
| 1345 | * |
| 1346 | * @see llvm::Type::getContext() |
| 1347 | */ |
| 1348 | LLVM_C_ABI LLVMContextRef LLVMGetTypeContext(LLVMTypeRef Ty); |
| 1349 | |
| 1350 | /** |
| 1351 | * Dump a representation of a type to stderr. |
| 1352 | * |
| 1353 | * @see llvm::Type::dump() |
| 1354 | */ |
| 1355 | LLVM_C_ABI void LLVMDumpType(LLVMTypeRef Val); |
| 1356 | |
| 1357 | /** |
| 1358 | * Return a string representation of the type. Use |
| 1359 | * LLVMDisposeMessage to free the string. |
| 1360 | * |
| 1361 | * @see llvm::Type::print() |
| 1362 | */ |
| 1363 | LLVM_C_ABI char *LLVMPrintTypeToString(LLVMTypeRef Val); |
| 1364 | |
| 1365 | /** |
| 1366 | * @defgroup LLVMCCoreTypeInt Integer Types |
| 1367 | * |
| 1368 | * Functions in this section operate on integer types. |
| 1369 | * |
| 1370 | * @{ |
| 1371 | */ |
| 1372 | |
| 1373 | /** |
| 1374 | * Obtain an integer type from a context with specified bit width. |
| 1375 | */ |
| 1376 | LLVM_C_ABI LLVMTypeRef LLVMInt1TypeInContext(LLVMContextRef C); |
| 1377 | LLVM_C_ABI LLVMTypeRef LLVMInt8TypeInContext(LLVMContextRef C); |
| 1378 | LLVM_C_ABI LLVMTypeRef LLVMInt16TypeInContext(LLVMContextRef C); |
| 1379 | LLVM_C_ABI LLVMTypeRef LLVMInt32TypeInContext(LLVMContextRef C); |
| 1380 | LLVM_C_ABI LLVMTypeRef LLVMInt64TypeInContext(LLVMContextRef C); |
| 1381 | LLVM_C_ABI LLVMTypeRef LLVMInt128TypeInContext(LLVMContextRef C); |
| 1382 | LLVM_C_ABI LLVMTypeRef LLVMIntTypeInContext(LLVMContextRef C, unsigned NumBits); |
| 1383 | |
| 1384 | /** |
| 1385 | * Obtain an integer type from the global context with a specified bit |
| 1386 | * width. |
| 1387 | */ |
| 1388 | LLVM_C_ABI |
| 1389 | LLVM_ATTRIBUTE_C_DEPRECATED(LLVMTypeRef LLVMInt1Type(void), |
| 1390 | "Use of the global context is deprecated, use " |
| 1391 | "LLVMInt1TypeInContext instead" ); |
| 1392 | LLVM_C_ABI |
| 1393 | LLVM_ATTRIBUTE_C_DEPRECATED(LLVMTypeRef LLVMInt8Type(void), |
| 1394 | "Use of the global context is deprecated, use " |
| 1395 | "LLVMInt8TypeInContext instead" ); |
| 1396 | LLVM_C_ABI |
| 1397 | LLVM_ATTRIBUTE_C_DEPRECATED(LLVMTypeRef LLVMInt16Type(void), |
| 1398 | "Use of the global context is deprecated, use " |
| 1399 | "LLVMInt16TypeInContext instead" ); |
| 1400 | LLVM_C_ABI |
| 1401 | LLVM_ATTRIBUTE_C_DEPRECATED(LLVMTypeRef LLVMInt32Type(void), |
| 1402 | "Use of the global context is deprecated, use " |
| 1403 | "LLVMInt32TypeInContext instead" ); |
| 1404 | LLVM_C_ABI |
| 1405 | LLVM_ATTRIBUTE_C_DEPRECATED(LLVMTypeRef LLVMInt64Type(void), |
| 1406 | "Use of the global context is deprecated, use " |
| 1407 | "LLVMInt64TypeInContext instead" ); |
| 1408 | LLVM_C_ABI |
| 1409 | LLVM_ATTRIBUTE_C_DEPRECATED(LLVMTypeRef LLVMInt128Type(void), |
| 1410 | "Use of the global context is deprecated, use " |
| 1411 | "LLVMInt128TypeInContext instead" ); |
| 1412 | LLVM_C_ABI |
| 1413 | LLVM_ATTRIBUTE_C_DEPRECATED(LLVMTypeRef LLVMIntType(unsigned NumBits), |
| 1414 | "Use of the global context is deprecated, use " |
| 1415 | "LLVMIntTypeInContext instead" ); |
| 1416 | |
| 1417 | LLVM_C_ABI unsigned LLVMGetIntTypeWidth(LLVMTypeRef IntegerTy); |
| 1418 | |
| 1419 | /** |
| 1420 | * @} |
| 1421 | */ |
| 1422 | |
| 1423 | /** |
| 1424 | * @defgroup LLVMCCoreTypeFloat Floating Point Types |
| 1425 | * |
| 1426 | * @{ |
| 1427 | */ |
| 1428 | |
| 1429 | /** |
| 1430 | * Obtain a 16-bit floating point type from a context. |
| 1431 | */ |
| 1432 | LLVM_C_ABI LLVMTypeRef LLVMHalfTypeInContext(LLVMContextRef C); |
| 1433 | |
| 1434 | /** |
| 1435 | * Obtain a 16-bit brain floating point type from a context. |
| 1436 | */ |
| 1437 | LLVM_C_ABI LLVMTypeRef LLVMBFloatTypeInContext(LLVMContextRef C); |
| 1438 | |
| 1439 | /** |
| 1440 | * Obtain a 32-bit floating point type from a context. |
| 1441 | */ |
| 1442 | LLVM_C_ABI LLVMTypeRef LLVMFloatTypeInContext(LLVMContextRef C); |
| 1443 | |
| 1444 | /** |
| 1445 | * Obtain a 64-bit floating point type from a context. |
| 1446 | */ |
| 1447 | LLVM_C_ABI LLVMTypeRef LLVMDoubleTypeInContext(LLVMContextRef C); |
| 1448 | |
| 1449 | /** |
| 1450 | * Obtain a 80-bit floating point type (X87) from a context. |
| 1451 | */ |
| 1452 | LLVM_C_ABI LLVMTypeRef LLVMX86FP80TypeInContext(LLVMContextRef C); |
| 1453 | |
| 1454 | /** |
| 1455 | * Obtain a 128-bit floating point type (112-bit mantissa) from a |
| 1456 | * context. |
| 1457 | */ |
| 1458 | LLVM_C_ABI LLVMTypeRef LLVMFP128TypeInContext(LLVMContextRef C); |
| 1459 | |
| 1460 | /** |
| 1461 | * Obtain a 128-bit floating point type (two 64-bits) from a context. |
| 1462 | */ |
| 1463 | LLVM_C_ABI LLVMTypeRef LLVMPPCFP128TypeInContext(LLVMContextRef C); |
| 1464 | |
| 1465 | /** |
| 1466 | * Obtain a floating point type from the global context. |
| 1467 | * |
| 1468 | * These map to the functions in this group of the same name. |
| 1469 | */ |
| 1470 | LLVM_C_ABI |
| 1471 | LLVM_ATTRIBUTE_C_DEPRECATED(LLVMTypeRef LLVMHalfType(void), |
| 1472 | "Use of the global context is deprecated, use " |
| 1473 | "LLVMHalfTypeInContext instead" ); |
| 1474 | LLVM_C_ABI |
| 1475 | LLVM_ATTRIBUTE_C_DEPRECATED(LLVMTypeRef LLVMBFloatType(void), |
| 1476 | "Use of the global context is deprecated, use " |
| 1477 | "LLVMBFloatTypeInContext instead" ); |
| 1478 | LLVM_C_ABI |
| 1479 | LLVM_ATTRIBUTE_C_DEPRECATED(LLVMTypeRef LLVMFloatType(void), |
| 1480 | "Use of the global context is deprecated, use " |
| 1481 | "LLVMFloatTypeInContext instead" ); |
| 1482 | LLVM_C_ABI |
| 1483 | LLVM_ATTRIBUTE_C_DEPRECATED(LLVMTypeRef LLVMDoubleType(void), |
| 1484 | "Use of the global context is deprecated, use " |
| 1485 | "LLVMDoubleTypeInContext instead" ); |
| 1486 | LLVM_C_ABI |
| 1487 | LLVM_ATTRIBUTE_C_DEPRECATED(LLVMTypeRef LLVMX86FP80Type(void), |
| 1488 | "Use of the global context is deprecated, use " |
| 1489 | "LLVMX86FP80TypeInContext instead" ); |
| 1490 | LLVM_C_ABI |
| 1491 | LLVM_ATTRIBUTE_C_DEPRECATED(LLVMTypeRef LLVMFP128Type(void), |
| 1492 | "Use of the global context is deprecated, use " |
| 1493 | "LLVMFP128TypeInContext instead" ); |
| 1494 | LLVM_C_ABI |
| 1495 | LLVM_ATTRIBUTE_C_DEPRECATED(LLVMTypeRef LLVMPPCFP128Type(void), |
| 1496 | "Use of the global context is deprecated, use " |
| 1497 | "LLVMPPCFP128TypeInContext instead" ); |
| 1498 | |
| 1499 | /** |
| 1500 | * @} |
| 1501 | */ |
| 1502 | |
| 1503 | /** |
| 1504 | * @defgroup LLVMCCoreTypeFunction Function Types |
| 1505 | * |
| 1506 | * @{ |
| 1507 | */ |
| 1508 | |
| 1509 | /** |
| 1510 | * Obtain a function type consisting of a specified signature. |
| 1511 | * |
| 1512 | * The function is defined as a tuple of a return Type, a list of |
| 1513 | * parameter types, and whether the function is variadic. |
| 1514 | */ |
| 1515 | LLVM_C_ABI LLVMTypeRef LLVMFunctionType(LLVMTypeRef ReturnType, |
| 1516 | LLVMTypeRef *ParamTypes, |
| 1517 | unsigned ParamCount, LLVMBool IsVarArg); |
| 1518 | |
| 1519 | /** |
| 1520 | * Returns whether a function type is variadic. |
| 1521 | */ |
| 1522 | LLVM_C_ABI LLVMBool LLVMIsFunctionVarArg(LLVMTypeRef FunctionTy); |
| 1523 | |
| 1524 | /** |
| 1525 | * Obtain the Type this function Type returns. |
| 1526 | */ |
| 1527 | LLVM_C_ABI LLVMTypeRef LLVMGetReturnType(LLVMTypeRef FunctionTy); |
| 1528 | |
| 1529 | /** |
| 1530 | * Obtain the number of parameters this function accepts. |
| 1531 | */ |
| 1532 | LLVM_C_ABI unsigned LLVMCountParamTypes(LLVMTypeRef FunctionTy); |
| 1533 | |
| 1534 | /** |
| 1535 | * Obtain the types of a function's parameters. |
| 1536 | * |
| 1537 | * The Dest parameter should point to a pre-allocated array of |
| 1538 | * LLVMTypeRef at least LLVMCountParamTypes() large. On return, the |
| 1539 | * first LLVMCountParamTypes() entries in the array will be populated |
| 1540 | * with LLVMTypeRef instances. |
| 1541 | * |
| 1542 | * @param FunctionTy The function type to operate on. |
| 1543 | * @param Dest Memory address of an array to be filled with result. |
| 1544 | */ |
| 1545 | LLVM_C_ABI void LLVMGetParamTypes(LLVMTypeRef FunctionTy, LLVMTypeRef *Dest); |
| 1546 | |
| 1547 | /** |
| 1548 | * @} |
| 1549 | */ |
| 1550 | |
| 1551 | /** |
| 1552 | * @defgroup LLVMCCoreTypeStruct Structure Types |
| 1553 | * |
| 1554 | * These functions relate to LLVMTypeRef instances. |
| 1555 | * |
| 1556 | * @see llvm::StructType |
| 1557 | * |
| 1558 | * @{ |
| 1559 | */ |
| 1560 | |
| 1561 | /** |
| 1562 | * Create a new structure type in a context. |
| 1563 | * |
| 1564 | * A structure is specified by a list of inner elements/types and |
| 1565 | * whether these can be packed together. |
| 1566 | * |
| 1567 | * @see llvm::StructType::create() |
| 1568 | */ |
| 1569 | LLVM_C_ABI LLVMTypeRef LLVMStructTypeInContext(LLVMContextRef C, |
| 1570 | LLVMTypeRef *ElementTypes, |
| 1571 | unsigned ElementCount, |
| 1572 | LLVMBool Packed); |
| 1573 | |
| 1574 | /** |
| 1575 | * Create a new structure type in the global context. |
| 1576 | * |
| 1577 | * @see llvm::StructType::create() |
| 1578 | */ |
| 1579 | LLVM_C_ABI LLVM_ATTRIBUTE_C_DEPRECATED( |
| 1580 | LLVMTypeRef LLVMStructType(LLVMTypeRef *ElementTypes, unsigned ElementCount, |
| 1581 | LLVMBool Packed), |
| 1582 | "Use of the global context is deprecated, use LLVMStructTypeInContext " |
| 1583 | "instead" ); |
| 1584 | |
| 1585 | /** |
| 1586 | * Create an empty structure in a context having a specified name. |
| 1587 | * |
| 1588 | * @see llvm::StructType::create() |
| 1589 | */ |
| 1590 | LLVM_C_ABI LLVMTypeRef LLVMStructCreateNamed(LLVMContextRef C, |
| 1591 | const char *Name); |
| 1592 | |
| 1593 | /** |
| 1594 | * Obtain the name of a structure. |
| 1595 | * |
| 1596 | * @see llvm::StructType::getName() |
| 1597 | */ |
| 1598 | LLVM_C_ABI const char *LLVMGetStructName(LLVMTypeRef Ty); |
| 1599 | |
| 1600 | /** |
| 1601 | * Set the contents of a structure type. |
| 1602 | * |
| 1603 | * @see llvm::StructType::setBody() |
| 1604 | */ |
| 1605 | LLVM_C_ABI void LLVMStructSetBody(LLVMTypeRef StructTy, |
| 1606 | LLVMTypeRef *ElementTypes, |
| 1607 | unsigned ElementCount, LLVMBool Packed); |
| 1608 | |
| 1609 | /** |
| 1610 | * Get the number of elements defined inside the structure. |
| 1611 | * |
| 1612 | * @see llvm::StructType::getNumElements() |
| 1613 | */ |
| 1614 | LLVM_C_ABI unsigned LLVMCountStructElementTypes(LLVMTypeRef StructTy); |
| 1615 | |
| 1616 | /** |
| 1617 | * Get the elements within a structure. |
| 1618 | * |
| 1619 | * The function is passed the address of a pre-allocated array of |
| 1620 | * LLVMTypeRef at least LLVMCountStructElementTypes() long. After |
| 1621 | * invocation, this array will be populated with the structure's |
| 1622 | * elements. The objects in the destination array will have a lifetime |
| 1623 | * of the structure type itself, which is the lifetime of the context it |
| 1624 | * is contained in. |
| 1625 | */ |
| 1626 | LLVM_C_ABI void LLVMGetStructElementTypes(LLVMTypeRef StructTy, |
| 1627 | LLVMTypeRef *Dest); |
| 1628 | |
| 1629 | /** |
| 1630 | * Get the type of the element at a given index in the structure. |
| 1631 | * |
| 1632 | * @see llvm::StructType::getTypeAtIndex() |
| 1633 | */ |
| 1634 | LLVM_C_ABI LLVMTypeRef LLVMStructGetTypeAtIndex(LLVMTypeRef StructTy, |
| 1635 | unsigned i); |
| 1636 | |
| 1637 | /** |
| 1638 | * Determine whether a structure is packed. |
| 1639 | * |
| 1640 | * @see llvm::StructType::isPacked() |
| 1641 | */ |
| 1642 | LLVM_C_ABI LLVMBool LLVMIsPackedStruct(LLVMTypeRef StructTy); |
| 1643 | |
| 1644 | /** |
| 1645 | * Determine whether a structure is opaque. |
| 1646 | * |
| 1647 | * @see llvm::StructType::isOpaque() |
| 1648 | */ |
| 1649 | LLVM_C_ABI LLVMBool LLVMIsOpaqueStruct(LLVMTypeRef StructTy); |
| 1650 | |
| 1651 | /** |
| 1652 | * Determine whether a structure is literal. |
| 1653 | * |
| 1654 | * @see llvm::StructType::isLiteral() |
| 1655 | */ |
| 1656 | LLVM_C_ABI LLVMBool LLVMIsLiteralStruct(LLVMTypeRef StructTy); |
| 1657 | |
| 1658 | /** |
| 1659 | * @} |
| 1660 | */ |
| 1661 | |
| 1662 | /** |
| 1663 | * @defgroup LLVMCCoreTypeSequential Sequential Types |
| 1664 | * |
| 1665 | * Sequential types represents "arrays" of types. This is a super class |
| 1666 | * for array, vector, and pointer types. |
| 1667 | * |
| 1668 | * @{ |
| 1669 | */ |
| 1670 | |
| 1671 | /** |
| 1672 | * Obtain the element type of an array or vector type. |
| 1673 | * |
| 1674 | * @see llvm::SequentialType::getElementType() |
| 1675 | */ |
| 1676 | LLVM_C_ABI LLVMTypeRef LLVMGetElementType(LLVMTypeRef Ty); |
| 1677 | |
| 1678 | /** |
| 1679 | * Returns type's subtypes |
| 1680 | * |
| 1681 | * @see llvm::Type::subtypes() |
| 1682 | */ |
| 1683 | LLVM_C_ABI void LLVMGetSubtypes(LLVMTypeRef Tp, LLVMTypeRef *Arr); |
| 1684 | |
| 1685 | /** |
| 1686 | * Return the number of types in the derived type. |
| 1687 | * |
| 1688 | * @see llvm::Type::getNumContainedTypes() |
| 1689 | */ |
| 1690 | LLVM_C_ABI unsigned LLVMGetNumContainedTypes(LLVMTypeRef Tp); |
| 1691 | |
| 1692 | /** |
| 1693 | * Create a fixed size array type that refers to a specific type. |
| 1694 | * |
| 1695 | * The created type will exist in the context that its element type |
| 1696 | * exists in. |
| 1697 | * |
| 1698 | * @deprecated LLVMArrayType is deprecated in favor of the API accurate |
| 1699 | * LLVMArrayType2 |
| 1700 | * @see llvm::ArrayType::get() |
| 1701 | */ |
| 1702 | LLVM_C_ABI LLVMTypeRef LLVMArrayType(LLVMTypeRef ElementType, |
| 1703 | unsigned ElementCount); |
| 1704 | |
| 1705 | /** |
| 1706 | * Create a fixed size array type that refers to a specific type. |
| 1707 | * |
| 1708 | * The created type will exist in the context that its element type |
| 1709 | * exists in. |
| 1710 | * |
| 1711 | * @see llvm::ArrayType::get() |
| 1712 | */ |
| 1713 | LLVM_C_ABI LLVMTypeRef LLVMArrayType2(LLVMTypeRef ElementType, |
| 1714 | uint64_t ElementCount); |
| 1715 | |
| 1716 | /** |
| 1717 | * Obtain the length of an array type. |
| 1718 | * |
| 1719 | * This only works on types that represent arrays. |
| 1720 | * |
| 1721 | * @deprecated LLVMGetArrayLength is deprecated in favor of the API accurate |
| 1722 | * LLVMGetArrayLength2 |
| 1723 | * @see llvm::ArrayType::getNumElements() |
| 1724 | */ |
| 1725 | LLVM_C_ABI unsigned LLVMGetArrayLength(LLVMTypeRef ArrayTy); |
| 1726 | |
| 1727 | /** |
| 1728 | * Obtain the length of an array type. |
| 1729 | * |
| 1730 | * This only works on types that represent arrays. |
| 1731 | * |
| 1732 | * @see llvm::ArrayType::getNumElements() |
| 1733 | */ |
| 1734 | LLVM_C_ABI uint64_t LLVMGetArrayLength2(LLVMTypeRef ArrayTy); |
| 1735 | |
| 1736 | /** |
| 1737 | * Create a pointer type that points to a defined type. |
| 1738 | * |
| 1739 | * The created type will exist in the context that its pointee type |
| 1740 | * exists in. |
| 1741 | * |
| 1742 | * @see llvm::PointerType::get() |
| 1743 | */ |
| 1744 | LLVM_C_ABI LLVMTypeRef LLVMPointerType(LLVMTypeRef ElementType, |
| 1745 | unsigned AddressSpace); |
| 1746 | |
| 1747 | /** |
| 1748 | * Determine whether a pointer is opaque. |
| 1749 | * |
| 1750 | * True if this is an instance of an opaque PointerType. |
| 1751 | * |
| 1752 | * @see llvm::Type::isOpaquePointerTy() |
| 1753 | */ |
| 1754 | LLVM_C_ABI LLVMBool LLVMPointerTypeIsOpaque(LLVMTypeRef Ty); |
| 1755 | |
| 1756 | /** |
| 1757 | * Create an opaque pointer type in a context. |
| 1758 | * |
| 1759 | * @see llvm::PointerType::get() |
| 1760 | */ |
| 1761 | LLVM_C_ABI LLVMTypeRef LLVMPointerTypeInContext(LLVMContextRef C, |
| 1762 | unsigned AddressSpace); |
| 1763 | |
| 1764 | /** |
| 1765 | * Obtain the address space of a pointer type. |
| 1766 | * |
| 1767 | * This only works on types that represent pointers. |
| 1768 | * |
| 1769 | * @see llvm::PointerType::getAddressSpace() |
| 1770 | */ |
| 1771 | LLVM_C_ABI unsigned LLVMGetPointerAddressSpace(LLVMTypeRef PointerTy); |
| 1772 | |
| 1773 | /** |
| 1774 | * Create a vector type that contains a defined type and has a specific |
| 1775 | * number of elements. |
| 1776 | * |
| 1777 | * The created type will exist in the context thats its element type |
| 1778 | * exists in. |
| 1779 | * |
| 1780 | * @see llvm::VectorType::get() |
| 1781 | */ |
| 1782 | LLVM_C_ABI LLVMTypeRef LLVMVectorType(LLVMTypeRef ElementType, |
| 1783 | unsigned ElementCount); |
| 1784 | |
| 1785 | /** |
| 1786 | * Create a vector type that contains a defined type and has a scalable |
| 1787 | * number of elements. |
| 1788 | * |
| 1789 | * The created type will exist in the context thats its element type |
| 1790 | * exists in. |
| 1791 | * |
| 1792 | * @see llvm::ScalableVectorType::get() |
| 1793 | */ |
| 1794 | LLVM_C_ABI LLVMTypeRef LLVMScalableVectorType(LLVMTypeRef ElementType, |
| 1795 | unsigned ElementCount); |
| 1796 | |
| 1797 | /** |
| 1798 | * Obtain the (possibly scalable) number of elements in a vector type. |
| 1799 | * |
| 1800 | * This only works on types that represent vectors (fixed or scalable). |
| 1801 | * |
| 1802 | * @see llvm::VectorType::getNumElements() |
| 1803 | */ |
| 1804 | LLVM_C_ABI unsigned LLVMGetVectorSize(LLVMTypeRef VectorTy); |
| 1805 | |
| 1806 | /** |
| 1807 | * Get the pointer value for the associated ConstantPtrAuth constant. |
| 1808 | * |
| 1809 | * @see llvm::ConstantPtrAuth::getPointer |
| 1810 | */ |
| 1811 | LLVM_C_ABI LLVMValueRef LLVMGetConstantPtrAuthPointer(LLVMValueRef PtrAuth); |
| 1812 | |
| 1813 | /** |
| 1814 | * Get the key value for the associated ConstantPtrAuth constant. |
| 1815 | * |
| 1816 | * @see llvm::ConstantPtrAuth::getKey |
| 1817 | */ |
| 1818 | LLVM_C_ABI LLVMValueRef LLVMGetConstantPtrAuthKey(LLVMValueRef PtrAuth); |
| 1819 | |
| 1820 | /** |
| 1821 | * Get the discriminator value for the associated ConstantPtrAuth constant. |
| 1822 | * |
| 1823 | * @see llvm::ConstantPtrAuth::getDiscriminator |
| 1824 | */ |
| 1825 | LLVM_C_ABI LLVMValueRef |
| 1826 | LLVMGetConstantPtrAuthDiscriminator(LLVMValueRef PtrAuth); |
| 1827 | |
| 1828 | /** |
| 1829 | * Get the address discriminator value for the associated ConstantPtrAuth |
| 1830 | * constant. |
| 1831 | * |
| 1832 | * @see llvm::ConstantPtrAuth::getAddrDiscriminator |
| 1833 | */ |
| 1834 | LLVM_C_ABI LLVMValueRef |
| 1835 | LLVMGetConstantPtrAuthAddrDiscriminator(LLVMValueRef PtrAuth); |
| 1836 | |
| 1837 | /** |
| 1838 | * @} |
| 1839 | */ |
| 1840 | |
| 1841 | /** |
| 1842 | * @defgroup LLVMCCoreTypeOther Other Types |
| 1843 | * |
| 1844 | * @{ |
| 1845 | */ |
| 1846 | |
| 1847 | /** |
| 1848 | * Create a void type in a context. |
| 1849 | */ |
| 1850 | LLVM_C_ABI LLVMTypeRef LLVMVoidTypeInContext(LLVMContextRef C); |
| 1851 | |
| 1852 | /** |
| 1853 | * Create a label type in a context. |
| 1854 | */ |
| 1855 | LLVM_C_ABI LLVMTypeRef LLVMLabelTypeInContext(LLVMContextRef C); |
| 1856 | |
| 1857 | /** |
| 1858 | * Create a X86 AMX type in a context. |
| 1859 | */ |
| 1860 | LLVM_C_ABI LLVMTypeRef LLVMX86AMXTypeInContext(LLVMContextRef C); |
| 1861 | |
| 1862 | /** |
| 1863 | * Create a token type in a context. |
| 1864 | */ |
| 1865 | LLVM_C_ABI LLVMTypeRef LLVMTokenTypeInContext(LLVMContextRef C); |
| 1866 | |
| 1867 | /** |
| 1868 | * Create a metadata type in a context. |
| 1869 | */ |
| 1870 | LLVM_C_ABI LLVMTypeRef LLVMMetadataTypeInContext(LLVMContextRef C); |
| 1871 | |
| 1872 | /** |
| 1873 | * These are similar to the above functions except they operate on the |
| 1874 | * global context. |
| 1875 | */ |
| 1876 | LLVM_C_ABI |
| 1877 | LLVM_ATTRIBUTE_C_DEPRECATED(LLVMTypeRef LLVMVoidType(void), |
| 1878 | "Use of the global context is deprecated, use " |
| 1879 | "LLVMVoidTypeInContext instead" ); |
| 1880 | LLVM_C_ABI |
| 1881 | LLVM_ATTRIBUTE_C_DEPRECATED(LLVMTypeRef LLVMLabelType(void), |
| 1882 | "Use of the global context is deprecated, use " |
| 1883 | "LLVMLabelTypeInContext instead" ); |
| 1884 | LLVM_C_ABI |
| 1885 | LLVM_ATTRIBUTE_C_DEPRECATED(LLVMTypeRef LLVMX86AMXType(void), |
| 1886 | "Use of the global context is deprecated, use " |
| 1887 | "LLVMX86AMXTypeInContext instead" ); |
| 1888 | |
| 1889 | /** |
| 1890 | * Create a target extension type in LLVM context. |
| 1891 | */ |
| 1892 | LLVM_C_ABI LLVMTypeRef LLVMTargetExtTypeInContext( |
| 1893 | LLVMContextRef C, const char *Name, LLVMTypeRef *TypeParams, |
| 1894 | unsigned TypeParamCount, unsigned *IntParams, unsigned IntParamCount); |
| 1895 | |
| 1896 | /** |
| 1897 | * Obtain the name for this target extension type. |
| 1898 | * |
| 1899 | * @see llvm::TargetExtType::getName() |
| 1900 | */ |
| 1901 | LLVM_C_ABI const char *LLVMGetTargetExtTypeName(LLVMTypeRef TargetExtTy); |
| 1902 | |
| 1903 | /** |
| 1904 | * Obtain the number of type parameters for this target extension type. |
| 1905 | * |
| 1906 | * @see llvm::TargetExtType::getNumTypeParameters() |
| 1907 | */ |
| 1908 | LLVM_C_ABI unsigned LLVMGetTargetExtTypeNumTypeParams(LLVMTypeRef TargetExtTy); |
| 1909 | |
| 1910 | /** |
| 1911 | * Get the type parameter at the given index for the target extension type. |
| 1912 | * |
| 1913 | * @see llvm::TargetExtType::getTypeParameter() |
| 1914 | */ |
| 1915 | LLVM_C_ABI LLVMTypeRef LLVMGetTargetExtTypeTypeParam(LLVMTypeRef TargetExtTy, |
| 1916 | unsigned Idx); |
| 1917 | |
| 1918 | /** |
| 1919 | * Obtain the number of int parameters for this target extension type. |
| 1920 | * |
| 1921 | * @see llvm::TargetExtType::getNumIntParameters() |
| 1922 | */ |
| 1923 | LLVM_C_ABI unsigned LLVMGetTargetExtTypeNumIntParams(LLVMTypeRef TargetExtTy); |
| 1924 | |
| 1925 | /** |
| 1926 | * Get the int parameter at the given index for the target extension type. |
| 1927 | * |
| 1928 | * @see llvm::TargetExtType::getIntParameter() |
| 1929 | */ |
| 1930 | LLVM_C_ABI unsigned LLVMGetTargetExtTypeIntParam(LLVMTypeRef TargetExtTy, |
| 1931 | unsigned Idx); |
| 1932 | |
| 1933 | /** |
| 1934 | * @} |
| 1935 | */ |
| 1936 | |
| 1937 | /** |
| 1938 | * @} |
| 1939 | */ |
| 1940 | |
| 1941 | /** |
| 1942 | * @defgroup LLVMCCoreValues Values |
| 1943 | * |
| 1944 | * The bulk of LLVM's object model consists of values, which comprise a very |
| 1945 | * rich type hierarchy. |
| 1946 | * |
| 1947 | * LLVMValueRef essentially represents llvm::Value. There is a rich |
| 1948 | * hierarchy of classes within this type. Depending on the instance |
| 1949 | * obtained, not all APIs are available. |
| 1950 | * |
| 1951 | * Callers can determine the type of an LLVMValueRef by calling the |
| 1952 | * LLVMIsA* family of functions (e.g. LLVMIsAArgument()). These |
| 1953 | * functions are defined by a macro, so it isn't obvious which are |
| 1954 | * available by looking at the Doxygen source code. Instead, look at the |
| 1955 | * source definition of LLVM_FOR_EACH_VALUE_SUBCLASS and note the list |
| 1956 | * of value names given. These value names also correspond to classes in |
| 1957 | * the llvm::Value hierarchy. |
| 1958 | * |
| 1959 | * @{ |
| 1960 | */ |
| 1961 | |
| 1962 | // Currently, clang-format tries to format the LLVM_FOR_EACH_VALUE_SUBCLASS |
| 1963 | // macro in a progressively-indented fashion, which is not desired |
| 1964 | // clang-format off |
| 1965 | |
| 1966 | #define LLVM_FOR_EACH_VALUE_SUBCLASS(macro) \ |
| 1967 | macro(Argument) \ |
| 1968 | macro(BasicBlock) \ |
| 1969 | macro(InlineAsm) \ |
| 1970 | macro(User) \ |
| 1971 | macro(Constant) \ |
| 1972 | macro(BlockAddress) \ |
| 1973 | macro(ConstantAggregateZero) \ |
| 1974 | macro(ConstantArray) \ |
| 1975 | macro(ConstantDataSequential) \ |
| 1976 | macro(ConstantDataArray) \ |
| 1977 | macro(ConstantDataVector) \ |
| 1978 | macro(ConstantExpr) \ |
| 1979 | macro(ConstantFP) \ |
| 1980 | macro(ConstantInt) \ |
| 1981 | macro(ConstantPointerNull) \ |
| 1982 | macro(ConstantStruct) \ |
| 1983 | macro(ConstantTokenNone) \ |
| 1984 | macro(ConstantVector) \ |
| 1985 | macro(ConstantPtrAuth) \ |
| 1986 | macro(GlobalValue) \ |
| 1987 | macro(GlobalAlias) \ |
| 1988 | macro(GlobalObject) \ |
| 1989 | macro(Function) \ |
| 1990 | macro(GlobalVariable) \ |
| 1991 | macro(GlobalIFunc) \ |
| 1992 | macro(UndefValue) \ |
| 1993 | macro(PoisonValue) \ |
| 1994 | macro(Instruction) \ |
| 1995 | macro(UnaryOperator) \ |
| 1996 | macro(BinaryOperator) \ |
| 1997 | macro(CallInst) \ |
| 1998 | macro(IntrinsicInst) \ |
| 1999 | macro(DbgInfoIntrinsic) \ |
| 2000 | macro(DbgVariableIntrinsic) \ |
| 2001 | macro(DbgDeclareInst) \ |
| 2002 | macro(DbgLabelInst) \ |
| 2003 | macro(MemIntrinsic) \ |
| 2004 | macro(MemCpyInst) \ |
| 2005 | macro(MemMoveInst) \ |
| 2006 | macro(MemSetInst) \ |
| 2007 | macro(CmpInst) \ |
| 2008 | macro(FCmpInst) \ |
| 2009 | macro(ICmpInst) \ |
| 2010 | macro(ExtractElementInst) \ |
| 2011 | macro(GetElementPtrInst) \ |
| 2012 | macro(InsertElementInst) \ |
| 2013 | macro(InsertValueInst) \ |
| 2014 | macro(LandingPadInst) \ |
| 2015 | macro(PHINode) \ |
| 2016 | macro(SelectInst) \ |
| 2017 | macro(ShuffleVectorInst) \ |
| 2018 | macro(StoreInst) \ |
| 2019 | macro(BranchInst) \ |
| 2020 | macro(IndirectBrInst) \ |
| 2021 | macro(InvokeInst) \ |
| 2022 | macro(ReturnInst) \ |
| 2023 | macro(SwitchInst) \ |
| 2024 | macro(UnreachableInst) \ |
| 2025 | macro(ResumeInst) \ |
| 2026 | macro(CleanupReturnInst) \ |
| 2027 | macro(CatchReturnInst) \ |
| 2028 | macro(CatchSwitchInst) \ |
| 2029 | macro(CallBrInst) \ |
| 2030 | macro(FuncletPadInst) \ |
| 2031 | macro(CatchPadInst) \ |
| 2032 | macro(CleanupPadInst) \ |
| 2033 | macro(UnaryInstruction) \ |
| 2034 | macro(AllocaInst) \ |
| 2035 | macro(CastInst) \ |
| 2036 | macro(AddrSpaceCastInst) \ |
| 2037 | macro(BitCastInst) \ |
| 2038 | macro(FPExtInst) \ |
| 2039 | macro(FPToSIInst) \ |
| 2040 | macro(FPToUIInst) \ |
| 2041 | macro(FPTruncInst) \ |
| 2042 | macro(IntToPtrInst) \ |
| 2043 | macro(PtrToIntInst) \ |
| 2044 | macro(SExtInst) \ |
| 2045 | macro(SIToFPInst) \ |
| 2046 | macro(TruncInst) \ |
| 2047 | macro(UIToFPInst) \ |
| 2048 | macro(ZExtInst) \ |
| 2049 | macro(ExtractValueInst) \ |
| 2050 | macro(LoadInst) \ |
| 2051 | macro(VAArgInst) \ |
| 2052 | macro(FreezeInst) \ |
| 2053 | macro(AtomicCmpXchgInst) \ |
| 2054 | macro(AtomicRMWInst) \ |
| 2055 | macro(FenceInst) |
| 2056 | |
| 2057 | // clang-format on |
| 2058 | |
| 2059 | /** |
| 2060 | * @defgroup LLVMCCoreValueGeneral General APIs |
| 2061 | * |
| 2062 | * Functions in this section work on all LLVMValueRef instances, |
| 2063 | * regardless of their sub-type. They correspond to functions available |
| 2064 | * on llvm::Value. |
| 2065 | * |
| 2066 | * @{ |
| 2067 | */ |
| 2068 | |
| 2069 | /** |
| 2070 | * Obtain the type of a value. |
| 2071 | * |
| 2072 | * @see llvm::Value::getType() |
| 2073 | */ |
| 2074 | LLVM_C_ABI LLVMTypeRef LLVMTypeOf(LLVMValueRef Val); |
| 2075 | |
| 2076 | /** |
| 2077 | * Obtain the enumerated type of a Value instance. |
| 2078 | * |
| 2079 | * @see llvm::Value::getValueID() |
| 2080 | */ |
| 2081 | LLVM_C_ABI LLVMValueKind LLVMGetValueKind(LLVMValueRef Val); |
| 2082 | |
| 2083 | /** |
| 2084 | * Obtain the string name of a value. |
| 2085 | * |
| 2086 | * @see llvm::Value::getName() |
| 2087 | */ |
| 2088 | LLVM_C_ABI const char *LLVMGetValueName2(LLVMValueRef Val, size_t *Length); |
| 2089 | |
| 2090 | /** |
| 2091 | * Set the string name of a value. |
| 2092 | * |
| 2093 | * @see llvm::Value::setName() |
| 2094 | */ |
| 2095 | LLVM_C_ABI void LLVMSetValueName2(LLVMValueRef Val, const char *Name, |
| 2096 | size_t NameLen); |
| 2097 | |
| 2098 | /** |
| 2099 | * Dump a representation of a value to stderr. |
| 2100 | * |
| 2101 | * @see llvm::Value::dump() |
| 2102 | */ |
| 2103 | LLVM_C_ABI void LLVMDumpValue(LLVMValueRef Val); |
| 2104 | |
| 2105 | /** |
| 2106 | * Return a string representation of the value. Use |
| 2107 | * LLVMDisposeMessage to free the string. |
| 2108 | * |
| 2109 | * @see llvm::Value::print() |
| 2110 | */ |
| 2111 | LLVM_C_ABI char *LLVMPrintValueToString(LLVMValueRef Val); |
| 2112 | |
| 2113 | /** |
| 2114 | * Obtain the context to which this value is associated. |
| 2115 | * |
| 2116 | * @see llvm::Value::getContext() |
| 2117 | */ |
| 2118 | LLVM_C_ABI LLVMContextRef LLVMGetValueContext(LLVMValueRef Val); |
| 2119 | |
| 2120 | /** |
| 2121 | * Return a string representation of the DbgRecord. Use |
| 2122 | * LLVMDisposeMessage to free the string. |
| 2123 | * |
| 2124 | * @see llvm::DbgRecord::print() |
| 2125 | */ |
| 2126 | LLVM_C_ABI char *LLVMPrintDbgRecordToString(LLVMDbgRecordRef Record); |
| 2127 | |
| 2128 | /** |
| 2129 | * Replace all uses of a value with another one. |
| 2130 | * |
| 2131 | * @see llvm::Value::replaceAllUsesWith() |
| 2132 | */ |
| 2133 | LLVM_C_ABI void LLVMReplaceAllUsesWith(LLVMValueRef OldVal, |
| 2134 | LLVMValueRef NewVal); |
| 2135 | |
| 2136 | /** |
| 2137 | * Determine whether the specified value instance is constant. |
| 2138 | */ |
| 2139 | LLVM_C_ABI LLVMBool LLVMIsConstant(LLVMValueRef Val); |
| 2140 | |
| 2141 | /** |
| 2142 | * Determine whether a value instance is undefined. |
| 2143 | */ |
| 2144 | LLVM_C_ABI LLVMBool LLVMIsUndef(LLVMValueRef Val); |
| 2145 | |
| 2146 | /** |
| 2147 | * Determine whether a value instance is poisonous. |
| 2148 | */ |
| 2149 | LLVM_C_ABI LLVMBool LLVMIsPoison(LLVMValueRef Val); |
| 2150 | |
| 2151 | /** |
| 2152 | * Convert value instances between types. |
| 2153 | * |
| 2154 | * Internally, an LLVMValueRef is "pinned" to a specific type. This |
| 2155 | * series of functions allows you to cast an instance to a specific |
| 2156 | * type. |
| 2157 | * |
| 2158 | * If the cast is not valid for the specified type, NULL is returned. |
| 2159 | * |
| 2160 | * @see llvm::dyn_cast_or_null<> |
| 2161 | */ |
| 2162 | #define LLVM_DECLARE_VALUE_CAST(name) \ |
| 2163 | LLVM_C_ABI LLVMValueRef LLVMIsA##name(LLVMValueRef Val); |
| 2164 | LLVM_FOR_EACH_VALUE_SUBCLASS(LLVM_DECLARE_VALUE_CAST) |
| 2165 | |
| 2166 | LLVM_C_ABI LLVMValueRef LLVMIsAMDNode(LLVMValueRef Val); |
| 2167 | LLVM_C_ABI LLVMValueRef LLVMIsAValueAsMetadata(LLVMValueRef Val); |
| 2168 | LLVM_C_ABI LLVMValueRef LLVMIsAMDString(LLVMValueRef Val); |
| 2169 | |
| 2170 | /** Deprecated: Use LLVMGetValueName2 instead. */ |
| 2171 | LLVM_C_ABI const char *LLVMGetValueName(LLVMValueRef Val); |
| 2172 | /** Deprecated: Use LLVMSetValueName2 instead. */ |
| 2173 | LLVM_C_ABI void LLVMSetValueName(LLVMValueRef Val, const char *Name); |
| 2174 | |
| 2175 | /** |
| 2176 | * @} |
| 2177 | */ |
| 2178 | |
| 2179 | /** |
| 2180 | * @defgroup LLVMCCoreValueUses Usage |
| 2181 | * |
| 2182 | * This module defines functions that allow you to inspect the uses of a |
| 2183 | * LLVMValueRef. |
| 2184 | * |
| 2185 | * It is possible to obtain an LLVMUseRef for any LLVMValueRef instance. |
| 2186 | * Each LLVMUseRef (which corresponds to a llvm::Use instance) holds a |
| 2187 | * llvm::User and llvm::Value. |
| 2188 | * |
| 2189 | * @{ |
| 2190 | */ |
| 2191 | |
| 2192 | /** |
| 2193 | * Obtain the first use of a value. |
| 2194 | * |
| 2195 | * Uses are obtained in an iterator fashion. First, call this function |
| 2196 | * to obtain a reference to the first use. Then, call LLVMGetNextUse() |
| 2197 | * on that instance and all subsequently obtained instances until |
| 2198 | * LLVMGetNextUse() returns NULL. |
| 2199 | * |
| 2200 | * @see llvm::Value::use_begin() |
| 2201 | */ |
| 2202 | LLVM_C_ABI LLVMUseRef LLVMGetFirstUse(LLVMValueRef Val); |
| 2203 | |
| 2204 | /** |
| 2205 | * Obtain the next use of a value. |
| 2206 | * |
| 2207 | * This effectively advances the iterator. It returns NULL if you are on |
| 2208 | * the final use and no more are available. |
| 2209 | */ |
| 2210 | LLVM_C_ABI LLVMUseRef LLVMGetNextUse(LLVMUseRef U); |
| 2211 | |
| 2212 | /** |
| 2213 | * Obtain the user value for a user. |
| 2214 | * |
| 2215 | * The returned value corresponds to a llvm::User type. |
| 2216 | * |
| 2217 | * @see llvm::Use::getUser() |
| 2218 | */ |
| 2219 | LLVM_C_ABI LLVMValueRef LLVMGetUser(LLVMUseRef U); |
| 2220 | |
| 2221 | /** |
| 2222 | * Obtain the value this use corresponds to. |
| 2223 | * |
| 2224 | * @see llvm::Use::get(). |
| 2225 | */ |
| 2226 | LLVM_C_ABI LLVMValueRef LLVMGetUsedValue(LLVMUseRef U); |
| 2227 | |
| 2228 | /** |
| 2229 | * @} |
| 2230 | */ |
| 2231 | |
| 2232 | /** |
| 2233 | * @defgroup LLVMCCoreValueUser User value |
| 2234 | * |
| 2235 | * Function in this group pertain to LLVMValueRef instances that descent |
| 2236 | * from llvm::User. This includes constants, instructions, and |
| 2237 | * operators. |
| 2238 | * |
| 2239 | * @{ |
| 2240 | */ |
| 2241 | |
| 2242 | /** |
| 2243 | * Obtain an operand at a specific index in a llvm::User value. |
| 2244 | * |
| 2245 | * @see llvm::User::getOperand() |
| 2246 | */ |
| 2247 | LLVM_C_ABI LLVMValueRef LLVMGetOperand(LLVMValueRef Val, unsigned Index); |
| 2248 | |
| 2249 | /** |
| 2250 | * Obtain the use of an operand at a specific index in a llvm::User value. |
| 2251 | * |
| 2252 | * @see llvm::User::getOperandUse() |
| 2253 | */ |
| 2254 | LLVM_C_ABI LLVMUseRef LLVMGetOperandUse(LLVMValueRef Val, unsigned Index); |
| 2255 | |
| 2256 | /** |
| 2257 | * Set an operand at a specific index in a llvm::User value. |
| 2258 | * |
| 2259 | * @see llvm::User::setOperand() |
| 2260 | */ |
| 2261 | LLVM_C_ABI void LLVMSetOperand(LLVMValueRef User, unsigned Index, |
| 2262 | LLVMValueRef Val); |
| 2263 | |
| 2264 | /** |
| 2265 | * Obtain the number of operands in a llvm::User value. |
| 2266 | * |
| 2267 | * @see llvm::User::getNumOperands() |
| 2268 | */ |
| 2269 | LLVM_C_ABI int LLVMGetNumOperands(LLVMValueRef Val); |
| 2270 | |
| 2271 | /** |
| 2272 | * @} |
| 2273 | */ |
| 2274 | |
| 2275 | /** |
| 2276 | * @defgroup LLVMCCoreValueConstant Constants |
| 2277 | * |
| 2278 | * This section contains APIs for interacting with LLVMValueRef that |
| 2279 | * correspond to llvm::Constant instances. |
| 2280 | * |
| 2281 | * These functions will work for any LLVMValueRef in the llvm::Constant |
| 2282 | * class hierarchy. |
| 2283 | * |
| 2284 | * @{ |
| 2285 | */ |
| 2286 | |
| 2287 | /** |
| 2288 | * Obtain a constant value referring to the null instance of a type. |
| 2289 | * |
| 2290 | * @see llvm::Constant::getNullValue() |
| 2291 | */ |
| 2292 | LLVM_C_ABI LLVMValueRef LLVMConstNull(LLVMTypeRef Ty); /* all zeroes */ |
| 2293 | |
| 2294 | /** |
| 2295 | * Obtain a constant value referring to the instance of a type |
| 2296 | * consisting of all ones. |
| 2297 | * |
| 2298 | * This is only valid for integer types. |
| 2299 | * |
| 2300 | * @see llvm::Constant::getAllOnesValue() |
| 2301 | */ |
| 2302 | LLVM_C_ABI LLVMValueRef LLVMConstAllOnes(LLVMTypeRef Ty); |
| 2303 | |
| 2304 | /** |
| 2305 | * Obtain a constant value referring to an undefined value of a type. |
| 2306 | * |
| 2307 | * @see llvm::UndefValue::get() |
| 2308 | */ |
| 2309 | LLVM_C_ABI LLVMValueRef LLVMGetUndef(LLVMTypeRef Ty); |
| 2310 | |
| 2311 | /** |
| 2312 | * Obtain a constant value referring to a poison value of a type. |
| 2313 | * |
| 2314 | * @see llvm::PoisonValue::get() |
| 2315 | */ |
| 2316 | LLVM_C_ABI LLVMValueRef LLVMGetPoison(LLVMTypeRef Ty); |
| 2317 | |
| 2318 | /** |
| 2319 | * Determine whether a value instance is null. |
| 2320 | * |
| 2321 | * @see llvm::Constant::isNullValue() |
| 2322 | */ |
| 2323 | LLVM_C_ABI LLVMBool LLVMIsNull(LLVMValueRef Val); |
| 2324 | |
| 2325 | /** |
| 2326 | * Obtain a constant that is a constant pointer pointing to NULL for a |
| 2327 | * specified type. |
| 2328 | */ |
| 2329 | LLVM_C_ABI LLVMValueRef LLVMConstPointerNull(LLVMTypeRef Ty); |
| 2330 | |
| 2331 | /** |
| 2332 | * @defgroup LLVMCCoreValueConstantScalar Scalar constants |
| 2333 | * |
| 2334 | * Functions in this group model LLVMValueRef instances that correspond |
| 2335 | * to constants referring to scalar types. |
| 2336 | * |
| 2337 | * For integer types, the LLVMTypeRef parameter should correspond to a |
| 2338 | * llvm::IntegerType instance and the returned LLVMValueRef will |
| 2339 | * correspond to a llvm::ConstantInt. |
| 2340 | * |
| 2341 | * For floating point types, the LLVMTypeRef returned corresponds to a |
| 2342 | * llvm::ConstantFP. |
| 2343 | * |
| 2344 | * @{ |
| 2345 | */ |
| 2346 | |
| 2347 | /** |
| 2348 | * Obtain a constant value for an integer type. |
| 2349 | * |
| 2350 | * The returned value corresponds to a llvm::ConstantInt. |
| 2351 | * |
| 2352 | * @see llvm::ConstantInt::get() |
| 2353 | * |
| 2354 | * @param IntTy Integer type to obtain value of. |
| 2355 | * @param N The value the returned instance should refer to. |
| 2356 | * @param SignExtend Whether to sign extend the produced value. |
| 2357 | */ |
| 2358 | LLVM_C_ABI LLVMValueRef LLVMConstInt(LLVMTypeRef IntTy, unsigned long long N, |
| 2359 | LLVMBool SignExtend); |
| 2360 | |
| 2361 | /** |
| 2362 | * Obtain a constant value for an integer of arbitrary precision. |
| 2363 | * |
| 2364 | * @see llvm::ConstantInt::get() |
| 2365 | */ |
| 2366 | LLVM_C_ABI LLVMValueRef LLVMConstIntOfArbitraryPrecision( |
| 2367 | LLVMTypeRef IntTy, unsigned NumWords, const uint64_t Words[]); |
| 2368 | |
| 2369 | /** |
| 2370 | * Obtain a constant value for an integer parsed from a string. |
| 2371 | * |
| 2372 | * A similar API, LLVMConstIntOfStringAndSize is also available. If the |
| 2373 | * string's length is available, it is preferred to call that function |
| 2374 | * instead. |
| 2375 | * |
| 2376 | * @see llvm::ConstantInt::get() |
| 2377 | */ |
| 2378 | LLVM_C_ABI LLVMValueRef LLVMConstIntOfString(LLVMTypeRef IntTy, |
| 2379 | const char *Text, uint8_t Radix); |
| 2380 | |
| 2381 | /** |
| 2382 | * Obtain a constant value for an integer parsed from a string with |
| 2383 | * specified length. |
| 2384 | * |
| 2385 | * @see llvm::ConstantInt::get() |
| 2386 | */ |
| 2387 | LLVM_C_ABI LLVMValueRef LLVMConstIntOfStringAndSize(LLVMTypeRef IntTy, |
| 2388 | const char *Text, |
| 2389 | unsigned SLen, |
| 2390 | uint8_t Radix); |
| 2391 | |
| 2392 | /** |
| 2393 | * Obtain a constant value referring to a double floating point value. |
| 2394 | */ |
| 2395 | LLVM_C_ABI LLVMValueRef LLVMConstReal(LLVMTypeRef RealTy, double N); |
| 2396 | |
| 2397 | /** |
| 2398 | * Obtain a constant for a floating point value parsed from a string. |
| 2399 | * |
| 2400 | * A similar API, LLVMConstRealOfStringAndSize is also available. It |
| 2401 | * should be used if the input string's length is known. |
| 2402 | */ |
| 2403 | LLVM_C_ABI LLVMValueRef LLVMConstRealOfString(LLVMTypeRef RealTy, |
| 2404 | const char *Text); |
| 2405 | |
| 2406 | /** |
| 2407 | * Obtain a constant for a floating point value parsed from a string. |
| 2408 | */ |
| 2409 | LLVM_C_ABI LLVMValueRef LLVMConstRealOfStringAndSize(LLVMTypeRef RealTy, |
| 2410 | const char *Text, |
| 2411 | unsigned SLen); |
| 2412 | |
| 2413 | /** |
| 2414 | * Obtain a constant for a floating point value from array of 64 bit values. |
| 2415 | * The length of the array N must be ceildiv(bits, 64), where bits is the |
| 2416 | * scalar size in bits of the floating-point type. |
| 2417 | */ |
| 2418 | |
| 2419 | LLVM_C_ABI LLVMValueRef LLVMConstFPFromBits(LLVMTypeRef Ty, const uint64_t N[]); |
| 2420 | |
| 2421 | /** |
| 2422 | * Obtain the zero extended value for an integer constant value. |
| 2423 | * |
| 2424 | * @see llvm::ConstantInt::getZExtValue() |
| 2425 | */ |
| 2426 | LLVM_C_ABI unsigned long long |
| 2427 | LLVMConstIntGetZExtValue(LLVMValueRef ConstantVal); |
| 2428 | |
| 2429 | /** |
| 2430 | * Obtain the sign extended value for an integer constant value. |
| 2431 | * |
| 2432 | * @see llvm::ConstantInt::getSExtValue() |
| 2433 | */ |
| 2434 | LLVM_C_ABI long long LLVMConstIntGetSExtValue(LLVMValueRef ConstantVal); |
| 2435 | |
| 2436 | /** |
| 2437 | * Obtain the double value for an floating point constant value. |
| 2438 | * losesInfo indicates if some precision was lost in the conversion. |
| 2439 | * |
| 2440 | * @see llvm::ConstantFP::getDoubleValue |
| 2441 | */ |
| 2442 | LLVM_C_ABI double LLVMConstRealGetDouble(LLVMValueRef ConstantVal, |
| 2443 | LLVMBool *losesInfo); |
| 2444 | |
| 2445 | /** |
| 2446 | * @} |
| 2447 | */ |
| 2448 | |
| 2449 | /** |
| 2450 | * @defgroup LLVMCCoreValueConstantComposite Composite Constants |
| 2451 | * |
| 2452 | * Functions in this group operate on composite constants. |
| 2453 | * |
| 2454 | * @{ |
| 2455 | */ |
| 2456 | |
| 2457 | /** |
| 2458 | * Create a ConstantDataSequential and initialize it with a string. |
| 2459 | * |
| 2460 | * @deprecated LLVMConstStringInContext is deprecated in favor of the API |
| 2461 | * accurate LLVMConstStringInContext2 |
| 2462 | * @see llvm::ConstantDataArray::getString() |
| 2463 | */ |
| 2464 | LLVM_C_ABI LLVMValueRef LLVMConstStringInContext(LLVMContextRef C, |
| 2465 | const char *Str, |
| 2466 | unsigned Length, |
| 2467 | LLVMBool DontNullTerminate); |
| 2468 | |
| 2469 | /** |
| 2470 | * Create a ConstantDataSequential and initialize it with a string. |
| 2471 | * |
| 2472 | * @see llvm::ConstantDataArray::getString() |
| 2473 | */ |
| 2474 | LLVM_C_ABI LLVMValueRef LLVMConstStringInContext2(LLVMContextRef C, |
| 2475 | const char *Str, |
| 2476 | size_t Length, |
| 2477 | LLVMBool DontNullTerminate); |
| 2478 | |
| 2479 | /** |
| 2480 | * Create a ConstantDataSequential with string content in the global context. |
| 2481 | * |
| 2482 | * This is the same as LLVMConstStringInContext except it operates on the |
| 2483 | * global context. |
| 2484 | * |
| 2485 | * @see LLVMConstStringInContext() |
| 2486 | * @see llvm::ConstantDataArray::getString() |
| 2487 | */ |
| 2488 | LLVM_C_ABI LLVM_ATTRIBUTE_C_DEPRECATED( |
| 2489 | LLVMValueRef LLVMConstString(const char *Str, unsigned Length, |
| 2490 | LLVMBool DontNullTerminate), |
| 2491 | "Use of the global context is deprecated, use LLVMConstStringInContext2 " |
| 2492 | "instead" ); |
| 2493 | |
| 2494 | /** |
| 2495 | * Returns true if the specified constant is an array of i8. |
| 2496 | * |
| 2497 | * @see ConstantDataSequential::getAsString() |
| 2498 | */ |
| 2499 | LLVM_C_ABI LLVMBool LLVMIsConstantString(LLVMValueRef c); |
| 2500 | |
| 2501 | /** |
| 2502 | * Get the given constant data sequential as a string. |
| 2503 | * |
| 2504 | * @see ConstantDataSequential::getAsString() |
| 2505 | */ |
| 2506 | LLVM_C_ABI const char *LLVMGetAsString(LLVMValueRef c, size_t *Length); |
| 2507 | |
| 2508 | /** |
| 2509 | * Get the raw, underlying bytes of the given constant data sequential. |
| 2510 | * |
| 2511 | * This is the same as LLVMGetAsString except it works for all constant data |
| 2512 | * sequentials, not just i8 arrays. |
| 2513 | * |
| 2514 | * @see ConstantDataSequential::getRawDataValues() |
| 2515 | */ |
| 2516 | LLVM_C_ABI const char *LLVMGetRawDataValues(LLVMValueRef c, |
| 2517 | size_t *SizeInBytes); |
| 2518 | |
| 2519 | /** |
| 2520 | * Create an anonymous ConstantStruct with the specified values. |
| 2521 | * |
| 2522 | * @see llvm::ConstantStruct::getAnon() |
| 2523 | */ |
| 2524 | LLVM_C_ABI LLVMValueRef LLVMConstStructInContext(LLVMContextRef C, |
| 2525 | LLVMValueRef *ConstantVals, |
| 2526 | unsigned Count, |
| 2527 | LLVMBool Packed); |
| 2528 | |
| 2529 | /** |
| 2530 | * Create a ConstantStruct in the global Context. |
| 2531 | * |
| 2532 | * This is the same as LLVMConstStructInContext except it operates on the |
| 2533 | * global Context. |
| 2534 | * |
| 2535 | * @see LLVMConstStructInContext() |
| 2536 | */ |
| 2537 | LLVM_C_ABI LLVM_ATTRIBUTE_C_DEPRECATED( |
| 2538 | LLVMValueRef LLVMConstStruct(LLVMValueRef *ConstantVals, unsigned Count, |
| 2539 | LLVMBool Packed), |
| 2540 | "Use of the global context is deprecated, use LLVMConstStructInContext " |
| 2541 | "instead" ); |
| 2542 | |
| 2543 | /** |
| 2544 | * Create a ConstantArray from values. |
| 2545 | * |
| 2546 | * @deprecated LLVMConstArray is deprecated in favor of the API accurate |
| 2547 | * LLVMConstArray2 |
| 2548 | * @see llvm::ConstantArray::get() |
| 2549 | */ |
| 2550 | LLVM_C_ABI LLVMValueRef LLVMConstArray(LLVMTypeRef ElementTy, |
| 2551 | LLVMValueRef *ConstantVals, |
| 2552 | unsigned Length); |
| 2553 | |
| 2554 | /** |
| 2555 | * Create a ConstantArray from values. |
| 2556 | * |
| 2557 | * @see llvm::ConstantArray::get() |
| 2558 | */ |
| 2559 | LLVM_C_ABI LLVMValueRef LLVMConstArray2(LLVMTypeRef ElementTy, |
| 2560 | LLVMValueRef *ConstantVals, |
| 2561 | uint64_t Length); |
| 2562 | |
| 2563 | /** |
| 2564 | * Create a ConstantDataArray from raw values. |
| 2565 | * |
| 2566 | * ElementTy must be one of i8, i16, i32, i64, half, bfloat, float, or double. |
| 2567 | * Data points to a contiguous buffer of raw values in the host endianness. The |
| 2568 | * element count is inferred from the element type and the data size in bytes. |
| 2569 | * |
| 2570 | * @see llvm::ConstantDataArray::getRaw() |
| 2571 | */ |
| 2572 | LLVM_C_ABI LLVMValueRef LLVMConstDataArray(LLVMTypeRef ElementTy, |
| 2573 | const char *Data, |
| 2574 | size_t SizeInBytes); |
| 2575 | |
| 2576 | /** |
| 2577 | * Create a non-anonymous ConstantStruct from values. |
| 2578 | * |
| 2579 | * @see llvm::ConstantStruct::get() |
| 2580 | */ |
| 2581 | LLVM_C_ABI LLVMValueRef LLVMConstNamedStruct(LLVMTypeRef StructTy, |
| 2582 | LLVMValueRef *ConstantVals, |
| 2583 | unsigned Count); |
| 2584 | |
| 2585 | /** |
| 2586 | * Get element of a constant aggregate (struct, array or vector) at the |
| 2587 | * specified index. Returns null if the index is out of range, or it's not |
| 2588 | * possible to determine the element (e.g., because the constant is a |
| 2589 | * constant expression.) |
| 2590 | * |
| 2591 | * @see llvm::Constant::getAggregateElement() |
| 2592 | */ |
| 2593 | LLVM_C_ABI LLVMValueRef LLVMGetAggregateElement(LLVMValueRef C, unsigned Idx); |
| 2594 | |
| 2595 | /** |
| 2596 | * Get an element at specified index as a constant. |
| 2597 | * |
| 2598 | * @see ConstantDataSequential::getElementAsConstant() |
| 2599 | */ |
| 2600 | LLVM_C_ABI LLVM_ATTRIBUTE_C_DEPRECATED( |
| 2601 | LLVMValueRef LLVMGetElementAsConstant(LLVMValueRef C, unsigned idx), |
| 2602 | "Use LLVMGetAggregateElement instead" ); |
| 2603 | |
| 2604 | /** |
| 2605 | * Create a ConstantVector from values. |
| 2606 | * |
| 2607 | * @see llvm::ConstantVector::get() |
| 2608 | */ |
| 2609 | LLVM_C_ABI LLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals, |
| 2610 | unsigned Size); |
| 2611 | |
| 2612 | /** |
| 2613 | * Create a ConstantPtrAuth constant with the given values. |
| 2614 | * |
| 2615 | * @see llvm::ConstantPtrAuth::get() |
| 2616 | */ |
| 2617 | LLVM_C_ABI LLVMValueRef LLVMConstantPtrAuth(LLVMValueRef Ptr, LLVMValueRef Key, |
| 2618 | LLVMValueRef Disc, |
| 2619 | LLVMValueRef AddrDisc); |
| 2620 | |
| 2621 | /** |
| 2622 | * @} |
| 2623 | */ |
| 2624 | |
| 2625 | /** |
| 2626 | * @defgroup LLVMCCoreValueConstantExpressions Constant Expressions |
| 2627 | * |
| 2628 | * Functions in this group correspond to APIs on llvm::ConstantExpr. |
| 2629 | * |
| 2630 | * @see llvm::ConstantExpr. |
| 2631 | * |
| 2632 | * @{ |
| 2633 | */ |
| 2634 | LLVM_C_ABI LLVMOpcode LLVMGetConstOpcode(LLVMValueRef ConstantVal); |
| 2635 | LLVM_C_ABI LLVMValueRef LLVMAlignOf(LLVMTypeRef Ty); |
| 2636 | LLVM_C_ABI LLVMValueRef LLVMSizeOf(LLVMTypeRef Ty); |
| 2637 | LLVM_C_ABI LLVMValueRef LLVMConstNeg(LLVMValueRef ConstantVal); |
| 2638 | LLVM_C_ABI LLVMValueRef LLVMConstNSWNeg(LLVMValueRef ConstantVal); |
| 2639 | LLVM_C_ABI LLVM_ATTRIBUTE_C_DEPRECATED( |
| 2640 | LLVMValueRef LLVMConstNUWNeg(LLVMValueRef ConstantVal), |
| 2641 | "Use LLVMConstNull instead." ); |
| 2642 | LLVM_C_ABI LLVMValueRef LLVMConstNot(LLVMValueRef ConstantVal); |
| 2643 | LLVM_C_ABI LLVMValueRef LLVMConstAdd(LLVMValueRef LHSConstant, |
| 2644 | LLVMValueRef RHSConstant); |
| 2645 | LLVM_C_ABI LLVMValueRef LLVMConstNSWAdd(LLVMValueRef LHSConstant, |
| 2646 | LLVMValueRef RHSConstant); |
| 2647 | LLVM_C_ABI LLVMValueRef LLVMConstNUWAdd(LLVMValueRef LHSConstant, |
| 2648 | LLVMValueRef RHSConstant); |
| 2649 | LLVM_C_ABI LLVMValueRef LLVMConstSub(LLVMValueRef LHSConstant, |
| 2650 | LLVMValueRef RHSConstant); |
| 2651 | LLVM_C_ABI LLVMValueRef LLVMConstNSWSub(LLVMValueRef LHSConstant, |
| 2652 | LLVMValueRef RHSConstant); |
| 2653 | LLVM_C_ABI LLVMValueRef LLVMConstNUWSub(LLVMValueRef LHSConstant, |
| 2654 | LLVMValueRef RHSConstant); |
| 2655 | LLVM_C_ABI LLVMValueRef LLVMConstXor(LLVMValueRef LHSConstant, |
| 2656 | LLVMValueRef RHSConstant); |
| 2657 | LLVM_C_ABI LLVMValueRef LLVMConstGEP2(LLVMTypeRef Ty, LLVMValueRef ConstantVal, |
| 2658 | LLVMValueRef *ConstantIndices, |
| 2659 | unsigned NumIndices); |
| 2660 | LLVM_C_ABI LLVMValueRef LLVMConstInBoundsGEP2(LLVMTypeRef Ty, |
| 2661 | LLVMValueRef ConstantVal, |
| 2662 | LLVMValueRef *ConstantIndices, |
| 2663 | unsigned NumIndices); |
| 2664 | /** |
| 2665 | * Creates a constant GetElementPtr expression. Similar to LLVMConstGEP2, but |
| 2666 | * allows specifying the no-wrap flags. |
| 2667 | * |
| 2668 | * @see llvm::ConstantExpr::getGetElementPtr() |
| 2669 | */ |
| 2670 | LLVM_C_ABI LLVMValueRef LLVMConstGEPWithNoWrapFlags( |
| 2671 | LLVMTypeRef Ty, LLVMValueRef ConstantVal, LLVMValueRef *ConstantIndices, |
| 2672 | unsigned NumIndices, LLVMGEPNoWrapFlags NoWrapFlags); |
| 2673 | LLVM_C_ABI LLVMValueRef LLVMConstTrunc(LLVMValueRef ConstantVal, |
| 2674 | LLVMTypeRef ToType); |
| 2675 | LLVM_C_ABI LLVMValueRef LLVMConstPtrToInt(LLVMValueRef ConstantVal, |
| 2676 | LLVMTypeRef ToType); |
| 2677 | LLVM_C_ABI LLVMValueRef LLVMConstIntToPtr(LLVMValueRef ConstantVal, |
| 2678 | LLVMTypeRef ToType); |
| 2679 | LLVM_C_ABI LLVMValueRef LLVMConstBitCast(LLVMValueRef ConstantVal, |
| 2680 | LLVMTypeRef ToType); |
| 2681 | LLVM_C_ABI LLVMValueRef LLVMConstAddrSpaceCast(LLVMValueRef ConstantVal, |
| 2682 | LLVMTypeRef ToType); |
| 2683 | LLVM_C_ABI LLVMValueRef LLVMConstTruncOrBitCast(LLVMValueRef ConstantVal, |
| 2684 | LLVMTypeRef ToType); |
| 2685 | LLVM_C_ABI LLVMValueRef LLVMConstPointerCast(LLVMValueRef ConstantVal, |
| 2686 | LLVMTypeRef ToType); |
| 2687 | LLVM_C_ABI LLVMValueRef (LLVMValueRef VectorConstant, |
| 2688 | LLVMValueRef IndexConstant); |
| 2689 | LLVM_C_ABI LLVMValueRef LLVMConstInsertElement( |
| 2690 | LLVMValueRef VectorConstant, LLVMValueRef ElementValueConstant, |
| 2691 | LLVMValueRef IndexConstant); |
| 2692 | LLVM_C_ABI LLVMValueRef LLVMConstShuffleVector(LLVMValueRef VectorAConstant, |
| 2693 | LLVMValueRef VectorBConstant, |
| 2694 | LLVMValueRef MaskConstant); |
| 2695 | LLVM_C_ABI LLVMValueRef LLVMBlockAddress(LLVMValueRef F, LLVMBasicBlockRef BB); |
| 2696 | |
| 2697 | /** |
| 2698 | * Gets the function associated with a given BlockAddress constant value. |
| 2699 | */ |
| 2700 | LLVM_C_ABI LLVMValueRef LLVMGetBlockAddressFunction(LLVMValueRef BlockAddr); |
| 2701 | |
| 2702 | /** |
| 2703 | * Gets the basic block associated with a given BlockAddress constant value. |
| 2704 | */ |
| 2705 | LLVM_C_ABI LLVMBasicBlockRef |
| 2706 | LLVMGetBlockAddressBasicBlock(LLVMValueRef BlockAddr); |
| 2707 | |
| 2708 | /** Deprecated: Use LLVMGetInlineAsm instead. */ |
| 2709 | LLVM_C_ABI LLVMValueRef LLVMConstInlineAsm(LLVMTypeRef Ty, |
| 2710 | const char *AsmString, |
| 2711 | const char *Constraints, |
| 2712 | LLVMBool HasSideEffects, |
| 2713 | LLVMBool IsAlignStack); |
| 2714 | |
| 2715 | /** |
| 2716 | * @} |
| 2717 | */ |
| 2718 | |
| 2719 | /** |
| 2720 | * @defgroup LLVMCCoreValueConstantGlobals Global Values |
| 2721 | * |
| 2722 | * This group contains functions that operate on global values. Functions in |
| 2723 | * this group relate to functions in the llvm::GlobalValue class tree. |
| 2724 | * |
| 2725 | * @see llvm::GlobalValue |
| 2726 | * |
| 2727 | * @{ |
| 2728 | */ |
| 2729 | |
| 2730 | LLVM_C_ABI LLVMModuleRef LLVMGetGlobalParent(LLVMValueRef Global); |
| 2731 | LLVM_C_ABI LLVMBool LLVMIsDeclaration(LLVMValueRef Global); |
| 2732 | LLVM_C_ABI LLVMLinkage LLVMGetLinkage(LLVMValueRef Global); |
| 2733 | LLVM_C_ABI void LLVMSetLinkage(LLVMValueRef Global, LLVMLinkage Linkage); |
| 2734 | LLVM_C_ABI const char *LLVMGetSection(LLVMValueRef Global); |
| 2735 | LLVM_C_ABI void LLVMSetSection(LLVMValueRef Global, const char *Section); |
| 2736 | LLVM_C_ABI LLVMVisibility LLVMGetVisibility(LLVMValueRef Global); |
| 2737 | LLVM_C_ABI void LLVMSetVisibility(LLVMValueRef Global, LLVMVisibility Viz); |
| 2738 | LLVM_C_ABI LLVMDLLStorageClass LLVMGetDLLStorageClass(LLVMValueRef Global); |
| 2739 | LLVM_C_ABI void LLVMSetDLLStorageClass(LLVMValueRef Global, |
| 2740 | LLVMDLLStorageClass Class); |
| 2741 | LLVM_C_ABI LLVMUnnamedAddr LLVMGetUnnamedAddress(LLVMValueRef Global); |
| 2742 | LLVM_C_ABI void LLVMSetUnnamedAddress(LLVMValueRef Global, |
| 2743 | LLVMUnnamedAddr UnnamedAddr); |
| 2744 | |
| 2745 | /** |
| 2746 | * Returns the "value type" of a global value. This differs from the formal |
| 2747 | * type of a global value which is always a pointer type. |
| 2748 | * |
| 2749 | * @see llvm::GlobalValue::getValueType() |
| 2750 | * @see llvm::Function::getFunctionType() |
| 2751 | */ |
| 2752 | LLVM_C_ABI LLVMTypeRef LLVMGlobalGetValueType(LLVMValueRef Global); |
| 2753 | |
| 2754 | /** Deprecated: Use LLVMGetUnnamedAddress instead. */ |
| 2755 | LLVM_C_ABI LLVMBool LLVMHasUnnamedAddr(LLVMValueRef Global); |
| 2756 | /** Deprecated: Use LLVMSetUnnamedAddress instead. */ |
| 2757 | LLVM_C_ABI void LLVMSetUnnamedAddr(LLVMValueRef Global, |
| 2758 | LLVMBool HasUnnamedAddr); |
| 2759 | |
| 2760 | /** |
| 2761 | * @defgroup LLVMCCoreValueWithAlignment Values with alignment |
| 2762 | * |
| 2763 | * Functions in this group only apply to values with alignment, i.e. |
| 2764 | * global variables, load and store instructions. |
| 2765 | */ |
| 2766 | |
| 2767 | /** |
| 2768 | * Obtain the preferred alignment of the value. |
| 2769 | * @see llvm::AllocaInst::getAlignment() |
| 2770 | * @see llvm::LoadInst::getAlignment() |
| 2771 | * @see llvm::StoreInst::getAlignment() |
| 2772 | * @see llvm::AtomicRMWInst::setAlignment() |
| 2773 | * @see llvm::AtomicCmpXchgInst::setAlignment() |
| 2774 | * @see llvm::GlobalValue::getAlignment() |
| 2775 | */ |
| 2776 | LLVM_C_ABI unsigned LLVMGetAlignment(LLVMValueRef V); |
| 2777 | |
| 2778 | /** |
| 2779 | * Set the preferred alignment of the value. |
| 2780 | * @see llvm::AllocaInst::setAlignment() |
| 2781 | * @see llvm::LoadInst::setAlignment() |
| 2782 | * @see llvm::StoreInst::setAlignment() |
| 2783 | * @see llvm::AtomicRMWInst::setAlignment() |
| 2784 | * @see llvm::AtomicCmpXchgInst::setAlignment() |
| 2785 | * @see llvm::GlobalValue::setAlignment() |
| 2786 | */ |
| 2787 | LLVM_C_ABI void LLVMSetAlignment(LLVMValueRef V, unsigned Bytes); |
| 2788 | |
| 2789 | /** |
| 2790 | * Sets a metadata attachment, erasing the existing metadata attachment if |
| 2791 | * it already exists for the given kind. |
| 2792 | * |
| 2793 | * @see llvm::GlobalObject::setMetadata() |
| 2794 | */ |
| 2795 | LLVM_C_ABI void LLVMGlobalSetMetadata(LLVMValueRef Global, unsigned Kind, |
| 2796 | LLVMMetadataRef MD); |
| 2797 | |
| 2798 | /** |
| 2799 | * Adds a metadata attachment. |
| 2800 | * |
| 2801 | * @see llvm::GlobalObject::addMetadata() |
| 2802 | */ |
| 2803 | LLVM_C_ABI void LLVMGlobalAddMetadata(LLVMValueRef Global, unsigned Kind, |
| 2804 | LLVMMetadataRef MD); |
| 2805 | |
| 2806 | /** |
| 2807 | * Erases a metadata attachment of the given kind if it exists. |
| 2808 | * |
| 2809 | * @see llvm::GlobalObject::eraseMetadata() |
| 2810 | */ |
| 2811 | LLVM_C_ABI void LLVMGlobalEraseMetadata(LLVMValueRef Global, unsigned Kind); |
| 2812 | |
| 2813 | /** |
| 2814 | * Removes all metadata attachments from this value. |
| 2815 | * |
| 2816 | * @see llvm::GlobalObject::clearMetadata() |
| 2817 | */ |
| 2818 | LLVM_C_ABI void LLVMGlobalClearMetadata(LLVMValueRef Global); |
| 2819 | |
| 2820 | /** |
| 2821 | * Add debuginfo metadata to this global. |
| 2822 | * |
| 2823 | * @see llvm::GlobalVariable::addDebugInfo() |
| 2824 | */ |
| 2825 | LLVM_C_ABI void LLVMGlobalAddDebugInfo(LLVMValueRef Global, |
| 2826 | LLVMMetadataRef GVE); |
| 2827 | |
| 2828 | /** |
| 2829 | * Retrieves an array of metadata entries representing the metadata attached to |
| 2830 | * this value. The caller is responsible for freeing this array by calling |
| 2831 | * \c LLVMDisposeValueMetadataEntries. |
| 2832 | * |
| 2833 | * @see llvm::GlobalObject::getAllMetadata() |
| 2834 | */ |
| 2835 | LLVM_C_ABI LLVMValueMetadataEntry * |
| 2836 | LLVMGlobalCopyAllMetadata(LLVMValueRef Value, size_t *NumEntries); |
| 2837 | |
| 2838 | /** |
| 2839 | * Destroys value metadata entries. |
| 2840 | */ |
| 2841 | LLVM_C_ABI void |
| 2842 | LLVMDisposeValueMetadataEntries(LLVMValueMetadataEntry *Entries); |
| 2843 | |
| 2844 | /** |
| 2845 | * Returns the kind of a value metadata entry at a specific index. |
| 2846 | */ |
| 2847 | LLVM_C_ABI unsigned |
| 2848 | LLVMValueMetadataEntriesGetKind(LLVMValueMetadataEntry *Entries, |
| 2849 | unsigned Index); |
| 2850 | |
| 2851 | /** |
| 2852 | * Returns the underlying metadata node of a value metadata entry at a |
| 2853 | * specific index. |
| 2854 | */ |
| 2855 | LLVM_C_ABI LLVMMetadataRef LLVMValueMetadataEntriesGetMetadata( |
| 2856 | LLVMValueMetadataEntry *Entries, unsigned Index); |
| 2857 | |
| 2858 | /** |
| 2859 | * @} |
| 2860 | */ |
| 2861 | |
| 2862 | /** |
| 2863 | * @defgroup LLVMCoreValueConstantGlobalVariable Global Variables |
| 2864 | * |
| 2865 | * This group contains functions that operate on global variable values. |
| 2866 | * |
| 2867 | * @see llvm::GlobalVariable |
| 2868 | * |
| 2869 | * @{ |
| 2870 | */ |
| 2871 | LLVM_C_ABI LLVMValueRef LLVMAddGlobal(LLVMModuleRef M, LLVMTypeRef Ty, |
| 2872 | const char *Name); |
| 2873 | LLVM_C_ABI LLVMValueRef LLVMAddGlobalInAddressSpace(LLVMModuleRef M, |
| 2874 | LLVMTypeRef Ty, |
| 2875 | const char *Name, |
| 2876 | unsigned AddressSpace); |
| 2877 | LLVM_C_ABI LLVMValueRef LLVMGetNamedGlobal(LLVMModuleRef M, const char *Name); |
| 2878 | LLVM_C_ABI LLVMValueRef LLVMGetNamedGlobalWithLength(LLVMModuleRef M, |
| 2879 | const char *Name, |
| 2880 | size_t Length); |
| 2881 | LLVM_C_ABI LLVMValueRef LLVMGetFirstGlobal(LLVMModuleRef M); |
| 2882 | LLVM_C_ABI LLVMValueRef LLVMGetLastGlobal(LLVMModuleRef M); |
| 2883 | LLVM_C_ABI LLVMValueRef LLVMGetNextGlobal(LLVMValueRef GlobalVar); |
| 2884 | LLVM_C_ABI LLVMValueRef LLVMGetPreviousGlobal(LLVMValueRef GlobalVar); |
| 2885 | LLVM_C_ABI void LLVMDeleteGlobal(LLVMValueRef GlobalVar); |
| 2886 | LLVM_C_ABI LLVMValueRef LLVMGetInitializer(LLVMValueRef GlobalVar); |
| 2887 | LLVM_C_ABI void LLVMSetInitializer(LLVMValueRef GlobalVar, |
| 2888 | LLVMValueRef ConstantVal); |
| 2889 | LLVM_C_ABI LLVMBool LLVMIsThreadLocal(LLVMValueRef GlobalVar); |
| 2890 | LLVM_C_ABI void LLVMSetThreadLocal(LLVMValueRef GlobalVar, |
| 2891 | LLVMBool IsThreadLocal); |
| 2892 | LLVM_C_ABI LLVMBool LLVMIsGlobalConstant(LLVMValueRef GlobalVar); |
| 2893 | LLVM_C_ABI void LLVMSetGlobalConstant(LLVMValueRef GlobalVar, |
| 2894 | LLVMBool IsConstant); |
| 2895 | LLVM_C_ABI LLVMThreadLocalMode LLVMGetThreadLocalMode(LLVMValueRef GlobalVar); |
| 2896 | LLVM_C_ABI void LLVMSetThreadLocalMode(LLVMValueRef GlobalVar, |
| 2897 | LLVMThreadLocalMode Mode); |
| 2898 | LLVM_C_ABI LLVMBool LLVMIsExternallyInitialized(LLVMValueRef GlobalVar); |
| 2899 | LLVM_C_ABI void LLVMSetExternallyInitialized(LLVMValueRef GlobalVar, |
| 2900 | LLVMBool IsExtInit); |
| 2901 | |
| 2902 | /** |
| 2903 | * @} |
| 2904 | */ |
| 2905 | |
| 2906 | /** |
| 2907 | * @defgroup LLVMCoreValueConstantGlobalAlias Global Aliases |
| 2908 | * |
| 2909 | * This group contains function that operate on global alias values. |
| 2910 | * |
| 2911 | * @see llvm::GlobalAlias |
| 2912 | * |
| 2913 | * @{ |
| 2914 | */ |
| 2915 | |
| 2916 | /** |
| 2917 | * Add a GlobalAlias with the given value type, address space and aliasee. |
| 2918 | * |
| 2919 | * @see llvm::GlobalAlias::create() |
| 2920 | */ |
| 2921 | LLVM_C_ABI LLVMValueRef LLVMAddAlias2(LLVMModuleRef M, LLVMTypeRef ValueTy, |
| 2922 | unsigned AddrSpace, LLVMValueRef Aliasee, |
| 2923 | const char *Name); |
| 2924 | |
| 2925 | /** |
| 2926 | * Obtain a GlobalAlias value from a Module by its name. |
| 2927 | * |
| 2928 | * The returned value corresponds to a llvm::GlobalAlias value. |
| 2929 | * |
| 2930 | * @see llvm::Module::getNamedAlias() |
| 2931 | */ |
| 2932 | LLVM_C_ABI LLVMValueRef LLVMGetNamedGlobalAlias(LLVMModuleRef M, |
| 2933 | const char *Name, |
| 2934 | size_t NameLen); |
| 2935 | |
| 2936 | /** |
| 2937 | * Obtain an iterator to the first GlobalAlias in a Module. |
| 2938 | * |
| 2939 | * @see llvm::Module::alias_begin() |
| 2940 | */ |
| 2941 | LLVM_C_ABI LLVMValueRef LLVMGetFirstGlobalAlias(LLVMModuleRef M); |
| 2942 | |
| 2943 | /** |
| 2944 | * Obtain an iterator to the last GlobalAlias in a Module. |
| 2945 | * |
| 2946 | * @see llvm::Module::alias_end() |
| 2947 | */ |
| 2948 | LLVM_C_ABI LLVMValueRef LLVMGetLastGlobalAlias(LLVMModuleRef M); |
| 2949 | |
| 2950 | /** |
| 2951 | * Advance a GlobalAlias iterator to the next GlobalAlias. |
| 2952 | * |
| 2953 | * Returns NULL if the iterator was already at the end and there are no more |
| 2954 | * global aliases. |
| 2955 | */ |
| 2956 | LLVM_C_ABI LLVMValueRef LLVMGetNextGlobalAlias(LLVMValueRef GA); |
| 2957 | |
| 2958 | /** |
| 2959 | * Decrement a GlobalAlias iterator to the previous GlobalAlias. |
| 2960 | * |
| 2961 | * Returns NULL if the iterator was already at the beginning and there are |
| 2962 | * no previous global aliases. |
| 2963 | */ |
| 2964 | LLVM_C_ABI LLVMValueRef LLVMGetPreviousGlobalAlias(LLVMValueRef GA); |
| 2965 | |
| 2966 | /** |
| 2967 | * Retrieve the target value of an alias. |
| 2968 | */ |
| 2969 | LLVM_C_ABI LLVMValueRef LLVMAliasGetAliasee(LLVMValueRef Alias); |
| 2970 | |
| 2971 | /** |
| 2972 | * Set the target value of an alias. |
| 2973 | */ |
| 2974 | LLVM_C_ABI void LLVMAliasSetAliasee(LLVMValueRef Alias, LLVMValueRef Aliasee); |
| 2975 | |
| 2976 | /** |
| 2977 | * @} |
| 2978 | */ |
| 2979 | |
| 2980 | /** |
| 2981 | * @defgroup LLVMCCoreValueFunction Function values |
| 2982 | * |
| 2983 | * Functions in this group operate on LLVMValueRef instances that |
| 2984 | * correspond to llvm::Function instances. |
| 2985 | * |
| 2986 | * @see llvm::Function |
| 2987 | * |
| 2988 | * @{ |
| 2989 | */ |
| 2990 | |
| 2991 | /** |
| 2992 | * Remove a function from its containing module and deletes it. |
| 2993 | * |
| 2994 | * @see llvm::Function::eraseFromParent() |
| 2995 | */ |
| 2996 | LLVM_C_ABI void LLVMDeleteFunction(LLVMValueRef Fn); |
| 2997 | |
| 2998 | /** |
| 2999 | * Check whether the given function has a personality function. |
| 3000 | * |
| 3001 | * @see llvm::Function::hasPersonalityFn() |
| 3002 | */ |
| 3003 | LLVM_C_ABI LLVMBool LLVMHasPersonalityFn(LLVMValueRef Fn); |
| 3004 | |
| 3005 | /** |
| 3006 | * Obtain the personality function attached to the function. |
| 3007 | * |
| 3008 | * @see llvm::Function::getPersonalityFn() |
| 3009 | */ |
| 3010 | LLVM_C_ABI LLVMValueRef LLVMGetPersonalityFn(LLVMValueRef Fn); |
| 3011 | |
| 3012 | /** |
| 3013 | * Set the personality function attached to the function. |
| 3014 | * |
| 3015 | * @see llvm::Function::setPersonalityFn() |
| 3016 | */ |
| 3017 | LLVM_C_ABI void LLVMSetPersonalityFn(LLVMValueRef Fn, |
| 3018 | LLVMValueRef PersonalityFn); |
| 3019 | |
| 3020 | /** |
| 3021 | * Obtain the intrinsic ID number which matches the given function name. |
| 3022 | * |
| 3023 | * @see llvm::Intrinsic::lookupIntrinsicID() |
| 3024 | */ |
| 3025 | LLVM_C_ABI unsigned LLVMLookupIntrinsicID(const char *Name, size_t NameLen); |
| 3026 | |
| 3027 | /** |
| 3028 | * Obtain the ID number from a function instance. |
| 3029 | * |
| 3030 | * @see llvm::Function::getIntrinsicID() |
| 3031 | */ |
| 3032 | LLVM_C_ABI unsigned LLVMGetIntrinsicID(LLVMValueRef Fn); |
| 3033 | |
| 3034 | /** |
| 3035 | * Get or insert the declaration of an intrinsic. For overloaded intrinsics, |
| 3036 | * parameter types must be provided to uniquely identify an overload. |
| 3037 | * |
| 3038 | * @see llvm::Intrinsic::getOrInsertDeclaration() |
| 3039 | */ |
| 3040 | LLVM_C_ABI LLVMValueRef LLVMGetIntrinsicDeclaration(LLVMModuleRef Mod, |
| 3041 | unsigned ID, |
| 3042 | LLVMTypeRef *ParamTypes, |
| 3043 | size_t ParamCount); |
| 3044 | |
| 3045 | /** |
| 3046 | * Retrieves the type of an intrinsic. For overloaded intrinsics, parameter |
| 3047 | * types must be provided to uniquely identify an overload. |
| 3048 | * |
| 3049 | * @see llvm::Intrinsic::getType() |
| 3050 | */ |
| 3051 | LLVM_C_ABI LLVMTypeRef LLVMIntrinsicGetType(LLVMContextRef Ctx, unsigned ID, |
| 3052 | LLVMTypeRef *ParamTypes, |
| 3053 | size_t ParamCount); |
| 3054 | |
| 3055 | /** |
| 3056 | * Retrieves the name of an intrinsic. |
| 3057 | * |
| 3058 | * @see llvm::Intrinsic::getName() |
| 3059 | */ |
| 3060 | LLVM_C_ABI const char *LLVMIntrinsicGetName(unsigned ID, size_t *NameLength); |
| 3061 | |
| 3062 | /** Deprecated: Use LLVMIntrinsicCopyOverloadedName2 instead. */ |
| 3063 | LLVM_C_ABI char *LLVMIntrinsicCopyOverloadedName(unsigned ID, |
| 3064 | LLVMTypeRef *ParamTypes, |
| 3065 | size_t ParamCount, |
| 3066 | size_t *NameLength); |
| 3067 | |
| 3068 | /** |
| 3069 | * Copies the name of an overloaded intrinsic identified by a given list of |
| 3070 | * parameter types. |
| 3071 | * |
| 3072 | * Unlike LLVMIntrinsicGetName, the caller is responsible for freeing the |
| 3073 | * returned string. |
| 3074 | * |
| 3075 | * This version also supports unnamed types. |
| 3076 | * |
| 3077 | * @see llvm::Intrinsic::getName() |
| 3078 | */ |
| 3079 | LLVM_C_ABI char *LLVMIntrinsicCopyOverloadedName2(LLVMModuleRef Mod, |
| 3080 | unsigned ID, |
| 3081 | LLVMTypeRef *ParamTypes, |
| 3082 | size_t ParamCount, |
| 3083 | size_t *NameLength); |
| 3084 | |
| 3085 | /** |
| 3086 | * Obtain if the intrinsic identified by the given ID is overloaded. |
| 3087 | * |
| 3088 | * @see llvm::Intrinsic::isOverloaded() |
| 3089 | */ |
| 3090 | LLVM_C_ABI LLVMBool LLVMIntrinsicIsOverloaded(unsigned ID); |
| 3091 | |
| 3092 | /** |
| 3093 | * Obtain the calling function of a function. |
| 3094 | * |
| 3095 | * The returned value corresponds to the LLVMCallConv enumeration. |
| 3096 | * |
| 3097 | * @see llvm::Function::getCallingConv() |
| 3098 | */ |
| 3099 | LLVM_C_ABI unsigned LLVMGetFunctionCallConv(LLVMValueRef Fn); |
| 3100 | |
| 3101 | /** |
| 3102 | * Set the calling convention of a function. |
| 3103 | * |
| 3104 | * @see llvm::Function::setCallingConv() |
| 3105 | * |
| 3106 | * @param Fn Function to operate on |
| 3107 | * @param CC LLVMCallConv to set calling convention to |
| 3108 | */ |
| 3109 | LLVM_C_ABI void LLVMSetFunctionCallConv(LLVMValueRef Fn, unsigned CC); |
| 3110 | |
| 3111 | /** |
| 3112 | * Obtain the name of the garbage collector to use during code |
| 3113 | * generation. |
| 3114 | * |
| 3115 | * @see llvm::Function::getGC() |
| 3116 | */ |
| 3117 | LLVM_C_ABI const char *LLVMGetGC(LLVMValueRef Fn); |
| 3118 | |
| 3119 | /** |
| 3120 | * Define the garbage collector to use during code generation. |
| 3121 | * |
| 3122 | * @see llvm::Function::setGC() |
| 3123 | */ |
| 3124 | LLVM_C_ABI void LLVMSetGC(LLVMValueRef Fn, const char *Name); |
| 3125 | |
| 3126 | /** |
| 3127 | * Gets the prefix data associated with a function. Only valid on functions, and |
| 3128 | * only if LLVMHasPrefixData returns true. |
| 3129 | * See https://llvm.org/docs/LangRef.html#prefix-data |
| 3130 | */ |
| 3131 | LLVM_C_ABI LLVMValueRef LLVMGetPrefixData(LLVMValueRef Fn); |
| 3132 | |
| 3133 | /** |
| 3134 | * Check if a given function has prefix data. Only valid on functions. |
| 3135 | * See https://llvm.org/docs/LangRef.html#prefix-data |
| 3136 | */ |
| 3137 | LLVM_C_ABI LLVMBool LLVMHasPrefixData(LLVMValueRef Fn); |
| 3138 | |
| 3139 | /** |
| 3140 | * Sets the prefix data for the function. Only valid on functions. |
| 3141 | * See https://llvm.org/docs/LangRef.html#prefix-data |
| 3142 | */ |
| 3143 | LLVM_C_ABI void LLVMSetPrefixData(LLVMValueRef Fn, LLVMValueRef prefixData); |
| 3144 | |
| 3145 | /** |
| 3146 | * Gets the prologue data associated with a function. Only valid on functions, |
| 3147 | * and only if LLVMHasPrologueData returns true. |
| 3148 | * See https://llvm.org/docs/LangRef.html#prologue-data |
| 3149 | */ |
| 3150 | LLVM_C_ABI LLVMValueRef LLVMGetPrologueData(LLVMValueRef Fn); |
| 3151 | |
| 3152 | /** |
| 3153 | * Check if a given function has prologue data. Only valid on functions. |
| 3154 | * See https://llvm.org/docs/LangRef.html#prologue-data |
| 3155 | */ |
| 3156 | LLVM_C_ABI LLVMBool LLVMHasPrologueData(LLVMValueRef Fn); |
| 3157 | |
| 3158 | /** |
| 3159 | * Sets the prologue data for the function. Only valid on functions. |
| 3160 | * See https://llvm.org/docs/LangRef.html#prologue-data |
| 3161 | */ |
| 3162 | LLVM_C_ABI void LLVMSetPrologueData(LLVMValueRef Fn, LLVMValueRef prologueData); |
| 3163 | |
| 3164 | /** |
| 3165 | * Add an attribute to a function. |
| 3166 | * |
| 3167 | * @see llvm::Function::addAttribute() |
| 3168 | */ |
| 3169 | LLVM_C_ABI void LLVMAddAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx, |
| 3170 | LLVMAttributeRef A); |
| 3171 | LLVM_C_ABI unsigned LLVMGetAttributeCountAtIndex(LLVMValueRef F, |
| 3172 | LLVMAttributeIndex Idx); |
| 3173 | LLVM_C_ABI void LLVMGetAttributesAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx, |
| 3174 | LLVMAttributeRef *Attrs); |
| 3175 | LLVM_C_ABI LLVMAttributeRef LLVMGetEnumAttributeAtIndex(LLVMValueRef F, |
| 3176 | LLVMAttributeIndex Idx, |
| 3177 | unsigned KindID); |
| 3178 | LLVM_C_ABI LLVMAttributeRef LLVMGetStringAttributeAtIndex( |
| 3179 | LLVMValueRef F, LLVMAttributeIndex Idx, const char *K, unsigned KLen); |
| 3180 | LLVM_C_ABI void LLVMRemoveEnumAttributeAtIndex(LLVMValueRef F, |
| 3181 | LLVMAttributeIndex Idx, |
| 3182 | unsigned KindID); |
| 3183 | LLVM_C_ABI void LLVMRemoveStringAttributeAtIndex(LLVMValueRef F, |
| 3184 | LLVMAttributeIndex Idx, |
| 3185 | const char *K, unsigned KLen); |
| 3186 | |
| 3187 | /** |
| 3188 | * Add a target-dependent attribute to a function |
| 3189 | * @see llvm::AttrBuilder::addAttribute() |
| 3190 | */ |
| 3191 | LLVM_C_ABI void LLVMAddTargetDependentFunctionAttr(LLVMValueRef Fn, |
| 3192 | const char *A, |
| 3193 | const char *V); |
| 3194 | |
| 3195 | /** |
| 3196 | * @defgroup LLVMCCoreValueFunctionParameters Function Parameters |
| 3197 | * |
| 3198 | * Functions in this group relate to arguments/parameters on functions. |
| 3199 | * |
| 3200 | * Functions in this group expect LLVMValueRef instances that correspond |
| 3201 | * to llvm::Function instances. |
| 3202 | * |
| 3203 | * @{ |
| 3204 | */ |
| 3205 | |
| 3206 | /** |
| 3207 | * Obtain the number of parameters in a function. |
| 3208 | * |
| 3209 | * @see llvm::Function::arg_size() |
| 3210 | */ |
| 3211 | LLVM_C_ABI unsigned LLVMCountParams(LLVMValueRef Fn); |
| 3212 | |
| 3213 | /** |
| 3214 | * Obtain the parameters in a function. |
| 3215 | * |
| 3216 | * The takes a pointer to a pre-allocated array of LLVMValueRef that is |
| 3217 | * at least LLVMCountParams() long. This array will be filled with |
| 3218 | * LLVMValueRef instances which correspond to the parameters the |
| 3219 | * function receives. Each LLVMValueRef corresponds to a llvm::Argument |
| 3220 | * instance. |
| 3221 | * |
| 3222 | * @see llvm::Function::arg_begin() |
| 3223 | */ |
| 3224 | LLVM_C_ABI void LLVMGetParams(LLVMValueRef Fn, LLVMValueRef *Params); |
| 3225 | |
| 3226 | /** |
| 3227 | * Obtain the parameter at the specified index. |
| 3228 | * |
| 3229 | * Parameters are indexed from 0. |
| 3230 | * |
| 3231 | * @see llvm::Function::arg_begin() |
| 3232 | */ |
| 3233 | LLVM_C_ABI LLVMValueRef LLVMGetParam(LLVMValueRef Fn, unsigned Index); |
| 3234 | |
| 3235 | /** |
| 3236 | * Obtain the function to which this argument belongs. |
| 3237 | * |
| 3238 | * Unlike other functions in this group, this one takes an LLVMValueRef |
| 3239 | * that corresponds to a llvm::Attribute. |
| 3240 | * |
| 3241 | * The returned LLVMValueRef is the llvm::Function to which this |
| 3242 | * argument belongs. |
| 3243 | */ |
| 3244 | LLVM_C_ABI LLVMValueRef LLVMGetParamParent(LLVMValueRef Inst); |
| 3245 | |
| 3246 | /** |
| 3247 | * Obtain the first parameter to a function. |
| 3248 | * |
| 3249 | * @see llvm::Function::arg_begin() |
| 3250 | */ |
| 3251 | LLVM_C_ABI LLVMValueRef LLVMGetFirstParam(LLVMValueRef Fn); |
| 3252 | |
| 3253 | /** |
| 3254 | * Obtain the last parameter to a function. |
| 3255 | * |
| 3256 | * @see llvm::Function::arg_end() |
| 3257 | */ |
| 3258 | LLVM_C_ABI LLVMValueRef LLVMGetLastParam(LLVMValueRef Fn); |
| 3259 | |
| 3260 | /** |
| 3261 | * Obtain the next parameter to a function. |
| 3262 | * |
| 3263 | * This takes an LLVMValueRef obtained from LLVMGetFirstParam() (which is |
| 3264 | * actually a wrapped iterator) and obtains the next parameter from the |
| 3265 | * underlying iterator. |
| 3266 | */ |
| 3267 | LLVM_C_ABI LLVMValueRef LLVMGetNextParam(LLVMValueRef Arg); |
| 3268 | |
| 3269 | /** |
| 3270 | * Obtain the previous parameter to a function. |
| 3271 | * |
| 3272 | * This is the opposite of LLVMGetNextParam(). |
| 3273 | */ |
| 3274 | LLVM_C_ABI LLVMValueRef LLVMGetPreviousParam(LLVMValueRef Arg); |
| 3275 | |
| 3276 | /** |
| 3277 | * Set the alignment for a function parameter. |
| 3278 | * |
| 3279 | * @see llvm::Argument::addAttr() |
| 3280 | * @see llvm::AttrBuilder::addAlignmentAttr() |
| 3281 | */ |
| 3282 | LLVM_C_ABI void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned Align); |
| 3283 | |
| 3284 | /** |
| 3285 | * @} |
| 3286 | */ |
| 3287 | |
| 3288 | /** |
| 3289 | * @defgroup LLVMCCoreValueGlobalIFunc IFuncs |
| 3290 | * |
| 3291 | * Functions in this group relate to indirect functions. |
| 3292 | * |
| 3293 | * Functions in this group expect LLVMValueRef instances that correspond |
| 3294 | * to llvm::GlobalIFunc instances. |
| 3295 | * |
| 3296 | * @{ |
| 3297 | */ |
| 3298 | |
| 3299 | /** |
| 3300 | * Add a global indirect function to a module under a specified name. |
| 3301 | * |
| 3302 | * @see llvm::GlobalIFunc::create() |
| 3303 | */ |
| 3304 | LLVM_C_ABI LLVMValueRef LLVMAddGlobalIFunc(LLVMModuleRef M, const char *Name, |
| 3305 | size_t NameLen, LLVMTypeRef Ty, |
| 3306 | unsigned AddrSpace, |
| 3307 | LLVMValueRef Resolver); |
| 3308 | |
| 3309 | /** |
| 3310 | * Obtain a GlobalIFunc value from a Module by its name. |
| 3311 | * |
| 3312 | * The returned value corresponds to a llvm::GlobalIFunc value. |
| 3313 | * |
| 3314 | * @see llvm::Module::getNamedIFunc() |
| 3315 | */ |
| 3316 | LLVM_C_ABI LLVMValueRef LLVMGetNamedGlobalIFunc(LLVMModuleRef M, |
| 3317 | const char *Name, |
| 3318 | size_t NameLen); |
| 3319 | |
| 3320 | /** |
| 3321 | * Obtain an iterator to the first GlobalIFunc in a Module. |
| 3322 | * |
| 3323 | * @see llvm::Module::ifunc_begin() |
| 3324 | */ |
| 3325 | LLVM_C_ABI LLVMValueRef LLVMGetFirstGlobalIFunc(LLVMModuleRef M); |
| 3326 | |
| 3327 | /** |
| 3328 | * Obtain an iterator to the last GlobalIFunc in a Module. |
| 3329 | * |
| 3330 | * @see llvm::Module::ifunc_end() |
| 3331 | */ |
| 3332 | LLVM_C_ABI LLVMValueRef LLVMGetLastGlobalIFunc(LLVMModuleRef M); |
| 3333 | |
| 3334 | /** |
| 3335 | * Advance a GlobalIFunc iterator to the next GlobalIFunc. |
| 3336 | * |
| 3337 | * Returns NULL if the iterator was already at the end and there are no more |
| 3338 | * global aliases. |
| 3339 | */ |
| 3340 | LLVM_C_ABI LLVMValueRef LLVMGetNextGlobalIFunc(LLVMValueRef IFunc); |
| 3341 | |
| 3342 | /** |
| 3343 | * Decrement a GlobalIFunc iterator to the previous GlobalIFunc. |
| 3344 | * |
| 3345 | * Returns NULL if the iterator was already at the beginning and there are |
| 3346 | * no previous global aliases. |
| 3347 | */ |
| 3348 | LLVM_C_ABI LLVMValueRef LLVMGetPreviousGlobalIFunc(LLVMValueRef IFunc); |
| 3349 | |
| 3350 | /** |
| 3351 | * Retrieves the resolver function associated with this indirect function, or |
| 3352 | * NULL if it doesn't not exist. |
| 3353 | * |
| 3354 | * @see llvm::GlobalIFunc::getResolver() |
| 3355 | */ |
| 3356 | LLVM_C_ABI LLVMValueRef LLVMGetGlobalIFuncResolver(LLVMValueRef IFunc); |
| 3357 | |
| 3358 | /** |
| 3359 | * Sets the resolver function associated with this indirect function. |
| 3360 | * |
| 3361 | * @see llvm::GlobalIFunc::setResolver() |
| 3362 | */ |
| 3363 | LLVM_C_ABI void LLVMSetGlobalIFuncResolver(LLVMValueRef IFunc, |
| 3364 | LLVMValueRef Resolver); |
| 3365 | |
| 3366 | /** |
| 3367 | * Remove a global indirect function from its parent module and delete it. |
| 3368 | * |
| 3369 | * @see llvm::GlobalIFunc::eraseFromParent() |
| 3370 | */ |
| 3371 | LLVM_C_ABI void LLVMEraseGlobalIFunc(LLVMValueRef IFunc); |
| 3372 | |
| 3373 | /** |
| 3374 | * Remove a global indirect function from its parent module. |
| 3375 | * |
| 3376 | * This unlinks the global indirect function from its containing module but |
| 3377 | * keeps it alive. |
| 3378 | * |
| 3379 | * @see llvm::GlobalIFunc::removeFromParent() |
| 3380 | */ |
| 3381 | LLVM_C_ABI void LLVMRemoveGlobalIFunc(LLVMValueRef IFunc); |
| 3382 | |
| 3383 | /** |
| 3384 | * @} |
| 3385 | */ |
| 3386 | |
| 3387 | /** |
| 3388 | * @} |
| 3389 | */ |
| 3390 | |
| 3391 | /** |
| 3392 | * @} |
| 3393 | */ |
| 3394 | |
| 3395 | /** |
| 3396 | * @} |
| 3397 | */ |
| 3398 | |
| 3399 | /** |
| 3400 | * @defgroup LLVMCCoreValueMetadata Metadata |
| 3401 | * |
| 3402 | * @{ |
| 3403 | */ |
| 3404 | |
| 3405 | /** |
| 3406 | * Create an MDString value from a given string value. |
| 3407 | * |
| 3408 | * The MDString value does not take ownership of the given string, it remains |
| 3409 | * the responsibility of the caller to free it. |
| 3410 | * |
| 3411 | * @see llvm::MDString::get() |
| 3412 | */ |
| 3413 | LLVM_C_ABI LLVMMetadataRef LLVMMDStringInContext2(LLVMContextRef C, |
| 3414 | const char *Str, size_t SLen); |
| 3415 | |
| 3416 | /** |
| 3417 | * Create an MDNode value with the given array of operands. |
| 3418 | * |
| 3419 | * @see llvm::MDNode::get() |
| 3420 | */ |
| 3421 | LLVM_C_ABI LLVMMetadataRef LLVMMDNodeInContext2(LLVMContextRef C, |
| 3422 | LLVMMetadataRef *MDs, |
| 3423 | size_t Count); |
| 3424 | |
| 3425 | /** |
| 3426 | * Obtain a Metadata as a Value. |
| 3427 | */ |
| 3428 | LLVM_C_ABI LLVMValueRef LLVMMetadataAsValue(LLVMContextRef C, |
| 3429 | LLVMMetadataRef MD); |
| 3430 | |
| 3431 | /** |
| 3432 | * Obtain a Value as a Metadata. |
| 3433 | */ |
| 3434 | LLVM_C_ABI LLVMMetadataRef LLVMValueAsMetadata(LLVMValueRef Val); |
| 3435 | |
| 3436 | /** |
| 3437 | * Obtain the underlying string from a MDString value. |
| 3438 | * |
| 3439 | * @param V Instance to obtain string from. |
| 3440 | * @param Length Memory address which will hold length of returned string. |
| 3441 | * @return String data in MDString. |
| 3442 | */ |
| 3443 | LLVM_C_ABI const char *LLVMGetMDString(LLVMValueRef V, unsigned *Length); |
| 3444 | |
| 3445 | /** |
| 3446 | * Obtain the number of operands from an MDNode value. |
| 3447 | * |
| 3448 | * @param V MDNode to get number of operands from. |
| 3449 | * @return Number of operands of the MDNode. |
| 3450 | */ |
| 3451 | LLVM_C_ABI unsigned LLVMGetMDNodeNumOperands(LLVMValueRef V); |
| 3452 | |
| 3453 | /** |
| 3454 | * Obtain the given MDNode's operands. |
| 3455 | * |
| 3456 | * The passed LLVMValueRef pointer should point to enough memory to hold all of |
| 3457 | * the operands of the given MDNode (see LLVMGetMDNodeNumOperands) as |
| 3458 | * LLVMValueRefs. This memory will be populated with the LLVMValueRefs of the |
| 3459 | * MDNode's operands. |
| 3460 | * |
| 3461 | * @param V MDNode to get the operands from. |
| 3462 | * @param Dest Destination array for operands. |
| 3463 | */ |
| 3464 | LLVM_C_ABI void LLVMGetMDNodeOperands(LLVMValueRef V, LLVMValueRef *Dest); |
| 3465 | |
| 3466 | /** |
| 3467 | * Replace an operand at a specific index in a llvm::MDNode value. |
| 3468 | * |
| 3469 | * @see llvm::MDNode::replaceOperandWith() |
| 3470 | */ |
| 3471 | LLVM_C_ABI void LLVMReplaceMDNodeOperandWith(LLVMValueRef V, unsigned Index, |
| 3472 | LLVMMetadataRef Replacement); |
| 3473 | |
| 3474 | /** Deprecated: Use LLVMMDStringInContext2 instead. */ |
| 3475 | LLVM_C_ABI LLVMValueRef LLVMMDStringInContext(LLVMContextRef C, const char *Str, |
| 3476 | unsigned SLen); |
| 3477 | /** Deprecated: Use LLVMMDStringInContext2 instead. */ |
| 3478 | LLVM_C_ABI LLVM_ATTRIBUTE_C_DEPRECATED( |
| 3479 | LLVMValueRef LLVMMDString(const char *Str, unsigned SLen), |
| 3480 | "Use of the global context is deprecated, use LLVMMDStringInContext2 " |
| 3481 | "instead" ); |
| 3482 | /** Deprecated: Use LLVMMDNodeInContext2 instead. */ |
| 3483 | LLVM_C_ABI LLVMValueRef LLVMMDNodeInContext(LLVMContextRef C, |
| 3484 | LLVMValueRef *Vals, unsigned Count); |
| 3485 | /** Deprecated: Use LLVMMDNodeInContext2 instead. */ |
| 3486 | LLVM_C_ABI LLVM_ATTRIBUTE_C_DEPRECATED( |
| 3487 | LLVMValueRef LLVMMDNode(LLVMValueRef *Vals, unsigned Count), |
| 3488 | "Use of the global context is deprecated, use LLVMMDNodeInContext2 " |
| 3489 | "instead" ); |
| 3490 | |
| 3491 | /** |
| 3492 | * @} |
| 3493 | */ |
| 3494 | |
| 3495 | /** |
| 3496 | * @defgroup LLVMCCoreOperandBundle Operand Bundles |
| 3497 | * |
| 3498 | * Functions in this group operate on LLVMOperandBundleRef instances that |
| 3499 | * correspond to llvm::OperandBundleDef instances. |
| 3500 | * |
| 3501 | * @see llvm::OperandBundleDef |
| 3502 | * |
| 3503 | * @{ |
| 3504 | */ |
| 3505 | |
| 3506 | /** |
| 3507 | * Create a new operand bundle. |
| 3508 | * |
| 3509 | * Every invocation should be paired with LLVMDisposeOperandBundle() or memory |
| 3510 | * will be leaked. |
| 3511 | * |
| 3512 | * @param Tag Tag name of the operand bundle |
| 3513 | * @param TagLen Length of Tag |
| 3514 | * @param Args Memory address of an array of bundle operands |
| 3515 | * @param NumArgs Length of Args |
| 3516 | */ |
| 3517 | LLVM_C_ABI LLVMOperandBundleRef LLVMCreateOperandBundle(const char *Tag, |
| 3518 | size_t TagLen, |
| 3519 | LLVMValueRef *Args, |
| 3520 | unsigned NumArgs); |
| 3521 | |
| 3522 | /** |
| 3523 | * Destroy an operand bundle. |
| 3524 | * |
| 3525 | * This must be called for every created operand bundle or memory will be |
| 3526 | * leaked. |
| 3527 | */ |
| 3528 | LLVM_C_ABI void LLVMDisposeOperandBundle(LLVMOperandBundleRef Bundle); |
| 3529 | |
| 3530 | /** |
| 3531 | * Obtain the tag of an operand bundle as a string. |
| 3532 | * |
| 3533 | * @param Bundle Operand bundle to obtain tag of. |
| 3534 | * @param Len Out parameter which holds the length of the returned string. |
| 3535 | * @return The tag name of Bundle. |
| 3536 | * @see OperandBundleDef::getTag() |
| 3537 | */ |
| 3538 | LLVM_C_ABI const char *LLVMGetOperandBundleTag(LLVMOperandBundleRef Bundle, |
| 3539 | size_t *Len); |
| 3540 | |
| 3541 | /** |
| 3542 | * Obtain the number of operands for an operand bundle. |
| 3543 | * |
| 3544 | * @param Bundle Operand bundle to obtain operand count of. |
| 3545 | * @return The number of operands. |
| 3546 | * @see OperandBundleDef::input_size() |
| 3547 | */ |
| 3548 | LLVM_C_ABI unsigned LLVMGetNumOperandBundleArgs(LLVMOperandBundleRef Bundle); |
| 3549 | |
| 3550 | /** |
| 3551 | * Obtain the operand for an operand bundle at the given index. |
| 3552 | * |
| 3553 | * @param Bundle Operand bundle to obtain operand of. |
| 3554 | * @param Index An operand index, must be less than |
| 3555 | * LLVMGetNumOperandBundleArgs(). |
| 3556 | * @return The operand. |
| 3557 | */ |
| 3558 | LLVM_C_ABI LLVMValueRef |
| 3559 | LLVMGetOperandBundleArgAtIndex(LLVMOperandBundleRef Bundle, unsigned Index); |
| 3560 | |
| 3561 | /** |
| 3562 | * @} |
| 3563 | */ |
| 3564 | |
| 3565 | /** |
| 3566 | * @defgroup LLVMCCoreValueBasicBlock Basic Block |
| 3567 | * |
| 3568 | * A basic block represents a single entry single exit section of code. |
| 3569 | * Basic blocks contain a list of instructions which form the body of |
| 3570 | * the block. |
| 3571 | * |
| 3572 | * Basic blocks belong to functions. They have the type of label. |
| 3573 | * |
| 3574 | * Basic blocks are themselves values. However, the C API models them as |
| 3575 | * LLVMBasicBlockRef. |
| 3576 | * |
| 3577 | * @see llvm::BasicBlock |
| 3578 | * |
| 3579 | * @{ |
| 3580 | */ |
| 3581 | |
| 3582 | /** |
| 3583 | * Convert a basic block instance to a value type. |
| 3584 | */ |
| 3585 | LLVM_C_ABI LLVMValueRef LLVMBasicBlockAsValue(LLVMBasicBlockRef BB); |
| 3586 | |
| 3587 | /** |
| 3588 | * Determine whether an LLVMValueRef is itself a basic block. |
| 3589 | */ |
| 3590 | LLVM_C_ABI LLVMBool LLVMValueIsBasicBlock(LLVMValueRef Val); |
| 3591 | |
| 3592 | /** |
| 3593 | * Convert an LLVMValueRef to an LLVMBasicBlockRef instance. |
| 3594 | */ |
| 3595 | LLVM_C_ABI LLVMBasicBlockRef LLVMValueAsBasicBlock(LLVMValueRef Val); |
| 3596 | |
| 3597 | /** |
| 3598 | * Obtain the string name of a basic block. |
| 3599 | */ |
| 3600 | LLVM_C_ABI const char *LLVMGetBasicBlockName(LLVMBasicBlockRef BB); |
| 3601 | |
| 3602 | /** |
| 3603 | * Obtain the function to which a basic block belongs. |
| 3604 | * |
| 3605 | * @see llvm::BasicBlock::getParent() |
| 3606 | */ |
| 3607 | LLVM_C_ABI LLVMValueRef LLVMGetBasicBlockParent(LLVMBasicBlockRef BB); |
| 3608 | |
| 3609 | /** |
| 3610 | * Obtain the terminator instruction for a basic block. |
| 3611 | * |
| 3612 | * If the basic block does not have a terminator (it is not well-formed |
| 3613 | * if it doesn't), then NULL is returned. |
| 3614 | * |
| 3615 | * The returned LLVMValueRef corresponds to an llvm::Instruction. |
| 3616 | * |
| 3617 | * @see llvm::BasicBlock::getTerminator() |
| 3618 | */ |
| 3619 | LLVM_C_ABI LLVMValueRef LLVMGetBasicBlockTerminator(LLVMBasicBlockRef BB); |
| 3620 | |
| 3621 | /** |
| 3622 | * Obtain the number of basic blocks in a function. |
| 3623 | * |
| 3624 | * @param Fn Function value to operate on. |
| 3625 | */ |
| 3626 | LLVM_C_ABI unsigned LLVMCountBasicBlocks(LLVMValueRef Fn); |
| 3627 | |
| 3628 | /** |
| 3629 | * Obtain all of the basic blocks in a function. |
| 3630 | * |
| 3631 | * This operates on a function value. The BasicBlocks parameter is a |
| 3632 | * pointer to a pre-allocated array of LLVMBasicBlockRef of at least |
| 3633 | * LLVMCountBasicBlocks() in length. This array is populated with |
| 3634 | * LLVMBasicBlockRef instances. |
| 3635 | */ |
| 3636 | LLVM_C_ABI void LLVMGetBasicBlocks(LLVMValueRef Fn, |
| 3637 | LLVMBasicBlockRef *BasicBlocks); |
| 3638 | |
| 3639 | /** |
| 3640 | * Obtain the first basic block in a function. |
| 3641 | * |
| 3642 | * The returned basic block can be used as an iterator. You will likely |
| 3643 | * eventually call into LLVMGetNextBasicBlock() with it. |
| 3644 | * |
| 3645 | * @see llvm::Function::begin() |
| 3646 | */ |
| 3647 | LLVM_C_ABI LLVMBasicBlockRef LLVMGetFirstBasicBlock(LLVMValueRef Fn); |
| 3648 | |
| 3649 | /** |
| 3650 | * Obtain the last basic block in a function. |
| 3651 | * |
| 3652 | * @see llvm::Function::end() |
| 3653 | */ |
| 3654 | LLVM_C_ABI LLVMBasicBlockRef LLVMGetLastBasicBlock(LLVMValueRef Fn); |
| 3655 | |
| 3656 | /** |
| 3657 | * Advance a basic block iterator. |
| 3658 | */ |
| 3659 | LLVM_C_ABI LLVMBasicBlockRef LLVMGetNextBasicBlock(LLVMBasicBlockRef BB); |
| 3660 | |
| 3661 | /** |
| 3662 | * Go backwards in a basic block iterator. |
| 3663 | */ |
| 3664 | LLVM_C_ABI LLVMBasicBlockRef LLVMGetPreviousBasicBlock(LLVMBasicBlockRef BB); |
| 3665 | |
| 3666 | /** |
| 3667 | * Obtain the basic block that corresponds to the entry point of a |
| 3668 | * function. |
| 3669 | * |
| 3670 | * @see llvm::Function::getEntryBlock() |
| 3671 | */ |
| 3672 | LLVM_C_ABI LLVMBasicBlockRef LLVMGetEntryBasicBlock(LLVMValueRef Fn); |
| 3673 | |
| 3674 | /** |
| 3675 | * Insert the given basic block after the insertion point of the given builder. |
| 3676 | * |
| 3677 | * The insertion point must be valid. |
| 3678 | * |
| 3679 | * @see llvm::Function::BasicBlockListType::insertAfter() |
| 3680 | */ |
| 3681 | LLVM_C_ABI void |
| 3682 | LLVMInsertExistingBasicBlockAfterInsertBlock(LLVMBuilderRef Builder, |
| 3683 | LLVMBasicBlockRef BB); |
| 3684 | |
| 3685 | /** |
| 3686 | * Append the given basic block to the basic block list of the given function. |
| 3687 | * |
| 3688 | * @see llvm::Function::BasicBlockListType::push_back() |
| 3689 | */ |
| 3690 | LLVM_C_ABI void LLVMAppendExistingBasicBlock(LLVMValueRef Fn, |
| 3691 | LLVMBasicBlockRef BB); |
| 3692 | |
| 3693 | /** |
| 3694 | * Create a new basic block without inserting it into a function. |
| 3695 | * |
| 3696 | * @see llvm::BasicBlock::Create() |
| 3697 | */ |
| 3698 | LLVM_C_ABI LLVMBasicBlockRef LLVMCreateBasicBlockInContext(LLVMContextRef C, |
| 3699 | const char *Name); |
| 3700 | |
| 3701 | /** |
| 3702 | * Append a basic block to the end of a function. |
| 3703 | * |
| 3704 | * @see llvm::BasicBlock::Create() |
| 3705 | */ |
| 3706 | LLVM_C_ABI LLVMBasicBlockRef LLVMAppendBasicBlockInContext(LLVMContextRef C, |
| 3707 | LLVMValueRef Fn, |
| 3708 | const char *Name); |
| 3709 | |
| 3710 | /** |
| 3711 | * Append a basic block to the end of a function using the global |
| 3712 | * context. |
| 3713 | * |
| 3714 | * @see llvm::BasicBlock::Create() |
| 3715 | */ |
| 3716 | LLVM_C_ABI LLVM_ATTRIBUTE_C_DEPRECATED( |
| 3717 | LLVMBasicBlockRef LLVMAppendBasicBlock(LLVMValueRef Fn, const char *Name), |
| 3718 | "Use of the global context is deprecated, use " |
| 3719 | "LLVMAppendBasicBlockInContext instead" ); |
| 3720 | |
| 3721 | /** |
| 3722 | * Insert a basic block in a function before another basic block. |
| 3723 | * |
| 3724 | * The function to add to is determined by the function of the |
| 3725 | * passed basic block. |
| 3726 | * |
| 3727 | * @see llvm::BasicBlock::Create() |
| 3728 | */ |
| 3729 | LLVM_C_ABI LLVMBasicBlockRef LLVMInsertBasicBlockInContext(LLVMContextRef C, |
| 3730 | LLVMBasicBlockRef BB, |
| 3731 | const char *Name); |
| 3732 | |
| 3733 | /** |
| 3734 | * Insert a basic block in a function using the global context. |
| 3735 | * |
| 3736 | * @see llvm::BasicBlock::Create() |
| 3737 | */ |
| 3738 | LLVM_C_ABI LLVM_ATTRIBUTE_C_DEPRECATED( |
| 3739 | LLVMBasicBlockRef LLVMInsertBasicBlock(LLVMBasicBlockRef InsertBeforeBB, |
| 3740 | const char *Name), |
| 3741 | "Use of the global context is deprecated, use " |
| 3742 | "LLVMInsertBasicBlockInContext instead" ); |
| 3743 | |
| 3744 | /** |
| 3745 | * Remove a basic block from a function and delete it. |
| 3746 | * |
| 3747 | * This deletes the basic block from its containing function and deletes |
| 3748 | * the basic block itself. |
| 3749 | * |
| 3750 | * @see llvm::BasicBlock::eraseFromParent() |
| 3751 | */ |
| 3752 | LLVM_C_ABI void LLVMDeleteBasicBlock(LLVMBasicBlockRef BB); |
| 3753 | |
| 3754 | /** |
| 3755 | * Remove a basic block from a function. |
| 3756 | * |
| 3757 | * This deletes the basic block from its containing function but keep |
| 3758 | * the basic block alive. |
| 3759 | * |
| 3760 | * @see llvm::BasicBlock::removeFromParent() |
| 3761 | */ |
| 3762 | LLVM_C_ABI void LLVMRemoveBasicBlockFromParent(LLVMBasicBlockRef BB); |
| 3763 | |
| 3764 | /** |
| 3765 | * Move a basic block to before another one. |
| 3766 | * |
| 3767 | * @see llvm::BasicBlock::moveBefore() |
| 3768 | */ |
| 3769 | LLVM_C_ABI void LLVMMoveBasicBlockBefore(LLVMBasicBlockRef BB, |
| 3770 | LLVMBasicBlockRef MovePos); |
| 3771 | |
| 3772 | /** |
| 3773 | * Move a basic block to after another one. |
| 3774 | * |
| 3775 | * @see llvm::BasicBlock::moveAfter() |
| 3776 | */ |
| 3777 | LLVM_C_ABI void LLVMMoveBasicBlockAfter(LLVMBasicBlockRef BB, |
| 3778 | LLVMBasicBlockRef MovePos); |
| 3779 | |
| 3780 | /** |
| 3781 | * Obtain the first instruction in a basic block. |
| 3782 | * |
| 3783 | * The returned LLVMValueRef corresponds to a llvm::Instruction |
| 3784 | * instance. |
| 3785 | */ |
| 3786 | LLVM_C_ABI LLVMValueRef LLVMGetFirstInstruction(LLVMBasicBlockRef BB); |
| 3787 | |
| 3788 | /** |
| 3789 | * Obtain the last instruction in a basic block. |
| 3790 | * |
| 3791 | * The returned LLVMValueRef corresponds to an LLVM:Instruction. |
| 3792 | */ |
| 3793 | LLVM_C_ABI LLVMValueRef LLVMGetLastInstruction(LLVMBasicBlockRef BB); |
| 3794 | |
| 3795 | /** |
| 3796 | * @} |
| 3797 | */ |
| 3798 | |
| 3799 | /** |
| 3800 | * @defgroup LLVMCCoreValueInstruction Instructions |
| 3801 | * |
| 3802 | * Functions in this group relate to the inspection and manipulation of |
| 3803 | * individual instructions. |
| 3804 | * |
| 3805 | * In the C++ API, an instruction is modeled by llvm::Instruction. This |
| 3806 | * class has a large number of descendents. llvm::Instruction is a |
| 3807 | * llvm::Value and in the C API, instructions are modeled by |
| 3808 | * LLVMValueRef. |
| 3809 | * |
| 3810 | * This group also contains sub-groups which operate on specific |
| 3811 | * llvm::Instruction types, e.g. llvm::CallInst. |
| 3812 | * |
| 3813 | * @{ |
| 3814 | */ |
| 3815 | |
| 3816 | /** |
| 3817 | * Determine whether an instruction has any metadata attached. |
| 3818 | */ |
| 3819 | LLVM_C_ABI int LLVMHasMetadata(LLVMValueRef Val); |
| 3820 | |
| 3821 | /** |
| 3822 | * Return metadata associated with an instruction value. |
| 3823 | */ |
| 3824 | LLVM_C_ABI LLVMValueRef LLVMGetMetadata(LLVMValueRef Val, unsigned KindID); |
| 3825 | |
| 3826 | /** |
| 3827 | * Set metadata associated with an instruction value. |
| 3828 | */ |
| 3829 | LLVM_C_ABI void LLVMSetMetadata(LLVMValueRef Val, unsigned KindID, |
| 3830 | LLVMValueRef Node); |
| 3831 | |
| 3832 | /** |
| 3833 | * Returns the metadata associated with an instruction value, but filters out |
| 3834 | * all the debug locations. |
| 3835 | * |
| 3836 | * @see llvm::Instruction::getAllMetadataOtherThanDebugLoc() |
| 3837 | */ |
| 3838 | LLVM_C_ABI LLVMValueMetadataEntry * |
| 3839 | LLVMInstructionGetAllMetadataOtherThanDebugLoc(LLVMValueRef Instr, |
| 3840 | size_t *NumEntries); |
| 3841 | |
| 3842 | /** |
| 3843 | * Obtain the basic block to which an instruction belongs. |
| 3844 | * |
| 3845 | * @see llvm::Instruction::getParent() |
| 3846 | */ |
| 3847 | LLVM_C_ABI LLVMBasicBlockRef LLVMGetInstructionParent(LLVMValueRef Inst); |
| 3848 | |
| 3849 | /** |
| 3850 | * Obtain the instruction that occurs after the one specified. |
| 3851 | * |
| 3852 | * The next instruction will be from the same basic block. |
| 3853 | * |
| 3854 | * If this is the last instruction in a basic block, NULL will be |
| 3855 | * returned. |
| 3856 | */ |
| 3857 | LLVM_C_ABI LLVMValueRef LLVMGetNextInstruction(LLVMValueRef Inst); |
| 3858 | |
| 3859 | /** |
| 3860 | * Obtain the instruction that occurred before this one. |
| 3861 | * |
| 3862 | * If the instruction is the first instruction in a basic block, NULL |
| 3863 | * will be returned. |
| 3864 | */ |
| 3865 | LLVM_C_ABI LLVMValueRef LLVMGetPreviousInstruction(LLVMValueRef Inst); |
| 3866 | |
| 3867 | /** |
| 3868 | * Remove an instruction. |
| 3869 | * |
| 3870 | * The instruction specified is removed from its containing building |
| 3871 | * block but is kept alive. |
| 3872 | * |
| 3873 | * @see llvm::Instruction::removeFromParent() |
| 3874 | */ |
| 3875 | LLVM_C_ABI void LLVMInstructionRemoveFromParent(LLVMValueRef Inst); |
| 3876 | |
| 3877 | /** |
| 3878 | * Remove and delete an instruction. |
| 3879 | * |
| 3880 | * The instruction specified is removed from its containing building |
| 3881 | * block and then deleted. |
| 3882 | * |
| 3883 | * @see llvm::Instruction::eraseFromParent() |
| 3884 | */ |
| 3885 | LLVM_C_ABI void LLVMInstructionEraseFromParent(LLVMValueRef Inst); |
| 3886 | |
| 3887 | /** |
| 3888 | * Delete an instruction. |
| 3889 | * |
| 3890 | * The instruction specified is deleted. It must have previously been |
| 3891 | * removed from its containing building block. |
| 3892 | * |
| 3893 | * @see llvm::Value::deleteValue() |
| 3894 | */ |
| 3895 | LLVM_C_ABI void LLVMDeleteInstruction(LLVMValueRef Inst); |
| 3896 | |
| 3897 | /** |
| 3898 | * Obtain the code opcode for an individual instruction. |
| 3899 | * |
| 3900 | * @see llvm::Instruction::getOpCode() |
| 3901 | */ |
| 3902 | LLVM_C_ABI LLVMOpcode LLVMGetInstructionOpcode(LLVMValueRef Inst); |
| 3903 | |
| 3904 | /** |
| 3905 | * Obtain the predicate of an instruction. |
| 3906 | * |
| 3907 | * This is only valid for instructions that correspond to llvm::ICmpInst. |
| 3908 | * |
| 3909 | * @see llvm::ICmpInst::getPredicate() |
| 3910 | */ |
| 3911 | LLVM_C_ABI LLVMIntPredicate LLVMGetICmpPredicate(LLVMValueRef Inst); |
| 3912 | |
| 3913 | /** |
| 3914 | * Get whether or not an icmp instruction has the samesign flag. |
| 3915 | * |
| 3916 | * This is only valid for instructions that correspond to llvm::ICmpInst. |
| 3917 | * |
| 3918 | * @see llvm::ICmpInst::hasSameSign() |
| 3919 | */ |
| 3920 | LLVM_C_ABI LLVMBool LLVMGetICmpSameSign(LLVMValueRef Inst); |
| 3921 | |
| 3922 | /** |
| 3923 | * Set the samesign flag on an icmp instruction. |
| 3924 | * |
| 3925 | * This is only valid for instructions that correspond to llvm::ICmpInst. |
| 3926 | * |
| 3927 | * @see llvm::ICmpInst::setSameSign() |
| 3928 | */ |
| 3929 | LLVM_C_ABI void LLVMSetICmpSameSign(LLVMValueRef Inst, LLVMBool SameSign); |
| 3930 | |
| 3931 | /** |
| 3932 | * Obtain the float predicate of an instruction. |
| 3933 | * |
| 3934 | * This is only valid for instructions that correspond to llvm::FCmpInst. |
| 3935 | * |
| 3936 | * @see llvm::FCmpInst::getPredicate() |
| 3937 | */ |
| 3938 | LLVM_C_ABI LLVMRealPredicate LLVMGetFCmpPredicate(LLVMValueRef Inst); |
| 3939 | |
| 3940 | /** |
| 3941 | * Create a copy of 'this' instruction that is identical in all ways |
| 3942 | * except the following: |
| 3943 | * * The instruction has no parent |
| 3944 | * * The instruction has no name |
| 3945 | * |
| 3946 | * @see llvm::Instruction::clone() |
| 3947 | */ |
| 3948 | LLVM_C_ABI LLVMValueRef LLVMInstructionClone(LLVMValueRef Inst); |
| 3949 | |
| 3950 | /** |
| 3951 | * Determine whether an instruction is a terminator. This routine is named to |
| 3952 | * be compatible with historical functions that did this by querying the |
| 3953 | * underlying C++ type. |
| 3954 | * |
| 3955 | * @see llvm::Instruction::isTerminator() |
| 3956 | */ |
| 3957 | LLVM_C_ABI LLVMValueRef LLVMIsATerminatorInst(LLVMValueRef Inst); |
| 3958 | |
| 3959 | /** |
| 3960 | * Obtain the first debug record attached to an instruction. |
| 3961 | * |
| 3962 | * Use LLVMGetNextDbgRecord() and LLVMGetPreviousDbgRecord() to traverse the |
| 3963 | * sequence of DbgRecords. |
| 3964 | * |
| 3965 | * Return the first DbgRecord attached to Inst or NULL if there are none. |
| 3966 | * |
| 3967 | * @see llvm::Instruction::getDbgRecordRange() |
| 3968 | */ |
| 3969 | LLVM_C_ABI LLVMDbgRecordRef LLVMGetFirstDbgRecord(LLVMValueRef Inst); |
| 3970 | |
| 3971 | /** |
| 3972 | * Obtain the last debug record attached to an instruction. |
| 3973 | * |
| 3974 | * Return the last DbgRecord attached to Inst or NULL if there are none. |
| 3975 | * |
| 3976 | * @see llvm::Instruction::getDbgRecordRange() |
| 3977 | */ |
| 3978 | LLVM_C_ABI LLVMDbgRecordRef LLVMGetLastDbgRecord(LLVMValueRef Inst); |
| 3979 | |
| 3980 | /** |
| 3981 | * Obtain the next DbgRecord in the sequence or NULL if there are no more. |
| 3982 | * |
| 3983 | * @see llvm::Instruction::getDbgRecordRange() |
| 3984 | */ |
| 3985 | LLVM_C_ABI LLVMDbgRecordRef LLVMGetNextDbgRecord(LLVMDbgRecordRef DbgRecord); |
| 3986 | |
| 3987 | /** |
| 3988 | * Obtain the previous DbgRecord in the sequence or NULL if there are no more. |
| 3989 | * |
| 3990 | * @see llvm::Instruction::getDbgRecordRange() |
| 3991 | */ |
| 3992 | LLVM_C_ABI LLVMDbgRecordRef |
| 3993 | LLVMGetPreviousDbgRecord(LLVMDbgRecordRef DbgRecord); |
| 3994 | |
| 3995 | /** |
| 3996 | * Get the debug location attached to the debug record. |
| 3997 | * |
| 3998 | * @see llvm::DbgRecord::getDebugLoc() |
| 3999 | */ |
| 4000 | LLVM_C_ABI LLVMMetadataRef LLVMDbgRecordGetDebugLoc(LLVMDbgRecordRef Rec); |
| 4001 | |
| 4002 | LLVM_C_ABI LLVMDbgRecordKind LLVMDbgRecordGetKind(LLVMDbgRecordRef Rec); |
| 4003 | |
| 4004 | /** |
| 4005 | * Get the value of the DbgVariableRecord. |
| 4006 | * |
| 4007 | * @see llvm::DbgVariableRecord::getValue() |
| 4008 | */ |
| 4009 | LLVM_C_ABI LLVMValueRef LLVMDbgVariableRecordGetValue(LLVMDbgRecordRef Rec, |
| 4010 | unsigned OpIdx); |
| 4011 | |
| 4012 | /** |
| 4013 | * Get the debug info variable of the DbgVariableRecord. |
| 4014 | * |
| 4015 | * @see llvm::DbgVariableRecord::getVariable() |
| 4016 | */ |
| 4017 | LLVM_C_ABI LLVMMetadataRef |
| 4018 | LLVMDbgVariableRecordGetVariable(LLVMDbgRecordRef Rec); |
| 4019 | |
| 4020 | /** |
| 4021 | * Get the debug info expression of the DbgVariableRecord. |
| 4022 | * |
| 4023 | * @see llvm::DbgVariableRecord::getExpression() |
| 4024 | */ |
| 4025 | LLVM_C_ABI LLVMMetadataRef |
| 4026 | LLVMDbgVariableRecordGetExpression(LLVMDbgRecordRef Rec); |
| 4027 | |
| 4028 | /** |
| 4029 | * @defgroup LLVMCCoreValueInstructionCall Call Sites and Invocations |
| 4030 | * |
| 4031 | * Functions in this group apply to instructions that refer to call |
| 4032 | * sites and invocations. These correspond to C++ types in the |
| 4033 | * llvm::CallInst class tree. |
| 4034 | * |
| 4035 | * @{ |
| 4036 | */ |
| 4037 | |
| 4038 | /** |
| 4039 | * Obtain the argument count for a call instruction. |
| 4040 | * |
| 4041 | * This expects an LLVMValueRef that corresponds to a llvm::CallInst, |
| 4042 | * llvm::InvokeInst, or llvm:FuncletPadInst. |
| 4043 | * |
| 4044 | * @see llvm::CallInst::getNumArgOperands() |
| 4045 | * @see llvm::InvokeInst::getNumArgOperands() |
| 4046 | * @see llvm::FuncletPadInst::getNumArgOperands() |
| 4047 | */ |
| 4048 | LLVM_C_ABI unsigned LLVMGetNumArgOperands(LLVMValueRef Instr); |
| 4049 | |
| 4050 | /** |
| 4051 | * Set the calling convention for a call instruction. |
| 4052 | * |
| 4053 | * This expects an LLVMValueRef that corresponds to a llvm::CallInst or |
| 4054 | * llvm::InvokeInst. |
| 4055 | * |
| 4056 | * @see llvm::CallInst::setCallingConv() |
| 4057 | * @see llvm::InvokeInst::setCallingConv() |
| 4058 | */ |
| 4059 | LLVM_C_ABI void LLVMSetInstructionCallConv(LLVMValueRef Instr, unsigned CC); |
| 4060 | |
| 4061 | /** |
| 4062 | * Obtain the calling convention for a call instruction. |
| 4063 | * |
| 4064 | * This is the opposite of LLVMSetInstructionCallConv(). Reads its |
| 4065 | * usage. |
| 4066 | * |
| 4067 | * @see LLVMSetInstructionCallConv() |
| 4068 | */ |
| 4069 | LLVM_C_ABI unsigned LLVMGetInstructionCallConv(LLVMValueRef Instr); |
| 4070 | |
| 4071 | LLVM_C_ABI void LLVMSetInstrParamAlignment(LLVMValueRef Instr, |
| 4072 | LLVMAttributeIndex Idx, |
| 4073 | unsigned Align); |
| 4074 | |
| 4075 | LLVM_C_ABI void LLVMAddCallSiteAttribute(LLVMValueRef C, LLVMAttributeIndex Idx, |
| 4076 | LLVMAttributeRef A); |
| 4077 | LLVM_C_ABI unsigned LLVMGetCallSiteAttributeCount(LLVMValueRef C, |
| 4078 | LLVMAttributeIndex Idx); |
| 4079 | LLVM_C_ABI void LLVMGetCallSiteAttributes(LLVMValueRef C, |
| 4080 | LLVMAttributeIndex Idx, |
| 4081 | LLVMAttributeRef *Attrs); |
| 4082 | LLVM_C_ABI LLVMAttributeRef LLVMGetCallSiteEnumAttribute(LLVMValueRef C, |
| 4083 | LLVMAttributeIndex Idx, |
| 4084 | unsigned KindID); |
| 4085 | LLVM_C_ABI LLVMAttributeRef LLVMGetCallSiteStringAttribute( |
| 4086 | LLVMValueRef C, LLVMAttributeIndex Idx, const char *K, unsigned KLen); |
| 4087 | LLVM_C_ABI void LLVMRemoveCallSiteEnumAttribute(LLVMValueRef C, |
| 4088 | LLVMAttributeIndex Idx, |
| 4089 | unsigned KindID); |
| 4090 | LLVM_C_ABI void LLVMRemoveCallSiteStringAttribute(LLVMValueRef C, |
| 4091 | LLVMAttributeIndex Idx, |
| 4092 | const char *K, unsigned KLen); |
| 4093 | |
| 4094 | /** |
| 4095 | * Obtain the function type called by this instruction. |
| 4096 | * |
| 4097 | * @see llvm::CallBase::getFunctionType() |
| 4098 | */ |
| 4099 | LLVM_C_ABI LLVMTypeRef LLVMGetCalledFunctionType(LLVMValueRef C); |
| 4100 | |
| 4101 | /** |
| 4102 | * Obtain the pointer to the function invoked by this instruction. |
| 4103 | * |
| 4104 | * This expects an LLVMValueRef that corresponds to a llvm::CallInst or |
| 4105 | * llvm::InvokeInst. |
| 4106 | * |
| 4107 | * @see llvm::CallInst::getCalledOperand() |
| 4108 | * @see llvm::InvokeInst::getCalledOperand() |
| 4109 | */ |
| 4110 | LLVM_C_ABI LLVMValueRef LLVMGetCalledValue(LLVMValueRef Instr); |
| 4111 | |
| 4112 | /** |
| 4113 | * Obtain the number of operand bundles attached to this instruction. |
| 4114 | * |
| 4115 | * This only works on llvm::CallInst and llvm::InvokeInst instructions. |
| 4116 | * |
| 4117 | * @see llvm::CallBase::getNumOperandBundles() |
| 4118 | */ |
| 4119 | LLVM_C_ABI unsigned LLVMGetNumOperandBundles(LLVMValueRef C); |
| 4120 | |
| 4121 | /** |
| 4122 | * Obtain the operand bundle attached to this instruction at the given index. |
| 4123 | * Use LLVMDisposeOperandBundle to free the operand bundle. |
| 4124 | * |
| 4125 | * This only works on llvm::CallInst and llvm::InvokeInst instructions. |
| 4126 | */ |
| 4127 | LLVM_C_ABI LLVMOperandBundleRef LLVMGetOperandBundleAtIndex(LLVMValueRef C, |
| 4128 | unsigned Index); |
| 4129 | |
| 4130 | /** |
| 4131 | * Obtain whether a call instruction is a tail call. |
| 4132 | * |
| 4133 | * This only works on llvm::CallInst instructions. |
| 4134 | * |
| 4135 | * @see llvm::CallInst::isTailCall() |
| 4136 | */ |
| 4137 | LLVM_C_ABI LLVMBool LLVMIsTailCall(LLVMValueRef CallInst); |
| 4138 | |
| 4139 | /** |
| 4140 | * Set whether a call instruction is a tail call. |
| 4141 | * |
| 4142 | * This only works on llvm::CallInst instructions. |
| 4143 | * |
| 4144 | * @see llvm::CallInst::setTailCall() |
| 4145 | */ |
| 4146 | LLVM_C_ABI void LLVMSetTailCall(LLVMValueRef CallInst, LLVMBool IsTailCall); |
| 4147 | |
| 4148 | /** |
| 4149 | * Obtain a tail call kind of the call instruction. |
| 4150 | * |
| 4151 | * @see llvm::CallInst::setTailCallKind() |
| 4152 | */ |
| 4153 | LLVM_C_ABI LLVMTailCallKind LLVMGetTailCallKind(LLVMValueRef CallInst); |
| 4154 | |
| 4155 | /** |
| 4156 | * Set the call kind of the call instruction. |
| 4157 | * |
| 4158 | * @see llvm::CallInst::getTailCallKind() |
| 4159 | */ |
| 4160 | LLVM_C_ABI void LLVMSetTailCallKind(LLVMValueRef CallInst, |
| 4161 | LLVMTailCallKind kind); |
| 4162 | |
| 4163 | /** |
| 4164 | * Return the normal destination basic block. |
| 4165 | * |
| 4166 | * This only works on llvm::InvokeInst instructions. |
| 4167 | * |
| 4168 | * @see llvm::InvokeInst::getNormalDest() |
| 4169 | */ |
| 4170 | LLVM_C_ABI LLVMBasicBlockRef LLVMGetNormalDest(LLVMValueRef InvokeInst); |
| 4171 | |
| 4172 | /** |
| 4173 | * Return the unwind destination basic block. |
| 4174 | * |
| 4175 | * Works on llvm::InvokeInst, llvm::CleanupReturnInst, and |
| 4176 | * llvm::CatchSwitchInst instructions. |
| 4177 | * |
| 4178 | * @see llvm::InvokeInst::getUnwindDest() |
| 4179 | * @see llvm::CleanupReturnInst::getUnwindDest() |
| 4180 | * @see llvm::CatchSwitchInst::getUnwindDest() |
| 4181 | */ |
| 4182 | LLVM_C_ABI LLVMBasicBlockRef LLVMGetUnwindDest(LLVMValueRef InvokeInst); |
| 4183 | |
| 4184 | /** |
| 4185 | * Set the normal destination basic block. |
| 4186 | * |
| 4187 | * This only works on llvm::InvokeInst instructions. |
| 4188 | * |
| 4189 | * @see llvm::InvokeInst::setNormalDest() |
| 4190 | */ |
| 4191 | LLVM_C_ABI void LLVMSetNormalDest(LLVMValueRef InvokeInst, LLVMBasicBlockRef B); |
| 4192 | |
| 4193 | /** |
| 4194 | * Set the unwind destination basic block. |
| 4195 | * |
| 4196 | * Works on llvm::InvokeInst, llvm::CleanupReturnInst, and |
| 4197 | * llvm::CatchSwitchInst instructions. |
| 4198 | * |
| 4199 | * @see llvm::InvokeInst::setUnwindDest() |
| 4200 | * @see llvm::CleanupReturnInst::setUnwindDest() |
| 4201 | * @see llvm::CatchSwitchInst::setUnwindDest() |
| 4202 | */ |
| 4203 | LLVM_C_ABI void LLVMSetUnwindDest(LLVMValueRef InvokeInst, LLVMBasicBlockRef B); |
| 4204 | |
| 4205 | /** |
| 4206 | * Get the default destination of a CallBr instruction. |
| 4207 | * |
| 4208 | * @see llvm::CallBrInst::getDefaultDest() |
| 4209 | */ |
| 4210 | LLVM_C_ABI LLVMBasicBlockRef LLVMGetCallBrDefaultDest(LLVMValueRef CallBr); |
| 4211 | |
| 4212 | /** |
| 4213 | * Get the number of indirect destinations of a CallBr instruction. |
| 4214 | * |
| 4215 | * @see llvm::CallBrInst::getNumIndirectDests() |
| 4216 | |
| 4217 | */ |
| 4218 | LLVM_C_ABI unsigned LLVMGetCallBrNumIndirectDests(LLVMValueRef CallBr); |
| 4219 | |
| 4220 | /** |
| 4221 | * Get the indirect destination of a CallBr instruction at the given index. |
| 4222 | * |
| 4223 | * @see llvm::CallBrInst::getIndirectDest() |
| 4224 | */ |
| 4225 | LLVM_C_ABI LLVMBasicBlockRef LLVMGetCallBrIndirectDest(LLVMValueRef CallBr, |
| 4226 | unsigned Idx); |
| 4227 | |
| 4228 | /** |
| 4229 | * @} |
| 4230 | */ |
| 4231 | |
| 4232 | /** |
| 4233 | * @defgroup LLVMCCoreValueInstructionTerminator Terminators |
| 4234 | * |
| 4235 | * Functions in this group only apply to instructions for which |
| 4236 | * LLVMIsATerminatorInst returns true. |
| 4237 | * |
| 4238 | * @{ |
| 4239 | */ |
| 4240 | |
| 4241 | /** |
| 4242 | * Return the number of successors that this terminator has. |
| 4243 | * |
| 4244 | * @see llvm::Instruction::getNumSuccessors |
| 4245 | */ |
| 4246 | LLVM_C_ABI unsigned LLVMGetNumSuccessors(LLVMValueRef Term); |
| 4247 | |
| 4248 | /** |
| 4249 | * Return the specified successor. |
| 4250 | * |
| 4251 | * @see llvm::Instruction::getSuccessor |
| 4252 | */ |
| 4253 | LLVM_C_ABI LLVMBasicBlockRef LLVMGetSuccessor(LLVMValueRef Term, unsigned i); |
| 4254 | |
| 4255 | /** |
| 4256 | * Update the specified successor to point at the provided block. |
| 4257 | * |
| 4258 | * @see llvm::Instruction::setSuccessor |
| 4259 | */ |
| 4260 | LLVM_C_ABI void LLVMSetSuccessor(LLVMValueRef Term, unsigned i, |
| 4261 | LLVMBasicBlockRef block); |
| 4262 | |
| 4263 | /** |
| 4264 | * Return if a branch is conditional. |
| 4265 | * |
| 4266 | * This only works on llvm::BranchInst instructions. |
| 4267 | * |
| 4268 | * @see llvm::BranchInst::isConditional |
| 4269 | */ |
| 4270 | LLVM_C_ABI LLVMBool LLVMIsConditional(LLVMValueRef Branch); |
| 4271 | |
| 4272 | /** |
| 4273 | * Return the condition of a branch instruction. |
| 4274 | * |
| 4275 | * This only works on llvm::BranchInst instructions. |
| 4276 | * |
| 4277 | * @see llvm::BranchInst::getCondition |
| 4278 | */ |
| 4279 | LLVM_C_ABI LLVMValueRef LLVMGetCondition(LLVMValueRef Branch); |
| 4280 | |
| 4281 | /** |
| 4282 | * Set the condition of a branch instruction. |
| 4283 | * |
| 4284 | * This only works on llvm::BranchInst instructions. |
| 4285 | * |
| 4286 | * @see llvm::BranchInst::setCondition |
| 4287 | */ |
| 4288 | LLVM_C_ABI void LLVMSetCondition(LLVMValueRef Branch, LLVMValueRef Cond); |
| 4289 | |
| 4290 | /** |
| 4291 | * Obtain the default destination basic block of a switch instruction. |
| 4292 | * |
| 4293 | * This only works on llvm::SwitchInst instructions. |
| 4294 | * |
| 4295 | * @see llvm::SwitchInst::getDefaultDest() |
| 4296 | */ |
| 4297 | LLVM_C_ABI LLVMBasicBlockRef LLVMGetSwitchDefaultDest(LLVMValueRef SwitchInstr); |
| 4298 | |
| 4299 | /** |
| 4300 | * Obtain the case value for a successor of a switch instruction. i corresponds |
| 4301 | * to the successor index. The first successor is the default destination, so i |
| 4302 | * must be greater than zero. |
| 4303 | * |
| 4304 | * This only works on llvm::SwitchInst instructions. |
| 4305 | * |
| 4306 | * @see llvm::SwitchInst::CaseHandle::getCaseValue() |
| 4307 | */ |
| 4308 | LLVM_C_ABI LLVMValueRef LLVMGetSwitchCaseValue(LLVMValueRef SwitchInstr, |
| 4309 | unsigned i); |
| 4310 | |
| 4311 | /** |
| 4312 | * Set the case value for a successor of a switch instruction. i corresponds to |
| 4313 | * the successor index. The first successor is the default destination, so i |
| 4314 | * must be greater than zero. |
| 4315 | * |
| 4316 | * This only works on llvm::SwitchInst instructions. |
| 4317 | * |
| 4318 | * @see llvm::SwitchInst::CaseHandle::setValue() |
| 4319 | */ |
| 4320 | LLVM_C_ABI void LLVMSetSwitchCaseValue(LLVMValueRef SwitchInstr, unsigned i, |
| 4321 | LLVMValueRef CaseValue); |
| 4322 | |
| 4323 | /** |
| 4324 | * @} |
| 4325 | */ |
| 4326 | |
| 4327 | /** |
| 4328 | * @defgroup LLVMCCoreValueInstructionAlloca Allocas |
| 4329 | * |
| 4330 | * Functions in this group only apply to instructions that map to |
| 4331 | * llvm::AllocaInst instances. |
| 4332 | * |
| 4333 | * @{ |
| 4334 | */ |
| 4335 | |
| 4336 | /** |
| 4337 | * Obtain the type that is being allocated by the alloca instruction. |
| 4338 | */ |
| 4339 | LLVM_C_ABI LLVMTypeRef LLVMGetAllocatedType(LLVMValueRef Alloca); |
| 4340 | |
| 4341 | /** |
| 4342 | * @} |
| 4343 | */ |
| 4344 | |
| 4345 | /** |
| 4346 | * @defgroup LLVMCCoreValueInstructionGetElementPointer GEPs |
| 4347 | * |
| 4348 | * Functions in this group only apply to instructions that map to |
| 4349 | * llvm::GetElementPtrInst instances. |
| 4350 | * |
| 4351 | * @{ |
| 4352 | */ |
| 4353 | |
| 4354 | /** |
| 4355 | * Check whether the given GEP operator is inbounds. |
| 4356 | */ |
| 4357 | LLVM_C_ABI LLVMBool LLVMIsInBounds(LLVMValueRef GEP); |
| 4358 | |
| 4359 | /** |
| 4360 | * Set the given GEP instruction to be inbounds or not. |
| 4361 | */ |
| 4362 | LLVM_C_ABI void LLVMSetIsInBounds(LLVMValueRef GEP, LLVMBool InBounds); |
| 4363 | |
| 4364 | /** |
| 4365 | * Get the source element type of the given GEP operator. |
| 4366 | */ |
| 4367 | LLVM_C_ABI LLVMTypeRef LLVMGetGEPSourceElementType(LLVMValueRef GEP); |
| 4368 | |
| 4369 | /** |
| 4370 | * Get the no-wrap related flags for the given GEP instruction. |
| 4371 | * |
| 4372 | * @see llvm::GetElementPtrInst::getNoWrapFlags |
| 4373 | */ |
| 4374 | LLVM_C_ABI LLVMGEPNoWrapFlags LLVMGEPGetNoWrapFlags(LLVMValueRef GEP); |
| 4375 | |
| 4376 | /** |
| 4377 | * Set the no-wrap related flags for the given GEP instruction. |
| 4378 | * |
| 4379 | * @see llvm::GetElementPtrInst::setNoWrapFlags |
| 4380 | */ |
| 4381 | LLVM_C_ABI void LLVMGEPSetNoWrapFlags(LLVMValueRef GEP, |
| 4382 | LLVMGEPNoWrapFlags NoWrapFlags); |
| 4383 | |
| 4384 | /** |
| 4385 | * @} |
| 4386 | */ |
| 4387 | |
| 4388 | /** |
| 4389 | * @defgroup LLVMCCoreValueInstructionPHINode PHI Nodes |
| 4390 | * |
| 4391 | * Functions in this group only apply to instructions that map to |
| 4392 | * llvm::PHINode instances. |
| 4393 | * |
| 4394 | * @{ |
| 4395 | */ |
| 4396 | |
| 4397 | /** |
| 4398 | * Add an incoming value to the end of a PHI list. |
| 4399 | */ |
| 4400 | LLVM_C_ABI void LLVMAddIncoming(LLVMValueRef PhiNode, |
| 4401 | LLVMValueRef *IncomingValues, |
| 4402 | LLVMBasicBlockRef *IncomingBlocks, |
| 4403 | unsigned Count); |
| 4404 | |
| 4405 | /** |
| 4406 | * Obtain the number of incoming basic blocks to a PHI node. |
| 4407 | */ |
| 4408 | LLVM_C_ABI unsigned LLVMCountIncoming(LLVMValueRef PhiNode); |
| 4409 | |
| 4410 | /** |
| 4411 | * Obtain an incoming value to a PHI node as an LLVMValueRef. |
| 4412 | */ |
| 4413 | LLVM_C_ABI LLVMValueRef LLVMGetIncomingValue(LLVMValueRef PhiNode, |
| 4414 | unsigned Index); |
| 4415 | |
| 4416 | /** |
| 4417 | * Obtain an incoming value to a PHI node as an LLVMBasicBlockRef. |
| 4418 | */ |
| 4419 | LLVM_C_ABI LLVMBasicBlockRef LLVMGetIncomingBlock(LLVMValueRef PhiNode, |
| 4420 | unsigned Index); |
| 4421 | |
| 4422 | /** |
| 4423 | * @} |
| 4424 | */ |
| 4425 | |
| 4426 | /** |
| 4427 | * @defgroup LLVMCCoreValueInstructionExtractValue ExtractValue |
| 4428 | * @defgroup LLVMCCoreValueInstructionInsertValue InsertValue |
| 4429 | * |
| 4430 | * Functions in this group only apply to instructions that map to |
| 4431 | * llvm::ExtractValue and llvm::InsertValue instances. |
| 4432 | * |
| 4433 | * @{ |
| 4434 | */ |
| 4435 | |
| 4436 | /** |
| 4437 | * Obtain the number of indices. |
| 4438 | * NB: This also works on GEP operators. |
| 4439 | */ |
| 4440 | LLVM_C_ABI unsigned LLVMGetNumIndices(LLVMValueRef Inst); |
| 4441 | |
| 4442 | /** |
| 4443 | * Obtain the indices as an array. |
| 4444 | */ |
| 4445 | LLVM_C_ABI const unsigned *LLVMGetIndices(LLVMValueRef Inst); |
| 4446 | |
| 4447 | /** |
| 4448 | * @} |
| 4449 | */ |
| 4450 | |
| 4451 | /** |
| 4452 | * @} |
| 4453 | */ |
| 4454 | |
| 4455 | /** |
| 4456 | * @} |
| 4457 | */ |
| 4458 | |
| 4459 | /** |
| 4460 | * @defgroup LLVMCCoreInstructionBuilder Instruction Builders |
| 4461 | * |
| 4462 | * An instruction builder represents a point within a basic block and is |
| 4463 | * the exclusive means of building instructions using the C interface. |
| 4464 | * |
| 4465 | * @{ |
| 4466 | */ |
| 4467 | |
| 4468 | LLVM_C_ABI LLVMBuilderRef LLVMCreateBuilderInContext(LLVMContextRef C); |
| 4469 | LLVM_C_ABI |
| 4470 | LLVM_ATTRIBUTE_C_DEPRECATED(LLVMBuilderRef LLVMCreateBuilder(void), |
| 4471 | "Use of the global context is deprecated, use " |
| 4472 | "LLVMCreateBuilderInContext instead" ); |
| 4473 | /** |
| 4474 | * Set the builder position before Instr but after any attached debug records, |
| 4475 | * or if Instr is null set the position to the end of Block. |
| 4476 | */ |
| 4477 | LLVM_C_ABI void LLVMPositionBuilder(LLVMBuilderRef Builder, |
| 4478 | LLVMBasicBlockRef Block, |
| 4479 | LLVMValueRef Instr); |
| 4480 | /** |
| 4481 | * Set the builder position before Instr and any attached debug records, |
| 4482 | * or if Instr is null set the position to the end of Block. |
| 4483 | */ |
| 4484 | LLVM_C_ABI void LLVMPositionBuilderBeforeDbgRecords(LLVMBuilderRef Builder, |
| 4485 | LLVMBasicBlockRef Block, |
| 4486 | LLVMValueRef Inst); |
| 4487 | /** |
| 4488 | * Set the builder position before Instr but after any attached debug records. |
| 4489 | */ |
| 4490 | LLVM_C_ABI void LLVMPositionBuilderBefore(LLVMBuilderRef Builder, |
| 4491 | LLVMValueRef Instr); |
| 4492 | /** |
| 4493 | * Set the builder position before Instr and any attached debug records. |
| 4494 | */ |
| 4495 | LLVM_C_ABI void |
| 4496 | LLVMPositionBuilderBeforeInstrAndDbgRecords(LLVMBuilderRef Builder, |
| 4497 | LLVMValueRef Instr); |
| 4498 | LLVM_C_ABI void LLVMPositionBuilderAtEnd(LLVMBuilderRef Builder, |
| 4499 | LLVMBasicBlockRef Block); |
| 4500 | LLVM_C_ABI LLVMBasicBlockRef LLVMGetInsertBlock(LLVMBuilderRef Builder); |
| 4501 | LLVM_C_ABI void LLVMClearInsertionPosition(LLVMBuilderRef Builder); |
| 4502 | LLVM_C_ABI void LLVMInsertIntoBuilder(LLVMBuilderRef Builder, |
| 4503 | LLVMValueRef Instr); |
| 4504 | LLVM_C_ABI void LLVMInsertIntoBuilderWithName(LLVMBuilderRef Builder, |
| 4505 | LLVMValueRef Instr, |
| 4506 | const char *Name); |
| 4507 | LLVM_C_ABI void LLVMDisposeBuilder(LLVMBuilderRef Builder); |
| 4508 | |
| 4509 | /* Metadata */ |
| 4510 | |
| 4511 | /** |
| 4512 | * Get location information used by debugging information. |
| 4513 | * |
| 4514 | * @see llvm::IRBuilder::getCurrentDebugLocation() |
| 4515 | */ |
| 4516 | LLVM_C_ABI LLVMMetadataRef LLVMGetCurrentDebugLocation2(LLVMBuilderRef Builder); |
| 4517 | |
| 4518 | /** |
| 4519 | * Set location information used by debugging information. |
| 4520 | * |
| 4521 | * To clear the location metadata of the given instruction, pass NULL to \p Loc. |
| 4522 | * |
| 4523 | * @see llvm::IRBuilder::SetCurrentDebugLocation() |
| 4524 | */ |
| 4525 | LLVM_C_ABI void LLVMSetCurrentDebugLocation2(LLVMBuilderRef Builder, |
| 4526 | LLVMMetadataRef Loc); |
| 4527 | |
| 4528 | /** |
| 4529 | * Attempts to set the debug location for the given instruction using the |
| 4530 | * current debug location for the given builder. If the builder has no current |
| 4531 | * debug location, this function is a no-op. |
| 4532 | * |
| 4533 | * @deprecated LLVMSetInstDebugLocation is deprecated in favor of the more general |
| 4534 | * LLVMAddMetadataToInst. |
| 4535 | * |
| 4536 | * @see llvm::IRBuilder::SetInstDebugLocation() |
| 4537 | */ |
| 4538 | LLVM_C_ABI void LLVMSetInstDebugLocation(LLVMBuilderRef Builder, |
| 4539 | LLVMValueRef Inst); |
| 4540 | |
| 4541 | /** |
| 4542 | * Adds the metadata registered with the given builder to the given instruction. |
| 4543 | * |
| 4544 | * @see llvm::IRBuilder::AddMetadataToInst() |
| 4545 | */ |
| 4546 | LLVM_C_ABI void LLVMAddMetadataToInst(LLVMBuilderRef Builder, |
| 4547 | LLVMValueRef Inst); |
| 4548 | |
| 4549 | /** |
| 4550 | * Get the dafult floating-point math metadata for a given builder. |
| 4551 | * |
| 4552 | * @see llvm::IRBuilder::getDefaultFPMathTag() |
| 4553 | */ |
| 4554 | LLVM_C_ABI LLVMMetadataRef |
| 4555 | LLVMBuilderGetDefaultFPMathTag(LLVMBuilderRef Builder); |
| 4556 | |
| 4557 | /** |
| 4558 | * Set the default floating-point math metadata for the given builder. |
| 4559 | * |
| 4560 | * To clear the metadata, pass NULL to \p FPMathTag. |
| 4561 | * |
| 4562 | * @see llvm::IRBuilder::setDefaultFPMathTag() |
| 4563 | */ |
| 4564 | LLVM_C_ABI void LLVMBuilderSetDefaultFPMathTag(LLVMBuilderRef Builder, |
| 4565 | LLVMMetadataRef FPMathTag); |
| 4566 | |
| 4567 | /** |
| 4568 | * Obtain the context to which this builder is associated. |
| 4569 | * |
| 4570 | * @see llvm::IRBuilder::getContext() |
| 4571 | */ |
| 4572 | LLVM_C_ABI LLVMContextRef LLVMGetBuilderContext(LLVMBuilderRef Builder); |
| 4573 | |
| 4574 | /** |
| 4575 | * Deprecated: Passing the NULL location will crash. |
| 4576 | * Use LLVMGetCurrentDebugLocation2 instead. |
| 4577 | */ |
| 4578 | LLVM_C_ABI void LLVMSetCurrentDebugLocation(LLVMBuilderRef Builder, |
| 4579 | LLVMValueRef L); |
| 4580 | /** |
| 4581 | * Deprecated: Returning the NULL location will crash. |
| 4582 | * Use LLVMGetCurrentDebugLocation2 instead. |
| 4583 | */ |
| 4584 | LLVM_C_ABI LLVMValueRef LLVMGetCurrentDebugLocation(LLVMBuilderRef Builder); |
| 4585 | |
| 4586 | /* Terminators */ |
| 4587 | LLVM_C_ABI LLVMValueRef LLVMBuildRetVoid(LLVMBuilderRef); |
| 4588 | LLVM_C_ABI LLVMValueRef LLVMBuildRet(LLVMBuilderRef, LLVMValueRef V); |
| 4589 | LLVM_C_ABI LLVMValueRef LLVMBuildAggregateRet(LLVMBuilderRef, |
| 4590 | LLVMValueRef *RetVals, |
| 4591 | unsigned N); |
| 4592 | LLVM_C_ABI LLVMValueRef LLVMBuildBr(LLVMBuilderRef, LLVMBasicBlockRef Dest); |
| 4593 | LLVM_C_ABI LLVMValueRef LLVMBuildCondBr(LLVMBuilderRef, LLVMValueRef If, |
| 4594 | LLVMBasicBlockRef Then, |
| 4595 | LLVMBasicBlockRef Else); |
| 4596 | LLVM_C_ABI LLVMValueRef LLVMBuildSwitch(LLVMBuilderRef, LLVMValueRef V, |
| 4597 | LLVMBasicBlockRef Else, |
| 4598 | unsigned NumCases); |
| 4599 | LLVM_C_ABI LLVMValueRef LLVMBuildIndirectBr(LLVMBuilderRef B, LLVMValueRef Addr, |
| 4600 | unsigned NumDests); |
| 4601 | LLVM_C_ABI LLVMValueRef LLVMBuildCallBr( |
| 4602 | LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Fn, |
| 4603 | LLVMBasicBlockRef DefaultDest, LLVMBasicBlockRef *IndirectDests, |
| 4604 | unsigned NumIndirectDests, LLVMValueRef *Args, unsigned NumArgs, |
| 4605 | LLVMOperandBundleRef *Bundles, unsigned NumBundles, const char *Name); |
| 4606 | LLVM_C_ABI LLVMValueRef LLVMBuildInvoke2(LLVMBuilderRef, LLVMTypeRef Ty, |
| 4607 | LLVMValueRef Fn, LLVMValueRef *Args, |
| 4608 | unsigned NumArgs, |
| 4609 | LLVMBasicBlockRef Then, |
| 4610 | LLVMBasicBlockRef Catch, |
| 4611 | const char *Name); |
| 4612 | LLVM_C_ABI LLVMValueRef LLVMBuildInvokeWithOperandBundles( |
| 4613 | LLVMBuilderRef, LLVMTypeRef Ty, LLVMValueRef Fn, LLVMValueRef *Args, |
| 4614 | unsigned NumArgs, LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch, |
| 4615 | LLVMOperandBundleRef *Bundles, unsigned NumBundles, const char *Name); |
| 4616 | LLVM_C_ABI LLVMValueRef LLVMBuildUnreachable(LLVMBuilderRef); |
| 4617 | |
| 4618 | /* Exception Handling */ |
| 4619 | LLVM_C_ABI LLVMValueRef LLVMBuildResume(LLVMBuilderRef B, LLVMValueRef Exn); |
| 4620 | LLVM_C_ABI LLVMValueRef LLVMBuildLandingPad(LLVMBuilderRef B, LLVMTypeRef Ty, |
| 4621 | LLVMValueRef PersFn, |
| 4622 | unsigned NumClauses, |
| 4623 | const char *Name); |
| 4624 | LLVM_C_ABI LLVMValueRef LLVMBuildCleanupRet(LLVMBuilderRef B, |
| 4625 | LLVMValueRef CatchPad, |
| 4626 | LLVMBasicBlockRef BB); |
| 4627 | LLVM_C_ABI LLVMValueRef LLVMBuildCatchRet(LLVMBuilderRef B, |
| 4628 | LLVMValueRef CatchPad, |
| 4629 | LLVMBasicBlockRef BB); |
| 4630 | LLVM_C_ABI LLVMValueRef LLVMBuildCatchPad(LLVMBuilderRef B, |
| 4631 | LLVMValueRef ParentPad, |
| 4632 | LLVMValueRef *Args, unsigned NumArgs, |
| 4633 | const char *Name); |
| 4634 | LLVM_C_ABI LLVMValueRef LLVMBuildCleanupPad(LLVMBuilderRef B, |
| 4635 | LLVMValueRef ParentPad, |
| 4636 | LLVMValueRef *Args, |
| 4637 | unsigned NumArgs, const char *Name); |
| 4638 | LLVM_C_ABI LLVMValueRef LLVMBuildCatchSwitch(LLVMBuilderRef B, |
| 4639 | LLVMValueRef ParentPad, |
| 4640 | LLVMBasicBlockRef UnwindBB, |
| 4641 | unsigned NumHandlers, |
| 4642 | const char *Name); |
| 4643 | |
| 4644 | /* Add a case to the switch instruction */ |
| 4645 | LLVM_C_ABI void LLVMAddCase(LLVMValueRef Switch, LLVMValueRef OnVal, |
| 4646 | LLVMBasicBlockRef Dest); |
| 4647 | |
| 4648 | /* Add a destination to the indirectbr instruction */ |
| 4649 | LLVM_C_ABI void LLVMAddDestination(LLVMValueRef IndirectBr, |
| 4650 | LLVMBasicBlockRef Dest); |
| 4651 | |
| 4652 | /* Get the number of clauses on the landingpad instruction */ |
| 4653 | LLVM_C_ABI unsigned LLVMGetNumClauses(LLVMValueRef LandingPad); |
| 4654 | |
| 4655 | /* Get the value of the clause at index Idx on the landingpad instruction */ |
| 4656 | LLVM_C_ABI LLVMValueRef LLVMGetClause(LLVMValueRef LandingPad, unsigned Idx); |
| 4657 | |
| 4658 | /* Add a catch or filter clause to the landingpad instruction */ |
| 4659 | LLVM_C_ABI void LLVMAddClause(LLVMValueRef LandingPad, LLVMValueRef ClauseVal); |
| 4660 | |
| 4661 | /* Get the 'cleanup' flag in the landingpad instruction */ |
| 4662 | LLVM_C_ABI LLVMBool LLVMIsCleanup(LLVMValueRef LandingPad); |
| 4663 | |
| 4664 | /* Set the 'cleanup' flag in the landingpad instruction */ |
| 4665 | LLVM_C_ABI void LLVMSetCleanup(LLVMValueRef LandingPad, LLVMBool Val); |
| 4666 | |
| 4667 | /* Add a destination to the catchswitch instruction */ |
| 4668 | LLVM_C_ABI void LLVMAddHandler(LLVMValueRef CatchSwitch, |
| 4669 | LLVMBasicBlockRef Dest); |
| 4670 | |
| 4671 | /* Get the number of handlers on the catchswitch instruction */ |
| 4672 | LLVM_C_ABI unsigned LLVMGetNumHandlers(LLVMValueRef CatchSwitch); |
| 4673 | |
| 4674 | /** |
| 4675 | * Obtain the basic blocks acting as handlers for a catchswitch instruction. |
| 4676 | * |
| 4677 | * The Handlers parameter should point to a pre-allocated array of |
| 4678 | * LLVMBasicBlockRefs at least LLVMGetNumHandlers() large. On return, the |
| 4679 | * first LLVMGetNumHandlers() entries in the array will be populated |
| 4680 | * with LLVMBasicBlockRef instances. |
| 4681 | * |
| 4682 | * @param CatchSwitch The catchswitch instruction to operate on. |
| 4683 | * @param Handlers Memory address of an array to be filled with basic blocks. |
| 4684 | */ |
| 4685 | LLVM_C_ABI void LLVMGetHandlers(LLVMValueRef CatchSwitch, |
| 4686 | LLVMBasicBlockRef *Handlers); |
| 4687 | |
| 4688 | /* Funclets */ |
| 4689 | |
| 4690 | /* Get the number of funcletpad arguments. */ |
| 4691 | LLVM_C_ABI LLVMValueRef LLVMGetArgOperand(LLVMValueRef Funclet, unsigned i); |
| 4692 | |
| 4693 | /* Set a funcletpad argument at the given index. */ |
| 4694 | LLVM_C_ABI void LLVMSetArgOperand(LLVMValueRef Funclet, unsigned i, |
| 4695 | LLVMValueRef value); |
| 4696 | |
| 4697 | /** |
| 4698 | * Get the parent catchswitch instruction of a catchpad instruction. |
| 4699 | * |
| 4700 | * This only works on llvm::CatchPadInst instructions. |
| 4701 | * |
| 4702 | * @see llvm::CatchPadInst::getCatchSwitch() |
| 4703 | */ |
| 4704 | LLVM_C_ABI LLVMValueRef LLVMGetParentCatchSwitch(LLVMValueRef CatchPad); |
| 4705 | |
| 4706 | /** |
| 4707 | * Set the parent catchswitch instruction of a catchpad instruction. |
| 4708 | * |
| 4709 | * This only works on llvm::CatchPadInst instructions. |
| 4710 | * |
| 4711 | * @see llvm::CatchPadInst::setCatchSwitch() |
| 4712 | */ |
| 4713 | LLVM_C_ABI void LLVMSetParentCatchSwitch(LLVMValueRef CatchPad, |
| 4714 | LLVMValueRef CatchSwitch); |
| 4715 | |
| 4716 | /* Arithmetic */ |
| 4717 | LLVM_C_ABI LLVMValueRef LLVMBuildAdd(LLVMBuilderRef, LLVMValueRef LHS, |
| 4718 | LLVMValueRef RHS, const char *Name); |
| 4719 | LLVM_C_ABI LLVMValueRef LLVMBuildNSWAdd(LLVMBuilderRef, LLVMValueRef LHS, |
| 4720 | LLVMValueRef RHS, const char *Name); |
| 4721 | LLVM_C_ABI LLVMValueRef LLVMBuildNUWAdd(LLVMBuilderRef, LLVMValueRef LHS, |
| 4722 | LLVMValueRef RHS, const char *Name); |
| 4723 | LLVM_C_ABI LLVMValueRef LLVMBuildFAdd(LLVMBuilderRef, LLVMValueRef LHS, |
| 4724 | LLVMValueRef RHS, const char *Name); |
| 4725 | LLVM_C_ABI LLVMValueRef LLVMBuildSub(LLVMBuilderRef, LLVMValueRef LHS, |
| 4726 | LLVMValueRef RHS, const char *Name); |
| 4727 | LLVM_C_ABI LLVMValueRef LLVMBuildNSWSub(LLVMBuilderRef, LLVMValueRef LHS, |
| 4728 | LLVMValueRef RHS, const char *Name); |
| 4729 | LLVM_C_ABI LLVMValueRef LLVMBuildNUWSub(LLVMBuilderRef, LLVMValueRef LHS, |
| 4730 | LLVMValueRef RHS, const char *Name); |
| 4731 | LLVM_C_ABI LLVMValueRef LLVMBuildFSub(LLVMBuilderRef, LLVMValueRef LHS, |
| 4732 | LLVMValueRef RHS, const char *Name); |
| 4733 | LLVM_C_ABI LLVMValueRef LLVMBuildMul(LLVMBuilderRef, LLVMValueRef LHS, |
| 4734 | LLVMValueRef RHS, const char *Name); |
| 4735 | LLVM_C_ABI LLVMValueRef LLVMBuildNSWMul(LLVMBuilderRef, LLVMValueRef LHS, |
| 4736 | LLVMValueRef RHS, const char *Name); |
| 4737 | LLVM_C_ABI LLVMValueRef LLVMBuildNUWMul(LLVMBuilderRef, LLVMValueRef LHS, |
| 4738 | LLVMValueRef RHS, const char *Name); |
| 4739 | LLVM_C_ABI LLVMValueRef LLVMBuildFMul(LLVMBuilderRef, LLVMValueRef LHS, |
| 4740 | LLVMValueRef RHS, const char *Name); |
| 4741 | LLVM_C_ABI LLVMValueRef LLVMBuildUDiv(LLVMBuilderRef, LLVMValueRef LHS, |
| 4742 | LLVMValueRef RHS, const char *Name); |
| 4743 | LLVM_C_ABI LLVMValueRef LLVMBuildExactUDiv(LLVMBuilderRef, LLVMValueRef LHS, |
| 4744 | LLVMValueRef RHS, const char *Name); |
| 4745 | LLVM_C_ABI LLVMValueRef LLVMBuildSDiv(LLVMBuilderRef, LLVMValueRef LHS, |
| 4746 | LLVMValueRef RHS, const char *Name); |
| 4747 | LLVM_C_ABI LLVMValueRef LLVMBuildExactSDiv(LLVMBuilderRef, LLVMValueRef LHS, |
| 4748 | LLVMValueRef RHS, const char *Name); |
| 4749 | LLVM_C_ABI LLVMValueRef LLVMBuildFDiv(LLVMBuilderRef, LLVMValueRef LHS, |
| 4750 | LLVMValueRef RHS, const char *Name); |
| 4751 | LLVM_C_ABI LLVMValueRef LLVMBuildURem(LLVMBuilderRef, LLVMValueRef LHS, |
| 4752 | LLVMValueRef RHS, const char *Name); |
| 4753 | LLVM_C_ABI LLVMValueRef LLVMBuildSRem(LLVMBuilderRef, LLVMValueRef LHS, |
| 4754 | LLVMValueRef RHS, const char *Name); |
| 4755 | LLVM_C_ABI LLVMValueRef LLVMBuildFRem(LLVMBuilderRef, LLVMValueRef LHS, |
| 4756 | LLVMValueRef RHS, const char *Name); |
| 4757 | LLVM_C_ABI LLVMValueRef LLVMBuildShl(LLVMBuilderRef, LLVMValueRef LHS, |
| 4758 | LLVMValueRef RHS, const char *Name); |
| 4759 | LLVM_C_ABI LLVMValueRef LLVMBuildLShr(LLVMBuilderRef, LLVMValueRef LHS, |
| 4760 | LLVMValueRef RHS, const char *Name); |
| 4761 | LLVM_C_ABI LLVMValueRef LLVMBuildAShr(LLVMBuilderRef, LLVMValueRef LHS, |
| 4762 | LLVMValueRef RHS, const char *Name); |
| 4763 | LLVM_C_ABI LLVMValueRef LLVMBuildAnd(LLVMBuilderRef, LLVMValueRef LHS, |
| 4764 | LLVMValueRef RHS, const char *Name); |
| 4765 | LLVM_C_ABI LLVMValueRef LLVMBuildOr(LLVMBuilderRef, LLVMValueRef LHS, |
| 4766 | LLVMValueRef RHS, const char *Name); |
| 4767 | LLVM_C_ABI LLVMValueRef LLVMBuildXor(LLVMBuilderRef, LLVMValueRef LHS, |
| 4768 | LLVMValueRef RHS, const char *Name); |
| 4769 | LLVM_C_ABI LLVMValueRef LLVMBuildBinOp(LLVMBuilderRef B, LLVMOpcode Op, |
| 4770 | LLVMValueRef LHS, LLVMValueRef RHS, |
| 4771 | const char *Name); |
| 4772 | LLVM_C_ABI LLVMValueRef LLVMBuildNeg(LLVMBuilderRef, LLVMValueRef V, |
| 4773 | const char *Name); |
| 4774 | LLVM_C_ABI LLVMValueRef LLVMBuildNSWNeg(LLVMBuilderRef B, LLVMValueRef V, |
| 4775 | const char *Name); |
| 4776 | LLVM_C_ABI LLVM_ATTRIBUTE_C_DEPRECATED( |
| 4777 | LLVMValueRef LLVMBuildNUWNeg(LLVMBuilderRef B, LLVMValueRef V, |
| 4778 | const char *Name), |
| 4779 | "Use LLVMBuildNeg + LLVMSetNUW instead." ); |
| 4780 | LLVM_C_ABI LLVMValueRef LLVMBuildFNeg(LLVMBuilderRef, LLVMValueRef V, |
| 4781 | const char *Name); |
| 4782 | LLVM_C_ABI LLVMValueRef LLVMBuildNot(LLVMBuilderRef, LLVMValueRef V, |
| 4783 | const char *Name); |
| 4784 | |
| 4785 | LLVM_C_ABI LLVMBool LLVMGetNUW(LLVMValueRef ArithInst); |
| 4786 | LLVM_C_ABI void LLVMSetNUW(LLVMValueRef ArithInst, LLVMBool HasNUW); |
| 4787 | LLVM_C_ABI LLVMBool LLVMGetNSW(LLVMValueRef ArithInst); |
| 4788 | LLVM_C_ABI void LLVMSetNSW(LLVMValueRef ArithInst, LLVMBool HasNSW); |
| 4789 | LLVM_C_ABI LLVMBool LLVMGetExact(LLVMValueRef DivOrShrInst); |
| 4790 | LLVM_C_ABI void LLVMSetExact(LLVMValueRef DivOrShrInst, LLVMBool IsExact); |
| 4791 | |
| 4792 | /** |
| 4793 | * Gets if the instruction has the non-negative flag set. |
| 4794 | * Only valid for zext instructions. |
| 4795 | */ |
| 4796 | LLVM_C_ABI LLVMBool LLVMGetNNeg(LLVMValueRef NonNegInst); |
| 4797 | /** |
| 4798 | * Sets the non-negative flag for the instruction. |
| 4799 | * Only valid for zext instructions. |
| 4800 | */ |
| 4801 | LLVM_C_ABI void LLVMSetNNeg(LLVMValueRef NonNegInst, LLVMBool IsNonNeg); |
| 4802 | |
| 4803 | /** |
| 4804 | * Get the flags for which fast-math-style optimizations are allowed for this |
| 4805 | * value. |
| 4806 | * |
| 4807 | * Only valid on floating point instructions. |
| 4808 | * @see LLVMCanValueUseFastMathFlags |
| 4809 | */ |
| 4810 | LLVM_C_ABI LLVMFastMathFlags LLVMGetFastMathFlags(LLVMValueRef FPMathInst); |
| 4811 | |
| 4812 | /** |
| 4813 | * Sets the flags for which fast-math-style optimizations are allowed for this |
| 4814 | * value. |
| 4815 | * |
| 4816 | * Only valid on floating point instructions. |
| 4817 | * @see LLVMCanValueUseFastMathFlags |
| 4818 | */ |
| 4819 | LLVM_C_ABI void LLVMSetFastMathFlags(LLVMValueRef FPMathInst, |
| 4820 | LLVMFastMathFlags FMF); |
| 4821 | |
| 4822 | /** |
| 4823 | * Check if a given value can potentially have fast math flags. |
| 4824 | * |
| 4825 | * Will return true for floating point arithmetic instructions, and for select, |
| 4826 | * phi, and call instructions whose type is a floating point type, or a vector |
| 4827 | * or array thereof. See https://llvm.org/docs/LangRef.html#fast-math-flags |
| 4828 | */ |
| 4829 | LLVM_C_ABI LLVMBool LLVMCanValueUseFastMathFlags(LLVMValueRef Inst); |
| 4830 | |
| 4831 | /** |
| 4832 | * Gets whether the instruction has the disjoint flag set. |
| 4833 | * Only valid for or instructions. |
| 4834 | */ |
| 4835 | LLVM_C_ABI LLVMBool LLVMGetIsDisjoint(LLVMValueRef Inst); |
| 4836 | /** |
| 4837 | * Sets the disjoint flag for the instruction. |
| 4838 | * Only valid for or instructions. |
| 4839 | */ |
| 4840 | LLVM_C_ABI void LLVMSetIsDisjoint(LLVMValueRef Inst, LLVMBool IsDisjoint); |
| 4841 | |
| 4842 | /* Memory */ |
| 4843 | LLVM_C_ABI LLVMValueRef LLVMBuildMalloc(LLVMBuilderRef, LLVMTypeRef Ty, |
| 4844 | const char *Name); |
| 4845 | LLVM_C_ABI LLVMValueRef LLVMBuildArrayMalloc(LLVMBuilderRef, LLVMTypeRef Ty, |
| 4846 | LLVMValueRef Val, |
| 4847 | const char *Name); |
| 4848 | |
| 4849 | /** |
| 4850 | * Creates and inserts a memset to the specified pointer and the |
| 4851 | * specified value. |
| 4852 | * |
| 4853 | * @see llvm::IRRBuilder::CreateMemSet() |
| 4854 | */ |
| 4855 | LLVM_C_ABI LLVMValueRef LLVMBuildMemSet(LLVMBuilderRef B, LLVMValueRef Ptr, |
| 4856 | LLVMValueRef Val, LLVMValueRef Len, |
| 4857 | unsigned Align); |
| 4858 | /** |
| 4859 | * Creates and inserts a memcpy between the specified pointers. |
| 4860 | * |
| 4861 | * @see llvm::IRRBuilder::CreateMemCpy() |
| 4862 | */ |
| 4863 | LLVM_C_ABI LLVMValueRef LLVMBuildMemCpy(LLVMBuilderRef B, LLVMValueRef Dst, |
| 4864 | unsigned DstAlign, LLVMValueRef Src, |
| 4865 | unsigned SrcAlign, LLVMValueRef Size); |
| 4866 | /** |
| 4867 | * Creates and inserts a memmove between the specified pointers. |
| 4868 | * |
| 4869 | * @see llvm::IRRBuilder::CreateMemMove() |
| 4870 | */ |
| 4871 | LLVM_C_ABI LLVMValueRef LLVMBuildMemMove(LLVMBuilderRef B, LLVMValueRef Dst, |
| 4872 | unsigned DstAlign, LLVMValueRef Src, |
| 4873 | unsigned SrcAlign, LLVMValueRef Size); |
| 4874 | |
| 4875 | LLVM_C_ABI LLVMValueRef LLVMBuildAlloca(LLVMBuilderRef, LLVMTypeRef Ty, |
| 4876 | const char *Name); |
| 4877 | LLVM_C_ABI LLVMValueRef LLVMBuildArrayAlloca(LLVMBuilderRef, LLVMTypeRef Ty, |
| 4878 | LLVMValueRef Val, |
| 4879 | const char *Name); |
| 4880 | LLVM_C_ABI LLVMValueRef LLVMBuildFree(LLVMBuilderRef, LLVMValueRef PointerVal); |
| 4881 | LLVM_C_ABI LLVMValueRef LLVMBuildLoad2(LLVMBuilderRef, LLVMTypeRef Ty, |
| 4882 | LLVMValueRef PointerVal, |
| 4883 | const char *Name); |
| 4884 | LLVM_C_ABI LLVMValueRef LLVMBuildStore(LLVMBuilderRef, LLVMValueRef Val, |
| 4885 | LLVMValueRef Ptr); |
| 4886 | LLVM_C_ABI LLVMValueRef LLVMBuildGEP2(LLVMBuilderRef B, LLVMTypeRef Ty, |
| 4887 | LLVMValueRef Pointer, |
| 4888 | LLVMValueRef *Indices, |
| 4889 | unsigned NumIndices, const char *Name); |
| 4890 | LLVM_C_ABI LLVMValueRef LLVMBuildInBoundsGEP2(LLVMBuilderRef B, LLVMTypeRef Ty, |
| 4891 | LLVMValueRef Pointer, |
| 4892 | LLVMValueRef *Indices, |
| 4893 | unsigned NumIndices, |
| 4894 | const char *Name); |
| 4895 | /** |
| 4896 | * Creates a GetElementPtr instruction. Similar to LLVMBuildGEP2, but allows |
| 4897 | * specifying the no-wrap flags. |
| 4898 | * |
| 4899 | * @see llvm::IRBuilder::CreateGEP() |
| 4900 | */ |
| 4901 | LLVM_C_ABI LLVMValueRef LLVMBuildGEPWithNoWrapFlags( |
| 4902 | LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Pointer, |
| 4903 | LLVMValueRef *Indices, unsigned NumIndices, const char *Name, |
| 4904 | LLVMGEPNoWrapFlags NoWrapFlags); |
| 4905 | LLVM_C_ABI LLVMValueRef LLVMBuildStructGEP2(LLVMBuilderRef B, LLVMTypeRef Ty, |
| 4906 | LLVMValueRef Pointer, unsigned Idx, |
| 4907 | const char *Name); |
| 4908 | LLVM_C_ABI LLVMValueRef LLVMBuildGlobalString(LLVMBuilderRef B, const char *Str, |
| 4909 | const char *Name); |
| 4910 | /** |
| 4911 | * Deprecated: Use LLVMBuildGlobalString instead, which has identical behavior. |
| 4912 | */ |
| 4913 | LLVM_C_ABI LLVMValueRef LLVMBuildGlobalStringPtr(LLVMBuilderRef B, |
| 4914 | const char *Str, |
| 4915 | const char *Name); |
| 4916 | LLVM_C_ABI LLVMBool LLVMGetVolatile(LLVMValueRef Inst); |
| 4917 | LLVM_C_ABI void LLVMSetVolatile(LLVMValueRef MemoryAccessInst, |
| 4918 | LLVMBool IsVolatile); |
| 4919 | LLVM_C_ABI LLVMBool LLVMGetWeak(LLVMValueRef CmpXchgInst); |
| 4920 | LLVM_C_ABI void LLVMSetWeak(LLVMValueRef CmpXchgInst, LLVMBool IsWeak); |
| 4921 | LLVM_C_ABI LLVMAtomicOrdering LLVMGetOrdering(LLVMValueRef MemoryAccessInst); |
| 4922 | LLVM_C_ABI void LLVMSetOrdering(LLVMValueRef MemoryAccessInst, |
| 4923 | LLVMAtomicOrdering Ordering); |
| 4924 | LLVM_C_ABI LLVMAtomicRMWBinOp LLVMGetAtomicRMWBinOp(LLVMValueRef AtomicRMWInst); |
| 4925 | LLVM_C_ABI void LLVMSetAtomicRMWBinOp(LLVMValueRef AtomicRMWInst, |
| 4926 | LLVMAtomicRMWBinOp BinOp); |
| 4927 | |
| 4928 | /* Casts */ |
| 4929 | LLVM_C_ABI LLVMValueRef LLVMBuildTrunc(LLVMBuilderRef, LLVMValueRef Val, |
| 4930 | LLVMTypeRef DestTy, const char *Name); |
| 4931 | LLVM_C_ABI LLVMValueRef LLVMBuildZExt(LLVMBuilderRef, LLVMValueRef Val, |
| 4932 | LLVMTypeRef DestTy, const char *Name); |
| 4933 | LLVM_C_ABI LLVMValueRef LLVMBuildSExt(LLVMBuilderRef, LLVMValueRef Val, |
| 4934 | LLVMTypeRef DestTy, const char *Name); |
| 4935 | LLVM_C_ABI LLVMValueRef LLVMBuildFPToUI(LLVMBuilderRef, LLVMValueRef Val, |
| 4936 | LLVMTypeRef DestTy, const char *Name); |
| 4937 | LLVM_C_ABI LLVMValueRef LLVMBuildFPToSI(LLVMBuilderRef, LLVMValueRef Val, |
| 4938 | LLVMTypeRef DestTy, const char *Name); |
| 4939 | LLVM_C_ABI LLVMValueRef LLVMBuildUIToFP(LLVMBuilderRef, LLVMValueRef Val, |
| 4940 | LLVMTypeRef DestTy, const char *Name); |
| 4941 | LLVM_C_ABI LLVMValueRef LLVMBuildSIToFP(LLVMBuilderRef, LLVMValueRef Val, |
| 4942 | LLVMTypeRef DestTy, const char *Name); |
| 4943 | LLVM_C_ABI LLVMValueRef LLVMBuildFPTrunc(LLVMBuilderRef, LLVMValueRef Val, |
| 4944 | LLVMTypeRef DestTy, const char *Name); |
| 4945 | LLVM_C_ABI LLVMValueRef LLVMBuildFPExt(LLVMBuilderRef, LLVMValueRef Val, |
| 4946 | LLVMTypeRef DestTy, const char *Name); |
| 4947 | LLVM_C_ABI LLVMValueRef LLVMBuildPtrToInt(LLVMBuilderRef, LLVMValueRef Val, |
| 4948 | LLVMTypeRef DestTy, const char *Name); |
| 4949 | LLVM_C_ABI LLVMValueRef LLVMBuildIntToPtr(LLVMBuilderRef, LLVMValueRef Val, |
| 4950 | LLVMTypeRef DestTy, const char *Name); |
| 4951 | LLVM_C_ABI LLVMValueRef LLVMBuildBitCast(LLVMBuilderRef, LLVMValueRef Val, |
| 4952 | LLVMTypeRef DestTy, const char *Name); |
| 4953 | LLVM_C_ABI LLVMValueRef LLVMBuildAddrSpaceCast(LLVMBuilderRef, LLVMValueRef Val, |
| 4954 | LLVMTypeRef DestTy, |
| 4955 | const char *Name); |
| 4956 | LLVM_C_ABI LLVMValueRef LLVMBuildZExtOrBitCast(LLVMBuilderRef, LLVMValueRef Val, |
| 4957 | LLVMTypeRef DestTy, |
| 4958 | const char *Name); |
| 4959 | LLVM_C_ABI LLVMValueRef LLVMBuildSExtOrBitCast(LLVMBuilderRef, LLVMValueRef Val, |
| 4960 | LLVMTypeRef DestTy, |
| 4961 | const char *Name); |
| 4962 | LLVM_C_ABI LLVMValueRef LLVMBuildTruncOrBitCast(LLVMBuilderRef, |
| 4963 | LLVMValueRef Val, |
| 4964 | LLVMTypeRef DestTy, |
| 4965 | const char *Name); |
| 4966 | LLVM_C_ABI LLVMValueRef LLVMBuildCast(LLVMBuilderRef B, LLVMOpcode Op, |
| 4967 | LLVMValueRef Val, LLVMTypeRef DestTy, |
| 4968 | const char *Name); |
| 4969 | LLVM_C_ABI LLVMValueRef LLVMBuildPointerCast(LLVMBuilderRef, LLVMValueRef Val, |
| 4970 | LLVMTypeRef DestTy, |
| 4971 | const char *Name); |
| 4972 | LLVM_C_ABI LLVMValueRef LLVMBuildIntCast2(LLVMBuilderRef, LLVMValueRef Val, |
| 4973 | LLVMTypeRef DestTy, LLVMBool IsSigned, |
| 4974 | const char *Name); |
| 4975 | LLVM_C_ABI LLVMValueRef LLVMBuildFPCast(LLVMBuilderRef, LLVMValueRef Val, |
| 4976 | LLVMTypeRef DestTy, const char *Name); |
| 4977 | |
| 4978 | /** Deprecated: This cast is always signed. Use LLVMBuildIntCast2 instead. */ |
| 4979 | LLVM_C_ABI LLVMValueRef LLVMBuildIntCast(LLVMBuilderRef, |
| 4980 | LLVMValueRef Val, /*Signed cast!*/ |
| 4981 | LLVMTypeRef DestTy, const char *Name); |
| 4982 | |
| 4983 | LLVM_C_ABI LLVMOpcode LLVMGetCastOpcode(LLVMValueRef Src, LLVMBool SrcIsSigned, |
| 4984 | LLVMTypeRef DestTy, |
| 4985 | LLVMBool DestIsSigned); |
| 4986 | |
| 4987 | /* Comparisons */ |
| 4988 | LLVM_C_ABI LLVMValueRef LLVMBuildICmp(LLVMBuilderRef, LLVMIntPredicate Op, |
| 4989 | LLVMValueRef LHS, LLVMValueRef RHS, |
| 4990 | const char *Name); |
| 4991 | LLVM_C_ABI LLVMValueRef LLVMBuildFCmp(LLVMBuilderRef, LLVMRealPredicate Op, |
| 4992 | LLVMValueRef LHS, LLVMValueRef RHS, |
| 4993 | const char *Name); |
| 4994 | |
| 4995 | /* Miscellaneous instructions */ |
| 4996 | LLVM_C_ABI LLVMValueRef LLVMBuildPhi(LLVMBuilderRef, LLVMTypeRef Ty, |
| 4997 | const char *Name); |
| 4998 | LLVM_C_ABI LLVMValueRef LLVMBuildCall2(LLVMBuilderRef, LLVMTypeRef, |
| 4999 | LLVMValueRef Fn, LLVMValueRef *Args, |
| 5000 | unsigned NumArgs, const char *Name); |
| 5001 | LLVM_C_ABI LLVMValueRef LLVMBuildCallWithOperandBundles( |
| 5002 | LLVMBuilderRef, LLVMTypeRef, LLVMValueRef Fn, LLVMValueRef *Args, |
| 5003 | unsigned NumArgs, LLVMOperandBundleRef *Bundles, unsigned NumBundles, |
| 5004 | const char *Name); |
| 5005 | LLVM_C_ABI LLVMValueRef LLVMBuildSelect(LLVMBuilderRef, LLVMValueRef If, |
| 5006 | LLVMValueRef Then, LLVMValueRef Else, |
| 5007 | const char *Name); |
| 5008 | LLVM_C_ABI LLVMValueRef LLVMBuildVAArg(LLVMBuilderRef, LLVMValueRef List, |
| 5009 | LLVMTypeRef Ty, const char *Name); |
| 5010 | LLVM_C_ABI LLVMValueRef (LLVMBuilderRef, |
| 5011 | LLVMValueRef VecVal, |
| 5012 | LLVMValueRef Index, |
| 5013 | const char *Name); |
| 5014 | LLVM_C_ABI LLVMValueRef LLVMBuildInsertElement(LLVMBuilderRef, |
| 5015 | LLVMValueRef VecVal, |
| 5016 | LLVMValueRef EltVal, |
| 5017 | LLVMValueRef Index, |
| 5018 | const char *Name); |
| 5019 | LLVM_C_ABI LLVMValueRef LLVMBuildShuffleVector(LLVMBuilderRef, LLVMValueRef V1, |
| 5020 | LLVMValueRef V2, |
| 5021 | LLVMValueRef Mask, |
| 5022 | const char *Name); |
| 5023 | LLVM_C_ABI LLVMValueRef (LLVMBuilderRef, |
| 5024 | LLVMValueRef AggVal, |
| 5025 | unsigned Index, const char *Name); |
| 5026 | LLVM_C_ABI LLVMValueRef LLVMBuildInsertValue(LLVMBuilderRef, |
| 5027 | LLVMValueRef AggVal, |
| 5028 | LLVMValueRef EltVal, |
| 5029 | unsigned Index, const char *Name); |
| 5030 | LLVM_C_ABI LLVMValueRef LLVMBuildFreeze(LLVMBuilderRef, LLVMValueRef Val, |
| 5031 | const char *Name); |
| 5032 | |
| 5033 | LLVM_C_ABI LLVMValueRef LLVMBuildIsNull(LLVMBuilderRef, LLVMValueRef Val, |
| 5034 | const char *Name); |
| 5035 | LLVM_C_ABI LLVMValueRef LLVMBuildIsNotNull(LLVMBuilderRef, LLVMValueRef Val, |
| 5036 | const char *Name); |
| 5037 | LLVM_C_ABI LLVMValueRef LLVMBuildPtrDiff2(LLVMBuilderRef, LLVMTypeRef ElemTy, |
| 5038 | LLVMValueRef LHS, LLVMValueRef RHS, |
| 5039 | const char *Name); |
| 5040 | LLVM_C_ABI LLVMValueRef LLVMBuildFence(LLVMBuilderRef B, |
| 5041 | LLVMAtomicOrdering ordering, |
| 5042 | LLVMBool singleThread, const char *Name); |
| 5043 | LLVM_C_ABI LLVMValueRef LLVMBuildFenceSyncScope(LLVMBuilderRef B, |
| 5044 | LLVMAtomicOrdering ordering, |
| 5045 | unsigned SSID, |
| 5046 | const char *Name); |
| 5047 | LLVM_C_ABI LLVMValueRef LLVMBuildAtomicRMW(LLVMBuilderRef B, |
| 5048 | LLVMAtomicRMWBinOp op, |
| 5049 | LLVMValueRef PTR, LLVMValueRef Val, |
| 5050 | LLVMAtomicOrdering ordering, |
| 5051 | LLVMBool singleThread); |
| 5052 | LLVM_C_ABI LLVMValueRef LLVMBuildAtomicRMWSyncScope( |
| 5053 | LLVMBuilderRef B, LLVMAtomicRMWBinOp op, LLVMValueRef PTR, LLVMValueRef Val, |
| 5054 | LLVMAtomicOrdering ordering, unsigned SSID); |
| 5055 | LLVM_C_ABI LLVMValueRef LLVMBuildAtomicCmpXchg( |
| 5056 | LLVMBuilderRef B, LLVMValueRef Ptr, LLVMValueRef Cmp, LLVMValueRef New, |
| 5057 | LLVMAtomicOrdering SuccessOrdering, LLVMAtomicOrdering FailureOrdering, |
| 5058 | LLVMBool SingleThread); |
| 5059 | LLVM_C_ABI LLVMValueRef LLVMBuildAtomicCmpXchgSyncScope( |
| 5060 | LLVMBuilderRef B, LLVMValueRef Ptr, LLVMValueRef Cmp, LLVMValueRef New, |
| 5061 | LLVMAtomicOrdering SuccessOrdering, LLVMAtomicOrdering FailureOrdering, |
| 5062 | unsigned SSID); |
| 5063 | |
| 5064 | /** |
| 5065 | * Get the number of elements in the mask of a ShuffleVector instruction. |
| 5066 | */ |
| 5067 | LLVM_C_ABI unsigned LLVMGetNumMaskElements(LLVMValueRef ShuffleVectorInst); |
| 5068 | |
| 5069 | /** |
| 5070 | * \returns a constant that specifies that the result of a \c ShuffleVectorInst |
| 5071 | * is undefined. |
| 5072 | */ |
| 5073 | LLVM_C_ABI int LLVMGetUndefMaskElem(void); |
| 5074 | |
| 5075 | /** |
| 5076 | * Get the mask value at position Elt in the mask of a ShuffleVector |
| 5077 | * instruction. |
| 5078 | * |
| 5079 | * \Returns the result of \c LLVMGetUndefMaskElem() if the mask value is |
| 5080 | * poison at that position. |
| 5081 | */ |
| 5082 | LLVM_C_ABI int LLVMGetMaskValue(LLVMValueRef ShuffleVectorInst, unsigned Elt); |
| 5083 | |
| 5084 | LLVM_C_ABI LLVMBool LLVMIsAtomicSingleThread(LLVMValueRef AtomicInst); |
| 5085 | LLVM_C_ABI void LLVMSetAtomicSingleThread(LLVMValueRef AtomicInst, |
| 5086 | LLVMBool SingleThread); |
| 5087 | |
| 5088 | /** |
| 5089 | * Returns whether an instruction is an atomic instruction, e.g., atomicrmw, |
| 5090 | * cmpxchg, fence, or loads and stores with atomic ordering. |
| 5091 | */ |
| 5092 | LLVM_C_ABI LLVMBool LLVMIsAtomic(LLVMValueRef Inst); |
| 5093 | |
| 5094 | /** |
| 5095 | * Returns the synchronization scope ID of an atomic instruction. |
| 5096 | */ |
| 5097 | LLVM_C_ABI unsigned LLVMGetAtomicSyncScopeID(LLVMValueRef AtomicInst); |
| 5098 | |
| 5099 | /** |
| 5100 | * Sets the synchronization scope ID of an atomic instruction. |
| 5101 | */ |
| 5102 | LLVM_C_ABI void LLVMSetAtomicSyncScopeID(LLVMValueRef AtomicInst, |
| 5103 | unsigned SSID); |
| 5104 | |
| 5105 | LLVM_C_ABI LLVMAtomicOrdering |
| 5106 | LLVMGetCmpXchgSuccessOrdering(LLVMValueRef CmpXchgInst); |
| 5107 | LLVM_C_ABI void LLVMSetCmpXchgSuccessOrdering(LLVMValueRef CmpXchgInst, |
| 5108 | LLVMAtomicOrdering Ordering); |
| 5109 | LLVM_C_ABI LLVMAtomicOrdering |
| 5110 | LLVMGetCmpXchgFailureOrdering(LLVMValueRef CmpXchgInst); |
| 5111 | LLVM_C_ABI void LLVMSetCmpXchgFailureOrdering(LLVMValueRef CmpXchgInst, |
| 5112 | LLVMAtomicOrdering Ordering); |
| 5113 | |
| 5114 | /** |
| 5115 | * @} |
| 5116 | */ |
| 5117 | |
| 5118 | /** |
| 5119 | * @defgroup LLVMCCoreModuleProvider Module Providers |
| 5120 | * |
| 5121 | * @{ |
| 5122 | */ |
| 5123 | |
| 5124 | /** |
| 5125 | * Changes the type of M so it can be passed to FunctionPassManagers and the |
| 5126 | * JIT. They take ModuleProviders for historical reasons. |
| 5127 | */ |
| 5128 | LLVM_C_ABI LLVMModuleProviderRef |
| 5129 | LLVMCreateModuleProviderForExistingModule(LLVMModuleRef M); |
| 5130 | |
| 5131 | /** |
| 5132 | * Destroys the module M. |
| 5133 | */ |
| 5134 | LLVM_C_ABI void LLVMDisposeModuleProvider(LLVMModuleProviderRef M); |
| 5135 | |
| 5136 | /** |
| 5137 | * @} |
| 5138 | */ |
| 5139 | |
| 5140 | /** |
| 5141 | * @defgroup LLVMCCoreMemoryBuffers Memory Buffers |
| 5142 | * |
| 5143 | * @{ |
| 5144 | */ |
| 5145 | |
| 5146 | LLVM_C_ABI LLVMBool LLVMCreateMemoryBufferWithContentsOfFile( |
| 5147 | const char *Path, LLVMMemoryBufferRef *OutMemBuf, char **OutMessage); |
| 5148 | LLVM_C_ABI LLVMBool LLVMCreateMemoryBufferWithSTDIN( |
| 5149 | LLVMMemoryBufferRef *OutMemBuf, char **OutMessage); |
| 5150 | LLVM_C_ABI LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRange( |
| 5151 | const char *InputData, size_t InputDataLength, const char *BufferName, |
| 5152 | LLVMBool RequiresNullTerminator); |
| 5153 | LLVM_C_ABI LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRangeCopy( |
| 5154 | const char *InputData, size_t InputDataLength, const char *BufferName); |
| 5155 | LLVM_C_ABI const char *LLVMGetBufferStart(LLVMMemoryBufferRef MemBuf); |
| 5156 | LLVM_C_ABI size_t LLVMGetBufferSize(LLVMMemoryBufferRef MemBuf); |
| 5157 | LLVM_C_ABI void LLVMDisposeMemoryBuffer(LLVMMemoryBufferRef MemBuf); |
| 5158 | |
| 5159 | /** |
| 5160 | * @} |
| 5161 | */ |
| 5162 | |
| 5163 | /** |
| 5164 | * @defgroup LLVMCCorePassManagers Pass Managers |
| 5165 | * @ingroup LLVMCCore |
| 5166 | * |
| 5167 | * @{ |
| 5168 | */ |
| 5169 | |
| 5170 | /** Constructs a new whole-module pass pipeline. This type of pipeline is |
| 5171 | suitable for link-time optimization and whole-module transformations. |
| 5172 | @see llvm::PassManager::PassManager */ |
| 5173 | LLVM_C_ABI LLVMPassManagerRef LLVMCreatePassManager(void); |
| 5174 | |
| 5175 | /** Constructs a new function-by-function pass pipeline over the module |
| 5176 | provider. It does not take ownership of the module provider. This type of |
| 5177 | pipeline is suitable for code generation and JIT compilation tasks. |
| 5178 | @see llvm::FunctionPassManager::FunctionPassManager */ |
| 5179 | LLVM_C_ABI LLVMPassManagerRef |
| 5180 | LLVMCreateFunctionPassManagerForModule(LLVMModuleRef M); |
| 5181 | |
| 5182 | /** Deprecated: Use LLVMCreateFunctionPassManagerForModule instead. */ |
| 5183 | LLVM_C_ABI LLVMPassManagerRef |
| 5184 | LLVMCreateFunctionPassManager(LLVMModuleProviderRef MP); |
| 5185 | |
| 5186 | /** Initializes, executes on the provided module, and finalizes all of the |
| 5187 | passes scheduled in the pass manager. Returns 1 if any of the passes |
| 5188 | modified the module, 0 otherwise. |
| 5189 | @see llvm::PassManager::run(Module&) */ |
| 5190 | LLVM_C_ABI LLVMBool LLVMRunPassManager(LLVMPassManagerRef PM, LLVMModuleRef M); |
| 5191 | |
| 5192 | /** Initializes all of the function passes scheduled in the function pass |
| 5193 | manager. Returns 1 if any of the passes modified the module, 0 otherwise. |
| 5194 | @see llvm::FunctionPassManager::doInitialization */ |
| 5195 | LLVM_C_ABI LLVMBool LLVMInitializeFunctionPassManager(LLVMPassManagerRef FPM); |
| 5196 | |
| 5197 | /** Executes all of the function passes scheduled in the function pass manager |
| 5198 | on the provided function. Returns 1 if any of the passes modified the |
| 5199 | function, false otherwise. |
| 5200 | @see llvm::FunctionPassManager::run(Function&) */ |
| 5201 | LLVM_C_ABI LLVMBool LLVMRunFunctionPassManager(LLVMPassManagerRef FPM, |
| 5202 | LLVMValueRef F); |
| 5203 | |
| 5204 | /** Finalizes all of the function passes scheduled in the function pass |
| 5205 | manager. Returns 1 if any of the passes modified the module, 0 otherwise. |
| 5206 | @see llvm::FunctionPassManager::doFinalization */ |
| 5207 | LLVM_C_ABI LLVMBool LLVMFinalizeFunctionPassManager(LLVMPassManagerRef FPM); |
| 5208 | |
| 5209 | /** Frees the memory of a pass pipeline. For function pipelines, does not free |
| 5210 | the module provider. |
| 5211 | @see llvm::PassManagerBase::~PassManagerBase. */ |
| 5212 | LLVM_C_ABI void LLVMDisposePassManager(LLVMPassManagerRef PM); |
| 5213 | |
| 5214 | /** |
| 5215 | * @} |
| 5216 | */ |
| 5217 | |
| 5218 | /** |
| 5219 | * @defgroup LLVMCCoreThreading Threading |
| 5220 | * |
| 5221 | * Handle the structures needed to make LLVM safe for multithreading. |
| 5222 | * |
| 5223 | * @{ |
| 5224 | */ |
| 5225 | |
| 5226 | /** Deprecated: Multi-threading can only be enabled/disabled with the compile |
| 5227 | time define LLVM_ENABLE_THREADS. This function always returns |
| 5228 | LLVMIsMultithreaded(). */ |
| 5229 | LLVM_C_ABI LLVMBool LLVMStartMultithreaded(void); |
| 5230 | |
| 5231 | /** Deprecated: Multi-threading can only be enabled/disabled with the compile |
| 5232 | time define LLVM_ENABLE_THREADS. */ |
| 5233 | LLVM_C_ABI void LLVMStopMultithreaded(void); |
| 5234 | |
| 5235 | /** Check whether LLVM is executing in thread-safe mode or not. |
| 5236 | @see llvm::llvm_is_multithreaded */ |
| 5237 | LLVM_C_ABI LLVMBool LLVMIsMultithreaded(void); |
| 5238 | |
| 5239 | /** |
| 5240 | * @} |
| 5241 | */ |
| 5242 | |
| 5243 | /** |
| 5244 | * @} |
| 5245 | */ |
| 5246 | |
| 5247 | /** |
| 5248 | * @} |
| 5249 | */ |
| 5250 | |
| 5251 | LLVM_C_EXTERN_C_END |
| 5252 | |
| 5253 | #endif /* LLVM_C_CORE_H */ |
| 5254 | |