1 /*===-- llvm-c/Core.h - Core Library C Interface ------------------*- C -*-===*\
3 |* The LLVM Compiler Infrastructure *|
5 |* This file is distributed under the University of Illinois Open Source *|
6 |* License. See LICENSE.TXT for details. *|
8 |*===----------------------------------------------------------------------===*|
10 |* This header declares the C interface to libLLVMCore.a, which implements *|
11 |* the LLVM intermediate representation. *|
13 \*===----------------------------------------------------------------------===*/
18 #include "llvm-c/ErrorHandling.h"
19 #include "llvm-c/Types.h"
26 * @defgroup LLVMC LLVM-C: C interface to LLVM
28 * This module exposes parts of the LLVM library as a C API.
34 * @defgroup LLVMCTransforms Transforms
38 * @defgroup LLVMCCore Core
40 * This modules provide an interface to libLLVMCore, which implements
41 * the LLVM intermediate representation as well as other related types
44 * Many exotic languages can interoperate with C code but have a harder time
45 * with C++ due to name mangling. So in addition to C, this interface enables
46 * tools written in such languages.
52 * @defgroup LLVMCCoreTypes Types and Enumerations
58 /* Terminator Instructions */
64 /* removed 6 due to API changes */
67 /* Standard Binary Operators */
81 /* Logical Operators */
89 /* Memory Operators */
93 LLVMGetElementPtr = 29,
108 LLVMAddrSpaceCast = 60,
110 /* Other Operators */
119 LLVMExtractElement = 50,
120 LLVMInsertElement = 51,
121 LLVMShuffleVector = 52,
122 LLVMExtractValue = 53,
123 LLVMInsertValue = 54,
125 /* Atomic operators */
127 LLVMAtomicCmpXchg = 56,
130 /* Exception Handling Operators */
141 LLVMVoidTypeKind, /**< type with no size */
142 LLVMHalfTypeKind, /**< 16 bit floating point type */
143 LLVMFloatTypeKind, /**< 32 bit floating point type */
144 LLVMDoubleTypeKind, /**< 64 bit floating point type */
145 LLVMX86_FP80TypeKind, /**< 80 bit floating point type (X87) */
146 LLVMFP128TypeKind, /**< 128 bit floating point type (112-bit mantissa)*/
147 LLVMPPC_FP128TypeKind, /**< 128 bit floating point type (two 64-bits) */
148 LLVMLabelTypeKind, /**< Labels */
149 LLVMIntegerTypeKind, /**< Arbitrary bit width integers */
150 LLVMFunctionTypeKind, /**< Functions */
151 LLVMStructTypeKind, /**< Structures */
152 LLVMArrayTypeKind, /**< Arrays */
153 LLVMPointerTypeKind, /**< Pointers */
154 LLVMVectorTypeKind, /**< SIMD 'packed' format, or other vector type */
155 LLVMMetadataTypeKind, /**< Metadata */
156 LLVMX86_MMXTypeKind, /**< X86 MMX */
157 LLVMTokenTypeKind /**< Tokens */
161 LLVMExternalLinkage, /**< Externally visible function */
162 LLVMAvailableExternallyLinkage,
163 LLVMLinkOnceAnyLinkage, /**< Keep one copy of function when linking (inline)*/
164 LLVMLinkOnceODRLinkage, /**< Same, but only replaced by something
166 LLVMLinkOnceODRAutoHideLinkage, /**< Obsolete */
167 LLVMWeakAnyLinkage, /**< Keep one copy of function when linking (weak) */
168 LLVMWeakODRLinkage, /**< Same, but only replaced by something
170 LLVMAppendingLinkage, /**< Special purpose, only applies to global arrays */
171 LLVMInternalLinkage, /**< Rename collisions when linking (static
173 LLVMPrivateLinkage, /**< Like Internal, but omit from symbol table */
174 LLVMDLLImportLinkage, /**< Obsolete */
175 LLVMDLLExportLinkage, /**< Obsolete */
176 LLVMExternalWeakLinkage,/**< ExternalWeak linkage description */
177 LLVMGhostLinkage, /**< Obsolete */
178 LLVMCommonLinkage, /**< Tentative definitions */
179 LLVMLinkerPrivateLinkage, /**< Like Private, but linker removes. */
180 LLVMLinkerPrivateWeakLinkage /**< Like LinkerPrivate, but is weak. */
184 LLVMDefaultVisibility, /**< The GV is visible */
185 LLVMHiddenVisibility, /**< The GV is hidden */
186 LLVMProtectedVisibility /**< The GV is protected */
190 LLVMDefaultStorageClass = 0,
191 LLVMDLLImportStorageClass = 1, /**< Function to be imported from DLL. */
192 LLVMDLLExportStorageClass = 2 /**< Function to be accessible from DLL. */
193 } LLVMDLLStorageClass;
197 LLVMFastCallConv = 8,
198 LLVMColdCallConv = 9,
199 LLVMWebKitJSCallConv = 12,
200 LLVMAnyRegCallConv = 13,
201 LLVMX86StdcallCallConv = 64,
202 LLVMX86FastcallCallConv = 65
206 LLVMArgumentValueKind,
207 LLVMBasicBlockValueKind,
208 LLVMMemoryUseValueKind,
209 LLVMMemoryDefValueKind,
210 LLVMMemoryPhiValueKind,
212 LLVMFunctionValueKind,
213 LLVMGlobalAliasValueKind,
214 LLVMGlobalIFuncValueKind,
215 LLVMGlobalVariableValueKind,
216 LLVMBlockAddressValueKind,
217 LLVMConstantExprValueKind,
218 LLVMConstantArrayValueKind,
219 LLVMConstantStructValueKind,
220 LLVMConstantVectorValueKind,
222 LLVMUndefValueValueKind,
223 LLVMConstantAggregateZeroValueKind,
224 LLVMConstantDataArrayValueKind,
225 LLVMConstantDataVectorValueKind,
226 LLVMConstantIntValueKind,
227 LLVMConstantFPValueKind,
228 LLVMConstantPointerNullValueKind,
229 LLVMConstantTokenNoneValueKind,
231 LLVMMetadataAsValueValueKind,
232 LLVMInlineAsmValueKind,
234 LLVMInstructionValueKind,
238 LLVMIntEQ = 32, /**< equal */
239 LLVMIntNE, /**< not equal */
240 LLVMIntUGT, /**< unsigned greater than */
241 LLVMIntUGE, /**< unsigned greater or equal */
242 LLVMIntULT, /**< unsigned less than */
243 LLVMIntULE, /**< unsigned less or equal */
244 LLVMIntSGT, /**< signed greater than */
245 LLVMIntSGE, /**< signed greater or equal */
246 LLVMIntSLT, /**< signed less than */
247 LLVMIntSLE /**< signed less or equal */
251 LLVMRealPredicateFalse, /**< Always false (always folded) */
252 LLVMRealOEQ, /**< True if ordered and equal */
253 LLVMRealOGT, /**< True if ordered and greater than */
254 LLVMRealOGE, /**< True if ordered and greater than or equal */
255 LLVMRealOLT, /**< True if ordered and less than */
256 LLVMRealOLE, /**< True if ordered and less than or equal */
257 LLVMRealONE, /**< True if ordered and operands are unequal */
258 LLVMRealORD, /**< True if ordered (no nans) */
259 LLVMRealUNO, /**< True if unordered: isnan(X) | isnan(Y) */
260 LLVMRealUEQ, /**< True if unordered or equal */
261 LLVMRealUGT, /**< True if unordered or greater than */
262 LLVMRealUGE, /**< True if unordered, greater than, or equal */
263 LLVMRealULT, /**< True if unordered or less than */
264 LLVMRealULE, /**< True if unordered, less than, or equal */
265 LLVMRealUNE, /**< True if unordered or not equal */
266 LLVMRealPredicateTrue /**< Always true (always folded) */
270 LLVMLandingPadCatch, /**< A catch clause */
271 LLVMLandingPadFilter /**< A filter clause */
272 } LLVMLandingPadClauseTy;
275 LLVMNotThreadLocal = 0,
276 LLVMGeneralDynamicTLSModel,
277 LLVMLocalDynamicTLSModel,
278 LLVMInitialExecTLSModel,
279 LLVMLocalExecTLSModel
280 } LLVMThreadLocalMode;
283 LLVMAtomicOrderingNotAtomic = 0, /**< A load or store which is not atomic */
284 LLVMAtomicOrderingUnordered = 1, /**< Lowest level of atomicity, guarantees
285 somewhat sane results, lock free. */
286 LLVMAtomicOrderingMonotonic = 2, /**< guarantees that if you take all the
287 operations affecting a specific address,
288 a consistent ordering exists */
289 LLVMAtomicOrderingAcquire = 4, /**< Acquire provides a barrier of the sort
290 necessary to acquire a lock to access other
291 memory with normal loads and stores. */
292 LLVMAtomicOrderingRelease = 5, /**< Release is similar to Acquire, but with
293 a barrier of the sort necessary to release
295 LLVMAtomicOrderingAcquireRelease = 6, /**< provides both an Acquire and a
296 Release barrier (for fences and
297 operations which both read and write
299 LLVMAtomicOrderingSequentiallyConsistent = 7 /**< provides Acquire semantics
300 for loads and Release
301 semantics for stores.
302 Additionally, it guarantees
303 that a total ordering exists
305 SequentiallyConsistent
307 } LLVMAtomicOrdering;
310 LLVMAtomicRMWBinOpXchg, /**< Set the new value and return the one old */
311 LLVMAtomicRMWBinOpAdd, /**< Add a value and return the old one */
312 LLVMAtomicRMWBinOpSub, /**< Subtract a value and return the old one */
313 LLVMAtomicRMWBinOpAnd, /**< And a value and return the old one */
314 LLVMAtomicRMWBinOpNand, /**< Not-And a value and return the old one */
315 LLVMAtomicRMWBinOpOr, /**< OR a value and return the old one */
316 LLVMAtomicRMWBinOpXor, /**< Xor a value and return the old one */
317 LLVMAtomicRMWBinOpMax, /**< Sets the value if it's greater than the
318 original using a signed comparison and return
320 LLVMAtomicRMWBinOpMin, /**< Sets the value if it's Smaller than the
321 original using a signed comparison and return
323 LLVMAtomicRMWBinOpUMax, /**< Sets the value if it's greater than the
324 original using an unsigned comparison and return
326 LLVMAtomicRMWBinOpUMin /**< Sets the value if it's greater than the
327 original using an unsigned comparison and return
329 } LLVMAtomicRMWBinOp;
336 } LLVMDiagnosticSeverity;
339 * Attribute index are either LLVMAttributeReturnIndex,
340 * LLVMAttributeFunctionIndex or a parameter number from 1 to N.
343 LLVMAttributeReturnIndex = 0U,
344 // ISO C restricts enumerator values to range of 'int'
345 // (4294967295 is too large)
346 // LLVMAttributeFunctionIndex = ~0U,
347 LLVMAttributeFunctionIndex = -1,
350 typedef unsigned LLVMAttributeIndex;
356 void LLVMInitializeCore(LLVMPassRegistryRef R);
358 /** Deallocate and destroy all ManagedStatic variables.
359 @see llvm::llvm_shutdown
360 @see ManagedStatic */
361 void LLVMShutdown(void);
363 /*===-- Error handling ----------------------------------------------------===*/
365 char *LLVMCreateMessage(const char *Message);
366 void LLVMDisposeMessage(char *Message);
369 * @defgroup LLVMCCoreContext Contexts
371 * Contexts are execution states for the core LLVM IR system.
373 * Most types are tied to a context instance. Multiple contexts can
374 * exist simultaneously. A single context is not thread safe. However,
375 * different contexts can execute on different threads simultaneously.
380 typedef void (*LLVMDiagnosticHandler)(LLVMDiagnosticInfoRef, void *);
381 typedef void (*LLVMYieldCallback)(LLVMContextRef, void *);
384 * Create a new context.
386 * Every call to this function should be paired with a call to
387 * LLVMContextDispose() or the context will leak memory.
389 LLVMContextRef LLVMContextCreate(void);
392 * Obtain the global context instance.
394 LLVMContextRef LLVMGetGlobalContext(void);
397 * Set the diagnostic handler for this context.
399 void LLVMContextSetDiagnosticHandler(LLVMContextRef C,
400 LLVMDiagnosticHandler Handler,
401 void *DiagnosticContext);
404 * Get the diagnostic handler of this context.
406 LLVMDiagnosticHandler LLVMContextGetDiagnosticHandler(LLVMContextRef C);
409 * Get the diagnostic context of this context.
411 void *LLVMContextGetDiagnosticContext(LLVMContextRef C);
414 * Set the yield callback function for this context.
416 * @see LLVMContext::setYieldCallback()
418 void LLVMContextSetYieldCallback(LLVMContextRef C, LLVMYieldCallback Callback,
422 * Destroy a context instance.
424 * This should be called for every call to LLVMContextCreate() or memory
427 void LLVMContextDispose(LLVMContextRef C);
430 * Return a string representation of the DiagnosticInfo. Use
431 * LLVMDisposeMessage to free the string.
433 * @see DiagnosticInfo::print()
435 char *LLVMGetDiagInfoDescription(LLVMDiagnosticInfoRef DI);
438 * Return an enum LLVMDiagnosticSeverity.
440 * @see DiagnosticInfo::getSeverity()
442 LLVMDiagnosticSeverity LLVMGetDiagInfoSeverity(LLVMDiagnosticInfoRef DI);
444 unsigned LLVMGetMDKindIDInContext(LLVMContextRef C, const char *Name,
446 unsigned LLVMGetMDKindID(const char *Name, unsigned SLen);
449 * Return an unique id given the name of a enum attribute,
450 * or 0 if no attribute by that name exists.
452 * See http://llvm.org/docs/LangRef.html#parameter-attributes
453 * and http://llvm.org/docs/LangRef.html#function-attributes
454 * for the list of available attributes.
456 * NB: Attribute names and/or id are subject to change without
457 * going through the C API deprecation cycle.
459 unsigned LLVMGetEnumAttributeKindForName(const char *Name, size_t SLen);
460 unsigned LLVMGetLastEnumAttributeKind(void);
463 * Create an enum attribute.
465 LLVMAttributeRef LLVMCreateEnumAttribute(LLVMContextRef C, unsigned KindID,
469 * Get the unique id corresponding to the enum attribute
470 * passed as argument.
472 unsigned LLVMGetEnumAttributeKind(LLVMAttributeRef A);
475 * Get the enum attribute's value. 0 is returned if none exists.
477 uint64_t LLVMGetEnumAttributeValue(LLVMAttributeRef A);
480 * Create a string attribute.
482 LLVMAttributeRef LLVMCreateStringAttribute(LLVMContextRef C,
483 const char *K, unsigned KLength,
484 const char *V, unsigned VLength);
487 * Get the string attribute's kind.
489 const char *LLVMGetStringAttributeKind(LLVMAttributeRef A, unsigned *Length);
492 * Get the string attribute's value.
494 const char *LLVMGetStringAttributeValue(LLVMAttributeRef A, unsigned *Length);
497 * Check for the different types of attributes.
499 LLVMBool LLVMIsEnumAttribute(LLVMAttributeRef A);
500 LLVMBool LLVMIsStringAttribute(LLVMAttributeRef A);
507 * @defgroup LLVMCCoreModule Modules
509 * Modules represent the top-level structure in an LLVM program. An LLVM
510 * module is effectively a translation unit or a collection of
511 * translation units merged together.
517 * Create a new, empty module in the global context.
519 * This is equivalent to calling LLVMModuleCreateWithNameInContext with
520 * LLVMGetGlobalContext() as the context parameter.
522 * Every invocation should be paired with LLVMDisposeModule() or memory
525 LLVMModuleRef LLVMModuleCreateWithName(const char *ModuleID);
528 * Create a new, empty module in a specific context.
530 * Every invocation should be paired with LLVMDisposeModule() or memory
533 LLVMModuleRef LLVMModuleCreateWithNameInContext(const char *ModuleID,
536 * Return an exact copy of the specified module.
538 LLVMModuleRef LLVMCloneModule(LLVMModuleRef M);
541 * Destroy a module instance.
543 * This must be called for every created module or memory will be
546 void LLVMDisposeModule(LLVMModuleRef M);
549 * Obtain the identifier of a module.
551 * @param M Module to obtain identifier of
552 * @param Len Out parameter which holds the length of the returned string.
553 * @return The identifier of M.
554 * @see Module::getModuleIdentifier()
556 const char *LLVMGetModuleIdentifier(LLVMModuleRef M, size_t *Len);
559 * Set the identifier of a module to a string Ident with length Len.
561 * @param M The module to set identifier
562 * @param Ident The string to set M's identifier to
563 * @param Len Length of Ident
564 * @see Module::setModuleIdentifier()
566 void LLVMSetModuleIdentifier(LLVMModuleRef M, const char *Ident, size_t Len);
569 * Obtain the data layout for a module.
571 * @see Module::getDataLayoutStr()
573 * LLVMGetDataLayout is DEPRECATED, as the name is not only incorrect,
574 * but match the name of another method on the module. Prefer the use
575 * of LLVMGetDataLayoutStr, which is not ambiguous.
577 const char *LLVMGetDataLayoutStr(LLVMModuleRef M);
578 const char *LLVMGetDataLayout(LLVMModuleRef M);
581 * Set the data layout for a module.
583 * @see Module::setDataLayout()
585 void LLVMSetDataLayout(LLVMModuleRef M, const char *DataLayoutStr);
588 * Obtain the target triple for a module.
590 * @see Module::getTargetTriple()
592 const char *LLVMGetTarget(LLVMModuleRef M);
595 * Set the target triple for a module.
597 * @see Module::setTargetTriple()
599 void LLVMSetTarget(LLVMModuleRef M, const char *Triple);
602 * Dump a representation of a module to stderr.
604 * @see Module::dump()
606 void LLVMDumpModule(LLVMModuleRef M);
609 * Print a representation of a module to a file. The ErrorMessage needs to be
610 * disposed with LLVMDisposeMessage. Returns 0 on success, 1 otherwise.
612 * @see Module::print()
614 LLVMBool LLVMPrintModuleToFile(LLVMModuleRef M, const char *Filename,
615 char **ErrorMessage);
618 * Return a string representation of the module. Use
619 * LLVMDisposeMessage to free the string.
621 * @see Module::print()
623 char *LLVMPrintModuleToString(LLVMModuleRef M);
626 * Set inline assembly for a module.
628 * @see Module::setModuleInlineAsm()
630 void LLVMSetModuleInlineAsm(LLVMModuleRef M, const char *Asm);
633 * Obtain the context to which this module is associated.
635 * @see Module::getContext()
637 LLVMContextRef LLVMGetModuleContext(LLVMModuleRef M);
640 * Obtain a Type from a module by its registered name.
642 LLVMTypeRef LLVMGetTypeByName(LLVMModuleRef M, const char *Name);
645 * Obtain the number of operands for named metadata in a module.
647 * @see llvm::Module::getNamedMetadata()
649 unsigned LLVMGetNamedMetadataNumOperands(LLVMModuleRef M, const char *Name);
652 * Obtain the named metadata operands for a module.
654 * The passed LLVMValueRef pointer should refer to an array of
655 * LLVMValueRef at least LLVMGetNamedMetadataNumOperands long. This
656 * array will be populated with the LLVMValueRef instances. Each
657 * instance corresponds to a llvm::MDNode.
659 * @see llvm::Module::getNamedMetadata()
660 * @see llvm::MDNode::getOperand()
662 void LLVMGetNamedMetadataOperands(LLVMModuleRef M, const char *Name,
666 * Add an operand to named metadata.
668 * @see llvm::Module::getNamedMetadata()
669 * @see llvm::MDNode::addOperand()
671 void LLVMAddNamedMetadataOperand(LLVMModuleRef M, const char *Name,
675 * Add a function to a module under a specified name.
677 * @see llvm::Function::Create()
679 LLVMValueRef LLVMAddFunction(LLVMModuleRef M, const char *Name,
680 LLVMTypeRef FunctionTy);
683 * Obtain a Function value from a Module by its name.
685 * The returned value corresponds to a llvm::Function value.
687 * @see llvm::Module::getFunction()
689 LLVMValueRef LLVMGetNamedFunction(LLVMModuleRef M, const char *Name);
692 * Obtain an iterator to the first Function in a Module.
694 * @see llvm::Module::begin()
696 LLVMValueRef LLVMGetFirstFunction(LLVMModuleRef M);
699 * Obtain an iterator to the last Function in a Module.
701 * @see llvm::Module::end()
703 LLVMValueRef LLVMGetLastFunction(LLVMModuleRef M);
706 * Advance a Function iterator to the next Function.
708 * Returns NULL if the iterator was already at the end and there are no more
711 LLVMValueRef LLVMGetNextFunction(LLVMValueRef Fn);
714 * Decrement a Function iterator to the previous Function.
716 * Returns NULL if the iterator was already at the beginning and there are
717 * no previous functions.
719 LLVMValueRef LLVMGetPreviousFunction(LLVMValueRef Fn);
726 * @defgroup LLVMCCoreType Types
728 * Types represent the type of a value.
730 * Types are associated with a context instance. The context internally
731 * deduplicates types so there is only 1 instance of a specific type
732 * alive at a time. In other words, a unique type is shared among all
733 * consumers within a context.
735 * A Type in the C API corresponds to llvm::Type.
737 * Types have the following hierarchy:
755 * Obtain the enumerated type of a Type instance.
757 * @see llvm::Type:getTypeID()
759 LLVMTypeKind LLVMGetTypeKind(LLVMTypeRef Ty);
762 * Whether the type has a known size.
764 * Things that don't have a size are abstract types, labels, and void.a
766 * @see llvm::Type::isSized()
768 LLVMBool LLVMTypeIsSized(LLVMTypeRef Ty);
771 * Obtain the context to which this type instance is associated.
773 * @see llvm::Type::getContext()
775 LLVMContextRef LLVMGetTypeContext(LLVMTypeRef Ty);
778 * Dump a representation of a type to stderr.
780 * @see llvm::Type::dump()
782 void LLVMDumpType(LLVMTypeRef Val);
785 * Return a string representation of the type. Use
786 * LLVMDisposeMessage to free the string.
788 * @see llvm::Type::print()
790 char *LLVMPrintTypeToString(LLVMTypeRef Val);
793 * @defgroup LLVMCCoreTypeInt Integer Types
795 * Functions in this section operate on integer types.
801 * Obtain an integer type from a context with specified bit width.
803 LLVMTypeRef LLVMInt1TypeInContext(LLVMContextRef C);
804 LLVMTypeRef LLVMInt8TypeInContext(LLVMContextRef C);
805 LLVMTypeRef LLVMInt16TypeInContext(LLVMContextRef C);
806 LLVMTypeRef LLVMInt32TypeInContext(LLVMContextRef C);
807 LLVMTypeRef LLVMInt64TypeInContext(LLVMContextRef C);
808 LLVMTypeRef LLVMInt128TypeInContext(LLVMContextRef C);
809 LLVMTypeRef LLVMIntTypeInContext(LLVMContextRef C, unsigned NumBits);
812 * Obtain an integer type from the global context with a specified bit
815 LLVMTypeRef LLVMInt1Type(void);
816 LLVMTypeRef LLVMInt8Type(void);
817 LLVMTypeRef LLVMInt16Type(void);
818 LLVMTypeRef LLVMInt32Type(void);
819 LLVMTypeRef LLVMInt64Type(void);
820 LLVMTypeRef LLVMInt128Type(void);
821 LLVMTypeRef LLVMIntType(unsigned NumBits);
822 unsigned LLVMGetIntTypeWidth(LLVMTypeRef IntegerTy);
829 * @defgroup LLVMCCoreTypeFloat Floating Point Types
835 * Obtain a 16-bit floating point type from a context.
837 LLVMTypeRef LLVMHalfTypeInContext(LLVMContextRef C);
840 * Obtain a 32-bit floating point type from a context.
842 LLVMTypeRef LLVMFloatTypeInContext(LLVMContextRef C);
845 * Obtain a 64-bit floating point type from a context.
847 LLVMTypeRef LLVMDoubleTypeInContext(LLVMContextRef C);
850 * Obtain a 80-bit floating point type (X87) from a context.
852 LLVMTypeRef LLVMX86FP80TypeInContext(LLVMContextRef C);
855 * Obtain a 128-bit floating point type (112-bit mantissa) from a
858 LLVMTypeRef LLVMFP128TypeInContext(LLVMContextRef C);
861 * Obtain a 128-bit floating point type (two 64-bits) from a context.
863 LLVMTypeRef LLVMPPCFP128TypeInContext(LLVMContextRef C);
866 * Obtain a floating point type from the global context.
868 * These map to the functions in this group of the same name.
870 LLVMTypeRef LLVMHalfType(void);
871 LLVMTypeRef LLVMFloatType(void);
872 LLVMTypeRef LLVMDoubleType(void);
873 LLVMTypeRef LLVMX86FP80Type(void);
874 LLVMTypeRef LLVMFP128Type(void);
875 LLVMTypeRef LLVMPPCFP128Type(void);
882 * @defgroup LLVMCCoreTypeFunction Function Types
888 * Obtain a function type consisting of a specified signature.
890 * The function is defined as a tuple of a return Type, a list of
891 * parameter types, and whether the function is variadic.
893 LLVMTypeRef LLVMFunctionType(LLVMTypeRef ReturnType,
894 LLVMTypeRef *ParamTypes, unsigned ParamCount,
898 * Returns whether a function type is variadic.
900 LLVMBool LLVMIsFunctionVarArg(LLVMTypeRef FunctionTy);
903 * Obtain the Type this function Type returns.
905 LLVMTypeRef LLVMGetReturnType(LLVMTypeRef FunctionTy);
908 * Obtain the number of parameters this function accepts.
910 unsigned LLVMCountParamTypes(LLVMTypeRef FunctionTy);
913 * Obtain the types of a function's parameters.
915 * The Dest parameter should point to a pre-allocated array of
916 * LLVMTypeRef at least LLVMCountParamTypes() large. On return, the
917 * first LLVMCountParamTypes() entries in the array will be populated
918 * with LLVMTypeRef instances.
920 * @param FunctionTy The function type to operate on.
921 * @param Dest Memory address of an array to be filled with result.
923 void LLVMGetParamTypes(LLVMTypeRef FunctionTy, LLVMTypeRef *Dest);
930 * @defgroup LLVMCCoreTypeStruct Structure Types
932 * These functions relate to LLVMTypeRef instances.
934 * @see llvm::StructType
940 * Create a new structure type in a context.
942 * A structure is specified by a list of inner elements/types and
943 * whether these can be packed together.
945 * @see llvm::StructType::create()
947 LLVMTypeRef LLVMStructTypeInContext(LLVMContextRef C, LLVMTypeRef *ElementTypes,
948 unsigned ElementCount, LLVMBool Packed);
951 * Create a new structure type in the global context.
953 * @see llvm::StructType::create()
955 LLVMTypeRef LLVMStructType(LLVMTypeRef *ElementTypes, unsigned ElementCount,
959 * Create an empty structure in a context having a specified name.
961 * @see llvm::StructType::create()
963 LLVMTypeRef LLVMStructCreateNamed(LLVMContextRef C, const char *Name);
966 * Obtain the name of a structure.
968 * @see llvm::StructType::getName()
970 const char *LLVMGetStructName(LLVMTypeRef Ty);
973 * Set the contents of a structure type.
975 * @see llvm::StructType::setBody()
977 void LLVMStructSetBody(LLVMTypeRef StructTy, LLVMTypeRef *ElementTypes,
978 unsigned ElementCount, LLVMBool Packed);
981 * Get the number of elements defined inside the structure.
983 * @see llvm::StructType::getNumElements()
985 unsigned LLVMCountStructElementTypes(LLVMTypeRef StructTy);
988 * Get the elements within a structure.
990 * The function is passed the address of a pre-allocated array of
991 * LLVMTypeRef at least LLVMCountStructElementTypes() long. After
992 * invocation, this array will be populated with the structure's
993 * elements. The objects in the destination array will have a lifetime
994 * of the structure type itself, which is the lifetime of the context it
997 void LLVMGetStructElementTypes(LLVMTypeRef StructTy, LLVMTypeRef *Dest);
1000 * Get the type of the element at a given index in the structure.
1002 * @see llvm::StructType::getTypeAtIndex()
1004 LLVMTypeRef LLVMStructGetTypeAtIndex(LLVMTypeRef StructTy, unsigned i);
1007 * Determine whether a structure is packed.
1009 * @see llvm::StructType::isPacked()
1011 LLVMBool LLVMIsPackedStruct(LLVMTypeRef StructTy);
1014 * Determine whether a structure is opaque.
1016 * @see llvm::StructType::isOpaque()
1018 LLVMBool LLVMIsOpaqueStruct(LLVMTypeRef StructTy);
1025 * @defgroup LLVMCCoreTypeSequential Sequential Types
1027 * Sequential types represents "arrays" of types. This is a super class
1028 * for array, vector, and pointer types.
1034 * Obtain the type of elements within a sequential type.
1036 * This works on array, vector, and pointer types.
1038 * @see llvm::SequentialType::getElementType()
1040 LLVMTypeRef LLVMGetElementType(LLVMTypeRef Ty);
1043 * Create a fixed size array type that refers to a specific type.
1045 * The created type will exist in the context that its element type
1048 * @see llvm::ArrayType::get()
1050 LLVMTypeRef LLVMArrayType(LLVMTypeRef ElementType, unsigned ElementCount);
1053 * Obtain the length of an array type.
1055 * This only works on types that represent arrays.
1057 * @see llvm::ArrayType::getNumElements()
1059 unsigned LLVMGetArrayLength(LLVMTypeRef ArrayTy);
1062 * Create a pointer type that points to a defined type.
1064 * The created type will exist in the context that its pointee type
1067 * @see llvm::PointerType::get()
1069 LLVMTypeRef LLVMPointerType(LLVMTypeRef ElementType, unsigned AddressSpace);
1072 * Obtain the address space of a pointer type.
1074 * This only works on types that represent pointers.
1076 * @see llvm::PointerType::getAddressSpace()
1078 unsigned LLVMGetPointerAddressSpace(LLVMTypeRef PointerTy);
1081 * Create a vector type that contains a defined type and has a specific
1082 * number of elements.
1084 * The created type will exist in the context thats its element type
1087 * @see llvm::VectorType::get()
1089 LLVMTypeRef LLVMVectorType(LLVMTypeRef ElementType, unsigned ElementCount);
1092 * Obtain the number of elements in a vector type.
1094 * This only works on types that represent vectors.
1096 * @see llvm::VectorType::getNumElements()
1098 unsigned LLVMGetVectorSize(LLVMTypeRef VectorTy);
1105 * @defgroup LLVMCCoreTypeOther Other Types
1111 * Create a void type in a context.
1113 LLVMTypeRef LLVMVoidTypeInContext(LLVMContextRef C);
1116 * Create a label type in a context.
1118 LLVMTypeRef LLVMLabelTypeInContext(LLVMContextRef C);
1121 * Create a X86 MMX type in a context.
1123 LLVMTypeRef LLVMX86MMXTypeInContext(LLVMContextRef C);
1126 * These are similar to the above functions except they operate on the
1129 LLVMTypeRef LLVMVoidType(void);
1130 LLVMTypeRef LLVMLabelType(void);
1131 LLVMTypeRef LLVMX86MMXType(void);
1142 * @defgroup LLVMCCoreValues Values
1144 * The bulk of LLVM's object model consists of values, which comprise a very
1145 * rich type hierarchy.
1147 * LLVMValueRef essentially represents llvm::Value. There is a rich
1148 * hierarchy of classes within this type. Depending on the instance
1149 * obtained, not all APIs are available.
1151 * Callers can determine the type of an LLVMValueRef by calling the
1152 * LLVMIsA* family of functions (e.g. LLVMIsAArgument()). These
1153 * functions are defined by a macro, so it isn't obvious which are
1154 * available by looking at the Doxygen source code. Instead, look at the
1155 * source definition of LLVM_FOR_EACH_VALUE_SUBCLASS and note the list
1156 * of value names given. These value names also correspond to classes in
1157 * the llvm::Value hierarchy.
1162 #define LLVM_FOR_EACH_VALUE_SUBCLASS(macro) \
1168 macro(BlockAddress) \
1169 macro(ConstantAggregateZero) \
1170 macro(ConstantArray) \
1171 macro(ConstantDataSequential) \
1172 macro(ConstantDataArray) \
1173 macro(ConstantDataVector) \
1174 macro(ConstantExpr) \
1176 macro(ConstantInt) \
1177 macro(ConstantPointerNull) \
1178 macro(ConstantStruct) \
1179 macro(ConstantTokenNone) \
1180 macro(ConstantVector) \
1181 macro(GlobalValue) \
1182 macro(GlobalAlias) \
1183 macro(GlobalObject) \
1185 macro(GlobalVariable) \
1187 macro(Instruction) \
1188 macro(BinaryOperator) \
1190 macro(IntrinsicInst) \
1191 macro(DbgInfoIntrinsic) \
1192 macro(DbgDeclareInst) \
1193 macro(MemIntrinsic) \
1195 macro(MemMoveInst) \
1200 macro(ExtractElementInst) \
1201 macro(GetElementPtrInst) \
1202 macro(InsertElementInst) \
1203 macro(InsertValueInst) \
1204 macro(LandingPadInst) \
1207 macro(ShuffleVectorInst) \
1209 macro(TerminatorInst) \
1211 macro(IndirectBrInst) \
1215 macro(UnreachableInst) \
1217 macro(CleanupReturnInst) \
1218 macro(CatchReturnInst) \
1219 macro(FuncletPadInst) \
1220 macro(CatchPadInst) \
1221 macro(CleanupPadInst) \
1222 macro(UnaryInstruction) \
1225 macro(AddrSpaceCastInst) \
1226 macro(BitCastInst) \
1230 macro(FPTruncInst) \
1231 macro(IntToPtrInst) \
1232 macro(PtrToIntInst) \
1238 macro(ExtractValueInst) \
1243 * @defgroup LLVMCCoreValueGeneral General APIs
1245 * Functions in this section work on all LLVMValueRef instances,
1246 * regardless of their sub-type. They correspond to functions available
1253 * Obtain the type of a value.
1255 * @see llvm::Value::getType()
1257 LLVMTypeRef LLVMTypeOf(LLVMValueRef Val);
1260 * Obtain the enumerated type of a Value instance.
1262 * @see llvm::Value::getValueID()
1264 LLVMValueKind LLVMGetValueKind(LLVMValueRef Val);
1267 * Obtain the string name of a value.
1269 * @see llvm::Value::getName()
1271 const char *LLVMGetValueName(LLVMValueRef Val);
1274 * Set the string name of a value.
1276 * @see llvm::Value::setName()
1278 void LLVMSetValueName(LLVMValueRef Val, const char *Name);
1281 * Dump a representation of a value to stderr.
1283 * @see llvm::Value::dump()
1285 void LLVMDumpValue(LLVMValueRef Val);
1288 * Return a string representation of the value. Use
1289 * LLVMDisposeMessage to free the string.
1291 * @see llvm::Value::print()
1293 char *LLVMPrintValueToString(LLVMValueRef Val);
1296 * Replace all uses of a value with another one.
1298 * @see llvm::Value::replaceAllUsesWith()
1300 void LLVMReplaceAllUsesWith(LLVMValueRef OldVal, LLVMValueRef NewVal);
1303 * Determine whether the specified value instance is constant.
1305 LLVMBool LLVMIsConstant(LLVMValueRef Val);
1308 * Determine whether a value instance is undefined.
1310 LLVMBool LLVMIsUndef(LLVMValueRef Val);
1313 * Convert value instances between types.
1315 * Internally, an LLVMValueRef is "pinned" to a specific type. This
1316 * series of functions allows you to cast an instance to a specific
1319 * If the cast is not valid for the specified type, NULL is returned.
1321 * @see llvm::dyn_cast_or_null<>
1323 #define LLVM_DECLARE_VALUE_CAST(name) \
1324 LLVMValueRef LLVMIsA##name(LLVMValueRef Val);
1325 LLVM_FOR_EACH_VALUE_SUBCLASS(LLVM_DECLARE_VALUE_CAST)
1327 LLVMValueRef LLVMIsAMDNode(LLVMValueRef Val);
1328 LLVMValueRef LLVMIsAMDString(LLVMValueRef Val);
1335 * @defgroup LLVMCCoreValueUses Usage
1337 * This module defines functions that allow you to inspect the uses of a
1340 * It is possible to obtain an LLVMUseRef for any LLVMValueRef instance.
1341 * Each LLVMUseRef (which corresponds to a llvm::Use instance) holds a
1342 * llvm::User and llvm::Value.
1348 * Obtain the first use of a value.
1350 * Uses are obtained in an iterator fashion. First, call this function
1351 * to obtain a reference to the first use. Then, call LLVMGetNextUse()
1352 * on that instance and all subsequently obtained instances until
1353 * LLVMGetNextUse() returns NULL.
1355 * @see llvm::Value::use_begin()
1357 LLVMUseRef LLVMGetFirstUse(LLVMValueRef Val);
1360 * Obtain the next use of a value.
1362 * This effectively advances the iterator. It returns NULL if you are on
1363 * the final use and no more are available.
1365 LLVMUseRef LLVMGetNextUse(LLVMUseRef U);
1368 * Obtain the user value for a user.
1370 * The returned value corresponds to a llvm::User type.
1372 * @see llvm::Use::getUser()
1374 LLVMValueRef LLVMGetUser(LLVMUseRef U);
1377 * Obtain the value this use corresponds to.
1379 * @see llvm::Use::get().
1381 LLVMValueRef LLVMGetUsedValue(LLVMUseRef U);
1388 * @defgroup LLVMCCoreValueUser User value
1390 * Function in this group pertain to LLVMValueRef instances that descent
1391 * from llvm::User. This includes constants, instructions, and
1398 * Obtain an operand at a specific index in a llvm::User value.
1400 * @see llvm::User::getOperand()
1402 LLVMValueRef LLVMGetOperand(LLVMValueRef Val, unsigned Index);
1405 * Obtain the use of an operand at a specific index in a llvm::User value.
1407 * @see llvm::User::getOperandUse()
1409 LLVMUseRef LLVMGetOperandUse(LLVMValueRef Val, unsigned Index);
1412 * Set an operand at a specific index in a llvm::User value.
1414 * @see llvm::User::setOperand()
1416 void LLVMSetOperand(LLVMValueRef User, unsigned Index, LLVMValueRef Val);
1419 * Obtain the number of operands in a llvm::User value.
1421 * @see llvm::User::getNumOperands()
1423 int LLVMGetNumOperands(LLVMValueRef Val);
1430 * @defgroup LLVMCCoreValueConstant Constants
1432 * This section contains APIs for interacting with LLVMValueRef that
1433 * correspond to llvm::Constant instances.
1435 * These functions will work for any LLVMValueRef in the llvm::Constant
1442 * Obtain a constant value referring to the null instance of a type.
1444 * @see llvm::Constant::getNullValue()
1446 LLVMValueRef LLVMConstNull(LLVMTypeRef Ty); /* all zeroes */
1449 * Obtain a constant value referring to the instance of a type
1450 * consisting of all ones.
1452 * This is only valid for integer types.
1454 * @see llvm::Constant::getAllOnesValue()
1456 LLVMValueRef LLVMConstAllOnes(LLVMTypeRef Ty);
1459 * Obtain a constant value referring to an undefined value of a type.
1461 * @see llvm::UndefValue::get()
1463 LLVMValueRef LLVMGetUndef(LLVMTypeRef Ty);
1466 * Determine whether a value instance is null.
1468 * @see llvm::Constant::isNullValue()
1470 LLVMBool LLVMIsNull(LLVMValueRef Val);
1473 * Obtain a constant that is a constant pointer pointing to NULL for a
1476 LLVMValueRef LLVMConstPointerNull(LLVMTypeRef Ty);
1479 * @defgroup LLVMCCoreValueConstantScalar Scalar constants
1481 * Functions in this group model LLVMValueRef instances that correspond
1482 * to constants referring to scalar types.
1484 * For integer types, the LLVMTypeRef parameter should correspond to a
1485 * llvm::IntegerType instance and the returned LLVMValueRef will
1486 * correspond to a llvm::ConstantInt.
1488 * For floating point types, the LLVMTypeRef returned corresponds to a
1495 * Obtain a constant value for an integer type.
1497 * The returned value corresponds to a llvm::ConstantInt.
1499 * @see llvm::ConstantInt::get()
1501 * @param IntTy Integer type to obtain value of.
1502 * @param N The value the returned instance should refer to.
1503 * @param SignExtend Whether to sign extend the produced value.
1505 LLVMValueRef LLVMConstInt(LLVMTypeRef IntTy, unsigned long long N,
1506 LLVMBool SignExtend);
1509 * Obtain a constant value for an integer of arbitrary precision.
1511 * @see llvm::ConstantInt::get()
1513 LLVMValueRef LLVMConstIntOfArbitraryPrecision(LLVMTypeRef IntTy,
1515 const uint64_t Words[]);
1518 * Obtain a constant value for an integer parsed from a string.
1520 * A similar API, LLVMConstIntOfStringAndSize is also available. If the
1521 * string's length is available, it is preferred to call that function
1524 * @see llvm::ConstantInt::get()
1526 LLVMValueRef LLVMConstIntOfString(LLVMTypeRef IntTy, const char *Text,
1530 * Obtain a constant value for an integer parsed from a string with
1533 * @see llvm::ConstantInt::get()
1535 LLVMValueRef LLVMConstIntOfStringAndSize(LLVMTypeRef IntTy, const char *Text,
1536 unsigned SLen, uint8_t Radix);
1539 * Obtain a constant value referring to a double floating point value.
1541 LLVMValueRef LLVMConstReal(LLVMTypeRef RealTy, double N);
1544 * Obtain a constant for a floating point value parsed from a string.
1546 * A similar API, LLVMConstRealOfStringAndSize is also available. It
1547 * should be used if the input string's length is known.
1549 LLVMValueRef LLVMConstRealOfString(LLVMTypeRef RealTy, const char *Text);
1552 * Obtain a constant for a floating point value parsed from a string.
1554 LLVMValueRef LLVMConstRealOfStringAndSize(LLVMTypeRef RealTy, const char *Text,
1558 * Obtain the zero extended value for an integer constant value.
1560 * @see llvm::ConstantInt::getZExtValue()
1562 unsigned long long LLVMConstIntGetZExtValue(LLVMValueRef ConstantVal);
1565 * Obtain the sign extended value for an integer constant value.
1567 * @see llvm::ConstantInt::getSExtValue()
1569 long long LLVMConstIntGetSExtValue(LLVMValueRef ConstantVal);
1572 * Obtain the double value for an floating point constant value.
1573 * losesInfo indicates if some precision was lost in the conversion.
1575 * @see llvm::ConstantFP::getDoubleValue
1577 double LLVMConstRealGetDouble(LLVMValueRef ConstantVal, LLVMBool *losesInfo);
1584 * @defgroup LLVMCCoreValueConstantComposite Composite Constants
1586 * Functions in this group operate on composite constants.
1592 * Create a ConstantDataSequential and initialize it with a string.
1594 * @see llvm::ConstantDataArray::getString()
1596 LLVMValueRef LLVMConstStringInContext(LLVMContextRef C, const char *Str,
1597 unsigned Length, LLVMBool DontNullTerminate);
1600 * Create a ConstantDataSequential with string content in the global context.
1602 * This is the same as LLVMConstStringInContext except it operates on the
1605 * @see LLVMConstStringInContext()
1606 * @see llvm::ConstantDataArray::getString()
1608 LLVMValueRef LLVMConstString(const char *Str, unsigned Length,
1609 LLVMBool DontNullTerminate);
1612 * Returns true if the specified constant is an array of i8.
1614 * @see ConstantDataSequential::getAsString()
1616 LLVMBool LLVMIsConstantString(LLVMValueRef c);
1619 * Get the given constant data sequential as a string.
1621 * @see ConstantDataSequential::getAsString()
1623 const char *LLVMGetAsString(LLVMValueRef c, size_t *Length);
1626 * Create an anonymous ConstantStruct with the specified values.
1628 * @see llvm::ConstantStruct::getAnon()
1630 LLVMValueRef LLVMConstStructInContext(LLVMContextRef C,
1631 LLVMValueRef *ConstantVals,
1632 unsigned Count, LLVMBool Packed);
1635 * Create a ConstantStruct in the global Context.
1637 * This is the same as LLVMConstStructInContext except it operates on the
1640 * @see LLVMConstStructInContext()
1642 LLVMValueRef LLVMConstStruct(LLVMValueRef *ConstantVals, unsigned Count,
1646 * Create a ConstantArray from values.
1648 * @see llvm::ConstantArray::get()
1650 LLVMValueRef LLVMConstArray(LLVMTypeRef ElementTy,
1651 LLVMValueRef *ConstantVals, unsigned Length);
1654 * Create a non-anonymous ConstantStruct from values.
1656 * @see llvm::ConstantStruct::get()
1658 LLVMValueRef LLVMConstNamedStruct(LLVMTypeRef StructTy,
1659 LLVMValueRef *ConstantVals,
1663 * Get an element at specified index as a constant.
1665 * @see ConstantDataSequential::getElementAsConstant()
1667 LLVMValueRef LLVMGetElementAsConstant(LLVMValueRef C, unsigned idx);
1670 * Create a ConstantVector from values.
1672 * @see llvm::ConstantVector::get()
1674 LLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals, unsigned Size);
1681 * @defgroup LLVMCCoreValueConstantExpressions Constant Expressions
1683 * Functions in this group correspond to APIs on llvm::ConstantExpr.
1685 * @see llvm::ConstantExpr.
1689 LLVMOpcode LLVMGetConstOpcode(LLVMValueRef ConstantVal);
1690 LLVMValueRef LLVMAlignOf(LLVMTypeRef Ty);
1691 LLVMValueRef LLVMSizeOf(LLVMTypeRef Ty);
1692 LLVMValueRef LLVMConstNeg(LLVMValueRef ConstantVal);
1693 LLVMValueRef LLVMConstNSWNeg(LLVMValueRef ConstantVal);
1694 LLVMValueRef LLVMConstNUWNeg(LLVMValueRef ConstantVal);
1695 LLVMValueRef LLVMConstFNeg(LLVMValueRef ConstantVal);
1696 LLVMValueRef LLVMConstNot(LLVMValueRef ConstantVal);
1697 LLVMValueRef LLVMConstAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1698 LLVMValueRef LLVMConstNSWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1699 LLVMValueRef LLVMConstNUWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1700 LLVMValueRef LLVMConstFAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1701 LLVMValueRef LLVMConstSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1702 LLVMValueRef LLVMConstNSWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1703 LLVMValueRef LLVMConstNUWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1704 LLVMValueRef LLVMConstFSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1705 LLVMValueRef LLVMConstMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1706 LLVMValueRef LLVMConstNSWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1707 LLVMValueRef LLVMConstNUWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1708 LLVMValueRef LLVMConstFMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1709 LLVMValueRef LLVMConstUDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1710 LLVMValueRef LLVMConstExactUDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1711 LLVMValueRef LLVMConstSDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1712 LLVMValueRef LLVMConstExactSDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1713 LLVMValueRef LLVMConstFDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1714 LLVMValueRef LLVMConstURem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1715 LLVMValueRef LLVMConstSRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1716 LLVMValueRef LLVMConstFRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1717 LLVMValueRef LLVMConstAnd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1718 LLVMValueRef LLVMConstOr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1719 LLVMValueRef LLVMConstXor(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1720 LLVMValueRef LLVMConstICmp(LLVMIntPredicate Predicate,
1721 LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1722 LLVMValueRef LLVMConstFCmp(LLVMRealPredicate Predicate,
1723 LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1724 LLVMValueRef LLVMConstShl(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1725 LLVMValueRef LLVMConstLShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1726 LLVMValueRef LLVMConstAShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1727 LLVMValueRef LLVMConstGEP(LLVMValueRef ConstantVal,
1728 LLVMValueRef *ConstantIndices, unsigned NumIndices);
1729 LLVMValueRef LLVMConstInBoundsGEP(LLVMValueRef ConstantVal,
1730 LLVMValueRef *ConstantIndices,
1731 unsigned NumIndices);
1732 LLVMValueRef LLVMConstTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1733 LLVMValueRef LLVMConstSExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1734 LLVMValueRef LLVMConstZExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1735 LLVMValueRef LLVMConstFPTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1736 LLVMValueRef LLVMConstFPExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1737 LLVMValueRef LLVMConstUIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1738 LLVMValueRef LLVMConstSIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1739 LLVMValueRef LLVMConstFPToUI(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1740 LLVMValueRef LLVMConstFPToSI(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1741 LLVMValueRef LLVMConstPtrToInt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1742 LLVMValueRef LLVMConstIntToPtr(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1743 LLVMValueRef LLVMConstBitCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1744 LLVMValueRef LLVMConstAddrSpaceCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1745 LLVMValueRef LLVMConstZExtOrBitCast(LLVMValueRef ConstantVal,
1746 LLVMTypeRef ToType);
1747 LLVMValueRef LLVMConstSExtOrBitCast(LLVMValueRef ConstantVal,
1748 LLVMTypeRef ToType);
1749 LLVMValueRef LLVMConstTruncOrBitCast(LLVMValueRef ConstantVal,
1750 LLVMTypeRef ToType);
1751 LLVMValueRef LLVMConstPointerCast(LLVMValueRef ConstantVal,
1752 LLVMTypeRef ToType);
1753 LLVMValueRef LLVMConstIntCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType,
1755 LLVMValueRef LLVMConstFPCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1756 LLVMValueRef LLVMConstSelect(LLVMValueRef ConstantCondition,
1757 LLVMValueRef ConstantIfTrue,
1758 LLVMValueRef ConstantIfFalse);
1759 LLVMValueRef LLVMConstExtractElement(LLVMValueRef VectorConstant,
1760 LLVMValueRef IndexConstant);
1761 LLVMValueRef LLVMConstInsertElement(LLVMValueRef VectorConstant,
1762 LLVMValueRef ElementValueConstant,
1763 LLVMValueRef IndexConstant);
1764 LLVMValueRef LLVMConstShuffleVector(LLVMValueRef VectorAConstant,
1765 LLVMValueRef VectorBConstant,
1766 LLVMValueRef MaskConstant);
1767 LLVMValueRef LLVMConstExtractValue(LLVMValueRef AggConstant, unsigned *IdxList,
1769 LLVMValueRef LLVMConstInsertValue(LLVMValueRef AggConstant,
1770 LLVMValueRef ElementValueConstant,
1771 unsigned *IdxList, unsigned NumIdx);
1772 LLVMValueRef LLVMConstInlineAsm(LLVMTypeRef Ty,
1773 const char *AsmString, const char *Constraints,
1774 LLVMBool HasSideEffects, LLVMBool IsAlignStack);
1775 LLVMValueRef LLVMBlockAddress(LLVMValueRef F, LLVMBasicBlockRef BB);
1782 * @defgroup LLVMCCoreValueConstantGlobals Global Values
1784 * This group contains functions that operate on global values. Functions in
1785 * this group relate to functions in the llvm::GlobalValue class tree.
1787 * @see llvm::GlobalValue
1792 LLVMModuleRef LLVMGetGlobalParent(LLVMValueRef Global);
1793 LLVMBool LLVMIsDeclaration(LLVMValueRef Global);
1794 LLVMLinkage LLVMGetLinkage(LLVMValueRef Global);
1795 void LLVMSetLinkage(LLVMValueRef Global, LLVMLinkage Linkage);
1796 const char *LLVMGetSection(LLVMValueRef Global);
1797 void LLVMSetSection(LLVMValueRef Global, const char *Section);
1798 LLVMVisibility LLVMGetVisibility(LLVMValueRef Global);
1799 void LLVMSetVisibility(LLVMValueRef Global, LLVMVisibility Viz);
1800 LLVMDLLStorageClass LLVMGetDLLStorageClass(LLVMValueRef Global);
1801 void LLVMSetDLLStorageClass(LLVMValueRef Global, LLVMDLLStorageClass Class);
1802 LLVMBool LLVMHasUnnamedAddr(LLVMValueRef Global);
1803 void LLVMSetUnnamedAddr(LLVMValueRef Global, LLVMBool HasUnnamedAddr);
1806 * @defgroup LLVMCCoreValueWithAlignment Values with alignment
1808 * Functions in this group only apply to values with alignment, i.e.
1809 * global variables, load and store instructions.
1813 * Obtain the preferred alignment of the value.
1814 * @see llvm::AllocaInst::getAlignment()
1815 * @see llvm::LoadInst::getAlignment()
1816 * @see llvm::StoreInst::getAlignment()
1817 * @see llvm::GlobalValue::getAlignment()
1819 unsigned LLVMGetAlignment(LLVMValueRef V);
1822 * Set the preferred alignment of the value.
1823 * @see llvm::AllocaInst::setAlignment()
1824 * @see llvm::LoadInst::setAlignment()
1825 * @see llvm::StoreInst::setAlignment()
1826 * @see llvm::GlobalValue::setAlignment()
1828 void LLVMSetAlignment(LLVMValueRef V, unsigned Bytes);
1835 * @defgroup LLVMCoreValueConstantGlobalVariable Global Variables
1837 * This group contains functions that operate on global variable values.
1839 * @see llvm::GlobalVariable
1843 LLVMValueRef LLVMAddGlobal(LLVMModuleRef M, LLVMTypeRef Ty, const char *Name);
1844 LLVMValueRef LLVMAddGlobalInAddressSpace(LLVMModuleRef M, LLVMTypeRef Ty,
1846 unsigned AddressSpace);
1847 LLVMValueRef LLVMGetNamedGlobal(LLVMModuleRef M, const char *Name);
1848 LLVMValueRef LLVMGetFirstGlobal(LLVMModuleRef M);
1849 LLVMValueRef LLVMGetLastGlobal(LLVMModuleRef M);
1850 LLVMValueRef LLVMGetNextGlobal(LLVMValueRef GlobalVar);
1851 LLVMValueRef LLVMGetPreviousGlobal(LLVMValueRef GlobalVar);
1852 void LLVMDeleteGlobal(LLVMValueRef GlobalVar);
1853 LLVMValueRef LLVMGetInitializer(LLVMValueRef GlobalVar);
1854 void LLVMSetInitializer(LLVMValueRef GlobalVar, LLVMValueRef ConstantVal);
1855 LLVMBool LLVMIsThreadLocal(LLVMValueRef GlobalVar);
1856 void LLVMSetThreadLocal(LLVMValueRef GlobalVar, LLVMBool IsThreadLocal);
1857 LLVMBool LLVMIsGlobalConstant(LLVMValueRef GlobalVar);
1858 void LLVMSetGlobalConstant(LLVMValueRef GlobalVar, LLVMBool IsConstant);
1859 LLVMThreadLocalMode LLVMGetThreadLocalMode(LLVMValueRef GlobalVar);
1860 void LLVMSetThreadLocalMode(LLVMValueRef GlobalVar, LLVMThreadLocalMode Mode);
1861 LLVMBool LLVMIsExternallyInitialized(LLVMValueRef GlobalVar);
1862 void LLVMSetExternallyInitialized(LLVMValueRef GlobalVar, LLVMBool IsExtInit);
1869 * @defgroup LLVMCoreValueConstantGlobalAlias Global Aliases
1871 * This group contains function that operate on global alias values.
1873 * @see llvm::GlobalAlias
1877 LLVMValueRef LLVMAddAlias(LLVMModuleRef M, LLVMTypeRef Ty, LLVMValueRef Aliasee,
1885 * @defgroup LLVMCCoreValueFunction Function values
1887 * Functions in this group operate on LLVMValueRef instances that
1888 * correspond to llvm::Function instances.
1890 * @see llvm::Function
1896 * Remove a function from its containing module and deletes it.
1898 * @see llvm::Function::eraseFromParent()
1900 void LLVMDeleteFunction(LLVMValueRef Fn);
1903 * Check whether the given function has a personality function.
1905 * @see llvm::Function::hasPersonalityFn()
1907 LLVMBool LLVMHasPersonalityFn(LLVMValueRef Fn);
1910 * Obtain the personality function attached to the function.
1912 * @see llvm::Function::getPersonalityFn()
1914 LLVMValueRef LLVMGetPersonalityFn(LLVMValueRef Fn);
1917 * Set the personality function attached to the function.
1919 * @see llvm::Function::setPersonalityFn()
1921 void LLVMSetPersonalityFn(LLVMValueRef Fn, LLVMValueRef PersonalityFn);
1924 * Obtain the ID number from a function instance.
1926 * @see llvm::Function::getIntrinsicID()
1928 unsigned LLVMGetIntrinsicID(LLVMValueRef Fn);
1931 * Obtain the calling function of a function.
1933 * The returned value corresponds to the LLVMCallConv enumeration.
1935 * @see llvm::Function::getCallingConv()
1937 unsigned LLVMGetFunctionCallConv(LLVMValueRef Fn);
1940 * Set the calling convention of a function.
1942 * @see llvm::Function::setCallingConv()
1944 * @param Fn Function to operate on
1945 * @param CC LLVMCallConv to set calling convention to
1947 void LLVMSetFunctionCallConv(LLVMValueRef Fn, unsigned CC);
1950 * Obtain the name of the garbage collector to use during code
1953 * @see llvm::Function::getGC()
1955 const char *LLVMGetGC(LLVMValueRef Fn);
1958 * Define the garbage collector to use during code generation.
1960 * @see llvm::Function::setGC()
1962 void LLVMSetGC(LLVMValueRef Fn, const char *Name);
1965 * Add an attribute to a function.
1967 * @see llvm::Function::addAttribute()
1969 void LLVMAddAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx,
1970 LLVMAttributeRef A);
1971 unsigned LLVMGetAttributeCountAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx);
1972 void LLVMGetAttributesAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx,
1973 LLVMAttributeRef *Attrs);
1974 LLVMAttributeRef LLVMGetEnumAttributeAtIndex(LLVMValueRef F,
1975 LLVMAttributeIndex Idx,
1977 LLVMAttributeRef LLVMGetStringAttributeAtIndex(LLVMValueRef F,
1978 LLVMAttributeIndex Idx,
1979 const char *K, unsigned KLen);
1980 void LLVMRemoveEnumAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx,
1982 void LLVMRemoveStringAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx,
1983 const char *K, unsigned KLen);
1986 * Add a target-dependent attribute to a function
1987 * @see llvm::AttrBuilder::addAttribute()
1989 void LLVMAddTargetDependentFunctionAttr(LLVMValueRef Fn, const char *A,
1993 * @defgroup LLVMCCoreValueFunctionParameters Function Parameters
1995 * Functions in this group relate to arguments/parameters on functions.
1997 * Functions in this group expect LLVMValueRef instances that correspond
1998 * to llvm::Function instances.
2004 * Obtain the number of parameters in a function.
2006 * @see llvm::Function::arg_size()
2008 unsigned LLVMCountParams(LLVMValueRef Fn);
2011 * Obtain the parameters in a function.
2013 * The takes a pointer to a pre-allocated array of LLVMValueRef that is
2014 * at least LLVMCountParams() long. This array will be filled with
2015 * LLVMValueRef instances which correspond to the parameters the
2016 * function receives. Each LLVMValueRef corresponds to a llvm::Argument
2019 * @see llvm::Function::arg_begin()
2021 void LLVMGetParams(LLVMValueRef Fn, LLVMValueRef *Params);
2024 * Obtain the parameter at the specified index.
2026 * Parameters are indexed from 0.
2028 * @see llvm::Function::arg_begin()
2030 LLVMValueRef LLVMGetParam(LLVMValueRef Fn, unsigned Index);
2033 * Obtain the function to which this argument belongs.
2035 * Unlike other functions in this group, this one takes an LLVMValueRef
2036 * that corresponds to a llvm::Attribute.
2038 * The returned LLVMValueRef is the llvm::Function to which this
2041 LLVMValueRef LLVMGetParamParent(LLVMValueRef Inst);
2044 * Obtain the first parameter to a function.
2046 * @see llvm::Function::arg_begin()
2048 LLVMValueRef LLVMGetFirstParam(LLVMValueRef Fn);
2051 * Obtain the last parameter to a function.
2053 * @see llvm::Function::arg_end()
2055 LLVMValueRef LLVMGetLastParam(LLVMValueRef Fn);
2058 * Obtain the next parameter to a function.
2060 * This takes an LLVMValueRef obtained from LLVMGetFirstParam() (which is
2061 * actually a wrapped iterator) and obtains the next parameter from the
2062 * underlying iterator.
2064 LLVMValueRef LLVMGetNextParam(LLVMValueRef Arg);
2067 * Obtain the previous parameter to a function.
2069 * This is the opposite of LLVMGetNextParam().
2071 LLVMValueRef LLVMGetPreviousParam(LLVMValueRef Arg);
2074 * Set the alignment for a function parameter.
2076 * @see llvm::Argument::addAttr()
2077 * @see llvm::AttrBuilder::addAlignmentAttr()
2079 void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned Align);
2098 * @defgroup LLVMCCoreValueMetadata Metadata
2104 * Obtain a MDString value from a context.
2106 * The returned instance corresponds to the llvm::MDString class.
2108 * The instance is specified by string data of a specified length. The
2109 * string content is copied, so the backing memory can be freed after
2110 * this function returns.
2112 LLVMValueRef LLVMMDStringInContext(LLVMContextRef C, const char *Str,
2116 * Obtain a MDString value from the global context.
2118 LLVMValueRef LLVMMDString(const char *Str, unsigned SLen);
2121 * Obtain a MDNode value from a context.
2123 * The returned value corresponds to the llvm::MDNode class.
2125 LLVMValueRef LLVMMDNodeInContext(LLVMContextRef C, LLVMValueRef *Vals,
2129 * Obtain a MDNode value from the global context.
2131 LLVMValueRef LLVMMDNode(LLVMValueRef *Vals, unsigned Count);
2134 * Obtain a Metadata as a Value.
2136 LLVMValueRef LLVMMetadataAsValue(LLVMContextRef C, LLVMMetadataRef MD);
2139 * Obtain a Value as a Metadata.
2141 LLVMMetadataRef LLVMValueAsMetadata(LLVMValueRef Val);
2144 * Obtain the underlying string from a MDString value.
2146 * @param V Instance to obtain string from.
2147 * @param Length Memory address which will hold length of returned string.
2148 * @return String data in MDString.
2150 const char *LLVMGetMDString(LLVMValueRef V, unsigned *Length);
2153 * Obtain the number of operands from an MDNode value.
2155 * @param V MDNode to get number of operands from.
2156 * @return Number of operands of the MDNode.
2158 unsigned LLVMGetMDNodeNumOperands(LLVMValueRef V);
2161 * Obtain the given MDNode's operands.
2163 * The passed LLVMValueRef pointer should point to enough memory to hold all of
2164 * the operands of the given MDNode (see LLVMGetMDNodeNumOperands) as
2165 * LLVMValueRefs. This memory will be populated with the LLVMValueRefs of the
2166 * MDNode's operands.
2168 * @param V MDNode to get the operands from.
2169 * @param Dest Destination array for operands.
2171 void LLVMGetMDNodeOperands(LLVMValueRef V, LLVMValueRef *Dest);
2178 * @defgroup LLVMCCoreValueBasicBlock Basic Block
2180 * A basic block represents a single entry single exit section of code.
2181 * Basic blocks contain a list of instructions which form the body of
2184 * Basic blocks belong to functions. They have the type of label.
2186 * Basic blocks are themselves values. However, the C API models them as
2187 * LLVMBasicBlockRef.
2189 * @see llvm::BasicBlock
2195 * Convert a basic block instance to a value type.
2197 LLVMValueRef LLVMBasicBlockAsValue(LLVMBasicBlockRef BB);
2200 * Determine whether an LLVMValueRef is itself a basic block.
2202 LLVMBool LLVMValueIsBasicBlock(LLVMValueRef Val);
2205 * Convert an LLVMValueRef to an LLVMBasicBlockRef instance.
2207 LLVMBasicBlockRef LLVMValueAsBasicBlock(LLVMValueRef Val);
2210 * Obtain the string name of a basic block.
2212 const char *LLVMGetBasicBlockName(LLVMBasicBlockRef BB);
2215 * Obtain the function to which a basic block belongs.
2217 * @see llvm::BasicBlock::getParent()
2219 LLVMValueRef LLVMGetBasicBlockParent(LLVMBasicBlockRef BB);
2222 * Obtain the terminator instruction for a basic block.
2224 * If the basic block does not have a terminator (it is not well-formed
2225 * if it doesn't), then NULL is returned.
2227 * The returned LLVMValueRef corresponds to a llvm::TerminatorInst.
2229 * @see llvm::BasicBlock::getTerminator()
2231 LLVMValueRef LLVMGetBasicBlockTerminator(LLVMBasicBlockRef BB);
2234 * Obtain the number of basic blocks in a function.
2236 * @param Fn Function value to operate on.
2238 unsigned LLVMCountBasicBlocks(LLVMValueRef Fn);
2241 * Obtain all of the basic blocks in a function.
2243 * This operates on a function value. The BasicBlocks parameter is a
2244 * pointer to a pre-allocated array of LLVMBasicBlockRef of at least
2245 * LLVMCountBasicBlocks() in length. This array is populated with
2246 * LLVMBasicBlockRef instances.
2248 void LLVMGetBasicBlocks(LLVMValueRef Fn, LLVMBasicBlockRef *BasicBlocks);
2251 * Obtain the first basic block in a function.
2253 * The returned basic block can be used as an iterator. You will likely
2254 * eventually call into LLVMGetNextBasicBlock() with it.
2256 * @see llvm::Function::begin()
2258 LLVMBasicBlockRef LLVMGetFirstBasicBlock(LLVMValueRef Fn);
2261 * Obtain the last basic block in a function.
2263 * @see llvm::Function::end()
2265 LLVMBasicBlockRef LLVMGetLastBasicBlock(LLVMValueRef Fn);
2268 * Advance a basic block iterator.
2270 LLVMBasicBlockRef LLVMGetNextBasicBlock(LLVMBasicBlockRef BB);
2273 * Go backwards in a basic block iterator.
2275 LLVMBasicBlockRef LLVMGetPreviousBasicBlock(LLVMBasicBlockRef BB);
2278 * Obtain the basic block that corresponds to the entry point of a
2281 * @see llvm::Function::getEntryBlock()
2283 LLVMBasicBlockRef LLVMGetEntryBasicBlock(LLVMValueRef Fn);
2286 * Append a basic block to the end of a function.
2288 * @see llvm::BasicBlock::Create()
2290 LLVMBasicBlockRef LLVMAppendBasicBlockInContext(LLVMContextRef C,
2295 * Append a basic block to the end of a function using the global
2298 * @see llvm::BasicBlock::Create()
2300 LLVMBasicBlockRef LLVMAppendBasicBlock(LLVMValueRef Fn, const char *Name);
2303 * Insert a basic block in a function before another basic block.
2305 * The function to add to is determined by the function of the
2306 * passed basic block.
2308 * @see llvm::BasicBlock::Create()
2310 LLVMBasicBlockRef LLVMInsertBasicBlockInContext(LLVMContextRef C,
2311 LLVMBasicBlockRef BB,
2315 * Insert a basic block in a function using the global context.
2317 * @see llvm::BasicBlock::Create()
2319 LLVMBasicBlockRef LLVMInsertBasicBlock(LLVMBasicBlockRef InsertBeforeBB,
2323 * Remove a basic block from a function and delete it.
2325 * This deletes the basic block from its containing function and deletes
2326 * the basic block itself.
2328 * @see llvm::BasicBlock::eraseFromParent()
2330 void LLVMDeleteBasicBlock(LLVMBasicBlockRef BB);
2333 * Remove a basic block from a function.
2335 * This deletes the basic block from its containing function but keep
2336 * the basic block alive.
2338 * @see llvm::BasicBlock::removeFromParent()
2340 void LLVMRemoveBasicBlockFromParent(LLVMBasicBlockRef BB);
2343 * Move a basic block to before another one.
2345 * @see llvm::BasicBlock::moveBefore()
2347 void LLVMMoveBasicBlockBefore(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos);
2350 * Move a basic block to after another one.
2352 * @see llvm::BasicBlock::moveAfter()
2354 void LLVMMoveBasicBlockAfter(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos);
2357 * Obtain the first instruction in a basic block.
2359 * The returned LLVMValueRef corresponds to a llvm::Instruction
2362 LLVMValueRef LLVMGetFirstInstruction(LLVMBasicBlockRef BB);
2365 * Obtain the last instruction in a basic block.
2367 * The returned LLVMValueRef corresponds to an LLVM:Instruction.
2369 LLVMValueRef LLVMGetLastInstruction(LLVMBasicBlockRef BB);
2376 * @defgroup LLVMCCoreValueInstruction Instructions
2378 * Functions in this group relate to the inspection and manipulation of
2379 * individual instructions.
2381 * In the C++ API, an instruction is modeled by llvm::Instruction. This
2382 * class has a large number of descendents. llvm::Instruction is a
2383 * llvm::Value and in the C API, instructions are modeled by
2386 * This group also contains sub-groups which operate on specific
2387 * llvm::Instruction types, e.g. llvm::CallInst.
2393 * Determine whether an instruction has any metadata attached.
2395 int LLVMHasMetadata(LLVMValueRef Val);
2398 * Return metadata associated with an instruction value.
2400 LLVMValueRef LLVMGetMetadata(LLVMValueRef Val, unsigned KindID);
2403 * Set metadata associated with an instruction value.
2405 void LLVMSetMetadata(LLVMValueRef Val, unsigned KindID, LLVMValueRef Node);
2408 * Obtain the basic block to which an instruction belongs.
2410 * @see llvm::Instruction::getParent()
2412 LLVMBasicBlockRef LLVMGetInstructionParent(LLVMValueRef Inst);
2415 * Obtain the instruction that occurs after the one specified.
2417 * The next instruction will be from the same basic block.
2419 * If this is the last instruction in a basic block, NULL will be
2422 LLVMValueRef LLVMGetNextInstruction(LLVMValueRef Inst);
2425 * Obtain the instruction that occurred before this one.
2427 * If the instruction is the first instruction in a basic block, NULL
2430 LLVMValueRef LLVMGetPreviousInstruction(LLVMValueRef Inst);
2433 * Remove and delete an instruction.
2435 * The instruction specified is removed from its containing building
2436 * block but is kept alive.
2438 * @see llvm::Instruction::removeFromParent()
2440 void LLVMInstructionRemoveFromParent(LLVMValueRef Inst);
2443 * Remove and delete an instruction.
2445 * The instruction specified is removed from its containing building
2446 * block and then deleted.
2448 * @see llvm::Instruction::eraseFromParent()
2450 void LLVMInstructionEraseFromParent(LLVMValueRef Inst);
2453 * Obtain the code opcode for an individual instruction.
2455 * @see llvm::Instruction::getOpCode()
2457 LLVMOpcode LLVMGetInstructionOpcode(LLVMValueRef Inst);
2460 * Obtain the predicate of an instruction.
2462 * This is only valid for instructions that correspond to llvm::ICmpInst
2463 * or llvm::ConstantExpr whose opcode is llvm::Instruction::ICmp.
2465 * @see llvm::ICmpInst::getPredicate()
2467 LLVMIntPredicate LLVMGetICmpPredicate(LLVMValueRef Inst);
2470 * Obtain the float predicate of an instruction.
2472 * This is only valid for instructions that correspond to llvm::FCmpInst
2473 * or llvm::ConstantExpr whose opcode is llvm::Instruction::FCmp.
2475 * @see llvm::FCmpInst::getPredicate()
2477 LLVMRealPredicate LLVMGetFCmpPredicate(LLVMValueRef Inst);
2480 * Create a copy of 'this' instruction that is identical in all ways
2481 * except the following:
2482 * * The instruction has no parent
2483 * * The instruction has no name
2485 * @see llvm::Instruction::clone()
2487 LLVMValueRef LLVMInstructionClone(LLVMValueRef Inst);
2490 * @defgroup LLVMCCoreValueInstructionCall Call Sites and Invocations
2492 * Functions in this group apply to instructions that refer to call
2493 * sites and invocations. These correspond to C++ types in the
2494 * llvm::CallInst class tree.
2500 * Obtain the argument count for a call instruction.
2502 * This expects an LLVMValueRef that corresponds to a llvm::CallInst or
2505 * @see llvm::CallInst::getNumArgOperands()
2506 * @see llvm::InvokeInst::getNumArgOperands()
2508 unsigned LLVMGetNumArgOperands(LLVMValueRef Instr);
2511 * Set the calling convention for a call instruction.
2513 * This expects an LLVMValueRef that corresponds to a llvm::CallInst or
2516 * @see llvm::CallInst::setCallingConv()
2517 * @see llvm::InvokeInst::setCallingConv()
2519 void LLVMSetInstructionCallConv(LLVMValueRef Instr, unsigned CC);
2522 * Obtain the calling convention for a call instruction.
2524 * This is the opposite of LLVMSetInstructionCallConv(). Reads its
2527 * @see LLVMSetInstructionCallConv()
2529 unsigned LLVMGetInstructionCallConv(LLVMValueRef Instr);
2531 void LLVMSetInstrParamAlignment(LLVMValueRef Instr, unsigned index,
2534 void LLVMAddCallSiteAttribute(LLVMValueRef C, LLVMAttributeIndex Idx,
2535 LLVMAttributeRef A);
2536 unsigned LLVMGetCallSiteAttributeCount(LLVMValueRef C, LLVMAttributeIndex Idx);
2537 void LLVMGetCallSiteAttributes(LLVMValueRef C, LLVMAttributeIndex Idx,
2538 LLVMAttributeRef *Attrs);
2539 LLVMAttributeRef LLVMGetCallSiteEnumAttribute(LLVMValueRef C,
2540 LLVMAttributeIndex Idx,
2542 LLVMAttributeRef LLVMGetCallSiteStringAttribute(LLVMValueRef C,
2543 LLVMAttributeIndex Idx,
2544 const char *K, unsigned KLen);
2545 void LLVMRemoveCallSiteEnumAttribute(LLVMValueRef C, LLVMAttributeIndex Idx,
2547 void LLVMRemoveCallSiteStringAttribute(LLVMValueRef C, LLVMAttributeIndex Idx,
2548 const char *K, unsigned KLen);
2551 * Obtain the pointer to the function invoked by this instruction.
2553 * This expects an LLVMValueRef that corresponds to a llvm::CallInst or
2556 * @see llvm::CallInst::getCalledValue()
2557 * @see llvm::InvokeInst::getCalledValue()
2559 LLVMValueRef LLVMGetCalledValue(LLVMValueRef Instr);
2562 * Obtain whether a call instruction is a tail call.
2564 * This only works on llvm::CallInst instructions.
2566 * @see llvm::CallInst::isTailCall()
2568 LLVMBool LLVMIsTailCall(LLVMValueRef CallInst);
2571 * Set whether a call instruction is a tail call.
2573 * This only works on llvm::CallInst instructions.
2575 * @see llvm::CallInst::setTailCall()
2577 void LLVMSetTailCall(LLVMValueRef CallInst, LLVMBool IsTailCall);
2580 * Return the normal destination basic block.
2582 * This only works on llvm::InvokeInst instructions.
2584 * @see llvm::InvokeInst::getNormalDest()
2586 LLVMBasicBlockRef LLVMGetNormalDest(LLVMValueRef InvokeInst);
2589 * Return the unwind destination basic block.
2591 * This only works on llvm::InvokeInst instructions.
2593 * @see llvm::InvokeInst::getUnwindDest()
2595 LLVMBasicBlockRef LLVMGetUnwindDest(LLVMValueRef InvokeInst);
2598 * Set the normal destination basic block.
2600 * This only works on llvm::InvokeInst instructions.
2602 * @see llvm::InvokeInst::setNormalDest()
2604 void LLVMSetNormalDest(LLVMValueRef InvokeInst, LLVMBasicBlockRef B);
2607 * Set the unwind destination basic block.
2609 * This only works on llvm::InvokeInst instructions.
2611 * @see llvm::InvokeInst::setUnwindDest()
2613 void LLVMSetUnwindDest(LLVMValueRef InvokeInst, LLVMBasicBlockRef B);
2620 * @defgroup LLVMCCoreValueInstructionTerminator Terminators
2622 * Functions in this group only apply to instructions that map to
2623 * llvm::TerminatorInst instances.
2629 * Return the number of successors that this terminator has.
2631 * @see llvm::TerminatorInst::getNumSuccessors
2633 unsigned LLVMGetNumSuccessors(LLVMValueRef Term);
2636 * Return the specified successor.
2638 * @see llvm::TerminatorInst::getSuccessor
2640 LLVMBasicBlockRef LLVMGetSuccessor(LLVMValueRef Term, unsigned i);
2643 * Update the specified successor to point at the provided block.
2645 * @see llvm::TerminatorInst::setSuccessor
2647 void LLVMSetSuccessor(LLVMValueRef Term, unsigned i, LLVMBasicBlockRef block);
2650 * Return if a branch is conditional.
2652 * This only works on llvm::BranchInst instructions.
2654 * @see llvm::BranchInst::isConditional
2656 LLVMBool LLVMIsConditional(LLVMValueRef Branch);
2659 * Return the condition of a branch instruction.
2661 * This only works on llvm::BranchInst instructions.
2663 * @see llvm::BranchInst::getCondition
2665 LLVMValueRef LLVMGetCondition(LLVMValueRef Branch);
2668 * Set the condition of a branch instruction.
2670 * This only works on llvm::BranchInst instructions.
2672 * @see llvm::BranchInst::setCondition
2674 void LLVMSetCondition(LLVMValueRef Branch, LLVMValueRef Cond);
2677 * Obtain the default destination basic block of a switch instruction.
2679 * This only works on llvm::SwitchInst instructions.
2681 * @see llvm::SwitchInst::getDefaultDest()
2683 LLVMBasicBlockRef LLVMGetSwitchDefaultDest(LLVMValueRef SwitchInstr);
2690 * @defgroup LLVMCCoreValueInstructionAlloca Allocas
2692 * Functions in this group only apply to instructions that map to
2693 * llvm::AllocaInst instances.
2699 * Obtain the type that is being allocated by the alloca instruction.
2701 LLVMTypeRef LLVMGetAllocatedType(LLVMValueRef Alloca);
2708 * @defgroup LLVMCCoreValueInstructionGetElementPointer GEPs
2710 * Functions in this group only apply to instructions that map to
2711 * llvm::GetElementPtrInst instances.
2717 * Check whether the given GEP instruction is inbounds.
2719 LLVMBool LLVMIsInBounds(LLVMValueRef GEP);
2722 * Set the given GEP instruction to be inbounds or not.
2724 void LLVMSetIsInBounds(LLVMValueRef GEP, LLVMBool InBounds);
2731 * @defgroup LLVMCCoreValueInstructionPHINode PHI Nodes
2733 * Functions in this group only apply to instructions that map to
2734 * llvm::PHINode instances.
2740 * Add an incoming value to the end of a PHI list.
2742 void LLVMAddIncoming(LLVMValueRef PhiNode, LLVMValueRef *IncomingValues,
2743 LLVMBasicBlockRef *IncomingBlocks, unsigned Count);
2746 * Obtain the number of incoming basic blocks to a PHI node.
2748 unsigned LLVMCountIncoming(LLVMValueRef PhiNode);
2751 * Obtain an incoming value to a PHI node as an LLVMValueRef.
2753 LLVMValueRef LLVMGetIncomingValue(LLVMValueRef PhiNode, unsigned Index);
2756 * Obtain an incoming value to a PHI node as an LLVMBasicBlockRef.
2758 LLVMBasicBlockRef LLVMGetIncomingBlock(LLVMValueRef PhiNode, unsigned Index);
2765 * @defgroup LLVMCCoreValueInstructionExtractValue ExtractValue
2766 * @defgroup LLVMCCoreValueInstructionInsertValue InsertValue
2768 * Functions in this group only apply to instructions that map to
2769 * llvm::ExtractValue and llvm::InsertValue instances.
2775 * Obtain the number of indices.
2776 * NB: This also works on GEP.
2778 unsigned LLVMGetNumIndices(LLVMValueRef Inst);
2781 * Obtain the indices as an array.
2783 const unsigned *LLVMGetIndices(LLVMValueRef Inst);
2798 * @defgroup LLVMCCoreInstructionBuilder Instruction Builders
2800 * An instruction builder represents a point within a basic block and is
2801 * the exclusive means of building instructions using the C interface.
2806 LLVMBuilderRef LLVMCreateBuilderInContext(LLVMContextRef C);
2807 LLVMBuilderRef LLVMCreateBuilder(void);
2808 void LLVMPositionBuilder(LLVMBuilderRef Builder, LLVMBasicBlockRef Block,
2809 LLVMValueRef Instr);
2810 void LLVMPositionBuilderBefore(LLVMBuilderRef Builder, LLVMValueRef Instr);
2811 void LLVMPositionBuilderAtEnd(LLVMBuilderRef Builder, LLVMBasicBlockRef Block);
2812 LLVMBasicBlockRef LLVMGetInsertBlock(LLVMBuilderRef Builder);
2813 void LLVMClearInsertionPosition(LLVMBuilderRef Builder);
2814 void LLVMInsertIntoBuilder(LLVMBuilderRef Builder, LLVMValueRef Instr);
2815 void LLVMInsertIntoBuilderWithName(LLVMBuilderRef Builder, LLVMValueRef Instr,
2817 void LLVMDisposeBuilder(LLVMBuilderRef Builder);
2820 void LLVMSetCurrentDebugLocation(LLVMBuilderRef Builder, LLVMValueRef L);
2821 LLVMValueRef LLVMGetCurrentDebugLocation(LLVMBuilderRef Builder);
2822 void LLVMSetInstDebugLocation(LLVMBuilderRef Builder, LLVMValueRef Inst);
2825 LLVMValueRef LLVMBuildRetVoid(LLVMBuilderRef);
2826 LLVMValueRef LLVMBuildRet(LLVMBuilderRef, LLVMValueRef V);
2827 LLVMValueRef LLVMBuildAggregateRet(LLVMBuilderRef, LLVMValueRef *RetVals,
2829 LLVMValueRef LLVMBuildBr(LLVMBuilderRef, LLVMBasicBlockRef Dest);
2830 LLVMValueRef LLVMBuildCondBr(LLVMBuilderRef, LLVMValueRef If,
2831 LLVMBasicBlockRef Then, LLVMBasicBlockRef Else);
2832 LLVMValueRef LLVMBuildSwitch(LLVMBuilderRef, LLVMValueRef V,
2833 LLVMBasicBlockRef Else, unsigned NumCases);
2834 LLVMValueRef LLVMBuildIndirectBr(LLVMBuilderRef B, LLVMValueRef Addr,
2836 LLVMValueRef LLVMBuildInvoke(LLVMBuilderRef, LLVMValueRef Fn,
2837 LLVMValueRef *Args, unsigned NumArgs,
2838 LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch,
2840 LLVMValueRef LLVMBuildLandingPad(LLVMBuilderRef B, LLVMTypeRef Ty,
2841 LLVMValueRef PersFn, unsigned NumClauses,
2843 LLVMValueRef LLVMBuildResume(LLVMBuilderRef B, LLVMValueRef Exn);
2844 LLVMValueRef LLVMBuildUnreachable(LLVMBuilderRef);
2846 /* Add a case to the switch instruction */
2847 void LLVMAddCase(LLVMValueRef Switch, LLVMValueRef OnVal,
2848 LLVMBasicBlockRef Dest);
2850 /* Add a destination to the indirectbr instruction */
2851 void LLVMAddDestination(LLVMValueRef IndirectBr, LLVMBasicBlockRef Dest);
2853 /* Get the number of clauses on the landingpad instruction */
2854 unsigned LLVMGetNumClauses(LLVMValueRef LandingPad);
2856 /* Get the value of the clause at idnex Idx on the landingpad instruction */
2857 LLVMValueRef LLVMGetClause(LLVMValueRef LandingPad, unsigned Idx);
2859 /* Add a catch or filter clause to the landingpad instruction */
2860 void LLVMAddClause(LLVMValueRef LandingPad, LLVMValueRef ClauseVal);
2862 /* Get the 'cleanup' flag in the landingpad instruction */
2863 LLVMBool LLVMIsCleanup(LLVMValueRef LandingPad);
2865 /* Set the 'cleanup' flag in the landingpad instruction */
2866 void LLVMSetCleanup(LLVMValueRef LandingPad, LLVMBool Val);
2869 LLVMValueRef LLVMBuildAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2871 LLVMValueRef LLVMBuildNSWAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2873 LLVMValueRef LLVMBuildNUWAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2875 LLVMValueRef LLVMBuildFAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2877 LLVMValueRef LLVMBuildSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2879 LLVMValueRef LLVMBuildNSWSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2881 LLVMValueRef LLVMBuildNUWSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2883 LLVMValueRef LLVMBuildFSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2885 LLVMValueRef LLVMBuildMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2887 LLVMValueRef LLVMBuildNSWMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2889 LLVMValueRef LLVMBuildNUWMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2891 LLVMValueRef LLVMBuildFMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2893 LLVMValueRef LLVMBuildUDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2895 LLVMValueRef LLVMBuildExactUDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2897 LLVMValueRef LLVMBuildSDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2899 LLVMValueRef LLVMBuildExactSDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2901 LLVMValueRef LLVMBuildFDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2903 LLVMValueRef LLVMBuildURem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2905 LLVMValueRef LLVMBuildSRem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2907 LLVMValueRef LLVMBuildFRem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2909 LLVMValueRef LLVMBuildShl(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2911 LLVMValueRef LLVMBuildLShr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2913 LLVMValueRef LLVMBuildAShr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2915 LLVMValueRef LLVMBuildAnd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2917 LLVMValueRef LLVMBuildOr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2919 LLVMValueRef LLVMBuildXor(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2921 LLVMValueRef LLVMBuildBinOp(LLVMBuilderRef B, LLVMOpcode Op,
2922 LLVMValueRef LHS, LLVMValueRef RHS,
2924 LLVMValueRef LLVMBuildNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name);
2925 LLVMValueRef LLVMBuildNSWNeg(LLVMBuilderRef B, LLVMValueRef V,
2927 LLVMValueRef LLVMBuildNUWNeg(LLVMBuilderRef B, LLVMValueRef V,
2929 LLVMValueRef LLVMBuildFNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name);
2930 LLVMValueRef LLVMBuildNot(LLVMBuilderRef, LLVMValueRef V, const char *Name);
2933 LLVMValueRef LLVMBuildMalloc(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
2934 LLVMValueRef LLVMBuildArrayMalloc(LLVMBuilderRef, LLVMTypeRef Ty,
2935 LLVMValueRef Val, const char *Name);
2936 LLVMValueRef LLVMBuildAlloca(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
2937 LLVMValueRef LLVMBuildArrayAlloca(LLVMBuilderRef, LLVMTypeRef Ty,
2938 LLVMValueRef Val, const char *Name);
2939 LLVMValueRef LLVMBuildFree(LLVMBuilderRef, LLVMValueRef PointerVal);
2940 LLVMValueRef LLVMBuildLoad(LLVMBuilderRef, LLVMValueRef PointerVal,
2942 LLVMValueRef LLVMBuildStore(LLVMBuilderRef, LLVMValueRef Val, LLVMValueRef Ptr);
2943 LLVMValueRef LLVMBuildGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
2944 LLVMValueRef *Indices, unsigned NumIndices,
2946 LLVMValueRef LLVMBuildInBoundsGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
2947 LLVMValueRef *Indices, unsigned NumIndices,
2949 LLVMValueRef LLVMBuildStructGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
2950 unsigned Idx, const char *Name);
2951 LLVMValueRef LLVMBuildGlobalString(LLVMBuilderRef B, const char *Str,
2953 LLVMValueRef LLVMBuildGlobalStringPtr(LLVMBuilderRef B, const char *Str,
2955 LLVMBool LLVMGetVolatile(LLVMValueRef MemoryAccessInst);
2956 void LLVMSetVolatile(LLVMValueRef MemoryAccessInst, LLVMBool IsVolatile);
2957 LLVMAtomicOrdering LLVMGetOrdering(LLVMValueRef MemoryAccessInst);
2958 void LLVMSetOrdering(LLVMValueRef MemoryAccessInst, LLVMAtomicOrdering Ordering);
2961 LLVMValueRef LLVMBuildTrunc(LLVMBuilderRef, LLVMValueRef Val,
2962 LLVMTypeRef DestTy, const char *Name);
2963 LLVMValueRef LLVMBuildZExt(LLVMBuilderRef, LLVMValueRef Val,
2964 LLVMTypeRef DestTy, const char *Name);
2965 LLVMValueRef LLVMBuildSExt(LLVMBuilderRef, LLVMValueRef Val,
2966 LLVMTypeRef DestTy, const char *Name);
2967 LLVMValueRef LLVMBuildFPToUI(LLVMBuilderRef, LLVMValueRef Val,
2968 LLVMTypeRef DestTy, const char *Name);
2969 LLVMValueRef LLVMBuildFPToSI(LLVMBuilderRef, LLVMValueRef Val,
2970 LLVMTypeRef DestTy, const char *Name);
2971 LLVMValueRef LLVMBuildUIToFP(LLVMBuilderRef, LLVMValueRef Val,
2972 LLVMTypeRef DestTy, const char *Name);
2973 LLVMValueRef LLVMBuildSIToFP(LLVMBuilderRef, LLVMValueRef Val,
2974 LLVMTypeRef DestTy, const char *Name);
2975 LLVMValueRef LLVMBuildFPTrunc(LLVMBuilderRef, LLVMValueRef Val,
2976 LLVMTypeRef DestTy, const char *Name);
2977 LLVMValueRef LLVMBuildFPExt(LLVMBuilderRef, LLVMValueRef Val,
2978 LLVMTypeRef DestTy, const char *Name);
2979 LLVMValueRef LLVMBuildPtrToInt(LLVMBuilderRef, LLVMValueRef Val,
2980 LLVMTypeRef DestTy, const char *Name);
2981 LLVMValueRef LLVMBuildIntToPtr(LLVMBuilderRef, LLVMValueRef Val,
2982 LLVMTypeRef DestTy, const char *Name);
2983 LLVMValueRef LLVMBuildBitCast(LLVMBuilderRef, LLVMValueRef Val,
2984 LLVMTypeRef DestTy, const char *Name);
2985 LLVMValueRef LLVMBuildAddrSpaceCast(LLVMBuilderRef, LLVMValueRef Val,
2986 LLVMTypeRef DestTy, const char *Name);
2987 LLVMValueRef LLVMBuildZExtOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
2988 LLVMTypeRef DestTy, const char *Name);
2989 LLVMValueRef LLVMBuildSExtOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
2990 LLVMTypeRef DestTy, const char *Name);
2991 LLVMValueRef LLVMBuildTruncOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
2992 LLVMTypeRef DestTy, const char *Name);
2993 LLVMValueRef LLVMBuildCast(LLVMBuilderRef B, LLVMOpcode Op, LLVMValueRef Val,
2994 LLVMTypeRef DestTy, const char *Name);
2995 LLVMValueRef LLVMBuildPointerCast(LLVMBuilderRef, LLVMValueRef Val,
2996 LLVMTypeRef DestTy, const char *Name);
2997 LLVMValueRef LLVMBuildIntCast(LLVMBuilderRef, LLVMValueRef Val, /*Signed cast!*/
2998 LLVMTypeRef DestTy, const char *Name);
2999 LLVMValueRef LLVMBuildFPCast(LLVMBuilderRef, LLVMValueRef Val,
3000 LLVMTypeRef DestTy, const char *Name);
3003 LLVMValueRef LLVMBuildICmp(LLVMBuilderRef, LLVMIntPredicate Op,
3004 LLVMValueRef LHS, LLVMValueRef RHS,
3006 LLVMValueRef LLVMBuildFCmp(LLVMBuilderRef, LLVMRealPredicate Op,
3007 LLVMValueRef LHS, LLVMValueRef RHS,
3010 /* Miscellaneous instructions */
3011 LLVMValueRef LLVMBuildPhi(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
3012 LLVMValueRef LLVMBuildCall(LLVMBuilderRef, LLVMValueRef Fn,
3013 LLVMValueRef *Args, unsigned NumArgs,
3015 LLVMValueRef LLVMBuildSelect(LLVMBuilderRef, LLVMValueRef If,
3016 LLVMValueRef Then, LLVMValueRef Else,
3018 LLVMValueRef LLVMBuildVAArg(LLVMBuilderRef, LLVMValueRef List, LLVMTypeRef Ty,
3020 LLVMValueRef LLVMBuildExtractElement(LLVMBuilderRef, LLVMValueRef VecVal,
3021 LLVMValueRef Index, const char *Name);
3022 LLVMValueRef LLVMBuildInsertElement(LLVMBuilderRef, LLVMValueRef VecVal,
3023 LLVMValueRef EltVal, LLVMValueRef Index,
3025 LLVMValueRef LLVMBuildShuffleVector(LLVMBuilderRef, LLVMValueRef V1,
3026 LLVMValueRef V2, LLVMValueRef Mask,
3028 LLVMValueRef LLVMBuildExtractValue(LLVMBuilderRef, LLVMValueRef AggVal,
3029 unsigned Index, const char *Name);
3030 LLVMValueRef LLVMBuildInsertValue(LLVMBuilderRef, LLVMValueRef AggVal,
3031 LLVMValueRef EltVal, unsigned Index,
3034 LLVMValueRef LLVMBuildIsNull(LLVMBuilderRef, LLVMValueRef Val,
3036 LLVMValueRef LLVMBuildIsNotNull(LLVMBuilderRef, LLVMValueRef Val,
3038 LLVMValueRef LLVMBuildPtrDiff(LLVMBuilderRef, LLVMValueRef LHS,
3039 LLVMValueRef RHS, const char *Name);
3040 LLVMValueRef LLVMBuildFence(LLVMBuilderRef B, LLVMAtomicOrdering ordering,
3041 LLVMBool singleThread, const char *Name);
3042 LLVMValueRef LLVMBuildAtomicRMW(LLVMBuilderRef B, LLVMAtomicRMWBinOp op,
3043 LLVMValueRef PTR, LLVMValueRef Val,
3044 LLVMAtomicOrdering ordering,
3045 LLVMBool singleThread);
3046 LLVMValueRef LLVMBuildAtomicCmpXchg(LLVMBuilderRef B, LLVMValueRef Ptr,
3047 LLVMValueRef Cmp, LLVMValueRef New,
3048 LLVMAtomicOrdering SuccessOrdering,
3049 LLVMAtomicOrdering FailureOrdering,
3050 LLVMBool SingleThread);
3052 LLVMBool LLVMIsAtomicSingleThread(LLVMValueRef AtomicInst);
3053 void LLVMSetAtomicSingleThread(LLVMValueRef AtomicInst, LLVMBool SingleThread);
3055 LLVMAtomicOrdering LLVMGetCmpXchgSuccessOrdering(LLVMValueRef CmpXchgInst);
3056 void LLVMSetCmpXchgSuccessOrdering(LLVMValueRef CmpXchgInst,
3057 LLVMAtomicOrdering Ordering);
3058 LLVMAtomicOrdering LLVMGetCmpXchgFailureOrdering(LLVMValueRef CmpXchgInst);
3059 void LLVMSetCmpXchgFailureOrdering(LLVMValueRef CmpXchgInst,
3060 LLVMAtomicOrdering Ordering);
3067 * @defgroup LLVMCCoreModuleProvider Module Providers
3073 * Changes the type of M so it can be passed to FunctionPassManagers and the
3074 * JIT. They take ModuleProviders for historical reasons.
3076 LLVMModuleProviderRef
3077 LLVMCreateModuleProviderForExistingModule(LLVMModuleRef M);
3080 * Destroys the module M.
3082 void LLVMDisposeModuleProvider(LLVMModuleProviderRef M);
3089 * @defgroup LLVMCCoreMemoryBuffers Memory Buffers
3094 LLVMBool LLVMCreateMemoryBufferWithContentsOfFile(const char *Path,
3095 LLVMMemoryBufferRef *OutMemBuf,
3097 LLVMBool LLVMCreateMemoryBufferWithSTDIN(LLVMMemoryBufferRef *OutMemBuf,
3099 LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRange(const char *InputData,
3100 size_t InputDataLength,
3101 const char *BufferName,
3102 LLVMBool RequiresNullTerminator);
3103 LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRangeCopy(const char *InputData,
3104 size_t InputDataLength,
3105 const char *BufferName);
3106 const char *LLVMGetBufferStart(LLVMMemoryBufferRef MemBuf);
3107 size_t LLVMGetBufferSize(LLVMMemoryBufferRef MemBuf);
3108 void LLVMDisposeMemoryBuffer(LLVMMemoryBufferRef MemBuf);
3115 * @defgroup LLVMCCorePassRegistry Pass Registry
3120 /** Return the global pass registry, for use with initialization functions.
3121 @see llvm::PassRegistry::getPassRegistry */
3122 LLVMPassRegistryRef LLVMGetGlobalPassRegistry(void);
3129 * @defgroup LLVMCCorePassManagers Pass Managers
3134 /** Constructs a new whole-module pass pipeline. This type of pipeline is
3135 suitable for link-time optimization and whole-module transformations.
3136 @see llvm::PassManager::PassManager */
3137 LLVMPassManagerRef LLVMCreatePassManager(void);
3139 /** Constructs a new function-by-function pass pipeline over the module
3140 provider. It does not take ownership of the module provider. This type of
3141 pipeline is suitable for code generation and JIT compilation tasks.
3142 @see llvm::FunctionPassManager::FunctionPassManager */
3143 LLVMPassManagerRef LLVMCreateFunctionPassManagerForModule(LLVMModuleRef M);
3145 /** Deprecated: Use LLVMCreateFunctionPassManagerForModule instead. */
3146 LLVMPassManagerRef LLVMCreateFunctionPassManager(LLVMModuleProviderRef MP);
3148 /** Initializes, executes on the provided module, and finalizes all of the
3149 passes scheduled in the pass manager. Returns 1 if any of the passes
3150 modified the module, 0 otherwise.
3151 @see llvm::PassManager::run(Module&) */
3152 LLVMBool LLVMRunPassManager(LLVMPassManagerRef PM, LLVMModuleRef M);
3154 /** Initializes all of the function passes scheduled in the function pass
3155 manager. Returns 1 if any of the passes modified the module, 0 otherwise.
3156 @see llvm::FunctionPassManager::doInitialization */
3157 LLVMBool LLVMInitializeFunctionPassManager(LLVMPassManagerRef FPM);
3159 /** Executes all of the function passes scheduled in the function pass manager
3160 on the provided function. Returns 1 if any of the passes modified the
3161 function, false otherwise.
3162 @see llvm::FunctionPassManager::run(Function&) */
3163 LLVMBool LLVMRunFunctionPassManager(LLVMPassManagerRef FPM, LLVMValueRef F);
3165 /** Finalizes all of the function passes scheduled in in the function pass
3166 manager. Returns 1 if any of the passes modified the module, 0 otherwise.
3167 @see llvm::FunctionPassManager::doFinalization */
3168 LLVMBool LLVMFinalizeFunctionPassManager(LLVMPassManagerRef FPM);
3170 /** Frees the memory of a pass pipeline. For function pipelines, does not free
3171 the module provider.
3172 @see llvm::PassManagerBase::~PassManagerBase. */
3173 void LLVMDisposePassManager(LLVMPassManagerRef PM);
3180 * @defgroup LLVMCCoreThreading Threading
3182 * Handle the structures needed to make LLVM safe for multithreading.
3187 /** Deprecated: Multi-threading can only be enabled/disabled with the compile
3188 time define LLVM_ENABLE_THREADS. This function always returns
3189 LLVMIsMultithreaded(). */
3190 LLVMBool LLVMStartMultithreaded(void);
3192 /** Deprecated: Multi-threading can only be enabled/disabled with the compile
3193 time define LLVM_ENABLE_THREADS. */
3194 void LLVMStopMultithreaded(void);
3196 /** Check whether LLVM is executing in thread-safe mode or not.
3197 @see llvm::llvm_is_multithreaded */
3198 LLVMBool LLVMIsMultithreaded(void);
3216 #endif /* LLVM_C_CORE_H */