1 /*===-- llvm-c/Core.h - Core Library C Interface ------------------*- C -*-===*\
3 |* Part of the LLVM Project, under the Apache License v2.0 with LLVM *|
5 |* See https://llvm.org/LICENSE.txt for license information. *|
6 |* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *|
8 |*===----------------------------------------------------------------------===*|
10 |* This header declares the C interface to libLLVMCore.a, which implements *|
11 |* the LLVM intermediate representation. *|
13 \*===----------------------------------------------------------------------===*/
18 #include "llvm-c/Deprecated.h"
19 #include "llvm-c/ErrorHandling.h"
20 #include "llvm-c/ExternC.h"
21 #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
57 /// External users depend on the following values being stable. It is not safe
60 /* Terminator Instructions */
66 /* removed 6 due to API changes */
70 /* Standard Unary Operators */
73 /* Standard Binary Operators */
87 /* Logical Operators */
95 /* Memory Operators */
99 LLVMGetElementPtr
= 29,
114 LLVMAddrSpaceCast
= 60,
116 /* Other Operators */
125 LLVMExtractElement
= 50,
126 LLVMInsertElement
= 51,
127 LLVMShuffleVector
= 52,
128 LLVMExtractValue
= 53,
129 LLVMInsertValue
= 54,
132 /* Atomic operators */
134 LLVMAtomicCmpXchg
= 56,
137 /* Exception Handling Operators */
148 LLVMVoidTypeKind
, /**< type with no size */
149 LLVMHalfTypeKind
, /**< 16 bit floating point type */
150 LLVMFloatTypeKind
, /**< 32 bit floating point type */
151 LLVMDoubleTypeKind
, /**< 64 bit floating point type */
152 LLVMX86_FP80TypeKind
, /**< 80 bit floating point type (X87) */
153 LLVMFP128TypeKind
, /**< 128 bit floating point type (112-bit mantissa)*/
154 LLVMPPC_FP128TypeKind
, /**< 128 bit floating point type (two 64-bits) */
155 LLVMLabelTypeKind
, /**< Labels */
156 LLVMIntegerTypeKind
, /**< Arbitrary bit width integers */
157 LLVMFunctionTypeKind
, /**< Functions */
158 LLVMStructTypeKind
, /**< Structures */
159 LLVMArrayTypeKind
, /**< Arrays */
160 LLVMPointerTypeKind
, /**< Pointers */
161 LLVMVectorTypeKind
, /**< Fixed width SIMD vector type */
162 LLVMMetadataTypeKind
, /**< Metadata */
163 LLVMX86_MMXTypeKind
, /**< X86 MMX */
164 LLVMTokenTypeKind
, /**< Tokens */
165 LLVMScalableVectorTypeKind
, /**< Scalable SIMD vector type */
166 LLVMBFloatTypeKind
, /**< 16 bit brain floating point type */
167 LLVMX86_AMXTypeKind
/**< X86 AMX */
171 LLVMExternalLinkage
, /**< Externally visible function */
172 LLVMAvailableExternallyLinkage
,
173 LLVMLinkOnceAnyLinkage
, /**< Keep one copy of function when linking (inline)*/
174 LLVMLinkOnceODRLinkage
, /**< Same, but only replaced by something
176 LLVMLinkOnceODRAutoHideLinkage
, /**< Obsolete */
177 LLVMWeakAnyLinkage
, /**< Keep one copy of function when linking (weak) */
178 LLVMWeakODRLinkage
, /**< Same, but only replaced by something
180 LLVMAppendingLinkage
, /**< Special purpose, only applies to global arrays */
181 LLVMInternalLinkage
, /**< Rename collisions when linking (static
183 LLVMPrivateLinkage
, /**< Like Internal, but omit from symbol table */
184 LLVMDLLImportLinkage
, /**< Obsolete */
185 LLVMDLLExportLinkage
, /**< Obsolete */
186 LLVMExternalWeakLinkage
,/**< ExternalWeak linkage description */
187 LLVMGhostLinkage
, /**< Obsolete */
188 LLVMCommonLinkage
, /**< Tentative definitions */
189 LLVMLinkerPrivateLinkage
, /**< Like Private, but linker removes. */
190 LLVMLinkerPrivateWeakLinkage
/**< Like LinkerPrivate, but is weak. */
194 LLVMDefaultVisibility
, /**< The GV is visible */
195 LLVMHiddenVisibility
, /**< The GV is hidden */
196 LLVMProtectedVisibility
/**< The GV is protected */
200 LLVMNoUnnamedAddr
, /**< Address of the GV is significant. */
201 LLVMLocalUnnamedAddr
, /**< Address of the GV is locally insignificant. */
202 LLVMGlobalUnnamedAddr
/**< Address of the GV is globally insignificant. */
206 LLVMDefaultStorageClass
= 0,
207 LLVMDLLImportStorageClass
= 1, /**< Function to be imported from DLL. */
208 LLVMDLLExportStorageClass
= 2 /**< Function to be accessible from DLL. */
209 } LLVMDLLStorageClass
;
213 LLVMFastCallConv
= 8,
214 LLVMColdCallConv
= 9,
215 LLVMGHCCallConv
= 10,
216 LLVMHiPECallConv
= 11,
217 LLVMWebKitJSCallConv
= 12,
218 LLVMAnyRegCallConv
= 13,
219 LLVMPreserveMostCallConv
= 14,
220 LLVMPreserveAllCallConv
= 15,
221 LLVMSwiftCallConv
= 16,
222 LLVMCXXFASTTLSCallConv
= 17,
223 LLVMX86StdcallCallConv
= 64,
224 LLVMX86FastcallCallConv
= 65,
225 LLVMARMAPCSCallConv
= 66,
226 LLVMARMAAPCSCallConv
= 67,
227 LLVMARMAAPCSVFPCallConv
= 68,
228 LLVMMSP430INTRCallConv
= 69,
229 LLVMX86ThisCallCallConv
= 70,
230 LLVMPTXKernelCallConv
= 71,
231 LLVMPTXDeviceCallConv
= 72,
232 LLVMSPIRFUNCCallConv
= 75,
233 LLVMSPIRKERNELCallConv
= 76,
234 LLVMIntelOCLBICallConv
= 77,
235 LLVMX8664SysVCallConv
= 78,
236 LLVMWin64CallConv
= 79,
237 LLVMX86VectorCallCallConv
= 80,
238 LLVMHHVMCallConv
= 81,
239 LLVMHHVMCCallConv
= 82,
240 LLVMX86INTRCallConv
= 83,
241 LLVMAVRINTRCallConv
= 84,
242 LLVMAVRSIGNALCallConv
= 85,
243 LLVMAVRBUILTINCallConv
= 86,
244 LLVMAMDGPUVSCallConv
= 87,
245 LLVMAMDGPUGSCallConv
= 88,
246 LLVMAMDGPUPSCallConv
= 89,
247 LLVMAMDGPUCSCallConv
= 90,
248 LLVMAMDGPUKERNELCallConv
= 91,
249 LLVMX86RegCallCallConv
= 92,
250 LLVMAMDGPUHSCallConv
= 93,
251 LLVMMSP430BUILTINCallConv
= 94,
252 LLVMAMDGPULSCallConv
= 95,
253 LLVMAMDGPUESCallConv
= 96
257 LLVMArgumentValueKind
,
258 LLVMBasicBlockValueKind
,
259 LLVMMemoryUseValueKind
,
260 LLVMMemoryDefValueKind
,
261 LLVMMemoryPhiValueKind
,
263 LLVMFunctionValueKind
,
264 LLVMGlobalAliasValueKind
,
265 LLVMGlobalIFuncValueKind
,
266 LLVMGlobalVariableValueKind
,
267 LLVMBlockAddressValueKind
,
268 LLVMConstantExprValueKind
,
269 LLVMConstantArrayValueKind
,
270 LLVMConstantStructValueKind
,
271 LLVMConstantVectorValueKind
,
273 LLVMUndefValueValueKind
,
274 LLVMConstantAggregateZeroValueKind
,
275 LLVMConstantDataArrayValueKind
,
276 LLVMConstantDataVectorValueKind
,
277 LLVMConstantIntValueKind
,
278 LLVMConstantFPValueKind
,
279 LLVMConstantPointerNullValueKind
,
280 LLVMConstantTokenNoneValueKind
,
282 LLVMMetadataAsValueValueKind
,
283 LLVMInlineAsmValueKind
,
285 LLVMInstructionValueKind
,
286 LLVMPoisonValueValueKind
290 LLVMIntEQ
= 32, /**< equal */
291 LLVMIntNE
, /**< not equal */
292 LLVMIntUGT
, /**< unsigned greater than */
293 LLVMIntUGE
, /**< unsigned greater or equal */
294 LLVMIntULT
, /**< unsigned less than */
295 LLVMIntULE
, /**< unsigned less or equal */
296 LLVMIntSGT
, /**< signed greater than */
297 LLVMIntSGE
, /**< signed greater or equal */
298 LLVMIntSLT
, /**< signed less than */
299 LLVMIntSLE
/**< signed less or equal */
303 LLVMRealPredicateFalse
, /**< Always false (always folded) */
304 LLVMRealOEQ
, /**< True if ordered and equal */
305 LLVMRealOGT
, /**< True if ordered and greater than */
306 LLVMRealOGE
, /**< True if ordered and greater than or equal */
307 LLVMRealOLT
, /**< True if ordered and less than */
308 LLVMRealOLE
, /**< True if ordered and less than or equal */
309 LLVMRealONE
, /**< True if ordered and operands are unequal */
310 LLVMRealORD
, /**< True if ordered (no nans) */
311 LLVMRealUNO
, /**< True if unordered: isnan(X) | isnan(Y) */
312 LLVMRealUEQ
, /**< True if unordered or equal */
313 LLVMRealUGT
, /**< True if unordered or greater than */
314 LLVMRealUGE
, /**< True if unordered, greater than, or equal */
315 LLVMRealULT
, /**< True if unordered or less than */
316 LLVMRealULE
, /**< True if unordered, less than, or equal */
317 LLVMRealUNE
, /**< True if unordered or not equal */
318 LLVMRealPredicateTrue
/**< Always true (always folded) */
322 LLVMLandingPadCatch
, /**< A catch clause */
323 LLVMLandingPadFilter
/**< A filter clause */
324 } LLVMLandingPadClauseTy
;
327 LLVMNotThreadLocal
= 0,
328 LLVMGeneralDynamicTLSModel
,
329 LLVMLocalDynamicTLSModel
,
330 LLVMInitialExecTLSModel
,
331 LLVMLocalExecTLSModel
332 } LLVMThreadLocalMode
;
335 LLVMAtomicOrderingNotAtomic
= 0, /**< A load or store which is not atomic */
336 LLVMAtomicOrderingUnordered
= 1, /**< Lowest level of atomicity, guarantees
337 somewhat sane results, lock free. */
338 LLVMAtomicOrderingMonotonic
= 2, /**< guarantees that if you take all the
339 operations affecting a specific address,
340 a consistent ordering exists */
341 LLVMAtomicOrderingAcquire
= 4, /**< Acquire provides a barrier of the sort
342 necessary to acquire a lock to access other
343 memory with normal loads and stores. */
344 LLVMAtomicOrderingRelease
= 5, /**< Release is similar to Acquire, but with
345 a barrier of the sort necessary to release
347 LLVMAtomicOrderingAcquireRelease
= 6, /**< provides both an Acquire and a
348 Release barrier (for fences and
349 operations which both read and write
351 LLVMAtomicOrderingSequentiallyConsistent
= 7 /**< provides Acquire semantics
352 for loads and Release
353 semantics for stores.
354 Additionally, it guarantees
355 that a total ordering exists
357 SequentiallyConsistent
359 } LLVMAtomicOrdering
;
362 LLVMAtomicRMWBinOpXchg
, /**< Set the new value and return the one old */
363 LLVMAtomicRMWBinOpAdd
, /**< Add a value and return the old one */
364 LLVMAtomicRMWBinOpSub
, /**< Subtract a value and return the old one */
365 LLVMAtomicRMWBinOpAnd
, /**< And a value and return the old one */
366 LLVMAtomicRMWBinOpNand
, /**< Not-And a value and return the old one */
367 LLVMAtomicRMWBinOpOr
, /**< OR a value and return the old one */
368 LLVMAtomicRMWBinOpXor
, /**< Xor a value and return the old one */
369 LLVMAtomicRMWBinOpMax
, /**< Sets the value if it's greater than the
370 original using a signed comparison and return
372 LLVMAtomicRMWBinOpMin
, /**< Sets the value if it's Smaller than the
373 original using a signed comparison and return
375 LLVMAtomicRMWBinOpUMax
, /**< Sets the value if it's greater than the
376 original using an unsigned comparison and return
378 LLVMAtomicRMWBinOpUMin
, /**< Sets the value if it's greater than the
379 original using an unsigned comparison and return
381 LLVMAtomicRMWBinOpFAdd
, /**< Add a floating point value and return the
383 LLVMAtomicRMWBinOpFSub
/**< Subtract a floating point value and return the
385 } LLVMAtomicRMWBinOp
;
392 } LLVMDiagnosticSeverity
;
395 LLVMInlineAsmDialectATT
,
396 LLVMInlineAsmDialectIntel
397 } LLVMInlineAsmDialect
;
401 * Emits an error if two values disagree, otherwise the resulting value is
402 * that of the operands.
404 * @see Module::ModFlagBehavior::Error
406 LLVMModuleFlagBehaviorError
,
408 * Emits a warning if two values disagree. The result value will be the
409 * operand for the flag from the first module being linked.
411 * @see Module::ModFlagBehavior::Warning
413 LLVMModuleFlagBehaviorWarning
,
415 * Adds a requirement that another module flag be present and have a
416 * specified value after linking is performed. The value must be a metadata
417 * pair, where the first element of the pair is the ID of the module flag
418 * to be restricted, and the second element of the pair is the value the
419 * module flag should be restricted to. This behavior can be used to
420 * restrict the allowable results (via triggering of an error) of linking
421 * IDs with the **Override** behavior.
423 * @see Module::ModFlagBehavior::Require
425 LLVMModuleFlagBehaviorRequire
,
427 * Uses the specified value, regardless of the behavior or value of the
428 * other module. If both modules specify **Override**, but the values
429 * differ, an error will be emitted.
431 * @see Module::ModFlagBehavior::Override
433 LLVMModuleFlagBehaviorOverride
,
435 * Appends the two values, which are required to be metadata nodes.
437 * @see Module::ModFlagBehavior::Append
439 LLVMModuleFlagBehaviorAppend
,
441 * Appends the two values, which are required to be metadata
442 * nodes. However, duplicate entries in the second list are dropped
443 * during the append operation.
445 * @see Module::ModFlagBehavior::AppendUnique
447 LLVMModuleFlagBehaviorAppendUnique
,
448 } LLVMModuleFlagBehavior
;
451 * Attribute index are either LLVMAttributeReturnIndex,
452 * LLVMAttributeFunctionIndex or a parameter number from 1 to N.
455 LLVMAttributeReturnIndex
= 0U,
456 // ISO C restricts enumerator values to range of 'int'
457 // (4294967295 is too large)
458 // LLVMAttributeFunctionIndex = ~0U,
459 LLVMAttributeFunctionIndex
= -1,
462 typedef unsigned LLVMAttributeIndex
;
468 void LLVMInitializeCore(LLVMPassRegistryRef R
);
470 /** Deallocate and destroy all ManagedStatic variables.
471 @see llvm::llvm_shutdown
472 @see ManagedStatic */
473 void LLVMShutdown(void);
475 /*===-- Error handling ----------------------------------------------------===*/
477 char *LLVMCreateMessage(const char *Message
);
478 void LLVMDisposeMessage(char *Message
);
481 * @defgroup LLVMCCoreContext Contexts
483 * Contexts are execution states for the core LLVM IR system.
485 * Most types are tied to a context instance. Multiple contexts can
486 * exist simultaneously. A single context is not thread safe. However,
487 * different contexts can execute on different threads simultaneously.
492 typedef void (*LLVMDiagnosticHandler
)(LLVMDiagnosticInfoRef
, void *);
493 typedef void (*LLVMYieldCallback
)(LLVMContextRef
, void *);
496 * Create a new context.
498 * Every call to this function should be paired with a call to
499 * LLVMContextDispose() or the context will leak memory.
501 LLVMContextRef
LLVMContextCreate(void);
504 * Obtain the global context instance.
506 LLVMContextRef
LLVMGetGlobalContext(void);
509 * Set the diagnostic handler for this context.
511 void LLVMContextSetDiagnosticHandler(LLVMContextRef C
,
512 LLVMDiagnosticHandler Handler
,
513 void *DiagnosticContext
);
516 * Get the diagnostic handler of this context.
518 LLVMDiagnosticHandler
LLVMContextGetDiagnosticHandler(LLVMContextRef C
);
521 * Get the diagnostic context of this context.
523 void *LLVMContextGetDiagnosticContext(LLVMContextRef C
);
526 * Set the yield callback function for this context.
528 * @see LLVMContext::setYieldCallback()
530 void LLVMContextSetYieldCallback(LLVMContextRef C
, LLVMYieldCallback Callback
,
534 * Retrieve whether the given context is set to discard all value names.
536 * @see LLVMContext::shouldDiscardValueNames()
538 LLVMBool
LLVMContextShouldDiscardValueNames(LLVMContextRef C
);
541 * Set whether the given context discards all value names.
543 * If true, only the names of GlobalValue objects will be available in the IR.
544 * This can be used to save memory and runtime, especially in release mode.
546 * @see LLVMContext::setDiscardValueNames()
548 void LLVMContextSetDiscardValueNames(LLVMContextRef C
, LLVMBool Discard
);
551 * Destroy a context instance.
553 * This should be called for every call to LLVMContextCreate() or memory
556 void LLVMContextDispose(LLVMContextRef C
);
559 * Return a string representation of the DiagnosticInfo. Use
560 * LLVMDisposeMessage to free the string.
562 * @see DiagnosticInfo::print()
564 char *LLVMGetDiagInfoDescription(LLVMDiagnosticInfoRef DI
);
567 * Return an enum LLVMDiagnosticSeverity.
569 * @see DiagnosticInfo::getSeverity()
571 LLVMDiagnosticSeverity
LLVMGetDiagInfoSeverity(LLVMDiagnosticInfoRef DI
);
573 unsigned LLVMGetMDKindIDInContext(LLVMContextRef C
, const char *Name
,
575 unsigned LLVMGetMDKindID(const char *Name
, unsigned SLen
);
578 * Return an unique id given the name of a enum attribute,
579 * or 0 if no attribute by that name exists.
581 * See http://llvm.org/docs/LangRef.html#parameter-attributes
582 * and http://llvm.org/docs/LangRef.html#function-attributes
583 * for the list of available attributes.
585 * NB: Attribute names and/or id are subject to change without
586 * going through the C API deprecation cycle.
588 unsigned LLVMGetEnumAttributeKindForName(const char *Name
, size_t SLen
);
589 unsigned LLVMGetLastEnumAttributeKind(void);
592 * Create an enum attribute.
594 LLVMAttributeRef
LLVMCreateEnumAttribute(LLVMContextRef C
, unsigned KindID
,
598 * Get the unique id corresponding to the enum attribute
599 * passed as argument.
601 unsigned LLVMGetEnumAttributeKind(LLVMAttributeRef A
);
604 * Get the enum attribute's value. 0 is returned if none exists.
606 uint64_t LLVMGetEnumAttributeValue(LLVMAttributeRef A
);
609 * Create a type attribute
611 LLVMAttributeRef
LLVMCreateTypeAttribute(LLVMContextRef C
, unsigned KindID
,
612 LLVMTypeRef type_ref
);
615 * Get the type attribute's value.
617 LLVMTypeRef
LLVMGetTypeAttributeValue(LLVMAttributeRef A
);
620 * Create a string attribute.
622 LLVMAttributeRef
LLVMCreateStringAttribute(LLVMContextRef C
,
623 const char *K
, unsigned KLength
,
624 const char *V
, unsigned VLength
);
627 * Get the string attribute's kind.
629 const char *LLVMGetStringAttributeKind(LLVMAttributeRef A
, unsigned *Length
);
632 * Get the string attribute's value.
634 const char *LLVMGetStringAttributeValue(LLVMAttributeRef A
, unsigned *Length
);
637 * Check for the different types of attributes.
639 LLVMBool
LLVMIsEnumAttribute(LLVMAttributeRef A
);
640 LLVMBool
LLVMIsStringAttribute(LLVMAttributeRef A
);
641 LLVMBool
LLVMIsTypeAttribute(LLVMAttributeRef A
);
644 * Obtain a Type from a context by its registered name.
646 LLVMTypeRef
LLVMGetTypeByName2(LLVMContextRef C
, const char *Name
);
653 * @defgroup LLVMCCoreModule Modules
655 * Modules represent the top-level structure in an LLVM program. An LLVM
656 * module is effectively a translation unit or a collection of
657 * translation units merged together.
663 * Create a new, empty module in the global context.
665 * This is equivalent to calling LLVMModuleCreateWithNameInContext with
666 * LLVMGetGlobalContext() as the context parameter.
668 * Every invocation should be paired with LLVMDisposeModule() or memory
671 LLVMModuleRef
LLVMModuleCreateWithName(const char *ModuleID
);
674 * Create a new, empty module in a specific context.
676 * Every invocation should be paired with LLVMDisposeModule() or memory
679 LLVMModuleRef
LLVMModuleCreateWithNameInContext(const char *ModuleID
,
682 * Return an exact copy of the specified module.
684 LLVMModuleRef
LLVMCloneModule(LLVMModuleRef M
);
687 * Destroy a module instance.
689 * This must be called for every created module or memory will be
692 void LLVMDisposeModule(LLVMModuleRef M
);
695 * Obtain the identifier of a module.
697 * @param M Module to obtain identifier of
698 * @param Len Out parameter which holds the length of the returned string.
699 * @return The identifier of M.
700 * @see Module::getModuleIdentifier()
702 const char *LLVMGetModuleIdentifier(LLVMModuleRef M
, size_t *Len
);
705 * Set the identifier of a module to a string Ident with length Len.
707 * @param M The module to set identifier
708 * @param Ident The string to set M's identifier to
709 * @param Len Length of Ident
710 * @see Module::setModuleIdentifier()
712 void LLVMSetModuleIdentifier(LLVMModuleRef M
, const char *Ident
, size_t Len
);
715 * Obtain the module's original source file name.
717 * @param M Module to obtain the name of
718 * @param Len Out parameter which holds the length of the returned string
719 * @return The original source file name of M
720 * @see Module::getSourceFileName()
722 const char *LLVMGetSourceFileName(LLVMModuleRef M
, size_t *Len
);
725 * Set the original source file name of a module to a string Name with length
728 * @param M The module to set the source file name of
729 * @param Name The string to set M's source file name to
730 * @param Len Length of Name
731 * @see Module::setSourceFileName()
733 void LLVMSetSourceFileName(LLVMModuleRef M
, const char *Name
, size_t Len
);
736 * Obtain the data layout for a module.
738 * @see Module::getDataLayoutStr()
740 * LLVMGetDataLayout is DEPRECATED, as the name is not only incorrect,
741 * but match the name of another method on the module. Prefer the use
742 * of LLVMGetDataLayoutStr, which is not ambiguous.
744 const char *LLVMGetDataLayoutStr(LLVMModuleRef M
);
745 const char *LLVMGetDataLayout(LLVMModuleRef M
);
748 * Set the data layout for a module.
750 * @see Module::setDataLayout()
752 void LLVMSetDataLayout(LLVMModuleRef M
, const char *DataLayoutStr
);
755 * Obtain the target triple for a module.
757 * @see Module::getTargetTriple()
759 const char *LLVMGetTarget(LLVMModuleRef M
);
762 * Set the target triple for a module.
764 * @see Module::setTargetTriple()
766 void LLVMSetTarget(LLVMModuleRef M
, const char *Triple
);
769 * Returns the module flags as an array of flag-key-value triples. The caller
770 * is responsible for freeing this array by calling
771 * \c LLVMDisposeModuleFlagsMetadata.
773 * @see Module::getModuleFlagsMetadata()
775 LLVMModuleFlagEntry
*LLVMCopyModuleFlagsMetadata(LLVMModuleRef M
, size_t *Len
);
778 * Destroys module flags metadata entries.
780 void LLVMDisposeModuleFlagsMetadata(LLVMModuleFlagEntry
*Entries
);
783 * Returns the flag behavior for a module flag entry at a specific index.
785 * @see Module::ModuleFlagEntry::Behavior
787 LLVMModuleFlagBehavior
788 LLVMModuleFlagEntriesGetFlagBehavior(LLVMModuleFlagEntry
*Entries
,
792 * Returns the key for a module flag entry at a specific index.
794 * @see Module::ModuleFlagEntry::Key
796 const char *LLVMModuleFlagEntriesGetKey(LLVMModuleFlagEntry
*Entries
,
797 unsigned Index
, size_t *Len
);
800 * Returns the metadata for a module flag entry at a specific index.
802 * @see Module::ModuleFlagEntry::Val
804 LLVMMetadataRef
LLVMModuleFlagEntriesGetMetadata(LLVMModuleFlagEntry
*Entries
,
808 * Add a module-level flag to the module-level flags metadata if it doesn't
811 * @see Module::getModuleFlag()
813 LLVMMetadataRef
LLVMGetModuleFlag(LLVMModuleRef M
,
814 const char *Key
, size_t KeyLen
);
817 * Add a module-level flag to the module-level flags metadata if it doesn't
820 * @see Module::addModuleFlag()
822 void LLVMAddModuleFlag(LLVMModuleRef M
, LLVMModuleFlagBehavior Behavior
,
823 const char *Key
, size_t KeyLen
,
824 LLVMMetadataRef Val
);
827 * Dump a representation of a module to stderr.
829 * @see Module::dump()
831 void LLVMDumpModule(LLVMModuleRef M
);
834 * Print a representation of a module to a file. The ErrorMessage needs to be
835 * disposed with LLVMDisposeMessage. Returns 0 on success, 1 otherwise.
837 * @see Module::print()
839 LLVMBool
LLVMPrintModuleToFile(LLVMModuleRef M
, const char *Filename
,
840 char **ErrorMessage
);
843 * Return a string representation of the module. Use
844 * LLVMDisposeMessage to free the string.
846 * @see Module::print()
848 char *LLVMPrintModuleToString(LLVMModuleRef M
);
851 * Get inline assembly for a module.
853 * @see Module::getModuleInlineAsm()
855 const char *LLVMGetModuleInlineAsm(LLVMModuleRef M
, size_t *Len
);
858 * Set inline assembly for a module.
860 * @see Module::setModuleInlineAsm()
862 void LLVMSetModuleInlineAsm2(LLVMModuleRef M
, const char *Asm
, size_t Len
);
865 * Append inline assembly to a module.
867 * @see Module::appendModuleInlineAsm()
869 void LLVMAppendModuleInlineAsm(LLVMModuleRef M
, const char *Asm
, size_t Len
);
872 * Create the specified uniqued inline asm string.
874 * @see InlineAsm::get()
876 LLVMValueRef
LLVMGetInlineAsm(LLVMTypeRef Ty
, char *AsmString
,
877 size_t AsmStringSize
, char *Constraints
,
878 size_t ConstraintsSize
, LLVMBool HasSideEffects
,
879 LLVMBool IsAlignStack
,
880 LLVMInlineAsmDialect Dialect
, LLVMBool CanThrow
);
883 * Obtain the context to which this module is associated.
885 * @see Module::getContext()
887 LLVMContextRef
LLVMGetModuleContext(LLVMModuleRef M
);
889 /** Deprecated: Use LLVMGetTypeByName2 instead. */
890 LLVMTypeRef
LLVMGetTypeByName(LLVMModuleRef M
, const char *Name
);
893 * Obtain an iterator to the first NamedMDNode in a Module.
895 * @see llvm::Module::named_metadata_begin()
897 LLVMNamedMDNodeRef
LLVMGetFirstNamedMetadata(LLVMModuleRef M
);
900 * Obtain an iterator to the last NamedMDNode in a Module.
902 * @see llvm::Module::named_metadata_end()
904 LLVMNamedMDNodeRef
LLVMGetLastNamedMetadata(LLVMModuleRef M
);
907 * Advance a NamedMDNode iterator to the next NamedMDNode.
909 * Returns NULL if the iterator was already at the end and there are no more
910 * named metadata nodes.
912 LLVMNamedMDNodeRef
LLVMGetNextNamedMetadata(LLVMNamedMDNodeRef NamedMDNode
);
915 * Decrement a NamedMDNode iterator to the previous NamedMDNode.
917 * Returns NULL if the iterator was already at the beginning and there are
918 * no previous named metadata nodes.
920 LLVMNamedMDNodeRef
LLVMGetPreviousNamedMetadata(LLVMNamedMDNodeRef NamedMDNode
);
923 * Retrieve a NamedMDNode with the given name, returning NULL if no such
926 * @see llvm::Module::getNamedMetadata()
928 LLVMNamedMDNodeRef
LLVMGetNamedMetadata(LLVMModuleRef M
,
929 const char *Name
, size_t NameLen
);
932 * Retrieve a NamedMDNode with the given name, creating a new node if no such
935 * @see llvm::Module::getOrInsertNamedMetadata()
937 LLVMNamedMDNodeRef
LLVMGetOrInsertNamedMetadata(LLVMModuleRef M
,
942 * Retrieve the name of a NamedMDNode.
944 * @see llvm::NamedMDNode::getName()
946 const char *LLVMGetNamedMetadataName(LLVMNamedMDNodeRef NamedMD
,
950 * Obtain the number of operands for named metadata in a module.
952 * @see llvm::Module::getNamedMetadata()
954 unsigned LLVMGetNamedMetadataNumOperands(LLVMModuleRef M
, const char *Name
);
957 * Obtain the named metadata operands for a module.
959 * The passed LLVMValueRef pointer should refer to an array of
960 * LLVMValueRef at least LLVMGetNamedMetadataNumOperands long. This
961 * array will be populated with the LLVMValueRef instances. Each
962 * instance corresponds to a llvm::MDNode.
964 * @see llvm::Module::getNamedMetadata()
965 * @see llvm::MDNode::getOperand()
967 void LLVMGetNamedMetadataOperands(LLVMModuleRef M
, const char *Name
,
971 * Add an operand to named metadata.
973 * @see llvm::Module::getNamedMetadata()
974 * @see llvm::MDNode::addOperand()
976 void LLVMAddNamedMetadataOperand(LLVMModuleRef M
, const char *Name
,
980 * Return the directory of the debug location for this value, which must be
981 * an llvm::Instruction, llvm::GlobalVariable, or llvm::Function.
983 * @see llvm::Instruction::getDebugLoc()
984 * @see llvm::GlobalVariable::getDebugInfo()
985 * @see llvm::Function::getSubprogram()
987 const char *LLVMGetDebugLocDirectory(LLVMValueRef Val
, unsigned *Length
);
990 * Return the filename of the debug location for this value, which must be
991 * an llvm::Instruction, llvm::GlobalVariable, or llvm::Function.
993 * @see llvm::Instruction::getDebugLoc()
994 * @see llvm::GlobalVariable::getDebugInfo()
995 * @see llvm::Function::getSubprogram()
997 const char *LLVMGetDebugLocFilename(LLVMValueRef Val
, unsigned *Length
);
1000 * Return the line number of the debug location for this value, which must be
1001 * an llvm::Instruction, llvm::GlobalVariable, or llvm::Function.
1003 * @see llvm::Instruction::getDebugLoc()
1004 * @see llvm::GlobalVariable::getDebugInfo()
1005 * @see llvm::Function::getSubprogram()
1007 unsigned LLVMGetDebugLocLine(LLVMValueRef Val
);
1010 * Return the column number of the debug location for this value, which must be
1011 * an llvm::Instruction.
1013 * @see llvm::Instruction::getDebugLoc()
1015 unsigned LLVMGetDebugLocColumn(LLVMValueRef Val
);
1018 * Add a function to a module under a specified name.
1020 * @see llvm::Function::Create()
1022 LLVMValueRef
LLVMAddFunction(LLVMModuleRef M
, const char *Name
,
1023 LLVMTypeRef FunctionTy
);
1026 * Obtain a Function value from a Module by its name.
1028 * The returned value corresponds to a llvm::Function value.
1030 * @see llvm::Module::getFunction()
1032 LLVMValueRef
LLVMGetNamedFunction(LLVMModuleRef M
, const char *Name
);
1035 * Obtain an iterator to the first Function in a Module.
1037 * @see llvm::Module::begin()
1039 LLVMValueRef
LLVMGetFirstFunction(LLVMModuleRef M
);
1042 * Obtain an iterator to the last Function in a Module.
1044 * @see llvm::Module::end()
1046 LLVMValueRef
LLVMGetLastFunction(LLVMModuleRef M
);
1049 * Advance a Function iterator to the next Function.
1051 * Returns NULL if the iterator was already at the end and there are no more
1054 LLVMValueRef
LLVMGetNextFunction(LLVMValueRef Fn
);
1057 * Decrement a Function iterator to the previous Function.
1059 * Returns NULL if the iterator was already at the beginning and there are
1060 * no previous functions.
1062 LLVMValueRef
LLVMGetPreviousFunction(LLVMValueRef Fn
);
1064 /** Deprecated: Use LLVMSetModuleInlineAsm2 instead. */
1065 void LLVMSetModuleInlineAsm(LLVMModuleRef M
, const char *Asm
);
1072 * @defgroup LLVMCCoreType Types
1074 * Types represent the type of a value.
1076 * Types are associated with a context instance. The context internally
1077 * deduplicates types so there is only 1 instance of a specific type
1078 * alive at a time. In other words, a unique type is shared among all
1079 * consumers within a context.
1081 * A Type in the C API corresponds to llvm::Type.
1083 * Types have the following hierarchy:
1101 * Obtain the enumerated type of a Type instance.
1103 * @see llvm::Type:getTypeID()
1105 LLVMTypeKind
LLVMGetTypeKind(LLVMTypeRef Ty
);
1108 * Whether the type has a known size.
1110 * Things that don't have a size are abstract types, labels, and void.a
1112 * @see llvm::Type::isSized()
1114 LLVMBool
LLVMTypeIsSized(LLVMTypeRef Ty
);
1117 * Obtain the context to which this type instance is associated.
1119 * @see llvm::Type::getContext()
1121 LLVMContextRef
LLVMGetTypeContext(LLVMTypeRef Ty
);
1124 * Dump a representation of a type to stderr.
1126 * @see llvm::Type::dump()
1128 void LLVMDumpType(LLVMTypeRef Val
);
1131 * Return a string representation of the type. Use
1132 * LLVMDisposeMessage to free the string.
1134 * @see llvm::Type::print()
1136 char *LLVMPrintTypeToString(LLVMTypeRef Val
);
1139 * @defgroup LLVMCCoreTypeInt Integer Types
1141 * Functions in this section operate on integer types.
1147 * Obtain an integer type from a context with specified bit width.
1149 LLVMTypeRef
LLVMInt1TypeInContext(LLVMContextRef C
);
1150 LLVMTypeRef
LLVMInt8TypeInContext(LLVMContextRef C
);
1151 LLVMTypeRef
LLVMInt16TypeInContext(LLVMContextRef C
);
1152 LLVMTypeRef
LLVMInt32TypeInContext(LLVMContextRef C
);
1153 LLVMTypeRef
LLVMInt64TypeInContext(LLVMContextRef C
);
1154 LLVMTypeRef
LLVMInt128TypeInContext(LLVMContextRef C
);
1155 LLVMTypeRef
LLVMIntTypeInContext(LLVMContextRef C
, unsigned NumBits
);
1158 * Obtain an integer type from the global context with a specified bit
1161 LLVMTypeRef
LLVMInt1Type(void);
1162 LLVMTypeRef
LLVMInt8Type(void);
1163 LLVMTypeRef
LLVMInt16Type(void);
1164 LLVMTypeRef
LLVMInt32Type(void);
1165 LLVMTypeRef
LLVMInt64Type(void);
1166 LLVMTypeRef
LLVMInt128Type(void);
1167 LLVMTypeRef
LLVMIntType(unsigned NumBits
);
1168 unsigned LLVMGetIntTypeWidth(LLVMTypeRef IntegerTy
);
1175 * @defgroup LLVMCCoreTypeFloat Floating Point Types
1181 * Obtain a 16-bit floating point type from a context.
1183 LLVMTypeRef
LLVMHalfTypeInContext(LLVMContextRef C
);
1186 * Obtain a 16-bit brain floating point type from a context.
1188 LLVMTypeRef
LLVMBFloatTypeInContext(LLVMContextRef C
);
1191 * Obtain a 32-bit floating point type from a context.
1193 LLVMTypeRef
LLVMFloatTypeInContext(LLVMContextRef C
);
1196 * Obtain a 64-bit floating point type from a context.
1198 LLVMTypeRef
LLVMDoubleTypeInContext(LLVMContextRef C
);
1201 * Obtain a 80-bit floating point type (X87) from a context.
1203 LLVMTypeRef
LLVMX86FP80TypeInContext(LLVMContextRef C
);
1206 * Obtain a 128-bit floating point type (112-bit mantissa) from a
1209 LLVMTypeRef
LLVMFP128TypeInContext(LLVMContextRef C
);
1212 * Obtain a 128-bit floating point type (two 64-bits) from a context.
1214 LLVMTypeRef
LLVMPPCFP128TypeInContext(LLVMContextRef C
);
1217 * Obtain a floating point type from the global context.
1219 * These map to the functions in this group of the same name.
1221 LLVMTypeRef
LLVMHalfType(void);
1222 LLVMTypeRef
LLVMBFloatType(void);
1223 LLVMTypeRef
LLVMFloatType(void);
1224 LLVMTypeRef
LLVMDoubleType(void);
1225 LLVMTypeRef
LLVMX86FP80Type(void);
1226 LLVMTypeRef
LLVMFP128Type(void);
1227 LLVMTypeRef
LLVMPPCFP128Type(void);
1234 * @defgroup LLVMCCoreTypeFunction Function Types
1240 * Obtain a function type consisting of a specified signature.
1242 * The function is defined as a tuple of a return Type, a list of
1243 * parameter types, and whether the function is variadic.
1245 LLVMTypeRef
LLVMFunctionType(LLVMTypeRef ReturnType
,
1246 LLVMTypeRef
*ParamTypes
, unsigned ParamCount
,
1250 * Returns whether a function type is variadic.
1252 LLVMBool
LLVMIsFunctionVarArg(LLVMTypeRef FunctionTy
);
1255 * Obtain the Type this function Type returns.
1257 LLVMTypeRef
LLVMGetReturnType(LLVMTypeRef FunctionTy
);
1260 * Obtain the number of parameters this function accepts.
1262 unsigned LLVMCountParamTypes(LLVMTypeRef FunctionTy
);
1265 * Obtain the types of a function's parameters.
1267 * The Dest parameter should point to a pre-allocated array of
1268 * LLVMTypeRef at least LLVMCountParamTypes() large. On return, the
1269 * first LLVMCountParamTypes() entries in the array will be populated
1270 * with LLVMTypeRef instances.
1272 * @param FunctionTy The function type to operate on.
1273 * @param Dest Memory address of an array to be filled with result.
1275 void LLVMGetParamTypes(LLVMTypeRef FunctionTy
, LLVMTypeRef
*Dest
);
1282 * @defgroup LLVMCCoreTypeStruct Structure Types
1284 * These functions relate to LLVMTypeRef instances.
1286 * @see llvm::StructType
1292 * Create a new structure type in a context.
1294 * A structure is specified by a list of inner elements/types and
1295 * whether these can be packed together.
1297 * @see llvm::StructType::create()
1299 LLVMTypeRef
LLVMStructTypeInContext(LLVMContextRef C
, LLVMTypeRef
*ElementTypes
,
1300 unsigned ElementCount
, LLVMBool Packed
);
1303 * Create a new structure type in the global context.
1305 * @see llvm::StructType::create()
1307 LLVMTypeRef
LLVMStructType(LLVMTypeRef
*ElementTypes
, unsigned ElementCount
,
1311 * Create an empty structure in a context having a specified name.
1313 * @see llvm::StructType::create()
1315 LLVMTypeRef
LLVMStructCreateNamed(LLVMContextRef C
, const char *Name
);
1318 * Obtain the name of a structure.
1320 * @see llvm::StructType::getName()
1322 const char *LLVMGetStructName(LLVMTypeRef Ty
);
1325 * Set the contents of a structure type.
1327 * @see llvm::StructType::setBody()
1329 void LLVMStructSetBody(LLVMTypeRef StructTy
, LLVMTypeRef
*ElementTypes
,
1330 unsigned ElementCount
, LLVMBool Packed
);
1333 * Get the number of elements defined inside the structure.
1335 * @see llvm::StructType::getNumElements()
1337 unsigned LLVMCountStructElementTypes(LLVMTypeRef StructTy
);
1340 * Get the elements within a structure.
1342 * The function is passed the address of a pre-allocated array of
1343 * LLVMTypeRef at least LLVMCountStructElementTypes() long. After
1344 * invocation, this array will be populated with the structure's
1345 * elements. The objects in the destination array will have a lifetime
1346 * of the structure type itself, which is the lifetime of the context it
1349 void LLVMGetStructElementTypes(LLVMTypeRef StructTy
, LLVMTypeRef
*Dest
);
1352 * Get the type of the element at a given index in the structure.
1354 * @see llvm::StructType::getTypeAtIndex()
1356 LLVMTypeRef
LLVMStructGetTypeAtIndex(LLVMTypeRef StructTy
, unsigned i
);
1359 * Determine whether a structure is packed.
1361 * @see llvm::StructType::isPacked()
1363 LLVMBool
LLVMIsPackedStruct(LLVMTypeRef StructTy
);
1366 * Determine whether a structure is opaque.
1368 * @see llvm::StructType::isOpaque()
1370 LLVMBool
LLVMIsOpaqueStruct(LLVMTypeRef StructTy
);
1373 * Determine whether a structure is literal.
1375 * @see llvm::StructType::isLiteral()
1377 LLVMBool
LLVMIsLiteralStruct(LLVMTypeRef StructTy
);
1384 * @defgroup LLVMCCoreTypeSequential Sequential Types
1386 * Sequential types represents "arrays" of types. This is a super class
1387 * for array, vector, and pointer types.
1393 * Obtain the type of elements within a sequential type.
1395 * This works on array, vector, and pointer types.
1397 * @see llvm::SequentialType::getElementType()
1399 LLVMTypeRef
LLVMGetElementType(LLVMTypeRef Ty
);
1402 * Returns type's subtypes
1404 * @see llvm::Type::subtypes()
1406 void LLVMGetSubtypes(LLVMTypeRef Tp
, LLVMTypeRef
*Arr
);
1409 * Return the number of types in the derived type.
1411 * @see llvm::Type::getNumContainedTypes()
1413 unsigned LLVMGetNumContainedTypes(LLVMTypeRef Tp
);
1416 * Create a fixed size array type that refers to a specific type.
1418 * The created type will exist in the context that its element type
1421 * @see llvm::ArrayType::get()
1423 LLVMTypeRef
LLVMArrayType(LLVMTypeRef ElementType
, unsigned ElementCount
);
1426 * Obtain the length of an array type.
1428 * This only works on types that represent arrays.
1430 * @see llvm::ArrayType::getNumElements()
1432 unsigned LLVMGetArrayLength(LLVMTypeRef ArrayTy
);
1435 * Create a pointer type that points to a defined type.
1437 * The created type will exist in the context that its pointee type
1440 * @see llvm::PointerType::get()
1442 LLVMTypeRef
LLVMPointerType(LLVMTypeRef ElementType
, unsigned AddressSpace
);
1445 * Obtain the address space of a pointer type.
1447 * This only works on types that represent pointers.
1449 * @see llvm::PointerType::getAddressSpace()
1451 unsigned LLVMGetPointerAddressSpace(LLVMTypeRef PointerTy
);
1454 * Create a vector type that contains a defined type and has a specific
1455 * number of elements.
1457 * The created type will exist in the context thats its element type
1460 * @see llvm::VectorType::get()
1462 LLVMTypeRef
LLVMVectorType(LLVMTypeRef ElementType
, unsigned ElementCount
);
1465 * Create a vector type that contains a defined type and has a scalable
1466 * number of elements.
1468 * The created type will exist in the context thats its element type
1471 * @see llvm::ScalableVectorType::get()
1473 LLVMTypeRef
LLVMScalableVectorType(LLVMTypeRef ElementType
,
1474 unsigned ElementCount
);
1477 * Obtain the (possibly scalable) number of elements in a vector type.
1479 * This only works on types that represent vectors (fixed or scalable).
1481 * @see llvm::VectorType::getNumElements()
1483 unsigned LLVMGetVectorSize(LLVMTypeRef VectorTy
);
1490 * @defgroup LLVMCCoreTypeOther Other Types
1496 * Create a void type in a context.
1498 LLVMTypeRef
LLVMVoidTypeInContext(LLVMContextRef C
);
1501 * Create a label type in a context.
1503 LLVMTypeRef
LLVMLabelTypeInContext(LLVMContextRef C
);
1506 * Create a X86 MMX type in a context.
1508 LLVMTypeRef
LLVMX86MMXTypeInContext(LLVMContextRef C
);
1511 * Create a X86 AMX type in a context.
1513 LLVMTypeRef
LLVMX86AMXTypeInContext(LLVMContextRef C
);
1516 * Create a token type in a context.
1518 LLVMTypeRef
LLVMTokenTypeInContext(LLVMContextRef C
);
1521 * Create a metadata type in a context.
1523 LLVMTypeRef
LLVMMetadataTypeInContext(LLVMContextRef C
);
1526 * These are similar to the above functions except they operate on the
1529 LLVMTypeRef
LLVMVoidType(void);
1530 LLVMTypeRef
LLVMLabelType(void);
1531 LLVMTypeRef
LLVMX86MMXType(void);
1532 LLVMTypeRef
LLVMX86AMXType(void);
1543 * @defgroup LLVMCCoreValues Values
1545 * The bulk of LLVM's object model consists of values, which comprise a very
1546 * rich type hierarchy.
1548 * LLVMValueRef essentially represents llvm::Value. There is a rich
1549 * hierarchy of classes within this type. Depending on the instance
1550 * obtained, not all APIs are available.
1552 * Callers can determine the type of an LLVMValueRef by calling the
1553 * LLVMIsA* family of functions (e.g. LLVMIsAArgument()). These
1554 * functions are defined by a macro, so it isn't obvious which are
1555 * available by looking at the Doxygen source code. Instead, look at the
1556 * source definition of LLVM_FOR_EACH_VALUE_SUBCLASS and note the list
1557 * of value names given. These value names also correspond to classes in
1558 * the llvm::Value hierarchy.
1563 #define LLVM_FOR_EACH_VALUE_SUBCLASS(macro) \
1569 macro(BlockAddress) \
1570 macro(ConstantAggregateZero) \
1571 macro(ConstantArray) \
1572 macro(ConstantDataSequential) \
1573 macro(ConstantDataArray) \
1574 macro(ConstantDataVector) \
1575 macro(ConstantExpr) \
1577 macro(ConstantInt) \
1578 macro(ConstantPointerNull) \
1579 macro(ConstantStruct) \
1580 macro(ConstantTokenNone) \
1581 macro(ConstantVector) \
1582 macro(GlobalValue) \
1583 macro(GlobalAlias) \
1584 macro(GlobalObject) \
1586 macro(GlobalVariable) \
1587 macro(GlobalIFunc) \
1589 macro(PoisonValue) \
1590 macro(Instruction) \
1591 macro(UnaryOperator) \
1592 macro(BinaryOperator) \
1594 macro(IntrinsicInst) \
1595 macro(DbgInfoIntrinsic) \
1596 macro(DbgVariableIntrinsic) \
1597 macro(DbgDeclareInst) \
1598 macro(DbgLabelInst) \
1599 macro(MemIntrinsic) \
1601 macro(MemMoveInst) \
1606 macro(ExtractElementInst) \
1607 macro(GetElementPtrInst) \
1608 macro(InsertElementInst) \
1609 macro(InsertValueInst) \
1610 macro(LandingPadInst) \
1613 macro(ShuffleVectorInst) \
1616 macro(IndirectBrInst) \
1620 macro(UnreachableInst) \
1622 macro(CleanupReturnInst) \
1623 macro(CatchReturnInst) \
1624 macro(CatchSwitchInst) \
1626 macro(FuncletPadInst) \
1627 macro(CatchPadInst) \
1628 macro(CleanupPadInst) \
1629 macro(UnaryInstruction) \
1632 macro(AddrSpaceCastInst) \
1633 macro(BitCastInst) \
1637 macro(FPTruncInst) \
1638 macro(IntToPtrInst) \
1639 macro(PtrToIntInst) \
1645 macro(ExtractValueInst) \
1649 macro(AtomicCmpXchgInst) \
1650 macro(AtomicRMWInst) \
1654 * @defgroup LLVMCCoreValueGeneral General APIs
1656 * Functions in this section work on all LLVMValueRef instances,
1657 * regardless of their sub-type. They correspond to functions available
1664 * Obtain the type of a value.
1666 * @see llvm::Value::getType()
1668 LLVMTypeRef
LLVMTypeOf(LLVMValueRef Val
);
1671 * Obtain the enumerated type of a Value instance.
1673 * @see llvm::Value::getValueID()
1675 LLVMValueKind
LLVMGetValueKind(LLVMValueRef Val
);
1678 * Obtain the string name of a value.
1680 * @see llvm::Value::getName()
1682 const char *LLVMGetValueName2(LLVMValueRef Val
, size_t *Length
);
1685 * Set the string name of a value.
1687 * @see llvm::Value::setName()
1689 void LLVMSetValueName2(LLVMValueRef Val
, const char *Name
, size_t NameLen
);
1692 * Dump a representation of a value to stderr.
1694 * @see llvm::Value::dump()
1696 void LLVMDumpValue(LLVMValueRef Val
);
1699 * Return a string representation of the value. Use
1700 * LLVMDisposeMessage to free the string.
1702 * @see llvm::Value::print()
1704 char *LLVMPrintValueToString(LLVMValueRef Val
);
1707 * Replace all uses of a value with another one.
1709 * @see llvm::Value::replaceAllUsesWith()
1711 void LLVMReplaceAllUsesWith(LLVMValueRef OldVal
, LLVMValueRef NewVal
);
1714 * Determine whether the specified value instance is constant.
1716 LLVMBool
LLVMIsConstant(LLVMValueRef Val
);
1719 * Determine whether a value instance is undefined.
1721 LLVMBool
LLVMIsUndef(LLVMValueRef Val
);
1724 * Determine whether a value instance is poisonous.
1726 LLVMBool
LLVMIsPoison(LLVMValueRef Val
);
1729 * Convert value instances between types.
1731 * Internally, an LLVMValueRef is "pinned" to a specific type. This
1732 * series of functions allows you to cast an instance to a specific
1735 * If the cast is not valid for the specified type, NULL is returned.
1737 * @see llvm::dyn_cast_or_null<>
1739 #define LLVM_DECLARE_VALUE_CAST(name) \
1740 LLVMValueRef LLVMIsA##name(LLVMValueRef Val);
1741 LLVM_FOR_EACH_VALUE_SUBCLASS(LLVM_DECLARE_VALUE_CAST
)
1743 LLVMValueRef
LLVMIsAMDNode(LLVMValueRef Val
);
1744 LLVMValueRef
LLVMIsAMDString(LLVMValueRef Val
);
1746 /** Deprecated: Use LLVMGetValueName2 instead. */
1747 const char *LLVMGetValueName(LLVMValueRef Val
);
1748 /** Deprecated: Use LLVMSetValueName2 instead. */
1749 void LLVMSetValueName(LLVMValueRef Val
, const char *Name
);
1756 * @defgroup LLVMCCoreValueUses Usage
1758 * This module defines functions that allow you to inspect the uses of a
1761 * It is possible to obtain an LLVMUseRef for any LLVMValueRef instance.
1762 * Each LLVMUseRef (which corresponds to a llvm::Use instance) holds a
1763 * llvm::User and llvm::Value.
1769 * Obtain the first use of a value.
1771 * Uses are obtained in an iterator fashion. First, call this function
1772 * to obtain a reference to the first use. Then, call LLVMGetNextUse()
1773 * on that instance and all subsequently obtained instances until
1774 * LLVMGetNextUse() returns NULL.
1776 * @see llvm::Value::use_begin()
1778 LLVMUseRef
LLVMGetFirstUse(LLVMValueRef Val
);
1781 * Obtain the next use of a value.
1783 * This effectively advances the iterator. It returns NULL if you are on
1784 * the final use and no more are available.
1786 LLVMUseRef
LLVMGetNextUse(LLVMUseRef U
);
1789 * Obtain the user value for a user.
1791 * The returned value corresponds to a llvm::User type.
1793 * @see llvm::Use::getUser()
1795 LLVMValueRef
LLVMGetUser(LLVMUseRef U
);
1798 * Obtain the value this use corresponds to.
1800 * @see llvm::Use::get().
1802 LLVMValueRef
LLVMGetUsedValue(LLVMUseRef U
);
1809 * @defgroup LLVMCCoreValueUser User value
1811 * Function in this group pertain to LLVMValueRef instances that descent
1812 * from llvm::User. This includes constants, instructions, and
1819 * Obtain an operand at a specific index in a llvm::User value.
1821 * @see llvm::User::getOperand()
1823 LLVMValueRef
LLVMGetOperand(LLVMValueRef Val
, unsigned Index
);
1826 * Obtain the use of an operand at a specific index in a llvm::User value.
1828 * @see llvm::User::getOperandUse()
1830 LLVMUseRef
LLVMGetOperandUse(LLVMValueRef Val
, unsigned Index
);
1833 * Set an operand at a specific index in a llvm::User value.
1835 * @see llvm::User::setOperand()
1837 void LLVMSetOperand(LLVMValueRef User
, unsigned Index
, LLVMValueRef Val
);
1840 * Obtain the number of operands in a llvm::User value.
1842 * @see llvm::User::getNumOperands()
1844 int LLVMGetNumOperands(LLVMValueRef Val
);
1851 * @defgroup LLVMCCoreValueConstant Constants
1853 * This section contains APIs for interacting with LLVMValueRef that
1854 * correspond to llvm::Constant instances.
1856 * These functions will work for any LLVMValueRef in the llvm::Constant
1863 * Obtain a constant value referring to the null instance of a type.
1865 * @see llvm::Constant::getNullValue()
1867 LLVMValueRef
LLVMConstNull(LLVMTypeRef Ty
); /* all zeroes */
1870 * Obtain a constant value referring to the instance of a type
1871 * consisting of all ones.
1873 * This is only valid for integer types.
1875 * @see llvm::Constant::getAllOnesValue()
1877 LLVMValueRef
LLVMConstAllOnes(LLVMTypeRef Ty
);
1880 * Obtain a constant value referring to an undefined value of a type.
1882 * @see llvm::UndefValue::get()
1884 LLVMValueRef
LLVMGetUndef(LLVMTypeRef Ty
);
1887 * Obtain a constant value referring to a poison value of a type.
1889 * @see llvm::PoisonValue::get()
1891 LLVMValueRef
LLVMGetPoison(LLVMTypeRef Ty
);
1894 * Determine whether a value instance is null.
1896 * @see llvm::Constant::isNullValue()
1898 LLVMBool
LLVMIsNull(LLVMValueRef Val
);
1901 * Obtain a constant that is a constant pointer pointing to NULL for a
1904 LLVMValueRef
LLVMConstPointerNull(LLVMTypeRef Ty
);
1907 * @defgroup LLVMCCoreValueConstantScalar Scalar constants
1909 * Functions in this group model LLVMValueRef instances that correspond
1910 * to constants referring to scalar types.
1912 * For integer types, the LLVMTypeRef parameter should correspond to a
1913 * llvm::IntegerType instance and the returned LLVMValueRef will
1914 * correspond to a llvm::ConstantInt.
1916 * For floating point types, the LLVMTypeRef returned corresponds to a
1923 * Obtain a constant value for an integer type.
1925 * The returned value corresponds to a llvm::ConstantInt.
1927 * @see llvm::ConstantInt::get()
1929 * @param IntTy Integer type to obtain value of.
1930 * @param N The value the returned instance should refer to.
1931 * @param SignExtend Whether to sign extend the produced value.
1933 LLVMValueRef
LLVMConstInt(LLVMTypeRef IntTy
, unsigned long long N
,
1934 LLVMBool SignExtend
);
1937 * Obtain a constant value for an integer of arbitrary precision.
1939 * @see llvm::ConstantInt::get()
1941 LLVMValueRef
LLVMConstIntOfArbitraryPrecision(LLVMTypeRef IntTy
,
1943 const uint64_t Words
[]);
1946 * Obtain a constant value for an integer parsed from a string.
1948 * A similar API, LLVMConstIntOfStringAndSize is also available. If the
1949 * string's length is available, it is preferred to call that function
1952 * @see llvm::ConstantInt::get()
1954 LLVMValueRef
LLVMConstIntOfString(LLVMTypeRef IntTy
, const char *Text
,
1958 * Obtain a constant value for an integer parsed from a string with
1961 * @see llvm::ConstantInt::get()
1963 LLVMValueRef
LLVMConstIntOfStringAndSize(LLVMTypeRef IntTy
, const char *Text
,
1964 unsigned SLen
, uint8_t Radix
);
1967 * Obtain a constant value referring to a double floating point value.
1969 LLVMValueRef
LLVMConstReal(LLVMTypeRef RealTy
, double N
);
1972 * Obtain a constant for a floating point value parsed from a string.
1974 * A similar API, LLVMConstRealOfStringAndSize is also available. It
1975 * should be used if the input string's length is known.
1977 LLVMValueRef
LLVMConstRealOfString(LLVMTypeRef RealTy
, const char *Text
);
1980 * Obtain a constant for a floating point value parsed from a string.
1982 LLVMValueRef
LLVMConstRealOfStringAndSize(LLVMTypeRef RealTy
, const char *Text
,
1986 * Obtain the zero extended value for an integer constant value.
1988 * @see llvm::ConstantInt::getZExtValue()
1990 unsigned long long LLVMConstIntGetZExtValue(LLVMValueRef ConstantVal
);
1993 * Obtain the sign extended value for an integer constant value.
1995 * @see llvm::ConstantInt::getSExtValue()
1997 long long LLVMConstIntGetSExtValue(LLVMValueRef ConstantVal
);
2000 * Obtain the double value for an floating point constant value.
2001 * losesInfo indicates if some precision was lost in the conversion.
2003 * @see llvm::ConstantFP::getDoubleValue
2005 double LLVMConstRealGetDouble(LLVMValueRef ConstantVal
, LLVMBool
*losesInfo
);
2012 * @defgroup LLVMCCoreValueConstantComposite Composite Constants
2014 * Functions in this group operate on composite constants.
2020 * Create a ConstantDataSequential and initialize it with a string.
2022 * @see llvm::ConstantDataArray::getString()
2024 LLVMValueRef
LLVMConstStringInContext(LLVMContextRef C
, const char *Str
,
2025 unsigned Length
, LLVMBool DontNullTerminate
);
2028 * Create a ConstantDataSequential with string content in the global context.
2030 * This is the same as LLVMConstStringInContext except it operates on the
2033 * @see LLVMConstStringInContext()
2034 * @see llvm::ConstantDataArray::getString()
2036 LLVMValueRef
LLVMConstString(const char *Str
, unsigned Length
,
2037 LLVMBool DontNullTerminate
);
2040 * Returns true if the specified constant is an array of i8.
2042 * @see ConstantDataSequential::getAsString()
2044 LLVMBool
LLVMIsConstantString(LLVMValueRef c
);
2047 * Get the given constant data sequential as a string.
2049 * @see ConstantDataSequential::getAsString()
2051 const char *LLVMGetAsString(LLVMValueRef c
, size_t *Length
);
2054 * Create an anonymous ConstantStruct with the specified values.
2056 * @see llvm::ConstantStruct::getAnon()
2058 LLVMValueRef
LLVMConstStructInContext(LLVMContextRef C
,
2059 LLVMValueRef
*ConstantVals
,
2060 unsigned Count
, LLVMBool Packed
);
2063 * Create a ConstantStruct in the global Context.
2065 * This is the same as LLVMConstStructInContext except it operates on the
2068 * @see LLVMConstStructInContext()
2070 LLVMValueRef
LLVMConstStruct(LLVMValueRef
*ConstantVals
, unsigned Count
,
2074 * Create a ConstantArray from values.
2076 * @see llvm::ConstantArray::get()
2078 LLVMValueRef
LLVMConstArray(LLVMTypeRef ElementTy
,
2079 LLVMValueRef
*ConstantVals
, unsigned Length
);
2082 * Create a non-anonymous ConstantStruct from values.
2084 * @see llvm::ConstantStruct::get()
2086 LLVMValueRef
LLVMConstNamedStruct(LLVMTypeRef StructTy
,
2087 LLVMValueRef
*ConstantVals
,
2091 * Get an element at specified index as a constant.
2093 * @see ConstantDataSequential::getElementAsConstant()
2095 LLVMValueRef
LLVMGetElementAsConstant(LLVMValueRef C
, unsigned idx
);
2098 * Create a ConstantVector from values.
2100 * @see llvm::ConstantVector::get()
2102 LLVMValueRef
LLVMConstVector(LLVMValueRef
*ScalarConstantVals
, unsigned Size
);
2109 * @defgroup LLVMCCoreValueConstantExpressions Constant Expressions
2111 * Functions in this group correspond to APIs on llvm::ConstantExpr.
2113 * @see llvm::ConstantExpr.
2117 LLVMOpcode
LLVMGetConstOpcode(LLVMValueRef ConstantVal
);
2118 LLVMValueRef
LLVMAlignOf(LLVMTypeRef Ty
);
2119 LLVMValueRef
LLVMSizeOf(LLVMTypeRef Ty
);
2120 LLVMValueRef
LLVMConstNeg(LLVMValueRef ConstantVal
);
2121 LLVMValueRef
LLVMConstNSWNeg(LLVMValueRef ConstantVal
);
2122 LLVMValueRef
LLVMConstNUWNeg(LLVMValueRef ConstantVal
);
2123 LLVMValueRef
LLVMConstFNeg(LLVMValueRef ConstantVal
);
2124 LLVMValueRef
LLVMConstNot(LLVMValueRef ConstantVal
);
2125 LLVMValueRef
LLVMConstAdd(LLVMValueRef LHSConstant
, LLVMValueRef RHSConstant
);
2126 LLVMValueRef
LLVMConstNSWAdd(LLVMValueRef LHSConstant
, LLVMValueRef RHSConstant
);
2127 LLVMValueRef
LLVMConstNUWAdd(LLVMValueRef LHSConstant
, LLVMValueRef RHSConstant
);
2128 LLVMValueRef
LLVMConstFAdd(LLVMValueRef LHSConstant
, LLVMValueRef RHSConstant
);
2129 LLVMValueRef
LLVMConstSub(LLVMValueRef LHSConstant
, LLVMValueRef RHSConstant
);
2130 LLVMValueRef
LLVMConstNSWSub(LLVMValueRef LHSConstant
, LLVMValueRef RHSConstant
);
2131 LLVMValueRef
LLVMConstNUWSub(LLVMValueRef LHSConstant
, LLVMValueRef RHSConstant
);
2132 LLVMValueRef
LLVMConstFSub(LLVMValueRef LHSConstant
, LLVMValueRef RHSConstant
);
2133 LLVMValueRef
LLVMConstMul(LLVMValueRef LHSConstant
, LLVMValueRef RHSConstant
);
2134 LLVMValueRef
LLVMConstNSWMul(LLVMValueRef LHSConstant
, LLVMValueRef RHSConstant
);
2135 LLVMValueRef
LLVMConstNUWMul(LLVMValueRef LHSConstant
, LLVMValueRef RHSConstant
);
2136 LLVMValueRef
LLVMConstFMul(LLVMValueRef LHSConstant
, LLVMValueRef RHSConstant
);
2137 LLVMValueRef
LLVMConstUDiv(LLVMValueRef LHSConstant
, LLVMValueRef RHSConstant
);
2138 LLVMValueRef
LLVMConstExactUDiv(LLVMValueRef LHSConstant
, LLVMValueRef RHSConstant
);
2139 LLVMValueRef
LLVMConstSDiv(LLVMValueRef LHSConstant
, LLVMValueRef RHSConstant
);
2140 LLVMValueRef
LLVMConstExactSDiv(LLVMValueRef LHSConstant
, LLVMValueRef RHSConstant
);
2141 LLVMValueRef
LLVMConstFDiv(LLVMValueRef LHSConstant
, LLVMValueRef RHSConstant
);
2142 LLVMValueRef
LLVMConstURem(LLVMValueRef LHSConstant
, LLVMValueRef RHSConstant
);
2143 LLVMValueRef
LLVMConstSRem(LLVMValueRef LHSConstant
, LLVMValueRef RHSConstant
);
2144 LLVMValueRef
LLVMConstFRem(LLVMValueRef LHSConstant
, LLVMValueRef RHSConstant
);
2145 LLVMValueRef
LLVMConstAnd(LLVMValueRef LHSConstant
, LLVMValueRef RHSConstant
);
2146 LLVMValueRef
LLVMConstOr(LLVMValueRef LHSConstant
, LLVMValueRef RHSConstant
);
2147 LLVMValueRef
LLVMConstXor(LLVMValueRef LHSConstant
, LLVMValueRef RHSConstant
);
2148 LLVMValueRef
LLVMConstICmp(LLVMIntPredicate Predicate
,
2149 LLVMValueRef LHSConstant
, LLVMValueRef RHSConstant
);
2150 LLVMValueRef
LLVMConstFCmp(LLVMRealPredicate Predicate
,
2151 LLVMValueRef LHSConstant
, LLVMValueRef RHSConstant
);
2152 LLVMValueRef
LLVMConstShl(LLVMValueRef LHSConstant
, LLVMValueRef RHSConstant
);
2153 LLVMValueRef
LLVMConstLShr(LLVMValueRef LHSConstant
, LLVMValueRef RHSConstant
);
2154 LLVMValueRef
LLVMConstAShr(LLVMValueRef LHSConstant
, LLVMValueRef RHSConstant
);
2155 LLVM_ATTRIBUTE_C_DEPRECATED(
2156 LLVMValueRef
LLVMConstGEP(LLVMValueRef ConstantVal
,
2157 LLVMValueRef
*ConstantIndices
,
2158 unsigned NumIndices
),
2159 "Use LLVMConstGEP2 instead to support opaque pointers");
2160 LLVMValueRef
LLVMConstGEP2(LLVMTypeRef Ty
, LLVMValueRef ConstantVal
,
2161 LLVMValueRef
*ConstantIndices
, unsigned NumIndices
);
2162 LLVM_ATTRIBUTE_C_DEPRECATED(
2163 LLVMValueRef
LLVMConstInBoundsGEP(LLVMValueRef ConstantVal
,
2164 LLVMValueRef
*ConstantIndices
,
2165 unsigned NumIndices
),
2166 "Use LLVMConstInBoundsGEP2 instead to support opaque pointers");
2167 LLVMValueRef
LLVMConstInBoundsGEP2(LLVMTypeRef Ty
, LLVMValueRef ConstantVal
,
2168 LLVMValueRef
*ConstantIndices
,
2169 unsigned NumIndices
);
2170 LLVMValueRef
LLVMConstTrunc(LLVMValueRef ConstantVal
, LLVMTypeRef ToType
);
2171 LLVMValueRef
LLVMConstSExt(LLVMValueRef ConstantVal
, LLVMTypeRef ToType
);
2172 LLVMValueRef
LLVMConstZExt(LLVMValueRef ConstantVal
, LLVMTypeRef ToType
);
2173 LLVMValueRef
LLVMConstFPTrunc(LLVMValueRef ConstantVal
, LLVMTypeRef ToType
);
2174 LLVMValueRef
LLVMConstFPExt(LLVMValueRef ConstantVal
, LLVMTypeRef ToType
);
2175 LLVMValueRef
LLVMConstUIToFP(LLVMValueRef ConstantVal
, LLVMTypeRef ToType
);
2176 LLVMValueRef
LLVMConstSIToFP(LLVMValueRef ConstantVal
, LLVMTypeRef ToType
);
2177 LLVMValueRef
LLVMConstFPToUI(LLVMValueRef ConstantVal
, LLVMTypeRef ToType
);
2178 LLVMValueRef
LLVMConstFPToSI(LLVMValueRef ConstantVal
, LLVMTypeRef ToType
);
2179 LLVMValueRef
LLVMConstPtrToInt(LLVMValueRef ConstantVal
, LLVMTypeRef ToType
);
2180 LLVMValueRef
LLVMConstIntToPtr(LLVMValueRef ConstantVal
, LLVMTypeRef ToType
);
2181 LLVMValueRef
LLVMConstBitCast(LLVMValueRef ConstantVal
, LLVMTypeRef ToType
);
2182 LLVMValueRef
LLVMConstAddrSpaceCast(LLVMValueRef ConstantVal
, LLVMTypeRef ToType
);
2183 LLVMValueRef
LLVMConstZExtOrBitCast(LLVMValueRef ConstantVal
,
2184 LLVMTypeRef ToType
);
2185 LLVMValueRef
LLVMConstSExtOrBitCast(LLVMValueRef ConstantVal
,
2186 LLVMTypeRef ToType
);
2187 LLVMValueRef
LLVMConstTruncOrBitCast(LLVMValueRef ConstantVal
,
2188 LLVMTypeRef ToType
);
2189 LLVMValueRef
LLVMConstPointerCast(LLVMValueRef ConstantVal
,
2190 LLVMTypeRef ToType
);
2191 LLVMValueRef
LLVMConstIntCast(LLVMValueRef ConstantVal
, LLVMTypeRef ToType
,
2193 LLVMValueRef
LLVMConstFPCast(LLVMValueRef ConstantVal
, LLVMTypeRef ToType
);
2194 LLVMValueRef
LLVMConstSelect(LLVMValueRef ConstantCondition
,
2195 LLVMValueRef ConstantIfTrue
,
2196 LLVMValueRef ConstantIfFalse
);
2197 LLVMValueRef
LLVMConstExtractElement(LLVMValueRef VectorConstant
,
2198 LLVMValueRef IndexConstant
);
2199 LLVMValueRef
LLVMConstInsertElement(LLVMValueRef VectorConstant
,
2200 LLVMValueRef ElementValueConstant
,
2201 LLVMValueRef IndexConstant
);
2202 LLVMValueRef
LLVMConstShuffleVector(LLVMValueRef VectorAConstant
,
2203 LLVMValueRef VectorBConstant
,
2204 LLVMValueRef MaskConstant
);
2205 LLVMValueRef
LLVMConstExtractValue(LLVMValueRef AggConstant
, unsigned *IdxList
,
2207 LLVMValueRef
LLVMConstInsertValue(LLVMValueRef AggConstant
,
2208 LLVMValueRef ElementValueConstant
,
2209 unsigned *IdxList
, unsigned NumIdx
);
2210 LLVMValueRef
LLVMBlockAddress(LLVMValueRef F
, LLVMBasicBlockRef BB
);
2212 /** Deprecated: Use LLVMGetInlineAsm instead. */
2213 LLVMValueRef
LLVMConstInlineAsm(LLVMTypeRef Ty
,
2214 const char *AsmString
, const char *Constraints
,
2215 LLVMBool HasSideEffects
, LLVMBool IsAlignStack
);
2222 * @defgroup LLVMCCoreValueConstantGlobals Global Values
2224 * This group contains functions that operate on global values. Functions in
2225 * this group relate to functions in the llvm::GlobalValue class tree.
2227 * @see llvm::GlobalValue
2232 LLVMModuleRef
LLVMGetGlobalParent(LLVMValueRef Global
);
2233 LLVMBool
LLVMIsDeclaration(LLVMValueRef Global
);
2234 LLVMLinkage
LLVMGetLinkage(LLVMValueRef Global
);
2235 void LLVMSetLinkage(LLVMValueRef Global
, LLVMLinkage Linkage
);
2236 const char *LLVMGetSection(LLVMValueRef Global
);
2237 void LLVMSetSection(LLVMValueRef Global
, const char *Section
);
2238 LLVMVisibility
LLVMGetVisibility(LLVMValueRef Global
);
2239 void LLVMSetVisibility(LLVMValueRef Global
, LLVMVisibility Viz
);
2240 LLVMDLLStorageClass
LLVMGetDLLStorageClass(LLVMValueRef Global
);
2241 void LLVMSetDLLStorageClass(LLVMValueRef Global
, LLVMDLLStorageClass Class
);
2242 LLVMUnnamedAddr
LLVMGetUnnamedAddress(LLVMValueRef Global
);
2243 void LLVMSetUnnamedAddress(LLVMValueRef Global
, LLVMUnnamedAddr UnnamedAddr
);
2246 * Returns the "value type" of a global value. This differs from the formal
2247 * type of a global value which is always a pointer type.
2249 * @see llvm::GlobalValue::getValueType()
2251 LLVMTypeRef
LLVMGlobalGetValueType(LLVMValueRef Global
);
2253 /** Deprecated: Use LLVMGetUnnamedAddress instead. */
2254 LLVMBool
LLVMHasUnnamedAddr(LLVMValueRef Global
);
2255 /** Deprecated: Use LLVMSetUnnamedAddress instead. */
2256 void LLVMSetUnnamedAddr(LLVMValueRef Global
, LLVMBool HasUnnamedAddr
);
2259 * @defgroup LLVMCCoreValueWithAlignment Values with alignment
2261 * Functions in this group only apply to values with alignment, i.e.
2262 * global variables, load and store instructions.
2266 * Obtain the preferred alignment of the value.
2267 * @see llvm::AllocaInst::getAlignment()
2268 * @see llvm::LoadInst::getAlignment()
2269 * @see llvm::StoreInst::getAlignment()
2270 * @see llvm::AtomicRMWInst::setAlignment()
2271 * @see llvm::AtomicCmpXchgInst::setAlignment()
2272 * @see llvm::GlobalValue::getAlignment()
2274 unsigned LLVMGetAlignment(LLVMValueRef V
);
2277 * Set the preferred alignment of the value.
2278 * @see llvm::AllocaInst::setAlignment()
2279 * @see llvm::LoadInst::setAlignment()
2280 * @see llvm::StoreInst::setAlignment()
2281 * @see llvm::AtomicRMWInst::setAlignment()
2282 * @see llvm::AtomicCmpXchgInst::setAlignment()
2283 * @see llvm::GlobalValue::setAlignment()
2285 void LLVMSetAlignment(LLVMValueRef V
, unsigned Bytes
);
2288 * Sets a metadata attachment, erasing the existing metadata attachment if
2289 * it already exists for the given kind.
2291 * @see llvm::GlobalObject::setMetadata()
2293 void LLVMGlobalSetMetadata(LLVMValueRef Global
, unsigned Kind
,
2294 LLVMMetadataRef MD
);
2297 * Erases a metadata attachment of the given kind if it exists.
2299 * @see llvm::GlobalObject::eraseMetadata()
2301 void LLVMGlobalEraseMetadata(LLVMValueRef Global
, unsigned Kind
);
2304 * Removes all metadata attachments from this value.
2306 * @see llvm::GlobalObject::clearMetadata()
2308 void LLVMGlobalClearMetadata(LLVMValueRef Global
);
2311 * Retrieves an array of metadata entries representing the metadata attached to
2312 * this value. The caller is responsible for freeing this array by calling
2313 * \c LLVMDisposeValueMetadataEntries.
2315 * @see llvm::GlobalObject::getAllMetadata()
2317 LLVMValueMetadataEntry
*LLVMGlobalCopyAllMetadata(LLVMValueRef Value
,
2318 size_t *NumEntries
);
2321 * Destroys value metadata entries.
2323 void LLVMDisposeValueMetadataEntries(LLVMValueMetadataEntry
*Entries
);
2326 * Returns the kind of a value metadata entry at a specific index.
2328 unsigned LLVMValueMetadataEntriesGetKind(LLVMValueMetadataEntry
*Entries
,
2332 * Returns the underlying metadata node of a value metadata entry at a
2336 LLVMValueMetadataEntriesGetMetadata(LLVMValueMetadataEntry
*Entries
,
2344 * @defgroup LLVMCoreValueConstantGlobalVariable Global Variables
2346 * This group contains functions that operate on global variable values.
2348 * @see llvm::GlobalVariable
2352 LLVMValueRef
LLVMAddGlobal(LLVMModuleRef M
, LLVMTypeRef Ty
, const char *Name
);
2353 LLVMValueRef
LLVMAddGlobalInAddressSpace(LLVMModuleRef M
, LLVMTypeRef Ty
,
2355 unsigned AddressSpace
);
2356 LLVMValueRef
LLVMGetNamedGlobal(LLVMModuleRef M
, const char *Name
);
2357 LLVMValueRef
LLVMGetFirstGlobal(LLVMModuleRef M
);
2358 LLVMValueRef
LLVMGetLastGlobal(LLVMModuleRef M
);
2359 LLVMValueRef
LLVMGetNextGlobal(LLVMValueRef GlobalVar
);
2360 LLVMValueRef
LLVMGetPreviousGlobal(LLVMValueRef GlobalVar
);
2361 void LLVMDeleteGlobal(LLVMValueRef GlobalVar
);
2362 LLVMValueRef
LLVMGetInitializer(LLVMValueRef GlobalVar
);
2363 void LLVMSetInitializer(LLVMValueRef GlobalVar
, LLVMValueRef ConstantVal
);
2364 LLVMBool
LLVMIsThreadLocal(LLVMValueRef GlobalVar
);
2365 void LLVMSetThreadLocal(LLVMValueRef GlobalVar
, LLVMBool IsThreadLocal
);
2366 LLVMBool
LLVMIsGlobalConstant(LLVMValueRef GlobalVar
);
2367 void LLVMSetGlobalConstant(LLVMValueRef GlobalVar
, LLVMBool IsConstant
);
2368 LLVMThreadLocalMode
LLVMGetThreadLocalMode(LLVMValueRef GlobalVar
);
2369 void LLVMSetThreadLocalMode(LLVMValueRef GlobalVar
, LLVMThreadLocalMode Mode
);
2370 LLVMBool
LLVMIsExternallyInitialized(LLVMValueRef GlobalVar
);
2371 void LLVMSetExternallyInitialized(LLVMValueRef GlobalVar
, LLVMBool IsExtInit
);
2378 * @defgroup LLVMCoreValueConstantGlobalAlias Global Aliases
2380 * This group contains function that operate on global alias values.
2382 * @see llvm::GlobalAlias
2387 LLVM_ATTRIBUTE_C_DEPRECATED(
2388 LLVMValueRef
LLVMAddAlias(LLVMModuleRef M
, LLVMTypeRef Ty
,
2389 LLVMValueRef Aliasee
, const char *Name
),
2390 "Use LLVMAddAlias2 instead to support opaque pointers");
2393 * Add a GlobalAlias with the given value type, address space and aliasee.
2395 * @see llvm::GlobalAlias::create()
2397 LLVMValueRef
LLVMAddAlias2(LLVMModuleRef M
, LLVMTypeRef ValueTy
,
2398 unsigned AddrSpace
, LLVMValueRef Aliasee
,
2402 * Obtain a GlobalAlias value from a Module by its name.
2404 * The returned value corresponds to a llvm::GlobalAlias value.
2406 * @see llvm::Module::getNamedAlias()
2408 LLVMValueRef
LLVMGetNamedGlobalAlias(LLVMModuleRef M
,
2409 const char *Name
, size_t NameLen
);
2412 * Obtain an iterator to the first GlobalAlias in a Module.
2414 * @see llvm::Module::alias_begin()
2416 LLVMValueRef
LLVMGetFirstGlobalAlias(LLVMModuleRef M
);
2419 * Obtain an iterator to the last GlobalAlias in a Module.
2421 * @see llvm::Module::alias_end()
2423 LLVMValueRef
LLVMGetLastGlobalAlias(LLVMModuleRef M
);
2426 * Advance a GlobalAlias iterator to the next GlobalAlias.
2428 * Returns NULL if the iterator was already at the end and there are no more
2431 LLVMValueRef
LLVMGetNextGlobalAlias(LLVMValueRef GA
);
2434 * Decrement a GlobalAlias iterator to the previous GlobalAlias.
2436 * Returns NULL if the iterator was already at the beginning and there are
2437 * no previous global aliases.
2439 LLVMValueRef
LLVMGetPreviousGlobalAlias(LLVMValueRef GA
);
2442 * Retrieve the target value of an alias.
2444 LLVMValueRef
LLVMAliasGetAliasee(LLVMValueRef Alias
);
2447 * Set the target value of an alias.
2449 void LLVMAliasSetAliasee(LLVMValueRef Alias
, LLVMValueRef Aliasee
);
2456 * @defgroup LLVMCCoreValueFunction Function values
2458 * Functions in this group operate on LLVMValueRef instances that
2459 * correspond to llvm::Function instances.
2461 * @see llvm::Function
2467 * Remove a function from its containing module and deletes it.
2469 * @see llvm::Function::eraseFromParent()
2471 void LLVMDeleteFunction(LLVMValueRef Fn
);
2474 * Check whether the given function has a personality function.
2476 * @see llvm::Function::hasPersonalityFn()
2478 LLVMBool
LLVMHasPersonalityFn(LLVMValueRef Fn
);
2481 * Obtain the personality function attached to the function.
2483 * @see llvm::Function::getPersonalityFn()
2485 LLVMValueRef
LLVMGetPersonalityFn(LLVMValueRef Fn
);
2488 * Set the personality function attached to the function.
2490 * @see llvm::Function::setPersonalityFn()
2492 void LLVMSetPersonalityFn(LLVMValueRef Fn
, LLVMValueRef PersonalityFn
);
2495 * Obtain the intrinsic ID number which matches the given function name.
2497 * @see llvm::Function::lookupIntrinsicID()
2499 unsigned LLVMLookupIntrinsicID(const char *Name
, size_t NameLen
);
2502 * Obtain the ID number from a function instance.
2504 * @see llvm::Function::getIntrinsicID()
2506 unsigned LLVMGetIntrinsicID(LLVMValueRef Fn
);
2509 * Create or insert the declaration of an intrinsic. For overloaded intrinsics,
2510 * parameter types must be provided to uniquely identify an overload.
2512 * @see llvm::Intrinsic::getDeclaration()
2514 LLVMValueRef
LLVMGetIntrinsicDeclaration(LLVMModuleRef Mod
,
2516 LLVMTypeRef
*ParamTypes
,
2520 * Retrieves the type of an intrinsic. For overloaded intrinsics, parameter
2521 * types must be provided to uniquely identify an overload.
2523 * @see llvm::Intrinsic::getType()
2525 LLVMTypeRef
LLVMIntrinsicGetType(LLVMContextRef Ctx
, unsigned ID
,
2526 LLVMTypeRef
*ParamTypes
, size_t ParamCount
);
2529 * Retrieves the name of an intrinsic.
2531 * @see llvm::Intrinsic::getName()
2533 const char *LLVMIntrinsicGetName(unsigned ID
, size_t *NameLength
);
2535 /** Deprecated: Use LLVMIntrinsicCopyOverloadedName2 instead. */
2536 const char *LLVMIntrinsicCopyOverloadedName(unsigned ID
,
2537 LLVMTypeRef
*ParamTypes
,
2539 size_t *NameLength
);
2542 * Copies the name of an overloaded intrinsic identified by a given list of
2545 * Unlike LLVMIntrinsicGetName, the caller is responsible for freeing the
2548 * This version also supports unnamed types.
2550 * @see llvm::Intrinsic::getName()
2552 const char *LLVMIntrinsicCopyOverloadedName2(LLVMModuleRef Mod
, unsigned ID
,
2553 LLVMTypeRef
*ParamTypes
,
2555 size_t *NameLength
);
2558 * Obtain if the intrinsic identified by the given ID is overloaded.
2560 * @see llvm::Intrinsic::isOverloaded()
2562 LLVMBool
LLVMIntrinsicIsOverloaded(unsigned ID
);
2565 * Obtain the calling function of a function.
2567 * The returned value corresponds to the LLVMCallConv enumeration.
2569 * @see llvm::Function::getCallingConv()
2571 unsigned LLVMGetFunctionCallConv(LLVMValueRef Fn
);
2574 * Set the calling convention of a function.
2576 * @see llvm::Function::setCallingConv()
2578 * @param Fn Function to operate on
2579 * @param CC LLVMCallConv to set calling convention to
2581 void LLVMSetFunctionCallConv(LLVMValueRef Fn
, unsigned CC
);
2584 * Obtain the name of the garbage collector to use during code
2587 * @see llvm::Function::getGC()
2589 const char *LLVMGetGC(LLVMValueRef Fn
);
2592 * Define the garbage collector to use during code generation.
2594 * @see llvm::Function::setGC()
2596 void LLVMSetGC(LLVMValueRef Fn
, const char *Name
);
2599 * Add an attribute to a function.
2601 * @see llvm::Function::addAttribute()
2603 void LLVMAddAttributeAtIndex(LLVMValueRef F
, LLVMAttributeIndex Idx
,
2604 LLVMAttributeRef A
);
2605 unsigned LLVMGetAttributeCountAtIndex(LLVMValueRef F
, LLVMAttributeIndex Idx
);
2606 void LLVMGetAttributesAtIndex(LLVMValueRef F
, LLVMAttributeIndex Idx
,
2607 LLVMAttributeRef
*Attrs
);
2608 LLVMAttributeRef
LLVMGetEnumAttributeAtIndex(LLVMValueRef F
,
2609 LLVMAttributeIndex Idx
,
2611 LLVMAttributeRef
LLVMGetStringAttributeAtIndex(LLVMValueRef F
,
2612 LLVMAttributeIndex Idx
,
2613 const char *K
, unsigned KLen
);
2614 void LLVMRemoveEnumAttributeAtIndex(LLVMValueRef F
, LLVMAttributeIndex Idx
,
2616 void LLVMRemoveStringAttributeAtIndex(LLVMValueRef F
, LLVMAttributeIndex Idx
,
2617 const char *K
, unsigned KLen
);
2620 * Add a target-dependent attribute to a function
2621 * @see llvm::AttrBuilder::addAttribute()
2623 void LLVMAddTargetDependentFunctionAttr(LLVMValueRef Fn
, const char *A
,
2627 * @defgroup LLVMCCoreValueFunctionParameters Function Parameters
2629 * Functions in this group relate to arguments/parameters on functions.
2631 * Functions in this group expect LLVMValueRef instances that correspond
2632 * to llvm::Function instances.
2638 * Obtain the number of parameters in a function.
2640 * @see llvm::Function::arg_size()
2642 unsigned LLVMCountParams(LLVMValueRef Fn
);
2645 * Obtain the parameters in a function.
2647 * The takes a pointer to a pre-allocated array of LLVMValueRef that is
2648 * at least LLVMCountParams() long. This array will be filled with
2649 * LLVMValueRef instances which correspond to the parameters the
2650 * function receives. Each LLVMValueRef corresponds to a llvm::Argument
2653 * @see llvm::Function::arg_begin()
2655 void LLVMGetParams(LLVMValueRef Fn
, LLVMValueRef
*Params
);
2658 * Obtain the parameter at the specified index.
2660 * Parameters are indexed from 0.
2662 * @see llvm::Function::arg_begin()
2664 LLVMValueRef
LLVMGetParam(LLVMValueRef Fn
, unsigned Index
);
2667 * Obtain the function to which this argument belongs.
2669 * Unlike other functions in this group, this one takes an LLVMValueRef
2670 * that corresponds to a llvm::Attribute.
2672 * The returned LLVMValueRef is the llvm::Function to which this
2675 LLVMValueRef
LLVMGetParamParent(LLVMValueRef Inst
);
2678 * Obtain the first parameter to a function.
2680 * @see llvm::Function::arg_begin()
2682 LLVMValueRef
LLVMGetFirstParam(LLVMValueRef Fn
);
2685 * Obtain the last parameter to a function.
2687 * @see llvm::Function::arg_end()
2689 LLVMValueRef
LLVMGetLastParam(LLVMValueRef Fn
);
2692 * Obtain the next parameter to a function.
2694 * This takes an LLVMValueRef obtained from LLVMGetFirstParam() (which is
2695 * actually a wrapped iterator) and obtains the next parameter from the
2696 * underlying iterator.
2698 LLVMValueRef
LLVMGetNextParam(LLVMValueRef Arg
);
2701 * Obtain the previous parameter to a function.
2703 * This is the opposite of LLVMGetNextParam().
2705 LLVMValueRef
LLVMGetPreviousParam(LLVMValueRef Arg
);
2708 * Set the alignment for a function parameter.
2710 * @see llvm::Argument::addAttr()
2711 * @see llvm::AttrBuilder::addAlignmentAttr()
2713 void LLVMSetParamAlignment(LLVMValueRef Arg
, unsigned Align
);
2720 * @defgroup LLVMCCoreValueGlobalIFunc IFuncs
2722 * Functions in this group relate to indirect functions.
2724 * Functions in this group expect LLVMValueRef instances that correspond
2725 * to llvm::GlobalIFunc instances.
2731 * Add a global indirect function to a module under a specified name.
2733 * @see llvm::GlobalIFunc::create()
2735 LLVMValueRef
LLVMAddGlobalIFunc(LLVMModuleRef M
,
2736 const char *Name
, size_t NameLen
,
2737 LLVMTypeRef Ty
, unsigned AddrSpace
,
2738 LLVMValueRef Resolver
);
2741 * Obtain a GlobalIFunc value from a Module by its name.
2743 * The returned value corresponds to a llvm::GlobalIFunc value.
2745 * @see llvm::Module::getNamedIFunc()
2747 LLVMValueRef
LLVMGetNamedGlobalIFunc(LLVMModuleRef M
,
2748 const char *Name
, size_t NameLen
);
2751 * Obtain an iterator to the first GlobalIFunc in a Module.
2753 * @see llvm::Module::ifunc_begin()
2755 LLVMValueRef
LLVMGetFirstGlobalIFunc(LLVMModuleRef M
);
2758 * Obtain an iterator to the last GlobalIFunc in a Module.
2760 * @see llvm::Module::ifunc_end()
2762 LLVMValueRef
LLVMGetLastGlobalIFunc(LLVMModuleRef M
);
2765 * Advance a GlobalIFunc iterator to the next GlobalIFunc.
2767 * Returns NULL if the iterator was already at the end and there are no more
2770 LLVMValueRef
LLVMGetNextGlobalIFunc(LLVMValueRef IFunc
);
2773 * Decrement a GlobalIFunc iterator to the previous GlobalIFunc.
2775 * Returns NULL if the iterator was already at the beginning and there are
2776 * no previous global aliases.
2778 LLVMValueRef
LLVMGetPreviousGlobalIFunc(LLVMValueRef IFunc
);
2781 * Retrieves the resolver function associated with this indirect function, or
2782 * NULL if it doesn't not exist.
2784 * @see llvm::GlobalIFunc::getResolver()
2786 LLVMValueRef
LLVMGetGlobalIFuncResolver(LLVMValueRef IFunc
);
2789 * Sets the resolver function associated with this indirect function.
2791 * @see llvm::GlobalIFunc::setResolver()
2793 void LLVMSetGlobalIFuncResolver(LLVMValueRef IFunc
, LLVMValueRef Resolver
);
2796 * Remove a global indirect function from its parent module and delete it.
2798 * @see llvm::GlobalIFunc::eraseFromParent()
2800 void LLVMEraseGlobalIFunc(LLVMValueRef IFunc
);
2803 * Remove a global indirect function from its parent module.
2805 * This unlinks the global indirect function from its containing module but
2808 * @see llvm::GlobalIFunc::removeFromParent()
2810 void LLVMRemoveGlobalIFunc(LLVMValueRef IFunc
);
2829 * @defgroup LLVMCCoreValueMetadata Metadata
2835 * Create an MDString value from a given string value.
2837 * The MDString value does not take ownership of the given string, it remains
2838 * the responsibility of the caller to free it.
2840 * @see llvm::MDString::get()
2842 LLVMMetadataRef
LLVMMDStringInContext2(LLVMContextRef C
, const char *Str
,
2846 * Create an MDNode value with the given array of operands.
2848 * @see llvm::MDNode::get()
2850 LLVMMetadataRef
LLVMMDNodeInContext2(LLVMContextRef C
, LLVMMetadataRef
*MDs
,
2854 * Obtain a Metadata as a Value.
2856 LLVMValueRef
LLVMMetadataAsValue(LLVMContextRef C
, LLVMMetadataRef MD
);
2859 * Obtain a Value as a Metadata.
2861 LLVMMetadataRef
LLVMValueAsMetadata(LLVMValueRef Val
);
2864 * Obtain the underlying string from a MDString value.
2866 * @param V Instance to obtain string from.
2867 * @param Length Memory address which will hold length of returned string.
2868 * @return String data in MDString.
2870 const char *LLVMGetMDString(LLVMValueRef V
, unsigned *Length
);
2873 * Obtain the number of operands from an MDNode value.
2875 * @param V MDNode to get number of operands from.
2876 * @return Number of operands of the MDNode.
2878 unsigned LLVMGetMDNodeNumOperands(LLVMValueRef V
);
2881 * Obtain the given MDNode's operands.
2883 * The passed LLVMValueRef pointer should point to enough memory to hold all of
2884 * the operands of the given MDNode (see LLVMGetMDNodeNumOperands) as
2885 * LLVMValueRefs. This memory will be populated with the LLVMValueRefs of the
2886 * MDNode's operands.
2888 * @param V MDNode to get the operands from.
2889 * @param Dest Destination array for operands.
2891 void LLVMGetMDNodeOperands(LLVMValueRef V
, LLVMValueRef
*Dest
);
2893 /** Deprecated: Use LLVMMDStringInContext2 instead. */
2894 LLVMValueRef
LLVMMDStringInContext(LLVMContextRef C
, const char *Str
,
2896 /** Deprecated: Use LLVMMDStringInContext2 instead. */
2897 LLVMValueRef
LLVMMDString(const char *Str
, unsigned SLen
);
2898 /** Deprecated: Use LLVMMDNodeInContext2 instead. */
2899 LLVMValueRef
LLVMMDNodeInContext(LLVMContextRef C
, LLVMValueRef
*Vals
,
2901 /** Deprecated: Use LLVMMDNodeInContext2 instead. */
2902 LLVMValueRef
LLVMMDNode(LLVMValueRef
*Vals
, unsigned Count
);
2909 * @defgroup LLVMCCoreValueBasicBlock Basic Block
2911 * A basic block represents a single entry single exit section of code.
2912 * Basic blocks contain a list of instructions which form the body of
2915 * Basic blocks belong to functions. They have the type of label.
2917 * Basic blocks are themselves values. However, the C API models them as
2918 * LLVMBasicBlockRef.
2920 * @see llvm::BasicBlock
2926 * Convert a basic block instance to a value type.
2928 LLVMValueRef
LLVMBasicBlockAsValue(LLVMBasicBlockRef BB
);
2931 * Determine whether an LLVMValueRef is itself a basic block.
2933 LLVMBool
LLVMValueIsBasicBlock(LLVMValueRef Val
);
2936 * Convert an LLVMValueRef to an LLVMBasicBlockRef instance.
2938 LLVMBasicBlockRef
LLVMValueAsBasicBlock(LLVMValueRef Val
);
2941 * Obtain the string name of a basic block.
2943 const char *LLVMGetBasicBlockName(LLVMBasicBlockRef BB
);
2946 * Obtain the function to which a basic block belongs.
2948 * @see llvm::BasicBlock::getParent()
2950 LLVMValueRef
LLVMGetBasicBlockParent(LLVMBasicBlockRef BB
);
2953 * Obtain the terminator instruction for a basic block.
2955 * If the basic block does not have a terminator (it is not well-formed
2956 * if it doesn't), then NULL is returned.
2958 * The returned LLVMValueRef corresponds to an llvm::Instruction.
2960 * @see llvm::BasicBlock::getTerminator()
2962 LLVMValueRef
LLVMGetBasicBlockTerminator(LLVMBasicBlockRef BB
);
2965 * Obtain the number of basic blocks in a function.
2967 * @param Fn Function value to operate on.
2969 unsigned LLVMCountBasicBlocks(LLVMValueRef Fn
);
2972 * Obtain all of the basic blocks in a function.
2974 * This operates on a function value. The BasicBlocks parameter is a
2975 * pointer to a pre-allocated array of LLVMBasicBlockRef of at least
2976 * LLVMCountBasicBlocks() in length. This array is populated with
2977 * LLVMBasicBlockRef instances.
2979 void LLVMGetBasicBlocks(LLVMValueRef Fn
, LLVMBasicBlockRef
*BasicBlocks
);
2982 * Obtain the first basic block in a function.
2984 * The returned basic block can be used as an iterator. You will likely
2985 * eventually call into LLVMGetNextBasicBlock() with it.
2987 * @see llvm::Function::begin()
2989 LLVMBasicBlockRef
LLVMGetFirstBasicBlock(LLVMValueRef Fn
);
2992 * Obtain the last basic block in a function.
2994 * @see llvm::Function::end()
2996 LLVMBasicBlockRef
LLVMGetLastBasicBlock(LLVMValueRef Fn
);
2999 * Advance a basic block iterator.
3001 LLVMBasicBlockRef
LLVMGetNextBasicBlock(LLVMBasicBlockRef BB
);
3004 * Go backwards in a basic block iterator.
3006 LLVMBasicBlockRef
LLVMGetPreviousBasicBlock(LLVMBasicBlockRef BB
);
3009 * Obtain the basic block that corresponds to the entry point of a
3012 * @see llvm::Function::getEntryBlock()
3014 LLVMBasicBlockRef
LLVMGetEntryBasicBlock(LLVMValueRef Fn
);
3017 * Insert the given basic block after the insertion point of the given builder.
3019 * The insertion point must be valid.
3021 * @see llvm::Function::BasicBlockListType::insertAfter()
3023 void LLVMInsertExistingBasicBlockAfterInsertBlock(LLVMBuilderRef Builder
,
3024 LLVMBasicBlockRef BB
);
3027 * Append the given basic block to the basic block list of the given function.
3029 * @see llvm::Function::BasicBlockListType::push_back()
3031 void LLVMAppendExistingBasicBlock(LLVMValueRef Fn
,
3032 LLVMBasicBlockRef BB
);
3035 * Create a new basic block without inserting it into a function.
3037 * @see llvm::BasicBlock::Create()
3039 LLVMBasicBlockRef
LLVMCreateBasicBlockInContext(LLVMContextRef C
,
3043 * Append a basic block to the end of a function.
3045 * @see llvm::BasicBlock::Create()
3047 LLVMBasicBlockRef
LLVMAppendBasicBlockInContext(LLVMContextRef C
,
3052 * Append a basic block to the end of a function using the global
3055 * @see llvm::BasicBlock::Create()
3057 LLVMBasicBlockRef
LLVMAppendBasicBlock(LLVMValueRef Fn
, const char *Name
);
3060 * Insert a basic block in a function before another basic block.
3062 * The function to add to is determined by the function of the
3063 * passed basic block.
3065 * @see llvm::BasicBlock::Create()
3067 LLVMBasicBlockRef
LLVMInsertBasicBlockInContext(LLVMContextRef C
,
3068 LLVMBasicBlockRef BB
,
3072 * Insert a basic block in a function using the global context.
3074 * @see llvm::BasicBlock::Create()
3076 LLVMBasicBlockRef
LLVMInsertBasicBlock(LLVMBasicBlockRef InsertBeforeBB
,
3080 * Remove a basic block from a function and delete it.
3082 * This deletes the basic block from its containing function and deletes
3083 * the basic block itself.
3085 * @see llvm::BasicBlock::eraseFromParent()
3087 void LLVMDeleteBasicBlock(LLVMBasicBlockRef BB
);
3090 * Remove a basic block from a function.
3092 * This deletes the basic block from its containing function but keep
3093 * the basic block alive.
3095 * @see llvm::BasicBlock::removeFromParent()
3097 void LLVMRemoveBasicBlockFromParent(LLVMBasicBlockRef BB
);
3100 * Move a basic block to before another one.
3102 * @see llvm::BasicBlock::moveBefore()
3104 void LLVMMoveBasicBlockBefore(LLVMBasicBlockRef BB
, LLVMBasicBlockRef MovePos
);
3107 * Move a basic block to after another one.
3109 * @see llvm::BasicBlock::moveAfter()
3111 void LLVMMoveBasicBlockAfter(LLVMBasicBlockRef BB
, LLVMBasicBlockRef MovePos
);
3114 * Obtain the first instruction in a basic block.
3116 * The returned LLVMValueRef corresponds to a llvm::Instruction
3119 LLVMValueRef
LLVMGetFirstInstruction(LLVMBasicBlockRef BB
);
3122 * Obtain the last instruction in a basic block.
3124 * The returned LLVMValueRef corresponds to an LLVM:Instruction.
3126 LLVMValueRef
LLVMGetLastInstruction(LLVMBasicBlockRef BB
);
3133 * @defgroup LLVMCCoreValueInstruction Instructions
3135 * Functions in this group relate to the inspection and manipulation of
3136 * individual instructions.
3138 * In the C++ API, an instruction is modeled by llvm::Instruction. This
3139 * class has a large number of descendents. llvm::Instruction is a
3140 * llvm::Value and in the C API, instructions are modeled by
3143 * This group also contains sub-groups which operate on specific
3144 * llvm::Instruction types, e.g. llvm::CallInst.
3150 * Determine whether an instruction has any metadata attached.
3152 int LLVMHasMetadata(LLVMValueRef Val
);
3155 * Return metadata associated with an instruction value.
3157 LLVMValueRef
LLVMGetMetadata(LLVMValueRef Val
, unsigned KindID
);
3160 * Set metadata associated with an instruction value.
3162 void LLVMSetMetadata(LLVMValueRef Val
, unsigned KindID
, LLVMValueRef Node
);
3165 * Returns the metadata associated with an instruction value, but filters out
3166 * all the debug locations.
3168 * @see llvm::Instruction::getAllMetadataOtherThanDebugLoc()
3170 LLVMValueMetadataEntry
*
3171 LLVMInstructionGetAllMetadataOtherThanDebugLoc(LLVMValueRef Instr
,
3172 size_t *NumEntries
);
3175 * Obtain the basic block to which an instruction belongs.
3177 * @see llvm::Instruction::getParent()
3179 LLVMBasicBlockRef
LLVMGetInstructionParent(LLVMValueRef Inst
);
3182 * Obtain the instruction that occurs after the one specified.
3184 * The next instruction will be from the same basic block.
3186 * If this is the last instruction in a basic block, NULL will be
3189 LLVMValueRef
LLVMGetNextInstruction(LLVMValueRef Inst
);
3192 * Obtain the instruction that occurred before this one.
3194 * If the instruction is the first instruction in a basic block, NULL
3197 LLVMValueRef
LLVMGetPreviousInstruction(LLVMValueRef Inst
);
3200 * Remove and delete an instruction.
3202 * The instruction specified is removed from its containing building
3203 * block but is kept alive.
3205 * @see llvm::Instruction::removeFromParent()
3207 void LLVMInstructionRemoveFromParent(LLVMValueRef Inst
);
3210 * Remove and delete an instruction.
3212 * The instruction specified is removed from its containing building
3213 * block and then deleted.
3215 * @see llvm::Instruction::eraseFromParent()
3217 void LLVMInstructionEraseFromParent(LLVMValueRef Inst
);
3220 * Obtain the code opcode for an individual instruction.
3222 * @see llvm::Instruction::getOpCode()
3224 LLVMOpcode
LLVMGetInstructionOpcode(LLVMValueRef Inst
);
3227 * Obtain the predicate of an instruction.
3229 * This is only valid for instructions that correspond to llvm::ICmpInst
3230 * or llvm::ConstantExpr whose opcode is llvm::Instruction::ICmp.
3232 * @see llvm::ICmpInst::getPredicate()
3234 LLVMIntPredicate
LLVMGetICmpPredicate(LLVMValueRef Inst
);
3237 * Obtain the float predicate of an instruction.
3239 * This is only valid for instructions that correspond to llvm::FCmpInst
3240 * or llvm::ConstantExpr whose opcode is llvm::Instruction::FCmp.
3242 * @see llvm::FCmpInst::getPredicate()
3244 LLVMRealPredicate
LLVMGetFCmpPredicate(LLVMValueRef Inst
);
3247 * Create a copy of 'this' instruction that is identical in all ways
3248 * except the following:
3249 * * The instruction has no parent
3250 * * The instruction has no name
3252 * @see llvm::Instruction::clone()
3254 LLVMValueRef
LLVMInstructionClone(LLVMValueRef Inst
);
3257 * Determine whether an instruction is a terminator. This routine is named to
3258 * be compatible with historical functions that did this by querying the
3259 * underlying C++ type.
3261 * @see llvm::Instruction::isTerminator()
3263 LLVMValueRef
LLVMIsATerminatorInst(LLVMValueRef Inst
);
3266 * @defgroup LLVMCCoreValueInstructionCall Call Sites and Invocations
3268 * Functions in this group apply to instructions that refer to call
3269 * sites and invocations. These correspond to C++ types in the
3270 * llvm::CallInst class tree.
3276 * Obtain the argument count for a call instruction.
3278 * This expects an LLVMValueRef that corresponds to a llvm::CallInst,
3279 * llvm::InvokeInst, or llvm:FuncletPadInst.
3281 * @see llvm::CallInst::getNumArgOperands()
3282 * @see llvm::InvokeInst::getNumArgOperands()
3283 * @see llvm::FuncletPadInst::getNumArgOperands()
3285 unsigned LLVMGetNumArgOperands(LLVMValueRef Instr
);
3288 * Set the calling convention for a call instruction.
3290 * This expects an LLVMValueRef that corresponds to a llvm::CallInst or
3293 * @see llvm::CallInst::setCallingConv()
3294 * @see llvm::InvokeInst::setCallingConv()
3296 void LLVMSetInstructionCallConv(LLVMValueRef Instr
, unsigned CC
);
3299 * Obtain the calling convention for a call instruction.
3301 * This is the opposite of LLVMSetInstructionCallConv(). Reads its
3304 * @see LLVMSetInstructionCallConv()
3306 unsigned LLVMGetInstructionCallConv(LLVMValueRef Instr
);
3308 void LLVMSetInstrParamAlignment(LLVMValueRef Instr
, LLVMAttributeIndex Idx
,
3311 void LLVMAddCallSiteAttribute(LLVMValueRef C
, LLVMAttributeIndex Idx
,
3312 LLVMAttributeRef A
);
3313 unsigned LLVMGetCallSiteAttributeCount(LLVMValueRef C
, LLVMAttributeIndex Idx
);
3314 void LLVMGetCallSiteAttributes(LLVMValueRef C
, LLVMAttributeIndex Idx
,
3315 LLVMAttributeRef
*Attrs
);
3316 LLVMAttributeRef
LLVMGetCallSiteEnumAttribute(LLVMValueRef C
,
3317 LLVMAttributeIndex Idx
,
3319 LLVMAttributeRef
LLVMGetCallSiteStringAttribute(LLVMValueRef C
,
3320 LLVMAttributeIndex Idx
,
3321 const char *K
, unsigned KLen
);
3322 void LLVMRemoveCallSiteEnumAttribute(LLVMValueRef C
, LLVMAttributeIndex Idx
,
3324 void LLVMRemoveCallSiteStringAttribute(LLVMValueRef C
, LLVMAttributeIndex Idx
,
3325 const char *K
, unsigned KLen
);
3328 * Obtain the function type called by this instruction.
3330 * @see llvm::CallBase::getFunctionType()
3332 LLVMTypeRef
LLVMGetCalledFunctionType(LLVMValueRef C
);
3335 * Obtain the pointer to the function invoked by this instruction.
3337 * This expects an LLVMValueRef that corresponds to a llvm::CallInst or
3340 * @see llvm::CallInst::getCalledOperand()
3341 * @see llvm::InvokeInst::getCalledOperand()
3343 LLVMValueRef
LLVMGetCalledValue(LLVMValueRef Instr
);
3346 * Obtain whether a call instruction is a tail call.
3348 * This only works on llvm::CallInst instructions.
3350 * @see llvm::CallInst::isTailCall()
3352 LLVMBool
LLVMIsTailCall(LLVMValueRef CallInst
);
3355 * Set whether a call instruction is a tail call.
3357 * This only works on llvm::CallInst instructions.
3359 * @see llvm::CallInst::setTailCall()
3361 void LLVMSetTailCall(LLVMValueRef CallInst
, LLVMBool IsTailCall
);
3364 * Return the normal destination basic block.
3366 * This only works on llvm::InvokeInst instructions.
3368 * @see llvm::InvokeInst::getNormalDest()
3370 LLVMBasicBlockRef
LLVMGetNormalDest(LLVMValueRef InvokeInst
);
3373 * Return the unwind destination basic block.
3375 * Works on llvm::InvokeInst, llvm::CleanupReturnInst, and
3376 * llvm::CatchSwitchInst instructions.
3378 * @see llvm::InvokeInst::getUnwindDest()
3379 * @see llvm::CleanupReturnInst::getUnwindDest()
3380 * @see llvm::CatchSwitchInst::getUnwindDest()
3382 LLVMBasicBlockRef
LLVMGetUnwindDest(LLVMValueRef InvokeInst
);
3385 * Set the normal destination basic block.
3387 * This only works on llvm::InvokeInst instructions.
3389 * @see llvm::InvokeInst::setNormalDest()
3391 void LLVMSetNormalDest(LLVMValueRef InvokeInst
, LLVMBasicBlockRef B
);
3394 * Set the unwind destination basic block.
3396 * Works on llvm::InvokeInst, llvm::CleanupReturnInst, and
3397 * llvm::CatchSwitchInst instructions.
3399 * @see llvm::InvokeInst::setUnwindDest()
3400 * @see llvm::CleanupReturnInst::setUnwindDest()
3401 * @see llvm::CatchSwitchInst::setUnwindDest()
3403 void LLVMSetUnwindDest(LLVMValueRef InvokeInst
, LLVMBasicBlockRef B
);
3410 * @defgroup LLVMCCoreValueInstructionTerminator Terminators
3412 * Functions in this group only apply to instructions for which
3413 * LLVMIsATerminatorInst returns true.
3419 * Return the number of successors that this terminator has.
3421 * @see llvm::Instruction::getNumSuccessors
3423 unsigned LLVMGetNumSuccessors(LLVMValueRef Term
);
3426 * Return the specified successor.
3428 * @see llvm::Instruction::getSuccessor
3430 LLVMBasicBlockRef
LLVMGetSuccessor(LLVMValueRef Term
, unsigned i
);
3433 * Update the specified successor to point at the provided block.
3435 * @see llvm::Instruction::setSuccessor
3437 void LLVMSetSuccessor(LLVMValueRef Term
, unsigned i
, LLVMBasicBlockRef block
);
3440 * Return if a branch is conditional.
3442 * This only works on llvm::BranchInst instructions.
3444 * @see llvm::BranchInst::isConditional
3446 LLVMBool
LLVMIsConditional(LLVMValueRef Branch
);
3449 * Return the condition of a branch instruction.
3451 * This only works on llvm::BranchInst instructions.
3453 * @see llvm::BranchInst::getCondition
3455 LLVMValueRef
LLVMGetCondition(LLVMValueRef Branch
);
3458 * Set the condition of a branch instruction.
3460 * This only works on llvm::BranchInst instructions.
3462 * @see llvm::BranchInst::setCondition
3464 void LLVMSetCondition(LLVMValueRef Branch
, LLVMValueRef Cond
);
3467 * Obtain the default destination basic block of a switch instruction.
3469 * This only works on llvm::SwitchInst instructions.
3471 * @see llvm::SwitchInst::getDefaultDest()
3473 LLVMBasicBlockRef
LLVMGetSwitchDefaultDest(LLVMValueRef SwitchInstr
);
3480 * @defgroup LLVMCCoreValueInstructionAlloca Allocas
3482 * Functions in this group only apply to instructions that map to
3483 * llvm::AllocaInst instances.
3489 * Obtain the type that is being allocated by the alloca instruction.
3491 LLVMTypeRef
LLVMGetAllocatedType(LLVMValueRef Alloca
);
3498 * @defgroup LLVMCCoreValueInstructionGetElementPointer GEPs
3500 * Functions in this group only apply to instructions that map to
3501 * llvm::GetElementPtrInst instances.
3507 * Check whether the given GEP operator is inbounds.
3509 LLVMBool
LLVMIsInBounds(LLVMValueRef GEP
);
3512 * Set the given GEP instruction to be inbounds or not.
3514 void LLVMSetIsInBounds(LLVMValueRef GEP
, LLVMBool InBounds
);
3517 * Get the source element type of the given GEP operator.
3519 LLVMTypeRef
LLVMGetGEPSourceElementType(LLVMValueRef GEP
);
3526 * @defgroup LLVMCCoreValueInstructionPHINode PHI Nodes
3528 * Functions in this group only apply to instructions that map to
3529 * llvm::PHINode instances.
3535 * Add an incoming value to the end of a PHI list.
3537 void LLVMAddIncoming(LLVMValueRef PhiNode
, LLVMValueRef
*IncomingValues
,
3538 LLVMBasicBlockRef
*IncomingBlocks
, unsigned Count
);
3541 * Obtain the number of incoming basic blocks to a PHI node.
3543 unsigned LLVMCountIncoming(LLVMValueRef PhiNode
);
3546 * Obtain an incoming value to a PHI node as an LLVMValueRef.
3548 LLVMValueRef
LLVMGetIncomingValue(LLVMValueRef PhiNode
, unsigned Index
);
3551 * Obtain an incoming value to a PHI node as an LLVMBasicBlockRef.
3553 LLVMBasicBlockRef
LLVMGetIncomingBlock(LLVMValueRef PhiNode
, unsigned Index
);
3560 * @defgroup LLVMCCoreValueInstructionExtractValue ExtractValue
3561 * @defgroup LLVMCCoreValueInstructionInsertValue InsertValue
3563 * Functions in this group only apply to instructions that map to
3564 * llvm::ExtractValue and llvm::InsertValue instances.
3570 * Obtain the number of indices.
3571 * NB: This also works on GEP operators.
3573 unsigned LLVMGetNumIndices(LLVMValueRef Inst
);
3576 * Obtain the indices as an array.
3578 const unsigned *LLVMGetIndices(LLVMValueRef Inst
);
3593 * @defgroup LLVMCCoreInstructionBuilder Instruction Builders
3595 * An instruction builder represents a point within a basic block and is
3596 * the exclusive means of building instructions using the C interface.
3601 LLVMBuilderRef
LLVMCreateBuilderInContext(LLVMContextRef C
);
3602 LLVMBuilderRef
LLVMCreateBuilder(void);
3603 void LLVMPositionBuilder(LLVMBuilderRef Builder
, LLVMBasicBlockRef Block
,
3604 LLVMValueRef Instr
);
3605 void LLVMPositionBuilderBefore(LLVMBuilderRef Builder
, LLVMValueRef Instr
);
3606 void LLVMPositionBuilderAtEnd(LLVMBuilderRef Builder
, LLVMBasicBlockRef Block
);
3607 LLVMBasicBlockRef
LLVMGetInsertBlock(LLVMBuilderRef Builder
);
3608 void LLVMClearInsertionPosition(LLVMBuilderRef Builder
);
3609 void LLVMInsertIntoBuilder(LLVMBuilderRef Builder
, LLVMValueRef Instr
);
3610 void LLVMInsertIntoBuilderWithName(LLVMBuilderRef Builder
, LLVMValueRef Instr
,
3612 void LLVMDisposeBuilder(LLVMBuilderRef Builder
);
3617 * Get location information used by debugging information.
3619 * @see llvm::IRBuilder::getCurrentDebugLocation()
3621 LLVMMetadataRef
LLVMGetCurrentDebugLocation2(LLVMBuilderRef Builder
);
3624 * Set location information used by debugging information.
3626 * To clear the location metadata of the given instruction, pass NULL to \p Loc.
3628 * @see llvm::IRBuilder::SetCurrentDebugLocation()
3630 void LLVMSetCurrentDebugLocation2(LLVMBuilderRef Builder
, LLVMMetadataRef Loc
);
3633 * Attempts to set the debug location for the given instruction using the
3634 * current debug location for the given builder. If the builder has no current
3635 * debug location, this function is a no-op.
3637 * @deprecated LLVMSetInstDebugLocation is deprecated in favor of the more general
3638 * LLVMAddMetadataToInst.
3640 * @see llvm::IRBuilder::SetInstDebugLocation()
3642 void LLVMSetInstDebugLocation(LLVMBuilderRef Builder
, LLVMValueRef Inst
);
3645 * Adds the metadata registered with the given builder to the given instruction.
3647 * @see llvm::IRBuilder::AddMetadataToInst()
3649 void LLVMAddMetadataToInst(LLVMBuilderRef Builder
, LLVMValueRef Inst
);
3652 * Get the dafult floating-point math metadata for a given builder.
3654 * @see llvm::IRBuilder::getDefaultFPMathTag()
3656 LLVMMetadataRef
LLVMBuilderGetDefaultFPMathTag(LLVMBuilderRef Builder
);
3659 * Set the default floating-point math metadata for the given builder.
3661 * To clear the metadata, pass NULL to \p FPMathTag.
3663 * @see llvm::IRBuilder::setDefaultFPMathTag()
3665 void LLVMBuilderSetDefaultFPMathTag(LLVMBuilderRef Builder
,
3666 LLVMMetadataRef FPMathTag
);
3669 * Deprecated: Passing the NULL location will crash.
3670 * Use LLVMGetCurrentDebugLocation2 instead.
3672 void LLVMSetCurrentDebugLocation(LLVMBuilderRef Builder
, LLVMValueRef L
);
3674 * Deprecated: Returning the NULL location will crash.
3675 * Use LLVMGetCurrentDebugLocation2 instead.
3677 LLVMValueRef
LLVMGetCurrentDebugLocation(LLVMBuilderRef Builder
);
3680 LLVMValueRef
LLVMBuildRetVoid(LLVMBuilderRef
);
3681 LLVMValueRef
LLVMBuildRet(LLVMBuilderRef
, LLVMValueRef V
);
3682 LLVMValueRef
LLVMBuildAggregateRet(LLVMBuilderRef
, LLVMValueRef
*RetVals
,
3684 LLVMValueRef
LLVMBuildBr(LLVMBuilderRef
, LLVMBasicBlockRef Dest
);
3685 LLVMValueRef
LLVMBuildCondBr(LLVMBuilderRef
, LLVMValueRef If
,
3686 LLVMBasicBlockRef Then
, LLVMBasicBlockRef Else
);
3687 LLVMValueRef
LLVMBuildSwitch(LLVMBuilderRef
, LLVMValueRef V
,
3688 LLVMBasicBlockRef Else
, unsigned NumCases
);
3689 LLVMValueRef
LLVMBuildIndirectBr(LLVMBuilderRef B
, LLVMValueRef Addr
,
3691 LLVM_ATTRIBUTE_C_DEPRECATED(
3692 LLVMValueRef
LLVMBuildInvoke(LLVMBuilderRef
, LLVMValueRef Fn
,
3693 LLVMValueRef
*Args
, unsigned NumArgs
,
3694 LLVMBasicBlockRef Then
,
3695 LLVMBasicBlockRef Catch
, const char *Name
),
3696 "Use LLVMBuildInvoke2 instead to support opaque pointers");
3697 LLVMValueRef
LLVMBuildInvoke2(LLVMBuilderRef
, LLVMTypeRef Ty
, LLVMValueRef Fn
,
3698 LLVMValueRef
*Args
, unsigned NumArgs
,
3699 LLVMBasicBlockRef Then
, LLVMBasicBlockRef Catch
,
3701 LLVMValueRef
LLVMBuildUnreachable(LLVMBuilderRef
);
3703 /* Exception Handling */
3704 LLVMValueRef
LLVMBuildResume(LLVMBuilderRef B
, LLVMValueRef Exn
);
3705 LLVMValueRef
LLVMBuildLandingPad(LLVMBuilderRef B
, LLVMTypeRef Ty
,
3706 LLVMValueRef PersFn
, unsigned NumClauses
,
3708 LLVMValueRef
LLVMBuildCleanupRet(LLVMBuilderRef B
, LLVMValueRef CatchPad
,
3709 LLVMBasicBlockRef BB
);
3710 LLVMValueRef
LLVMBuildCatchRet(LLVMBuilderRef B
, LLVMValueRef CatchPad
,
3711 LLVMBasicBlockRef BB
);
3712 LLVMValueRef
LLVMBuildCatchPad(LLVMBuilderRef B
, LLVMValueRef ParentPad
,
3713 LLVMValueRef
*Args
, unsigned NumArgs
,
3715 LLVMValueRef
LLVMBuildCleanupPad(LLVMBuilderRef B
, LLVMValueRef ParentPad
,
3716 LLVMValueRef
*Args
, unsigned NumArgs
,
3718 LLVMValueRef
LLVMBuildCatchSwitch(LLVMBuilderRef B
, LLVMValueRef ParentPad
,
3719 LLVMBasicBlockRef UnwindBB
,
3720 unsigned NumHandlers
, const char *Name
);
3722 /* Add a case to the switch instruction */
3723 void LLVMAddCase(LLVMValueRef Switch
, LLVMValueRef OnVal
,
3724 LLVMBasicBlockRef Dest
);
3726 /* Add a destination to the indirectbr instruction */
3727 void LLVMAddDestination(LLVMValueRef IndirectBr
, LLVMBasicBlockRef Dest
);
3729 /* Get the number of clauses on the landingpad instruction */
3730 unsigned LLVMGetNumClauses(LLVMValueRef LandingPad
);
3732 /* Get the value of the clause at index Idx on the landingpad instruction */
3733 LLVMValueRef
LLVMGetClause(LLVMValueRef LandingPad
, unsigned Idx
);
3735 /* Add a catch or filter clause to the landingpad instruction */
3736 void LLVMAddClause(LLVMValueRef LandingPad
, LLVMValueRef ClauseVal
);
3738 /* Get the 'cleanup' flag in the landingpad instruction */
3739 LLVMBool
LLVMIsCleanup(LLVMValueRef LandingPad
);
3741 /* Set the 'cleanup' flag in the landingpad instruction */
3742 void LLVMSetCleanup(LLVMValueRef LandingPad
, LLVMBool Val
);
3744 /* Add a destination to the catchswitch instruction */
3745 void LLVMAddHandler(LLVMValueRef CatchSwitch
, LLVMBasicBlockRef Dest
);
3747 /* Get the number of handlers on the catchswitch instruction */
3748 unsigned LLVMGetNumHandlers(LLVMValueRef CatchSwitch
);
3751 * Obtain the basic blocks acting as handlers for a catchswitch instruction.
3753 * The Handlers parameter should point to a pre-allocated array of
3754 * LLVMBasicBlockRefs at least LLVMGetNumHandlers() large. On return, the
3755 * first LLVMGetNumHandlers() entries in the array will be populated
3756 * with LLVMBasicBlockRef instances.
3758 * @param CatchSwitch The catchswitch instruction to operate on.
3759 * @param Handlers Memory address of an array to be filled with basic blocks.
3761 void LLVMGetHandlers(LLVMValueRef CatchSwitch
, LLVMBasicBlockRef
*Handlers
);
3765 /* Get the number of funcletpad arguments. */
3766 LLVMValueRef
LLVMGetArgOperand(LLVMValueRef Funclet
, unsigned i
);
3768 /* Set a funcletpad argument at the given index. */
3769 void LLVMSetArgOperand(LLVMValueRef Funclet
, unsigned i
, LLVMValueRef value
);
3772 * Get the parent catchswitch instruction of a catchpad instruction.
3774 * This only works on llvm::CatchPadInst instructions.
3776 * @see llvm::CatchPadInst::getCatchSwitch()
3778 LLVMValueRef
LLVMGetParentCatchSwitch(LLVMValueRef CatchPad
);
3781 * Set the parent catchswitch instruction of a catchpad instruction.
3783 * This only works on llvm::CatchPadInst instructions.
3785 * @see llvm::CatchPadInst::setCatchSwitch()
3787 void LLVMSetParentCatchSwitch(LLVMValueRef CatchPad
, LLVMValueRef CatchSwitch
);
3790 LLVMValueRef
LLVMBuildAdd(LLVMBuilderRef
, LLVMValueRef LHS
, LLVMValueRef RHS
,
3792 LLVMValueRef
LLVMBuildNSWAdd(LLVMBuilderRef
, LLVMValueRef LHS
, LLVMValueRef RHS
,
3794 LLVMValueRef
LLVMBuildNUWAdd(LLVMBuilderRef
, LLVMValueRef LHS
, LLVMValueRef RHS
,
3796 LLVMValueRef
LLVMBuildFAdd(LLVMBuilderRef
, LLVMValueRef LHS
, LLVMValueRef RHS
,
3798 LLVMValueRef
LLVMBuildSub(LLVMBuilderRef
, LLVMValueRef LHS
, LLVMValueRef RHS
,
3800 LLVMValueRef
LLVMBuildNSWSub(LLVMBuilderRef
, LLVMValueRef LHS
, LLVMValueRef RHS
,
3802 LLVMValueRef
LLVMBuildNUWSub(LLVMBuilderRef
, LLVMValueRef LHS
, LLVMValueRef RHS
,
3804 LLVMValueRef
LLVMBuildFSub(LLVMBuilderRef
, LLVMValueRef LHS
, LLVMValueRef RHS
,
3806 LLVMValueRef
LLVMBuildMul(LLVMBuilderRef
, LLVMValueRef LHS
, LLVMValueRef RHS
,
3808 LLVMValueRef
LLVMBuildNSWMul(LLVMBuilderRef
, LLVMValueRef LHS
, LLVMValueRef RHS
,
3810 LLVMValueRef
LLVMBuildNUWMul(LLVMBuilderRef
, LLVMValueRef LHS
, LLVMValueRef RHS
,
3812 LLVMValueRef
LLVMBuildFMul(LLVMBuilderRef
, LLVMValueRef LHS
, LLVMValueRef RHS
,
3814 LLVMValueRef
LLVMBuildUDiv(LLVMBuilderRef
, LLVMValueRef LHS
, LLVMValueRef RHS
,
3816 LLVMValueRef
LLVMBuildExactUDiv(LLVMBuilderRef
, LLVMValueRef LHS
, LLVMValueRef RHS
,
3818 LLVMValueRef
LLVMBuildSDiv(LLVMBuilderRef
, LLVMValueRef LHS
, LLVMValueRef RHS
,
3820 LLVMValueRef
LLVMBuildExactSDiv(LLVMBuilderRef
, LLVMValueRef LHS
, LLVMValueRef RHS
,
3822 LLVMValueRef
LLVMBuildFDiv(LLVMBuilderRef
, LLVMValueRef LHS
, LLVMValueRef RHS
,
3824 LLVMValueRef
LLVMBuildURem(LLVMBuilderRef
, LLVMValueRef LHS
, LLVMValueRef RHS
,
3826 LLVMValueRef
LLVMBuildSRem(LLVMBuilderRef
, LLVMValueRef LHS
, LLVMValueRef RHS
,
3828 LLVMValueRef
LLVMBuildFRem(LLVMBuilderRef
, LLVMValueRef LHS
, LLVMValueRef RHS
,
3830 LLVMValueRef
LLVMBuildShl(LLVMBuilderRef
, LLVMValueRef LHS
, LLVMValueRef RHS
,
3832 LLVMValueRef
LLVMBuildLShr(LLVMBuilderRef
, LLVMValueRef LHS
, LLVMValueRef RHS
,
3834 LLVMValueRef
LLVMBuildAShr(LLVMBuilderRef
, LLVMValueRef LHS
, LLVMValueRef RHS
,
3836 LLVMValueRef
LLVMBuildAnd(LLVMBuilderRef
, LLVMValueRef LHS
, LLVMValueRef RHS
,
3838 LLVMValueRef
LLVMBuildOr(LLVMBuilderRef
, LLVMValueRef LHS
, LLVMValueRef RHS
,
3840 LLVMValueRef
LLVMBuildXor(LLVMBuilderRef
, LLVMValueRef LHS
, LLVMValueRef RHS
,
3842 LLVMValueRef
LLVMBuildBinOp(LLVMBuilderRef B
, LLVMOpcode Op
,
3843 LLVMValueRef LHS
, LLVMValueRef RHS
,
3845 LLVMValueRef
LLVMBuildNeg(LLVMBuilderRef
, LLVMValueRef V
, const char *Name
);
3846 LLVMValueRef
LLVMBuildNSWNeg(LLVMBuilderRef B
, LLVMValueRef V
,
3848 LLVMValueRef
LLVMBuildNUWNeg(LLVMBuilderRef B
, LLVMValueRef V
,
3850 LLVMValueRef
LLVMBuildFNeg(LLVMBuilderRef
, LLVMValueRef V
, const char *Name
);
3851 LLVMValueRef
LLVMBuildNot(LLVMBuilderRef
, LLVMValueRef V
, const char *Name
);
3854 LLVMValueRef
LLVMBuildMalloc(LLVMBuilderRef
, LLVMTypeRef Ty
, const char *Name
);
3855 LLVMValueRef
LLVMBuildArrayMalloc(LLVMBuilderRef
, LLVMTypeRef Ty
,
3856 LLVMValueRef Val
, const char *Name
);
3859 * Creates and inserts a memset to the specified pointer and the
3862 * @see llvm::IRRBuilder::CreateMemSet()
3864 LLVMValueRef
LLVMBuildMemSet(LLVMBuilderRef B
, LLVMValueRef Ptr
,
3865 LLVMValueRef Val
, LLVMValueRef Len
,
3868 * Creates and inserts a memcpy between the specified pointers.
3870 * @see llvm::IRRBuilder::CreateMemCpy()
3872 LLVMValueRef
LLVMBuildMemCpy(LLVMBuilderRef B
,
3873 LLVMValueRef Dst
, unsigned DstAlign
,
3874 LLVMValueRef Src
, unsigned SrcAlign
,
3877 * Creates and inserts a memmove between the specified pointers.
3879 * @see llvm::IRRBuilder::CreateMemMove()
3881 LLVMValueRef
LLVMBuildMemMove(LLVMBuilderRef B
,
3882 LLVMValueRef Dst
, unsigned DstAlign
,
3883 LLVMValueRef Src
, unsigned SrcAlign
,
3886 LLVMValueRef
LLVMBuildAlloca(LLVMBuilderRef
, LLVMTypeRef Ty
, const char *Name
);
3887 LLVMValueRef
LLVMBuildArrayAlloca(LLVMBuilderRef
, LLVMTypeRef Ty
,
3888 LLVMValueRef Val
, const char *Name
);
3889 LLVMValueRef
LLVMBuildFree(LLVMBuilderRef
, LLVMValueRef PointerVal
);
3890 LLVM_ATTRIBUTE_C_DEPRECATED(
3891 LLVMValueRef
LLVMBuildLoad(LLVMBuilderRef
, LLVMValueRef PointerVal
,
3893 "Use LLVMBuildLoad2 instead to support opaque pointers");
3894 LLVMValueRef
LLVMBuildLoad2(LLVMBuilderRef
, LLVMTypeRef Ty
,
3895 LLVMValueRef PointerVal
, const char *Name
);
3896 LLVMValueRef
LLVMBuildStore(LLVMBuilderRef
, LLVMValueRef Val
, LLVMValueRef Ptr
);
3897 LLVM_ATTRIBUTE_C_DEPRECATED(
3898 LLVMValueRef
LLVMBuildGEP(LLVMBuilderRef B
, LLVMValueRef Pointer
,
3899 LLVMValueRef
*Indices
, unsigned NumIndices
,
3901 "Use LLVMBuildGEP2 instead to support opaque pointers");
3902 LLVM_ATTRIBUTE_C_DEPRECATED(
3903 LLVMValueRef
LLVMBuildInBoundsGEP(LLVMBuilderRef B
, LLVMValueRef Pointer
,
3904 LLVMValueRef
*Indices
,
3905 unsigned NumIndices
, const char *Name
),
3906 "Use LLVMBuildInBoundsGEP2 instead to support opaque pointers");
3907 LLVM_ATTRIBUTE_C_DEPRECATED(
3908 LLVMValueRef
LLVMBuildStructGEP(LLVMBuilderRef B
, LLVMValueRef Pointer
,
3909 unsigned Idx
, const char *Name
),
3910 "Use LLVMBuildStructGEP2 instead to support opaque pointers");
3911 LLVMValueRef
LLVMBuildGEP2(LLVMBuilderRef B
, LLVMTypeRef Ty
,
3912 LLVMValueRef Pointer
, LLVMValueRef
*Indices
,
3913 unsigned NumIndices
, const char *Name
);
3914 LLVMValueRef
LLVMBuildInBoundsGEP2(LLVMBuilderRef B
, LLVMTypeRef Ty
,
3915 LLVMValueRef Pointer
, LLVMValueRef
*Indices
,
3916 unsigned NumIndices
, const char *Name
);
3917 LLVMValueRef
LLVMBuildStructGEP2(LLVMBuilderRef B
, LLVMTypeRef Ty
,
3918 LLVMValueRef Pointer
, unsigned Idx
,
3920 LLVMValueRef
LLVMBuildGlobalString(LLVMBuilderRef B
, const char *Str
,
3922 LLVMValueRef
LLVMBuildGlobalStringPtr(LLVMBuilderRef B
, const char *Str
,
3924 LLVMBool
LLVMGetVolatile(LLVMValueRef MemoryAccessInst
);
3925 void LLVMSetVolatile(LLVMValueRef MemoryAccessInst
, LLVMBool IsVolatile
);
3926 LLVMBool
LLVMGetWeak(LLVMValueRef CmpXchgInst
);
3927 void LLVMSetWeak(LLVMValueRef CmpXchgInst
, LLVMBool IsWeak
);
3928 LLVMAtomicOrdering
LLVMGetOrdering(LLVMValueRef MemoryAccessInst
);
3929 void LLVMSetOrdering(LLVMValueRef MemoryAccessInst
, LLVMAtomicOrdering Ordering
);
3930 LLVMAtomicRMWBinOp
LLVMGetAtomicRMWBinOp(LLVMValueRef AtomicRMWInst
);
3931 void LLVMSetAtomicRMWBinOp(LLVMValueRef AtomicRMWInst
, LLVMAtomicRMWBinOp BinOp
);
3934 LLVMValueRef
LLVMBuildTrunc(LLVMBuilderRef
, LLVMValueRef Val
,
3935 LLVMTypeRef DestTy
, const char *Name
);
3936 LLVMValueRef
LLVMBuildZExt(LLVMBuilderRef
, LLVMValueRef Val
,
3937 LLVMTypeRef DestTy
, const char *Name
);
3938 LLVMValueRef
LLVMBuildSExt(LLVMBuilderRef
, LLVMValueRef Val
,
3939 LLVMTypeRef DestTy
, const char *Name
);
3940 LLVMValueRef
LLVMBuildFPToUI(LLVMBuilderRef
, LLVMValueRef Val
,
3941 LLVMTypeRef DestTy
, const char *Name
);
3942 LLVMValueRef
LLVMBuildFPToSI(LLVMBuilderRef
, LLVMValueRef Val
,
3943 LLVMTypeRef DestTy
, const char *Name
);
3944 LLVMValueRef
LLVMBuildUIToFP(LLVMBuilderRef
, LLVMValueRef Val
,
3945 LLVMTypeRef DestTy
, const char *Name
);
3946 LLVMValueRef
LLVMBuildSIToFP(LLVMBuilderRef
, LLVMValueRef Val
,
3947 LLVMTypeRef DestTy
, const char *Name
);
3948 LLVMValueRef
LLVMBuildFPTrunc(LLVMBuilderRef
, LLVMValueRef Val
,
3949 LLVMTypeRef DestTy
, const char *Name
);
3950 LLVMValueRef
LLVMBuildFPExt(LLVMBuilderRef
, LLVMValueRef Val
,
3951 LLVMTypeRef DestTy
, const char *Name
);
3952 LLVMValueRef
LLVMBuildPtrToInt(LLVMBuilderRef
, LLVMValueRef Val
,
3953 LLVMTypeRef DestTy
, const char *Name
);
3954 LLVMValueRef
LLVMBuildIntToPtr(LLVMBuilderRef
, LLVMValueRef Val
,
3955 LLVMTypeRef DestTy
, const char *Name
);
3956 LLVMValueRef
LLVMBuildBitCast(LLVMBuilderRef
, LLVMValueRef Val
,
3957 LLVMTypeRef DestTy
, const char *Name
);
3958 LLVMValueRef
LLVMBuildAddrSpaceCast(LLVMBuilderRef
, LLVMValueRef Val
,
3959 LLVMTypeRef DestTy
, const char *Name
);
3960 LLVMValueRef
LLVMBuildZExtOrBitCast(LLVMBuilderRef
, LLVMValueRef Val
,
3961 LLVMTypeRef DestTy
, const char *Name
);
3962 LLVMValueRef
LLVMBuildSExtOrBitCast(LLVMBuilderRef
, LLVMValueRef Val
,
3963 LLVMTypeRef DestTy
, const char *Name
);
3964 LLVMValueRef
LLVMBuildTruncOrBitCast(LLVMBuilderRef
, LLVMValueRef Val
,
3965 LLVMTypeRef DestTy
, const char *Name
);
3966 LLVMValueRef
LLVMBuildCast(LLVMBuilderRef B
, LLVMOpcode Op
, LLVMValueRef Val
,
3967 LLVMTypeRef DestTy
, const char *Name
);
3968 LLVMValueRef
LLVMBuildPointerCast(LLVMBuilderRef
, LLVMValueRef Val
,
3969 LLVMTypeRef DestTy
, const char *Name
);
3970 LLVMValueRef
LLVMBuildIntCast2(LLVMBuilderRef
, LLVMValueRef Val
,
3971 LLVMTypeRef DestTy
, LLVMBool IsSigned
,
3973 LLVMValueRef
LLVMBuildFPCast(LLVMBuilderRef
, LLVMValueRef Val
,
3974 LLVMTypeRef DestTy
, const char *Name
);
3976 /** Deprecated: This cast is always signed. Use LLVMBuildIntCast2 instead. */
3977 LLVMValueRef
LLVMBuildIntCast(LLVMBuilderRef
, LLVMValueRef Val
, /*Signed cast!*/
3978 LLVMTypeRef DestTy
, const char *Name
);
3981 LLVMValueRef
LLVMBuildICmp(LLVMBuilderRef
, LLVMIntPredicate Op
,
3982 LLVMValueRef LHS
, LLVMValueRef RHS
,
3984 LLVMValueRef
LLVMBuildFCmp(LLVMBuilderRef
, LLVMRealPredicate Op
,
3985 LLVMValueRef LHS
, LLVMValueRef RHS
,
3988 /* Miscellaneous instructions */
3989 LLVMValueRef
LLVMBuildPhi(LLVMBuilderRef
, LLVMTypeRef Ty
, const char *Name
);
3990 LLVM_ATTRIBUTE_C_DEPRECATED(
3991 LLVMValueRef
LLVMBuildCall(LLVMBuilderRef
, LLVMValueRef Fn
,
3992 LLVMValueRef
*Args
, unsigned NumArgs
,
3994 "Use LLVMBuildCall2 instead to support opaque pointers");
3995 LLVMValueRef
LLVMBuildCall2(LLVMBuilderRef
, LLVMTypeRef
, LLVMValueRef Fn
,
3996 LLVMValueRef
*Args
, unsigned NumArgs
,
3998 LLVMValueRef
LLVMBuildSelect(LLVMBuilderRef
, LLVMValueRef If
,
3999 LLVMValueRef Then
, LLVMValueRef Else
,
4001 LLVMValueRef
LLVMBuildVAArg(LLVMBuilderRef
, LLVMValueRef List
, LLVMTypeRef Ty
,
4003 LLVMValueRef
LLVMBuildExtractElement(LLVMBuilderRef
, LLVMValueRef VecVal
,
4004 LLVMValueRef Index
, const char *Name
);
4005 LLVMValueRef
LLVMBuildInsertElement(LLVMBuilderRef
, LLVMValueRef VecVal
,
4006 LLVMValueRef EltVal
, LLVMValueRef Index
,
4008 LLVMValueRef
LLVMBuildShuffleVector(LLVMBuilderRef
, LLVMValueRef V1
,
4009 LLVMValueRef V2
, LLVMValueRef Mask
,
4011 LLVMValueRef
LLVMBuildExtractValue(LLVMBuilderRef
, LLVMValueRef AggVal
,
4012 unsigned Index
, const char *Name
);
4013 LLVMValueRef
LLVMBuildInsertValue(LLVMBuilderRef
, LLVMValueRef AggVal
,
4014 LLVMValueRef EltVal
, unsigned Index
,
4016 LLVMValueRef
LLVMBuildFreeze(LLVMBuilderRef
, LLVMValueRef Val
,
4019 LLVMValueRef
LLVMBuildIsNull(LLVMBuilderRef
, LLVMValueRef Val
,
4021 LLVMValueRef
LLVMBuildIsNotNull(LLVMBuilderRef
, LLVMValueRef Val
,
4023 LLVMValueRef
LLVMBuildPtrDiff(LLVMBuilderRef
, LLVMValueRef LHS
,
4024 LLVMValueRef RHS
, const char *Name
);
4025 LLVMValueRef
LLVMBuildFence(LLVMBuilderRef B
, LLVMAtomicOrdering ordering
,
4026 LLVMBool singleThread
, const char *Name
);
4027 LLVMValueRef
LLVMBuildAtomicRMW(LLVMBuilderRef B
, LLVMAtomicRMWBinOp op
,
4028 LLVMValueRef PTR
, LLVMValueRef Val
,
4029 LLVMAtomicOrdering ordering
,
4030 LLVMBool singleThread
);
4031 LLVMValueRef
LLVMBuildAtomicCmpXchg(LLVMBuilderRef B
, LLVMValueRef Ptr
,
4032 LLVMValueRef Cmp
, LLVMValueRef New
,
4033 LLVMAtomicOrdering SuccessOrdering
,
4034 LLVMAtomicOrdering FailureOrdering
,
4035 LLVMBool SingleThread
);
4038 * Get the number of elements in the mask of a ShuffleVector instruction.
4040 unsigned LLVMGetNumMaskElements(LLVMValueRef ShuffleVectorInst
);
4043 * \returns a constant that specifies that the result of a \c ShuffleVectorInst
4046 int LLVMGetUndefMaskElem(void);
4049 * Get the mask value at position Elt in the mask of a ShuffleVector
4052 * \Returns the result of \c LLVMGetUndefMaskElem() if the mask value is undef
4055 int LLVMGetMaskValue(LLVMValueRef ShuffleVectorInst
, unsigned Elt
);
4057 LLVMBool
LLVMIsAtomicSingleThread(LLVMValueRef AtomicInst
);
4058 void LLVMSetAtomicSingleThread(LLVMValueRef AtomicInst
, LLVMBool SingleThread
);
4060 LLVMAtomicOrdering
LLVMGetCmpXchgSuccessOrdering(LLVMValueRef CmpXchgInst
);
4061 void LLVMSetCmpXchgSuccessOrdering(LLVMValueRef CmpXchgInst
,
4062 LLVMAtomicOrdering Ordering
);
4063 LLVMAtomicOrdering
LLVMGetCmpXchgFailureOrdering(LLVMValueRef CmpXchgInst
);
4064 void LLVMSetCmpXchgFailureOrdering(LLVMValueRef CmpXchgInst
,
4065 LLVMAtomicOrdering Ordering
);
4072 * @defgroup LLVMCCoreModuleProvider Module Providers
4078 * Changes the type of M so it can be passed to FunctionPassManagers and the
4079 * JIT. They take ModuleProviders for historical reasons.
4081 LLVMModuleProviderRef
4082 LLVMCreateModuleProviderForExistingModule(LLVMModuleRef M
);
4085 * Destroys the module M.
4087 void LLVMDisposeModuleProvider(LLVMModuleProviderRef M
);
4094 * @defgroup LLVMCCoreMemoryBuffers Memory Buffers
4099 LLVMBool
LLVMCreateMemoryBufferWithContentsOfFile(const char *Path
,
4100 LLVMMemoryBufferRef
*OutMemBuf
,
4102 LLVMBool
LLVMCreateMemoryBufferWithSTDIN(LLVMMemoryBufferRef
*OutMemBuf
,
4104 LLVMMemoryBufferRef
LLVMCreateMemoryBufferWithMemoryRange(const char *InputData
,
4105 size_t InputDataLength
,
4106 const char *BufferName
,
4107 LLVMBool RequiresNullTerminator
);
4108 LLVMMemoryBufferRef
LLVMCreateMemoryBufferWithMemoryRangeCopy(const char *InputData
,
4109 size_t InputDataLength
,
4110 const char *BufferName
);
4111 const char *LLVMGetBufferStart(LLVMMemoryBufferRef MemBuf
);
4112 size_t LLVMGetBufferSize(LLVMMemoryBufferRef MemBuf
);
4113 void LLVMDisposeMemoryBuffer(LLVMMemoryBufferRef MemBuf
);
4120 * @defgroup LLVMCCorePassRegistry Pass Registry
4121 * @ingroup LLVMCCore
4126 /** Return the global pass registry, for use with initialization functions.
4127 @see llvm::PassRegistry::getPassRegistry */
4128 LLVMPassRegistryRef
LLVMGetGlobalPassRegistry(void);
4135 * @defgroup LLVMCCorePassManagers Pass Managers
4136 * @ingroup LLVMCCore
4141 /** Constructs a new whole-module pass pipeline. This type of pipeline is
4142 suitable for link-time optimization and whole-module transformations.
4143 @see llvm::PassManager::PassManager */
4144 LLVMPassManagerRef
LLVMCreatePassManager(void);
4146 /** Constructs a new function-by-function pass pipeline over the module
4147 provider. It does not take ownership of the module provider. This type of
4148 pipeline is suitable for code generation and JIT compilation tasks.
4149 @see llvm::FunctionPassManager::FunctionPassManager */
4150 LLVMPassManagerRef
LLVMCreateFunctionPassManagerForModule(LLVMModuleRef M
);
4152 /** Deprecated: Use LLVMCreateFunctionPassManagerForModule instead. */
4153 LLVMPassManagerRef
LLVMCreateFunctionPassManager(LLVMModuleProviderRef MP
);
4155 /** Initializes, executes on the provided module, and finalizes all of the
4156 passes scheduled in the pass manager. Returns 1 if any of the passes
4157 modified the module, 0 otherwise.
4158 @see llvm::PassManager::run(Module&) */
4159 LLVMBool
LLVMRunPassManager(LLVMPassManagerRef PM
, LLVMModuleRef M
);
4161 /** Initializes all of the function passes scheduled in the function pass
4162 manager. Returns 1 if any of the passes modified the module, 0 otherwise.
4163 @see llvm::FunctionPassManager::doInitialization */
4164 LLVMBool
LLVMInitializeFunctionPassManager(LLVMPassManagerRef FPM
);
4166 /** Executes all of the function passes scheduled in the function pass manager
4167 on the provided function. Returns 1 if any of the passes modified the
4168 function, false otherwise.
4169 @see llvm::FunctionPassManager::run(Function&) */
4170 LLVMBool
LLVMRunFunctionPassManager(LLVMPassManagerRef FPM
, LLVMValueRef F
);
4172 /** Finalizes all of the function passes scheduled in the function pass
4173 manager. Returns 1 if any of the passes modified the module, 0 otherwise.
4174 @see llvm::FunctionPassManager::doFinalization */
4175 LLVMBool
LLVMFinalizeFunctionPassManager(LLVMPassManagerRef FPM
);
4177 /** Frees the memory of a pass pipeline. For function pipelines, does not free
4178 the module provider.
4179 @see llvm::PassManagerBase::~PassManagerBase. */
4180 void LLVMDisposePassManager(LLVMPassManagerRef PM
);
4187 * @defgroup LLVMCCoreThreading Threading
4189 * Handle the structures needed to make LLVM safe for multithreading.
4194 /** Deprecated: Multi-threading can only be enabled/disabled with the compile
4195 time define LLVM_ENABLE_THREADS. This function always returns
4196 LLVMIsMultithreaded(). */
4197 LLVMBool
LLVMStartMultithreaded(void);
4199 /** Deprecated: Multi-threading can only be enabled/disabled with the compile
4200 time define LLVM_ENABLE_THREADS. */
4201 void LLVMStopMultithreaded(void);
4203 /** Check whether LLVM is executing in thread-safe mode or not.
4204 @see llvm::llvm_is_multithreaded */
4205 LLVMBool
LLVMIsMultithreaded(void);
4221 #endif /* LLVM_C_CORE_H */