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