1 /*===-- llvm-c/Core.h - Core Library C Interface ------------------*- C -*-===*\
3 |* Part of the LLVM Project, under the Apache License v2.0 with LLVM *|
5 |* See https://llvm.org/LICENSE.txt for license information. *|
6 |* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *|
8 |*===----------------------------------------------------------------------===*|
10 |* This header declares the C interface to libLLVMCore.a, which implements *|
11 |* the LLVM intermediate representation. *|
13 \*===----------------------------------------------------------------------===*/
18 #include "llvm-c/ErrorHandling.h"
19 #include "llvm-c/ExternC.h"
20 #include "llvm-c/Types.h"
25 * @defgroup LLVMC LLVM-C: C interface to LLVM
27 * This module exposes parts of the LLVM library as a C API.
33 * @defgroup LLVMCTransforms Transforms
37 * @defgroup LLVMCCore Core
39 * This modules provide an interface to libLLVMCore, which implements
40 * the LLVM intermediate representation as well as other related types
43 * Many exotic languages can interoperate with C code but have a harder time
44 * with C++ due to name mangling. So in addition to C, this interface enables
45 * tools written in such languages.
51 * @defgroup LLVMCCoreTypes Types and Enumerations
56 /// External users depend on the following values being stable. It is not safe
59 /* Terminator Instructions */
65 /* removed 6 due to API changes */
69 /* Standard Unary Operators */
72 /* Standard Binary Operators */
86 /* Logical Operators */
94 /* Memory Operators */
98 LLVMGetElementPtr = 29,
113 LLVMAddrSpaceCast = 60,
115 /* Other Operators */
124 LLVMExtractElement = 50,
125 LLVMInsertElement = 51,
126 LLVMShuffleVector = 52,
127 LLVMExtractValue = 53,
128 LLVMInsertValue = 54,
131 /* Atomic operators */
133 LLVMAtomicCmpXchg = 56,
136 /* Exception Handling Operators */
147 LLVMVoidTypeKind, /**< type with no size */
148 LLVMHalfTypeKind, /**< 16 bit floating point type */
149 LLVMFloatTypeKind, /**< 32 bit floating point type */
150 LLVMDoubleTypeKind, /**< 64 bit floating point type */
151 LLVMX86_FP80TypeKind, /**< 80 bit floating point type (X87) */
152 LLVMFP128TypeKind, /**< 128 bit floating point type (112-bit mantissa)*/
153 LLVMPPC_FP128TypeKind, /**< 128 bit floating point type (two 64-bits) */
154 LLVMLabelTypeKind, /**< Labels */
155 LLVMIntegerTypeKind, /**< Arbitrary bit width integers */
156 LLVMFunctionTypeKind, /**< Functions */
157 LLVMStructTypeKind, /**< Structures */
158 LLVMArrayTypeKind, /**< Arrays */
159 LLVMPointerTypeKind, /**< Pointers */
160 LLVMVectorTypeKind, /**< SIMD 'packed' format, or other vector type */
161 LLVMMetadataTypeKind, /**< Metadata */
162 LLVMX86_MMXTypeKind, /**< X86 MMX */
163 LLVMTokenTypeKind /**< Tokens */
167 LLVMExternalLinkage, /**< Externally visible function */
168 LLVMAvailableExternallyLinkage,
169 LLVMLinkOnceAnyLinkage, /**< Keep one copy of function when linking (inline)*/
170 LLVMLinkOnceODRLinkage, /**< Same, but only replaced by something
172 LLVMLinkOnceODRAutoHideLinkage, /**< Obsolete */
173 LLVMWeakAnyLinkage, /**< Keep one copy of function when linking (weak) */
174 LLVMWeakODRLinkage, /**< Same, but only replaced by something
176 LLVMAppendingLinkage, /**< Special purpose, only applies to global arrays */
177 LLVMInternalLinkage, /**< Rename collisions when linking (static
179 LLVMPrivateLinkage, /**< Like Internal, but omit from symbol table */
180 LLVMDLLImportLinkage, /**< Obsolete */
181 LLVMDLLExportLinkage, /**< Obsolete */
182 LLVMExternalWeakLinkage,/**< ExternalWeak linkage description */
183 LLVMGhostLinkage, /**< Obsolete */
184 LLVMCommonLinkage, /**< Tentative definitions */
185 LLVMLinkerPrivateLinkage, /**< Like Private, but linker removes. */
186 LLVMLinkerPrivateWeakLinkage /**< Like LinkerPrivate, but is weak. */
190 LLVMDefaultVisibility, /**< The GV is visible */
191 LLVMHiddenVisibility, /**< The GV is hidden */
192 LLVMProtectedVisibility /**< The GV is protected */
196 LLVMNoUnnamedAddr, /**< Address of the GV is significant. */
197 LLVMLocalUnnamedAddr, /**< Address of the GV is locally insignificant. */
198 LLVMGlobalUnnamedAddr /**< Address of the GV is globally insignificant. */
202 LLVMDefaultStorageClass = 0,
203 LLVMDLLImportStorageClass = 1, /**< Function to be imported from DLL. */
204 LLVMDLLExportStorageClass = 2 /**< Function to be accessible from DLL. */
205 } LLVMDLLStorageClass;
209 LLVMFastCallConv = 8,
210 LLVMColdCallConv = 9,
211 LLVMGHCCallConv = 10,
212 LLVMHiPECallConv = 11,
213 LLVMWebKitJSCallConv = 12,
214 LLVMAnyRegCallConv = 13,
215 LLVMPreserveMostCallConv = 14,
216 LLVMPreserveAllCallConv = 15,
217 LLVMSwiftCallConv = 16,
218 LLVMCXXFASTTLSCallConv = 17,
219 LLVMX86StdcallCallConv = 64,
220 LLVMX86FastcallCallConv = 65,
221 LLVMARMAPCSCallConv = 66,
222 LLVMARMAAPCSCallConv = 67,
223 LLVMARMAAPCSVFPCallConv = 68,
224 LLVMMSP430INTRCallConv = 69,
225 LLVMX86ThisCallCallConv = 70,
226 LLVMPTXKernelCallConv = 71,
227 LLVMPTXDeviceCallConv = 72,
228 LLVMSPIRFUNCCallConv = 75,
229 LLVMSPIRKERNELCallConv = 76,
230 LLVMIntelOCLBICallConv = 77,
231 LLVMX8664SysVCallConv = 78,
232 LLVMWin64CallConv = 79,
233 LLVMX86VectorCallCallConv = 80,
234 LLVMHHVMCallConv = 81,
235 LLVMHHVMCCallConv = 82,
236 LLVMX86INTRCallConv = 83,
237 LLVMAVRINTRCallConv = 84,
238 LLVMAVRSIGNALCallConv = 85,
239 LLVMAVRBUILTINCallConv = 86,
240 LLVMAMDGPUVSCallConv = 87,
241 LLVMAMDGPUGSCallConv = 88,
242 LLVMAMDGPUPSCallConv = 89,
243 LLVMAMDGPUCSCallConv = 90,
244 LLVMAMDGPUKERNELCallConv = 91,
245 LLVMX86RegCallCallConv = 92,
246 LLVMAMDGPUHSCallConv = 93,
247 LLVMMSP430BUILTINCallConv = 94,
248 LLVMAMDGPULSCallConv = 95,
249 LLVMAMDGPUESCallConv = 96
253 LLVMArgumentValueKind,
254 LLVMBasicBlockValueKind,
255 LLVMMemoryUseValueKind,
256 LLVMMemoryDefValueKind,
257 LLVMMemoryPhiValueKind,
259 LLVMFunctionValueKind,
260 LLVMGlobalAliasValueKind,
261 LLVMGlobalIFuncValueKind,
262 LLVMGlobalVariableValueKind,
263 LLVMBlockAddressValueKind,
264 LLVMConstantExprValueKind,
265 LLVMConstantArrayValueKind,
266 LLVMConstantStructValueKind,
267 LLVMConstantVectorValueKind,
269 LLVMUndefValueValueKind,
270 LLVMConstantAggregateZeroValueKind,
271 LLVMConstantDataArrayValueKind,
272 LLVMConstantDataVectorValueKind,
273 LLVMConstantIntValueKind,
274 LLVMConstantFPValueKind,
275 LLVMConstantPointerNullValueKind,
276 LLVMConstantTokenNoneValueKind,
278 LLVMMetadataAsValueValueKind,
279 LLVMInlineAsmValueKind,
281 LLVMInstructionValueKind,
285 LLVMIntEQ = 32, /**< equal */
286 LLVMIntNE, /**< not equal */
287 LLVMIntUGT, /**< unsigned greater than */
288 LLVMIntUGE, /**< unsigned greater or equal */
289 LLVMIntULT, /**< unsigned less than */
290 LLVMIntULE, /**< unsigned less or equal */
291 LLVMIntSGT, /**< signed greater than */
292 LLVMIntSGE, /**< signed greater or equal */
293 LLVMIntSLT, /**< signed less than */
294 LLVMIntSLE /**< signed less or equal */
298 LLVMRealPredicateFalse, /**< Always false (always folded) */
299 LLVMRealOEQ, /**< True if ordered and equal */
300 LLVMRealOGT, /**< True if ordered and greater than */
301 LLVMRealOGE, /**< True if ordered and greater than or equal */
302 LLVMRealOLT, /**< True if ordered and less than */
303 LLVMRealOLE, /**< True if ordered and less than or equal */
304 LLVMRealONE, /**< True if ordered and operands are unequal */
305 LLVMRealORD, /**< True if ordered (no nans) */
306 LLVMRealUNO, /**< True if unordered: isnan(X) | isnan(Y) */
307 LLVMRealUEQ, /**< True if unordered or equal */
308 LLVMRealUGT, /**< True if unordered or greater than */
309 LLVMRealUGE, /**< True if unordered, greater than, or equal */
310 LLVMRealULT, /**< True if unordered or less than */
311 LLVMRealULE, /**< True if unordered, less than, or equal */
312 LLVMRealUNE, /**< True if unordered or not equal */
313 LLVMRealPredicateTrue /**< Always true (always folded) */
317 LLVMLandingPadCatch, /**< A catch clause */
318 LLVMLandingPadFilter /**< A filter clause */
319 } LLVMLandingPadClauseTy;
322 LLVMNotThreadLocal = 0,
323 LLVMGeneralDynamicTLSModel,
324 LLVMLocalDynamicTLSModel,
325 LLVMInitialExecTLSModel,
326 LLVMLocalExecTLSModel
327 } LLVMThreadLocalMode;
330 LLVMAtomicOrderingNotAtomic = 0, /**< A load or store which is not atomic */
331 LLVMAtomicOrderingUnordered = 1, /**< Lowest level of atomicity, guarantees
332 somewhat sane results, lock free. */
333 LLVMAtomicOrderingMonotonic = 2, /**< guarantees that if you take all the
334 operations affecting a specific address,
335 a consistent ordering exists */
336 LLVMAtomicOrderingAcquire = 4, /**< Acquire provides a barrier of the sort
337 necessary to acquire a lock to access other
338 memory with normal loads and stores. */
339 LLVMAtomicOrderingRelease = 5, /**< Release is similar to Acquire, but with
340 a barrier of the sort necessary to release
342 LLVMAtomicOrderingAcquireRelease = 6, /**< provides both an Acquire and a
343 Release barrier (for fences and
344 operations which both read and write
346 LLVMAtomicOrderingSequentiallyConsistent = 7 /**< provides Acquire semantics
347 for loads and Release
348 semantics for stores.
349 Additionally, it guarantees
350 that a total ordering exists
352 SequentiallyConsistent
354 } LLVMAtomicOrdering;
357 LLVMAtomicRMWBinOpXchg, /**< Set the new value and return the one old */
358 LLVMAtomicRMWBinOpAdd, /**< Add a value and return the old one */
359 LLVMAtomicRMWBinOpSub, /**< Subtract a value and return the old one */
360 LLVMAtomicRMWBinOpAnd, /**< And a value and return the old one */
361 LLVMAtomicRMWBinOpNand, /**< Not-And a value and return the old one */
362 LLVMAtomicRMWBinOpOr, /**< OR a value and return the old one */
363 LLVMAtomicRMWBinOpXor, /**< Xor a value and return the old one */
364 LLVMAtomicRMWBinOpMax, /**< Sets the value if it's greater than the
365 original using a signed comparison and return
367 LLVMAtomicRMWBinOpMin, /**< Sets the value if it's Smaller than the
368 original using a signed comparison and return
370 LLVMAtomicRMWBinOpUMax, /**< Sets the value if it's greater than the
371 original using an unsigned comparison and return
373 LLVMAtomicRMWBinOpUMin, /**< Sets the value if it's greater than the
374 original using an unsigned comparison and return
376 LLVMAtomicRMWBinOpFAdd, /**< Add a floating point value and return the
378 LLVMAtomicRMWBinOpFSub /**< Subtract a floating point value and return the
380 } LLVMAtomicRMWBinOp;
387 } LLVMDiagnosticSeverity;
390 LLVMInlineAsmDialectATT,
391 LLVMInlineAsmDialectIntel
392 } LLVMInlineAsmDialect;
396 * Emits an error if two values disagree, otherwise the resulting value is
397 * that of the operands.
399 * @see Module::ModFlagBehavior::Error
401 LLVMModuleFlagBehaviorError,
403 * Emits a warning if two values disagree. The result value will be the
404 * operand for the flag from the first module being linked.
406 * @see Module::ModFlagBehavior::Warning
408 LLVMModuleFlagBehaviorWarning,
410 * Adds a requirement that another module flag be present and have a
411 * specified value after linking is performed. The value must be a metadata
412 * pair, where the first element of the pair is the ID of the module flag
413 * to be restricted, and the second element of the pair is the value the
414 * module flag should be restricted to. This behavior can be used to
415 * restrict the allowable results (via triggering of an error) of linking
416 * IDs with the **Override** behavior.
418 * @see Module::ModFlagBehavior::Require
420 LLVMModuleFlagBehaviorRequire,
422 * Uses the specified value, regardless of the behavior or value of the
423 * other module. If both modules specify **Override**, but the values
424 * differ, an error will be emitted.
426 * @see Module::ModFlagBehavior::Override
428 LLVMModuleFlagBehaviorOverride,
430 * Appends the two values, which are required to be metadata nodes.
432 * @see Module::ModFlagBehavior::Append
434 LLVMModuleFlagBehaviorAppend,
436 * Appends the two values, which are required to be metadata
437 * nodes. However, duplicate entries in the second list are dropped
438 * during the append operation.
440 * @see Module::ModFlagBehavior::AppendUnique
442 LLVMModuleFlagBehaviorAppendUnique,
443 } LLVMModuleFlagBehavior;
446 * Attribute index are either LLVMAttributeReturnIndex,
447 * LLVMAttributeFunctionIndex or a parameter number from 1 to N.
450 LLVMAttributeReturnIndex = 0U,
451 // ISO C restricts enumerator values to range of 'int'
452 // (4294967295 is too large)
453 // LLVMAttributeFunctionIndex = ~0U,
454 LLVMAttributeFunctionIndex = -1,
457 typedef unsigned LLVMAttributeIndex;
463 void LLVMInitializeCore(LLVMPassRegistryRef R);
465 /** Deallocate and destroy all ManagedStatic variables.
466 @see llvm::llvm_shutdown
467 @see ManagedStatic */
468 void LLVMShutdown(void);
470 /*===-- Error handling ----------------------------------------------------===*/
472 char *LLVMCreateMessage(const char *Message);
473 void LLVMDisposeMessage(char *Message);
476 * @defgroup LLVMCCoreContext Contexts
478 * Contexts are execution states for the core LLVM IR system.
480 * Most types are tied to a context instance. Multiple contexts can
481 * exist simultaneously. A single context is not thread safe. However,
482 * different contexts can execute on different threads simultaneously.
487 typedef void (*LLVMDiagnosticHandler)(LLVMDiagnosticInfoRef, void *);
488 typedef void (*LLVMYieldCallback)(LLVMContextRef, void *);
491 * Create a new context.
493 * Every call to this function should be paired with a call to
494 * LLVMContextDispose() or the context will leak memory.
496 LLVMContextRef LLVMContextCreate(void);
499 * Obtain the global context instance.
501 LLVMContextRef LLVMGetGlobalContext(void);
504 * Set the diagnostic handler for this context.
506 void LLVMContextSetDiagnosticHandler(LLVMContextRef C,
507 LLVMDiagnosticHandler Handler,
508 void *DiagnosticContext);
511 * Get the diagnostic handler of this context.
513 LLVMDiagnosticHandler LLVMContextGetDiagnosticHandler(LLVMContextRef C);
516 * Get the diagnostic context of this context.
518 void *LLVMContextGetDiagnosticContext(LLVMContextRef C);
521 * Set the yield callback function for this context.
523 * @see LLVMContext::setYieldCallback()
525 void LLVMContextSetYieldCallback(LLVMContextRef C, LLVMYieldCallback Callback,
529 * Retrieve whether the given context is set to discard all value names.
531 * @see LLVMContext::shouldDiscardValueNames()
533 LLVMBool LLVMContextShouldDiscardValueNames(LLVMContextRef C);
536 * Set whether the given context discards all value names.
538 * If true, only the names of GlobalValue objects will be available in the IR.
539 * This can be used to save memory and runtime, especially in release mode.
541 * @see LLVMContext::setDiscardValueNames()
543 void LLVMContextSetDiscardValueNames(LLVMContextRef C, LLVMBool Discard);
546 * Destroy a context instance.
548 * This should be called for every call to LLVMContextCreate() or memory
551 void LLVMContextDispose(LLVMContextRef C);
554 * Return a string representation of the DiagnosticInfo. Use
555 * LLVMDisposeMessage to free the string.
557 * @see DiagnosticInfo::print()
559 char *LLVMGetDiagInfoDescription(LLVMDiagnosticInfoRef DI);
562 * Return an enum LLVMDiagnosticSeverity.
564 * @see DiagnosticInfo::getSeverity()
566 LLVMDiagnosticSeverity LLVMGetDiagInfoSeverity(LLVMDiagnosticInfoRef DI);
568 unsigned LLVMGetMDKindIDInContext(LLVMContextRef C, const char *Name,
570 unsigned LLVMGetMDKindID(const char *Name, unsigned SLen);
573 * Return an unique id given the name of a enum attribute,
574 * or 0 if no attribute by that name exists.
576 * See http://llvm.org/docs/LangRef.html#parameter-attributes
577 * and http://llvm.org/docs/LangRef.html#function-attributes
578 * for the list of available attributes.
580 * NB: Attribute names and/or id are subject to change without
581 * going through the C API deprecation cycle.
583 unsigned LLVMGetEnumAttributeKindForName(const char *Name, size_t SLen);
584 unsigned LLVMGetLastEnumAttributeKind(void);
587 * Create an enum attribute.
589 LLVMAttributeRef LLVMCreateEnumAttribute(LLVMContextRef C, unsigned KindID,
593 * Get the unique id corresponding to the enum attribute
594 * passed as argument.
596 unsigned LLVMGetEnumAttributeKind(LLVMAttributeRef A);
599 * Get the enum attribute's value. 0 is returned if none exists.
601 uint64_t LLVMGetEnumAttributeValue(LLVMAttributeRef A);
604 * Create a string attribute.
606 LLVMAttributeRef LLVMCreateStringAttribute(LLVMContextRef C,
607 const char *K, unsigned KLength,
608 const char *V, unsigned VLength);
611 * Get the string attribute's kind.
613 const char *LLVMGetStringAttributeKind(LLVMAttributeRef A, unsigned *Length);
616 * Get the string attribute's value.
618 const char *LLVMGetStringAttributeValue(LLVMAttributeRef A, unsigned *Length);
621 * Check for the different types of attributes.
623 LLVMBool LLVMIsEnumAttribute(LLVMAttributeRef A);
624 LLVMBool LLVMIsStringAttribute(LLVMAttributeRef A);
631 * @defgroup LLVMCCoreModule Modules
633 * Modules represent the top-level structure in an LLVM program. An LLVM
634 * module is effectively a translation unit or a collection of
635 * translation units merged together.
641 * Create a new, empty module in the global context.
643 * This is equivalent to calling LLVMModuleCreateWithNameInContext with
644 * LLVMGetGlobalContext() as the context parameter.
646 * Every invocation should be paired with LLVMDisposeModule() or memory
649 LLVMModuleRef LLVMModuleCreateWithName(const char *ModuleID);
652 * Create a new, empty module in a specific context.
654 * Every invocation should be paired with LLVMDisposeModule() or memory
657 LLVMModuleRef LLVMModuleCreateWithNameInContext(const char *ModuleID,
660 * Return an exact copy of the specified module.
662 LLVMModuleRef LLVMCloneModule(LLVMModuleRef M);
665 * Destroy a module instance.
667 * This must be called for every created module or memory will be
670 void LLVMDisposeModule(LLVMModuleRef M);
673 * Obtain the identifier of a module.
675 * @param M Module to obtain identifier of
676 * @param Len Out parameter which holds the length of the returned string.
677 * @return The identifier of M.
678 * @see Module::getModuleIdentifier()
680 const char *LLVMGetModuleIdentifier(LLVMModuleRef M, size_t *Len);
683 * Set the identifier of a module to a string Ident with length Len.
685 * @param M The module to set identifier
686 * @param Ident The string to set M's identifier to
687 * @param Len Length of Ident
688 * @see Module::setModuleIdentifier()
690 void LLVMSetModuleIdentifier(LLVMModuleRef M, const char *Ident, size_t Len);
693 * Obtain the module's original source file name.
695 * @param M Module to obtain the name of
696 * @param Len Out parameter which holds the length of the returned string
697 * @return The original source file name of M
698 * @see Module::getSourceFileName()
700 const char *LLVMGetSourceFileName(LLVMModuleRef M, size_t *Len);
703 * Set the original source file name of a module to a string Name with length
706 * @param M The module to set the source file name of
707 * @param Name The string to set M's source file name to
708 * @param Len Length of Name
709 * @see Module::setSourceFileName()
711 void LLVMSetSourceFileName(LLVMModuleRef M, const char *Name, size_t Len);
714 * Obtain the data layout for a module.
716 * @see Module::getDataLayoutStr()
718 * LLVMGetDataLayout is DEPRECATED, as the name is not only incorrect,
719 * but match the name of another method on the module. Prefer the use
720 * of LLVMGetDataLayoutStr, which is not ambiguous.
722 const char *LLVMGetDataLayoutStr(LLVMModuleRef M);
723 const char *LLVMGetDataLayout(LLVMModuleRef M);
726 * Set the data layout for a module.
728 * @see Module::setDataLayout()
730 void LLVMSetDataLayout(LLVMModuleRef M, const char *DataLayoutStr);
733 * Obtain the target triple for a module.
735 * @see Module::getTargetTriple()
737 const char *LLVMGetTarget(LLVMModuleRef M);
740 * Set the target triple for a module.
742 * @see Module::setTargetTriple()
744 void LLVMSetTarget(LLVMModuleRef M, const char *Triple);
747 * Returns the module flags as an array of flag-key-value triples. The caller
748 * is responsible for freeing this array by calling
749 * \c LLVMDisposeModuleFlagsMetadata.
751 * @see Module::getModuleFlagsMetadata()
753 LLVMModuleFlagEntry *LLVMCopyModuleFlagsMetadata(LLVMModuleRef M, size_t *Len);
756 * Destroys module flags metadata entries.
758 void LLVMDisposeModuleFlagsMetadata(LLVMModuleFlagEntry *Entries);
761 * Returns the flag behavior for a module flag entry at a specific index.
763 * @see Module::ModuleFlagEntry::Behavior
765 LLVMModuleFlagBehavior
766 LLVMModuleFlagEntriesGetFlagBehavior(LLVMModuleFlagEntry *Entries,
770 * Returns the key for a module flag entry at a specific index.
772 * @see Module::ModuleFlagEntry::Key
774 const char *LLVMModuleFlagEntriesGetKey(LLVMModuleFlagEntry *Entries,
775 unsigned Index, size_t *Len);
778 * Returns the metadata for a module flag entry at a specific index.
780 * @see Module::ModuleFlagEntry::Val
782 LLVMMetadataRef LLVMModuleFlagEntriesGetMetadata(LLVMModuleFlagEntry *Entries,
786 * Add a module-level flag to the module-level flags metadata if it doesn't
789 * @see Module::getModuleFlag()
791 LLVMMetadataRef LLVMGetModuleFlag(LLVMModuleRef M,
792 const char *Key, size_t KeyLen);
795 * Add a module-level flag to the module-level flags metadata if it doesn't
798 * @see Module::addModuleFlag()
800 void LLVMAddModuleFlag(LLVMModuleRef M, LLVMModuleFlagBehavior Behavior,
801 const char *Key, size_t KeyLen,
802 LLVMMetadataRef Val);
805 * Dump a representation of a module to stderr.
807 * @see Module::dump()
809 void LLVMDumpModule(LLVMModuleRef M);
812 * Print a representation of a module to a file. The ErrorMessage needs to be
813 * disposed with LLVMDisposeMessage. Returns 0 on success, 1 otherwise.
815 * @see Module::print()
817 LLVMBool LLVMPrintModuleToFile(LLVMModuleRef M, const char *Filename,
818 char **ErrorMessage);
821 * Return a string representation of the module. Use
822 * LLVMDisposeMessage to free the string.
824 * @see Module::print()
826 char *LLVMPrintModuleToString(LLVMModuleRef M);
829 * Get inline assembly for a module.
831 * @see Module::getModuleInlineAsm()
833 const char *LLVMGetModuleInlineAsm(LLVMModuleRef M, size_t *Len);
836 * Set inline assembly for a module.
838 * @see Module::setModuleInlineAsm()
840 void LLVMSetModuleInlineAsm2(LLVMModuleRef M, const char *Asm, size_t Len);
843 * Append inline assembly to a module.
845 * @see Module::appendModuleInlineAsm()
847 void LLVMAppendModuleInlineAsm(LLVMModuleRef M, const char *Asm, size_t Len);
850 * Create the specified uniqued inline asm string.
852 * @see InlineAsm::get()
854 LLVMValueRef LLVMGetInlineAsm(LLVMTypeRef Ty,
855 char *AsmString, size_t AsmStringSize,
856 char *Constraints, size_t ConstraintsSize,
857 LLVMBool HasSideEffects, LLVMBool IsAlignStack,
858 LLVMInlineAsmDialect Dialect);
861 * Obtain the context to which this module is associated.
863 * @see Module::getContext()
865 LLVMContextRef LLVMGetModuleContext(LLVMModuleRef M);
868 * Obtain a Type from a module by its registered name.
870 LLVMTypeRef LLVMGetTypeByName(LLVMModuleRef M, const char *Name);
873 * Obtain an iterator to the first NamedMDNode in a Module.
875 * @see llvm::Module::named_metadata_begin()
877 LLVMNamedMDNodeRef LLVMGetFirstNamedMetadata(LLVMModuleRef M);
880 * Obtain an iterator to the last NamedMDNode in a Module.
882 * @see llvm::Module::named_metadata_end()
884 LLVMNamedMDNodeRef LLVMGetLastNamedMetadata(LLVMModuleRef M);
887 * Advance a NamedMDNode iterator to the next NamedMDNode.
889 * Returns NULL if the iterator was already at the end and there are no more
890 * named metadata nodes.
892 LLVMNamedMDNodeRef LLVMGetNextNamedMetadata(LLVMNamedMDNodeRef NamedMDNode);
895 * Decrement a NamedMDNode iterator to the previous NamedMDNode.
897 * Returns NULL if the iterator was already at the beginning and there are
898 * no previous named metadata nodes.
900 LLVMNamedMDNodeRef LLVMGetPreviousNamedMetadata(LLVMNamedMDNodeRef NamedMDNode);
903 * Retrieve a NamedMDNode with the given name, returning NULL if no such
906 * @see llvm::Module::getNamedMetadata()
908 LLVMNamedMDNodeRef LLVMGetNamedMetadata(LLVMModuleRef M,
909 const char *Name, size_t NameLen);
912 * Retrieve a NamedMDNode with the given name, creating a new node if no such
915 * @see llvm::Module::getOrInsertNamedMetadata()
917 LLVMNamedMDNodeRef LLVMGetOrInsertNamedMetadata(LLVMModuleRef M,
922 * Retrieve the name of a NamedMDNode.
924 * @see llvm::NamedMDNode::getName()
926 const char *LLVMGetNamedMetadataName(LLVMNamedMDNodeRef NamedMD,
930 * Obtain the number of operands for named metadata in a module.
932 * @see llvm::Module::getNamedMetadata()
934 unsigned LLVMGetNamedMetadataNumOperands(LLVMModuleRef M, const char *Name);
937 * Obtain the named metadata operands for a module.
939 * The passed LLVMValueRef pointer should refer to an array of
940 * LLVMValueRef at least LLVMGetNamedMetadataNumOperands long. This
941 * array will be populated with the LLVMValueRef instances. Each
942 * instance corresponds to a llvm::MDNode.
944 * @see llvm::Module::getNamedMetadata()
945 * @see llvm::MDNode::getOperand()
947 void LLVMGetNamedMetadataOperands(LLVMModuleRef M, const char *Name,
951 * Add an operand to named metadata.
953 * @see llvm::Module::getNamedMetadata()
954 * @see llvm::MDNode::addOperand()
956 void LLVMAddNamedMetadataOperand(LLVMModuleRef M, const char *Name,
960 * Return the directory of the debug location for this value, which must be
961 * an llvm::Instruction, llvm::GlobalVariable, or llvm::Function.
963 * @see llvm::Instruction::getDebugLoc()
964 * @see llvm::GlobalVariable::getDebugInfo()
965 * @see llvm::Function::getSubprogram()
967 const char *LLVMGetDebugLocDirectory(LLVMValueRef Val, unsigned *Length);
970 * Return the filename of the debug location for this value, which must be
971 * an llvm::Instruction, llvm::GlobalVariable, or llvm::Function.
973 * @see llvm::Instruction::getDebugLoc()
974 * @see llvm::GlobalVariable::getDebugInfo()
975 * @see llvm::Function::getSubprogram()
977 const char *LLVMGetDebugLocFilename(LLVMValueRef Val, unsigned *Length);
980 * Return the line number of the debug location for this value, which must be
981 * an llvm::Instruction, llvm::GlobalVariable, or llvm::Function.
983 * @see llvm::Instruction::getDebugLoc()
984 * @see llvm::GlobalVariable::getDebugInfo()
985 * @see llvm::Function::getSubprogram()
987 unsigned LLVMGetDebugLocLine(LLVMValueRef Val);
990 * Return the column number of the debug location for this value, which must be
991 * an llvm::Instruction.
993 * @see llvm::Instruction::getDebugLoc()
995 unsigned LLVMGetDebugLocColumn(LLVMValueRef Val);
998 * Add a function to a module under a specified name.
1000 * @see llvm::Function::Create()
1002 LLVMValueRef LLVMAddFunction(LLVMModuleRef M, const char *Name,
1003 LLVMTypeRef FunctionTy);
1006 * Obtain a Function value from a Module by its name.
1008 * The returned value corresponds to a llvm::Function value.
1010 * @see llvm::Module::getFunction()
1012 LLVMValueRef LLVMGetNamedFunction(LLVMModuleRef M, const char *Name);
1015 * Obtain an iterator to the first Function in a Module.
1017 * @see llvm::Module::begin()
1019 LLVMValueRef LLVMGetFirstFunction(LLVMModuleRef M);
1022 * Obtain an iterator to the last Function in a Module.
1024 * @see llvm::Module::end()
1026 LLVMValueRef LLVMGetLastFunction(LLVMModuleRef M);
1029 * Advance a Function iterator to the next Function.
1031 * Returns NULL if the iterator was already at the end and there are no more
1034 LLVMValueRef LLVMGetNextFunction(LLVMValueRef Fn);
1037 * Decrement a Function iterator to the previous Function.
1039 * Returns NULL if the iterator was already at the beginning and there are
1040 * no previous functions.
1042 LLVMValueRef LLVMGetPreviousFunction(LLVMValueRef Fn);
1044 /** Deprecated: Use LLVMSetModuleInlineAsm2 instead. */
1045 void LLVMSetModuleInlineAsm(LLVMModuleRef M, const char *Asm);
1052 * @defgroup LLVMCCoreType Types
1054 * Types represent the type of a value.
1056 * Types are associated with a context instance. The context internally
1057 * deduplicates types so there is only 1 instance of a specific type
1058 * alive at a time. In other words, a unique type is shared among all
1059 * consumers within a context.
1061 * A Type in the C API corresponds to llvm::Type.
1063 * Types have the following hierarchy:
1081 * Obtain the enumerated type of a Type instance.
1083 * @see llvm::Type:getTypeID()
1085 LLVMTypeKind LLVMGetTypeKind(LLVMTypeRef Ty);
1088 * Whether the type has a known size.
1090 * Things that don't have a size are abstract types, labels, and void.a
1092 * @see llvm::Type::isSized()
1094 LLVMBool LLVMTypeIsSized(LLVMTypeRef Ty);
1097 * Obtain the context to which this type instance is associated.
1099 * @see llvm::Type::getContext()
1101 LLVMContextRef LLVMGetTypeContext(LLVMTypeRef Ty);
1104 * Dump a representation of a type to stderr.
1106 * @see llvm::Type::dump()
1108 void LLVMDumpType(LLVMTypeRef Val);
1111 * Return a string representation of the type. Use
1112 * LLVMDisposeMessage to free the string.
1114 * @see llvm::Type::print()
1116 char *LLVMPrintTypeToString(LLVMTypeRef Val);
1119 * @defgroup LLVMCCoreTypeInt Integer Types
1121 * Functions in this section operate on integer types.
1127 * Obtain an integer type from a context with specified bit width.
1129 LLVMTypeRef LLVMInt1TypeInContext(LLVMContextRef C);
1130 LLVMTypeRef LLVMInt8TypeInContext(LLVMContextRef C);
1131 LLVMTypeRef LLVMInt16TypeInContext(LLVMContextRef C);
1132 LLVMTypeRef LLVMInt32TypeInContext(LLVMContextRef C);
1133 LLVMTypeRef LLVMInt64TypeInContext(LLVMContextRef C);
1134 LLVMTypeRef LLVMInt128TypeInContext(LLVMContextRef C);
1135 LLVMTypeRef LLVMIntTypeInContext(LLVMContextRef C, unsigned NumBits);
1138 * Obtain an integer type from the global context with a specified bit
1141 LLVMTypeRef LLVMInt1Type(void);
1142 LLVMTypeRef LLVMInt8Type(void);
1143 LLVMTypeRef LLVMInt16Type(void);
1144 LLVMTypeRef LLVMInt32Type(void);
1145 LLVMTypeRef LLVMInt64Type(void);
1146 LLVMTypeRef LLVMInt128Type(void);
1147 LLVMTypeRef LLVMIntType(unsigned NumBits);
1148 unsigned LLVMGetIntTypeWidth(LLVMTypeRef IntegerTy);
1155 * @defgroup LLVMCCoreTypeFloat Floating Point Types
1161 * Obtain a 16-bit floating point type from a context.
1163 LLVMTypeRef LLVMHalfTypeInContext(LLVMContextRef C);
1166 * Obtain a 32-bit floating point type from a context.
1168 LLVMTypeRef LLVMFloatTypeInContext(LLVMContextRef C);
1171 * Obtain a 64-bit floating point type from a context.
1173 LLVMTypeRef LLVMDoubleTypeInContext(LLVMContextRef C);
1176 * Obtain a 80-bit floating point type (X87) from a context.
1178 LLVMTypeRef LLVMX86FP80TypeInContext(LLVMContextRef C);
1181 * Obtain a 128-bit floating point type (112-bit mantissa) from a
1184 LLVMTypeRef LLVMFP128TypeInContext(LLVMContextRef C);
1187 * Obtain a 128-bit floating point type (two 64-bits) from a context.
1189 LLVMTypeRef LLVMPPCFP128TypeInContext(LLVMContextRef C);
1192 * Obtain a floating point type from the global context.
1194 * These map to the functions in this group of the same name.
1196 LLVMTypeRef LLVMHalfType(void);
1197 LLVMTypeRef LLVMFloatType(void);
1198 LLVMTypeRef LLVMDoubleType(void);
1199 LLVMTypeRef LLVMX86FP80Type(void);
1200 LLVMTypeRef LLVMFP128Type(void);
1201 LLVMTypeRef LLVMPPCFP128Type(void);
1208 * @defgroup LLVMCCoreTypeFunction Function Types
1214 * Obtain a function type consisting of a specified signature.
1216 * The function is defined as a tuple of a return Type, a list of
1217 * parameter types, and whether the function is variadic.
1219 LLVMTypeRef LLVMFunctionType(LLVMTypeRef ReturnType,
1220 LLVMTypeRef *ParamTypes, unsigned ParamCount,
1224 * Returns whether a function type is variadic.
1226 LLVMBool LLVMIsFunctionVarArg(LLVMTypeRef FunctionTy);
1229 * Obtain the Type this function Type returns.
1231 LLVMTypeRef LLVMGetReturnType(LLVMTypeRef FunctionTy);
1234 * Obtain the number of parameters this function accepts.
1236 unsigned LLVMCountParamTypes(LLVMTypeRef FunctionTy);
1239 * Obtain the types of a function's parameters.
1241 * The Dest parameter should point to a pre-allocated array of
1242 * LLVMTypeRef at least LLVMCountParamTypes() large. On return, the
1243 * first LLVMCountParamTypes() entries in the array will be populated
1244 * with LLVMTypeRef instances.
1246 * @param FunctionTy The function type to operate on.
1247 * @param Dest Memory address of an array to be filled with result.
1249 void LLVMGetParamTypes(LLVMTypeRef FunctionTy, LLVMTypeRef *Dest);
1256 * @defgroup LLVMCCoreTypeStruct Structure Types
1258 * These functions relate to LLVMTypeRef instances.
1260 * @see llvm::StructType
1266 * Create a new structure type in a context.
1268 * A structure is specified by a list of inner elements/types and
1269 * whether these can be packed together.
1271 * @see llvm::StructType::create()
1273 LLVMTypeRef LLVMStructTypeInContext(LLVMContextRef C, LLVMTypeRef *ElementTypes,
1274 unsigned ElementCount, LLVMBool Packed);
1277 * Create a new structure type in the global context.
1279 * @see llvm::StructType::create()
1281 LLVMTypeRef LLVMStructType(LLVMTypeRef *ElementTypes, unsigned ElementCount,
1285 * Create an empty structure in a context having a specified name.
1287 * @see llvm::StructType::create()
1289 LLVMTypeRef LLVMStructCreateNamed(LLVMContextRef C, const char *Name);
1292 * Obtain the name of a structure.
1294 * @see llvm::StructType::getName()
1296 const char *LLVMGetStructName(LLVMTypeRef Ty);
1299 * Set the contents of a structure type.
1301 * @see llvm::StructType::setBody()
1303 void LLVMStructSetBody(LLVMTypeRef StructTy, LLVMTypeRef *ElementTypes,
1304 unsigned ElementCount, LLVMBool Packed);
1307 * Get the number of elements defined inside the structure.
1309 * @see llvm::StructType::getNumElements()
1311 unsigned LLVMCountStructElementTypes(LLVMTypeRef StructTy);
1314 * Get the elements within a structure.
1316 * The function is passed the address of a pre-allocated array of
1317 * LLVMTypeRef at least LLVMCountStructElementTypes() long. After
1318 * invocation, this array will be populated with the structure's
1319 * elements. The objects in the destination array will have a lifetime
1320 * of the structure type itself, which is the lifetime of the context it
1323 void LLVMGetStructElementTypes(LLVMTypeRef StructTy, LLVMTypeRef *Dest);
1326 * Get the type of the element at a given index in the structure.
1328 * @see llvm::StructType::getTypeAtIndex()
1330 LLVMTypeRef LLVMStructGetTypeAtIndex(LLVMTypeRef StructTy, unsigned i);
1333 * Determine whether a structure is packed.
1335 * @see llvm::StructType::isPacked()
1337 LLVMBool LLVMIsPackedStruct(LLVMTypeRef StructTy);
1340 * Determine whether a structure is opaque.
1342 * @see llvm::StructType::isOpaque()
1344 LLVMBool LLVMIsOpaqueStruct(LLVMTypeRef StructTy);
1347 * Determine whether a structure is literal.
1349 * @see llvm::StructType::isLiteral()
1351 LLVMBool LLVMIsLiteralStruct(LLVMTypeRef StructTy);
1358 * @defgroup LLVMCCoreTypeSequential Sequential Types
1360 * Sequential types represents "arrays" of types. This is a super class
1361 * for array, vector, and pointer types.
1367 * Obtain the type of elements within a sequential type.
1369 * This works on array, vector, and pointer types.
1371 * @see llvm::SequentialType::getElementType()
1373 LLVMTypeRef LLVMGetElementType(LLVMTypeRef Ty);
1376 * Returns type's subtypes
1378 * @see llvm::Type::subtypes()
1380 void LLVMGetSubtypes(LLVMTypeRef Tp, LLVMTypeRef *Arr);
1383 * Return the number of types in the derived type.
1385 * @see llvm::Type::getNumContainedTypes()
1387 unsigned LLVMGetNumContainedTypes(LLVMTypeRef Tp);
1390 * Create a fixed size array type that refers to a specific type.
1392 * The created type will exist in the context that its element type
1395 * @see llvm::ArrayType::get()
1397 LLVMTypeRef LLVMArrayType(LLVMTypeRef ElementType, unsigned ElementCount);
1400 * Obtain the length of an array type.
1402 * This only works on types that represent arrays.
1404 * @see llvm::ArrayType::getNumElements()
1406 unsigned LLVMGetArrayLength(LLVMTypeRef ArrayTy);
1409 * Create a pointer type that points to a defined type.
1411 * The created type will exist in the context that its pointee type
1414 * @see llvm::PointerType::get()
1416 LLVMTypeRef LLVMPointerType(LLVMTypeRef ElementType, unsigned AddressSpace);
1419 * Obtain the address space of a pointer type.
1421 * This only works on types that represent pointers.
1423 * @see llvm::PointerType::getAddressSpace()
1425 unsigned LLVMGetPointerAddressSpace(LLVMTypeRef PointerTy);
1428 * Create a vector type that contains a defined type and has a specific
1429 * number of elements.
1431 * The created type will exist in the context thats its element type
1434 * @see llvm::VectorType::get()
1436 LLVMTypeRef LLVMVectorType(LLVMTypeRef ElementType, unsigned ElementCount);
1439 * Obtain the number of elements in a vector type.
1441 * This only works on types that represent vectors.
1443 * @see llvm::VectorType::getNumElements()
1445 unsigned LLVMGetVectorSize(LLVMTypeRef VectorTy);
1452 * @defgroup LLVMCCoreTypeOther Other Types
1458 * Create a void type in a context.
1460 LLVMTypeRef LLVMVoidTypeInContext(LLVMContextRef C);
1463 * Create a label type in a context.
1465 LLVMTypeRef LLVMLabelTypeInContext(LLVMContextRef C);
1468 * Create a X86 MMX type in a context.
1470 LLVMTypeRef LLVMX86MMXTypeInContext(LLVMContextRef C);
1473 * Create a token type in a context.
1475 LLVMTypeRef LLVMTokenTypeInContext(LLVMContextRef C);
1478 * Create a metadata type in a context.
1480 LLVMTypeRef LLVMMetadataTypeInContext(LLVMContextRef C);
1483 * These are similar to the above functions except they operate on the
1486 LLVMTypeRef LLVMVoidType(void);
1487 LLVMTypeRef LLVMLabelType(void);
1488 LLVMTypeRef LLVMX86MMXType(void);
1499 * @defgroup LLVMCCoreValues Values
1501 * The bulk of LLVM's object model consists of values, which comprise a very
1502 * rich type hierarchy.
1504 * LLVMValueRef essentially represents llvm::Value. There is a rich
1505 * hierarchy of classes within this type. Depending on the instance
1506 * obtained, not all APIs are available.
1508 * Callers can determine the type of an LLVMValueRef by calling the
1509 * LLVMIsA* family of functions (e.g. LLVMIsAArgument()). These
1510 * functions are defined by a macro, so it isn't obvious which are
1511 * available by looking at the Doxygen source code. Instead, look at the
1512 * source definition of LLVM_FOR_EACH_VALUE_SUBCLASS and note the list
1513 * of value names given. These value names also correspond to classes in
1514 * the llvm::Value hierarchy.
1519 #define LLVM_FOR_EACH_VALUE_SUBCLASS(macro) \
1525 macro(BlockAddress) \
1526 macro(ConstantAggregateZero) \
1527 macro(ConstantArray) \
1528 macro(ConstantDataSequential) \
1529 macro(ConstantDataArray) \
1530 macro(ConstantDataVector) \
1531 macro(ConstantExpr) \
1533 macro(ConstantInt) \
1534 macro(ConstantPointerNull) \
1535 macro(ConstantStruct) \
1536 macro(ConstantTokenNone) \
1537 macro(ConstantVector) \
1538 macro(GlobalValue) \
1539 macro(GlobalAlias) \
1540 macro(GlobalIFunc) \
1541 macro(GlobalObject) \
1543 macro(GlobalVariable) \
1545 macro(Instruction) \
1546 macro(UnaryOperator) \
1547 macro(BinaryOperator) \
1549 macro(IntrinsicInst) \
1550 macro(DbgInfoIntrinsic) \
1551 macro(DbgVariableIntrinsic) \
1552 macro(DbgDeclareInst) \
1553 macro(DbgLabelInst) \
1554 macro(MemIntrinsic) \
1556 macro(MemMoveInst) \
1561 macro(ExtractElementInst) \
1562 macro(GetElementPtrInst) \
1563 macro(InsertElementInst) \
1564 macro(InsertValueInst) \
1565 macro(LandingPadInst) \
1568 macro(ShuffleVectorInst) \
1571 macro(IndirectBrInst) \
1575 macro(UnreachableInst) \
1577 macro(CleanupReturnInst) \
1578 macro(CatchReturnInst) \
1579 macro(CatchSwitchInst) \
1581 macro(FuncletPadInst) \
1582 macro(CatchPadInst) \
1583 macro(CleanupPadInst) \
1584 macro(UnaryInstruction) \
1587 macro(AddrSpaceCastInst) \
1588 macro(BitCastInst) \
1592 macro(FPTruncInst) \
1593 macro(IntToPtrInst) \
1594 macro(PtrToIntInst) \
1600 macro(ExtractValueInst) \
1604 macro(AtomicCmpXchgInst) \
1605 macro(AtomicRMWInst) \
1609 * @defgroup LLVMCCoreValueGeneral General APIs
1611 * Functions in this section work on all LLVMValueRef instances,
1612 * regardless of their sub-type. They correspond to functions available
1619 * Obtain the type of a value.
1621 * @see llvm::Value::getType()
1623 LLVMTypeRef LLVMTypeOf(LLVMValueRef Val);
1626 * Obtain the enumerated type of a Value instance.
1628 * @see llvm::Value::getValueID()
1630 LLVMValueKind LLVMGetValueKind(LLVMValueRef Val);
1633 * Obtain the string name of a value.
1635 * @see llvm::Value::getName()
1637 const char *LLVMGetValueName2(LLVMValueRef Val, size_t *Length);
1640 * Set the string name of a value.
1642 * @see llvm::Value::setName()
1644 void LLVMSetValueName2(LLVMValueRef Val, const char *Name, size_t NameLen);
1647 * Dump a representation of a value to stderr.
1649 * @see llvm::Value::dump()
1651 void LLVMDumpValue(LLVMValueRef Val);
1654 * Return a string representation of the value. Use
1655 * LLVMDisposeMessage to free the string.
1657 * @see llvm::Value::print()
1659 char *LLVMPrintValueToString(LLVMValueRef Val);
1662 * Replace all uses of a value with another one.
1664 * @see llvm::Value::replaceAllUsesWith()
1666 void LLVMReplaceAllUsesWith(LLVMValueRef OldVal, LLVMValueRef NewVal);
1669 * Determine whether the specified value instance is constant.
1671 LLVMBool LLVMIsConstant(LLVMValueRef Val);
1674 * Determine whether a value instance is undefined.
1676 LLVMBool LLVMIsUndef(LLVMValueRef Val);
1679 * Convert value instances between types.
1681 * Internally, an LLVMValueRef is "pinned" to a specific type. This
1682 * series of functions allows you to cast an instance to a specific
1685 * If the cast is not valid for the specified type, NULL is returned.
1687 * @see llvm::dyn_cast_or_null<>
1689 #define LLVM_DECLARE_VALUE_CAST(name) \
1690 LLVMValueRef LLVMIsA##name(LLVMValueRef Val);
1691 LLVM_FOR_EACH_VALUE_SUBCLASS(LLVM_DECLARE_VALUE_CAST)
1693 LLVMValueRef LLVMIsAMDNode(LLVMValueRef Val);
1694 LLVMValueRef LLVMIsAMDString(LLVMValueRef Val);
1696 /** Deprecated: Use LLVMGetValueName2 instead. */
1697 const char *LLVMGetValueName(LLVMValueRef Val);
1698 /** Deprecated: Use LLVMSetValueName2 instead. */
1699 void LLVMSetValueName(LLVMValueRef Val, const char *Name);
1706 * @defgroup LLVMCCoreValueUses Usage
1708 * This module defines functions that allow you to inspect the uses of a
1711 * It is possible to obtain an LLVMUseRef for any LLVMValueRef instance.
1712 * Each LLVMUseRef (which corresponds to a llvm::Use instance) holds a
1713 * llvm::User and llvm::Value.
1719 * Obtain the first use of a value.
1721 * Uses are obtained in an iterator fashion. First, call this function
1722 * to obtain a reference to the first use. Then, call LLVMGetNextUse()
1723 * on that instance and all subsequently obtained instances until
1724 * LLVMGetNextUse() returns NULL.
1726 * @see llvm::Value::use_begin()
1728 LLVMUseRef LLVMGetFirstUse(LLVMValueRef Val);
1731 * Obtain the next use of a value.
1733 * This effectively advances the iterator. It returns NULL if you are on
1734 * the final use and no more are available.
1736 LLVMUseRef LLVMGetNextUse(LLVMUseRef U);
1739 * Obtain the user value for a user.
1741 * The returned value corresponds to a llvm::User type.
1743 * @see llvm::Use::getUser()
1745 LLVMValueRef LLVMGetUser(LLVMUseRef U);
1748 * Obtain the value this use corresponds to.
1750 * @see llvm::Use::get().
1752 LLVMValueRef LLVMGetUsedValue(LLVMUseRef U);
1759 * @defgroup LLVMCCoreValueUser User value
1761 * Function in this group pertain to LLVMValueRef instances that descent
1762 * from llvm::User. This includes constants, instructions, and
1769 * Obtain an operand at a specific index in a llvm::User value.
1771 * @see llvm::User::getOperand()
1773 LLVMValueRef LLVMGetOperand(LLVMValueRef Val, unsigned Index);
1776 * Obtain the use of an operand at a specific index in a llvm::User value.
1778 * @see llvm::User::getOperandUse()
1780 LLVMUseRef LLVMGetOperandUse(LLVMValueRef Val, unsigned Index);
1783 * Set an operand at a specific index in a llvm::User value.
1785 * @see llvm::User::setOperand()
1787 void LLVMSetOperand(LLVMValueRef User, unsigned Index, LLVMValueRef Val);
1790 * Obtain the number of operands in a llvm::User value.
1792 * @see llvm::User::getNumOperands()
1794 int LLVMGetNumOperands(LLVMValueRef Val);
1801 * @defgroup LLVMCCoreValueConstant Constants
1803 * This section contains APIs for interacting with LLVMValueRef that
1804 * correspond to llvm::Constant instances.
1806 * These functions will work for any LLVMValueRef in the llvm::Constant
1813 * Obtain a constant value referring to the null instance of a type.
1815 * @see llvm::Constant::getNullValue()
1817 LLVMValueRef LLVMConstNull(LLVMTypeRef Ty); /* all zeroes */
1820 * Obtain a constant value referring to the instance of a type
1821 * consisting of all ones.
1823 * This is only valid for integer types.
1825 * @see llvm::Constant::getAllOnesValue()
1827 LLVMValueRef LLVMConstAllOnes(LLVMTypeRef Ty);
1830 * Obtain a constant value referring to an undefined value of a type.
1832 * @see llvm::UndefValue::get()
1834 LLVMValueRef LLVMGetUndef(LLVMTypeRef Ty);
1837 * Determine whether a value instance is null.
1839 * @see llvm::Constant::isNullValue()
1841 LLVMBool LLVMIsNull(LLVMValueRef Val);
1844 * Obtain a constant that is a constant pointer pointing to NULL for a
1847 LLVMValueRef LLVMConstPointerNull(LLVMTypeRef Ty);
1850 * @defgroup LLVMCCoreValueConstantScalar Scalar constants
1852 * Functions in this group model LLVMValueRef instances that correspond
1853 * to constants referring to scalar types.
1855 * For integer types, the LLVMTypeRef parameter should correspond to a
1856 * llvm::IntegerType instance and the returned LLVMValueRef will
1857 * correspond to a llvm::ConstantInt.
1859 * For floating point types, the LLVMTypeRef returned corresponds to a
1866 * Obtain a constant value for an integer type.
1868 * The returned value corresponds to a llvm::ConstantInt.
1870 * @see llvm::ConstantInt::get()
1872 * @param IntTy Integer type to obtain value of.
1873 * @param N The value the returned instance should refer to.
1874 * @param SignExtend Whether to sign extend the produced value.
1876 LLVMValueRef LLVMConstInt(LLVMTypeRef IntTy, unsigned long long N,
1877 LLVMBool SignExtend);
1880 * Obtain a constant value for an integer of arbitrary precision.
1882 * @see llvm::ConstantInt::get()
1884 LLVMValueRef LLVMConstIntOfArbitraryPrecision(LLVMTypeRef IntTy,
1886 const uint64_t Words[]);
1889 * Obtain a constant value for an integer parsed from a string.
1891 * A similar API, LLVMConstIntOfStringAndSize is also available. If the
1892 * string's length is available, it is preferred to call that function
1895 * @see llvm::ConstantInt::get()
1897 LLVMValueRef LLVMConstIntOfString(LLVMTypeRef IntTy, const char *Text,
1901 * Obtain a constant value for an integer parsed from a string with
1904 * @see llvm::ConstantInt::get()
1906 LLVMValueRef LLVMConstIntOfStringAndSize(LLVMTypeRef IntTy, const char *Text,
1907 unsigned SLen, uint8_t Radix);
1910 * Obtain a constant value referring to a double floating point value.
1912 LLVMValueRef LLVMConstReal(LLVMTypeRef RealTy, double N);
1915 * Obtain a constant for a floating point value parsed from a string.
1917 * A similar API, LLVMConstRealOfStringAndSize is also available. It
1918 * should be used if the input string's length is known.
1920 LLVMValueRef LLVMConstRealOfString(LLVMTypeRef RealTy, const char *Text);
1923 * Obtain a constant for a floating point value parsed from a string.
1925 LLVMValueRef LLVMConstRealOfStringAndSize(LLVMTypeRef RealTy, const char *Text,
1929 * Obtain the zero extended value for an integer constant value.
1931 * @see llvm::ConstantInt::getZExtValue()
1933 unsigned long long LLVMConstIntGetZExtValue(LLVMValueRef ConstantVal);
1936 * Obtain the sign extended value for an integer constant value.
1938 * @see llvm::ConstantInt::getSExtValue()
1940 long long LLVMConstIntGetSExtValue(LLVMValueRef ConstantVal);
1943 * Obtain the double value for an floating point constant value.
1944 * losesInfo indicates if some precision was lost in the conversion.
1946 * @see llvm::ConstantFP::getDoubleValue
1948 double LLVMConstRealGetDouble(LLVMValueRef ConstantVal, LLVMBool *losesInfo);
1955 * @defgroup LLVMCCoreValueConstantComposite Composite Constants
1957 * Functions in this group operate on composite constants.
1963 * Create a ConstantDataSequential and initialize it with a string.
1965 * @see llvm::ConstantDataArray::getString()
1967 LLVMValueRef LLVMConstStringInContext(LLVMContextRef C, const char *Str,
1968 unsigned Length, LLVMBool DontNullTerminate);
1971 * Create a ConstantDataSequential with string content in the global context.
1973 * This is the same as LLVMConstStringInContext except it operates on the
1976 * @see LLVMConstStringInContext()
1977 * @see llvm::ConstantDataArray::getString()
1979 LLVMValueRef LLVMConstString(const char *Str, unsigned Length,
1980 LLVMBool DontNullTerminate);
1983 * Returns true if the specified constant is an array of i8.
1985 * @see ConstantDataSequential::getAsString()
1987 LLVMBool LLVMIsConstantString(LLVMValueRef c);
1990 * Get the given constant data sequential as a string.
1992 * @see ConstantDataSequential::getAsString()
1994 const char *LLVMGetAsString(LLVMValueRef c, size_t *Length);
1997 * Create an anonymous ConstantStruct with the specified values.
1999 * @see llvm::ConstantStruct::getAnon()
2001 LLVMValueRef LLVMConstStructInContext(LLVMContextRef C,
2002 LLVMValueRef *ConstantVals,
2003 unsigned Count, LLVMBool Packed);
2006 * Create a ConstantStruct in the global Context.
2008 * This is the same as LLVMConstStructInContext except it operates on the
2011 * @see LLVMConstStructInContext()
2013 LLVMValueRef LLVMConstStruct(LLVMValueRef *ConstantVals, unsigned Count,
2017 * Create a ConstantArray from values.
2019 * @see llvm::ConstantArray::get()
2021 LLVMValueRef LLVMConstArray(LLVMTypeRef ElementTy,
2022 LLVMValueRef *ConstantVals, unsigned Length);
2025 * Create a non-anonymous ConstantStruct from values.
2027 * @see llvm::ConstantStruct::get()
2029 LLVMValueRef LLVMConstNamedStruct(LLVMTypeRef StructTy,
2030 LLVMValueRef *ConstantVals,
2034 * Get an element at specified index as a constant.
2036 * @see ConstantDataSequential::getElementAsConstant()
2038 LLVMValueRef LLVMGetElementAsConstant(LLVMValueRef C, unsigned idx);
2041 * Create a ConstantVector from values.
2043 * @see llvm::ConstantVector::get()
2045 LLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals, unsigned Size);
2052 * @defgroup LLVMCCoreValueConstantExpressions Constant Expressions
2054 * Functions in this group correspond to APIs on llvm::ConstantExpr.
2056 * @see llvm::ConstantExpr.
2060 LLVMOpcode LLVMGetConstOpcode(LLVMValueRef ConstantVal);
2061 LLVMValueRef LLVMAlignOf(LLVMTypeRef Ty);
2062 LLVMValueRef LLVMSizeOf(LLVMTypeRef Ty);
2063 LLVMValueRef LLVMConstNeg(LLVMValueRef ConstantVal);
2064 LLVMValueRef LLVMConstNSWNeg(LLVMValueRef ConstantVal);
2065 LLVMValueRef LLVMConstNUWNeg(LLVMValueRef ConstantVal);
2066 LLVMValueRef LLVMConstFNeg(LLVMValueRef ConstantVal);
2067 LLVMValueRef LLVMConstNot(LLVMValueRef ConstantVal);
2068 LLVMValueRef LLVMConstAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2069 LLVMValueRef LLVMConstNSWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2070 LLVMValueRef LLVMConstNUWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2071 LLVMValueRef LLVMConstFAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2072 LLVMValueRef LLVMConstSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2073 LLVMValueRef LLVMConstNSWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2074 LLVMValueRef LLVMConstNUWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2075 LLVMValueRef LLVMConstFSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2076 LLVMValueRef LLVMConstMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2077 LLVMValueRef LLVMConstNSWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2078 LLVMValueRef LLVMConstNUWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2079 LLVMValueRef LLVMConstFMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2080 LLVMValueRef LLVMConstUDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2081 LLVMValueRef LLVMConstExactUDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2082 LLVMValueRef LLVMConstSDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2083 LLVMValueRef LLVMConstExactSDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2084 LLVMValueRef LLVMConstFDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2085 LLVMValueRef LLVMConstURem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2086 LLVMValueRef LLVMConstSRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2087 LLVMValueRef LLVMConstFRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2088 LLVMValueRef LLVMConstAnd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2089 LLVMValueRef LLVMConstOr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2090 LLVMValueRef LLVMConstXor(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2091 LLVMValueRef LLVMConstICmp(LLVMIntPredicate Predicate,
2092 LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2093 LLVMValueRef LLVMConstFCmp(LLVMRealPredicate Predicate,
2094 LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2095 LLVMValueRef LLVMConstShl(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2096 LLVMValueRef LLVMConstLShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2097 LLVMValueRef LLVMConstAShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2098 LLVMValueRef LLVMConstGEP(LLVMValueRef ConstantVal,
2099 LLVMValueRef *ConstantIndices, unsigned NumIndices);
2100 LLVMValueRef LLVMConstGEP2(LLVMTypeRef Ty, LLVMValueRef ConstantVal,
2101 LLVMValueRef *ConstantIndices, unsigned NumIndices);
2102 LLVMValueRef LLVMConstInBoundsGEP(LLVMValueRef ConstantVal,
2103 LLVMValueRef *ConstantIndices,
2104 unsigned NumIndices);
2105 LLVMValueRef LLVMConstInBoundsGEP2(LLVMTypeRef Ty, LLVMValueRef ConstantVal,
2106 LLVMValueRef *ConstantIndices,
2107 unsigned NumIndices);
2108 LLVMValueRef LLVMConstTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
2109 LLVMValueRef LLVMConstSExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
2110 LLVMValueRef LLVMConstZExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
2111 LLVMValueRef LLVMConstFPTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
2112 LLVMValueRef LLVMConstFPExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
2113 LLVMValueRef LLVMConstUIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
2114 LLVMValueRef LLVMConstSIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
2115 LLVMValueRef LLVMConstFPToUI(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
2116 LLVMValueRef LLVMConstFPToSI(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
2117 LLVMValueRef LLVMConstPtrToInt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
2118 LLVMValueRef LLVMConstIntToPtr(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
2119 LLVMValueRef LLVMConstBitCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
2120 LLVMValueRef LLVMConstAddrSpaceCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
2121 LLVMValueRef LLVMConstZExtOrBitCast(LLVMValueRef ConstantVal,
2122 LLVMTypeRef ToType);
2123 LLVMValueRef LLVMConstSExtOrBitCast(LLVMValueRef ConstantVal,
2124 LLVMTypeRef ToType);
2125 LLVMValueRef LLVMConstTruncOrBitCast(LLVMValueRef ConstantVal,
2126 LLVMTypeRef ToType);
2127 LLVMValueRef LLVMConstPointerCast(LLVMValueRef ConstantVal,
2128 LLVMTypeRef ToType);
2129 LLVMValueRef LLVMConstIntCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType,
2131 LLVMValueRef LLVMConstFPCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
2132 LLVMValueRef LLVMConstSelect(LLVMValueRef ConstantCondition,
2133 LLVMValueRef ConstantIfTrue,
2134 LLVMValueRef ConstantIfFalse);
2135 LLVMValueRef LLVMConstExtractElement(LLVMValueRef VectorConstant,
2136 LLVMValueRef IndexConstant);
2137 LLVMValueRef LLVMConstInsertElement(LLVMValueRef VectorConstant,
2138 LLVMValueRef ElementValueConstant,
2139 LLVMValueRef IndexConstant);
2140 LLVMValueRef LLVMConstShuffleVector(LLVMValueRef VectorAConstant,
2141 LLVMValueRef VectorBConstant,
2142 LLVMValueRef MaskConstant);
2143 LLVMValueRef LLVMConstExtractValue(LLVMValueRef AggConstant, unsigned *IdxList,
2145 LLVMValueRef LLVMConstInsertValue(LLVMValueRef AggConstant,
2146 LLVMValueRef ElementValueConstant,
2147 unsigned *IdxList, unsigned NumIdx);
2148 LLVMValueRef LLVMBlockAddress(LLVMValueRef F, LLVMBasicBlockRef BB);
2150 /** Deprecated: Use LLVMGetInlineAsm instead. */
2151 LLVMValueRef LLVMConstInlineAsm(LLVMTypeRef Ty,
2152 const char *AsmString, const char *Constraints,
2153 LLVMBool HasSideEffects, LLVMBool IsAlignStack);
2160 * @defgroup LLVMCCoreValueConstantGlobals Global Values
2162 * This group contains functions that operate on global values. Functions in
2163 * this group relate to functions in the llvm::GlobalValue class tree.
2165 * @see llvm::GlobalValue
2170 LLVMModuleRef LLVMGetGlobalParent(LLVMValueRef Global);
2171 LLVMBool LLVMIsDeclaration(LLVMValueRef Global);
2172 LLVMLinkage LLVMGetLinkage(LLVMValueRef Global);
2173 void LLVMSetLinkage(LLVMValueRef Global, LLVMLinkage Linkage);
2174 const char *LLVMGetSection(LLVMValueRef Global);
2175 void LLVMSetSection(LLVMValueRef Global, const char *Section);
2176 LLVMVisibility LLVMGetVisibility(LLVMValueRef Global);
2177 void LLVMSetVisibility(LLVMValueRef Global, LLVMVisibility Viz);
2178 LLVMDLLStorageClass LLVMGetDLLStorageClass(LLVMValueRef Global);
2179 void LLVMSetDLLStorageClass(LLVMValueRef Global, LLVMDLLStorageClass Class);
2180 LLVMUnnamedAddr LLVMGetUnnamedAddress(LLVMValueRef Global);
2181 void LLVMSetUnnamedAddress(LLVMValueRef Global, LLVMUnnamedAddr UnnamedAddr);
2184 * Returns the "value type" of a global value. This differs from the formal
2185 * type of a global value which is always a pointer type.
2187 * @see llvm::GlobalValue::getValueType()
2189 LLVMTypeRef LLVMGlobalGetValueType(LLVMValueRef Global);
2191 /** Deprecated: Use LLVMGetUnnamedAddress instead. */
2192 LLVMBool LLVMHasUnnamedAddr(LLVMValueRef Global);
2193 /** Deprecated: Use LLVMSetUnnamedAddress instead. */
2194 void LLVMSetUnnamedAddr(LLVMValueRef Global, LLVMBool HasUnnamedAddr);
2197 * @defgroup LLVMCCoreValueWithAlignment Values with alignment
2199 * Functions in this group only apply to values with alignment, i.e.
2200 * global variables, load and store instructions.
2204 * Obtain the preferred alignment of the value.
2205 * @see llvm::AllocaInst::getAlignment()
2206 * @see llvm::LoadInst::getAlignment()
2207 * @see llvm::StoreInst::getAlignment()
2208 * @see llvm::GlobalValue::getAlignment()
2210 unsigned LLVMGetAlignment(LLVMValueRef V);
2213 * Set the preferred alignment of the value.
2214 * @see llvm::AllocaInst::setAlignment()
2215 * @see llvm::LoadInst::setAlignment()
2216 * @see llvm::StoreInst::setAlignment()
2217 * @see llvm::GlobalValue::setAlignment()
2219 void LLVMSetAlignment(LLVMValueRef V, unsigned Bytes);
2222 * Sets a metadata attachment, erasing the existing metadata attachment if
2223 * it already exists for the given kind.
2225 * @see llvm::GlobalObject::setMetadata()
2227 void LLVMGlobalSetMetadata(LLVMValueRef Global, unsigned Kind,
2228 LLVMMetadataRef MD);
2231 * Erases a metadata attachment of the given kind if it exists.
2233 * @see llvm::GlobalObject::eraseMetadata()
2235 void LLVMGlobalEraseMetadata(LLVMValueRef Global, unsigned Kind);
2238 * Removes all metadata attachments from this value.
2240 * @see llvm::GlobalObject::clearMetadata()
2242 void LLVMGlobalClearMetadata(LLVMValueRef Global);
2245 * Retrieves an array of metadata entries representing the metadata attached to
2246 * this value. The caller is responsible for freeing this array by calling
2247 * \c LLVMDisposeValueMetadataEntries.
2249 * @see llvm::GlobalObject::getAllMetadata()
2251 LLVMValueMetadataEntry *LLVMGlobalCopyAllMetadata(LLVMValueRef Value,
2252 size_t *NumEntries);
2255 * Destroys value metadata entries.
2257 void LLVMDisposeValueMetadataEntries(LLVMValueMetadataEntry *Entries);
2260 * Returns the kind of a value metadata entry at a specific index.
2262 unsigned LLVMValueMetadataEntriesGetKind(LLVMValueMetadataEntry *Entries,
2266 * Returns the underlying metadata node of a value metadata entry at a
2270 LLVMValueMetadataEntriesGetMetadata(LLVMValueMetadataEntry *Entries,
2278 * @defgroup LLVMCoreValueConstantGlobalVariable Global Variables
2280 * This group contains functions that operate on global variable values.
2282 * @see llvm::GlobalVariable
2286 LLVMValueRef LLVMAddGlobal(LLVMModuleRef M, LLVMTypeRef Ty, const char *Name);
2287 LLVMValueRef LLVMAddGlobalInAddressSpace(LLVMModuleRef M, LLVMTypeRef Ty,
2289 unsigned AddressSpace);
2290 LLVMValueRef LLVMGetNamedGlobal(LLVMModuleRef M, const char *Name);
2291 LLVMValueRef LLVMGetFirstGlobal(LLVMModuleRef M);
2292 LLVMValueRef LLVMGetLastGlobal(LLVMModuleRef M);
2293 LLVMValueRef LLVMGetNextGlobal(LLVMValueRef GlobalVar);
2294 LLVMValueRef LLVMGetPreviousGlobal(LLVMValueRef GlobalVar);
2295 void LLVMDeleteGlobal(LLVMValueRef GlobalVar);
2296 LLVMValueRef LLVMGetInitializer(LLVMValueRef GlobalVar);
2297 void LLVMSetInitializer(LLVMValueRef GlobalVar, LLVMValueRef ConstantVal);
2298 LLVMBool LLVMIsThreadLocal(LLVMValueRef GlobalVar);
2299 void LLVMSetThreadLocal(LLVMValueRef GlobalVar, LLVMBool IsThreadLocal);
2300 LLVMBool LLVMIsGlobalConstant(LLVMValueRef GlobalVar);
2301 void LLVMSetGlobalConstant(LLVMValueRef GlobalVar, LLVMBool IsConstant);
2302 LLVMThreadLocalMode LLVMGetThreadLocalMode(LLVMValueRef GlobalVar);
2303 void LLVMSetThreadLocalMode(LLVMValueRef GlobalVar, LLVMThreadLocalMode Mode);
2304 LLVMBool LLVMIsExternallyInitialized(LLVMValueRef GlobalVar);
2305 void LLVMSetExternallyInitialized(LLVMValueRef GlobalVar, LLVMBool IsExtInit);
2312 * @defgroup LLVMCoreValueConstantGlobalAlias Global Aliases
2314 * This group contains function that operate on global alias values.
2316 * @see llvm::GlobalAlias
2320 LLVMValueRef LLVMAddAlias(LLVMModuleRef M, LLVMTypeRef Ty, LLVMValueRef Aliasee,
2324 * Obtain a GlobalAlias value from a Module by its name.
2326 * The returned value corresponds to a llvm::GlobalAlias value.
2328 * @see llvm::Module::getNamedAlias()
2330 LLVMValueRef LLVMGetNamedGlobalAlias(LLVMModuleRef M,
2331 const char *Name, size_t NameLen);
2334 * Obtain an iterator to the first GlobalAlias in a Module.
2336 * @see llvm::Module::alias_begin()
2338 LLVMValueRef LLVMGetFirstGlobalAlias(LLVMModuleRef M);
2341 * Obtain an iterator to the last GlobalAlias in a Module.
2343 * @see llvm::Module::alias_end()
2345 LLVMValueRef LLVMGetLastGlobalAlias(LLVMModuleRef M);
2348 * Advance a GlobalAlias iterator to the next GlobalAlias.
2350 * Returns NULL if the iterator was already at the end and there are no more
2353 LLVMValueRef LLVMGetNextGlobalAlias(LLVMValueRef GA);
2356 * Decrement a GlobalAlias iterator to the previous GlobalAlias.
2358 * Returns NULL if the iterator was already at the beginning and there are
2359 * no previous global aliases.
2361 LLVMValueRef LLVMGetPreviousGlobalAlias(LLVMValueRef GA);
2364 * Retrieve the target value of an alias.
2366 LLVMValueRef LLVMAliasGetAliasee(LLVMValueRef Alias);
2369 * Set the target value of an alias.
2371 void LLVMAliasSetAliasee(LLVMValueRef Alias, LLVMValueRef Aliasee);
2378 * @defgroup LLVMCCoreValueFunction Function values
2380 * Functions in this group operate on LLVMValueRef instances that
2381 * correspond to llvm::Function instances.
2383 * @see llvm::Function
2389 * Remove a function from its containing module and deletes it.
2391 * @see llvm::Function::eraseFromParent()
2393 void LLVMDeleteFunction(LLVMValueRef Fn);
2396 * Check whether the given function has a personality function.
2398 * @see llvm::Function::hasPersonalityFn()
2400 LLVMBool LLVMHasPersonalityFn(LLVMValueRef Fn);
2403 * Obtain the personality function attached to the function.
2405 * @see llvm::Function::getPersonalityFn()
2407 LLVMValueRef LLVMGetPersonalityFn(LLVMValueRef Fn);
2410 * Set the personality function attached to the function.
2412 * @see llvm::Function::setPersonalityFn()
2414 void LLVMSetPersonalityFn(LLVMValueRef Fn, LLVMValueRef PersonalityFn);
2417 * Obtain the intrinsic ID number which matches the given function name.
2419 * @see llvm::Function::lookupIntrinsicID()
2421 unsigned LLVMLookupIntrinsicID(const char *Name, size_t NameLen);
2424 * Obtain the ID number from a function instance.
2426 * @see llvm::Function::getIntrinsicID()
2428 unsigned LLVMGetIntrinsicID(LLVMValueRef Fn);
2431 * Create or insert the declaration of an intrinsic. For overloaded intrinsics,
2432 * parameter types must be provided to uniquely identify an overload.
2434 * @see llvm::Intrinsic::getDeclaration()
2436 LLVMValueRef LLVMGetIntrinsicDeclaration(LLVMModuleRef Mod,
2438 LLVMTypeRef *ParamTypes,
2442 * Retrieves the type of an intrinsic. For overloaded intrinsics, parameter
2443 * types must be provided to uniquely identify an overload.
2445 * @see llvm::Intrinsic::getType()
2447 LLVMTypeRef LLVMIntrinsicGetType(LLVMContextRef Ctx, unsigned ID,
2448 LLVMTypeRef *ParamTypes, size_t ParamCount);
2451 * Retrieves the name of an intrinsic.
2453 * @see llvm::Intrinsic::getName()
2455 const char *LLVMIntrinsicGetName(unsigned ID, size_t *NameLength);
2458 * Copies the name of an overloaded intrinsic identified by a given list of
2461 * Unlike LLVMIntrinsicGetName, the caller is responsible for freeing the
2464 * @see llvm::Intrinsic::getName()
2466 const char *LLVMIntrinsicCopyOverloadedName(unsigned ID,
2467 LLVMTypeRef *ParamTypes,
2469 size_t *NameLength);
2472 * Obtain if the intrinsic identified by the given ID is overloaded.
2474 * @see llvm::Intrinsic::isOverloaded()
2476 LLVMBool LLVMIntrinsicIsOverloaded(unsigned ID);
2479 * Obtain the calling function of a function.
2481 * The returned value corresponds to the LLVMCallConv enumeration.
2483 * @see llvm::Function::getCallingConv()
2485 unsigned LLVMGetFunctionCallConv(LLVMValueRef Fn);
2488 * Set the calling convention of a function.
2490 * @see llvm::Function::setCallingConv()
2492 * @param Fn Function to operate on
2493 * @param CC LLVMCallConv to set calling convention to
2495 void LLVMSetFunctionCallConv(LLVMValueRef Fn, unsigned CC);
2498 * Obtain the name of the garbage collector to use during code
2501 * @see llvm::Function::getGC()
2503 const char *LLVMGetGC(LLVMValueRef Fn);
2506 * Define the garbage collector to use during code generation.
2508 * @see llvm::Function::setGC()
2510 void LLVMSetGC(LLVMValueRef Fn, const char *Name);
2513 * Add an attribute to a function.
2515 * @see llvm::Function::addAttribute()
2517 void LLVMAddAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx,
2518 LLVMAttributeRef A);
2519 unsigned LLVMGetAttributeCountAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx);
2520 void LLVMGetAttributesAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx,
2521 LLVMAttributeRef *Attrs);
2522 LLVMAttributeRef LLVMGetEnumAttributeAtIndex(LLVMValueRef F,
2523 LLVMAttributeIndex Idx,
2525 LLVMAttributeRef LLVMGetStringAttributeAtIndex(LLVMValueRef F,
2526 LLVMAttributeIndex Idx,
2527 const char *K, unsigned KLen);
2528 void LLVMRemoveEnumAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx,
2530 void LLVMRemoveStringAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx,
2531 const char *K, unsigned KLen);
2534 * Add a target-dependent attribute to a function
2535 * @see llvm::AttrBuilder::addAttribute()
2537 void LLVMAddTargetDependentFunctionAttr(LLVMValueRef Fn, const char *A,
2541 * @defgroup LLVMCCoreValueFunctionParameters Function Parameters
2543 * Functions in this group relate to arguments/parameters on functions.
2545 * Functions in this group expect LLVMValueRef instances that correspond
2546 * to llvm::Function instances.
2552 * Obtain the number of parameters in a function.
2554 * @see llvm::Function::arg_size()
2556 unsigned LLVMCountParams(LLVMValueRef Fn);
2559 * Obtain the parameters in a function.
2561 * The takes a pointer to a pre-allocated array of LLVMValueRef that is
2562 * at least LLVMCountParams() long. This array will be filled with
2563 * LLVMValueRef instances which correspond to the parameters the
2564 * function receives. Each LLVMValueRef corresponds to a llvm::Argument
2567 * @see llvm::Function::arg_begin()
2569 void LLVMGetParams(LLVMValueRef Fn, LLVMValueRef *Params);
2572 * Obtain the parameter at the specified index.
2574 * Parameters are indexed from 0.
2576 * @see llvm::Function::arg_begin()
2578 LLVMValueRef LLVMGetParam(LLVMValueRef Fn, unsigned Index);
2581 * Obtain the function to which this argument belongs.
2583 * Unlike other functions in this group, this one takes an LLVMValueRef
2584 * that corresponds to a llvm::Attribute.
2586 * The returned LLVMValueRef is the llvm::Function to which this
2589 LLVMValueRef LLVMGetParamParent(LLVMValueRef Inst);
2592 * Obtain the first parameter to a function.
2594 * @see llvm::Function::arg_begin()
2596 LLVMValueRef LLVMGetFirstParam(LLVMValueRef Fn);
2599 * Obtain the last parameter to a function.
2601 * @see llvm::Function::arg_end()
2603 LLVMValueRef LLVMGetLastParam(LLVMValueRef Fn);
2606 * Obtain the next parameter to a function.
2608 * This takes an LLVMValueRef obtained from LLVMGetFirstParam() (which is
2609 * actually a wrapped iterator) and obtains the next parameter from the
2610 * underlying iterator.
2612 LLVMValueRef LLVMGetNextParam(LLVMValueRef Arg);
2615 * Obtain the previous parameter to a function.
2617 * This is the opposite of LLVMGetNextParam().
2619 LLVMValueRef LLVMGetPreviousParam(LLVMValueRef Arg);
2622 * Set the alignment for a function parameter.
2624 * @see llvm::Argument::addAttr()
2625 * @see llvm::AttrBuilder::addAlignmentAttr()
2627 void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned Align);
2634 * @defgroup LLVMCCoreValueGlobalIFunc IFuncs
2636 * Functions in this group relate to indirect functions.
2638 * Functions in this group expect LLVMValueRef instances that correspond
2639 * to llvm::GlobalIFunc instances.
2645 * Add a global indirect function to a module under a specified name.
2647 * @see llvm::GlobalIFunc::create()
2649 LLVMValueRef LLVMAddGlobalIFunc(LLVMModuleRef M,
2650 const char *Name, size_t NameLen,
2651 LLVMTypeRef Ty, unsigned AddrSpace,
2652 LLVMValueRef Resolver);
2655 * Obtain a GlobalIFunc value from a Module by its name.
2657 * The returned value corresponds to a llvm::GlobalIFunc value.
2659 * @see llvm::Module::getNamedIFunc()
2661 LLVMValueRef LLVMGetNamedGlobalIFunc(LLVMModuleRef M,
2662 const char *Name, size_t NameLen);
2665 * Obtain an iterator to the first GlobalIFunc in a Module.
2667 * @see llvm::Module::ifunc_begin()
2669 LLVMValueRef LLVMGetFirstGlobalIFunc(LLVMModuleRef M);
2672 * Obtain an iterator to the last GlobalIFunc in a Module.
2674 * @see llvm::Module::ifunc_end()
2676 LLVMValueRef LLVMGetLastGlobalIFunc(LLVMModuleRef M);
2679 * Advance a GlobalIFunc iterator to the next GlobalIFunc.
2681 * Returns NULL if the iterator was already at the end and there are no more
2684 LLVMValueRef LLVMGetNextGlobalIFunc(LLVMValueRef IFunc);
2687 * Decrement a GlobalIFunc iterator to the previous GlobalIFunc.
2689 * Returns NULL if the iterator was already at the beginning and there are
2690 * no previous global aliases.
2692 LLVMValueRef LLVMGetPreviousGlobalIFunc(LLVMValueRef IFunc);
2695 * Retrieves the resolver function associated with this indirect function, or
2696 * NULL if it doesn't not exist.
2698 * @see llvm::GlobalIFunc::getResolver()
2700 LLVMValueRef LLVMGetGlobalIFuncResolver(LLVMValueRef IFunc);
2703 * Sets the resolver function associated with this indirect function.
2705 * @see llvm::GlobalIFunc::setResolver()
2707 void LLVMSetGlobalIFuncResolver(LLVMValueRef IFunc, LLVMValueRef Resolver);
2710 * Remove a global indirect function from its parent module and delete it.
2712 * @see llvm::GlobalIFunc::eraseFromParent()
2714 void LLVMEraseGlobalIFunc(LLVMValueRef IFunc);
2717 * Remove a global indirect function from its parent module.
2719 * This unlinks the global indirect function from its containing module but
2722 * @see llvm::GlobalIFunc::removeFromParent()
2724 void LLVMRemoveGlobalIFunc(LLVMValueRef IFunc);
2743 * @defgroup LLVMCCoreValueMetadata Metadata
2749 * Create an MDString value from a given string value.
2751 * The MDString value does not take ownership of the given string, it remains
2752 * the responsibility of the caller to free it.
2754 * @see llvm::MDString::get()
2756 LLVMMetadataRef LLVMMDStringInContext2(LLVMContextRef C, const char *Str,
2760 * Create an MDNode value with the given array of operands.
2762 * @see llvm::MDNode::get()
2764 LLVMMetadataRef LLVMMDNodeInContext2(LLVMContextRef C, LLVMMetadataRef *MDs,
2768 * Obtain a Metadata as a Value.
2770 LLVMValueRef LLVMMetadataAsValue(LLVMContextRef C, LLVMMetadataRef MD);
2773 * Obtain a Value as a Metadata.
2775 LLVMMetadataRef LLVMValueAsMetadata(LLVMValueRef Val);
2778 * Obtain the underlying string from a MDString value.
2780 * @param V Instance to obtain string from.
2781 * @param Length Memory address which will hold length of returned string.
2782 * @return String data in MDString.
2784 const char *LLVMGetMDString(LLVMValueRef V, unsigned *Length);
2787 * Obtain the number of operands from an MDNode value.
2789 * @param V MDNode to get number of operands from.
2790 * @return Number of operands of the MDNode.
2792 unsigned LLVMGetMDNodeNumOperands(LLVMValueRef V);
2795 * Obtain the given MDNode's operands.
2797 * The passed LLVMValueRef pointer should point to enough memory to hold all of
2798 * the operands of the given MDNode (see LLVMGetMDNodeNumOperands) as
2799 * LLVMValueRefs. This memory will be populated with the LLVMValueRefs of the
2800 * MDNode's operands.
2802 * @param V MDNode to get the operands from.
2803 * @param Dest Destination array for operands.
2805 void LLVMGetMDNodeOperands(LLVMValueRef V, LLVMValueRef *Dest);
2807 /** Deprecated: Use LLVMMDStringInContext2 instead. */
2808 LLVMValueRef LLVMMDStringInContext(LLVMContextRef C, const char *Str,
2810 /** Deprecated: Use LLVMMDStringInContext2 instead. */
2811 LLVMValueRef LLVMMDString(const char *Str, unsigned SLen);
2812 /** Deprecated: Use LLVMMDNodeInContext2 instead. */
2813 LLVMValueRef LLVMMDNodeInContext(LLVMContextRef C, LLVMValueRef *Vals,
2815 /** Deprecated: Use LLVMMDNodeInContext2 instead. */
2816 LLVMValueRef LLVMMDNode(LLVMValueRef *Vals, unsigned Count);
2823 * @defgroup LLVMCCoreValueBasicBlock Basic Block
2825 * A basic block represents a single entry single exit section of code.
2826 * Basic blocks contain a list of instructions which form the body of
2829 * Basic blocks belong to functions. They have the type of label.
2831 * Basic blocks are themselves values. However, the C API models them as
2832 * LLVMBasicBlockRef.
2834 * @see llvm::BasicBlock
2840 * Convert a basic block instance to a value type.
2842 LLVMValueRef LLVMBasicBlockAsValue(LLVMBasicBlockRef BB);
2845 * Determine whether an LLVMValueRef is itself a basic block.
2847 LLVMBool LLVMValueIsBasicBlock(LLVMValueRef Val);
2850 * Convert an LLVMValueRef to an LLVMBasicBlockRef instance.
2852 LLVMBasicBlockRef LLVMValueAsBasicBlock(LLVMValueRef Val);
2855 * Obtain the string name of a basic block.
2857 const char *LLVMGetBasicBlockName(LLVMBasicBlockRef BB);
2860 * Obtain the function to which a basic block belongs.
2862 * @see llvm::BasicBlock::getParent()
2864 LLVMValueRef LLVMGetBasicBlockParent(LLVMBasicBlockRef BB);
2867 * Obtain the terminator instruction for a basic block.
2869 * If the basic block does not have a terminator (it is not well-formed
2870 * if it doesn't), then NULL is returned.
2872 * The returned LLVMValueRef corresponds to an llvm::Instruction.
2874 * @see llvm::BasicBlock::getTerminator()
2876 LLVMValueRef LLVMGetBasicBlockTerminator(LLVMBasicBlockRef BB);
2879 * Obtain the number of basic blocks in a function.
2881 * @param Fn Function value to operate on.
2883 unsigned LLVMCountBasicBlocks(LLVMValueRef Fn);
2886 * Obtain all of the basic blocks in a function.
2888 * This operates on a function value. The BasicBlocks parameter is a
2889 * pointer to a pre-allocated array of LLVMBasicBlockRef of at least
2890 * LLVMCountBasicBlocks() in length. This array is populated with
2891 * LLVMBasicBlockRef instances.
2893 void LLVMGetBasicBlocks(LLVMValueRef Fn, LLVMBasicBlockRef *BasicBlocks);
2896 * Obtain the first basic block in a function.
2898 * The returned basic block can be used as an iterator. You will likely
2899 * eventually call into LLVMGetNextBasicBlock() with it.
2901 * @see llvm::Function::begin()
2903 LLVMBasicBlockRef LLVMGetFirstBasicBlock(LLVMValueRef Fn);
2906 * Obtain the last basic block in a function.
2908 * @see llvm::Function::end()
2910 LLVMBasicBlockRef LLVMGetLastBasicBlock(LLVMValueRef Fn);
2913 * Advance a basic block iterator.
2915 LLVMBasicBlockRef LLVMGetNextBasicBlock(LLVMBasicBlockRef BB);
2918 * Go backwards in a basic block iterator.
2920 LLVMBasicBlockRef LLVMGetPreviousBasicBlock(LLVMBasicBlockRef BB);
2923 * Obtain the basic block that corresponds to the entry point of a
2926 * @see llvm::Function::getEntryBlock()
2928 LLVMBasicBlockRef LLVMGetEntryBasicBlock(LLVMValueRef Fn);
2931 * Insert the given basic block after the insertion point of the given builder.
2933 * The insertion point must be valid.
2935 * @see llvm::Function::BasicBlockListType::insertAfter()
2937 void LLVMInsertExistingBasicBlockAfterInsertBlock(LLVMBuilderRef Builder,
2938 LLVMBasicBlockRef BB);
2941 * Append the given basic block to the basic block list of the given function.
2943 * @see llvm::Function::BasicBlockListType::push_back()
2945 void LLVMAppendExistingBasicBlock(LLVMValueRef Fn,
2946 LLVMBasicBlockRef BB);
2949 * Create a new basic block without inserting it into a function.
2951 * @see llvm::BasicBlock::Create()
2953 LLVMBasicBlockRef LLVMCreateBasicBlockInContext(LLVMContextRef C,
2957 * Append a basic block to the end of a function.
2959 * @see llvm::BasicBlock::Create()
2961 LLVMBasicBlockRef LLVMAppendBasicBlockInContext(LLVMContextRef C,
2966 * Append a basic block to the end of a function using the global
2969 * @see llvm::BasicBlock::Create()
2971 LLVMBasicBlockRef LLVMAppendBasicBlock(LLVMValueRef Fn, const char *Name);
2974 * Insert a basic block in a function before another basic block.
2976 * The function to add to is determined by the function of the
2977 * passed basic block.
2979 * @see llvm::BasicBlock::Create()
2981 LLVMBasicBlockRef LLVMInsertBasicBlockInContext(LLVMContextRef C,
2982 LLVMBasicBlockRef BB,
2986 * Insert a basic block in a function using the global context.
2988 * @see llvm::BasicBlock::Create()
2990 LLVMBasicBlockRef LLVMInsertBasicBlock(LLVMBasicBlockRef InsertBeforeBB,
2994 * Remove a basic block from a function and delete it.
2996 * This deletes the basic block from its containing function and deletes
2997 * the basic block itself.
2999 * @see llvm::BasicBlock::eraseFromParent()
3001 void LLVMDeleteBasicBlock(LLVMBasicBlockRef BB);
3004 * Remove a basic block from a function.
3006 * This deletes the basic block from its containing function but keep
3007 * the basic block alive.
3009 * @see llvm::BasicBlock::removeFromParent()
3011 void LLVMRemoveBasicBlockFromParent(LLVMBasicBlockRef BB);
3014 * Move a basic block to before another one.
3016 * @see llvm::BasicBlock::moveBefore()
3018 void LLVMMoveBasicBlockBefore(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos);
3021 * Move a basic block to after another one.
3023 * @see llvm::BasicBlock::moveAfter()
3025 void LLVMMoveBasicBlockAfter(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos);
3028 * Obtain the first instruction in a basic block.
3030 * The returned LLVMValueRef corresponds to a llvm::Instruction
3033 LLVMValueRef LLVMGetFirstInstruction(LLVMBasicBlockRef BB);
3036 * Obtain the last instruction in a basic block.
3038 * The returned LLVMValueRef corresponds to an LLVM:Instruction.
3040 LLVMValueRef LLVMGetLastInstruction(LLVMBasicBlockRef BB);
3047 * @defgroup LLVMCCoreValueInstruction Instructions
3049 * Functions in this group relate to the inspection and manipulation of
3050 * individual instructions.
3052 * In the C++ API, an instruction is modeled by llvm::Instruction. This
3053 * class has a large number of descendents. llvm::Instruction is a
3054 * llvm::Value and in the C API, instructions are modeled by
3057 * This group also contains sub-groups which operate on specific
3058 * llvm::Instruction types, e.g. llvm::CallInst.
3064 * Determine whether an instruction has any metadata attached.
3066 int LLVMHasMetadata(LLVMValueRef Val);
3069 * Return metadata associated with an instruction value.
3071 LLVMValueRef LLVMGetMetadata(LLVMValueRef Val, unsigned KindID);
3074 * Set metadata associated with an instruction value.
3076 void LLVMSetMetadata(LLVMValueRef Val, unsigned KindID, LLVMValueRef Node);
3079 * Returns the metadata associated with an instruction value, but filters out
3080 * all the debug locations.
3082 * @see llvm::Instruction::getAllMetadataOtherThanDebugLoc()
3084 LLVMValueMetadataEntry *
3085 LLVMInstructionGetAllMetadataOtherThanDebugLoc(LLVMValueRef Instr,
3086 size_t *NumEntries);
3089 * Obtain the basic block to which an instruction belongs.
3091 * @see llvm::Instruction::getParent()
3093 LLVMBasicBlockRef LLVMGetInstructionParent(LLVMValueRef Inst);
3096 * Obtain the instruction that occurs after the one specified.
3098 * The next instruction will be from the same basic block.
3100 * If this is the last instruction in a basic block, NULL will be
3103 LLVMValueRef LLVMGetNextInstruction(LLVMValueRef Inst);
3106 * Obtain the instruction that occurred before this one.
3108 * If the instruction is the first instruction in a basic block, NULL
3111 LLVMValueRef LLVMGetPreviousInstruction(LLVMValueRef Inst);
3114 * Remove and delete an instruction.
3116 * The instruction specified is removed from its containing building
3117 * block but is kept alive.
3119 * @see llvm::Instruction::removeFromParent()
3121 void LLVMInstructionRemoveFromParent(LLVMValueRef Inst);
3124 * Remove and delete an instruction.
3126 * The instruction specified is removed from its containing building
3127 * block and then deleted.
3129 * @see llvm::Instruction::eraseFromParent()
3131 void LLVMInstructionEraseFromParent(LLVMValueRef Inst);
3134 * Obtain the code opcode for an individual instruction.
3136 * @see llvm::Instruction::getOpCode()
3138 LLVMOpcode LLVMGetInstructionOpcode(LLVMValueRef Inst);
3141 * Obtain the predicate of an instruction.
3143 * This is only valid for instructions that correspond to llvm::ICmpInst
3144 * or llvm::ConstantExpr whose opcode is llvm::Instruction::ICmp.
3146 * @see llvm::ICmpInst::getPredicate()
3148 LLVMIntPredicate LLVMGetICmpPredicate(LLVMValueRef Inst);
3151 * Obtain the float predicate of an instruction.
3153 * This is only valid for instructions that correspond to llvm::FCmpInst
3154 * or llvm::ConstantExpr whose opcode is llvm::Instruction::FCmp.
3156 * @see llvm::FCmpInst::getPredicate()
3158 LLVMRealPredicate LLVMGetFCmpPredicate(LLVMValueRef Inst);
3161 * Create a copy of 'this' instruction that is identical in all ways
3162 * except the following:
3163 * * The instruction has no parent
3164 * * The instruction has no name
3166 * @see llvm::Instruction::clone()
3168 LLVMValueRef LLVMInstructionClone(LLVMValueRef Inst);
3171 * Determine whether an instruction is a terminator. This routine is named to
3172 * be compatible with historical functions that did this by querying the
3173 * underlying C++ type.
3175 * @see llvm::Instruction::isTerminator()
3177 LLVMValueRef LLVMIsATerminatorInst(LLVMValueRef Inst);
3180 * @defgroup LLVMCCoreValueInstructionCall Call Sites and Invocations
3182 * Functions in this group apply to instructions that refer to call
3183 * sites and invocations. These correspond to C++ types in the
3184 * llvm::CallInst class tree.
3190 * Obtain the argument count for a call instruction.
3192 * This expects an LLVMValueRef that corresponds to a llvm::CallInst,
3193 * llvm::InvokeInst, or llvm:FuncletPadInst.
3195 * @see llvm::CallInst::getNumArgOperands()
3196 * @see llvm::InvokeInst::getNumArgOperands()
3197 * @see llvm::FuncletPadInst::getNumArgOperands()
3199 unsigned LLVMGetNumArgOperands(LLVMValueRef Instr);
3202 * Set the calling convention for a call instruction.
3204 * This expects an LLVMValueRef that corresponds to a llvm::CallInst or
3207 * @see llvm::CallInst::setCallingConv()
3208 * @see llvm::InvokeInst::setCallingConv()
3210 void LLVMSetInstructionCallConv(LLVMValueRef Instr, unsigned CC);
3213 * Obtain the calling convention for a call instruction.
3215 * This is the opposite of LLVMSetInstructionCallConv(). Reads its
3218 * @see LLVMSetInstructionCallConv()
3220 unsigned LLVMGetInstructionCallConv(LLVMValueRef Instr);
3222 void LLVMSetInstrParamAlignment(LLVMValueRef Instr, unsigned index,
3225 void LLVMAddCallSiteAttribute(LLVMValueRef C, LLVMAttributeIndex Idx,
3226 LLVMAttributeRef A);
3227 unsigned LLVMGetCallSiteAttributeCount(LLVMValueRef C, LLVMAttributeIndex Idx);
3228 void LLVMGetCallSiteAttributes(LLVMValueRef C, LLVMAttributeIndex Idx,
3229 LLVMAttributeRef *Attrs);
3230 LLVMAttributeRef LLVMGetCallSiteEnumAttribute(LLVMValueRef C,
3231 LLVMAttributeIndex Idx,
3233 LLVMAttributeRef LLVMGetCallSiteStringAttribute(LLVMValueRef C,
3234 LLVMAttributeIndex Idx,
3235 const char *K, unsigned KLen);
3236 void LLVMRemoveCallSiteEnumAttribute(LLVMValueRef C, LLVMAttributeIndex Idx,
3238 void LLVMRemoveCallSiteStringAttribute(LLVMValueRef C, LLVMAttributeIndex Idx,
3239 const char *K, unsigned KLen);
3242 * Obtain the function type called by this instruction.
3244 * @see llvm::CallBase::getFunctionType()
3246 LLVMTypeRef LLVMGetCalledFunctionType(LLVMValueRef C);
3249 * Obtain the pointer to the function invoked by this instruction.
3251 * This expects an LLVMValueRef that corresponds to a llvm::CallInst or
3254 * @see llvm::CallInst::getCalledValue()
3255 * @see llvm::InvokeInst::getCalledValue()
3257 LLVMValueRef LLVMGetCalledValue(LLVMValueRef Instr);
3260 * Obtain whether a call instruction is a tail call.
3262 * This only works on llvm::CallInst instructions.
3264 * @see llvm::CallInst::isTailCall()
3266 LLVMBool LLVMIsTailCall(LLVMValueRef CallInst);
3269 * Set whether a call instruction is a tail call.
3271 * This only works on llvm::CallInst instructions.
3273 * @see llvm::CallInst::setTailCall()
3275 void LLVMSetTailCall(LLVMValueRef CallInst, LLVMBool IsTailCall);
3278 * Return the normal destination basic block.
3280 * This only works on llvm::InvokeInst instructions.
3282 * @see llvm::InvokeInst::getNormalDest()
3284 LLVMBasicBlockRef LLVMGetNormalDest(LLVMValueRef InvokeInst);
3287 * Return the unwind destination basic block.
3289 * Works on llvm::InvokeInst, llvm::CleanupReturnInst, and
3290 * llvm::CatchSwitchInst instructions.
3292 * @see llvm::InvokeInst::getUnwindDest()
3293 * @see llvm::CleanupReturnInst::getUnwindDest()
3294 * @see llvm::CatchSwitchInst::getUnwindDest()
3296 LLVMBasicBlockRef LLVMGetUnwindDest(LLVMValueRef InvokeInst);
3299 * Set the normal destination basic block.
3301 * This only works on llvm::InvokeInst instructions.
3303 * @see llvm::InvokeInst::setNormalDest()
3305 void LLVMSetNormalDest(LLVMValueRef InvokeInst, LLVMBasicBlockRef B);
3308 * Set the unwind destination basic block.
3310 * Works on llvm::InvokeInst, llvm::CleanupReturnInst, and
3311 * llvm::CatchSwitchInst instructions.
3313 * @see llvm::InvokeInst::setUnwindDest()
3314 * @see llvm::CleanupReturnInst::setUnwindDest()
3315 * @see llvm::CatchSwitchInst::setUnwindDest()
3317 void LLVMSetUnwindDest(LLVMValueRef InvokeInst, LLVMBasicBlockRef B);
3324 * @defgroup LLVMCCoreValueInstructionTerminator Terminators
3326 * Functions in this group only apply to instructions for which
3327 * LLVMIsATerminatorInst returns true.
3333 * Return the number of successors that this terminator has.
3335 * @see llvm::Instruction::getNumSuccessors
3337 unsigned LLVMGetNumSuccessors(LLVMValueRef Term);
3340 * Return the specified successor.
3342 * @see llvm::Instruction::getSuccessor
3344 LLVMBasicBlockRef LLVMGetSuccessor(LLVMValueRef Term, unsigned i);
3347 * Update the specified successor to point at the provided block.
3349 * @see llvm::Instruction::setSuccessor
3351 void LLVMSetSuccessor(LLVMValueRef Term, unsigned i, LLVMBasicBlockRef block);
3354 * Return if a branch is conditional.
3356 * This only works on llvm::BranchInst instructions.
3358 * @see llvm::BranchInst::isConditional
3360 LLVMBool LLVMIsConditional(LLVMValueRef Branch);
3363 * Return the condition of a branch instruction.
3365 * This only works on llvm::BranchInst instructions.
3367 * @see llvm::BranchInst::getCondition
3369 LLVMValueRef LLVMGetCondition(LLVMValueRef Branch);
3372 * Set the condition of a branch instruction.
3374 * This only works on llvm::BranchInst instructions.
3376 * @see llvm::BranchInst::setCondition
3378 void LLVMSetCondition(LLVMValueRef Branch, LLVMValueRef Cond);
3381 * Obtain the default destination basic block of a switch instruction.
3383 * This only works on llvm::SwitchInst instructions.
3385 * @see llvm::SwitchInst::getDefaultDest()
3387 LLVMBasicBlockRef LLVMGetSwitchDefaultDest(LLVMValueRef SwitchInstr);
3394 * @defgroup LLVMCCoreValueInstructionAlloca Allocas
3396 * Functions in this group only apply to instructions that map to
3397 * llvm::AllocaInst instances.
3403 * Obtain the type that is being allocated by the alloca instruction.
3405 LLVMTypeRef LLVMGetAllocatedType(LLVMValueRef Alloca);
3412 * @defgroup LLVMCCoreValueInstructionGetElementPointer GEPs
3414 * Functions in this group only apply to instructions that map to
3415 * llvm::GetElementPtrInst instances.
3421 * Check whether the given GEP instruction is inbounds.
3423 LLVMBool LLVMIsInBounds(LLVMValueRef GEP);
3426 * Set the given GEP instruction to be inbounds or not.
3428 void LLVMSetIsInBounds(LLVMValueRef GEP, LLVMBool InBounds);
3435 * @defgroup LLVMCCoreValueInstructionPHINode PHI Nodes
3437 * Functions in this group only apply to instructions that map to
3438 * llvm::PHINode instances.
3444 * Add an incoming value to the end of a PHI list.
3446 void LLVMAddIncoming(LLVMValueRef PhiNode, LLVMValueRef *IncomingValues,
3447 LLVMBasicBlockRef *IncomingBlocks, unsigned Count);
3450 * Obtain the number of incoming basic blocks to a PHI node.
3452 unsigned LLVMCountIncoming(LLVMValueRef PhiNode);
3455 * Obtain an incoming value to a PHI node as an LLVMValueRef.
3457 LLVMValueRef LLVMGetIncomingValue(LLVMValueRef PhiNode, unsigned Index);
3460 * Obtain an incoming value to a PHI node as an LLVMBasicBlockRef.
3462 LLVMBasicBlockRef LLVMGetIncomingBlock(LLVMValueRef PhiNode, unsigned Index);
3469 * @defgroup LLVMCCoreValueInstructionExtractValue ExtractValue
3470 * @defgroup LLVMCCoreValueInstructionInsertValue InsertValue
3472 * Functions in this group only apply to instructions that map to
3473 * llvm::ExtractValue and llvm::InsertValue instances.
3479 * Obtain the number of indices.
3480 * NB: This also works on GEP.
3482 unsigned LLVMGetNumIndices(LLVMValueRef Inst);
3485 * Obtain the indices as an array.
3487 const unsigned *LLVMGetIndices(LLVMValueRef Inst);
3502 * @defgroup LLVMCCoreInstructionBuilder Instruction Builders
3504 * An instruction builder represents a point within a basic block and is
3505 * the exclusive means of building instructions using the C interface.
3510 LLVMBuilderRef LLVMCreateBuilderInContext(LLVMContextRef C);
3511 LLVMBuilderRef LLVMCreateBuilder(void);
3512 void LLVMPositionBuilder(LLVMBuilderRef Builder, LLVMBasicBlockRef Block,
3513 LLVMValueRef Instr);
3514 void LLVMPositionBuilderBefore(LLVMBuilderRef Builder, LLVMValueRef Instr);
3515 void LLVMPositionBuilderAtEnd(LLVMBuilderRef Builder, LLVMBasicBlockRef Block);
3516 LLVMBasicBlockRef LLVMGetInsertBlock(LLVMBuilderRef Builder);
3517 void LLVMClearInsertionPosition(LLVMBuilderRef Builder);
3518 void LLVMInsertIntoBuilder(LLVMBuilderRef Builder, LLVMValueRef Instr);
3519 void LLVMInsertIntoBuilderWithName(LLVMBuilderRef Builder, LLVMValueRef Instr,
3521 void LLVMDisposeBuilder(LLVMBuilderRef Builder);
3526 * Get location information used by debugging information.
3528 * @see llvm::IRBuilder::getCurrentDebugLocation()
3530 LLVMMetadataRef LLVMGetCurrentDebugLocation2(LLVMBuilderRef Builder);
3533 * Set location information used by debugging information.
3535 * To clear the location metadata of the given instruction, pass NULL to \p Loc.
3537 * @see llvm::IRBuilder::SetCurrentDebugLocation()
3539 void LLVMSetCurrentDebugLocation2(LLVMBuilderRef Builder, LLVMMetadataRef Loc);
3542 * Attempts to set the debug location for the given instruction using the
3543 * current debug location for the given builder. If the builder has no current
3544 * debug location, this function is a no-op.
3546 * @see llvm::IRBuilder::SetInstDebugLocation()
3548 void LLVMSetInstDebugLocation(LLVMBuilderRef Builder, LLVMValueRef Inst);
3551 * Get the dafult floating-point math metadata for a given builder.
3553 * @see llvm::IRBuilder::getDefaultFPMathTag()
3555 LLVMMetadataRef LLVMBuilderGetDefaultFPMathTag(LLVMBuilderRef Builder);
3558 * Set the default floating-point math metadata for the given builder.
3560 * To clear the metadata, pass NULL to \p FPMathTag.
3562 * @see llvm::IRBuilder::setDefaultFPMathTag()
3564 void LLVMBuilderSetDefaultFPMathTag(LLVMBuilderRef Builder,
3565 LLVMMetadataRef FPMathTag);
3568 * Deprecated: Passing the NULL location will crash.
3569 * Use LLVMGetCurrentDebugLocation2 instead.
3571 void LLVMSetCurrentDebugLocation(LLVMBuilderRef Builder, LLVMValueRef L);
3573 * Deprecated: Returning the NULL location will crash.
3574 * Use LLVMGetCurrentDebugLocation2 instead.
3576 LLVMValueRef LLVMGetCurrentDebugLocation(LLVMBuilderRef Builder);
3579 LLVMValueRef LLVMBuildRetVoid(LLVMBuilderRef);
3580 LLVMValueRef LLVMBuildRet(LLVMBuilderRef, LLVMValueRef V);
3581 LLVMValueRef LLVMBuildAggregateRet(LLVMBuilderRef, LLVMValueRef *RetVals,
3583 LLVMValueRef LLVMBuildBr(LLVMBuilderRef, LLVMBasicBlockRef Dest);
3584 LLVMValueRef LLVMBuildCondBr(LLVMBuilderRef, LLVMValueRef If,
3585 LLVMBasicBlockRef Then, LLVMBasicBlockRef Else);
3586 LLVMValueRef LLVMBuildSwitch(LLVMBuilderRef, LLVMValueRef V,
3587 LLVMBasicBlockRef Else, unsigned NumCases);
3588 LLVMValueRef LLVMBuildIndirectBr(LLVMBuilderRef B, LLVMValueRef Addr,
3590 // LLVMBuildInvoke is deprecated in favor of LLVMBuildInvoke2, in preparation
3591 // for opaque pointer types.
3592 LLVMValueRef LLVMBuildInvoke(LLVMBuilderRef, LLVMValueRef Fn,
3593 LLVMValueRef *Args, unsigned NumArgs,
3594 LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch,
3596 LLVMValueRef LLVMBuildInvoke2(LLVMBuilderRef, LLVMTypeRef Ty, LLVMValueRef Fn,
3597 LLVMValueRef *Args, unsigned NumArgs,
3598 LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch,
3600 LLVMValueRef LLVMBuildUnreachable(LLVMBuilderRef);
3602 /* Exception Handling */
3603 LLVMValueRef LLVMBuildResume(LLVMBuilderRef B, LLVMValueRef Exn);
3604 LLVMValueRef LLVMBuildLandingPad(LLVMBuilderRef B, LLVMTypeRef Ty,
3605 LLVMValueRef PersFn, unsigned NumClauses,
3607 LLVMValueRef LLVMBuildCleanupRet(LLVMBuilderRef B, LLVMValueRef CatchPad,
3608 LLVMBasicBlockRef BB);
3609 LLVMValueRef LLVMBuildCatchRet(LLVMBuilderRef B, LLVMValueRef CatchPad,
3610 LLVMBasicBlockRef BB);
3611 LLVMValueRef LLVMBuildCatchPad(LLVMBuilderRef B, LLVMValueRef ParentPad,
3612 LLVMValueRef *Args, unsigned NumArgs,
3614 LLVMValueRef LLVMBuildCleanupPad(LLVMBuilderRef B, LLVMValueRef ParentPad,
3615 LLVMValueRef *Args, unsigned NumArgs,
3617 LLVMValueRef LLVMBuildCatchSwitch(LLVMBuilderRef B, LLVMValueRef ParentPad,
3618 LLVMBasicBlockRef UnwindBB,
3619 unsigned NumHandlers, const char *Name);
3621 /* Add a case to the switch instruction */
3622 void LLVMAddCase(LLVMValueRef Switch, LLVMValueRef OnVal,
3623 LLVMBasicBlockRef Dest);
3625 /* Add a destination to the indirectbr instruction */
3626 void LLVMAddDestination(LLVMValueRef IndirectBr, LLVMBasicBlockRef Dest);
3628 /* Get the number of clauses on the landingpad instruction */
3629 unsigned LLVMGetNumClauses(LLVMValueRef LandingPad);
3631 /* Get the value of the clause at idnex Idx on the landingpad instruction */
3632 LLVMValueRef LLVMGetClause(LLVMValueRef LandingPad, unsigned Idx);
3634 /* Add a catch or filter clause to the landingpad instruction */
3635 void LLVMAddClause(LLVMValueRef LandingPad, LLVMValueRef ClauseVal);
3637 /* Get the 'cleanup' flag in the landingpad instruction */
3638 LLVMBool LLVMIsCleanup(LLVMValueRef LandingPad);
3640 /* Set the 'cleanup' flag in the landingpad instruction */
3641 void LLVMSetCleanup(LLVMValueRef LandingPad, LLVMBool Val);
3643 /* Add a destination to the catchswitch instruction */
3644 void LLVMAddHandler(LLVMValueRef CatchSwitch, LLVMBasicBlockRef Dest);
3646 /* Get the number of handlers on the catchswitch instruction */
3647 unsigned LLVMGetNumHandlers(LLVMValueRef CatchSwitch);
3650 * Obtain the basic blocks acting as handlers for a catchswitch instruction.
3652 * The Handlers parameter should point to a pre-allocated array of
3653 * LLVMBasicBlockRefs at least LLVMGetNumHandlers() large. On return, the
3654 * first LLVMGetNumHandlers() entries in the array will be populated
3655 * with LLVMBasicBlockRef instances.
3657 * @param CatchSwitch The catchswitch instruction to operate on.
3658 * @param Handlers Memory address of an array to be filled with basic blocks.
3660 void LLVMGetHandlers(LLVMValueRef CatchSwitch, LLVMBasicBlockRef *Handlers);
3664 /* Get the number of funcletpad arguments. */
3665 LLVMValueRef LLVMGetArgOperand(LLVMValueRef Funclet, unsigned i);
3667 /* Set a funcletpad argument at the given index. */
3668 void LLVMSetArgOperand(LLVMValueRef Funclet, unsigned i, LLVMValueRef value);
3671 * Get the parent catchswitch instruction of a catchpad instruction.
3673 * This only works on llvm::CatchPadInst instructions.
3675 * @see llvm::CatchPadInst::getCatchSwitch()
3677 LLVMValueRef LLVMGetParentCatchSwitch(LLVMValueRef CatchPad);
3680 * Set the parent catchswitch instruction of a catchpad instruction.
3682 * This only works on llvm::CatchPadInst instructions.
3684 * @see llvm::CatchPadInst::setCatchSwitch()
3686 void LLVMSetParentCatchSwitch(LLVMValueRef CatchPad, LLVMValueRef CatchSwitch);
3689 LLVMValueRef LLVMBuildAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3691 LLVMValueRef LLVMBuildNSWAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3693 LLVMValueRef LLVMBuildNUWAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3695 LLVMValueRef LLVMBuildFAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3697 LLVMValueRef LLVMBuildSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3699 LLVMValueRef LLVMBuildNSWSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3701 LLVMValueRef LLVMBuildNUWSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3703 LLVMValueRef LLVMBuildFSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3705 LLVMValueRef LLVMBuildMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3707 LLVMValueRef LLVMBuildNSWMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3709 LLVMValueRef LLVMBuildNUWMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3711 LLVMValueRef LLVMBuildFMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3713 LLVMValueRef LLVMBuildUDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3715 LLVMValueRef LLVMBuildExactUDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3717 LLVMValueRef LLVMBuildSDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3719 LLVMValueRef LLVMBuildExactSDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3721 LLVMValueRef LLVMBuildFDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3723 LLVMValueRef LLVMBuildURem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3725 LLVMValueRef LLVMBuildSRem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3727 LLVMValueRef LLVMBuildFRem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3729 LLVMValueRef LLVMBuildShl(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3731 LLVMValueRef LLVMBuildLShr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3733 LLVMValueRef LLVMBuildAShr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3735 LLVMValueRef LLVMBuildAnd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3737 LLVMValueRef LLVMBuildOr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3739 LLVMValueRef LLVMBuildXor(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3741 LLVMValueRef LLVMBuildBinOp(LLVMBuilderRef B, LLVMOpcode Op,
3742 LLVMValueRef LHS, LLVMValueRef RHS,
3744 LLVMValueRef LLVMBuildNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name);
3745 LLVMValueRef LLVMBuildNSWNeg(LLVMBuilderRef B, LLVMValueRef V,
3747 LLVMValueRef LLVMBuildNUWNeg(LLVMBuilderRef B, LLVMValueRef V,
3749 LLVMValueRef LLVMBuildFNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name);
3750 LLVMValueRef LLVMBuildNot(LLVMBuilderRef, LLVMValueRef V, const char *Name);
3753 LLVMValueRef LLVMBuildMalloc(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
3754 LLVMValueRef LLVMBuildArrayMalloc(LLVMBuilderRef, LLVMTypeRef Ty,
3755 LLVMValueRef Val, const char *Name);
3758 * Creates and inserts a memset to the specified pointer and the
3761 * @see llvm::IRRBuilder::CreateMemSet()
3763 LLVMValueRef LLVMBuildMemSet(LLVMBuilderRef B, LLVMValueRef Ptr,
3764 LLVMValueRef Val, LLVMValueRef Len,
3767 * Creates and inserts a memcpy between the specified pointers.
3769 * @see llvm::IRRBuilder::CreateMemCpy()
3771 LLVMValueRef LLVMBuildMemCpy(LLVMBuilderRef B,
3772 LLVMValueRef Dst, unsigned DstAlign,
3773 LLVMValueRef Src, unsigned SrcAlign,
3776 * Creates and inserts a memmove between the specified pointers.
3778 * @see llvm::IRRBuilder::CreateMemMove()
3780 LLVMValueRef LLVMBuildMemMove(LLVMBuilderRef B,
3781 LLVMValueRef Dst, unsigned DstAlign,
3782 LLVMValueRef Src, unsigned SrcAlign,
3785 LLVMValueRef LLVMBuildAlloca(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
3786 LLVMValueRef LLVMBuildArrayAlloca(LLVMBuilderRef, LLVMTypeRef Ty,
3787 LLVMValueRef Val, const char *Name);
3788 LLVMValueRef LLVMBuildFree(LLVMBuilderRef, LLVMValueRef PointerVal);
3789 // LLVMBuildLoad is deprecated in favor of LLVMBuildLoad2, in preparation for
3790 // opaque pointer types.
3791 LLVMValueRef LLVMBuildLoad(LLVMBuilderRef, LLVMValueRef PointerVal,
3793 LLVMValueRef LLVMBuildLoad2(LLVMBuilderRef, LLVMTypeRef Ty,
3794 LLVMValueRef PointerVal, const char *Name);
3795 LLVMValueRef LLVMBuildStore(LLVMBuilderRef, LLVMValueRef Val, LLVMValueRef Ptr);
3796 // LLVMBuildGEP, LLVMBuildInBoundsGEP, and LLVMBuildStructGEP are deprecated in
3797 // favor of LLVMBuild*GEP2, in preparation for opaque pointer types.
3798 LLVMValueRef LLVMBuildGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
3799 LLVMValueRef *Indices, unsigned NumIndices,
3801 LLVMValueRef LLVMBuildInBoundsGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
3802 LLVMValueRef *Indices, unsigned NumIndices,
3804 LLVMValueRef LLVMBuildStructGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
3805 unsigned Idx, const char *Name);
3806 LLVMValueRef LLVMBuildGEP2(LLVMBuilderRef B, LLVMTypeRef Ty,
3807 LLVMValueRef Pointer, LLVMValueRef *Indices,
3808 unsigned NumIndices, const char *Name);
3809 LLVMValueRef LLVMBuildInBoundsGEP2(LLVMBuilderRef B, LLVMTypeRef Ty,
3810 LLVMValueRef Pointer, LLVMValueRef *Indices,
3811 unsigned NumIndices, const char *Name);
3812 LLVMValueRef LLVMBuildStructGEP2(LLVMBuilderRef B, LLVMTypeRef Ty,
3813 LLVMValueRef Pointer, unsigned Idx,
3815 LLVMValueRef LLVMBuildGlobalString(LLVMBuilderRef B, const char *Str,
3817 LLVMValueRef LLVMBuildGlobalStringPtr(LLVMBuilderRef B, const char *Str,
3819 LLVMBool LLVMGetVolatile(LLVMValueRef MemoryAccessInst);
3820 void LLVMSetVolatile(LLVMValueRef MemoryAccessInst, LLVMBool IsVolatile);
3821 LLVMBool LLVMGetWeak(LLVMValueRef CmpXchgInst);
3822 void LLVMSetWeak(LLVMValueRef CmpXchgInst, LLVMBool IsWeak);
3823 LLVMAtomicOrdering LLVMGetOrdering(LLVMValueRef MemoryAccessInst);
3824 void LLVMSetOrdering(LLVMValueRef MemoryAccessInst, LLVMAtomicOrdering Ordering);
3825 LLVMAtomicRMWBinOp LLVMGetAtomicRMWBinOp(LLVMValueRef AtomicRMWInst);
3826 void LLVMSetAtomicRMWBinOp(LLVMValueRef AtomicRMWInst, LLVMAtomicRMWBinOp BinOp);
3829 LLVMValueRef LLVMBuildTrunc(LLVMBuilderRef, LLVMValueRef Val,
3830 LLVMTypeRef DestTy, const char *Name);
3831 LLVMValueRef LLVMBuildZExt(LLVMBuilderRef, LLVMValueRef Val,
3832 LLVMTypeRef DestTy, const char *Name);
3833 LLVMValueRef LLVMBuildSExt(LLVMBuilderRef, LLVMValueRef Val,
3834 LLVMTypeRef DestTy, const char *Name);
3835 LLVMValueRef LLVMBuildFPToUI(LLVMBuilderRef, LLVMValueRef Val,
3836 LLVMTypeRef DestTy, const char *Name);
3837 LLVMValueRef LLVMBuildFPToSI(LLVMBuilderRef, LLVMValueRef Val,
3838 LLVMTypeRef DestTy, const char *Name);
3839 LLVMValueRef LLVMBuildUIToFP(LLVMBuilderRef, LLVMValueRef Val,
3840 LLVMTypeRef DestTy, const char *Name);
3841 LLVMValueRef LLVMBuildSIToFP(LLVMBuilderRef, LLVMValueRef Val,
3842 LLVMTypeRef DestTy, const char *Name);
3843 LLVMValueRef LLVMBuildFPTrunc(LLVMBuilderRef, LLVMValueRef Val,
3844 LLVMTypeRef DestTy, const char *Name);
3845 LLVMValueRef LLVMBuildFPExt(LLVMBuilderRef, LLVMValueRef Val,
3846 LLVMTypeRef DestTy, const char *Name);
3847 LLVMValueRef LLVMBuildPtrToInt(LLVMBuilderRef, LLVMValueRef Val,
3848 LLVMTypeRef DestTy, const char *Name);
3849 LLVMValueRef LLVMBuildIntToPtr(LLVMBuilderRef, LLVMValueRef Val,
3850 LLVMTypeRef DestTy, const char *Name);
3851 LLVMValueRef LLVMBuildBitCast(LLVMBuilderRef, LLVMValueRef Val,
3852 LLVMTypeRef DestTy, const char *Name);
3853 LLVMValueRef LLVMBuildAddrSpaceCast(LLVMBuilderRef, LLVMValueRef Val,
3854 LLVMTypeRef DestTy, const char *Name);
3855 LLVMValueRef LLVMBuildZExtOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
3856 LLVMTypeRef DestTy, const char *Name);
3857 LLVMValueRef LLVMBuildSExtOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
3858 LLVMTypeRef DestTy, const char *Name);
3859 LLVMValueRef LLVMBuildTruncOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
3860 LLVMTypeRef DestTy, const char *Name);
3861 LLVMValueRef LLVMBuildCast(LLVMBuilderRef B, LLVMOpcode Op, LLVMValueRef Val,
3862 LLVMTypeRef DestTy, const char *Name);
3863 LLVMValueRef LLVMBuildPointerCast(LLVMBuilderRef, LLVMValueRef Val,
3864 LLVMTypeRef DestTy, const char *Name);
3865 LLVMValueRef LLVMBuildIntCast2(LLVMBuilderRef, LLVMValueRef Val,
3866 LLVMTypeRef DestTy, LLVMBool IsSigned,
3868 LLVMValueRef LLVMBuildFPCast(LLVMBuilderRef, LLVMValueRef Val,
3869 LLVMTypeRef DestTy, const char *Name);
3871 /** Deprecated: This cast is always signed. Use LLVMBuildIntCast2 instead. */
3872 LLVMValueRef LLVMBuildIntCast(LLVMBuilderRef, LLVMValueRef Val, /*Signed cast!*/
3873 LLVMTypeRef DestTy, const char *Name);
3876 LLVMValueRef LLVMBuildICmp(LLVMBuilderRef, LLVMIntPredicate Op,
3877 LLVMValueRef LHS, LLVMValueRef RHS,
3879 LLVMValueRef LLVMBuildFCmp(LLVMBuilderRef, LLVMRealPredicate Op,
3880 LLVMValueRef LHS, LLVMValueRef RHS,
3883 /* Miscellaneous instructions */
3884 LLVMValueRef LLVMBuildPhi(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
3885 // LLVMBuildCall is deprecated in favor of LLVMBuildCall2, in preparation for
3886 // opaque pointer types.
3887 LLVMValueRef LLVMBuildCall(LLVMBuilderRef, LLVMValueRef Fn,
3888 LLVMValueRef *Args, unsigned NumArgs,
3890 LLVMValueRef LLVMBuildCall2(LLVMBuilderRef, LLVMTypeRef, LLVMValueRef Fn,
3891 LLVMValueRef *Args, unsigned NumArgs,
3893 LLVMValueRef LLVMBuildSelect(LLVMBuilderRef, LLVMValueRef If,
3894 LLVMValueRef Then, LLVMValueRef Else,
3896 LLVMValueRef LLVMBuildVAArg(LLVMBuilderRef, LLVMValueRef List, LLVMTypeRef Ty,
3898 LLVMValueRef LLVMBuildExtractElement(LLVMBuilderRef, LLVMValueRef VecVal,
3899 LLVMValueRef Index, const char *Name);
3900 LLVMValueRef LLVMBuildInsertElement(LLVMBuilderRef, LLVMValueRef VecVal,
3901 LLVMValueRef EltVal, LLVMValueRef Index,
3903 LLVMValueRef LLVMBuildShuffleVector(LLVMBuilderRef, LLVMValueRef V1,
3904 LLVMValueRef V2, LLVMValueRef Mask,
3906 LLVMValueRef LLVMBuildExtractValue(LLVMBuilderRef, LLVMValueRef AggVal,
3907 unsigned Index, const char *Name);
3908 LLVMValueRef LLVMBuildInsertValue(LLVMBuilderRef, LLVMValueRef AggVal,
3909 LLVMValueRef EltVal, unsigned Index,
3911 LLVMValueRef LLVMBuildFreeze(LLVMBuilderRef, LLVMValueRef Val,
3914 LLVMValueRef LLVMBuildIsNull(LLVMBuilderRef, LLVMValueRef Val,
3916 LLVMValueRef LLVMBuildIsNotNull(LLVMBuilderRef, LLVMValueRef Val,
3918 LLVMValueRef LLVMBuildPtrDiff(LLVMBuilderRef, LLVMValueRef LHS,
3919 LLVMValueRef RHS, const char *Name);
3920 LLVMValueRef LLVMBuildFence(LLVMBuilderRef B, LLVMAtomicOrdering ordering,
3921 LLVMBool singleThread, const char *Name);
3922 LLVMValueRef LLVMBuildAtomicRMW(LLVMBuilderRef B, LLVMAtomicRMWBinOp op,
3923 LLVMValueRef PTR, LLVMValueRef Val,
3924 LLVMAtomicOrdering ordering,
3925 LLVMBool singleThread);
3926 LLVMValueRef LLVMBuildAtomicCmpXchg(LLVMBuilderRef B, LLVMValueRef Ptr,
3927 LLVMValueRef Cmp, LLVMValueRef New,
3928 LLVMAtomicOrdering SuccessOrdering,
3929 LLVMAtomicOrdering FailureOrdering,
3930 LLVMBool SingleThread);
3932 LLVMBool LLVMIsAtomicSingleThread(LLVMValueRef AtomicInst);
3933 void LLVMSetAtomicSingleThread(LLVMValueRef AtomicInst, LLVMBool SingleThread);
3935 LLVMAtomicOrdering LLVMGetCmpXchgSuccessOrdering(LLVMValueRef CmpXchgInst);
3936 void LLVMSetCmpXchgSuccessOrdering(LLVMValueRef CmpXchgInst,
3937 LLVMAtomicOrdering Ordering);
3938 LLVMAtomicOrdering LLVMGetCmpXchgFailureOrdering(LLVMValueRef CmpXchgInst);
3939 void LLVMSetCmpXchgFailureOrdering(LLVMValueRef CmpXchgInst,
3940 LLVMAtomicOrdering Ordering);
3947 * @defgroup LLVMCCoreModuleProvider Module Providers
3953 * Changes the type of M so it can be passed to FunctionPassManagers and the
3954 * JIT. They take ModuleProviders for historical reasons.
3956 LLVMModuleProviderRef
3957 LLVMCreateModuleProviderForExistingModule(LLVMModuleRef M);
3960 * Destroys the module M.
3962 void LLVMDisposeModuleProvider(LLVMModuleProviderRef M);
3969 * @defgroup LLVMCCoreMemoryBuffers Memory Buffers
3974 LLVMBool LLVMCreateMemoryBufferWithContentsOfFile(const char *Path,
3975 LLVMMemoryBufferRef *OutMemBuf,
3977 LLVMBool LLVMCreateMemoryBufferWithSTDIN(LLVMMemoryBufferRef *OutMemBuf,
3979 LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRange(const char *InputData,
3980 size_t InputDataLength,
3981 const char *BufferName,
3982 LLVMBool RequiresNullTerminator);
3983 LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRangeCopy(const char *InputData,
3984 size_t InputDataLength,
3985 const char *BufferName);
3986 const char *LLVMGetBufferStart(LLVMMemoryBufferRef MemBuf);
3987 size_t LLVMGetBufferSize(LLVMMemoryBufferRef MemBuf);
3988 void LLVMDisposeMemoryBuffer(LLVMMemoryBufferRef MemBuf);
3995 * @defgroup LLVMCCorePassRegistry Pass Registry
4000 /** Return the global pass registry, for use with initialization functions.
4001 @see llvm::PassRegistry::getPassRegistry */
4002 LLVMPassRegistryRef LLVMGetGlobalPassRegistry(void);
4009 * @defgroup LLVMCCorePassManagers Pass Managers
4014 /** Constructs a new whole-module pass pipeline. This type of pipeline is
4015 suitable for link-time optimization and whole-module transformations.
4016 @see llvm::PassManager::PassManager */
4017 LLVMPassManagerRef LLVMCreatePassManager(void);
4019 /** Constructs a new function-by-function pass pipeline over the module
4020 provider. It does not take ownership of the module provider. This type of
4021 pipeline is suitable for code generation and JIT compilation tasks.
4022 @see llvm::FunctionPassManager::FunctionPassManager */
4023 LLVMPassManagerRef LLVMCreateFunctionPassManagerForModule(LLVMModuleRef M);
4025 /** Deprecated: Use LLVMCreateFunctionPassManagerForModule instead. */
4026 LLVMPassManagerRef LLVMCreateFunctionPassManager(LLVMModuleProviderRef MP);
4028 /** Initializes, executes on the provided module, and finalizes all of the
4029 passes scheduled in the pass manager. Returns 1 if any of the passes
4030 modified the module, 0 otherwise.
4031 @see llvm::PassManager::run(Module&) */
4032 LLVMBool LLVMRunPassManager(LLVMPassManagerRef PM, LLVMModuleRef M);
4034 /** Initializes all of the function passes scheduled in the function pass
4035 manager. Returns 1 if any of the passes modified the module, 0 otherwise.
4036 @see llvm::FunctionPassManager::doInitialization */
4037 LLVMBool LLVMInitializeFunctionPassManager(LLVMPassManagerRef FPM);
4039 /** Executes all of the function passes scheduled in the function pass manager
4040 on the provided function. Returns 1 if any of the passes modified the
4041 function, false otherwise.
4042 @see llvm::FunctionPassManager::run(Function&) */
4043 LLVMBool LLVMRunFunctionPassManager(LLVMPassManagerRef FPM, LLVMValueRef F);
4045 /** Finalizes all of the function passes scheduled in the function pass
4046 manager. Returns 1 if any of the passes modified the module, 0 otherwise.
4047 @see llvm::FunctionPassManager::doFinalization */
4048 LLVMBool LLVMFinalizeFunctionPassManager(LLVMPassManagerRef FPM);
4050 /** Frees the memory of a pass pipeline. For function pipelines, does not free
4051 the module provider.
4052 @see llvm::PassManagerBase::~PassManagerBase. */
4053 void LLVMDisposePassManager(LLVMPassManagerRef PM);
4060 * @defgroup LLVMCCoreThreading Threading
4062 * Handle the structures needed to make LLVM safe for multithreading.
4067 /** Deprecated: Multi-threading can only be enabled/disabled with the compile
4068 time define LLVM_ENABLE_THREADS. This function always returns
4069 LLVMIsMultithreaded(). */
4070 LLVMBool LLVMStartMultithreaded(void);
4072 /** Deprecated: Multi-threading can only be enabled/disabled with the compile
4073 time define LLVM_ENABLE_THREADS. */
4074 void LLVMStopMultithreaded(void);
4076 /** Check whether LLVM is executing in thread-safe mode or not.
4077 @see llvm::llvm_is_multithreaded */
4078 LLVMBool LLVMIsMultithreaded(void);
4094 #endif /* LLVM_C_CORE_H */