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