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