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 an iterator to the first NamedMDNode in a Module.
848 * @see llvm::Module::named_metadata_begin()
850 LLVMNamedMDNodeRef
LLVMGetFirstNamedMetadata(LLVMModuleRef M
);
853 * Obtain an iterator to the last NamedMDNode in a Module.
855 * @see llvm::Module::named_metadata_end()
857 LLVMNamedMDNodeRef
LLVMGetLastNamedMetadata(LLVMModuleRef M
);
860 * Advance a NamedMDNode iterator to the next NamedMDNode.
862 * Returns NULL if the iterator was already at the end and there are no more
863 * named metadata nodes.
865 LLVMNamedMDNodeRef
LLVMGetNextNamedMetadata(LLVMNamedMDNodeRef NamedMDNode
);
868 * Decrement a NamedMDNode iterator to the previous NamedMDNode.
870 * Returns NULL if the iterator was already at the beginning and there are
871 * no previous named metadata nodes.
873 LLVMNamedMDNodeRef
LLVMGetPreviousNamedMetadata(LLVMNamedMDNodeRef NamedMDNode
);
876 * Retrieve a NamedMDNode with the given name, returning NULL if no such
879 * @see llvm::Module::getNamedMetadata()
881 LLVMNamedMDNodeRef
LLVMGetNamedMetadata(LLVMModuleRef M
,
882 const char *Name
, size_t NameLen
);
885 * Retrieve a NamedMDNode with the given name, creating a new node if no such
888 * @see llvm::Module::getOrInsertNamedMetadata()
890 LLVMNamedMDNodeRef
LLVMGetOrInsertNamedMetadata(LLVMModuleRef M
,
895 * Retrieve the name of a NamedMDNode.
897 * @see llvm::NamedMDNode::getName()
899 const char *LLVMGetNamedMetadataName(LLVMNamedMDNodeRef NamedMD
,
903 * Obtain the number of operands for named metadata in a module.
905 * @see llvm::Module::getNamedMetadata()
907 unsigned LLVMGetNamedMetadataNumOperands(LLVMModuleRef M
, const char *Name
);
910 * Obtain the named metadata operands for a module.
912 * The passed LLVMValueRef pointer should refer to an array of
913 * LLVMValueRef at least LLVMGetNamedMetadataNumOperands long. This
914 * array will be populated with the LLVMValueRef instances. Each
915 * instance corresponds to a llvm::MDNode.
917 * @see llvm::Module::getNamedMetadata()
918 * @see llvm::MDNode::getOperand()
920 void LLVMGetNamedMetadataOperands(LLVMModuleRef M
, const char *Name
,
924 * Add an operand to named metadata.
926 * @see llvm::Module::getNamedMetadata()
927 * @see llvm::MDNode::addOperand()
929 void LLVMAddNamedMetadataOperand(LLVMModuleRef M
, const char *Name
,
933 * Add a function to a module under a specified name.
935 * @see llvm::Function::Create()
937 LLVMValueRef
LLVMAddFunction(LLVMModuleRef M
, const char *Name
,
938 LLVMTypeRef FunctionTy
);
941 * Obtain a Function value from a Module by its name.
943 * The returned value corresponds to a llvm::Function value.
945 * @see llvm::Module::getFunction()
947 LLVMValueRef
LLVMGetNamedFunction(LLVMModuleRef M
, const char *Name
);
950 * Obtain an iterator to the first Function in a Module.
952 * @see llvm::Module::begin()
954 LLVMValueRef
LLVMGetFirstFunction(LLVMModuleRef M
);
957 * Obtain an iterator to the last Function in a Module.
959 * @see llvm::Module::end()
961 LLVMValueRef
LLVMGetLastFunction(LLVMModuleRef M
);
964 * Advance a Function iterator to the next Function.
966 * Returns NULL if the iterator was already at the end and there are no more
969 LLVMValueRef
LLVMGetNextFunction(LLVMValueRef Fn
);
972 * Decrement a Function iterator to the previous Function.
974 * Returns NULL if the iterator was already at the beginning and there are
975 * no previous functions.
977 LLVMValueRef
LLVMGetPreviousFunction(LLVMValueRef Fn
);
979 /** Deprecated: Use LLVMSetModuleInlineAsm2 instead. */
980 void LLVMSetModuleInlineAsm(LLVMModuleRef M
, const char *Asm
);
987 * @defgroup LLVMCCoreType Types
989 * Types represent the type of a value.
991 * Types are associated with a context instance. The context internally
992 * deduplicates types so there is only 1 instance of a specific type
993 * alive at a time. In other words, a unique type is shared among all
994 * consumers within a context.
996 * A Type in the C API corresponds to llvm::Type.
998 * Types have the following hierarchy:
1016 * Obtain the enumerated type of a Type instance.
1018 * @see llvm::Type:getTypeID()
1020 LLVMTypeKind
LLVMGetTypeKind(LLVMTypeRef Ty
);
1023 * Whether the type has a known size.
1025 * Things that don't have a size are abstract types, labels, and void.a
1027 * @see llvm::Type::isSized()
1029 LLVMBool
LLVMTypeIsSized(LLVMTypeRef Ty
);
1032 * Obtain the context to which this type instance is associated.
1034 * @see llvm::Type::getContext()
1036 LLVMContextRef
LLVMGetTypeContext(LLVMTypeRef Ty
);
1039 * Dump a representation of a type to stderr.
1041 * @see llvm::Type::dump()
1043 void LLVMDumpType(LLVMTypeRef Val
);
1046 * Return a string representation of the type. Use
1047 * LLVMDisposeMessage to free the string.
1049 * @see llvm::Type::print()
1051 char *LLVMPrintTypeToString(LLVMTypeRef Val
);
1054 * @defgroup LLVMCCoreTypeInt Integer Types
1056 * Functions in this section operate on integer types.
1062 * Obtain an integer type from a context with specified bit width.
1064 LLVMTypeRef
LLVMInt1TypeInContext(LLVMContextRef C
);
1065 LLVMTypeRef
LLVMInt8TypeInContext(LLVMContextRef C
);
1066 LLVMTypeRef
LLVMInt16TypeInContext(LLVMContextRef C
);
1067 LLVMTypeRef
LLVMInt32TypeInContext(LLVMContextRef C
);
1068 LLVMTypeRef
LLVMInt64TypeInContext(LLVMContextRef C
);
1069 LLVMTypeRef
LLVMInt128TypeInContext(LLVMContextRef C
);
1070 LLVMTypeRef
LLVMIntTypeInContext(LLVMContextRef C
, unsigned NumBits
);
1073 * Obtain an integer type from the global context with a specified bit
1076 LLVMTypeRef
LLVMInt1Type(void);
1077 LLVMTypeRef
LLVMInt8Type(void);
1078 LLVMTypeRef
LLVMInt16Type(void);
1079 LLVMTypeRef
LLVMInt32Type(void);
1080 LLVMTypeRef
LLVMInt64Type(void);
1081 LLVMTypeRef
LLVMInt128Type(void);
1082 LLVMTypeRef
LLVMIntType(unsigned NumBits
);
1083 unsigned LLVMGetIntTypeWidth(LLVMTypeRef IntegerTy
);
1090 * @defgroup LLVMCCoreTypeFloat Floating Point Types
1096 * Obtain a 16-bit floating point type from a context.
1098 LLVMTypeRef
LLVMHalfTypeInContext(LLVMContextRef C
);
1101 * Obtain a 32-bit floating point type from a context.
1103 LLVMTypeRef
LLVMFloatTypeInContext(LLVMContextRef C
);
1106 * Obtain a 64-bit floating point type from a context.
1108 LLVMTypeRef
LLVMDoubleTypeInContext(LLVMContextRef C
);
1111 * Obtain a 80-bit floating point type (X87) from a context.
1113 LLVMTypeRef
LLVMX86FP80TypeInContext(LLVMContextRef C
);
1116 * Obtain a 128-bit floating point type (112-bit mantissa) from a
1119 LLVMTypeRef
LLVMFP128TypeInContext(LLVMContextRef C
);
1122 * Obtain a 128-bit floating point type (two 64-bits) from a context.
1124 LLVMTypeRef
LLVMPPCFP128TypeInContext(LLVMContextRef C
);
1127 * Obtain a floating point type from the global context.
1129 * These map to the functions in this group of the same name.
1131 LLVMTypeRef
LLVMHalfType(void);
1132 LLVMTypeRef
LLVMFloatType(void);
1133 LLVMTypeRef
LLVMDoubleType(void);
1134 LLVMTypeRef
LLVMX86FP80Type(void);
1135 LLVMTypeRef
LLVMFP128Type(void);
1136 LLVMTypeRef
LLVMPPCFP128Type(void);
1143 * @defgroup LLVMCCoreTypeFunction Function Types
1149 * Obtain a function type consisting of a specified signature.
1151 * The function is defined as a tuple of a return Type, a list of
1152 * parameter types, and whether the function is variadic.
1154 LLVMTypeRef
LLVMFunctionType(LLVMTypeRef ReturnType
,
1155 LLVMTypeRef
*ParamTypes
, unsigned ParamCount
,
1159 * Returns whether a function type is variadic.
1161 LLVMBool
LLVMIsFunctionVarArg(LLVMTypeRef FunctionTy
);
1164 * Obtain the Type this function Type returns.
1166 LLVMTypeRef
LLVMGetReturnType(LLVMTypeRef FunctionTy
);
1169 * Obtain the number of parameters this function accepts.
1171 unsigned LLVMCountParamTypes(LLVMTypeRef FunctionTy
);
1174 * Obtain the types of a function's parameters.
1176 * The Dest parameter should point to a pre-allocated array of
1177 * LLVMTypeRef at least LLVMCountParamTypes() large. On return, the
1178 * first LLVMCountParamTypes() entries in the array will be populated
1179 * with LLVMTypeRef instances.
1181 * @param FunctionTy The function type to operate on.
1182 * @param Dest Memory address of an array to be filled with result.
1184 void LLVMGetParamTypes(LLVMTypeRef FunctionTy
, LLVMTypeRef
*Dest
);
1191 * @defgroup LLVMCCoreTypeStruct Structure Types
1193 * These functions relate to LLVMTypeRef instances.
1195 * @see llvm::StructType
1201 * Create a new structure type in a context.
1203 * A structure is specified by a list of inner elements/types and
1204 * whether these can be packed together.
1206 * @see llvm::StructType::create()
1208 LLVMTypeRef
LLVMStructTypeInContext(LLVMContextRef C
, LLVMTypeRef
*ElementTypes
,
1209 unsigned ElementCount
, LLVMBool Packed
);
1212 * Create a new structure type in the global context.
1214 * @see llvm::StructType::create()
1216 LLVMTypeRef
LLVMStructType(LLVMTypeRef
*ElementTypes
, unsigned ElementCount
,
1220 * Create an empty structure in a context having a specified name.
1222 * @see llvm::StructType::create()
1224 LLVMTypeRef
LLVMStructCreateNamed(LLVMContextRef C
, const char *Name
);
1227 * Obtain the name of a structure.
1229 * @see llvm::StructType::getName()
1231 const char *LLVMGetStructName(LLVMTypeRef Ty
);
1234 * Set the contents of a structure type.
1236 * @see llvm::StructType::setBody()
1238 void LLVMStructSetBody(LLVMTypeRef StructTy
, LLVMTypeRef
*ElementTypes
,
1239 unsigned ElementCount
, LLVMBool Packed
);
1242 * Get the number of elements defined inside the structure.
1244 * @see llvm::StructType::getNumElements()
1246 unsigned LLVMCountStructElementTypes(LLVMTypeRef StructTy
);
1249 * Get the elements within a structure.
1251 * The function is passed the address of a pre-allocated array of
1252 * LLVMTypeRef at least LLVMCountStructElementTypes() long. After
1253 * invocation, this array will be populated with the structure's
1254 * elements. The objects in the destination array will have a lifetime
1255 * of the structure type itself, which is the lifetime of the context it
1258 void LLVMGetStructElementTypes(LLVMTypeRef StructTy
, LLVMTypeRef
*Dest
);
1261 * Get the type of the element at a given index in the structure.
1263 * @see llvm::StructType::getTypeAtIndex()
1265 LLVMTypeRef
LLVMStructGetTypeAtIndex(LLVMTypeRef StructTy
, unsigned i
);
1268 * Determine whether a structure is packed.
1270 * @see llvm::StructType::isPacked()
1272 LLVMBool
LLVMIsPackedStruct(LLVMTypeRef StructTy
);
1275 * Determine whether a structure is opaque.
1277 * @see llvm::StructType::isOpaque()
1279 LLVMBool
LLVMIsOpaqueStruct(LLVMTypeRef StructTy
);
1282 * Determine whether a structure is literal.
1284 * @see llvm::StructType::isLiteral()
1286 LLVMBool
LLVMIsLiteralStruct(LLVMTypeRef StructTy
);
1293 * @defgroup LLVMCCoreTypeSequential Sequential Types
1295 * Sequential types represents "arrays" of types. This is a super class
1296 * for array, vector, and pointer types.
1302 * Obtain the type of elements within a sequential type.
1304 * This works on array, vector, and pointer types.
1306 * @see llvm::SequentialType::getElementType()
1308 LLVMTypeRef
LLVMGetElementType(LLVMTypeRef Ty
);
1311 * Returns type's subtypes
1313 * @see llvm::Type::subtypes()
1315 void LLVMGetSubtypes(LLVMTypeRef Tp
, LLVMTypeRef
*Arr
);
1318 * Return the number of types in the derived type.
1320 * @see llvm::Type::getNumContainedTypes()
1322 unsigned LLVMGetNumContainedTypes(LLVMTypeRef Tp
);
1325 * Create a fixed size array type that refers to a specific type.
1327 * The created type will exist in the context that its element type
1330 * @see llvm::ArrayType::get()
1332 LLVMTypeRef
LLVMArrayType(LLVMTypeRef ElementType
, unsigned ElementCount
);
1335 * Obtain the length of an array type.
1337 * This only works on types that represent arrays.
1339 * @see llvm::ArrayType::getNumElements()
1341 unsigned LLVMGetArrayLength(LLVMTypeRef ArrayTy
);
1344 * Create a pointer type that points to a defined type.
1346 * The created type will exist in the context that its pointee type
1349 * @see llvm::PointerType::get()
1351 LLVMTypeRef
LLVMPointerType(LLVMTypeRef ElementType
, unsigned AddressSpace
);
1354 * Obtain the address space of a pointer type.
1356 * This only works on types that represent pointers.
1358 * @see llvm::PointerType::getAddressSpace()
1360 unsigned LLVMGetPointerAddressSpace(LLVMTypeRef PointerTy
);
1363 * Create a vector type that contains a defined type and has a specific
1364 * number of elements.
1366 * The created type will exist in the context thats its element type
1369 * @see llvm::VectorType::get()
1371 LLVMTypeRef
LLVMVectorType(LLVMTypeRef ElementType
, unsigned ElementCount
);
1374 * Obtain the number of elements in a vector type.
1376 * This only works on types that represent vectors.
1378 * @see llvm::VectorType::getNumElements()
1380 unsigned LLVMGetVectorSize(LLVMTypeRef VectorTy
);
1387 * @defgroup LLVMCCoreTypeOther Other Types
1393 * Create a void type in a context.
1395 LLVMTypeRef
LLVMVoidTypeInContext(LLVMContextRef C
);
1398 * Create a label type in a context.
1400 LLVMTypeRef
LLVMLabelTypeInContext(LLVMContextRef C
);
1403 * Create a X86 MMX type in a context.
1405 LLVMTypeRef
LLVMX86MMXTypeInContext(LLVMContextRef C
);
1408 * Create a token type in a context.
1410 LLVMTypeRef
LLVMTokenTypeInContext(LLVMContextRef C
);
1413 * Create a metadata type in a context.
1415 LLVMTypeRef
LLVMMetadataTypeInContext(LLVMContextRef C
);
1418 * These are similar to the above functions except they operate on the
1421 LLVMTypeRef
LLVMVoidType(void);
1422 LLVMTypeRef
LLVMLabelType(void);
1423 LLVMTypeRef
LLVMX86MMXType(void);
1434 * @defgroup LLVMCCoreValues Values
1436 * The bulk of LLVM's object model consists of values, which comprise a very
1437 * rich type hierarchy.
1439 * LLVMValueRef essentially represents llvm::Value. There is a rich
1440 * hierarchy of classes within this type. Depending on the instance
1441 * obtained, not all APIs are available.
1443 * Callers can determine the type of an LLVMValueRef by calling the
1444 * LLVMIsA* family of functions (e.g. LLVMIsAArgument()). These
1445 * functions are defined by a macro, so it isn't obvious which are
1446 * available by looking at the Doxygen source code. Instead, look at the
1447 * source definition of LLVM_FOR_EACH_VALUE_SUBCLASS and note the list
1448 * of value names given. These value names also correspond to classes in
1449 * the llvm::Value hierarchy.
1454 #define LLVM_FOR_EACH_VALUE_SUBCLASS(macro) \
1460 macro(BlockAddress) \
1461 macro(ConstantAggregateZero) \
1462 macro(ConstantArray) \
1463 macro(ConstantDataSequential) \
1464 macro(ConstantDataArray) \
1465 macro(ConstantDataVector) \
1466 macro(ConstantExpr) \
1468 macro(ConstantInt) \
1469 macro(ConstantPointerNull) \
1470 macro(ConstantStruct) \
1471 macro(ConstantTokenNone) \
1472 macro(ConstantVector) \
1473 macro(GlobalValue) \
1474 macro(GlobalAlias) \
1475 macro(GlobalIFunc) \
1476 macro(GlobalObject) \
1478 macro(GlobalVariable) \
1480 macro(Instruction) \
1481 macro(BinaryOperator) \
1483 macro(IntrinsicInst) \
1484 macro(DbgInfoIntrinsic) \
1485 macro(DbgVariableIntrinsic) \
1486 macro(DbgDeclareInst) \
1487 macro(DbgLabelInst) \
1488 macro(MemIntrinsic) \
1490 macro(MemMoveInst) \
1495 macro(ExtractElementInst) \
1496 macro(GetElementPtrInst) \
1497 macro(InsertElementInst) \
1498 macro(InsertValueInst) \
1499 macro(LandingPadInst) \
1502 macro(ShuffleVectorInst) \
1504 macro(TerminatorInst) \
1506 macro(IndirectBrInst) \
1510 macro(UnreachableInst) \
1512 macro(CleanupReturnInst) \
1513 macro(CatchReturnInst) \
1514 macro(FuncletPadInst) \
1515 macro(CatchPadInst) \
1516 macro(CleanupPadInst) \
1517 macro(UnaryInstruction) \
1520 macro(AddrSpaceCastInst) \
1521 macro(BitCastInst) \
1525 macro(FPTruncInst) \
1526 macro(IntToPtrInst) \
1527 macro(PtrToIntInst) \
1533 macro(ExtractValueInst) \
1538 * @defgroup LLVMCCoreValueGeneral General APIs
1540 * Functions in this section work on all LLVMValueRef instances,
1541 * regardless of their sub-type. They correspond to functions available
1548 * Obtain the type of a value.
1550 * @see llvm::Value::getType()
1552 LLVMTypeRef
LLVMTypeOf(LLVMValueRef Val
);
1555 * Obtain the enumerated type of a Value instance.
1557 * @see llvm::Value::getValueID()
1559 LLVMValueKind
LLVMGetValueKind(LLVMValueRef Val
);
1562 * Obtain the string name of a value.
1564 * @see llvm::Value::getName()
1566 const char *LLVMGetValueName2(LLVMValueRef Val
, size_t *Length
);
1569 * Set the string name of a value.
1571 * @see llvm::Value::setName()
1573 void LLVMSetValueName2(LLVMValueRef Val
, const char *Name
, size_t NameLen
);
1576 * Dump a representation of a value to stderr.
1578 * @see llvm::Value::dump()
1580 void LLVMDumpValue(LLVMValueRef Val
);
1583 * Return a string representation of the value. Use
1584 * LLVMDisposeMessage to free the string.
1586 * @see llvm::Value::print()
1588 char *LLVMPrintValueToString(LLVMValueRef Val
);
1591 * Replace all uses of a value with another one.
1593 * @see llvm::Value::replaceAllUsesWith()
1595 void LLVMReplaceAllUsesWith(LLVMValueRef OldVal
, LLVMValueRef NewVal
);
1598 * Determine whether the specified value instance is constant.
1600 LLVMBool
LLVMIsConstant(LLVMValueRef Val
);
1603 * Determine whether a value instance is undefined.
1605 LLVMBool
LLVMIsUndef(LLVMValueRef Val
);
1608 * Convert value instances between types.
1610 * Internally, an LLVMValueRef is "pinned" to a specific type. This
1611 * series of functions allows you to cast an instance to a specific
1614 * If the cast is not valid for the specified type, NULL is returned.
1616 * @see llvm::dyn_cast_or_null<>
1618 #define LLVM_DECLARE_VALUE_CAST(name) \
1619 LLVMValueRef LLVMIsA##name(LLVMValueRef Val);
1620 LLVM_FOR_EACH_VALUE_SUBCLASS(LLVM_DECLARE_VALUE_CAST
)
1622 LLVMValueRef
LLVMIsAMDNode(LLVMValueRef Val
);
1623 LLVMValueRef
LLVMIsAMDString(LLVMValueRef Val
);
1625 /** Deprecated: Use LLVMGetValueName2 instead. */
1626 const char *LLVMGetValueName(LLVMValueRef Val
);
1627 /** Deprecated: Use LLVMSetValueName2 instead. */
1628 void LLVMSetValueName(LLVMValueRef Val
, const char *Name
);
1635 * @defgroup LLVMCCoreValueUses Usage
1637 * This module defines functions that allow you to inspect the uses of a
1640 * It is possible to obtain an LLVMUseRef for any LLVMValueRef instance.
1641 * Each LLVMUseRef (which corresponds to a llvm::Use instance) holds a
1642 * llvm::User and llvm::Value.
1648 * Obtain the first use of a value.
1650 * Uses are obtained in an iterator fashion. First, call this function
1651 * to obtain a reference to the first use. Then, call LLVMGetNextUse()
1652 * on that instance and all subsequently obtained instances until
1653 * LLVMGetNextUse() returns NULL.
1655 * @see llvm::Value::use_begin()
1657 LLVMUseRef
LLVMGetFirstUse(LLVMValueRef Val
);
1660 * Obtain the next use of a value.
1662 * This effectively advances the iterator. It returns NULL if you are on
1663 * the final use and no more are available.
1665 LLVMUseRef
LLVMGetNextUse(LLVMUseRef U
);
1668 * Obtain the user value for a user.
1670 * The returned value corresponds to a llvm::User type.
1672 * @see llvm::Use::getUser()
1674 LLVMValueRef
LLVMGetUser(LLVMUseRef U
);
1677 * Obtain the value this use corresponds to.
1679 * @see llvm::Use::get().
1681 LLVMValueRef
LLVMGetUsedValue(LLVMUseRef U
);
1688 * @defgroup LLVMCCoreValueUser User value
1690 * Function in this group pertain to LLVMValueRef instances that descent
1691 * from llvm::User. This includes constants, instructions, and
1698 * Obtain an operand at a specific index in a llvm::User value.
1700 * @see llvm::User::getOperand()
1702 LLVMValueRef
LLVMGetOperand(LLVMValueRef Val
, unsigned Index
);
1705 * Obtain the use of an operand at a specific index in a llvm::User value.
1707 * @see llvm::User::getOperandUse()
1709 LLVMUseRef
LLVMGetOperandUse(LLVMValueRef Val
, unsigned Index
);
1712 * Set an operand at a specific index in a llvm::User value.
1714 * @see llvm::User::setOperand()
1716 void LLVMSetOperand(LLVMValueRef User
, unsigned Index
, LLVMValueRef Val
);
1719 * Obtain the number of operands in a llvm::User value.
1721 * @see llvm::User::getNumOperands()
1723 int LLVMGetNumOperands(LLVMValueRef Val
);
1730 * @defgroup LLVMCCoreValueConstant Constants
1732 * This section contains APIs for interacting with LLVMValueRef that
1733 * correspond to llvm::Constant instances.
1735 * These functions will work for any LLVMValueRef in the llvm::Constant
1742 * Obtain a constant value referring to the null instance of a type.
1744 * @see llvm::Constant::getNullValue()
1746 LLVMValueRef
LLVMConstNull(LLVMTypeRef Ty
); /* all zeroes */
1749 * Obtain a constant value referring to the instance of a type
1750 * consisting of all ones.
1752 * This is only valid for integer types.
1754 * @see llvm::Constant::getAllOnesValue()
1756 LLVMValueRef
LLVMConstAllOnes(LLVMTypeRef Ty
);
1759 * Obtain a constant value referring to an undefined value of a type.
1761 * @see llvm::UndefValue::get()
1763 LLVMValueRef
LLVMGetUndef(LLVMTypeRef Ty
);
1766 * Determine whether a value instance is null.
1768 * @see llvm::Constant::isNullValue()
1770 LLVMBool
LLVMIsNull(LLVMValueRef Val
);
1773 * Obtain a constant that is a constant pointer pointing to NULL for a
1776 LLVMValueRef
LLVMConstPointerNull(LLVMTypeRef Ty
);
1779 * @defgroup LLVMCCoreValueConstantScalar Scalar constants
1781 * Functions in this group model LLVMValueRef instances that correspond
1782 * to constants referring to scalar types.
1784 * For integer types, the LLVMTypeRef parameter should correspond to a
1785 * llvm::IntegerType instance and the returned LLVMValueRef will
1786 * correspond to a llvm::ConstantInt.
1788 * For floating point types, the LLVMTypeRef returned corresponds to a
1795 * Obtain a constant value for an integer type.
1797 * The returned value corresponds to a llvm::ConstantInt.
1799 * @see llvm::ConstantInt::get()
1801 * @param IntTy Integer type to obtain value of.
1802 * @param N The value the returned instance should refer to.
1803 * @param SignExtend Whether to sign extend the produced value.
1805 LLVMValueRef
LLVMConstInt(LLVMTypeRef IntTy
, unsigned long long N
,
1806 LLVMBool SignExtend
);
1809 * Obtain a constant value for an integer of arbitrary precision.
1811 * @see llvm::ConstantInt::get()
1813 LLVMValueRef
LLVMConstIntOfArbitraryPrecision(LLVMTypeRef IntTy
,
1815 const uint64_t Words
[]);
1818 * Obtain a constant value for an integer parsed from a string.
1820 * A similar API, LLVMConstIntOfStringAndSize is also available. If the
1821 * string's length is available, it is preferred to call that function
1824 * @see llvm::ConstantInt::get()
1826 LLVMValueRef
LLVMConstIntOfString(LLVMTypeRef IntTy
, const char *Text
,
1830 * Obtain a constant value for an integer parsed from a string with
1833 * @see llvm::ConstantInt::get()
1835 LLVMValueRef
LLVMConstIntOfStringAndSize(LLVMTypeRef IntTy
, const char *Text
,
1836 unsigned SLen
, uint8_t Radix
);
1839 * Obtain a constant value referring to a double floating point value.
1841 LLVMValueRef
LLVMConstReal(LLVMTypeRef RealTy
, double N
);
1844 * Obtain a constant for a floating point value parsed from a string.
1846 * A similar API, LLVMConstRealOfStringAndSize is also available. It
1847 * should be used if the input string's length is known.
1849 LLVMValueRef
LLVMConstRealOfString(LLVMTypeRef RealTy
, const char *Text
);
1852 * Obtain a constant for a floating point value parsed from a string.
1854 LLVMValueRef
LLVMConstRealOfStringAndSize(LLVMTypeRef RealTy
, const char *Text
,
1858 * Obtain the zero extended value for an integer constant value.
1860 * @see llvm::ConstantInt::getZExtValue()
1862 unsigned long long LLVMConstIntGetZExtValue(LLVMValueRef ConstantVal
);
1865 * Obtain the sign extended value for an integer constant value.
1867 * @see llvm::ConstantInt::getSExtValue()
1869 long long LLVMConstIntGetSExtValue(LLVMValueRef ConstantVal
);
1872 * Obtain the double value for an floating point constant value.
1873 * losesInfo indicates if some precision was lost in the conversion.
1875 * @see llvm::ConstantFP::getDoubleValue
1877 double LLVMConstRealGetDouble(LLVMValueRef ConstantVal
, LLVMBool
*losesInfo
);
1884 * @defgroup LLVMCCoreValueConstantComposite Composite Constants
1886 * Functions in this group operate on composite constants.
1892 * Create a ConstantDataSequential and initialize it with a string.
1894 * @see llvm::ConstantDataArray::getString()
1896 LLVMValueRef
LLVMConstStringInContext(LLVMContextRef C
, const char *Str
,
1897 unsigned Length
, LLVMBool DontNullTerminate
);
1900 * Create a ConstantDataSequential with string content in the global context.
1902 * This is the same as LLVMConstStringInContext except it operates on the
1905 * @see LLVMConstStringInContext()
1906 * @see llvm::ConstantDataArray::getString()
1908 LLVMValueRef
LLVMConstString(const char *Str
, unsigned Length
,
1909 LLVMBool DontNullTerminate
);
1912 * Returns true if the specified constant is an array of i8.
1914 * @see ConstantDataSequential::getAsString()
1916 LLVMBool
LLVMIsConstantString(LLVMValueRef c
);
1919 * Get the given constant data sequential as a string.
1921 * @see ConstantDataSequential::getAsString()
1923 const char *LLVMGetAsString(LLVMValueRef c
, size_t *Length
);
1926 * Create an anonymous ConstantStruct with the specified values.
1928 * @see llvm::ConstantStruct::getAnon()
1930 LLVMValueRef
LLVMConstStructInContext(LLVMContextRef C
,
1931 LLVMValueRef
*ConstantVals
,
1932 unsigned Count
, LLVMBool Packed
);
1935 * Create a ConstantStruct in the global Context.
1937 * This is the same as LLVMConstStructInContext except it operates on the
1940 * @see LLVMConstStructInContext()
1942 LLVMValueRef
LLVMConstStruct(LLVMValueRef
*ConstantVals
, unsigned Count
,
1946 * Create a ConstantArray from values.
1948 * @see llvm::ConstantArray::get()
1950 LLVMValueRef
LLVMConstArray(LLVMTypeRef ElementTy
,
1951 LLVMValueRef
*ConstantVals
, unsigned Length
);
1954 * Create a non-anonymous ConstantStruct from values.
1956 * @see llvm::ConstantStruct::get()
1958 LLVMValueRef
LLVMConstNamedStruct(LLVMTypeRef StructTy
,
1959 LLVMValueRef
*ConstantVals
,
1963 * Get an element at specified index as a constant.
1965 * @see ConstantDataSequential::getElementAsConstant()
1967 LLVMValueRef
LLVMGetElementAsConstant(LLVMValueRef C
, unsigned idx
);
1970 * Create a ConstantVector from values.
1972 * @see llvm::ConstantVector::get()
1974 LLVMValueRef
LLVMConstVector(LLVMValueRef
*ScalarConstantVals
, unsigned Size
);
1981 * @defgroup LLVMCCoreValueConstantExpressions Constant Expressions
1983 * Functions in this group correspond to APIs on llvm::ConstantExpr.
1985 * @see llvm::ConstantExpr.
1989 LLVMOpcode
LLVMGetConstOpcode(LLVMValueRef ConstantVal
);
1990 LLVMValueRef
LLVMAlignOf(LLVMTypeRef Ty
);
1991 LLVMValueRef
LLVMSizeOf(LLVMTypeRef Ty
);
1992 LLVMValueRef
LLVMConstNeg(LLVMValueRef ConstantVal
);
1993 LLVMValueRef
LLVMConstNSWNeg(LLVMValueRef ConstantVal
);
1994 LLVMValueRef
LLVMConstNUWNeg(LLVMValueRef ConstantVal
);
1995 LLVMValueRef
LLVMConstFNeg(LLVMValueRef ConstantVal
);
1996 LLVMValueRef
LLVMConstNot(LLVMValueRef ConstantVal
);
1997 LLVMValueRef
LLVMConstAdd(LLVMValueRef LHSConstant
, LLVMValueRef RHSConstant
);
1998 LLVMValueRef
LLVMConstNSWAdd(LLVMValueRef LHSConstant
, LLVMValueRef RHSConstant
);
1999 LLVMValueRef
LLVMConstNUWAdd(LLVMValueRef LHSConstant
, LLVMValueRef RHSConstant
);
2000 LLVMValueRef
LLVMConstFAdd(LLVMValueRef LHSConstant
, LLVMValueRef RHSConstant
);
2001 LLVMValueRef
LLVMConstSub(LLVMValueRef LHSConstant
, LLVMValueRef RHSConstant
);
2002 LLVMValueRef
LLVMConstNSWSub(LLVMValueRef LHSConstant
, LLVMValueRef RHSConstant
);
2003 LLVMValueRef
LLVMConstNUWSub(LLVMValueRef LHSConstant
, LLVMValueRef RHSConstant
);
2004 LLVMValueRef
LLVMConstFSub(LLVMValueRef LHSConstant
, LLVMValueRef RHSConstant
);
2005 LLVMValueRef
LLVMConstMul(LLVMValueRef LHSConstant
, LLVMValueRef RHSConstant
);
2006 LLVMValueRef
LLVMConstNSWMul(LLVMValueRef LHSConstant
, LLVMValueRef RHSConstant
);
2007 LLVMValueRef
LLVMConstNUWMul(LLVMValueRef LHSConstant
, LLVMValueRef RHSConstant
);
2008 LLVMValueRef
LLVMConstFMul(LLVMValueRef LHSConstant
, LLVMValueRef RHSConstant
);
2009 LLVMValueRef
LLVMConstUDiv(LLVMValueRef LHSConstant
, LLVMValueRef RHSConstant
);
2010 LLVMValueRef
LLVMConstExactUDiv(LLVMValueRef LHSConstant
, LLVMValueRef RHSConstant
);
2011 LLVMValueRef
LLVMConstSDiv(LLVMValueRef LHSConstant
, LLVMValueRef RHSConstant
);
2012 LLVMValueRef
LLVMConstExactSDiv(LLVMValueRef LHSConstant
, LLVMValueRef RHSConstant
);
2013 LLVMValueRef
LLVMConstFDiv(LLVMValueRef LHSConstant
, LLVMValueRef RHSConstant
);
2014 LLVMValueRef
LLVMConstURem(LLVMValueRef LHSConstant
, LLVMValueRef RHSConstant
);
2015 LLVMValueRef
LLVMConstSRem(LLVMValueRef LHSConstant
, LLVMValueRef RHSConstant
);
2016 LLVMValueRef
LLVMConstFRem(LLVMValueRef LHSConstant
, LLVMValueRef RHSConstant
);
2017 LLVMValueRef
LLVMConstAnd(LLVMValueRef LHSConstant
, LLVMValueRef RHSConstant
);
2018 LLVMValueRef
LLVMConstOr(LLVMValueRef LHSConstant
, LLVMValueRef RHSConstant
);
2019 LLVMValueRef
LLVMConstXor(LLVMValueRef LHSConstant
, LLVMValueRef RHSConstant
);
2020 LLVMValueRef
LLVMConstICmp(LLVMIntPredicate Predicate
,
2021 LLVMValueRef LHSConstant
, LLVMValueRef RHSConstant
);
2022 LLVMValueRef
LLVMConstFCmp(LLVMRealPredicate Predicate
,
2023 LLVMValueRef LHSConstant
, LLVMValueRef RHSConstant
);
2024 LLVMValueRef
LLVMConstShl(LLVMValueRef LHSConstant
, LLVMValueRef RHSConstant
);
2025 LLVMValueRef
LLVMConstLShr(LLVMValueRef LHSConstant
, LLVMValueRef RHSConstant
);
2026 LLVMValueRef
LLVMConstAShr(LLVMValueRef LHSConstant
, LLVMValueRef RHSConstant
);
2027 LLVMValueRef
LLVMConstGEP(LLVMValueRef ConstantVal
,
2028 LLVMValueRef
*ConstantIndices
, unsigned NumIndices
);
2029 LLVMValueRef
LLVMConstInBoundsGEP(LLVMValueRef ConstantVal
,
2030 LLVMValueRef
*ConstantIndices
,
2031 unsigned NumIndices
);
2032 LLVMValueRef
LLVMConstTrunc(LLVMValueRef ConstantVal
, LLVMTypeRef ToType
);
2033 LLVMValueRef
LLVMConstSExt(LLVMValueRef ConstantVal
, LLVMTypeRef ToType
);
2034 LLVMValueRef
LLVMConstZExt(LLVMValueRef ConstantVal
, LLVMTypeRef ToType
);
2035 LLVMValueRef
LLVMConstFPTrunc(LLVMValueRef ConstantVal
, LLVMTypeRef ToType
);
2036 LLVMValueRef
LLVMConstFPExt(LLVMValueRef ConstantVal
, LLVMTypeRef ToType
);
2037 LLVMValueRef
LLVMConstUIToFP(LLVMValueRef ConstantVal
, LLVMTypeRef ToType
);
2038 LLVMValueRef
LLVMConstSIToFP(LLVMValueRef ConstantVal
, LLVMTypeRef ToType
);
2039 LLVMValueRef
LLVMConstFPToUI(LLVMValueRef ConstantVal
, LLVMTypeRef ToType
);
2040 LLVMValueRef
LLVMConstFPToSI(LLVMValueRef ConstantVal
, LLVMTypeRef ToType
);
2041 LLVMValueRef
LLVMConstPtrToInt(LLVMValueRef ConstantVal
, LLVMTypeRef ToType
);
2042 LLVMValueRef
LLVMConstIntToPtr(LLVMValueRef ConstantVal
, LLVMTypeRef ToType
);
2043 LLVMValueRef
LLVMConstBitCast(LLVMValueRef ConstantVal
, LLVMTypeRef ToType
);
2044 LLVMValueRef
LLVMConstAddrSpaceCast(LLVMValueRef ConstantVal
, LLVMTypeRef ToType
);
2045 LLVMValueRef
LLVMConstZExtOrBitCast(LLVMValueRef ConstantVal
,
2046 LLVMTypeRef ToType
);
2047 LLVMValueRef
LLVMConstSExtOrBitCast(LLVMValueRef ConstantVal
,
2048 LLVMTypeRef ToType
);
2049 LLVMValueRef
LLVMConstTruncOrBitCast(LLVMValueRef ConstantVal
,
2050 LLVMTypeRef ToType
);
2051 LLVMValueRef
LLVMConstPointerCast(LLVMValueRef ConstantVal
,
2052 LLVMTypeRef ToType
);
2053 LLVMValueRef
LLVMConstIntCast(LLVMValueRef ConstantVal
, LLVMTypeRef ToType
,
2055 LLVMValueRef
LLVMConstFPCast(LLVMValueRef ConstantVal
, LLVMTypeRef ToType
);
2056 LLVMValueRef
LLVMConstSelect(LLVMValueRef ConstantCondition
,
2057 LLVMValueRef ConstantIfTrue
,
2058 LLVMValueRef ConstantIfFalse
);
2059 LLVMValueRef
LLVMConstExtractElement(LLVMValueRef VectorConstant
,
2060 LLVMValueRef IndexConstant
);
2061 LLVMValueRef
LLVMConstInsertElement(LLVMValueRef VectorConstant
,
2062 LLVMValueRef ElementValueConstant
,
2063 LLVMValueRef IndexConstant
);
2064 LLVMValueRef
LLVMConstShuffleVector(LLVMValueRef VectorAConstant
,
2065 LLVMValueRef VectorBConstant
,
2066 LLVMValueRef MaskConstant
);
2067 LLVMValueRef
LLVMConstExtractValue(LLVMValueRef AggConstant
, unsigned *IdxList
,
2069 LLVMValueRef
LLVMConstInsertValue(LLVMValueRef AggConstant
,
2070 LLVMValueRef ElementValueConstant
,
2071 unsigned *IdxList
, unsigned NumIdx
);
2072 LLVMValueRef
LLVMBlockAddress(LLVMValueRef F
, LLVMBasicBlockRef BB
);
2074 /** Deprecated: Use LLVMGetInlineAsm instead. */
2075 LLVMValueRef
LLVMConstInlineAsm(LLVMTypeRef Ty
,
2076 const char *AsmString
, const char *Constraints
,
2077 LLVMBool HasSideEffects
, LLVMBool IsAlignStack
);
2084 * @defgroup LLVMCCoreValueConstantGlobals Global Values
2086 * This group contains functions that operate on global values. Functions in
2087 * this group relate to functions in the llvm::GlobalValue class tree.
2089 * @see llvm::GlobalValue
2094 LLVMModuleRef
LLVMGetGlobalParent(LLVMValueRef Global
);
2095 LLVMBool
LLVMIsDeclaration(LLVMValueRef Global
);
2096 LLVMLinkage
LLVMGetLinkage(LLVMValueRef Global
);
2097 void LLVMSetLinkage(LLVMValueRef Global
, LLVMLinkage Linkage
);
2098 const char *LLVMGetSection(LLVMValueRef Global
);
2099 void LLVMSetSection(LLVMValueRef Global
, const char *Section
);
2100 LLVMVisibility
LLVMGetVisibility(LLVMValueRef Global
);
2101 void LLVMSetVisibility(LLVMValueRef Global
, LLVMVisibility Viz
);
2102 LLVMDLLStorageClass
LLVMGetDLLStorageClass(LLVMValueRef Global
);
2103 void LLVMSetDLLStorageClass(LLVMValueRef Global
, LLVMDLLStorageClass Class
);
2104 LLVMUnnamedAddr
LLVMGetUnnamedAddress(LLVMValueRef Global
);
2105 void LLVMSetUnnamedAddress(LLVMValueRef Global
, LLVMUnnamedAddr UnnamedAddr
);
2108 * Returns the "value type" of a global value. This differs from the formal
2109 * type of a global value which is always a pointer type.
2111 * @see llvm::GlobalValue::getValueType()
2113 LLVMTypeRef
LLVMGlobalGetValueType(LLVMValueRef Global
);
2115 /** Deprecated: Use LLVMGetUnnamedAddress instead. */
2116 LLVMBool
LLVMHasUnnamedAddr(LLVMValueRef Global
);
2117 /** Deprecated: Use LLVMSetUnnamedAddress instead. */
2118 void LLVMSetUnnamedAddr(LLVMValueRef Global
, LLVMBool HasUnnamedAddr
);
2121 * @defgroup LLVMCCoreValueWithAlignment Values with alignment
2123 * Functions in this group only apply to values with alignment, i.e.
2124 * global variables, load and store instructions.
2128 * Obtain the preferred alignment of the value.
2129 * @see llvm::AllocaInst::getAlignment()
2130 * @see llvm::LoadInst::getAlignment()
2131 * @see llvm::StoreInst::getAlignment()
2132 * @see llvm::GlobalValue::getAlignment()
2134 unsigned LLVMGetAlignment(LLVMValueRef V
);
2137 * Set the preferred alignment of the value.
2138 * @see llvm::AllocaInst::setAlignment()
2139 * @see llvm::LoadInst::setAlignment()
2140 * @see llvm::StoreInst::setAlignment()
2141 * @see llvm::GlobalValue::setAlignment()
2143 void LLVMSetAlignment(LLVMValueRef V
, unsigned Bytes
);
2146 * Sets a metadata attachment, erasing the existing metadata attachment if
2147 * it already exists for the given kind.
2149 * @see llvm::GlobalObject::setMetadata()
2151 void LLVMGlobalSetMetadata(LLVMValueRef Global
, unsigned Kind
,
2152 LLVMMetadataRef MD
);
2155 * Erases a metadata attachment of the given kind if it exists.
2157 * @see llvm::GlobalObject::eraseMetadata()
2159 void LLVMGlobalEraseMetadata(LLVMValueRef Global
, unsigned Kind
);
2162 * Removes all metadata attachments from this value.
2164 * @see llvm::GlobalObject::clearMetadata()
2166 void LLVMGlobalClearMetadata(LLVMValueRef Global
);
2169 * Retrieves an array of metadata entries representing the metadata attached to
2170 * this value. The caller is responsible for freeing this array by calling
2171 * \c LLVMDisposeValueMetadataEntries.
2173 * @see llvm::GlobalObject::getAllMetadata()
2175 LLVMValueMetadataEntry
*LLVMGlobalCopyAllMetadata(LLVMValueRef Value
,
2176 size_t *NumEntries
);
2179 * Destroys value metadata entries.
2181 void LLVMDisposeValueMetadataEntries(LLVMValueMetadataEntry
*Entries
);
2184 * Returns the kind of a value metadata entry at a specific index.
2186 unsigned LLVMValueMetadataEntriesGetKind(LLVMValueMetadataEntry
*Entries
,
2190 * Returns the underlying metadata node of a value metadata entry at a
2194 LLVMValueMetadataEntriesGetMetadata(LLVMValueMetadataEntry
*Entries
,
2202 * @defgroup LLVMCoreValueConstantGlobalVariable Global Variables
2204 * This group contains functions that operate on global variable values.
2206 * @see llvm::GlobalVariable
2210 LLVMValueRef
LLVMAddGlobal(LLVMModuleRef M
, LLVMTypeRef Ty
, const char *Name
);
2211 LLVMValueRef
LLVMAddGlobalInAddressSpace(LLVMModuleRef M
, LLVMTypeRef Ty
,
2213 unsigned AddressSpace
);
2214 LLVMValueRef
LLVMGetNamedGlobal(LLVMModuleRef M
, const char *Name
);
2215 LLVMValueRef
LLVMGetFirstGlobal(LLVMModuleRef M
);
2216 LLVMValueRef
LLVMGetLastGlobal(LLVMModuleRef M
);
2217 LLVMValueRef
LLVMGetNextGlobal(LLVMValueRef GlobalVar
);
2218 LLVMValueRef
LLVMGetPreviousGlobal(LLVMValueRef GlobalVar
);
2219 void LLVMDeleteGlobal(LLVMValueRef GlobalVar
);
2220 LLVMValueRef
LLVMGetInitializer(LLVMValueRef GlobalVar
);
2221 void LLVMSetInitializer(LLVMValueRef GlobalVar
, LLVMValueRef ConstantVal
);
2222 LLVMBool
LLVMIsThreadLocal(LLVMValueRef GlobalVar
);
2223 void LLVMSetThreadLocal(LLVMValueRef GlobalVar
, LLVMBool IsThreadLocal
);
2224 LLVMBool
LLVMIsGlobalConstant(LLVMValueRef GlobalVar
);
2225 void LLVMSetGlobalConstant(LLVMValueRef GlobalVar
, LLVMBool IsConstant
);
2226 LLVMThreadLocalMode
LLVMGetThreadLocalMode(LLVMValueRef GlobalVar
);
2227 void LLVMSetThreadLocalMode(LLVMValueRef GlobalVar
, LLVMThreadLocalMode Mode
);
2228 LLVMBool
LLVMIsExternallyInitialized(LLVMValueRef GlobalVar
);
2229 void LLVMSetExternallyInitialized(LLVMValueRef GlobalVar
, LLVMBool IsExtInit
);
2236 * @defgroup LLVMCoreValueConstantGlobalAlias Global Aliases
2238 * This group contains function that operate on global alias values.
2240 * @see llvm::GlobalAlias
2244 LLVMValueRef
LLVMAddAlias(LLVMModuleRef M
, LLVMTypeRef Ty
, LLVMValueRef Aliasee
,
2248 * Obtain a GlobalAlias value from a Module by its name.
2250 * The returned value corresponds to a llvm::GlobalAlias value.
2252 * @see llvm::Module::getNamedAlias()
2254 LLVMValueRef
LLVMGetNamedGlobalAlias(LLVMModuleRef M
,
2255 const char *Name
, size_t NameLen
);
2258 * Obtain an iterator to the first GlobalAlias in a Module.
2260 * @see llvm::Module::alias_begin()
2262 LLVMValueRef
LLVMGetFirstGlobalAlias(LLVMModuleRef M
);
2265 * Obtain an iterator to the last GlobalAlias in a Module.
2267 * @see llvm::Module::alias_end()
2269 LLVMValueRef
LLVMGetLastGlobalAlias(LLVMModuleRef M
);
2272 * Advance a GlobalAlias iterator to the next GlobalAlias.
2274 * Returns NULL if the iterator was already at the end and there are no more
2277 LLVMValueRef
LLVMGetNextGlobalAlias(LLVMValueRef GA
);
2280 * Decrement a GlobalAlias iterator to the previous GlobalAlias.
2282 * Returns NULL if the iterator was already at the beginning and there are
2283 * no previous global aliases.
2285 LLVMValueRef
LLVMGetPreviousGlobalAlias(LLVMValueRef GA
);
2288 * Retrieve the target value of an alias.
2290 LLVMValueRef
LLVMAliasGetAliasee(LLVMValueRef Alias
);
2293 * Set the target value of an alias.
2295 void LLVMAliasSetAliasee(LLVMValueRef Alias
, LLVMValueRef Aliasee
);
2302 * @defgroup LLVMCCoreValueFunction Function values
2304 * Functions in this group operate on LLVMValueRef instances that
2305 * correspond to llvm::Function instances.
2307 * @see llvm::Function
2313 * Remove a function from its containing module and deletes it.
2315 * @see llvm::Function::eraseFromParent()
2317 void LLVMDeleteFunction(LLVMValueRef Fn
);
2320 * Check whether the given function has a personality function.
2322 * @see llvm::Function::hasPersonalityFn()
2324 LLVMBool
LLVMHasPersonalityFn(LLVMValueRef Fn
);
2327 * Obtain the personality function attached to the function.
2329 * @see llvm::Function::getPersonalityFn()
2331 LLVMValueRef
LLVMGetPersonalityFn(LLVMValueRef Fn
);
2334 * Set the personality function attached to the function.
2336 * @see llvm::Function::setPersonalityFn()
2338 void LLVMSetPersonalityFn(LLVMValueRef Fn
, LLVMValueRef PersonalityFn
);
2341 * Obtain the ID number from a function instance.
2343 * @see llvm::Function::getIntrinsicID()
2345 unsigned LLVMGetIntrinsicID(LLVMValueRef Fn
);
2348 * Obtain the calling function of a function.
2350 * The returned value corresponds to the LLVMCallConv enumeration.
2352 * @see llvm::Function::getCallingConv()
2354 unsigned LLVMGetFunctionCallConv(LLVMValueRef Fn
);
2357 * Set the calling convention of a function.
2359 * @see llvm::Function::setCallingConv()
2361 * @param Fn Function to operate on
2362 * @param CC LLVMCallConv to set calling convention to
2364 void LLVMSetFunctionCallConv(LLVMValueRef Fn
, unsigned CC
);
2367 * Obtain the name of the garbage collector to use during code
2370 * @see llvm::Function::getGC()
2372 const char *LLVMGetGC(LLVMValueRef Fn
);
2375 * Define the garbage collector to use during code generation.
2377 * @see llvm::Function::setGC()
2379 void LLVMSetGC(LLVMValueRef Fn
, const char *Name
);
2382 * Add an attribute to a function.
2384 * @see llvm::Function::addAttribute()
2386 void LLVMAddAttributeAtIndex(LLVMValueRef F
, LLVMAttributeIndex Idx
,
2387 LLVMAttributeRef A
);
2388 unsigned LLVMGetAttributeCountAtIndex(LLVMValueRef F
, LLVMAttributeIndex Idx
);
2389 void LLVMGetAttributesAtIndex(LLVMValueRef F
, LLVMAttributeIndex Idx
,
2390 LLVMAttributeRef
*Attrs
);
2391 LLVMAttributeRef
LLVMGetEnumAttributeAtIndex(LLVMValueRef F
,
2392 LLVMAttributeIndex Idx
,
2394 LLVMAttributeRef
LLVMGetStringAttributeAtIndex(LLVMValueRef F
,
2395 LLVMAttributeIndex Idx
,
2396 const char *K
, unsigned KLen
);
2397 void LLVMRemoveEnumAttributeAtIndex(LLVMValueRef F
, LLVMAttributeIndex Idx
,
2399 void LLVMRemoveStringAttributeAtIndex(LLVMValueRef F
, LLVMAttributeIndex Idx
,
2400 const char *K
, unsigned KLen
);
2403 * Add a target-dependent attribute to a function
2404 * @see llvm::AttrBuilder::addAttribute()
2406 void LLVMAddTargetDependentFunctionAttr(LLVMValueRef Fn
, const char *A
,
2410 * @defgroup LLVMCCoreValueFunctionParameters Function Parameters
2412 * Functions in this group relate to arguments/parameters on functions.
2414 * Functions in this group expect LLVMValueRef instances that correspond
2415 * to llvm::Function instances.
2421 * Obtain the number of parameters in a function.
2423 * @see llvm::Function::arg_size()
2425 unsigned LLVMCountParams(LLVMValueRef Fn
);
2428 * Obtain the parameters in a function.
2430 * The takes a pointer to a pre-allocated array of LLVMValueRef that is
2431 * at least LLVMCountParams() long. This array will be filled with
2432 * LLVMValueRef instances which correspond to the parameters the
2433 * function receives. Each LLVMValueRef corresponds to a llvm::Argument
2436 * @see llvm::Function::arg_begin()
2438 void LLVMGetParams(LLVMValueRef Fn
, LLVMValueRef
*Params
);
2441 * Obtain the parameter at the specified index.
2443 * Parameters are indexed from 0.
2445 * @see llvm::Function::arg_begin()
2447 LLVMValueRef
LLVMGetParam(LLVMValueRef Fn
, unsigned Index
);
2450 * Obtain the function to which this argument belongs.
2452 * Unlike other functions in this group, this one takes an LLVMValueRef
2453 * that corresponds to a llvm::Attribute.
2455 * The returned LLVMValueRef is the llvm::Function to which this
2458 LLVMValueRef
LLVMGetParamParent(LLVMValueRef Inst
);
2461 * Obtain the first parameter to a function.
2463 * @see llvm::Function::arg_begin()
2465 LLVMValueRef
LLVMGetFirstParam(LLVMValueRef Fn
);
2468 * Obtain the last parameter to a function.
2470 * @see llvm::Function::arg_end()
2472 LLVMValueRef
LLVMGetLastParam(LLVMValueRef Fn
);
2475 * Obtain the next parameter to a function.
2477 * This takes an LLVMValueRef obtained from LLVMGetFirstParam() (which is
2478 * actually a wrapped iterator) and obtains the next parameter from the
2479 * underlying iterator.
2481 LLVMValueRef
LLVMGetNextParam(LLVMValueRef Arg
);
2484 * Obtain the previous parameter to a function.
2486 * This is the opposite of LLVMGetNextParam().
2488 LLVMValueRef
LLVMGetPreviousParam(LLVMValueRef Arg
);
2491 * Set the alignment for a function parameter.
2493 * @see llvm::Argument::addAttr()
2494 * @see llvm::AttrBuilder::addAlignmentAttr()
2496 void LLVMSetParamAlignment(LLVMValueRef Arg
, unsigned Align
);
2515 * @defgroup LLVMCCoreValueMetadata Metadata
2521 * Obtain a MDString value from a context.
2523 * The returned instance corresponds to the llvm::MDString class.
2525 * The instance is specified by string data of a specified length. The
2526 * string content is copied, so the backing memory can be freed after
2527 * this function returns.
2529 LLVMValueRef
LLVMMDStringInContext(LLVMContextRef C
, const char *Str
,
2533 * Obtain a MDString value from the global context.
2535 LLVMValueRef
LLVMMDString(const char *Str
, unsigned SLen
);
2538 * Obtain a MDNode value from a context.
2540 * The returned value corresponds to the llvm::MDNode class.
2542 LLVMValueRef
LLVMMDNodeInContext(LLVMContextRef C
, LLVMValueRef
*Vals
,
2546 * Obtain a MDNode value from the global context.
2548 LLVMValueRef
LLVMMDNode(LLVMValueRef
*Vals
, unsigned Count
);
2551 * Obtain a Metadata as a Value.
2553 LLVMValueRef
LLVMMetadataAsValue(LLVMContextRef C
, LLVMMetadataRef MD
);
2556 * Obtain a Value as a Metadata.
2558 LLVMMetadataRef
LLVMValueAsMetadata(LLVMValueRef Val
);
2561 * Obtain the underlying string from a MDString value.
2563 * @param V Instance to obtain string from.
2564 * @param Length Memory address which will hold length of returned string.
2565 * @return String data in MDString.
2567 const char *LLVMGetMDString(LLVMValueRef V
, unsigned *Length
);
2570 * Obtain the number of operands from an MDNode value.
2572 * @param V MDNode to get number of operands from.
2573 * @return Number of operands of the MDNode.
2575 unsigned LLVMGetMDNodeNumOperands(LLVMValueRef V
);
2578 * Obtain the given MDNode's operands.
2580 * The passed LLVMValueRef pointer should point to enough memory to hold all of
2581 * the operands of the given MDNode (see LLVMGetMDNodeNumOperands) as
2582 * LLVMValueRefs. This memory will be populated with the LLVMValueRefs of the
2583 * MDNode's operands.
2585 * @param V MDNode to get the operands from.
2586 * @param Dest Destination array for operands.
2588 void LLVMGetMDNodeOperands(LLVMValueRef V
, LLVMValueRef
*Dest
);
2595 * @defgroup LLVMCCoreValueBasicBlock Basic Block
2597 * A basic block represents a single entry single exit section of code.
2598 * Basic blocks contain a list of instructions which form the body of
2601 * Basic blocks belong to functions. They have the type of label.
2603 * Basic blocks are themselves values. However, the C API models them as
2604 * LLVMBasicBlockRef.
2606 * @see llvm::BasicBlock
2612 * Convert a basic block instance to a value type.
2614 LLVMValueRef
LLVMBasicBlockAsValue(LLVMBasicBlockRef BB
);
2617 * Determine whether an LLVMValueRef is itself a basic block.
2619 LLVMBool
LLVMValueIsBasicBlock(LLVMValueRef Val
);
2622 * Convert an LLVMValueRef to an LLVMBasicBlockRef instance.
2624 LLVMBasicBlockRef
LLVMValueAsBasicBlock(LLVMValueRef Val
);
2627 * Obtain the string name of a basic block.
2629 const char *LLVMGetBasicBlockName(LLVMBasicBlockRef BB
);
2632 * Obtain the function to which a basic block belongs.
2634 * @see llvm::BasicBlock::getParent()
2636 LLVMValueRef
LLVMGetBasicBlockParent(LLVMBasicBlockRef BB
);
2639 * Obtain the terminator instruction for a basic block.
2641 * If the basic block does not have a terminator (it is not well-formed
2642 * if it doesn't), then NULL is returned.
2644 * The returned LLVMValueRef corresponds to a llvm::TerminatorInst.
2646 * @see llvm::BasicBlock::getTerminator()
2648 LLVMValueRef
LLVMGetBasicBlockTerminator(LLVMBasicBlockRef BB
);
2651 * Obtain the number of basic blocks in a function.
2653 * @param Fn Function value to operate on.
2655 unsigned LLVMCountBasicBlocks(LLVMValueRef Fn
);
2658 * Obtain all of the basic blocks in a function.
2660 * This operates on a function value. The BasicBlocks parameter is a
2661 * pointer to a pre-allocated array of LLVMBasicBlockRef of at least
2662 * LLVMCountBasicBlocks() in length. This array is populated with
2663 * LLVMBasicBlockRef instances.
2665 void LLVMGetBasicBlocks(LLVMValueRef Fn
, LLVMBasicBlockRef
*BasicBlocks
);
2668 * Obtain the first basic block in a function.
2670 * The returned basic block can be used as an iterator. You will likely
2671 * eventually call into LLVMGetNextBasicBlock() with it.
2673 * @see llvm::Function::begin()
2675 LLVMBasicBlockRef
LLVMGetFirstBasicBlock(LLVMValueRef Fn
);
2678 * Obtain the last basic block in a function.
2680 * @see llvm::Function::end()
2682 LLVMBasicBlockRef
LLVMGetLastBasicBlock(LLVMValueRef Fn
);
2685 * Advance a basic block iterator.
2687 LLVMBasicBlockRef
LLVMGetNextBasicBlock(LLVMBasicBlockRef BB
);
2690 * Go backwards in a basic block iterator.
2692 LLVMBasicBlockRef
LLVMGetPreviousBasicBlock(LLVMBasicBlockRef BB
);
2695 * Obtain the basic block that corresponds to the entry point of a
2698 * @see llvm::Function::getEntryBlock()
2700 LLVMBasicBlockRef
LLVMGetEntryBasicBlock(LLVMValueRef Fn
);
2703 * Append a basic block to the end of a function.
2705 * @see llvm::BasicBlock::Create()
2707 LLVMBasicBlockRef
LLVMAppendBasicBlockInContext(LLVMContextRef C
,
2712 * Append a basic block to the end of a function using the global
2715 * @see llvm::BasicBlock::Create()
2717 LLVMBasicBlockRef
LLVMAppendBasicBlock(LLVMValueRef Fn
, const char *Name
);
2720 * Insert a basic block in a function before another basic block.
2722 * The function to add to is determined by the function of the
2723 * passed basic block.
2725 * @see llvm::BasicBlock::Create()
2727 LLVMBasicBlockRef
LLVMInsertBasicBlockInContext(LLVMContextRef C
,
2728 LLVMBasicBlockRef BB
,
2732 * Insert a basic block in a function using the global context.
2734 * @see llvm::BasicBlock::Create()
2736 LLVMBasicBlockRef
LLVMInsertBasicBlock(LLVMBasicBlockRef InsertBeforeBB
,
2740 * Remove a basic block from a function and delete it.
2742 * This deletes the basic block from its containing function and deletes
2743 * the basic block itself.
2745 * @see llvm::BasicBlock::eraseFromParent()
2747 void LLVMDeleteBasicBlock(LLVMBasicBlockRef BB
);
2750 * Remove a basic block from a function.
2752 * This deletes the basic block from its containing function but keep
2753 * the basic block alive.
2755 * @see llvm::BasicBlock::removeFromParent()
2757 void LLVMRemoveBasicBlockFromParent(LLVMBasicBlockRef BB
);
2760 * Move a basic block to before another one.
2762 * @see llvm::BasicBlock::moveBefore()
2764 void LLVMMoveBasicBlockBefore(LLVMBasicBlockRef BB
, LLVMBasicBlockRef MovePos
);
2767 * Move a basic block to after another one.
2769 * @see llvm::BasicBlock::moveAfter()
2771 void LLVMMoveBasicBlockAfter(LLVMBasicBlockRef BB
, LLVMBasicBlockRef MovePos
);
2774 * Obtain the first instruction in a basic block.
2776 * The returned LLVMValueRef corresponds to a llvm::Instruction
2779 LLVMValueRef
LLVMGetFirstInstruction(LLVMBasicBlockRef BB
);
2782 * Obtain the last instruction in a basic block.
2784 * The returned LLVMValueRef corresponds to an LLVM:Instruction.
2786 LLVMValueRef
LLVMGetLastInstruction(LLVMBasicBlockRef BB
);
2793 * @defgroup LLVMCCoreValueInstruction Instructions
2795 * Functions in this group relate to the inspection and manipulation of
2796 * individual instructions.
2798 * In the C++ API, an instruction is modeled by llvm::Instruction. This
2799 * class has a large number of descendents. llvm::Instruction is a
2800 * llvm::Value and in the C API, instructions are modeled by
2803 * This group also contains sub-groups which operate on specific
2804 * llvm::Instruction types, e.g. llvm::CallInst.
2810 * Determine whether an instruction has any metadata attached.
2812 int LLVMHasMetadata(LLVMValueRef Val
);
2815 * Return metadata associated with an instruction value.
2817 LLVMValueRef
LLVMGetMetadata(LLVMValueRef Val
, unsigned KindID
);
2820 * Set metadata associated with an instruction value.
2822 void LLVMSetMetadata(LLVMValueRef Val
, unsigned KindID
, LLVMValueRef Node
);
2825 * Returns the metadata associated with an instruction value, but filters out
2826 * all the debug locations.
2828 * @see llvm::Instruction::getAllMetadataOtherThanDebugLoc()
2830 LLVMValueMetadataEntry
*
2831 LLVMInstructionGetAllMetadataOtherThanDebugLoc(LLVMValueRef Instr
,
2832 size_t *NumEntries
);
2835 * Obtain the basic block to which an instruction belongs.
2837 * @see llvm::Instruction::getParent()
2839 LLVMBasicBlockRef
LLVMGetInstructionParent(LLVMValueRef Inst
);
2842 * Obtain the instruction that occurs after the one specified.
2844 * The next instruction will be from the same basic block.
2846 * If this is the last instruction in a basic block, NULL will be
2849 LLVMValueRef
LLVMGetNextInstruction(LLVMValueRef Inst
);
2852 * Obtain the instruction that occurred before this one.
2854 * If the instruction is the first instruction in a basic block, NULL
2857 LLVMValueRef
LLVMGetPreviousInstruction(LLVMValueRef Inst
);
2860 * Remove and delete an instruction.
2862 * The instruction specified is removed from its containing building
2863 * block but is kept alive.
2865 * @see llvm::Instruction::removeFromParent()
2867 void LLVMInstructionRemoveFromParent(LLVMValueRef Inst
);
2870 * Remove and delete an instruction.
2872 * The instruction specified is removed from its containing building
2873 * block and then deleted.
2875 * @see llvm::Instruction::eraseFromParent()
2877 void LLVMInstructionEraseFromParent(LLVMValueRef Inst
);
2880 * Obtain the code opcode for an individual instruction.
2882 * @see llvm::Instruction::getOpCode()
2884 LLVMOpcode
LLVMGetInstructionOpcode(LLVMValueRef Inst
);
2887 * Obtain the predicate of an instruction.
2889 * This is only valid for instructions that correspond to llvm::ICmpInst
2890 * or llvm::ConstantExpr whose opcode is llvm::Instruction::ICmp.
2892 * @see llvm::ICmpInst::getPredicate()
2894 LLVMIntPredicate
LLVMGetICmpPredicate(LLVMValueRef Inst
);
2897 * Obtain the float predicate of an instruction.
2899 * This is only valid for instructions that correspond to llvm::FCmpInst
2900 * or llvm::ConstantExpr whose opcode is llvm::Instruction::FCmp.
2902 * @see llvm::FCmpInst::getPredicate()
2904 LLVMRealPredicate
LLVMGetFCmpPredicate(LLVMValueRef Inst
);
2907 * Create a copy of 'this' instruction that is identical in all ways
2908 * except the following:
2909 * * The instruction has no parent
2910 * * The instruction has no name
2912 * @see llvm::Instruction::clone()
2914 LLVMValueRef
LLVMInstructionClone(LLVMValueRef Inst
);
2917 * @defgroup LLVMCCoreValueInstructionCall Call Sites and Invocations
2919 * Functions in this group apply to instructions that refer to call
2920 * sites and invocations. These correspond to C++ types in the
2921 * llvm::CallInst class tree.
2927 * Obtain the argument count for a call instruction.
2929 * This expects an LLVMValueRef that corresponds to a llvm::CallInst,
2930 * llvm::InvokeInst, or llvm:FuncletPadInst.
2932 * @see llvm::CallInst::getNumArgOperands()
2933 * @see llvm::InvokeInst::getNumArgOperands()
2934 * @see llvm::FuncletPadInst::getNumArgOperands()
2936 unsigned LLVMGetNumArgOperands(LLVMValueRef Instr
);
2939 * Set the calling convention for a call instruction.
2941 * This expects an LLVMValueRef that corresponds to a llvm::CallInst or
2944 * @see llvm::CallInst::setCallingConv()
2945 * @see llvm::InvokeInst::setCallingConv()
2947 void LLVMSetInstructionCallConv(LLVMValueRef Instr
, unsigned CC
);
2950 * Obtain the calling convention for a call instruction.
2952 * This is the opposite of LLVMSetInstructionCallConv(). Reads its
2955 * @see LLVMSetInstructionCallConv()
2957 unsigned LLVMGetInstructionCallConv(LLVMValueRef Instr
);
2959 void LLVMSetInstrParamAlignment(LLVMValueRef Instr
, unsigned index
,
2962 void LLVMAddCallSiteAttribute(LLVMValueRef C
, LLVMAttributeIndex Idx
,
2963 LLVMAttributeRef A
);
2964 unsigned LLVMGetCallSiteAttributeCount(LLVMValueRef C
, LLVMAttributeIndex Idx
);
2965 void LLVMGetCallSiteAttributes(LLVMValueRef C
, LLVMAttributeIndex Idx
,
2966 LLVMAttributeRef
*Attrs
);
2967 LLVMAttributeRef
LLVMGetCallSiteEnumAttribute(LLVMValueRef C
,
2968 LLVMAttributeIndex Idx
,
2970 LLVMAttributeRef
LLVMGetCallSiteStringAttribute(LLVMValueRef C
,
2971 LLVMAttributeIndex Idx
,
2972 const char *K
, unsigned KLen
);
2973 void LLVMRemoveCallSiteEnumAttribute(LLVMValueRef C
, LLVMAttributeIndex Idx
,
2975 void LLVMRemoveCallSiteStringAttribute(LLVMValueRef C
, LLVMAttributeIndex Idx
,
2976 const char *K
, unsigned KLen
);
2979 * Obtain the pointer to the function invoked by this instruction.
2981 * This expects an LLVMValueRef that corresponds to a llvm::CallInst or
2984 * @see llvm::CallInst::getCalledValue()
2985 * @see llvm::InvokeInst::getCalledValue()
2987 LLVMValueRef
LLVMGetCalledValue(LLVMValueRef Instr
);
2990 * Obtain whether a call instruction is a tail call.
2992 * This only works on llvm::CallInst instructions.
2994 * @see llvm::CallInst::isTailCall()
2996 LLVMBool
LLVMIsTailCall(LLVMValueRef CallInst
);
2999 * Set whether a call instruction is a tail call.
3001 * This only works on llvm::CallInst instructions.
3003 * @see llvm::CallInst::setTailCall()
3005 void LLVMSetTailCall(LLVMValueRef CallInst
, LLVMBool IsTailCall
);
3008 * Return the normal destination basic block.
3010 * This only works on llvm::InvokeInst instructions.
3012 * @see llvm::InvokeInst::getNormalDest()
3014 LLVMBasicBlockRef
LLVMGetNormalDest(LLVMValueRef InvokeInst
);
3017 * Return the unwind destination basic block.
3019 * Works on llvm::InvokeInst, llvm::CleanupReturnInst, and
3020 * llvm::CatchSwitchInst instructions.
3022 * @see llvm::InvokeInst::getUnwindDest()
3023 * @see llvm::CleanupReturnInst::getUnwindDest()
3024 * @see llvm::CatchSwitchInst::getUnwindDest()
3026 LLVMBasicBlockRef
LLVMGetUnwindDest(LLVMValueRef InvokeInst
);
3029 * Set the normal destination basic block.
3031 * This only works on llvm::InvokeInst instructions.
3033 * @see llvm::InvokeInst::setNormalDest()
3035 void LLVMSetNormalDest(LLVMValueRef InvokeInst
, LLVMBasicBlockRef B
);
3038 * Set the unwind destination basic block.
3040 * Works on llvm::InvokeInst, llvm::CleanupReturnInst, and
3041 * llvm::CatchSwitchInst instructions.
3043 * @see llvm::InvokeInst::setUnwindDest()
3044 * @see llvm::CleanupReturnInst::setUnwindDest()
3045 * @see llvm::CatchSwitchInst::setUnwindDest()
3047 void LLVMSetUnwindDest(LLVMValueRef InvokeInst
, LLVMBasicBlockRef B
);
3054 * @defgroup LLVMCCoreValueInstructionTerminator Terminators
3056 * Functions in this group only apply to instructions that map to
3057 * llvm::TerminatorInst instances.
3063 * Return the number of successors that this terminator has.
3065 * @see llvm::TerminatorInst::getNumSuccessors
3067 unsigned LLVMGetNumSuccessors(LLVMValueRef Term
);
3070 * Return the specified successor.
3072 * @see llvm::TerminatorInst::getSuccessor
3074 LLVMBasicBlockRef
LLVMGetSuccessor(LLVMValueRef Term
, unsigned i
);
3077 * Update the specified successor to point at the provided block.
3079 * @see llvm::TerminatorInst::setSuccessor
3081 void LLVMSetSuccessor(LLVMValueRef Term
, unsigned i
, LLVMBasicBlockRef block
);
3084 * Return if a branch is conditional.
3086 * This only works on llvm::BranchInst instructions.
3088 * @see llvm::BranchInst::isConditional
3090 LLVMBool
LLVMIsConditional(LLVMValueRef Branch
);
3093 * Return the condition of a branch instruction.
3095 * This only works on llvm::BranchInst instructions.
3097 * @see llvm::BranchInst::getCondition
3099 LLVMValueRef
LLVMGetCondition(LLVMValueRef Branch
);
3102 * Set the condition of a branch instruction.
3104 * This only works on llvm::BranchInst instructions.
3106 * @see llvm::BranchInst::setCondition
3108 void LLVMSetCondition(LLVMValueRef Branch
, LLVMValueRef Cond
);
3111 * Obtain the default destination basic block of a switch instruction.
3113 * This only works on llvm::SwitchInst instructions.
3115 * @see llvm::SwitchInst::getDefaultDest()
3117 LLVMBasicBlockRef
LLVMGetSwitchDefaultDest(LLVMValueRef SwitchInstr
);
3124 * @defgroup LLVMCCoreValueInstructionAlloca Allocas
3126 * Functions in this group only apply to instructions that map to
3127 * llvm::AllocaInst instances.
3133 * Obtain the type that is being allocated by the alloca instruction.
3135 LLVMTypeRef
LLVMGetAllocatedType(LLVMValueRef Alloca
);
3142 * @defgroup LLVMCCoreValueInstructionGetElementPointer GEPs
3144 * Functions in this group only apply to instructions that map to
3145 * llvm::GetElementPtrInst instances.
3151 * Check whether the given GEP instruction is inbounds.
3153 LLVMBool
LLVMIsInBounds(LLVMValueRef GEP
);
3156 * Set the given GEP instruction to be inbounds or not.
3158 void LLVMSetIsInBounds(LLVMValueRef GEP
, LLVMBool InBounds
);
3165 * @defgroup LLVMCCoreValueInstructionPHINode PHI Nodes
3167 * Functions in this group only apply to instructions that map to
3168 * llvm::PHINode instances.
3174 * Add an incoming value to the end of a PHI list.
3176 void LLVMAddIncoming(LLVMValueRef PhiNode
, LLVMValueRef
*IncomingValues
,
3177 LLVMBasicBlockRef
*IncomingBlocks
, unsigned Count
);
3180 * Obtain the number of incoming basic blocks to a PHI node.
3182 unsigned LLVMCountIncoming(LLVMValueRef PhiNode
);
3185 * Obtain an incoming value to a PHI node as an LLVMValueRef.
3187 LLVMValueRef
LLVMGetIncomingValue(LLVMValueRef PhiNode
, unsigned Index
);
3190 * Obtain an incoming value to a PHI node as an LLVMBasicBlockRef.
3192 LLVMBasicBlockRef
LLVMGetIncomingBlock(LLVMValueRef PhiNode
, unsigned Index
);
3199 * @defgroup LLVMCCoreValueInstructionExtractValue ExtractValue
3200 * @defgroup LLVMCCoreValueInstructionInsertValue InsertValue
3202 * Functions in this group only apply to instructions that map to
3203 * llvm::ExtractValue and llvm::InsertValue instances.
3209 * Obtain the number of indices.
3210 * NB: This also works on GEP.
3212 unsigned LLVMGetNumIndices(LLVMValueRef Inst
);
3215 * Obtain the indices as an array.
3217 const unsigned *LLVMGetIndices(LLVMValueRef Inst
);
3232 * @defgroup LLVMCCoreInstructionBuilder Instruction Builders
3234 * An instruction builder represents a point within a basic block and is
3235 * the exclusive means of building instructions using the C interface.
3240 LLVMBuilderRef
LLVMCreateBuilderInContext(LLVMContextRef C
);
3241 LLVMBuilderRef
LLVMCreateBuilder(void);
3242 void LLVMPositionBuilder(LLVMBuilderRef Builder
, LLVMBasicBlockRef Block
,
3243 LLVMValueRef Instr
);
3244 void LLVMPositionBuilderBefore(LLVMBuilderRef Builder
, LLVMValueRef Instr
);
3245 void LLVMPositionBuilderAtEnd(LLVMBuilderRef Builder
, LLVMBasicBlockRef Block
);
3246 LLVMBasicBlockRef
LLVMGetInsertBlock(LLVMBuilderRef Builder
);
3247 void LLVMClearInsertionPosition(LLVMBuilderRef Builder
);
3248 void LLVMInsertIntoBuilder(LLVMBuilderRef Builder
, LLVMValueRef Instr
);
3249 void LLVMInsertIntoBuilderWithName(LLVMBuilderRef Builder
, LLVMValueRef Instr
,
3251 void LLVMDisposeBuilder(LLVMBuilderRef Builder
);
3254 void LLVMSetCurrentDebugLocation(LLVMBuilderRef Builder
, LLVMValueRef L
);
3255 LLVMValueRef
LLVMGetCurrentDebugLocation(LLVMBuilderRef Builder
);
3256 void LLVMSetInstDebugLocation(LLVMBuilderRef Builder
, LLVMValueRef Inst
);
3259 LLVMValueRef
LLVMBuildRetVoid(LLVMBuilderRef
);
3260 LLVMValueRef
LLVMBuildRet(LLVMBuilderRef
, LLVMValueRef V
);
3261 LLVMValueRef
LLVMBuildAggregateRet(LLVMBuilderRef
, LLVMValueRef
*RetVals
,
3263 LLVMValueRef
LLVMBuildBr(LLVMBuilderRef
, LLVMBasicBlockRef Dest
);
3264 LLVMValueRef
LLVMBuildCondBr(LLVMBuilderRef
, LLVMValueRef If
,
3265 LLVMBasicBlockRef Then
, LLVMBasicBlockRef Else
);
3266 LLVMValueRef
LLVMBuildSwitch(LLVMBuilderRef
, LLVMValueRef V
,
3267 LLVMBasicBlockRef Else
, unsigned NumCases
);
3268 LLVMValueRef
LLVMBuildIndirectBr(LLVMBuilderRef B
, LLVMValueRef Addr
,
3270 LLVMValueRef
LLVMBuildInvoke(LLVMBuilderRef
, LLVMValueRef Fn
,
3271 LLVMValueRef
*Args
, unsigned NumArgs
,
3272 LLVMBasicBlockRef Then
, LLVMBasicBlockRef Catch
,
3274 LLVMValueRef
LLVMBuildUnreachable(LLVMBuilderRef
);
3276 /* Exception Handling */
3277 LLVMValueRef
LLVMBuildResume(LLVMBuilderRef B
, LLVMValueRef Exn
);
3278 LLVMValueRef
LLVMBuildLandingPad(LLVMBuilderRef B
, LLVMTypeRef Ty
,
3279 LLVMValueRef PersFn
, unsigned NumClauses
,
3281 LLVMValueRef
LLVMBuildCleanupRet(LLVMBuilderRef B
, LLVMValueRef CatchPad
,
3282 LLVMBasicBlockRef BB
);
3283 LLVMValueRef
LLVMBuildCatchRet(LLVMBuilderRef B
, LLVMValueRef CatchPad
,
3284 LLVMBasicBlockRef BB
);
3285 LLVMValueRef
LLVMBuildCatchPad(LLVMBuilderRef B
, LLVMValueRef ParentPad
,
3286 LLVMValueRef
*Args
, unsigned NumArgs
,
3288 LLVMValueRef
LLVMBuildCleanupPad(LLVMBuilderRef B
, LLVMValueRef ParentPad
,
3289 LLVMValueRef
*Args
, unsigned NumArgs
,
3291 LLVMValueRef
LLVMBuildCatchSwitch(LLVMBuilderRef B
, LLVMValueRef ParentPad
,
3292 LLVMBasicBlockRef UnwindBB
,
3293 unsigned NumHandlers
, const char *Name
);
3295 /* Add a case to the switch instruction */
3296 void LLVMAddCase(LLVMValueRef Switch
, LLVMValueRef OnVal
,
3297 LLVMBasicBlockRef Dest
);
3299 /* Add a destination to the indirectbr instruction */
3300 void LLVMAddDestination(LLVMValueRef IndirectBr
, LLVMBasicBlockRef Dest
);
3302 /* Get the number of clauses on the landingpad instruction */
3303 unsigned LLVMGetNumClauses(LLVMValueRef LandingPad
);
3305 /* Get the value of the clause at idnex Idx on the landingpad instruction */
3306 LLVMValueRef
LLVMGetClause(LLVMValueRef LandingPad
, unsigned Idx
);
3308 /* Add a catch or filter clause to the landingpad instruction */
3309 void LLVMAddClause(LLVMValueRef LandingPad
, LLVMValueRef ClauseVal
);
3311 /* Get the 'cleanup' flag in the landingpad instruction */
3312 LLVMBool
LLVMIsCleanup(LLVMValueRef LandingPad
);
3314 /* Set the 'cleanup' flag in the landingpad instruction */
3315 void LLVMSetCleanup(LLVMValueRef LandingPad
, LLVMBool Val
);
3317 /* Add a destination to the catchswitch instruction */
3318 void LLVMAddHandler(LLVMValueRef CatchSwitch
, LLVMBasicBlockRef Dest
);
3320 /* Get the number of handlers on the catchswitch instruction */
3321 unsigned LLVMGetNumHandlers(LLVMValueRef CatchSwitch
);
3324 * Obtain the basic blocks acting as handlers for a catchswitch instruction.
3326 * The Handlers parameter should point to a pre-allocated array of
3327 * LLVMBasicBlockRefs at least LLVMGetNumHandlers() large. On return, the
3328 * first LLVMGetNumHandlers() entries in the array will be populated
3329 * with LLVMBasicBlockRef instances.
3331 * @param CatchSwitch The catchswitch instruction to operate on.
3332 * @param Handlers Memory address of an array to be filled with basic blocks.
3334 void LLVMGetHandlers(LLVMValueRef CatchSwitch
, LLVMBasicBlockRef
*Handlers
);
3338 /* Get the number of funcletpad arguments. */
3339 LLVMValueRef
LLVMGetArgOperand(LLVMValueRef Funclet
, unsigned i
);
3341 /* Set a funcletpad argument at the given index. */
3342 void LLVMSetArgOperand(LLVMValueRef Funclet
, unsigned i
, LLVMValueRef value
);
3345 * Get the parent catchswitch instruction of a catchpad instruction.
3347 * This only works on llvm::CatchPadInst instructions.
3349 * @see llvm::CatchPadInst::getCatchSwitch()
3351 LLVMValueRef
LLVMGetParentCatchSwitch(LLVMValueRef CatchPad
);
3354 * Set the parent catchswitch instruction of a catchpad instruction.
3356 * This only works on llvm::CatchPadInst instructions.
3358 * @see llvm::CatchPadInst::setCatchSwitch()
3360 void LLVMSetParentCatchSwitch(LLVMValueRef CatchPad
, LLVMValueRef CatchSwitch
);
3363 LLVMValueRef
LLVMBuildAdd(LLVMBuilderRef
, LLVMValueRef LHS
, LLVMValueRef RHS
,
3365 LLVMValueRef
LLVMBuildNSWAdd(LLVMBuilderRef
, LLVMValueRef LHS
, LLVMValueRef RHS
,
3367 LLVMValueRef
LLVMBuildNUWAdd(LLVMBuilderRef
, LLVMValueRef LHS
, LLVMValueRef RHS
,
3369 LLVMValueRef
LLVMBuildFAdd(LLVMBuilderRef
, LLVMValueRef LHS
, LLVMValueRef RHS
,
3371 LLVMValueRef
LLVMBuildSub(LLVMBuilderRef
, LLVMValueRef LHS
, LLVMValueRef RHS
,
3373 LLVMValueRef
LLVMBuildNSWSub(LLVMBuilderRef
, LLVMValueRef LHS
, LLVMValueRef RHS
,
3375 LLVMValueRef
LLVMBuildNUWSub(LLVMBuilderRef
, LLVMValueRef LHS
, LLVMValueRef RHS
,
3377 LLVMValueRef
LLVMBuildFSub(LLVMBuilderRef
, LLVMValueRef LHS
, LLVMValueRef RHS
,
3379 LLVMValueRef
LLVMBuildMul(LLVMBuilderRef
, LLVMValueRef LHS
, LLVMValueRef RHS
,
3381 LLVMValueRef
LLVMBuildNSWMul(LLVMBuilderRef
, LLVMValueRef LHS
, LLVMValueRef RHS
,
3383 LLVMValueRef
LLVMBuildNUWMul(LLVMBuilderRef
, LLVMValueRef LHS
, LLVMValueRef RHS
,
3385 LLVMValueRef
LLVMBuildFMul(LLVMBuilderRef
, LLVMValueRef LHS
, LLVMValueRef RHS
,
3387 LLVMValueRef
LLVMBuildUDiv(LLVMBuilderRef
, LLVMValueRef LHS
, LLVMValueRef RHS
,
3389 LLVMValueRef
LLVMBuildExactUDiv(LLVMBuilderRef
, LLVMValueRef LHS
, LLVMValueRef RHS
,
3391 LLVMValueRef
LLVMBuildSDiv(LLVMBuilderRef
, LLVMValueRef LHS
, LLVMValueRef RHS
,
3393 LLVMValueRef
LLVMBuildExactSDiv(LLVMBuilderRef
, LLVMValueRef LHS
, LLVMValueRef RHS
,
3395 LLVMValueRef
LLVMBuildFDiv(LLVMBuilderRef
, LLVMValueRef LHS
, LLVMValueRef RHS
,
3397 LLVMValueRef
LLVMBuildURem(LLVMBuilderRef
, LLVMValueRef LHS
, LLVMValueRef RHS
,
3399 LLVMValueRef
LLVMBuildSRem(LLVMBuilderRef
, LLVMValueRef LHS
, LLVMValueRef RHS
,
3401 LLVMValueRef
LLVMBuildFRem(LLVMBuilderRef
, LLVMValueRef LHS
, LLVMValueRef RHS
,
3403 LLVMValueRef
LLVMBuildShl(LLVMBuilderRef
, LLVMValueRef LHS
, LLVMValueRef RHS
,
3405 LLVMValueRef
LLVMBuildLShr(LLVMBuilderRef
, LLVMValueRef LHS
, LLVMValueRef RHS
,
3407 LLVMValueRef
LLVMBuildAShr(LLVMBuilderRef
, LLVMValueRef LHS
, LLVMValueRef RHS
,
3409 LLVMValueRef
LLVMBuildAnd(LLVMBuilderRef
, LLVMValueRef LHS
, LLVMValueRef RHS
,
3411 LLVMValueRef
LLVMBuildOr(LLVMBuilderRef
, LLVMValueRef LHS
, LLVMValueRef RHS
,
3413 LLVMValueRef
LLVMBuildXor(LLVMBuilderRef
, LLVMValueRef LHS
, LLVMValueRef RHS
,
3415 LLVMValueRef
LLVMBuildBinOp(LLVMBuilderRef B
, LLVMOpcode Op
,
3416 LLVMValueRef LHS
, LLVMValueRef RHS
,
3418 LLVMValueRef
LLVMBuildNeg(LLVMBuilderRef
, LLVMValueRef V
, const char *Name
);
3419 LLVMValueRef
LLVMBuildNSWNeg(LLVMBuilderRef B
, LLVMValueRef V
,
3421 LLVMValueRef
LLVMBuildNUWNeg(LLVMBuilderRef B
, LLVMValueRef V
,
3423 LLVMValueRef
LLVMBuildFNeg(LLVMBuilderRef
, LLVMValueRef V
, const char *Name
);
3424 LLVMValueRef
LLVMBuildNot(LLVMBuilderRef
, LLVMValueRef V
, const char *Name
);
3427 LLVMValueRef
LLVMBuildMalloc(LLVMBuilderRef
, LLVMTypeRef Ty
, const char *Name
);
3428 LLVMValueRef
LLVMBuildArrayMalloc(LLVMBuilderRef
, LLVMTypeRef Ty
,
3429 LLVMValueRef Val
, const char *Name
);
3430 LLVMValueRef
LLVMBuildAlloca(LLVMBuilderRef
, LLVMTypeRef Ty
, const char *Name
);
3431 LLVMValueRef
LLVMBuildArrayAlloca(LLVMBuilderRef
, LLVMTypeRef Ty
,
3432 LLVMValueRef Val
, const char *Name
);
3433 LLVMValueRef
LLVMBuildFree(LLVMBuilderRef
, LLVMValueRef PointerVal
);
3434 LLVMValueRef
LLVMBuildLoad(LLVMBuilderRef
, LLVMValueRef PointerVal
,
3436 LLVMValueRef
LLVMBuildStore(LLVMBuilderRef
, LLVMValueRef Val
, LLVMValueRef Ptr
);
3437 LLVMValueRef
LLVMBuildGEP(LLVMBuilderRef B
, LLVMValueRef Pointer
,
3438 LLVMValueRef
*Indices
, unsigned NumIndices
,
3440 LLVMValueRef
LLVMBuildInBoundsGEP(LLVMBuilderRef B
, LLVMValueRef Pointer
,
3441 LLVMValueRef
*Indices
, unsigned NumIndices
,
3443 LLVMValueRef
LLVMBuildStructGEP(LLVMBuilderRef B
, LLVMValueRef Pointer
,
3444 unsigned Idx
, const char *Name
);
3445 LLVMValueRef
LLVMBuildGlobalString(LLVMBuilderRef B
, const char *Str
,
3447 LLVMValueRef
LLVMBuildGlobalStringPtr(LLVMBuilderRef B
, const char *Str
,
3449 LLVMBool
LLVMGetVolatile(LLVMValueRef MemoryAccessInst
);
3450 void LLVMSetVolatile(LLVMValueRef MemoryAccessInst
, LLVMBool IsVolatile
);
3451 LLVMAtomicOrdering
LLVMGetOrdering(LLVMValueRef MemoryAccessInst
);
3452 void LLVMSetOrdering(LLVMValueRef MemoryAccessInst
, LLVMAtomicOrdering Ordering
);
3455 LLVMValueRef
LLVMBuildTrunc(LLVMBuilderRef
, LLVMValueRef Val
,
3456 LLVMTypeRef DestTy
, const char *Name
);
3457 LLVMValueRef
LLVMBuildZExt(LLVMBuilderRef
, LLVMValueRef Val
,
3458 LLVMTypeRef DestTy
, const char *Name
);
3459 LLVMValueRef
LLVMBuildSExt(LLVMBuilderRef
, LLVMValueRef Val
,
3460 LLVMTypeRef DestTy
, const char *Name
);
3461 LLVMValueRef
LLVMBuildFPToUI(LLVMBuilderRef
, LLVMValueRef Val
,
3462 LLVMTypeRef DestTy
, const char *Name
);
3463 LLVMValueRef
LLVMBuildFPToSI(LLVMBuilderRef
, LLVMValueRef Val
,
3464 LLVMTypeRef DestTy
, const char *Name
);
3465 LLVMValueRef
LLVMBuildUIToFP(LLVMBuilderRef
, LLVMValueRef Val
,
3466 LLVMTypeRef DestTy
, const char *Name
);
3467 LLVMValueRef
LLVMBuildSIToFP(LLVMBuilderRef
, LLVMValueRef Val
,
3468 LLVMTypeRef DestTy
, const char *Name
);
3469 LLVMValueRef
LLVMBuildFPTrunc(LLVMBuilderRef
, LLVMValueRef Val
,
3470 LLVMTypeRef DestTy
, const char *Name
);
3471 LLVMValueRef
LLVMBuildFPExt(LLVMBuilderRef
, LLVMValueRef Val
,
3472 LLVMTypeRef DestTy
, const char *Name
);
3473 LLVMValueRef
LLVMBuildPtrToInt(LLVMBuilderRef
, LLVMValueRef Val
,
3474 LLVMTypeRef DestTy
, const char *Name
);
3475 LLVMValueRef
LLVMBuildIntToPtr(LLVMBuilderRef
, LLVMValueRef Val
,
3476 LLVMTypeRef DestTy
, const char *Name
);
3477 LLVMValueRef
LLVMBuildBitCast(LLVMBuilderRef
, LLVMValueRef Val
,
3478 LLVMTypeRef DestTy
, const char *Name
);
3479 LLVMValueRef
LLVMBuildAddrSpaceCast(LLVMBuilderRef
, LLVMValueRef Val
,
3480 LLVMTypeRef DestTy
, const char *Name
);
3481 LLVMValueRef
LLVMBuildZExtOrBitCast(LLVMBuilderRef
, LLVMValueRef Val
,
3482 LLVMTypeRef DestTy
, const char *Name
);
3483 LLVMValueRef
LLVMBuildSExtOrBitCast(LLVMBuilderRef
, LLVMValueRef Val
,
3484 LLVMTypeRef DestTy
, const char *Name
);
3485 LLVMValueRef
LLVMBuildTruncOrBitCast(LLVMBuilderRef
, LLVMValueRef Val
,
3486 LLVMTypeRef DestTy
, const char *Name
);
3487 LLVMValueRef
LLVMBuildCast(LLVMBuilderRef B
, LLVMOpcode Op
, LLVMValueRef Val
,
3488 LLVMTypeRef DestTy
, const char *Name
);
3489 LLVMValueRef
LLVMBuildPointerCast(LLVMBuilderRef
, LLVMValueRef Val
,
3490 LLVMTypeRef DestTy
, const char *Name
);
3491 LLVMValueRef
LLVMBuildIntCast(LLVMBuilderRef
, LLVMValueRef Val
, /*Signed cast!*/
3492 LLVMTypeRef DestTy
, const char *Name
);
3493 LLVMValueRef
LLVMBuildFPCast(LLVMBuilderRef
, LLVMValueRef Val
,
3494 LLVMTypeRef DestTy
, const char *Name
);
3497 LLVMValueRef
LLVMBuildICmp(LLVMBuilderRef
, LLVMIntPredicate Op
,
3498 LLVMValueRef LHS
, LLVMValueRef RHS
,
3500 LLVMValueRef
LLVMBuildFCmp(LLVMBuilderRef
, LLVMRealPredicate Op
,
3501 LLVMValueRef LHS
, LLVMValueRef RHS
,
3504 /* Miscellaneous instructions */
3505 LLVMValueRef
LLVMBuildPhi(LLVMBuilderRef
, LLVMTypeRef Ty
, const char *Name
);
3506 LLVMValueRef
LLVMBuildCall(LLVMBuilderRef
, LLVMValueRef Fn
,
3507 LLVMValueRef
*Args
, unsigned NumArgs
,
3509 LLVMValueRef
LLVMBuildSelect(LLVMBuilderRef
, LLVMValueRef If
,
3510 LLVMValueRef Then
, LLVMValueRef Else
,
3512 LLVMValueRef
LLVMBuildVAArg(LLVMBuilderRef
, LLVMValueRef List
, LLVMTypeRef Ty
,
3514 LLVMValueRef
LLVMBuildExtractElement(LLVMBuilderRef
, LLVMValueRef VecVal
,
3515 LLVMValueRef Index
, const char *Name
);
3516 LLVMValueRef
LLVMBuildInsertElement(LLVMBuilderRef
, LLVMValueRef VecVal
,
3517 LLVMValueRef EltVal
, LLVMValueRef Index
,
3519 LLVMValueRef
LLVMBuildShuffleVector(LLVMBuilderRef
, LLVMValueRef V1
,
3520 LLVMValueRef V2
, LLVMValueRef Mask
,
3522 LLVMValueRef
LLVMBuildExtractValue(LLVMBuilderRef
, LLVMValueRef AggVal
,
3523 unsigned Index
, const char *Name
);
3524 LLVMValueRef
LLVMBuildInsertValue(LLVMBuilderRef
, LLVMValueRef AggVal
,
3525 LLVMValueRef EltVal
, unsigned Index
,
3528 LLVMValueRef
LLVMBuildIsNull(LLVMBuilderRef
, LLVMValueRef Val
,
3530 LLVMValueRef
LLVMBuildIsNotNull(LLVMBuilderRef
, LLVMValueRef Val
,
3532 LLVMValueRef
LLVMBuildPtrDiff(LLVMBuilderRef
, LLVMValueRef LHS
,
3533 LLVMValueRef RHS
, const char *Name
);
3534 LLVMValueRef
LLVMBuildFence(LLVMBuilderRef B
, LLVMAtomicOrdering ordering
,
3535 LLVMBool singleThread
, const char *Name
);
3536 LLVMValueRef
LLVMBuildAtomicRMW(LLVMBuilderRef B
, LLVMAtomicRMWBinOp op
,
3537 LLVMValueRef PTR
, LLVMValueRef Val
,
3538 LLVMAtomicOrdering ordering
,
3539 LLVMBool singleThread
);
3540 LLVMValueRef
LLVMBuildAtomicCmpXchg(LLVMBuilderRef B
, LLVMValueRef Ptr
,
3541 LLVMValueRef Cmp
, LLVMValueRef New
,
3542 LLVMAtomicOrdering SuccessOrdering
,
3543 LLVMAtomicOrdering FailureOrdering
,
3544 LLVMBool SingleThread
);
3546 LLVMBool
LLVMIsAtomicSingleThread(LLVMValueRef AtomicInst
);
3547 void LLVMSetAtomicSingleThread(LLVMValueRef AtomicInst
, LLVMBool SingleThread
);
3549 LLVMAtomicOrdering
LLVMGetCmpXchgSuccessOrdering(LLVMValueRef CmpXchgInst
);
3550 void LLVMSetCmpXchgSuccessOrdering(LLVMValueRef CmpXchgInst
,
3551 LLVMAtomicOrdering Ordering
);
3552 LLVMAtomicOrdering
LLVMGetCmpXchgFailureOrdering(LLVMValueRef CmpXchgInst
);
3553 void LLVMSetCmpXchgFailureOrdering(LLVMValueRef CmpXchgInst
,
3554 LLVMAtomicOrdering Ordering
);
3561 * @defgroup LLVMCCoreModuleProvider Module Providers
3567 * Changes the type of M so it can be passed to FunctionPassManagers and the
3568 * JIT. They take ModuleProviders for historical reasons.
3570 LLVMModuleProviderRef
3571 LLVMCreateModuleProviderForExistingModule(LLVMModuleRef M
);
3574 * Destroys the module M.
3576 void LLVMDisposeModuleProvider(LLVMModuleProviderRef M
);
3583 * @defgroup LLVMCCoreMemoryBuffers Memory Buffers
3588 LLVMBool
LLVMCreateMemoryBufferWithContentsOfFile(const char *Path
,
3589 LLVMMemoryBufferRef
*OutMemBuf
,
3591 LLVMBool
LLVMCreateMemoryBufferWithSTDIN(LLVMMemoryBufferRef
*OutMemBuf
,
3593 LLVMMemoryBufferRef
LLVMCreateMemoryBufferWithMemoryRange(const char *InputData
,
3594 size_t InputDataLength
,
3595 const char *BufferName
,
3596 LLVMBool RequiresNullTerminator
);
3597 LLVMMemoryBufferRef
LLVMCreateMemoryBufferWithMemoryRangeCopy(const char *InputData
,
3598 size_t InputDataLength
,
3599 const char *BufferName
);
3600 const char *LLVMGetBufferStart(LLVMMemoryBufferRef MemBuf
);
3601 size_t LLVMGetBufferSize(LLVMMemoryBufferRef MemBuf
);
3602 void LLVMDisposeMemoryBuffer(LLVMMemoryBufferRef MemBuf
);
3609 * @defgroup LLVMCCorePassRegistry Pass Registry
3614 /** Return the global pass registry, for use with initialization functions.
3615 @see llvm::PassRegistry::getPassRegistry */
3616 LLVMPassRegistryRef
LLVMGetGlobalPassRegistry(void);
3623 * @defgroup LLVMCCorePassManagers Pass Managers
3628 /** Constructs a new whole-module pass pipeline. This type of pipeline is
3629 suitable for link-time optimization and whole-module transformations.
3630 @see llvm::PassManager::PassManager */
3631 LLVMPassManagerRef
LLVMCreatePassManager(void);
3633 /** Constructs a new function-by-function pass pipeline over the module
3634 provider. It does not take ownership of the module provider. This type of
3635 pipeline is suitable for code generation and JIT compilation tasks.
3636 @see llvm::FunctionPassManager::FunctionPassManager */
3637 LLVMPassManagerRef
LLVMCreateFunctionPassManagerForModule(LLVMModuleRef M
);
3639 /** Deprecated: Use LLVMCreateFunctionPassManagerForModule instead. */
3640 LLVMPassManagerRef
LLVMCreateFunctionPassManager(LLVMModuleProviderRef MP
);
3642 /** Initializes, executes on the provided module, and finalizes all of the
3643 passes scheduled in the pass manager. Returns 1 if any of the passes
3644 modified the module, 0 otherwise.
3645 @see llvm::PassManager::run(Module&) */
3646 LLVMBool
LLVMRunPassManager(LLVMPassManagerRef PM
, LLVMModuleRef M
);
3648 /** Initializes all of the function passes scheduled in the function pass
3649 manager. Returns 1 if any of the passes modified the module, 0 otherwise.
3650 @see llvm::FunctionPassManager::doInitialization */
3651 LLVMBool
LLVMInitializeFunctionPassManager(LLVMPassManagerRef FPM
);
3653 /** Executes all of the function passes scheduled in the function pass manager
3654 on the provided function. Returns 1 if any of the passes modified the
3655 function, false otherwise.
3656 @see llvm::FunctionPassManager::run(Function&) */
3657 LLVMBool
LLVMRunFunctionPassManager(LLVMPassManagerRef FPM
, LLVMValueRef F
);
3659 /** Finalizes all of the function passes scheduled in the function pass
3660 manager. Returns 1 if any of the passes modified the module, 0 otherwise.
3661 @see llvm::FunctionPassManager::doFinalization */
3662 LLVMBool
LLVMFinalizeFunctionPassManager(LLVMPassManagerRef FPM
);
3664 /** Frees the memory of a pass pipeline. For function pipelines, does not free
3665 the module provider.
3666 @see llvm::PassManagerBase::~PassManagerBase. */
3667 void LLVMDisposePassManager(LLVMPassManagerRef PM
);
3674 * @defgroup LLVMCCoreThreading Threading
3676 * Handle the structures needed to make LLVM safe for multithreading.
3681 /** Deprecated: Multi-threading can only be enabled/disabled with the compile
3682 time define LLVM_ENABLE_THREADS. This function always returns
3683 LLVMIsMultithreaded(). */
3684 LLVMBool
LLVMStartMultithreaded(void);
3686 /** Deprecated: Multi-threading can only be enabled/disabled with the compile
3687 time define LLVM_ENABLE_THREADS. */
3688 void LLVMStopMultithreaded(void);
3690 /** Check whether LLVM is executing in thread-safe mode or not.
3691 @see llvm::llvm_is_multithreaded */
3692 LLVMBool
LLVMIsMultithreaded(void);
3710 #endif /* LLVM_C_CORE_H */