1 /*===-- llvm-c/Core.h - Core Library C Interface ------------------*- C -*-===*\
3 |* The LLVM Compiler Infrastructure *|
5 |* This file is distributed under the University of Illinois Open Source *|
6 |* License. See LICENSE.TXT for details. *|
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/Types.h"
26 * @defgroup LLVMC LLVM-C: C interface to LLVM
28 * This module exposes parts of the LLVM library as a C API.
34 * @defgroup LLVMCTransforms Transforms
38 * @defgroup LLVMCCore Core
40 * This modules provide an interface to libLLVMCore, which implements
41 * the LLVM intermediate representation as well as other related types
44 * Many exotic languages can interoperate with C code but have a harder time
45 * with C++ due to name mangling. So in addition to C, this interface enables
46 * tools written in such languages.
52 * @defgroup LLVMCCoreTypes Types and Enumerations
58 /* Terminator Instructions */
64 /* removed 6 due to API changes */
67 /* Standard Binary Operators */
81 /* Logical Operators */
89 /* Memory Operators */
93 LLVMGetElementPtr = 29,
108 LLVMAddrSpaceCast = 60,
110 /* Other Operators */
119 LLVMExtractElement = 50,
120 LLVMInsertElement = 51,
121 LLVMShuffleVector = 52,
122 LLVMExtractValue = 53,
123 LLVMInsertValue = 54,
125 /* Atomic operators */
127 LLVMAtomicCmpXchg = 56,
130 /* Exception Handling Operators */
141 LLVMVoidTypeKind, /**< type with no size */
142 LLVMHalfTypeKind, /**< 16 bit floating point type */
143 LLVMFloatTypeKind, /**< 32 bit floating point type */
144 LLVMDoubleTypeKind, /**< 64 bit floating point type */
145 LLVMX86_FP80TypeKind, /**< 80 bit floating point type (X87) */
146 LLVMFP128TypeKind, /**< 128 bit floating point type (112-bit mantissa)*/
147 LLVMPPC_FP128TypeKind, /**< 128 bit floating point type (two 64-bits) */
148 LLVMLabelTypeKind, /**< Labels */
149 LLVMIntegerTypeKind, /**< Arbitrary bit width integers */
150 LLVMFunctionTypeKind, /**< Functions */
151 LLVMStructTypeKind, /**< Structures */
152 LLVMArrayTypeKind, /**< Arrays */
153 LLVMPointerTypeKind, /**< Pointers */
154 LLVMVectorTypeKind, /**< SIMD 'packed' format, or other vector type */
155 LLVMMetadataTypeKind, /**< Metadata */
156 LLVMX86_MMXTypeKind, /**< X86 MMX */
157 LLVMTokenTypeKind /**< Tokens */
161 LLVMExternalLinkage, /**< Externally visible function */
162 LLVMAvailableExternallyLinkage,
163 LLVMLinkOnceAnyLinkage, /**< Keep one copy of function when linking (inline)*/
164 LLVMLinkOnceODRLinkage, /**< Same, but only replaced by something
166 LLVMLinkOnceODRAutoHideLinkage, /**< Obsolete */
167 LLVMWeakAnyLinkage, /**< Keep one copy of function when linking (weak) */
168 LLVMWeakODRLinkage, /**< Same, but only replaced by something
170 LLVMAppendingLinkage, /**< Special purpose, only applies to global arrays */
171 LLVMInternalLinkage, /**< Rename collisions when linking (static
173 LLVMPrivateLinkage, /**< Like Internal, but omit from symbol table */
174 LLVMDLLImportLinkage, /**< Obsolete */
175 LLVMDLLExportLinkage, /**< Obsolete */
176 LLVMExternalWeakLinkage,/**< ExternalWeak linkage description */
177 LLVMGhostLinkage, /**< Obsolete */
178 LLVMCommonLinkage, /**< Tentative definitions */
179 LLVMLinkerPrivateLinkage, /**< Like Private, but linker removes. */
180 LLVMLinkerPrivateWeakLinkage /**< Like LinkerPrivate, but is weak. */
184 LLVMDefaultVisibility, /**< The GV is visible */
185 LLVMHiddenVisibility, /**< The GV is hidden */
186 LLVMProtectedVisibility /**< The GV is protected */
190 LLVMNoUnnamedAddr, /**< Address of the GV is significant. */
191 LLVMLocalUnnamedAddr, /**< Address of the GV is locally insignificant. */
192 LLVMGlobalUnnamedAddr /**< Address of the GV is globally insignificant. */
196 LLVMDefaultStorageClass = 0,
197 LLVMDLLImportStorageClass = 1, /**< Function to be imported from DLL. */
198 LLVMDLLExportStorageClass = 2 /**< Function to be accessible from DLL. */
199 } LLVMDLLStorageClass;
203 LLVMFastCallConv = 8,
204 LLVMColdCallConv = 9,
205 LLVMGHCCallConv = 10,
206 LLVMHiPECallConv = 11,
207 LLVMWebKitJSCallConv = 12,
208 LLVMAnyRegCallConv = 13,
209 LLVMPreserveMostCallConv = 14,
210 LLVMPreserveAllCallConv = 15,
211 LLVMSwiftCallConv = 16,
212 LLVMCXXFASTTLSCallConv = 17,
213 LLVMX86StdcallCallConv = 64,
214 LLVMX86FastcallCallConv = 65,
215 LLVMARMAPCSCallConv = 66,
216 LLVMARMAAPCSCallConv = 67,
217 LLVMARMAAPCSVFPCallConv = 68,
218 LLVMMSP430INTRCallConv = 69,
219 LLVMX86ThisCallCallConv = 70,
220 LLVMPTXKernelCallConv = 71,
221 LLVMPTXDeviceCallConv = 72,
222 LLVMSPIRFUNCCallConv = 75,
223 LLVMSPIRKERNELCallConv = 76,
224 LLVMIntelOCLBICallConv = 77,
225 LLVMX8664SysVCallConv = 78,
226 LLVMWin64CallConv = 79,
227 LLVMX86VectorCallCallConv = 80,
228 LLVMHHVMCallConv = 81,
229 LLVMHHVMCCallConv = 82,
230 LLVMX86INTRCallConv = 83,
231 LLVMAVRINTRCallConv = 84,
232 LLVMAVRSIGNALCallConv = 85,
233 LLVMAVRBUILTINCallConv = 86,
234 LLVMAMDGPUVSCallConv = 87,
235 LLVMAMDGPUGSCallConv = 88,
236 LLVMAMDGPUPSCallConv = 89,
237 LLVMAMDGPUCSCallConv = 90,
238 LLVMAMDGPUKERNELCallConv = 91,
239 LLVMX86RegCallCallConv = 92,
240 LLVMAMDGPUHSCallConv = 93,
241 LLVMMSP430BUILTINCallConv = 94,
242 LLVMAMDGPULSCallConv = 95,
243 LLVMAMDGPUESCallConv = 96
247 LLVMArgumentValueKind,
248 LLVMBasicBlockValueKind,
249 LLVMMemoryUseValueKind,
250 LLVMMemoryDefValueKind,
251 LLVMMemoryPhiValueKind,
253 LLVMFunctionValueKind,
254 LLVMGlobalAliasValueKind,
255 LLVMGlobalIFuncValueKind,
256 LLVMGlobalVariableValueKind,
257 LLVMBlockAddressValueKind,
258 LLVMConstantExprValueKind,
259 LLVMConstantArrayValueKind,
260 LLVMConstantStructValueKind,
261 LLVMConstantVectorValueKind,
263 LLVMUndefValueValueKind,
264 LLVMConstantAggregateZeroValueKind,
265 LLVMConstantDataArrayValueKind,
266 LLVMConstantDataVectorValueKind,
267 LLVMConstantIntValueKind,
268 LLVMConstantFPValueKind,
269 LLVMConstantPointerNullValueKind,
270 LLVMConstantTokenNoneValueKind,
272 LLVMMetadataAsValueValueKind,
273 LLVMInlineAsmValueKind,
275 LLVMInstructionValueKind,
279 LLVMIntEQ = 32, /**< equal */
280 LLVMIntNE, /**< not equal */
281 LLVMIntUGT, /**< unsigned greater than */
282 LLVMIntUGE, /**< unsigned greater or equal */
283 LLVMIntULT, /**< unsigned less than */
284 LLVMIntULE, /**< unsigned less or equal */
285 LLVMIntSGT, /**< signed greater than */
286 LLVMIntSGE, /**< signed greater or equal */
287 LLVMIntSLT, /**< signed less than */
288 LLVMIntSLE /**< signed less or equal */
292 LLVMRealPredicateFalse, /**< Always false (always folded) */
293 LLVMRealOEQ, /**< True if ordered and equal */
294 LLVMRealOGT, /**< True if ordered and greater than */
295 LLVMRealOGE, /**< True if ordered and greater than or equal */
296 LLVMRealOLT, /**< True if ordered and less than */
297 LLVMRealOLE, /**< True if ordered and less than or equal */
298 LLVMRealONE, /**< True if ordered and operands are unequal */
299 LLVMRealORD, /**< True if ordered (no nans) */
300 LLVMRealUNO, /**< True if unordered: isnan(X) | isnan(Y) */
301 LLVMRealUEQ, /**< True if unordered or equal */
302 LLVMRealUGT, /**< True if unordered or greater than */
303 LLVMRealUGE, /**< True if unordered, greater than, or equal */
304 LLVMRealULT, /**< True if unordered or less than */
305 LLVMRealULE, /**< True if unordered, less than, or equal */
306 LLVMRealUNE, /**< True if unordered or not equal */
307 LLVMRealPredicateTrue /**< Always true (always folded) */
311 LLVMLandingPadCatch, /**< A catch clause */
312 LLVMLandingPadFilter /**< A filter clause */
313 } LLVMLandingPadClauseTy;
316 LLVMNotThreadLocal = 0,
317 LLVMGeneralDynamicTLSModel,
318 LLVMLocalDynamicTLSModel,
319 LLVMInitialExecTLSModel,
320 LLVMLocalExecTLSModel
321 } LLVMThreadLocalMode;
324 LLVMAtomicOrderingNotAtomic = 0, /**< A load or store which is not atomic */
325 LLVMAtomicOrderingUnordered = 1, /**< Lowest level of atomicity, guarantees
326 somewhat sane results, lock free. */
327 LLVMAtomicOrderingMonotonic = 2, /**< guarantees that if you take all the
328 operations affecting a specific address,
329 a consistent ordering exists */
330 LLVMAtomicOrderingAcquire = 4, /**< Acquire provides a barrier of the sort
331 necessary to acquire a lock to access other
332 memory with normal loads and stores. */
333 LLVMAtomicOrderingRelease = 5, /**< Release is similar to Acquire, but with
334 a barrier of the sort necessary to release
336 LLVMAtomicOrderingAcquireRelease = 6, /**< provides both an Acquire and a
337 Release barrier (for fences and
338 operations which both read and write
340 LLVMAtomicOrderingSequentiallyConsistent = 7 /**< provides Acquire semantics
341 for loads and Release
342 semantics for stores.
343 Additionally, it guarantees
344 that a total ordering exists
346 SequentiallyConsistent
348 } LLVMAtomicOrdering;
351 LLVMAtomicRMWBinOpXchg, /**< Set the new value and return the one old */
352 LLVMAtomicRMWBinOpAdd, /**< Add a value and return the old one */
353 LLVMAtomicRMWBinOpSub, /**< Subtract a value and return the old one */
354 LLVMAtomicRMWBinOpAnd, /**< And a value and return the old one */
355 LLVMAtomicRMWBinOpNand, /**< Not-And a value and return the old one */
356 LLVMAtomicRMWBinOpOr, /**< OR a value and return the old one */
357 LLVMAtomicRMWBinOpXor, /**< Xor a value and return the old one */
358 LLVMAtomicRMWBinOpMax, /**< Sets the value if it's greater than the
359 original using a signed comparison and return
361 LLVMAtomicRMWBinOpMin, /**< Sets the value if it's Smaller than the
362 original using a signed comparison and return
364 LLVMAtomicRMWBinOpUMax, /**< Sets the value if it's greater than the
365 original using an unsigned comparison and return
367 LLVMAtomicRMWBinOpUMin /**< Sets the value if it's greater than the
368 original using an unsigned comparison and return
370 } LLVMAtomicRMWBinOp;
377 } LLVMDiagnosticSeverity;
380 LLVMInlineAsmDialectATT,
381 LLVMInlineAsmDialectIntel
382 } LLVMInlineAsmDialect;
386 * Emits an error if two values disagree, otherwise the resulting value is
387 * that of the operands.
389 * @see Module::ModFlagBehavior::Error
391 LLVMModuleFlagBehaviorError,
393 * Emits a warning if two values disagree. The result value will be the
394 * operand for the flag from the first module being linked.
396 * @see Module::ModFlagBehavior::Warning
398 LLVMModuleFlagBehaviorWarning,
400 * Adds a requirement that another module flag be present and have a
401 * specified value after linking is performed. The value must be a metadata
402 * pair, where the first element of the pair is the ID of the module flag
403 * to be restricted, and the second element of the pair is the value the
404 * module flag should be restricted to. This behavior can be used to
405 * restrict the allowable results (via triggering of an error) of linking
406 * IDs with the **Override** behavior.
408 * @see Module::ModFlagBehavior::Require
410 LLVMModuleFlagBehaviorRequire,
412 * Uses the specified value, regardless of the behavior or value of the
413 * other module. If both modules specify **Override**, but the values
414 * differ, an error will be emitted.
416 * @see Module::ModFlagBehavior::Override
418 LLVMModuleFlagBehaviorOverride,
420 * Appends the two values, which are required to be metadata nodes.
422 * @see Module::ModFlagBehavior::Append
424 LLVMModuleFlagBehaviorAppend,
426 * Appends the two values, which are required to be metadata
427 * nodes. However, duplicate entries in the second list are dropped
428 * during the append operation.
430 * @see Module::ModFlagBehavior::AppendUnique
432 LLVMModuleFlagBehaviorAppendUnique,
433 } LLVMModuleFlagBehavior;
436 * Attribute index are either LLVMAttributeReturnIndex,
437 * LLVMAttributeFunctionIndex or a parameter number from 1 to N.
440 LLVMAttributeReturnIndex = 0U,
441 // ISO C restricts enumerator values to range of 'int'
442 // (4294967295 is too large)
443 // LLVMAttributeFunctionIndex = ~0U,
444 LLVMAttributeFunctionIndex = -1,
447 typedef unsigned LLVMAttributeIndex;
453 void LLVMInitializeCore(LLVMPassRegistryRef R);
455 /** Deallocate and destroy all ManagedStatic variables.
456 @see llvm::llvm_shutdown
457 @see ManagedStatic */
458 void LLVMShutdown(void);
460 /*===-- Error handling ----------------------------------------------------===*/
462 char *LLVMCreateMessage(const char *Message);
463 void LLVMDisposeMessage(char *Message);
466 * @defgroup LLVMCCoreContext Contexts
468 * Contexts are execution states for the core LLVM IR system.
470 * Most types are tied to a context instance. Multiple contexts can
471 * exist simultaneously. A single context is not thread safe. However,
472 * different contexts can execute on different threads simultaneously.
477 typedef void (*LLVMDiagnosticHandler)(LLVMDiagnosticInfoRef, void *);
478 typedef void (*LLVMYieldCallback)(LLVMContextRef, void *);
481 * Create a new context.
483 * Every call to this function should be paired with a call to
484 * LLVMContextDispose() or the context will leak memory.
486 LLVMContextRef LLVMContextCreate(void);
489 * Obtain the global context instance.
491 LLVMContextRef LLVMGetGlobalContext(void);
494 * Set the diagnostic handler for this context.
496 void LLVMContextSetDiagnosticHandler(LLVMContextRef C,
497 LLVMDiagnosticHandler Handler,
498 void *DiagnosticContext);
501 * Get the diagnostic handler of this context.
503 LLVMDiagnosticHandler LLVMContextGetDiagnosticHandler(LLVMContextRef C);
506 * Get the diagnostic context of this context.
508 void *LLVMContextGetDiagnosticContext(LLVMContextRef C);
511 * Set the yield callback function for this context.
513 * @see LLVMContext::setYieldCallback()
515 void LLVMContextSetYieldCallback(LLVMContextRef C, LLVMYieldCallback Callback,
519 * Destroy a context instance.
521 * This should be called for every call to LLVMContextCreate() or memory
524 void LLVMContextDispose(LLVMContextRef C);
527 * Return a string representation of the DiagnosticInfo. Use
528 * LLVMDisposeMessage to free the string.
530 * @see DiagnosticInfo::print()
532 char *LLVMGetDiagInfoDescription(LLVMDiagnosticInfoRef DI);
535 * Return an enum LLVMDiagnosticSeverity.
537 * @see DiagnosticInfo::getSeverity()
539 LLVMDiagnosticSeverity LLVMGetDiagInfoSeverity(LLVMDiagnosticInfoRef DI);
541 unsigned LLVMGetMDKindIDInContext(LLVMContextRef C, const char *Name,
543 unsigned LLVMGetMDKindID(const char *Name, unsigned SLen);
546 * Return an unique id given the name of a enum attribute,
547 * or 0 if no attribute by that name exists.
549 * See http://llvm.org/docs/LangRef.html#parameter-attributes
550 * and http://llvm.org/docs/LangRef.html#function-attributes
551 * for the list of available attributes.
553 * NB: Attribute names and/or id are subject to change without
554 * going through the C API deprecation cycle.
556 unsigned LLVMGetEnumAttributeKindForName(const char *Name, size_t SLen);
557 unsigned LLVMGetLastEnumAttributeKind(void);
560 * Create an enum attribute.
562 LLVMAttributeRef LLVMCreateEnumAttribute(LLVMContextRef C, unsigned KindID,
566 * Get the unique id corresponding to the enum attribute
567 * passed as argument.
569 unsigned LLVMGetEnumAttributeKind(LLVMAttributeRef A);
572 * Get the enum attribute's value. 0 is returned if none exists.
574 uint64_t LLVMGetEnumAttributeValue(LLVMAttributeRef A);
577 * Create a string attribute.
579 LLVMAttributeRef LLVMCreateStringAttribute(LLVMContextRef C,
580 const char *K, unsigned KLength,
581 const char *V, unsigned VLength);
584 * Get the string attribute's kind.
586 const char *LLVMGetStringAttributeKind(LLVMAttributeRef A, unsigned *Length);
589 * Get the string attribute's value.
591 const char *LLVMGetStringAttributeValue(LLVMAttributeRef A, unsigned *Length);
594 * Check for the different types of attributes.
596 LLVMBool LLVMIsEnumAttribute(LLVMAttributeRef A);
597 LLVMBool LLVMIsStringAttribute(LLVMAttributeRef A);
604 * @defgroup LLVMCCoreModule Modules
606 * Modules represent the top-level structure in an LLVM program. An LLVM
607 * module is effectively a translation unit or a collection of
608 * translation units merged together.
614 * Create a new, empty module in the global context.
616 * This is equivalent to calling LLVMModuleCreateWithNameInContext with
617 * LLVMGetGlobalContext() as the context parameter.
619 * Every invocation should be paired with LLVMDisposeModule() or memory
622 LLVMModuleRef LLVMModuleCreateWithName(const char *ModuleID);
625 * Create a new, empty module in a specific context.
627 * Every invocation should be paired with LLVMDisposeModule() or memory
630 LLVMModuleRef LLVMModuleCreateWithNameInContext(const char *ModuleID,
633 * Return an exact copy of the specified module.
635 LLVMModuleRef LLVMCloneModule(LLVMModuleRef M);
638 * Destroy a module instance.
640 * This must be called for every created module or memory will be
643 void LLVMDisposeModule(LLVMModuleRef M);
646 * Obtain the identifier of a module.
648 * @param M Module to obtain identifier of
649 * @param Len Out parameter which holds the length of the returned string.
650 * @return The identifier of M.
651 * @see Module::getModuleIdentifier()
653 const char *LLVMGetModuleIdentifier(LLVMModuleRef M, size_t *Len);
656 * Set the identifier of a module to a string Ident with length Len.
658 * @param M The module to set identifier
659 * @param Ident The string to set M's identifier to
660 * @param Len Length of Ident
661 * @see Module::setModuleIdentifier()
663 void LLVMSetModuleIdentifier(LLVMModuleRef M, const char *Ident, size_t Len);
666 * Obtain the module's original source file name.
668 * @param M Module to obtain the name of
669 * @param Len Out parameter which holds the length of the returned string
670 * @return The original source file name of M
671 * @see Module::getSourceFileName()
673 const char *LLVMGetSourceFileName(LLVMModuleRef M, size_t *Len);
676 * Set the original source file name of a module to a string Name with length
679 * @param M The module to set the source file name of
680 * @param Name The string to set M's source file name to
681 * @param Len Length of Name
682 * @see Module::setSourceFileName()
684 void LLVMSetSourceFileName(LLVMModuleRef M, const char *Name, size_t Len);
687 * Obtain the data layout for a module.
689 * @see Module::getDataLayoutStr()
691 * LLVMGetDataLayout is DEPRECATED, as the name is not only incorrect,
692 * but match the name of another method on the module. Prefer the use
693 * of LLVMGetDataLayoutStr, which is not ambiguous.
695 const char *LLVMGetDataLayoutStr(LLVMModuleRef M);
696 const char *LLVMGetDataLayout(LLVMModuleRef M);
699 * Set the data layout for a module.
701 * @see Module::setDataLayout()
703 void LLVMSetDataLayout(LLVMModuleRef M, const char *DataLayoutStr);
706 * Obtain the target triple for a module.
708 * @see Module::getTargetTriple()
710 const char *LLVMGetTarget(LLVMModuleRef M);
713 * Set the target triple for a module.
715 * @see Module::setTargetTriple()
717 void LLVMSetTarget(LLVMModuleRef M, const char *Triple);
720 * Returns the module flags as an array of flag-key-value triples. The caller
721 * is responsible for freeing this array by calling
722 * \c LLVMDisposeModuleFlagsMetadata.
724 * @see Module::getModuleFlagsMetadata()
726 LLVMModuleFlagEntry *LLVMCopyModuleFlagsMetadata(LLVMModuleRef M, size_t *Len);
729 * Destroys module flags metadata entries.
731 void LLVMDisposeModuleFlagsMetadata(LLVMModuleFlagEntry *Entries);
734 * Returns the flag behavior for a module flag entry at a specific index.
736 * @see Module::ModuleFlagEntry::Behavior
738 LLVMModuleFlagBehavior
739 LLVMModuleFlagEntriesGetFlagBehavior(LLVMModuleFlagEntry *Entries,
743 * Returns the key for a module flag entry at a specific index.
745 * @see Module::ModuleFlagEntry::Key
747 const char *LLVMModuleFlagEntriesGetKey(LLVMModuleFlagEntry *Entries,
748 unsigned Index, size_t *Len);
751 * Returns the metadata for a module flag entry at a specific index.
753 * @see Module::ModuleFlagEntry::Val
755 LLVMMetadataRef LLVMModuleFlagEntriesGetMetadata(LLVMModuleFlagEntry *Entries,
759 * Add a module-level flag to the module-level flags metadata if it doesn't
762 * @see Module::getModuleFlag()
764 LLVMMetadataRef LLVMGetModuleFlag(LLVMModuleRef M,
765 const char *Key, size_t KeyLen);
768 * Add a module-level flag to the module-level flags metadata if it doesn't
771 * @see Module::addModuleFlag()
773 void LLVMAddModuleFlag(LLVMModuleRef M, LLVMModuleFlagBehavior Behavior,
774 const char *Key, size_t KeyLen,
775 LLVMMetadataRef Val);
778 * Dump a representation of a module to stderr.
780 * @see Module::dump()
782 void LLVMDumpModule(LLVMModuleRef M);
785 * Print a representation of a module to a file. The ErrorMessage needs to be
786 * disposed with LLVMDisposeMessage. Returns 0 on success, 1 otherwise.
788 * @see Module::print()
790 LLVMBool LLVMPrintModuleToFile(LLVMModuleRef M, const char *Filename,
791 char **ErrorMessage);
794 * Return a string representation of the module. Use
795 * LLVMDisposeMessage to free the string.
797 * @see Module::print()
799 char *LLVMPrintModuleToString(LLVMModuleRef M);
802 * Get inline assembly for a module.
804 * @see Module::getModuleInlineAsm()
806 const char *LLVMGetModuleInlineAsm(LLVMModuleRef M, size_t *Len);
809 * Set inline assembly for a module.
811 * @see Module::setModuleInlineAsm()
813 void LLVMSetModuleInlineAsm2(LLVMModuleRef M, const char *Asm, size_t Len);
816 * Append inline assembly to a module.
818 * @see Module::appendModuleInlineAsm()
820 void LLVMAppendModuleInlineAsm(LLVMModuleRef M, const char *Asm, size_t Len);
823 * Create the specified uniqued inline asm string.
825 * @see InlineAsm::get()
827 LLVMValueRef LLVMGetInlineAsm(LLVMTypeRef Ty,
828 char *AsmString, size_t AsmStringSize,
829 char *Constraints, size_t ConstraintsSize,
830 LLVMBool HasSideEffects, LLVMBool IsAlignStack,
831 LLVMInlineAsmDialect Dialect);
834 * Obtain the context to which this module is associated.
836 * @see Module::getContext()
838 LLVMContextRef LLVMGetModuleContext(LLVMModuleRef M);
841 * Obtain a Type from a module by its registered name.
843 LLVMTypeRef LLVMGetTypeByName(LLVMModuleRef M, const char *Name);
846 * Obtain the number of operands for named metadata in a module.
848 * @see llvm::Module::getNamedMetadata()
850 unsigned LLVMGetNamedMetadataNumOperands(LLVMModuleRef M, const char *Name);
853 * Obtain the named metadata operands for a module.
855 * The passed LLVMValueRef pointer should refer to an array of
856 * LLVMValueRef at least LLVMGetNamedMetadataNumOperands long. This
857 * array will be populated with the LLVMValueRef instances. Each
858 * instance corresponds to a llvm::MDNode.
860 * @see llvm::Module::getNamedMetadata()
861 * @see llvm::MDNode::getOperand()
863 void LLVMGetNamedMetadataOperands(LLVMModuleRef M, const char *Name,
867 * Add an operand to named metadata.
869 * @see llvm::Module::getNamedMetadata()
870 * @see llvm::MDNode::addOperand()
872 void LLVMAddNamedMetadataOperand(LLVMModuleRef M, const char *Name,
876 * Add a function to a module under a specified name.
878 * @see llvm::Function::Create()
880 LLVMValueRef LLVMAddFunction(LLVMModuleRef M, const char *Name,
881 LLVMTypeRef FunctionTy);
884 * Obtain a Function value from a Module by its name.
886 * The returned value corresponds to a llvm::Function value.
888 * @see llvm::Module::getFunction()
890 LLVMValueRef LLVMGetNamedFunction(LLVMModuleRef M, const char *Name);
893 * Obtain an iterator to the first Function in a Module.
895 * @see llvm::Module::begin()
897 LLVMValueRef LLVMGetFirstFunction(LLVMModuleRef M);
900 * Obtain an iterator to the last Function in a Module.
902 * @see llvm::Module::end()
904 LLVMValueRef LLVMGetLastFunction(LLVMModuleRef M);
907 * Advance a Function iterator to the next Function.
909 * Returns NULL if the iterator was already at the end and there are no more
912 LLVMValueRef LLVMGetNextFunction(LLVMValueRef Fn);
915 * Decrement a Function iterator to the previous Function.
917 * Returns NULL if the iterator was already at the beginning and there are
918 * no previous functions.
920 LLVMValueRef LLVMGetPreviousFunction(LLVMValueRef Fn);
922 /** Deprecated: Use LLVMSetModuleInlineAsm2 instead. */
923 void LLVMSetModuleInlineAsm(LLVMModuleRef M, const char *Asm);
930 * @defgroup LLVMCCoreType Types
932 * Types represent the type of a value.
934 * Types are associated with a context instance. The context internally
935 * deduplicates types so there is only 1 instance of a specific type
936 * alive at a time. In other words, a unique type is shared among all
937 * consumers within a context.
939 * A Type in the C API corresponds to llvm::Type.
941 * Types have the following hierarchy:
959 * Obtain the enumerated type of a Type instance.
961 * @see llvm::Type:getTypeID()
963 LLVMTypeKind LLVMGetTypeKind(LLVMTypeRef Ty);
966 * Whether the type has a known size.
968 * Things that don't have a size are abstract types, labels, and void.a
970 * @see llvm::Type::isSized()
972 LLVMBool LLVMTypeIsSized(LLVMTypeRef Ty);
975 * Obtain the context to which this type instance is associated.
977 * @see llvm::Type::getContext()
979 LLVMContextRef LLVMGetTypeContext(LLVMTypeRef Ty);
982 * Dump a representation of a type to stderr.
984 * @see llvm::Type::dump()
986 void LLVMDumpType(LLVMTypeRef Val);
989 * Return a string representation of the type. Use
990 * LLVMDisposeMessage to free the string.
992 * @see llvm::Type::print()
994 char *LLVMPrintTypeToString(LLVMTypeRef Val);
997 * @defgroup LLVMCCoreTypeInt Integer Types
999 * Functions in this section operate on integer types.
1005 * Obtain an integer type from a context with specified bit width.
1007 LLVMTypeRef LLVMInt1TypeInContext(LLVMContextRef C);
1008 LLVMTypeRef LLVMInt8TypeInContext(LLVMContextRef C);
1009 LLVMTypeRef LLVMInt16TypeInContext(LLVMContextRef C);
1010 LLVMTypeRef LLVMInt32TypeInContext(LLVMContextRef C);
1011 LLVMTypeRef LLVMInt64TypeInContext(LLVMContextRef C);
1012 LLVMTypeRef LLVMInt128TypeInContext(LLVMContextRef C);
1013 LLVMTypeRef LLVMIntTypeInContext(LLVMContextRef C, unsigned NumBits);
1016 * Obtain an integer type from the global context with a specified bit
1019 LLVMTypeRef LLVMInt1Type(void);
1020 LLVMTypeRef LLVMInt8Type(void);
1021 LLVMTypeRef LLVMInt16Type(void);
1022 LLVMTypeRef LLVMInt32Type(void);
1023 LLVMTypeRef LLVMInt64Type(void);
1024 LLVMTypeRef LLVMInt128Type(void);
1025 LLVMTypeRef LLVMIntType(unsigned NumBits);
1026 unsigned LLVMGetIntTypeWidth(LLVMTypeRef IntegerTy);
1033 * @defgroup LLVMCCoreTypeFloat Floating Point Types
1039 * Obtain a 16-bit floating point type from a context.
1041 LLVMTypeRef LLVMHalfTypeInContext(LLVMContextRef C);
1044 * Obtain a 32-bit floating point type from a context.
1046 LLVMTypeRef LLVMFloatTypeInContext(LLVMContextRef C);
1049 * Obtain a 64-bit floating point type from a context.
1051 LLVMTypeRef LLVMDoubleTypeInContext(LLVMContextRef C);
1054 * Obtain a 80-bit floating point type (X87) from a context.
1056 LLVMTypeRef LLVMX86FP80TypeInContext(LLVMContextRef C);
1059 * Obtain a 128-bit floating point type (112-bit mantissa) from a
1062 LLVMTypeRef LLVMFP128TypeInContext(LLVMContextRef C);
1065 * Obtain a 128-bit floating point type (two 64-bits) from a context.
1067 LLVMTypeRef LLVMPPCFP128TypeInContext(LLVMContextRef C);
1070 * Obtain a floating point type from the global context.
1072 * These map to the functions in this group of the same name.
1074 LLVMTypeRef LLVMHalfType(void);
1075 LLVMTypeRef LLVMFloatType(void);
1076 LLVMTypeRef LLVMDoubleType(void);
1077 LLVMTypeRef LLVMX86FP80Type(void);
1078 LLVMTypeRef LLVMFP128Type(void);
1079 LLVMTypeRef LLVMPPCFP128Type(void);
1086 * @defgroup LLVMCCoreTypeFunction Function Types
1092 * Obtain a function type consisting of a specified signature.
1094 * The function is defined as a tuple of a return Type, a list of
1095 * parameter types, and whether the function is variadic.
1097 LLVMTypeRef LLVMFunctionType(LLVMTypeRef ReturnType,
1098 LLVMTypeRef *ParamTypes, unsigned ParamCount,
1102 * Returns whether a function type is variadic.
1104 LLVMBool LLVMIsFunctionVarArg(LLVMTypeRef FunctionTy);
1107 * Obtain the Type this function Type returns.
1109 LLVMTypeRef LLVMGetReturnType(LLVMTypeRef FunctionTy);
1112 * Obtain the number of parameters this function accepts.
1114 unsigned LLVMCountParamTypes(LLVMTypeRef FunctionTy);
1117 * Obtain the types of a function's parameters.
1119 * The Dest parameter should point to a pre-allocated array of
1120 * LLVMTypeRef at least LLVMCountParamTypes() large. On return, the
1121 * first LLVMCountParamTypes() entries in the array will be populated
1122 * with LLVMTypeRef instances.
1124 * @param FunctionTy The function type to operate on.
1125 * @param Dest Memory address of an array to be filled with result.
1127 void LLVMGetParamTypes(LLVMTypeRef FunctionTy, LLVMTypeRef *Dest);
1134 * @defgroup LLVMCCoreTypeStruct Structure Types
1136 * These functions relate to LLVMTypeRef instances.
1138 * @see llvm::StructType
1144 * Create a new structure type in a context.
1146 * A structure is specified by a list of inner elements/types and
1147 * whether these can be packed together.
1149 * @see llvm::StructType::create()
1151 LLVMTypeRef LLVMStructTypeInContext(LLVMContextRef C, LLVMTypeRef *ElementTypes,
1152 unsigned ElementCount, LLVMBool Packed);
1155 * Create a new structure type in the global context.
1157 * @see llvm::StructType::create()
1159 LLVMTypeRef LLVMStructType(LLVMTypeRef *ElementTypes, unsigned ElementCount,
1163 * Create an empty structure in a context having a specified name.
1165 * @see llvm::StructType::create()
1167 LLVMTypeRef LLVMStructCreateNamed(LLVMContextRef C, const char *Name);
1170 * Obtain the name of a structure.
1172 * @see llvm::StructType::getName()
1174 const char *LLVMGetStructName(LLVMTypeRef Ty);
1177 * Set the contents of a structure type.
1179 * @see llvm::StructType::setBody()
1181 void LLVMStructSetBody(LLVMTypeRef StructTy, LLVMTypeRef *ElementTypes,
1182 unsigned ElementCount, LLVMBool Packed);
1185 * Get the number of elements defined inside the structure.
1187 * @see llvm::StructType::getNumElements()
1189 unsigned LLVMCountStructElementTypes(LLVMTypeRef StructTy);
1192 * Get the elements within a structure.
1194 * The function is passed the address of a pre-allocated array of
1195 * LLVMTypeRef at least LLVMCountStructElementTypes() long. After
1196 * invocation, this array will be populated with the structure's
1197 * elements. The objects in the destination array will have a lifetime
1198 * of the structure type itself, which is the lifetime of the context it
1201 void LLVMGetStructElementTypes(LLVMTypeRef StructTy, LLVMTypeRef *Dest);
1204 * Get the type of the element at a given index in the structure.
1206 * @see llvm::StructType::getTypeAtIndex()
1208 LLVMTypeRef LLVMStructGetTypeAtIndex(LLVMTypeRef StructTy, unsigned i);
1211 * Determine whether a structure is packed.
1213 * @see llvm::StructType::isPacked()
1215 LLVMBool LLVMIsPackedStruct(LLVMTypeRef StructTy);
1218 * Determine whether a structure is opaque.
1220 * @see llvm::StructType::isOpaque()
1222 LLVMBool LLVMIsOpaqueStruct(LLVMTypeRef StructTy);
1229 * @defgroup LLVMCCoreTypeSequential Sequential Types
1231 * Sequential types represents "arrays" of types. This is a super class
1232 * for array, vector, and pointer types.
1238 * Obtain the type of elements within a sequential type.
1240 * This works on array, vector, and pointer types.
1242 * @see llvm::SequentialType::getElementType()
1244 LLVMTypeRef LLVMGetElementType(LLVMTypeRef Ty);
1247 * Returns type's subtypes
1249 * @see llvm::Type::subtypes()
1251 void LLVMGetSubtypes(LLVMTypeRef Tp, LLVMTypeRef *Arr);
1254 * Return the number of types in the derived type.
1256 * @see llvm::Type::getNumContainedTypes()
1258 unsigned LLVMGetNumContainedTypes(LLVMTypeRef Tp);
1261 * Create a fixed size array type that refers to a specific type.
1263 * The created type will exist in the context that its element type
1266 * @see llvm::ArrayType::get()
1268 LLVMTypeRef LLVMArrayType(LLVMTypeRef ElementType, unsigned ElementCount);
1271 * Obtain the length of an array type.
1273 * This only works on types that represent arrays.
1275 * @see llvm::ArrayType::getNumElements()
1277 unsigned LLVMGetArrayLength(LLVMTypeRef ArrayTy);
1280 * Create a pointer type that points to a defined type.
1282 * The created type will exist in the context that its pointee type
1285 * @see llvm::PointerType::get()
1287 LLVMTypeRef LLVMPointerType(LLVMTypeRef ElementType, unsigned AddressSpace);
1290 * Obtain the address space of a pointer type.
1292 * This only works on types that represent pointers.
1294 * @see llvm::PointerType::getAddressSpace()
1296 unsigned LLVMGetPointerAddressSpace(LLVMTypeRef PointerTy);
1299 * Create a vector type that contains a defined type and has a specific
1300 * number of elements.
1302 * The created type will exist in the context thats its element type
1305 * @see llvm::VectorType::get()
1307 LLVMTypeRef LLVMVectorType(LLVMTypeRef ElementType, unsigned ElementCount);
1310 * Obtain the number of elements in a vector type.
1312 * This only works on types that represent vectors.
1314 * @see llvm::VectorType::getNumElements()
1316 unsigned LLVMGetVectorSize(LLVMTypeRef VectorTy);
1323 * @defgroup LLVMCCoreTypeOther Other Types
1329 * Create a void type in a context.
1331 LLVMTypeRef LLVMVoidTypeInContext(LLVMContextRef C);
1334 * Create a label type in a context.
1336 LLVMTypeRef LLVMLabelTypeInContext(LLVMContextRef C);
1339 * Create a X86 MMX type in a context.
1341 LLVMTypeRef LLVMX86MMXTypeInContext(LLVMContextRef C);
1344 * Create a token type in a context.
1346 LLVMTypeRef LLVMTokenTypeInContext(LLVMContextRef C);
1349 * Create a metadata type in a context.
1351 LLVMTypeRef LLVMMetadataTypeInContext(LLVMContextRef C);
1354 * These are similar to the above functions except they operate on the
1357 LLVMTypeRef LLVMVoidType(void);
1358 LLVMTypeRef LLVMLabelType(void);
1359 LLVMTypeRef LLVMX86MMXType(void);
1370 * @defgroup LLVMCCoreValues Values
1372 * The bulk of LLVM's object model consists of values, which comprise a very
1373 * rich type hierarchy.
1375 * LLVMValueRef essentially represents llvm::Value. There is a rich
1376 * hierarchy of classes within this type. Depending on the instance
1377 * obtained, not all APIs are available.
1379 * Callers can determine the type of an LLVMValueRef by calling the
1380 * LLVMIsA* family of functions (e.g. LLVMIsAArgument()). These
1381 * functions are defined by a macro, so it isn't obvious which are
1382 * available by looking at the Doxygen source code. Instead, look at the
1383 * source definition of LLVM_FOR_EACH_VALUE_SUBCLASS and note the list
1384 * of value names given. These value names also correspond to classes in
1385 * the llvm::Value hierarchy.
1390 #define LLVM_FOR_EACH_VALUE_SUBCLASS(macro) \
1396 macro(BlockAddress) \
1397 macro(ConstantAggregateZero) \
1398 macro(ConstantArray) \
1399 macro(ConstantDataSequential) \
1400 macro(ConstantDataArray) \
1401 macro(ConstantDataVector) \
1402 macro(ConstantExpr) \
1404 macro(ConstantInt) \
1405 macro(ConstantPointerNull) \
1406 macro(ConstantStruct) \
1407 macro(ConstantTokenNone) \
1408 macro(ConstantVector) \
1409 macro(GlobalValue) \
1410 macro(GlobalAlias) \
1411 macro(GlobalObject) \
1413 macro(GlobalVariable) \
1415 macro(Instruction) \
1416 macro(BinaryOperator) \
1418 macro(IntrinsicInst) \
1419 macro(DbgInfoIntrinsic) \
1420 macro(DbgDeclareInst) \
1421 macro(MemIntrinsic) \
1423 macro(MemMoveInst) \
1428 macro(ExtractElementInst) \
1429 macro(GetElementPtrInst) \
1430 macro(InsertElementInst) \
1431 macro(InsertValueInst) \
1432 macro(LandingPadInst) \
1435 macro(ShuffleVectorInst) \
1437 macro(TerminatorInst) \
1439 macro(IndirectBrInst) \
1443 macro(UnreachableInst) \
1445 macro(CleanupReturnInst) \
1446 macro(CatchReturnInst) \
1447 macro(FuncletPadInst) \
1448 macro(CatchPadInst) \
1449 macro(CleanupPadInst) \
1450 macro(UnaryInstruction) \
1453 macro(AddrSpaceCastInst) \
1454 macro(BitCastInst) \
1458 macro(FPTruncInst) \
1459 macro(IntToPtrInst) \
1460 macro(PtrToIntInst) \
1466 macro(ExtractValueInst) \
1471 * @defgroup LLVMCCoreValueGeneral General APIs
1473 * Functions in this section work on all LLVMValueRef instances,
1474 * regardless of their sub-type. They correspond to functions available
1481 * Obtain the type of a value.
1483 * @see llvm::Value::getType()
1485 LLVMTypeRef LLVMTypeOf(LLVMValueRef Val);
1488 * Obtain the enumerated type of a Value instance.
1490 * @see llvm::Value::getValueID()
1492 LLVMValueKind LLVMGetValueKind(LLVMValueRef Val);
1495 * Obtain the string name of a value.
1497 * @see llvm::Value::getName()
1499 const char *LLVMGetValueName2(LLVMValueRef Val, size_t *Length);
1502 * Set the string name of a value.
1504 * @see llvm::Value::setName()
1506 void LLVMSetValueName2(LLVMValueRef Val, const char *Name, size_t NameLen);
1509 * Dump a representation of a value to stderr.
1511 * @see llvm::Value::dump()
1513 void LLVMDumpValue(LLVMValueRef Val);
1516 * Return a string representation of the value. Use
1517 * LLVMDisposeMessage to free the string.
1519 * @see llvm::Value::print()
1521 char *LLVMPrintValueToString(LLVMValueRef Val);
1524 * Replace all uses of a value with another one.
1526 * @see llvm::Value::replaceAllUsesWith()
1528 void LLVMReplaceAllUsesWith(LLVMValueRef OldVal, LLVMValueRef NewVal);
1531 * Determine whether the specified value instance is constant.
1533 LLVMBool LLVMIsConstant(LLVMValueRef Val);
1536 * Determine whether a value instance is undefined.
1538 LLVMBool LLVMIsUndef(LLVMValueRef Val);
1541 * Convert value instances between types.
1543 * Internally, an LLVMValueRef is "pinned" to a specific type. This
1544 * series of functions allows you to cast an instance to a specific
1547 * If the cast is not valid for the specified type, NULL is returned.
1549 * @see llvm::dyn_cast_or_null<>
1551 #define LLVM_DECLARE_VALUE_CAST(name) \
1552 LLVMValueRef LLVMIsA##name(LLVMValueRef Val);
1553 LLVM_FOR_EACH_VALUE_SUBCLASS(LLVM_DECLARE_VALUE_CAST)
1555 LLVMValueRef LLVMIsAMDNode(LLVMValueRef Val);
1556 LLVMValueRef LLVMIsAMDString(LLVMValueRef Val);
1558 /** Deprecated: Use LLVMGetValueName2 instead. */
1559 const char *LLVMGetValueName(LLVMValueRef Val);
1560 /** Deprecated: Use LLVMSetValueName2 instead. */
1561 void LLVMSetValueName(LLVMValueRef Val, const char *Name);
1568 * @defgroup LLVMCCoreValueUses Usage
1570 * This module defines functions that allow you to inspect the uses of a
1573 * It is possible to obtain an LLVMUseRef for any LLVMValueRef instance.
1574 * Each LLVMUseRef (which corresponds to a llvm::Use instance) holds a
1575 * llvm::User and llvm::Value.
1581 * Obtain the first use of a value.
1583 * Uses are obtained in an iterator fashion. First, call this function
1584 * to obtain a reference to the first use. Then, call LLVMGetNextUse()
1585 * on that instance and all subsequently obtained instances until
1586 * LLVMGetNextUse() returns NULL.
1588 * @see llvm::Value::use_begin()
1590 LLVMUseRef LLVMGetFirstUse(LLVMValueRef Val);
1593 * Obtain the next use of a value.
1595 * This effectively advances the iterator. It returns NULL if you are on
1596 * the final use and no more are available.
1598 LLVMUseRef LLVMGetNextUse(LLVMUseRef U);
1601 * Obtain the user value for a user.
1603 * The returned value corresponds to a llvm::User type.
1605 * @see llvm::Use::getUser()
1607 LLVMValueRef LLVMGetUser(LLVMUseRef U);
1610 * Obtain the value this use corresponds to.
1612 * @see llvm::Use::get().
1614 LLVMValueRef LLVMGetUsedValue(LLVMUseRef U);
1621 * @defgroup LLVMCCoreValueUser User value
1623 * Function in this group pertain to LLVMValueRef instances that descent
1624 * from llvm::User. This includes constants, instructions, and
1631 * Obtain an operand at a specific index in a llvm::User value.
1633 * @see llvm::User::getOperand()
1635 LLVMValueRef LLVMGetOperand(LLVMValueRef Val, unsigned Index);
1638 * Obtain the use of an operand at a specific index in a llvm::User value.
1640 * @see llvm::User::getOperandUse()
1642 LLVMUseRef LLVMGetOperandUse(LLVMValueRef Val, unsigned Index);
1645 * Set an operand at a specific index in a llvm::User value.
1647 * @see llvm::User::setOperand()
1649 void LLVMSetOperand(LLVMValueRef User, unsigned Index, LLVMValueRef Val);
1652 * Obtain the number of operands in a llvm::User value.
1654 * @see llvm::User::getNumOperands()
1656 int LLVMGetNumOperands(LLVMValueRef Val);
1663 * @defgroup LLVMCCoreValueConstant Constants
1665 * This section contains APIs for interacting with LLVMValueRef that
1666 * correspond to llvm::Constant instances.
1668 * These functions will work for any LLVMValueRef in the llvm::Constant
1675 * Obtain a constant value referring to the null instance of a type.
1677 * @see llvm::Constant::getNullValue()
1679 LLVMValueRef LLVMConstNull(LLVMTypeRef Ty); /* all zeroes */
1682 * Obtain a constant value referring to the instance of a type
1683 * consisting of all ones.
1685 * This is only valid for integer types.
1687 * @see llvm::Constant::getAllOnesValue()
1689 LLVMValueRef LLVMConstAllOnes(LLVMTypeRef Ty);
1692 * Obtain a constant value referring to an undefined value of a type.
1694 * @see llvm::UndefValue::get()
1696 LLVMValueRef LLVMGetUndef(LLVMTypeRef Ty);
1699 * Determine whether a value instance is null.
1701 * @see llvm::Constant::isNullValue()
1703 LLVMBool LLVMIsNull(LLVMValueRef Val);
1706 * Obtain a constant that is a constant pointer pointing to NULL for a
1709 LLVMValueRef LLVMConstPointerNull(LLVMTypeRef Ty);
1712 * @defgroup LLVMCCoreValueConstantScalar Scalar constants
1714 * Functions in this group model LLVMValueRef instances that correspond
1715 * to constants referring to scalar types.
1717 * For integer types, the LLVMTypeRef parameter should correspond to a
1718 * llvm::IntegerType instance and the returned LLVMValueRef will
1719 * correspond to a llvm::ConstantInt.
1721 * For floating point types, the LLVMTypeRef returned corresponds to a
1728 * Obtain a constant value for an integer type.
1730 * The returned value corresponds to a llvm::ConstantInt.
1732 * @see llvm::ConstantInt::get()
1734 * @param IntTy Integer type to obtain value of.
1735 * @param N The value the returned instance should refer to.
1736 * @param SignExtend Whether to sign extend the produced value.
1738 LLVMValueRef LLVMConstInt(LLVMTypeRef IntTy, unsigned long long N,
1739 LLVMBool SignExtend);
1742 * Obtain a constant value for an integer of arbitrary precision.
1744 * @see llvm::ConstantInt::get()
1746 LLVMValueRef LLVMConstIntOfArbitraryPrecision(LLVMTypeRef IntTy,
1748 const uint64_t Words[]);
1751 * Obtain a constant value for an integer parsed from a string.
1753 * A similar API, LLVMConstIntOfStringAndSize is also available. If the
1754 * string's length is available, it is preferred to call that function
1757 * @see llvm::ConstantInt::get()
1759 LLVMValueRef LLVMConstIntOfString(LLVMTypeRef IntTy, const char *Text,
1763 * Obtain a constant value for an integer parsed from a string with
1766 * @see llvm::ConstantInt::get()
1768 LLVMValueRef LLVMConstIntOfStringAndSize(LLVMTypeRef IntTy, const char *Text,
1769 unsigned SLen, uint8_t Radix);
1772 * Obtain a constant value referring to a double floating point value.
1774 LLVMValueRef LLVMConstReal(LLVMTypeRef RealTy, double N);
1777 * Obtain a constant for a floating point value parsed from a string.
1779 * A similar API, LLVMConstRealOfStringAndSize is also available. It
1780 * should be used if the input string's length is known.
1782 LLVMValueRef LLVMConstRealOfString(LLVMTypeRef RealTy, const char *Text);
1785 * Obtain a constant for a floating point value parsed from a string.
1787 LLVMValueRef LLVMConstRealOfStringAndSize(LLVMTypeRef RealTy, const char *Text,
1791 * Obtain the zero extended value for an integer constant value.
1793 * @see llvm::ConstantInt::getZExtValue()
1795 unsigned long long LLVMConstIntGetZExtValue(LLVMValueRef ConstantVal);
1798 * Obtain the sign extended value for an integer constant value.
1800 * @see llvm::ConstantInt::getSExtValue()
1802 long long LLVMConstIntGetSExtValue(LLVMValueRef ConstantVal);
1805 * Obtain the double value for an floating point constant value.
1806 * losesInfo indicates if some precision was lost in the conversion.
1808 * @see llvm::ConstantFP::getDoubleValue
1810 double LLVMConstRealGetDouble(LLVMValueRef ConstantVal, LLVMBool *losesInfo);
1817 * @defgroup LLVMCCoreValueConstantComposite Composite Constants
1819 * Functions in this group operate on composite constants.
1825 * Create a ConstantDataSequential and initialize it with a string.
1827 * @see llvm::ConstantDataArray::getString()
1829 LLVMValueRef LLVMConstStringInContext(LLVMContextRef C, const char *Str,
1830 unsigned Length, LLVMBool DontNullTerminate);
1833 * Create a ConstantDataSequential with string content in the global context.
1835 * This is the same as LLVMConstStringInContext except it operates on the
1838 * @see LLVMConstStringInContext()
1839 * @see llvm::ConstantDataArray::getString()
1841 LLVMValueRef LLVMConstString(const char *Str, unsigned Length,
1842 LLVMBool DontNullTerminate);
1845 * Returns true if the specified constant is an array of i8.
1847 * @see ConstantDataSequential::getAsString()
1849 LLVMBool LLVMIsConstantString(LLVMValueRef c);
1852 * Get the given constant data sequential as a string.
1854 * @see ConstantDataSequential::getAsString()
1856 const char *LLVMGetAsString(LLVMValueRef c, size_t *Length);
1859 * Create an anonymous ConstantStruct with the specified values.
1861 * @see llvm::ConstantStruct::getAnon()
1863 LLVMValueRef LLVMConstStructInContext(LLVMContextRef C,
1864 LLVMValueRef *ConstantVals,
1865 unsigned Count, LLVMBool Packed);
1868 * Create a ConstantStruct in the global Context.
1870 * This is the same as LLVMConstStructInContext except it operates on the
1873 * @see LLVMConstStructInContext()
1875 LLVMValueRef LLVMConstStruct(LLVMValueRef *ConstantVals, unsigned Count,
1879 * Create a ConstantArray from values.
1881 * @see llvm::ConstantArray::get()
1883 LLVMValueRef LLVMConstArray(LLVMTypeRef ElementTy,
1884 LLVMValueRef *ConstantVals, unsigned Length);
1887 * Create a non-anonymous ConstantStruct from values.
1889 * @see llvm::ConstantStruct::get()
1891 LLVMValueRef LLVMConstNamedStruct(LLVMTypeRef StructTy,
1892 LLVMValueRef *ConstantVals,
1896 * Get an element at specified index as a constant.
1898 * @see ConstantDataSequential::getElementAsConstant()
1900 LLVMValueRef LLVMGetElementAsConstant(LLVMValueRef C, unsigned idx);
1903 * Create a ConstantVector from values.
1905 * @see llvm::ConstantVector::get()
1907 LLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals, unsigned Size);
1914 * @defgroup LLVMCCoreValueConstantExpressions Constant Expressions
1916 * Functions in this group correspond to APIs on llvm::ConstantExpr.
1918 * @see llvm::ConstantExpr.
1922 LLVMOpcode LLVMGetConstOpcode(LLVMValueRef ConstantVal);
1923 LLVMValueRef LLVMAlignOf(LLVMTypeRef Ty);
1924 LLVMValueRef LLVMSizeOf(LLVMTypeRef Ty);
1925 LLVMValueRef LLVMConstNeg(LLVMValueRef ConstantVal);
1926 LLVMValueRef LLVMConstNSWNeg(LLVMValueRef ConstantVal);
1927 LLVMValueRef LLVMConstNUWNeg(LLVMValueRef ConstantVal);
1928 LLVMValueRef LLVMConstFNeg(LLVMValueRef ConstantVal);
1929 LLVMValueRef LLVMConstNot(LLVMValueRef ConstantVal);
1930 LLVMValueRef LLVMConstAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1931 LLVMValueRef LLVMConstNSWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1932 LLVMValueRef LLVMConstNUWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1933 LLVMValueRef LLVMConstFAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1934 LLVMValueRef LLVMConstSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1935 LLVMValueRef LLVMConstNSWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1936 LLVMValueRef LLVMConstNUWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1937 LLVMValueRef LLVMConstFSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1938 LLVMValueRef LLVMConstMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1939 LLVMValueRef LLVMConstNSWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1940 LLVMValueRef LLVMConstNUWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1941 LLVMValueRef LLVMConstFMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1942 LLVMValueRef LLVMConstUDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1943 LLVMValueRef LLVMConstExactUDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1944 LLVMValueRef LLVMConstSDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1945 LLVMValueRef LLVMConstExactSDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1946 LLVMValueRef LLVMConstFDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1947 LLVMValueRef LLVMConstURem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1948 LLVMValueRef LLVMConstSRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1949 LLVMValueRef LLVMConstFRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1950 LLVMValueRef LLVMConstAnd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1951 LLVMValueRef LLVMConstOr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1952 LLVMValueRef LLVMConstXor(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1953 LLVMValueRef LLVMConstICmp(LLVMIntPredicate Predicate,
1954 LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1955 LLVMValueRef LLVMConstFCmp(LLVMRealPredicate Predicate,
1956 LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1957 LLVMValueRef LLVMConstShl(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1958 LLVMValueRef LLVMConstLShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1959 LLVMValueRef LLVMConstAShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1960 LLVMValueRef LLVMConstGEP(LLVMValueRef ConstantVal,
1961 LLVMValueRef *ConstantIndices, unsigned NumIndices);
1962 LLVMValueRef LLVMConstInBoundsGEP(LLVMValueRef ConstantVal,
1963 LLVMValueRef *ConstantIndices,
1964 unsigned NumIndices);
1965 LLVMValueRef LLVMConstTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1966 LLVMValueRef LLVMConstSExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1967 LLVMValueRef LLVMConstZExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1968 LLVMValueRef LLVMConstFPTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1969 LLVMValueRef LLVMConstFPExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1970 LLVMValueRef LLVMConstUIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1971 LLVMValueRef LLVMConstSIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1972 LLVMValueRef LLVMConstFPToUI(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1973 LLVMValueRef LLVMConstFPToSI(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1974 LLVMValueRef LLVMConstPtrToInt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1975 LLVMValueRef LLVMConstIntToPtr(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1976 LLVMValueRef LLVMConstBitCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1977 LLVMValueRef LLVMConstAddrSpaceCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1978 LLVMValueRef LLVMConstZExtOrBitCast(LLVMValueRef ConstantVal,
1979 LLVMTypeRef ToType);
1980 LLVMValueRef LLVMConstSExtOrBitCast(LLVMValueRef ConstantVal,
1981 LLVMTypeRef ToType);
1982 LLVMValueRef LLVMConstTruncOrBitCast(LLVMValueRef ConstantVal,
1983 LLVMTypeRef ToType);
1984 LLVMValueRef LLVMConstPointerCast(LLVMValueRef ConstantVal,
1985 LLVMTypeRef ToType);
1986 LLVMValueRef LLVMConstIntCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType,
1988 LLVMValueRef LLVMConstFPCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1989 LLVMValueRef LLVMConstSelect(LLVMValueRef ConstantCondition,
1990 LLVMValueRef ConstantIfTrue,
1991 LLVMValueRef ConstantIfFalse);
1992 LLVMValueRef LLVMConstExtractElement(LLVMValueRef VectorConstant,
1993 LLVMValueRef IndexConstant);
1994 LLVMValueRef LLVMConstInsertElement(LLVMValueRef VectorConstant,
1995 LLVMValueRef ElementValueConstant,
1996 LLVMValueRef IndexConstant);
1997 LLVMValueRef LLVMConstShuffleVector(LLVMValueRef VectorAConstant,
1998 LLVMValueRef VectorBConstant,
1999 LLVMValueRef MaskConstant);
2000 LLVMValueRef LLVMConstExtractValue(LLVMValueRef AggConstant, unsigned *IdxList,
2002 LLVMValueRef LLVMConstInsertValue(LLVMValueRef AggConstant,
2003 LLVMValueRef ElementValueConstant,
2004 unsigned *IdxList, unsigned NumIdx);
2005 LLVMValueRef LLVMBlockAddress(LLVMValueRef F, LLVMBasicBlockRef BB);
2007 /** Deprecated: Use LLVMGetInlineAsm instead. */
2008 LLVMValueRef LLVMConstInlineAsm(LLVMTypeRef Ty,
2009 const char *AsmString, const char *Constraints,
2010 LLVMBool HasSideEffects, LLVMBool IsAlignStack);
2017 * @defgroup LLVMCCoreValueConstantGlobals Global Values
2019 * This group contains functions that operate on global values. Functions in
2020 * this group relate to functions in the llvm::GlobalValue class tree.
2022 * @see llvm::GlobalValue
2027 LLVMModuleRef LLVMGetGlobalParent(LLVMValueRef Global);
2028 LLVMBool LLVMIsDeclaration(LLVMValueRef Global);
2029 LLVMLinkage LLVMGetLinkage(LLVMValueRef Global);
2030 void LLVMSetLinkage(LLVMValueRef Global, LLVMLinkage Linkage);
2031 const char *LLVMGetSection(LLVMValueRef Global);
2032 void LLVMSetSection(LLVMValueRef Global, const char *Section);
2033 LLVMVisibility LLVMGetVisibility(LLVMValueRef Global);
2034 void LLVMSetVisibility(LLVMValueRef Global, LLVMVisibility Viz);
2035 LLVMDLLStorageClass LLVMGetDLLStorageClass(LLVMValueRef Global);
2036 void LLVMSetDLLStorageClass(LLVMValueRef Global, LLVMDLLStorageClass Class);
2037 LLVMUnnamedAddr LLVMGetUnnamedAddress(LLVMValueRef Global);
2038 void LLVMSetUnnamedAddress(LLVMValueRef Global, LLVMUnnamedAddr UnnamedAddr);
2040 /** Deprecated: Use LLVMGetUnnamedAddress instead. */
2041 LLVMBool LLVMHasUnnamedAddr(LLVMValueRef Global);
2042 /** Deprecated: Use LLVMSetUnnamedAddress instead. */
2043 void LLVMSetUnnamedAddr(LLVMValueRef Global, LLVMBool HasUnnamedAddr);
2046 * @defgroup LLVMCCoreValueWithAlignment Values with alignment
2048 * Functions in this group only apply to values with alignment, i.e.
2049 * global variables, load and store instructions.
2053 * Obtain the preferred alignment of the value.
2054 * @see llvm::AllocaInst::getAlignment()
2055 * @see llvm::LoadInst::getAlignment()
2056 * @see llvm::StoreInst::getAlignment()
2057 * @see llvm::GlobalValue::getAlignment()
2059 unsigned LLVMGetAlignment(LLVMValueRef V);
2062 * Set the preferred alignment of the value.
2063 * @see llvm::AllocaInst::setAlignment()
2064 * @see llvm::LoadInst::setAlignment()
2065 * @see llvm::StoreInst::setAlignment()
2066 * @see llvm::GlobalValue::setAlignment()
2068 void LLVMSetAlignment(LLVMValueRef V, unsigned Bytes);
2075 * @defgroup LLVMCoreValueConstantGlobalVariable Global Variables
2077 * This group contains functions that operate on global variable values.
2079 * @see llvm::GlobalVariable
2083 LLVMValueRef LLVMAddGlobal(LLVMModuleRef M, LLVMTypeRef Ty, const char *Name);
2084 LLVMValueRef LLVMAddGlobalInAddressSpace(LLVMModuleRef M, LLVMTypeRef Ty,
2086 unsigned AddressSpace);
2087 LLVMValueRef LLVMGetNamedGlobal(LLVMModuleRef M, const char *Name);
2088 LLVMValueRef LLVMGetFirstGlobal(LLVMModuleRef M);
2089 LLVMValueRef LLVMGetLastGlobal(LLVMModuleRef M);
2090 LLVMValueRef LLVMGetNextGlobal(LLVMValueRef GlobalVar);
2091 LLVMValueRef LLVMGetPreviousGlobal(LLVMValueRef GlobalVar);
2092 void LLVMDeleteGlobal(LLVMValueRef GlobalVar);
2093 LLVMValueRef LLVMGetInitializer(LLVMValueRef GlobalVar);
2094 void LLVMSetInitializer(LLVMValueRef GlobalVar, LLVMValueRef ConstantVal);
2095 LLVMBool LLVMIsThreadLocal(LLVMValueRef GlobalVar);
2096 void LLVMSetThreadLocal(LLVMValueRef GlobalVar, LLVMBool IsThreadLocal);
2097 LLVMBool LLVMIsGlobalConstant(LLVMValueRef GlobalVar);
2098 void LLVMSetGlobalConstant(LLVMValueRef GlobalVar, LLVMBool IsConstant);
2099 LLVMThreadLocalMode LLVMGetThreadLocalMode(LLVMValueRef GlobalVar);
2100 void LLVMSetThreadLocalMode(LLVMValueRef GlobalVar, LLVMThreadLocalMode Mode);
2101 LLVMBool LLVMIsExternallyInitialized(LLVMValueRef GlobalVar);
2102 void LLVMSetExternallyInitialized(LLVMValueRef GlobalVar, LLVMBool IsExtInit);
2109 * @defgroup LLVMCoreValueConstantGlobalAlias Global Aliases
2111 * This group contains function that operate on global alias values.
2113 * @see llvm::GlobalAlias
2117 LLVMValueRef LLVMAddAlias(LLVMModuleRef M, LLVMTypeRef Ty, LLVMValueRef Aliasee,
2121 * Obtain a GlobalAlias value from a Module by its name.
2123 * The returned value corresponds to a llvm::GlobalAlias value.
2125 * @see llvm::Module::getNamedAlias()
2127 LLVMValueRef LLVMGetNamedGlobalAlias(LLVMModuleRef M,
2128 const char *Name, size_t NameLen);
2131 * Obtain an iterator to the first GlobalAlias in a Module.
2133 * @see llvm::Module::alias_begin()
2135 LLVMValueRef LLVMGetFirstGlobalAlias(LLVMModuleRef M);
2138 * Obtain an iterator to the last GlobalAlias in a Module.
2140 * @see llvm::Module::alias_end()
2142 LLVMValueRef LLVMGetLastGlobalAlias(LLVMModuleRef M);
2145 * Advance a GlobalAlias iterator to the next GlobalAlias.
2147 * Returns NULL if the iterator was already at the end and there are no more
2150 LLVMValueRef LLVMGetNextGlobalAlias(LLVMValueRef GA);
2153 * Decrement a GlobalAlias iterator to the previous GlobalAlias.
2155 * Returns NULL if the iterator was already at the beginning and there are
2156 * no previous global aliases.
2158 LLVMValueRef LLVMGetPreviousGlobalAlias(LLVMValueRef GA);
2161 * Retrieve the target value of an alias.
2163 LLVMValueRef LLVMAliasGetAliasee(LLVMValueRef Alias);
2166 * Set the target value of an alias.
2168 void LLVMAliasSetAliasee(LLVMValueRef Alias, LLVMValueRef Aliasee);
2175 * @defgroup LLVMCCoreValueFunction Function values
2177 * Functions in this group operate on LLVMValueRef instances that
2178 * correspond to llvm::Function instances.
2180 * @see llvm::Function
2186 * Remove a function from its containing module and deletes it.
2188 * @see llvm::Function::eraseFromParent()
2190 void LLVMDeleteFunction(LLVMValueRef Fn);
2193 * Check whether the given function has a personality function.
2195 * @see llvm::Function::hasPersonalityFn()
2197 LLVMBool LLVMHasPersonalityFn(LLVMValueRef Fn);
2200 * Obtain the personality function attached to the function.
2202 * @see llvm::Function::getPersonalityFn()
2204 LLVMValueRef LLVMGetPersonalityFn(LLVMValueRef Fn);
2207 * Set the personality function attached to the function.
2209 * @see llvm::Function::setPersonalityFn()
2211 void LLVMSetPersonalityFn(LLVMValueRef Fn, LLVMValueRef PersonalityFn);
2214 * Obtain the ID number from a function instance.
2216 * @see llvm::Function::getIntrinsicID()
2218 unsigned LLVMGetIntrinsicID(LLVMValueRef Fn);
2221 * Obtain the calling function of a function.
2223 * The returned value corresponds to the LLVMCallConv enumeration.
2225 * @see llvm::Function::getCallingConv()
2227 unsigned LLVMGetFunctionCallConv(LLVMValueRef Fn);
2230 * Set the calling convention of a function.
2232 * @see llvm::Function::setCallingConv()
2234 * @param Fn Function to operate on
2235 * @param CC LLVMCallConv to set calling convention to
2237 void LLVMSetFunctionCallConv(LLVMValueRef Fn, unsigned CC);
2240 * Obtain the name of the garbage collector to use during code
2243 * @see llvm::Function::getGC()
2245 const char *LLVMGetGC(LLVMValueRef Fn);
2248 * Define the garbage collector to use during code generation.
2250 * @see llvm::Function::setGC()
2252 void LLVMSetGC(LLVMValueRef Fn, const char *Name);
2255 * Add an attribute to a function.
2257 * @see llvm::Function::addAttribute()
2259 void LLVMAddAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx,
2260 LLVMAttributeRef A);
2261 unsigned LLVMGetAttributeCountAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx);
2262 void LLVMGetAttributesAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx,
2263 LLVMAttributeRef *Attrs);
2264 LLVMAttributeRef LLVMGetEnumAttributeAtIndex(LLVMValueRef F,
2265 LLVMAttributeIndex Idx,
2267 LLVMAttributeRef LLVMGetStringAttributeAtIndex(LLVMValueRef F,
2268 LLVMAttributeIndex Idx,
2269 const char *K, unsigned KLen);
2270 void LLVMRemoveEnumAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx,
2272 void LLVMRemoveStringAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx,
2273 const char *K, unsigned KLen);
2276 * Add a target-dependent attribute to a function
2277 * @see llvm::AttrBuilder::addAttribute()
2279 void LLVMAddTargetDependentFunctionAttr(LLVMValueRef Fn, const char *A,
2283 * @defgroup LLVMCCoreValueFunctionParameters Function Parameters
2285 * Functions in this group relate to arguments/parameters on functions.
2287 * Functions in this group expect LLVMValueRef instances that correspond
2288 * to llvm::Function instances.
2294 * Obtain the number of parameters in a function.
2296 * @see llvm::Function::arg_size()
2298 unsigned LLVMCountParams(LLVMValueRef Fn);
2301 * Obtain the parameters in a function.
2303 * The takes a pointer to a pre-allocated array of LLVMValueRef that is
2304 * at least LLVMCountParams() long. This array will be filled with
2305 * LLVMValueRef instances which correspond to the parameters the
2306 * function receives. Each LLVMValueRef corresponds to a llvm::Argument
2309 * @see llvm::Function::arg_begin()
2311 void LLVMGetParams(LLVMValueRef Fn, LLVMValueRef *Params);
2314 * Obtain the parameter at the specified index.
2316 * Parameters are indexed from 0.
2318 * @see llvm::Function::arg_begin()
2320 LLVMValueRef LLVMGetParam(LLVMValueRef Fn, unsigned Index);
2323 * Obtain the function to which this argument belongs.
2325 * Unlike other functions in this group, this one takes an LLVMValueRef
2326 * that corresponds to a llvm::Attribute.
2328 * The returned LLVMValueRef is the llvm::Function to which this
2331 LLVMValueRef LLVMGetParamParent(LLVMValueRef Inst);
2334 * Obtain the first parameter to a function.
2336 * @see llvm::Function::arg_begin()
2338 LLVMValueRef LLVMGetFirstParam(LLVMValueRef Fn);
2341 * Obtain the last parameter to a function.
2343 * @see llvm::Function::arg_end()
2345 LLVMValueRef LLVMGetLastParam(LLVMValueRef Fn);
2348 * Obtain the next parameter to a function.
2350 * This takes an LLVMValueRef obtained from LLVMGetFirstParam() (which is
2351 * actually a wrapped iterator) and obtains the next parameter from the
2352 * underlying iterator.
2354 LLVMValueRef LLVMGetNextParam(LLVMValueRef Arg);
2357 * Obtain the previous parameter to a function.
2359 * This is the opposite of LLVMGetNextParam().
2361 LLVMValueRef LLVMGetPreviousParam(LLVMValueRef Arg);
2364 * Set the alignment for a function parameter.
2366 * @see llvm::Argument::addAttr()
2367 * @see llvm::AttrBuilder::addAlignmentAttr()
2369 void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned Align);
2388 * @defgroup LLVMCCoreValueMetadata Metadata
2394 * Obtain a MDString value from a context.
2396 * The returned instance corresponds to the llvm::MDString class.
2398 * The instance is specified by string data of a specified length. The
2399 * string content is copied, so the backing memory can be freed after
2400 * this function returns.
2402 LLVMValueRef LLVMMDStringInContext(LLVMContextRef C, const char *Str,
2406 * Obtain a MDString value from the global context.
2408 LLVMValueRef LLVMMDString(const char *Str, unsigned SLen);
2411 * Obtain a MDNode value from a context.
2413 * The returned value corresponds to the llvm::MDNode class.
2415 LLVMValueRef LLVMMDNodeInContext(LLVMContextRef C, LLVMValueRef *Vals,
2419 * Obtain a MDNode value from the global context.
2421 LLVMValueRef LLVMMDNode(LLVMValueRef *Vals, unsigned Count);
2424 * Obtain a Metadata as a Value.
2426 LLVMValueRef LLVMMetadataAsValue(LLVMContextRef C, LLVMMetadataRef MD);
2429 * Obtain a Value as a Metadata.
2431 LLVMMetadataRef LLVMValueAsMetadata(LLVMValueRef Val);
2434 * Obtain the underlying string from a MDString value.
2436 * @param V Instance to obtain string from.
2437 * @param Length Memory address which will hold length of returned string.
2438 * @return String data in MDString.
2440 const char *LLVMGetMDString(LLVMValueRef V, unsigned *Length);
2443 * Obtain the number of operands from an MDNode value.
2445 * @param V MDNode to get number of operands from.
2446 * @return Number of operands of the MDNode.
2448 unsigned LLVMGetMDNodeNumOperands(LLVMValueRef V);
2451 * Obtain the given MDNode's operands.
2453 * The passed LLVMValueRef pointer should point to enough memory to hold all of
2454 * the operands of the given MDNode (see LLVMGetMDNodeNumOperands) as
2455 * LLVMValueRefs. This memory will be populated with the LLVMValueRefs of the
2456 * MDNode's operands.
2458 * @param V MDNode to get the operands from.
2459 * @param Dest Destination array for operands.
2461 void LLVMGetMDNodeOperands(LLVMValueRef V, LLVMValueRef *Dest);
2468 * @defgroup LLVMCCoreValueBasicBlock Basic Block
2470 * A basic block represents a single entry single exit section of code.
2471 * Basic blocks contain a list of instructions which form the body of
2474 * Basic blocks belong to functions. They have the type of label.
2476 * Basic blocks are themselves values. However, the C API models them as
2477 * LLVMBasicBlockRef.
2479 * @see llvm::BasicBlock
2485 * Convert a basic block instance to a value type.
2487 LLVMValueRef LLVMBasicBlockAsValue(LLVMBasicBlockRef BB);
2490 * Determine whether an LLVMValueRef is itself a basic block.
2492 LLVMBool LLVMValueIsBasicBlock(LLVMValueRef Val);
2495 * Convert an LLVMValueRef to an LLVMBasicBlockRef instance.
2497 LLVMBasicBlockRef LLVMValueAsBasicBlock(LLVMValueRef Val);
2500 * Obtain the string name of a basic block.
2502 const char *LLVMGetBasicBlockName(LLVMBasicBlockRef BB);
2505 * Obtain the function to which a basic block belongs.
2507 * @see llvm::BasicBlock::getParent()
2509 LLVMValueRef LLVMGetBasicBlockParent(LLVMBasicBlockRef BB);
2512 * Obtain the terminator instruction for a basic block.
2514 * If the basic block does not have a terminator (it is not well-formed
2515 * if it doesn't), then NULL is returned.
2517 * The returned LLVMValueRef corresponds to a llvm::TerminatorInst.
2519 * @see llvm::BasicBlock::getTerminator()
2521 LLVMValueRef LLVMGetBasicBlockTerminator(LLVMBasicBlockRef BB);
2524 * Obtain the number of basic blocks in a function.
2526 * @param Fn Function value to operate on.
2528 unsigned LLVMCountBasicBlocks(LLVMValueRef Fn);
2531 * Obtain all of the basic blocks in a function.
2533 * This operates on a function value. The BasicBlocks parameter is a
2534 * pointer to a pre-allocated array of LLVMBasicBlockRef of at least
2535 * LLVMCountBasicBlocks() in length. This array is populated with
2536 * LLVMBasicBlockRef instances.
2538 void LLVMGetBasicBlocks(LLVMValueRef Fn, LLVMBasicBlockRef *BasicBlocks);
2541 * Obtain the first basic block in a function.
2543 * The returned basic block can be used as an iterator. You will likely
2544 * eventually call into LLVMGetNextBasicBlock() with it.
2546 * @see llvm::Function::begin()
2548 LLVMBasicBlockRef LLVMGetFirstBasicBlock(LLVMValueRef Fn);
2551 * Obtain the last basic block in a function.
2553 * @see llvm::Function::end()
2555 LLVMBasicBlockRef LLVMGetLastBasicBlock(LLVMValueRef Fn);
2558 * Advance a basic block iterator.
2560 LLVMBasicBlockRef LLVMGetNextBasicBlock(LLVMBasicBlockRef BB);
2563 * Go backwards in a basic block iterator.
2565 LLVMBasicBlockRef LLVMGetPreviousBasicBlock(LLVMBasicBlockRef BB);
2568 * Obtain the basic block that corresponds to the entry point of a
2571 * @see llvm::Function::getEntryBlock()
2573 LLVMBasicBlockRef LLVMGetEntryBasicBlock(LLVMValueRef Fn);
2576 * Append a basic block to the end of a function.
2578 * @see llvm::BasicBlock::Create()
2580 LLVMBasicBlockRef LLVMAppendBasicBlockInContext(LLVMContextRef C,
2585 * Append a basic block to the end of a function using the global
2588 * @see llvm::BasicBlock::Create()
2590 LLVMBasicBlockRef LLVMAppendBasicBlock(LLVMValueRef Fn, const char *Name);
2593 * Insert a basic block in a function before another basic block.
2595 * The function to add to is determined by the function of the
2596 * passed basic block.
2598 * @see llvm::BasicBlock::Create()
2600 LLVMBasicBlockRef LLVMInsertBasicBlockInContext(LLVMContextRef C,
2601 LLVMBasicBlockRef BB,
2605 * Insert a basic block in a function using the global context.
2607 * @see llvm::BasicBlock::Create()
2609 LLVMBasicBlockRef LLVMInsertBasicBlock(LLVMBasicBlockRef InsertBeforeBB,
2613 * Remove a basic block from a function and delete it.
2615 * This deletes the basic block from its containing function and deletes
2616 * the basic block itself.
2618 * @see llvm::BasicBlock::eraseFromParent()
2620 void LLVMDeleteBasicBlock(LLVMBasicBlockRef BB);
2623 * Remove a basic block from a function.
2625 * This deletes the basic block from its containing function but keep
2626 * the basic block alive.
2628 * @see llvm::BasicBlock::removeFromParent()
2630 void LLVMRemoveBasicBlockFromParent(LLVMBasicBlockRef BB);
2633 * Move a basic block to before another one.
2635 * @see llvm::BasicBlock::moveBefore()
2637 void LLVMMoveBasicBlockBefore(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos);
2640 * Move a basic block to after another one.
2642 * @see llvm::BasicBlock::moveAfter()
2644 void LLVMMoveBasicBlockAfter(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos);
2647 * Obtain the first instruction in a basic block.
2649 * The returned LLVMValueRef corresponds to a llvm::Instruction
2652 LLVMValueRef LLVMGetFirstInstruction(LLVMBasicBlockRef BB);
2655 * Obtain the last instruction in a basic block.
2657 * The returned LLVMValueRef corresponds to an LLVM:Instruction.
2659 LLVMValueRef LLVMGetLastInstruction(LLVMBasicBlockRef BB);
2666 * @defgroup LLVMCCoreValueInstruction Instructions
2668 * Functions in this group relate to the inspection and manipulation of
2669 * individual instructions.
2671 * In the C++ API, an instruction is modeled by llvm::Instruction. This
2672 * class has a large number of descendents. llvm::Instruction is a
2673 * llvm::Value and in the C API, instructions are modeled by
2676 * This group also contains sub-groups which operate on specific
2677 * llvm::Instruction types, e.g. llvm::CallInst.
2683 * Determine whether an instruction has any metadata attached.
2685 int LLVMHasMetadata(LLVMValueRef Val);
2688 * Return metadata associated with an instruction value.
2690 LLVMValueRef LLVMGetMetadata(LLVMValueRef Val, unsigned KindID);
2693 * Set metadata associated with an instruction value.
2695 void LLVMSetMetadata(LLVMValueRef Val, unsigned KindID, LLVMValueRef Node);
2698 * Obtain the basic block to which an instruction belongs.
2700 * @see llvm::Instruction::getParent()
2702 LLVMBasicBlockRef LLVMGetInstructionParent(LLVMValueRef Inst);
2705 * Obtain the instruction that occurs after the one specified.
2707 * The next instruction will be from the same basic block.
2709 * If this is the last instruction in a basic block, NULL will be
2712 LLVMValueRef LLVMGetNextInstruction(LLVMValueRef Inst);
2715 * Obtain the instruction that occurred before this one.
2717 * If the instruction is the first instruction in a basic block, NULL
2720 LLVMValueRef LLVMGetPreviousInstruction(LLVMValueRef Inst);
2723 * Remove and delete an instruction.
2725 * The instruction specified is removed from its containing building
2726 * block but is kept alive.
2728 * @see llvm::Instruction::removeFromParent()
2730 void LLVMInstructionRemoveFromParent(LLVMValueRef Inst);
2733 * Remove and delete an instruction.
2735 * The instruction specified is removed from its containing building
2736 * block and then deleted.
2738 * @see llvm::Instruction::eraseFromParent()
2740 void LLVMInstructionEraseFromParent(LLVMValueRef Inst);
2743 * Obtain the code opcode for an individual instruction.
2745 * @see llvm::Instruction::getOpCode()
2747 LLVMOpcode LLVMGetInstructionOpcode(LLVMValueRef Inst);
2750 * Obtain the predicate of an instruction.
2752 * This is only valid for instructions that correspond to llvm::ICmpInst
2753 * or llvm::ConstantExpr whose opcode is llvm::Instruction::ICmp.
2755 * @see llvm::ICmpInst::getPredicate()
2757 LLVMIntPredicate LLVMGetICmpPredicate(LLVMValueRef Inst);
2760 * Obtain the float predicate of an instruction.
2762 * This is only valid for instructions that correspond to llvm::FCmpInst
2763 * or llvm::ConstantExpr whose opcode is llvm::Instruction::FCmp.
2765 * @see llvm::FCmpInst::getPredicate()
2767 LLVMRealPredicate LLVMGetFCmpPredicate(LLVMValueRef Inst);
2770 * Create a copy of 'this' instruction that is identical in all ways
2771 * except the following:
2772 * * The instruction has no parent
2773 * * The instruction has no name
2775 * @see llvm::Instruction::clone()
2777 LLVMValueRef LLVMInstructionClone(LLVMValueRef Inst);
2780 * @defgroup LLVMCCoreValueInstructionCall Call Sites and Invocations
2782 * Functions in this group apply to instructions that refer to call
2783 * sites and invocations. These correspond to C++ types in the
2784 * llvm::CallInst class tree.
2790 * Obtain the argument count for a call instruction.
2792 * This expects an LLVMValueRef that corresponds to a llvm::CallInst,
2793 * llvm::InvokeInst, or llvm:FuncletPadInst.
2795 * @see llvm::CallInst::getNumArgOperands()
2796 * @see llvm::InvokeInst::getNumArgOperands()
2797 * @see llvm::FuncletPadInst::getNumArgOperands()
2799 unsigned LLVMGetNumArgOperands(LLVMValueRef Instr);
2802 * Set the calling convention for a call instruction.
2804 * This expects an LLVMValueRef that corresponds to a llvm::CallInst or
2807 * @see llvm::CallInst::setCallingConv()
2808 * @see llvm::InvokeInst::setCallingConv()
2810 void LLVMSetInstructionCallConv(LLVMValueRef Instr, unsigned CC);
2813 * Obtain the calling convention for a call instruction.
2815 * This is the opposite of LLVMSetInstructionCallConv(). Reads its
2818 * @see LLVMSetInstructionCallConv()
2820 unsigned LLVMGetInstructionCallConv(LLVMValueRef Instr);
2822 void LLVMSetInstrParamAlignment(LLVMValueRef Instr, unsigned index,
2825 void LLVMAddCallSiteAttribute(LLVMValueRef C, LLVMAttributeIndex Idx,
2826 LLVMAttributeRef A);
2827 unsigned LLVMGetCallSiteAttributeCount(LLVMValueRef C, LLVMAttributeIndex Idx);
2828 void LLVMGetCallSiteAttributes(LLVMValueRef C, LLVMAttributeIndex Idx,
2829 LLVMAttributeRef *Attrs);
2830 LLVMAttributeRef LLVMGetCallSiteEnumAttribute(LLVMValueRef C,
2831 LLVMAttributeIndex Idx,
2833 LLVMAttributeRef LLVMGetCallSiteStringAttribute(LLVMValueRef C,
2834 LLVMAttributeIndex Idx,
2835 const char *K, unsigned KLen);
2836 void LLVMRemoveCallSiteEnumAttribute(LLVMValueRef C, LLVMAttributeIndex Idx,
2838 void LLVMRemoveCallSiteStringAttribute(LLVMValueRef C, LLVMAttributeIndex Idx,
2839 const char *K, unsigned KLen);
2842 * Obtain the pointer to the function invoked by this instruction.
2844 * This expects an LLVMValueRef that corresponds to a llvm::CallInst or
2847 * @see llvm::CallInst::getCalledValue()
2848 * @see llvm::InvokeInst::getCalledValue()
2850 LLVMValueRef LLVMGetCalledValue(LLVMValueRef Instr);
2853 * Obtain whether a call instruction is a tail call.
2855 * This only works on llvm::CallInst instructions.
2857 * @see llvm::CallInst::isTailCall()
2859 LLVMBool LLVMIsTailCall(LLVMValueRef CallInst);
2862 * Set whether a call instruction is a tail call.
2864 * This only works on llvm::CallInst instructions.
2866 * @see llvm::CallInst::setTailCall()
2868 void LLVMSetTailCall(LLVMValueRef CallInst, LLVMBool IsTailCall);
2871 * Return the normal destination basic block.
2873 * This only works on llvm::InvokeInst instructions.
2875 * @see llvm::InvokeInst::getNormalDest()
2877 LLVMBasicBlockRef LLVMGetNormalDest(LLVMValueRef InvokeInst);
2880 * Return the unwind destination basic block.
2882 * Works on llvm::InvokeInst, llvm::CleanupReturnInst, and
2883 * llvm::CatchSwitchInst instructions.
2885 * @see llvm::InvokeInst::getUnwindDest()
2886 * @see llvm::CleanupReturnInst::getUnwindDest()
2887 * @see llvm::CatchSwitchInst::getUnwindDest()
2889 LLVMBasicBlockRef LLVMGetUnwindDest(LLVMValueRef InvokeInst);
2892 * Set the normal destination basic block.
2894 * This only works on llvm::InvokeInst instructions.
2896 * @see llvm::InvokeInst::setNormalDest()
2898 void LLVMSetNormalDest(LLVMValueRef InvokeInst, LLVMBasicBlockRef B);
2901 * Set the unwind destination basic block.
2903 * Works on llvm::InvokeInst, llvm::CleanupReturnInst, and
2904 * llvm::CatchSwitchInst instructions.
2906 * @see llvm::InvokeInst::setUnwindDest()
2907 * @see llvm::CleanupReturnInst::setUnwindDest()
2908 * @see llvm::CatchSwitchInst::setUnwindDest()
2910 void LLVMSetUnwindDest(LLVMValueRef InvokeInst, LLVMBasicBlockRef B);
2917 * @defgroup LLVMCCoreValueInstructionTerminator Terminators
2919 * Functions in this group only apply to instructions that map to
2920 * llvm::TerminatorInst instances.
2926 * Return the number of successors that this terminator has.
2928 * @see llvm::TerminatorInst::getNumSuccessors
2930 unsigned LLVMGetNumSuccessors(LLVMValueRef Term);
2933 * Return the specified successor.
2935 * @see llvm::TerminatorInst::getSuccessor
2937 LLVMBasicBlockRef LLVMGetSuccessor(LLVMValueRef Term, unsigned i);
2940 * Update the specified successor to point at the provided block.
2942 * @see llvm::TerminatorInst::setSuccessor
2944 void LLVMSetSuccessor(LLVMValueRef Term, unsigned i, LLVMBasicBlockRef block);
2947 * Return if a branch is conditional.
2949 * This only works on llvm::BranchInst instructions.
2951 * @see llvm::BranchInst::isConditional
2953 LLVMBool LLVMIsConditional(LLVMValueRef Branch);
2956 * Return the condition of a branch instruction.
2958 * This only works on llvm::BranchInst instructions.
2960 * @see llvm::BranchInst::getCondition
2962 LLVMValueRef LLVMGetCondition(LLVMValueRef Branch);
2965 * Set the condition of a branch instruction.
2967 * This only works on llvm::BranchInst instructions.
2969 * @see llvm::BranchInst::setCondition
2971 void LLVMSetCondition(LLVMValueRef Branch, LLVMValueRef Cond);
2974 * Obtain the default destination basic block of a switch instruction.
2976 * This only works on llvm::SwitchInst instructions.
2978 * @see llvm::SwitchInst::getDefaultDest()
2980 LLVMBasicBlockRef LLVMGetSwitchDefaultDest(LLVMValueRef SwitchInstr);
2987 * @defgroup LLVMCCoreValueInstructionAlloca Allocas
2989 * Functions in this group only apply to instructions that map to
2990 * llvm::AllocaInst instances.
2996 * Obtain the type that is being allocated by the alloca instruction.
2998 LLVMTypeRef LLVMGetAllocatedType(LLVMValueRef Alloca);
3005 * @defgroup LLVMCCoreValueInstructionGetElementPointer GEPs
3007 * Functions in this group only apply to instructions that map to
3008 * llvm::GetElementPtrInst instances.
3014 * Check whether the given GEP instruction is inbounds.
3016 LLVMBool LLVMIsInBounds(LLVMValueRef GEP);
3019 * Set the given GEP instruction to be inbounds or not.
3021 void LLVMSetIsInBounds(LLVMValueRef GEP, LLVMBool InBounds);
3028 * @defgroup LLVMCCoreValueInstructionPHINode PHI Nodes
3030 * Functions in this group only apply to instructions that map to
3031 * llvm::PHINode instances.
3037 * Add an incoming value to the end of a PHI list.
3039 void LLVMAddIncoming(LLVMValueRef PhiNode, LLVMValueRef *IncomingValues,
3040 LLVMBasicBlockRef *IncomingBlocks, unsigned Count);
3043 * Obtain the number of incoming basic blocks to a PHI node.
3045 unsigned LLVMCountIncoming(LLVMValueRef PhiNode);
3048 * Obtain an incoming value to a PHI node as an LLVMValueRef.
3050 LLVMValueRef LLVMGetIncomingValue(LLVMValueRef PhiNode, unsigned Index);
3053 * Obtain an incoming value to a PHI node as an LLVMBasicBlockRef.
3055 LLVMBasicBlockRef LLVMGetIncomingBlock(LLVMValueRef PhiNode, unsigned Index);
3062 * @defgroup LLVMCCoreValueInstructionExtractValue ExtractValue
3063 * @defgroup LLVMCCoreValueInstructionInsertValue InsertValue
3065 * Functions in this group only apply to instructions that map to
3066 * llvm::ExtractValue and llvm::InsertValue instances.
3072 * Obtain the number of indices.
3073 * NB: This also works on GEP.
3075 unsigned LLVMGetNumIndices(LLVMValueRef Inst);
3078 * Obtain the indices as an array.
3080 const unsigned *LLVMGetIndices(LLVMValueRef Inst);
3095 * @defgroup LLVMCCoreInstructionBuilder Instruction Builders
3097 * An instruction builder represents a point within a basic block and is
3098 * the exclusive means of building instructions using the C interface.
3103 LLVMBuilderRef LLVMCreateBuilderInContext(LLVMContextRef C);
3104 LLVMBuilderRef LLVMCreateBuilder(void);
3105 void LLVMPositionBuilder(LLVMBuilderRef Builder, LLVMBasicBlockRef Block,
3106 LLVMValueRef Instr);
3107 void LLVMPositionBuilderBefore(LLVMBuilderRef Builder, LLVMValueRef Instr);
3108 void LLVMPositionBuilderAtEnd(LLVMBuilderRef Builder, LLVMBasicBlockRef Block);
3109 LLVMBasicBlockRef LLVMGetInsertBlock(LLVMBuilderRef Builder);
3110 void LLVMClearInsertionPosition(LLVMBuilderRef Builder);
3111 void LLVMInsertIntoBuilder(LLVMBuilderRef Builder, LLVMValueRef Instr);
3112 void LLVMInsertIntoBuilderWithName(LLVMBuilderRef Builder, LLVMValueRef Instr,
3114 void LLVMDisposeBuilder(LLVMBuilderRef Builder);
3117 void LLVMSetCurrentDebugLocation(LLVMBuilderRef Builder, LLVMValueRef L);
3118 LLVMValueRef LLVMGetCurrentDebugLocation(LLVMBuilderRef Builder);
3119 void LLVMSetInstDebugLocation(LLVMBuilderRef Builder, LLVMValueRef Inst);
3122 LLVMValueRef LLVMBuildRetVoid(LLVMBuilderRef);
3123 LLVMValueRef LLVMBuildRet(LLVMBuilderRef, LLVMValueRef V);
3124 LLVMValueRef LLVMBuildAggregateRet(LLVMBuilderRef, LLVMValueRef *RetVals,
3126 LLVMValueRef LLVMBuildBr(LLVMBuilderRef, LLVMBasicBlockRef Dest);
3127 LLVMValueRef LLVMBuildCondBr(LLVMBuilderRef, LLVMValueRef If,
3128 LLVMBasicBlockRef Then, LLVMBasicBlockRef Else);
3129 LLVMValueRef LLVMBuildSwitch(LLVMBuilderRef, LLVMValueRef V,
3130 LLVMBasicBlockRef Else, unsigned NumCases);
3131 LLVMValueRef LLVMBuildIndirectBr(LLVMBuilderRef B, LLVMValueRef Addr,
3133 LLVMValueRef LLVMBuildInvoke(LLVMBuilderRef, LLVMValueRef Fn,
3134 LLVMValueRef *Args, unsigned NumArgs,
3135 LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch,
3137 LLVMValueRef LLVMBuildUnreachable(LLVMBuilderRef);
3139 /* Exception Handling */
3140 LLVMValueRef LLVMBuildResume(LLVMBuilderRef B, LLVMValueRef Exn);
3141 LLVMValueRef LLVMBuildLandingPad(LLVMBuilderRef B, LLVMTypeRef Ty,
3142 LLVMValueRef PersFn, unsigned NumClauses,
3144 LLVMValueRef LLVMBuildCleanupRet(LLVMBuilderRef B, LLVMValueRef CatchPad,
3145 LLVMBasicBlockRef BB);
3146 LLVMValueRef LLVMBuildCatchRet(LLVMBuilderRef B, LLVMValueRef CatchPad,
3147 LLVMBasicBlockRef BB);
3148 LLVMValueRef LLVMBuildCatchPad(LLVMBuilderRef B, LLVMValueRef ParentPad,
3149 LLVMValueRef *Args, unsigned NumArgs,
3151 LLVMValueRef LLVMBuildCleanupPad(LLVMBuilderRef B, LLVMValueRef ParentPad,
3152 LLVMValueRef *Args, unsigned NumArgs,
3154 LLVMValueRef LLVMBuildCatchSwitch(LLVMBuilderRef B, LLVMValueRef ParentPad,
3155 LLVMBasicBlockRef UnwindBB,
3156 unsigned NumHandlers, const char *Name);
3158 /* Add a case to the switch instruction */
3159 void LLVMAddCase(LLVMValueRef Switch, LLVMValueRef OnVal,
3160 LLVMBasicBlockRef Dest);
3162 /* Add a destination to the indirectbr instruction */
3163 void LLVMAddDestination(LLVMValueRef IndirectBr, LLVMBasicBlockRef Dest);
3165 /* Get the number of clauses on the landingpad instruction */
3166 unsigned LLVMGetNumClauses(LLVMValueRef LandingPad);
3168 /* Get the value of the clause at idnex Idx on the landingpad instruction */
3169 LLVMValueRef LLVMGetClause(LLVMValueRef LandingPad, unsigned Idx);
3171 /* Add a catch or filter clause to the landingpad instruction */
3172 void LLVMAddClause(LLVMValueRef LandingPad, LLVMValueRef ClauseVal);
3174 /* Get the 'cleanup' flag in the landingpad instruction */
3175 LLVMBool LLVMIsCleanup(LLVMValueRef LandingPad);
3177 /* Set the 'cleanup' flag in the landingpad instruction */
3178 void LLVMSetCleanup(LLVMValueRef LandingPad, LLVMBool Val);
3180 /* Add a destination to the catchswitch instruction */
3181 void LLVMAddHandler(LLVMValueRef CatchSwitch, LLVMBasicBlockRef Dest);
3183 /* Get the number of handlers on the catchswitch instruction */
3184 unsigned LLVMGetNumHandlers(LLVMValueRef CatchSwitch);
3187 * Obtain the basic blocks acting as handlers for a catchswitch instruction.
3189 * The Handlers parameter should point to a pre-allocated array of
3190 * LLVMBasicBlockRefs at least LLVMGetNumHandlers() large. On return, the
3191 * first LLVMGetNumHandlers() entries in the array will be populated
3192 * with LLVMBasicBlockRef instances.
3194 * @param CatchSwitch The catchswitch instruction to operate on.
3195 * @param Handlers Memory address of an array to be filled with basic blocks.
3197 void LLVMGetHandlers(LLVMValueRef CatchSwitch, LLVMBasicBlockRef *Handlers);
3201 /* Get the number of funcletpad arguments. */
3202 LLVMValueRef LLVMGetArgOperand(LLVMValueRef Funclet, unsigned i);
3204 /* Set a funcletpad argument at the given index. */
3205 void LLVMSetArgOperand(LLVMValueRef Funclet, unsigned i, LLVMValueRef value);
3208 * Get the parent catchswitch instruction of a catchpad instruction.
3210 * This only works on llvm::CatchPadInst instructions.
3212 * @see llvm::CatchPadInst::getCatchSwitch()
3214 LLVMValueRef LLVMGetParentCatchSwitch(LLVMValueRef CatchPad);
3217 * Set the parent catchswitch instruction of a catchpad instruction.
3219 * This only works on llvm::CatchPadInst instructions.
3221 * @see llvm::CatchPadInst::setCatchSwitch()
3223 void LLVMSetParentCatchSwitch(LLVMValueRef CatchPad, LLVMValueRef CatchSwitch);
3226 LLVMValueRef LLVMBuildAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3228 LLVMValueRef LLVMBuildNSWAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3230 LLVMValueRef LLVMBuildNUWAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3232 LLVMValueRef LLVMBuildFAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3234 LLVMValueRef LLVMBuildSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3236 LLVMValueRef LLVMBuildNSWSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3238 LLVMValueRef LLVMBuildNUWSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3240 LLVMValueRef LLVMBuildFSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3242 LLVMValueRef LLVMBuildMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3244 LLVMValueRef LLVMBuildNSWMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3246 LLVMValueRef LLVMBuildNUWMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3248 LLVMValueRef LLVMBuildFMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3250 LLVMValueRef LLVMBuildUDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3252 LLVMValueRef LLVMBuildExactUDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3254 LLVMValueRef LLVMBuildSDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3256 LLVMValueRef LLVMBuildExactSDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3258 LLVMValueRef LLVMBuildFDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3260 LLVMValueRef LLVMBuildURem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3262 LLVMValueRef LLVMBuildSRem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3264 LLVMValueRef LLVMBuildFRem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3266 LLVMValueRef LLVMBuildShl(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3268 LLVMValueRef LLVMBuildLShr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3270 LLVMValueRef LLVMBuildAShr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3272 LLVMValueRef LLVMBuildAnd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3274 LLVMValueRef LLVMBuildOr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3276 LLVMValueRef LLVMBuildXor(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3278 LLVMValueRef LLVMBuildBinOp(LLVMBuilderRef B, LLVMOpcode Op,
3279 LLVMValueRef LHS, LLVMValueRef RHS,
3281 LLVMValueRef LLVMBuildNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name);
3282 LLVMValueRef LLVMBuildNSWNeg(LLVMBuilderRef B, LLVMValueRef V,
3284 LLVMValueRef LLVMBuildNUWNeg(LLVMBuilderRef B, LLVMValueRef V,
3286 LLVMValueRef LLVMBuildFNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name);
3287 LLVMValueRef LLVMBuildNot(LLVMBuilderRef, LLVMValueRef V, const char *Name);
3290 LLVMValueRef LLVMBuildMalloc(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
3291 LLVMValueRef LLVMBuildArrayMalloc(LLVMBuilderRef, LLVMTypeRef Ty,
3292 LLVMValueRef Val, const char *Name);
3293 LLVMValueRef LLVMBuildAlloca(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
3294 LLVMValueRef LLVMBuildArrayAlloca(LLVMBuilderRef, LLVMTypeRef Ty,
3295 LLVMValueRef Val, const char *Name);
3296 LLVMValueRef LLVMBuildFree(LLVMBuilderRef, LLVMValueRef PointerVal);
3297 LLVMValueRef LLVMBuildLoad(LLVMBuilderRef, LLVMValueRef PointerVal,
3299 LLVMValueRef LLVMBuildStore(LLVMBuilderRef, LLVMValueRef Val, LLVMValueRef Ptr);
3300 LLVMValueRef LLVMBuildGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
3301 LLVMValueRef *Indices, unsigned NumIndices,
3303 LLVMValueRef LLVMBuildInBoundsGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
3304 LLVMValueRef *Indices, unsigned NumIndices,
3306 LLVMValueRef LLVMBuildStructGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
3307 unsigned Idx, const char *Name);
3308 LLVMValueRef LLVMBuildGlobalString(LLVMBuilderRef B, const char *Str,
3310 LLVMValueRef LLVMBuildGlobalStringPtr(LLVMBuilderRef B, const char *Str,
3312 LLVMBool LLVMGetVolatile(LLVMValueRef MemoryAccessInst);
3313 void LLVMSetVolatile(LLVMValueRef MemoryAccessInst, LLVMBool IsVolatile);
3314 LLVMAtomicOrdering LLVMGetOrdering(LLVMValueRef MemoryAccessInst);
3315 void LLVMSetOrdering(LLVMValueRef MemoryAccessInst, LLVMAtomicOrdering Ordering);
3318 LLVMValueRef LLVMBuildTrunc(LLVMBuilderRef, LLVMValueRef Val,
3319 LLVMTypeRef DestTy, const char *Name);
3320 LLVMValueRef LLVMBuildZExt(LLVMBuilderRef, LLVMValueRef Val,
3321 LLVMTypeRef DestTy, const char *Name);
3322 LLVMValueRef LLVMBuildSExt(LLVMBuilderRef, LLVMValueRef Val,
3323 LLVMTypeRef DestTy, const char *Name);
3324 LLVMValueRef LLVMBuildFPToUI(LLVMBuilderRef, LLVMValueRef Val,
3325 LLVMTypeRef DestTy, const char *Name);
3326 LLVMValueRef LLVMBuildFPToSI(LLVMBuilderRef, LLVMValueRef Val,
3327 LLVMTypeRef DestTy, const char *Name);
3328 LLVMValueRef LLVMBuildUIToFP(LLVMBuilderRef, LLVMValueRef Val,
3329 LLVMTypeRef DestTy, const char *Name);
3330 LLVMValueRef LLVMBuildSIToFP(LLVMBuilderRef, LLVMValueRef Val,
3331 LLVMTypeRef DestTy, const char *Name);
3332 LLVMValueRef LLVMBuildFPTrunc(LLVMBuilderRef, LLVMValueRef Val,
3333 LLVMTypeRef DestTy, const char *Name);
3334 LLVMValueRef LLVMBuildFPExt(LLVMBuilderRef, LLVMValueRef Val,
3335 LLVMTypeRef DestTy, const char *Name);
3336 LLVMValueRef LLVMBuildPtrToInt(LLVMBuilderRef, LLVMValueRef Val,
3337 LLVMTypeRef DestTy, const char *Name);
3338 LLVMValueRef LLVMBuildIntToPtr(LLVMBuilderRef, LLVMValueRef Val,
3339 LLVMTypeRef DestTy, const char *Name);
3340 LLVMValueRef LLVMBuildBitCast(LLVMBuilderRef, LLVMValueRef Val,
3341 LLVMTypeRef DestTy, const char *Name);
3342 LLVMValueRef LLVMBuildAddrSpaceCast(LLVMBuilderRef, LLVMValueRef Val,
3343 LLVMTypeRef DestTy, const char *Name);
3344 LLVMValueRef LLVMBuildZExtOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
3345 LLVMTypeRef DestTy, const char *Name);
3346 LLVMValueRef LLVMBuildSExtOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
3347 LLVMTypeRef DestTy, const char *Name);
3348 LLVMValueRef LLVMBuildTruncOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
3349 LLVMTypeRef DestTy, const char *Name);
3350 LLVMValueRef LLVMBuildCast(LLVMBuilderRef B, LLVMOpcode Op, LLVMValueRef Val,
3351 LLVMTypeRef DestTy, const char *Name);
3352 LLVMValueRef LLVMBuildPointerCast(LLVMBuilderRef, LLVMValueRef Val,
3353 LLVMTypeRef DestTy, const char *Name);
3354 LLVMValueRef LLVMBuildIntCast(LLVMBuilderRef, LLVMValueRef Val, /*Signed cast!*/
3355 LLVMTypeRef DestTy, const char *Name);
3356 LLVMValueRef LLVMBuildFPCast(LLVMBuilderRef, LLVMValueRef Val,
3357 LLVMTypeRef DestTy, const char *Name);
3360 LLVMValueRef LLVMBuildICmp(LLVMBuilderRef, LLVMIntPredicate Op,
3361 LLVMValueRef LHS, LLVMValueRef RHS,
3363 LLVMValueRef LLVMBuildFCmp(LLVMBuilderRef, LLVMRealPredicate Op,
3364 LLVMValueRef LHS, LLVMValueRef RHS,
3367 /* Miscellaneous instructions */
3368 LLVMValueRef LLVMBuildPhi(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
3369 LLVMValueRef LLVMBuildCall(LLVMBuilderRef, LLVMValueRef Fn,
3370 LLVMValueRef *Args, unsigned NumArgs,
3372 LLVMValueRef LLVMBuildSelect(LLVMBuilderRef, LLVMValueRef If,
3373 LLVMValueRef Then, LLVMValueRef Else,
3375 LLVMValueRef LLVMBuildVAArg(LLVMBuilderRef, LLVMValueRef List, LLVMTypeRef Ty,
3377 LLVMValueRef LLVMBuildExtractElement(LLVMBuilderRef, LLVMValueRef VecVal,
3378 LLVMValueRef Index, const char *Name);
3379 LLVMValueRef LLVMBuildInsertElement(LLVMBuilderRef, LLVMValueRef VecVal,
3380 LLVMValueRef EltVal, LLVMValueRef Index,
3382 LLVMValueRef LLVMBuildShuffleVector(LLVMBuilderRef, LLVMValueRef V1,
3383 LLVMValueRef V2, LLVMValueRef Mask,
3385 LLVMValueRef LLVMBuildExtractValue(LLVMBuilderRef, LLVMValueRef AggVal,
3386 unsigned Index, const char *Name);
3387 LLVMValueRef LLVMBuildInsertValue(LLVMBuilderRef, LLVMValueRef AggVal,
3388 LLVMValueRef EltVal, unsigned Index,
3391 LLVMValueRef LLVMBuildIsNull(LLVMBuilderRef, LLVMValueRef Val,
3393 LLVMValueRef LLVMBuildIsNotNull(LLVMBuilderRef, LLVMValueRef Val,
3395 LLVMValueRef LLVMBuildPtrDiff(LLVMBuilderRef, LLVMValueRef LHS,
3396 LLVMValueRef RHS, const char *Name);
3397 LLVMValueRef LLVMBuildFence(LLVMBuilderRef B, LLVMAtomicOrdering ordering,
3398 LLVMBool singleThread, const char *Name);
3399 LLVMValueRef LLVMBuildAtomicRMW(LLVMBuilderRef B, LLVMAtomicRMWBinOp op,
3400 LLVMValueRef PTR, LLVMValueRef Val,
3401 LLVMAtomicOrdering ordering,
3402 LLVMBool singleThread);
3403 LLVMValueRef LLVMBuildAtomicCmpXchg(LLVMBuilderRef B, LLVMValueRef Ptr,
3404 LLVMValueRef Cmp, LLVMValueRef New,
3405 LLVMAtomicOrdering SuccessOrdering,
3406 LLVMAtomicOrdering FailureOrdering,
3407 LLVMBool SingleThread);
3409 LLVMBool LLVMIsAtomicSingleThread(LLVMValueRef AtomicInst);
3410 void LLVMSetAtomicSingleThread(LLVMValueRef AtomicInst, LLVMBool SingleThread);
3412 LLVMAtomicOrdering LLVMGetCmpXchgSuccessOrdering(LLVMValueRef CmpXchgInst);
3413 void LLVMSetCmpXchgSuccessOrdering(LLVMValueRef CmpXchgInst,
3414 LLVMAtomicOrdering Ordering);
3415 LLVMAtomicOrdering LLVMGetCmpXchgFailureOrdering(LLVMValueRef CmpXchgInst);
3416 void LLVMSetCmpXchgFailureOrdering(LLVMValueRef CmpXchgInst,
3417 LLVMAtomicOrdering Ordering);
3424 * @defgroup LLVMCCoreModuleProvider Module Providers
3430 * Changes the type of M so it can be passed to FunctionPassManagers and the
3431 * JIT. They take ModuleProviders for historical reasons.
3433 LLVMModuleProviderRef
3434 LLVMCreateModuleProviderForExistingModule(LLVMModuleRef M);
3437 * Destroys the module M.
3439 void LLVMDisposeModuleProvider(LLVMModuleProviderRef M);
3446 * @defgroup LLVMCCoreMemoryBuffers Memory Buffers
3451 LLVMBool LLVMCreateMemoryBufferWithContentsOfFile(const char *Path,
3452 LLVMMemoryBufferRef *OutMemBuf,
3454 LLVMBool LLVMCreateMemoryBufferWithSTDIN(LLVMMemoryBufferRef *OutMemBuf,
3456 LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRange(const char *InputData,
3457 size_t InputDataLength,
3458 const char *BufferName,
3459 LLVMBool RequiresNullTerminator);
3460 LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRangeCopy(const char *InputData,
3461 size_t InputDataLength,
3462 const char *BufferName);
3463 const char *LLVMGetBufferStart(LLVMMemoryBufferRef MemBuf);
3464 size_t LLVMGetBufferSize(LLVMMemoryBufferRef MemBuf);
3465 void LLVMDisposeMemoryBuffer(LLVMMemoryBufferRef MemBuf);
3472 * @defgroup LLVMCCorePassRegistry Pass Registry
3477 /** Return the global pass registry, for use with initialization functions.
3478 @see llvm::PassRegistry::getPassRegistry */
3479 LLVMPassRegistryRef LLVMGetGlobalPassRegistry(void);
3486 * @defgroup LLVMCCorePassManagers Pass Managers
3491 /** Constructs a new whole-module pass pipeline. This type of pipeline is
3492 suitable for link-time optimization and whole-module transformations.
3493 @see llvm::PassManager::PassManager */
3494 LLVMPassManagerRef LLVMCreatePassManager(void);
3496 /** Constructs a new function-by-function pass pipeline over the module
3497 provider. It does not take ownership of the module provider. This type of
3498 pipeline is suitable for code generation and JIT compilation tasks.
3499 @see llvm::FunctionPassManager::FunctionPassManager */
3500 LLVMPassManagerRef LLVMCreateFunctionPassManagerForModule(LLVMModuleRef M);
3502 /** Deprecated: Use LLVMCreateFunctionPassManagerForModule instead. */
3503 LLVMPassManagerRef LLVMCreateFunctionPassManager(LLVMModuleProviderRef MP);
3505 /** Initializes, executes on the provided module, and finalizes all of the
3506 passes scheduled in the pass manager. Returns 1 if any of the passes
3507 modified the module, 0 otherwise.
3508 @see llvm::PassManager::run(Module&) */
3509 LLVMBool LLVMRunPassManager(LLVMPassManagerRef PM, LLVMModuleRef M);
3511 /** Initializes all of the function passes scheduled in the function pass
3512 manager. Returns 1 if any of the passes modified the module, 0 otherwise.
3513 @see llvm::FunctionPassManager::doInitialization */
3514 LLVMBool LLVMInitializeFunctionPassManager(LLVMPassManagerRef FPM);
3516 /** Executes all of the function passes scheduled in the function pass manager
3517 on the provided function. Returns 1 if any of the passes modified the
3518 function, false otherwise.
3519 @see llvm::FunctionPassManager::run(Function&) */
3520 LLVMBool LLVMRunFunctionPassManager(LLVMPassManagerRef FPM, LLVMValueRef F);
3522 /** Finalizes all of the function passes scheduled in the function pass
3523 manager. Returns 1 if any of the passes modified the module, 0 otherwise.
3524 @see llvm::FunctionPassManager::doFinalization */
3525 LLVMBool LLVMFinalizeFunctionPassManager(LLVMPassManagerRef FPM);
3527 /** Frees the memory of a pass pipeline. For function pipelines, does not free
3528 the module provider.
3529 @see llvm::PassManagerBase::~PassManagerBase. */
3530 void LLVMDisposePassManager(LLVMPassManagerRef PM);
3537 * @defgroup LLVMCCoreThreading Threading
3539 * Handle the structures needed to make LLVM safe for multithreading.
3544 /** Deprecated: Multi-threading can only be enabled/disabled with the compile
3545 time define LLVM_ENABLE_THREADS. This function always returns
3546 LLVMIsMultithreaded(). */
3547 LLVMBool LLVMStartMultithreaded(void);
3549 /** Deprecated: Multi-threading can only be enabled/disabled with the compile
3550 time define LLVM_ENABLE_THREADS. */
3551 void LLVMStopMultithreaded(void);
3553 /** Check whether LLVM is executing in thread-safe mode or not.
3554 @see llvm::llvm_is_multithreaded */
3555 LLVMBool LLVMIsMultithreaded(void);
3573 #endif /* LLVM_C_CORE_H */