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/Support.h"
25 * @defgroup LLVMC LLVM-C: C interface to LLVM
27 * This module exposes parts of the LLVM library as a C API.
33 * @defgroup LLVMCTransforms Transforms
37 * @defgroup LLVMCCore Core
39 * This modules provide an interface to libLLVMCore, which implements
40 * the LLVM intermediate representation as well as other related types
43 * LLVM uses a polymorphic type hierarchy which C cannot represent, therefore
44 * parameters must be passed as base types. Despite the declared types, most
45 * of the functions provided operate only on branches of the type hierarchy.
46 * The declared parameter names are descriptive and specify which type is
47 * required. Additionally, each type hierarchy is documented along with the
48 * functions that operate upon it. For more detail, refer to LLVM's C++ code.
49 * If in doubt, refer to Core.cpp, which performs parameter downcasts in the
50 * form unwrap<RequiredType>(Param).
52 * Many exotic languages can interoperate with C code but have a harder time
53 * with C++ due to name mangling. So in addition to C, this interface enables
54 * tools written in such languages.
60 * @defgroup LLVMCCoreTypes Types and Enumerations
68 * The top-level container for all LLVM global data. See the LLVMContext class.
70 typedef struct LLVMOpaqueContext *LLVMContextRef;
73 * The top-level container for all other LLVM Intermediate Representation (IR)
78 typedef struct LLVMOpaqueModule *LLVMModuleRef;
81 * Each value in the LLVM IR has a type, an LLVMTypeRef.
85 typedef struct LLVMOpaqueType *LLVMTypeRef;
88 * Represents an individual value in LLVM IR.
90 * This models llvm::Value.
92 typedef struct LLVMOpaqueValue *LLVMValueRef;
95 * Represents a basic block of instructions in LLVM IR.
97 * This models llvm::BasicBlock.
99 typedef struct LLVMOpaqueBasicBlock *LLVMBasicBlockRef;
102 * Represents an LLVM basic block builder.
104 * This models llvm::IRBuilder.
106 typedef struct LLVMOpaqueBuilder *LLVMBuilderRef;
109 * Interface used to provide a module to JIT or interpreter.
110 * This is now just a synonym for llvm::Module, but we have to keep using the
111 * different type to keep binary compatibility.
113 typedef struct LLVMOpaqueModuleProvider *LLVMModuleProviderRef;
115 /** @see llvm::PassManagerBase */
116 typedef struct LLVMOpaquePassManager *LLVMPassManagerRef;
118 /** @see llvm::PassRegistry */
119 typedef struct LLVMOpaquePassRegistry *LLVMPassRegistryRef;
122 * Used to get the users and usees of a Value.
125 typedef struct LLVMOpaqueUse *LLVMUseRef;
129 * @see llvm::DiagnosticInfo
131 typedef struct LLVMOpaqueDiagnosticInfo *LLVMDiagnosticInfoRef;
134 LLVMZExtAttribute = 1<<0,
135 LLVMSExtAttribute = 1<<1,
136 LLVMNoReturnAttribute = 1<<2,
137 LLVMInRegAttribute = 1<<3,
138 LLVMStructRetAttribute = 1<<4,
139 LLVMNoUnwindAttribute = 1<<5,
140 LLVMNoAliasAttribute = 1<<6,
141 LLVMByValAttribute = 1<<7,
142 LLVMNestAttribute = 1<<8,
143 LLVMReadNoneAttribute = 1<<9,
144 LLVMReadOnlyAttribute = 1<<10,
145 LLVMNoInlineAttribute = 1<<11,
146 LLVMAlwaysInlineAttribute = 1<<12,
147 LLVMOptimizeForSizeAttribute = 1<<13,
148 LLVMStackProtectAttribute = 1<<14,
149 LLVMStackProtectReqAttribute = 1<<15,
150 LLVMAlignment = 31<<16,
151 LLVMNoCaptureAttribute = 1<<21,
152 LLVMNoRedZoneAttribute = 1<<22,
153 LLVMNoImplicitFloatAttribute = 1<<23,
154 LLVMNakedAttribute = 1<<24,
155 LLVMInlineHintAttribute = 1<<25,
156 LLVMStackAlignment = 7<<26,
157 LLVMReturnsTwice = 1 << 29,
158 LLVMUWTable = 1 << 30,
159 LLVMNonLazyBind = 1 << 31
161 /* FIXME: These attributes are currently not included in the C API as
162 a temporary measure until the API/ABI impact to the C API is understood
163 and the path forward agreed upon.
164 LLVMAddressSafety = 1ULL << 32,
165 LLVMStackProtectStrongAttribute = 1ULL<<33,
166 LLVMCold = 1ULL << 34,
167 LLVMOptimizeNone = 1ULL << 35,
168 LLVMInAllocaAttribute = 1ULL << 36,
169 LLVMNonNullAttribute = 1ULL << 37,
170 LLVMJumpTableAttribute = 1ULL << 38,
175 /* Terminator Instructions */
181 /* removed 6 due to API changes */
184 /* Standard Binary Operators */
198 /* Logical Operators */
206 /* Memory Operators */
210 LLVMGetElementPtr = 29,
225 LLVMAddrSpaceCast = 60,
227 /* Other Operators */
236 LLVMExtractElement = 50,
237 LLVMInsertElement = 51,
238 LLVMShuffleVector = 52,
239 LLVMExtractValue = 53,
240 LLVMInsertValue = 54,
242 /* Atomic operators */
244 LLVMAtomicCmpXchg = 56,
247 /* Exception Handling Operators */
254 LLVMVoidTypeKind, /**< type with no size */
255 LLVMHalfTypeKind, /**< 16 bit floating point type */
256 LLVMFloatTypeKind, /**< 32 bit floating point type */
257 LLVMDoubleTypeKind, /**< 64 bit floating point type */
258 LLVMX86_FP80TypeKind, /**< 80 bit floating point type (X87) */
259 LLVMFP128TypeKind, /**< 128 bit floating point type (112-bit mantissa)*/
260 LLVMPPC_FP128TypeKind, /**< 128 bit floating point type (two 64-bits) */
261 LLVMLabelTypeKind, /**< Labels */
262 LLVMIntegerTypeKind, /**< Arbitrary bit width integers */
263 LLVMFunctionTypeKind, /**< Functions */
264 LLVMStructTypeKind, /**< Structures */
265 LLVMArrayTypeKind, /**< Arrays */
266 LLVMPointerTypeKind, /**< Pointers */
267 LLVMVectorTypeKind, /**< SIMD 'packed' format, or other vector type */
268 LLVMMetadataTypeKind, /**< Metadata */
269 LLVMX86_MMXTypeKind /**< X86 MMX */
273 LLVMExternalLinkage, /**< Externally visible function */
274 LLVMAvailableExternallyLinkage,
275 LLVMLinkOnceAnyLinkage, /**< Keep one copy of function when linking (inline)*/
276 LLVMLinkOnceODRLinkage, /**< Same, but only replaced by something
278 LLVMLinkOnceODRAutoHideLinkage, /**< Obsolete */
279 LLVMWeakAnyLinkage, /**< Keep one copy of function when linking (weak) */
280 LLVMWeakODRLinkage, /**< Same, but only replaced by something
282 LLVMAppendingLinkage, /**< Special purpose, only applies to global arrays */
283 LLVMInternalLinkage, /**< Rename collisions when linking (static
285 LLVMPrivateLinkage, /**< Like Internal, but omit from symbol table */
286 LLVMDLLImportLinkage, /**< Obsolete */
287 LLVMDLLExportLinkage, /**< Obsolete */
288 LLVMExternalWeakLinkage,/**< ExternalWeak linkage description */
289 LLVMGhostLinkage, /**< Obsolete */
290 LLVMCommonLinkage, /**< Tentative definitions */
291 LLVMLinkerPrivateLinkage, /**< Like Private, but linker removes. */
292 LLVMLinkerPrivateWeakLinkage /**< Like LinkerPrivate, but is weak. */
296 LLVMDefaultVisibility, /**< The GV is visible */
297 LLVMHiddenVisibility, /**< The GV is hidden */
298 LLVMProtectedVisibility /**< The GV is protected */
302 LLVMDefaultStorageClass = 0,
303 LLVMDLLImportStorageClass = 1, /**< Function to be imported from DLL. */
304 LLVMDLLExportStorageClass = 2 /**< Function to be accessible from DLL. */
305 } LLVMDLLStorageClass;
309 LLVMFastCallConv = 8,
310 LLVMColdCallConv = 9,
311 LLVMWebKitJSCallConv = 12,
312 LLVMAnyRegCallConv = 13,
313 LLVMX86StdcallCallConv = 64,
314 LLVMX86FastcallCallConv = 65
318 LLVMIntEQ = 32, /**< equal */
319 LLVMIntNE, /**< not equal */
320 LLVMIntUGT, /**< unsigned greater than */
321 LLVMIntUGE, /**< unsigned greater or equal */
322 LLVMIntULT, /**< unsigned less than */
323 LLVMIntULE, /**< unsigned less or equal */
324 LLVMIntSGT, /**< signed greater than */
325 LLVMIntSGE, /**< signed greater or equal */
326 LLVMIntSLT, /**< signed less than */
327 LLVMIntSLE /**< signed less or equal */
331 LLVMRealPredicateFalse, /**< Always false (always folded) */
332 LLVMRealOEQ, /**< True if ordered and equal */
333 LLVMRealOGT, /**< True if ordered and greater than */
334 LLVMRealOGE, /**< True if ordered and greater than or equal */
335 LLVMRealOLT, /**< True if ordered and less than */
336 LLVMRealOLE, /**< True if ordered and less than or equal */
337 LLVMRealONE, /**< True if ordered and operands are unequal */
338 LLVMRealORD, /**< True if ordered (no nans) */
339 LLVMRealUNO, /**< True if unordered: isnan(X) | isnan(Y) */
340 LLVMRealUEQ, /**< True if unordered or equal */
341 LLVMRealUGT, /**< True if unordered or greater than */
342 LLVMRealUGE, /**< True if unordered, greater than, or equal */
343 LLVMRealULT, /**< True if unordered or less than */
344 LLVMRealULE, /**< True if unordered, less than, or equal */
345 LLVMRealUNE, /**< True if unordered or not equal */
346 LLVMRealPredicateTrue /**< Always true (always folded) */
350 LLVMLandingPadCatch, /**< A catch clause */
351 LLVMLandingPadFilter /**< A filter clause */
352 } LLVMLandingPadClauseTy;
355 LLVMNotThreadLocal = 0,
356 LLVMGeneralDynamicTLSModel,
357 LLVMLocalDynamicTLSModel,
358 LLVMInitialExecTLSModel,
359 LLVMLocalExecTLSModel
360 } LLVMThreadLocalMode;
363 LLVMAtomicOrderingNotAtomic = 0, /**< A load or store which is not atomic */
364 LLVMAtomicOrderingUnordered = 1, /**< Lowest level of atomicity, guarantees
365 somewhat sane results, lock free. */
366 LLVMAtomicOrderingMonotonic = 2, /**< guarantees that if you take all the
367 operations affecting a specific address,
368 a consistent ordering exists */
369 LLVMAtomicOrderingAcquire = 4, /**< Acquire provides a barrier of the sort
370 necessary to acquire a lock to access other
371 memory with normal loads and stores. */
372 LLVMAtomicOrderingRelease = 5, /**< Release is similar to Acquire, but with
373 a barrier of the sort necessary to release
375 LLVMAtomicOrderingAcquireRelease = 6, /**< provides both an Acquire and a
376 Release barrier (for fences and
377 operations which both read and write
379 LLVMAtomicOrderingSequentiallyConsistent = 7 /**< provides Acquire semantics
380 for loads and Release
381 semantics for stores.
382 Additionally, it guarantees
383 that a total ordering exists
385 SequentiallyConsistent
387 } LLVMAtomicOrdering;
390 LLVMAtomicRMWBinOpXchg, /**< Set the new value and return the one old */
391 LLVMAtomicRMWBinOpAdd, /**< Add a value and return the old one */
392 LLVMAtomicRMWBinOpSub, /**< Subtract a value and return the old one */
393 LLVMAtomicRMWBinOpAnd, /**< And a value and return the old one */
394 LLVMAtomicRMWBinOpNand, /**< Not-And a value and return the old one */
395 LLVMAtomicRMWBinOpOr, /**< OR a value and return the old one */
396 LLVMAtomicRMWBinOpXor, /**< Xor a value and return the old one */
397 LLVMAtomicRMWBinOpMax, /**< Sets the value if it's greater than the
398 original using a signed comparison and return
400 LLVMAtomicRMWBinOpMin, /**< Sets the value if it's Smaller than the
401 original using a signed comparison and return
403 LLVMAtomicRMWBinOpUMax, /**< Sets the value if it's greater than the
404 original using an unsigned comparison and return
406 LLVMAtomicRMWBinOpUMin /**< Sets the value if it's greater than the
407 original using an unsigned comparison and return
409 } LLVMAtomicRMWBinOp;
416 } LLVMDiagnosticSeverity;
422 void LLVMInitializeCore(LLVMPassRegistryRef R);
424 /** Deallocate and destroy all ManagedStatic variables.
425 @see llvm::llvm_shutdown
426 @see ManagedStatic */
427 void LLVMShutdown(void);
430 /*===-- Error handling ----------------------------------------------------===*/
432 char *LLVMCreateMessage(const char *Message);
433 void LLVMDisposeMessage(char *Message);
435 typedef void (*LLVMFatalErrorHandler)(const char *Reason);
438 * Install a fatal error handler. By default, if LLVM detects a fatal error, it
439 * will call exit(1). This may not be appropriate in many contexts. For example,
440 * doing exit(1) will bypass many crash reporting/tracing system tools. This
441 * function allows you to install a callback that will be invoked prior to the
444 void LLVMInstallFatalErrorHandler(LLVMFatalErrorHandler Handler);
447 * Reset the fatal error handler. This resets LLVM's fatal error handling
448 * behavior to the default.
450 void LLVMResetFatalErrorHandler(void);
453 * Enable LLVM's built-in stack trace code. This intercepts the OS's crash
454 * signals and prints which component of LLVM you were in at the time if the
457 void LLVMEnablePrettyStackTrace(void);
460 * @defgroup LLVMCCoreContext Contexts
462 * Contexts are execution states for the core LLVM IR system.
464 * Most types are tied to a context instance. Multiple contexts can
465 * exist simultaneously. A single context is not thread safe. However,
466 * different contexts can execute on different threads simultaneously.
471 typedef void (*LLVMDiagnosticHandler)(LLVMDiagnosticInfoRef, void *);
472 typedef void (*LLVMYieldCallback)(LLVMContextRef, void *);
475 * Create a new context.
477 * Every call to this function should be paired with a call to
478 * LLVMContextDispose() or the context will leak memory.
480 LLVMContextRef LLVMContextCreate(void);
483 * Obtain the global context instance.
485 LLVMContextRef LLVMGetGlobalContext(void);
488 * Set the diagnostic handler for this context.
490 void LLVMContextSetDiagnosticHandler(LLVMContextRef C,
491 LLVMDiagnosticHandler Handler,
492 void *DiagnosticContext);
495 * Set the yield callback function for this context.
497 * @see LLVMContext::setYieldCallback()
499 void LLVMContextSetYieldCallback(LLVMContextRef C, LLVMYieldCallback Callback,
503 * Destroy a context instance.
505 * This should be called for every call to LLVMContextCreate() or memory
508 void LLVMContextDispose(LLVMContextRef C);
511 * Return a string representation of the DiagnosticInfo. Use
512 * LLVMDisposeMessage to free the string.
514 * @see DiagnosticInfo::print()
516 char *LLVMGetDiagInfoDescription(LLVMDiagnosticInfoRef DI);
519 * Return an enum LLVMDiagnosticSeverity.
521 * @see DiagnosticInfo::getSeverity()
523 LLVMDiagnosticSeverity LLVMGetDiagInfoSeverity(LLVMDiagnosticInfoRef DI);
525 unsigned LLVMGetMDKindIDInContext(LLVMContextRef C, const char* Name,
527 unsigned LLVMGetMDKindID(const char* Name, unsigned SLen);
534 * @defgroup LLVMCCoreModule Modules
536 * Modules represent the top-level structure in an LLVM program. An LLVM
537 * module is effectively a translation unit or a collection of
538 * translation units merged together.
544 * Create a new, empty module in the global context.
546 * This is equivalent to calling LLVMModuleCreateWithNameInContext with
547 * LLVMGetGlobalContext() as the context parameter.
549 * Every invocation should be paired with LLVMDisposeModule() or memory
552 LLVMModuleRef LLVMModuleCreateWithName(const char *ModuleID);
555 * Create a new, empty module in a specific context.
557 * Every invocation should be paired with LLVMDisposeModule() or memory
560 LLVMModuleRef LLVMModuleCreateWithNameInContext(const char *ModuleID,
564 * Destroy a module instance.
566 * This must be called for every created module or memory will be
569 void LLVMDisposeModule(LLVMModuleRef M);
572 * Obtain the data layout for a module.
574 * @see Module::getDataLayout()
576 const char *LLVMGetDataLayout(LLVMModuleRef M);
579 * Set the data layout for a module.
581 * @see Module::setDataLayout()
583 void LLVMSetDataLayout(LLVMModuleRef M, const char *Triple);
586 * Obtain the target triple for a module.
588 * @see Module::getTargetTriple()
590 const char *LLVMGetTarget(LLVMModuleRef M);
593 * Set the target triple for a module.
595 * @see Module::setTargetTriple()
597 void LLVMSetTarget(LLVMModuleRef M, const char *Triple);
600 * Dump a representation of a module to stderr.
602 * @see Module::dump()
604 void LLVMDumpModule(LLVMModuleRef M);
607 * Print a representation of a module to a file. The ErrorMessage needs to be
608 * disposed with LLVMDisposeMessage. Returns 0 on success, 1 otherwise.
610 * @see Module::print()
612 LLVMBool LLVMPrintModuleToFile(LLVMModuleRef M, const char *Filename,
613 char **ErrorMessage);
616 * Return a string representation of the module. Use
617 * LLVMDisposeMessage to free the string.
619 * @see Module::print()
621 char *LLVMPrintModuleToString(LLVMModuleRef M);
624 * Set inline assembly for a module.
626 * @see Module::setModuleInlineAsm()
628 void LLVMSetModuleInlineAsm(LLVMModuleRef M, const char *Asm);
631 * Obtain the context to which this module is associated.
633 * @see Module::getContext()
635 LLVMContextRef LLVMGetModuleContext(LLVMModuleRef M);
638 * Obtain a Type from a module by its registered name.
640 LLVMTypeRef LLVMGetTypeByName(LLVMModuleRef M, const char *Name);
643 * Obtain the number of operands for named metadata in a module.
645 * @see llvm::Module::getNamedMetadata()
647 unsigned LLVMGetNamedMetadataNumOperands(LLVMModuleRef M, const char* name);
650 * Obtain the named metadata operands for a module.
652 * The passed LLVMValueRef pointer should refer to an array of
653 * LLVMValueRef at least LLVMGetNamedMetadataNumOperands long. This
654 * array will be populated with the LLVMValueRef instances. Each
655 * instance corresponds to a llvm::MDNode.
657 * @see llvm::Module::getNamedMetadata()
658 * @see llvm::MDNode::getOperand()
660 void LLVMGetNamedMetadataOperands(LLVMModuleRef M, const char* name, LLVMValueRef *Dest);
663 * Add an operand to named metadata.
665 * @see llvm::Module::getNamedMetadata()
666 * @see llvm::MDNode::addOperand()
668 void LLVMAddNamedMetadataOperand(LLVMModuleRef M, const char* name,
672 * Add a function to a module under a specified name.
674 * @see llvm::Function::Create()
676 LLVMValueRef LLVMAddFunction(LLVMModuleRef M, const char *Name,
677 LLVMTypeRef FunctionTy);
680 * Obtain a Function value from a Module by its name.
682 * The returned value corresponds to a llvm::Function value.
684 * @see llvm::Module::getFunction()
686 LLVMValueRef LLVMGetNamedFunction(LLVMModuleRef M, const char *Name);
689 * Obtain an iterator to the first Function in a Module.
691 * @see llvm::Module::begin()
693 LLVMValueRef LLVMGetFirstFunction(LLVMModuleRef M);
696 * Obtain an iterator to the last Function in a Module.
698 * @see llvm::Module::end()
700 LLVMValueRef LLVMGetLastFunction(LLVMModuleRef M);
703 * Advance a Function iterator to the next Function.
705 * Returns NULL if the iterator was already at the end and there are no more
708 LLVMValueRef LLVMGetNextFunction(LLVMValueRef Fn);
711 * Decrement a Function iterator to the previous Function.
713 * Returns NULL if the iterator was already at the beginning and there are
714 * no previous functions.
716 LLVMValueRef LLVMGetPreviousFunction(LLVMValueRef Fn);
723 * @defgroup LLVMCCoreType Types
725 * Types represent the type of a value.
727 * Types are associated with a context instance. The context internally
728 * deduplicates types so there is only 1 instance of a specific type
729 * alive at a time. In other words, a unique type is shared among all
730 * consumers within a context.
732 * A Type in the C API corresponds to llvm::Type.
734 * Types have the following hierarchy:
752 * Obtain the enumerated type of a Type instance.
754 * @see llvm::Type:getTypeID()
756 LLVMTypeKind LLVMGetTypeKind(LLVMTypeRef Ty);
759 * Whether the type has a known size.
761 * Things that don't have a size are abstract types, labels, and void.a
763 * @see llvm::Type::isSized()
765 LLVMBool LLVMTypeIsSized(LLVMTypeRef Ty);
768 * Obtain the context to which this type instance is associated.
770 * @see llvm::Type::getContext()
772 LLVMContextRef LLVMGetTypeContext(LLVMTypeRef Ty);
775 * Dump a representation of a type to stderr.
777 * @see llvm::Type::dump()
779 void LLVMDumpType(LLVMTypeRef Val);
782 * Return a string representation of the type. Use
783 * LLVMDisposeMessage to free the string.
785 * @see llvm::Type::print()
787 char *LLVMPrintTypeToString(LLVMTypeRef Val);
790 * @defgroup LLVMCCoreTypeInt Integer Types
792 * Functions in this section operate on integer types.
798 * Obtain an integer type from a context with specified bit width.
800 LLVMTypeRef LLVMInt1TypeInContext(LLVMContextRef C);
801 LLVMTypeRef LLVMInt8TypeInContext(LLVMContextRef C);
802 LLVMTypeRef LLVMInt16TypeInContext(LLVMContextRef C);
803 LLVMTypeRef LLVMInt32TypeInContext(LLVMContextRef C);
804 LLVMTypeRef LLVMInt64TypeInContext(LLVMContextRef C);
805 LLVMTypeRef LLVMIntTypeInContext(LLVMContextRef C, unsigned NumBits);
808 * Obtain an integer type from the global context with a specified bit
811 LLVMTypeRef LLVMInt1Type(void);
812 LLVMTypeRef LLVMInt8Type(void);
813 LLVMTypeRef LLVMInt16Type(void);
814 LLVMTypeRef LLVMInt32Type(void);
815 LLVMTypeRef LLVMInt64Type(void);
816 LLVMTypeRef LLVMIntType(unsigned NumBits);
817 unsigned LLVMGetIntTypeWidth(LLVMTypeRef IntegerTy);
824 * @defgroup LLVMCCoreTypeFloat Floating Point Types
830 * Obtain a 16-bit floating point type from a context.
832 LLVMTypeRef LLVMHalfTypeInContext(LLVMContextRef C);
835 * Obtain a 32-bit floating point type from a context.
837 LLVMTypeRef LLVMFloatTypeInContext(LLVMContextRef C);
840 * Obtain a 64-bit floating point type from a context.
842 LLVMTypeRef LLVMDoubleTypeInContext(LLVMContextRef C);
845 * Obtain a 80-bit floating point type (X87) from a context.
847 LLVMTypeRef LLVMX86FP80TypeInContext(LLVMContextRef C);
850 * Obtain a 128-bit floating point type (112-bit mantissa) from a
853 LLVMTypeRef LLVMFP128TypeInContext(LLVMContextRef C);
856 * Obtain a 128-bit floating point type (two 64-bits) from a context.
858 LLVMTypeRef LLVMPPCFP128TypeInContext(LLVMContextRef C);
861 * Obtain a floating point type from the global context.
863 * These map to the functions in this group of the same name.
865 LLVMTypeRef LLVMHalfType(void);
866 LLVMTypeRef LLVMFloatType(void);
867 LLVMTypeRef LLVMDoubleType(void);
868 LLVMTypeRef LLVMX86FP80Type(void);
869 LLVMTypeRef LLVMFP128Type(void);
870 LLVMTypeRef LLVMPPCFP128Type(void);
877 * @defgroup LLVMCCoreTypeFunction Function Types
883 * Obtain a function type consisting of a specified signature.
885 * The function is defined as a tuple of a return Type, a list of
886 * parameter types, and whether the function is variadic.
888 LLVMTypeRef LLVMFunctionType(LLVMTypeRef ReturnType,
889 LLVMTypeRef *ParamTypes, unsigned ParamCount,
893 * Returns whether a function type is variadic.
895 LLVMBool LLVMIsFunctionVarArg(LLVMTypeRef FunctionTy);
898 * Obtain the Type this function Type returns.
900 LLVMTypeRef LLVMGetReturnType(LLVMTypeRef FunctionTy);
903 * Obtain the number of parameters this function accepts.
905 unsigned LLVMCountParamTypes(LLVMTypeRef FunctionTy);
908 * Obtain the types of a function's parameters.
910 * The Dest parameter should point to a pre-allocated array of
911 * LLVMTypeRef at least LLVMCountParamTypes() large. On return, the
912 * first LLVMCountParamTypes() entries in the array will be populated
913 * with LLVMTypeRef instances.
915 * @param FunctionTy The function type to operate on.
916 * @param Dest Memory address of an array to be filled with result.
918 void LLVMGetParamTypes(LLVMTypeRef FunctionTy, LLVMTypeRef *Dest);
925 * @defgroup LLVMCCoreTypeStruct Structure Types
927 * These functions relate to LLVMTypeRef instances.
929 * @see llvm::StructType
935 * Create a new structure type in a context.
937 * A structure is specified by a list of inner elements/types and
938 * whether these can be packed together.
940 * @see llvm::StructType::create()
942 LLVMTypeRef LLVMStructTypeInContext(LLVMContextRef C, LLVMTypeRef *ElementTypes,
943 unsigned ElementCount, LLVMBool Packed);
946 * Create a new structure type in the global context.
948 * @see llvm::StructType::create()
950 LLVMTypeRef LLVMStructType(LLVMTypeRef *ElementTypes, unsigned ElementCount,
954 * Create an empty structure in a context having a specified name.
956 * @see llvm::StructType::create()
958 LLVMTypeRef LLVMStructCreateNamed(LLVMContextRef C, const char *Name);
961 * Obtain the name of a structure.
963 * @see llvm::StructType::getName()
965 const char *LLVMGetStructName(LLVMTypeRef Ty);
968 * Set the contents of a structure type.
970 * @see llvm::StructType::setBody()
972 void LLVMStructSetBody(LLVMTypeRef StructTy, LLVMTypeRef *ElementTypes,
973 unsigned ElementCount, LLVMBool Packed);
976 * Get the number of elements defined inside the structure.
978 * @see llvm::StructType::getNumElements()
980 unsigned LLVMCountStructElementTypes(LLVMTypeRef StructTy);
983 * Get the elements within a structure.
985 * The function is passed the address of a pre-allocated array of
986 * LLVMTypeRef at least LLVMCountStructElementTypes() long. After
987 * invocation, this array will be populated with the structure's
988 * elements. The objects in the destination array will have a lifetime
989 * of the structure type itself, which is the lifetime of the context it
992 void LLVMGetStructElementTypes(LLVMTypeRef StructTy, LLVMTypeRef *Dest);
995 * Determine whether a structure is packed.
997 * @see llvm::StructType::isPacked()
999 LLVMBool LLVMIsPackedStruct(LLVMTypeRef StructTy);
1002 * Determine whether a structure is opaque.
1004 * @see llvm::StructType::isOpaque()
1006 LLVMBool LLVMIsOpaqueStruct(LLVMTypeRef StructTy);
1014 * @defgroup LLVMCCoreTypeSequential Sequential Types
1016 * Sequential types represents "arrays" of types. This is a super class
1017 * for array, vector, and pointer types.
1023 * Obtain the type of elements within a sequential type.
1025 * This works on array, vector, and pointer types.
1027 * @see llvm::SequentialType::getElementType()
1029 LLVMTypeRef LLVMGetElementType(LLVMTypeRef Ty);
1032 * Create a fixed size array type that refers to a specific type.
1034 * The created type will exist in the context that its element type
1037 * @see llvm::ArrayType::get()
1039 LLVMTypeRef LLVMArrayType(LLVMTypeRef ElementType, unsigned ElementCount);
1042 * Obtain the length of an array type.
1044 * This only works on types that represent arrays.
1046 * @see llvm::ArrayType::getNumElements()
1048 unsigned LLVMGetArrayLength(LLVMTypeRef ArrayTy);
1051 * Create a pointer type that points to a defined type.
1053 * The created type will exist in the context that its pointee type
1056 * @see llvm::PointerType::get()
1058 LLVMTypeRef LLVMPointerType(LLVMTypeRef ElementType, unsigned AddressSpace);
1061 * Obtain the address space of a pointer type.
1063 * This only works on types that represent pointers.
1065 * @see llvm::PointerType::getAddressSpace()
1067 unsigned LLVMGetPointerAddressSpace(LLVMTypeRef PointerTy);
1070 * Create a vector type that contains a defined type and has a specific
1071 * number of elements.
1073 * The created type will exist in the context thats its element type
1076 * @see llvm::VectorType::get()
1078 LLVMTypeRef LLVMVectorType(LLVMTypeRef ElementType, unsigned ElementCount);
1081 * Obtain the number of elements in a vector type.
1083 * This only works on types that represent vectors.
1085 * @see llvm::VectorType::getNumElements()
1087 unsigned LLVMGetVectorSize(LLVMTypeRef VectorTy);
1094 * @defgroup LLVMCCoreTypeOther Other Types
1100 * Create a void type in a context.
1102 LLVMTypeRef LLVMVoidTypeInContext(LLVMContextRef C);
1105 * Create a label type in a context.
1107 LLVMTypeRef LLVMLabelTypeInContext(LLVMContextRef C);
1110 * Create a X86 MMX type in a context.
1112 LLVMTypeRef LLVMX86MMXTypeInContext(LLVMContextRef C);
1115 * These are similar to the above functions except they operate on the
1118 LLVMTypeRef LLVMVoidType(void);
1119 LLVMTypeRef LLVMLabelType(void);
1120 LLVMTypeRef LLVMX86MMXType(void);
1131 * @defgroup LLVMCCoreValues Values
1133 * The bulk of LLVM's object model consists of values, which comprise a very
1134 * rich type hierarchy.
1136 * LLVMValueRef essentially represents llvm::Value. There is a rich
1137 * hierarchy of classes within this type. Depending on the instance
1138 * obtained, not all APIs are available.
1140 * Callers can determine the type of an LLVMValueRef by calling the
1141 * LLVMIsA* family of functions (e.g. LLVMIsAArgument()). These
1142 * functions are defined by a macro, so it isn't obvious which are
1143 * available by looking at the Doxygen source code. Instead, look at the
1144 * source definition of LLVM_FOR_EACH_VALUE_SUBCLASS and note the list
1145 * of value names given. These value names also correspond to classes in
1146 * the llvm::Value hierarchy.
1151 #define LLVM_FOR_EACH_VALUE_SUBCLASS(macro) \
1159 macro(BlockAddress) \
1160 macro(ConstantAggregateZero) \
1161 macro(ConstantArray) \
1162 macro(ConstantDataSequential) \
1163 macro(ConstantDataArray) \
1164 macro(ConstantDataVector) \
1165 macro(ConstantExpr) \
1167 macro(ConstantInt) \
1168 macro(ConstantPointerNull) \
1169 macro(ConstantStruct) \
1170 macro(ConstantVector) \
1171 macro(GlobalValue) \
1172 macro(GlobalAlias) \
1173 macro(GlobalObject) \
1175 macro(GlobalVariable) \
1177 macro(Instruction) \
1178 macro(BinaryOperator) \
1180 macro(IntrinsicInst) \
1181 macro(DbgInfoIntrinsic) \
1182 macro(DbgDeclareInst) \
1183 macro(MemIntrinsic) \
1185 macro(MemMoveInst) \
1190 macro(ExtractElementInst) \
1191 macro(GetElementPtrInst) \
1192 macro(InsertElementInst) \
1193 macro(InsertValueInst) \
1194 macro(LandingPadInst) \
1197 macro(ShuffleVectorInst) \
1199 macro(TerminatorInst) \
1201 macro(IndirectBrInst) \
1205 macro(UnreachableInst) \
1207 macro(UnaryInstruction) \
1210 macro(AddrSpaceCastInst) \
1211 macro(BitCastInst) \
1215 macro(FPTruncInst) \
1216 macro(IntToPtrInst) \
1217 macro(PtrToIntInst) \
1223 macro(ExtractValueInst) \
1228 * @defgroup LLVMCCoreValueGeneral General APIs
1230 * Functions in this section work on all LLVMValueRef instances,
1231 * regardless of their sub-type. They correspond to functions available
1238 * Obtain the type of a value.
1240 * @see llvm::Value::getType()
1242 LLVMTypeRef LLVMTypeOf(LLVMValueRef Val);
1245 * Obtain the string name of a value.
1247 * @see llvm::Value::getName()
1249 const char *LLVMGetValueName(LLVMValueRef Val);
1252 * Set the string name of a value.
1254 * @see llvm::Value::setName()
1256 void LLVMSetValueName(LLVMValueRef Val, const char *Name);
1259 * Dump a representation of a value to stderr.
1261 * @see llvm::Value::dump()
1263 void LLVMDumpValue(LLVMValueRef Val);
1266 * Return a string representation of the value. Use
1267 * LLVMDisposeMessage to free the string.
1269 * @see llvm::Value::print()
1271 char *LLVMPrintValueToString(LLVMValueRef Val);
1274 * Replace all uses of a value with another one.
1276 * @see llvm::Value::replaceAllUsesWith()
1278 void LLVMReplaceAllUsesWith(LLVMValueRef OldVal, LLVMValueRef NewVal);
1281 * Determine whether the specified constant instance is constant.
1283 LLVMBool LLVMIsConstant(LLVMValueRef Val);
1286 * Determine whether a value instance is undefined.
1288 LLVMBool LLVMIsUndef(LLVMValueRef Val);
1291 * Convert value instances between types.
1293 * Internally, an LLVMValueRef is "pinned" to a specific type. This
1294 * series of functions allows you to cast an instance to a specific
1297 * If the cast is not valid for the specified type, NULL is returned.
1299 * @see llvm::dyn_cast_or_null<>
1301 #define LLVM_DECLARE_VALUE_CAST(name) \
1302 LLVMValueRef LLVMIsA##name(LLVMValueRef Val);
1303 LLVM_FOR_EACH_VALUE_SUBCLASS(LLVM_DECLARE_VALUE_CAST)
1310 * @defgroup LLVMCCoreValueUses Usage
1312 * This module defines functions that allow you to inspect the uses of a
1315 * It is possible to obtain an LLVMUseRef for any LLVMValueRef instance.
1316 * Each LLVMUseRef (which corresponds to a llvm::Use instance) holds a
1317 * llvm::User and llvm::Value.
1323 * Obtain the first use of a value.
1325 * Uses are obtained in an iterator fashion. First, call this function
1326 * to obtain a reference to the first use. Then, call LLVMGetNextUse()
1327 * on that instance and all subsequently obtained instances until
1328 * LLVMGetNextUse() returns NULL.
1330 * @see llvm::Value::use_begin()
1332 LLVMUseRef LLVMGetFirstUse(LLVMValueRef Val);
1335 * Obtain the next use of a value.
1337 * This effectively advances the iterator. It returns NULL if you are on
1338 * the final use and no more are available.
1340 LLVMUseRef LLVMGetNextUse(LLVMUseRef U);
1343 * Obtain the user value for a user.
1345 * The returned value corresponds to a llvm::User type.
1347 * @see llvm::Use::getUser()
1349 LLVMValueRef LLVMGetUser(LLVMUseRef U);
1352 * Obtain the value this use corresponds to.
1354 * @see llvm::Use::get().
1356 LLVMValueRef LLVMGetUsedValue(LLVMUseRef U);
1363 * @defgroup LLVMCCoreValueUser User value
1365 * Function in this group pertain to LLVMValueRef instances that descent
1366 * from llvm::User. This includes constants, instructions, and
1373 * Obtain an operand at a specific index in a llvm::User value.
1375 * @see llvm::User::getOperand()
1377 LLVMValueRef LLVMGetOperand(LLVMValueRef Val, unsigned Index);
1380 * Set an operand at a specific index in a llvm::User value.
1382 * @see llvm::User::setOperand()
1384 void LLVMSetOperand(LLVMValueRef User, unsigned Index, LLVMValueRef Val);
1387 * Obtain the number of operands in a llvm::User value.
1389 * @see llvm::User::getNumOperands()
1391 int LLVMGetNumOperands(LLVMValueRef Val);
1398 * @defgroup LLVMCCoreValueConstant Constants
1400 * This section contains APIs for interacting with LLVMValueRef that
1401 * correspond to llvm::Constant instances.
1403 * These functions will work for any LLVMValueRef in the llvm::Constant
1410 * Obtain a constant value referring to the null instance of a type.
1412 * @see llvm::Constant::getNullValue()
1414 LLVMValueRef LLVMConstNull(LLVMTypeRef Ty); /* all zeroes */
1417 * Obtain a constant value referring to the instance of a type
1418 * consisting of all ones.
1420 * This is only valid for integer types.
1422 * @see llvm::Constant::getAllOnesValue()
1424 LLVMValueRef LLVMConstAllOnes(LLVMTypeRef Ty);
1427 * Obtain a constant value referring to an undefined value of a type.
1429 * @see llvm::UndefValue::get()
1431 LLVMValueRef LLVMGetUndef(LLVMTypeRef Ty);
1434 * Determine whether a value instance is null.
1436 * @see llvm::Constant::isNullValue()
1438 LLVMBool LLVMIsNull(LLVMValueRef Val);
1441 * Obtain a constant that is a constant pointer pointing to NULL for a
1444 LLVMValueRef LLVMConstPointerNull(LLVMTypeRef Ty);
1447 * @defgroup LLVMCCoreValueConstantScalar Scalar constants
1449 * Functions in this group model LLVMValueRef instances that correspond
1450 * to constants referring to scalar types.
1452 * For integer types, the LLVMTypeRef parameter should correspond to a
1453 * llvm::IntegerType instance and the returned LLVMValueRef will
1454 * correspond to a llvm::ConstantInt.
1456 * For floating point types, the LLVMTypeRef returned corresponds to a
1463 * Obtain a constant value for an integer type.
1465 * The returned value corresponds to a llvm::ConstantInt.
1467 * @see llvm::ConstantInt::get()
1469 * @param IntTy Integer type to obtain value of.
1470 * @param N The value the returned instance should refer to.
1471 * @param SignExtend Whether to sign extend the produced value.
1473 LLVMValueRef LLVMConstInt(LLVMTypeRef IntTy, unsigned long long N,
1474 LLVMBool SignExtend);
1477 * Obtain a constant value for an integer of arbitrary precision.
1479 * @see llvm::ConstantInt::get()
1481 LLVMValueRef LLVMConstIntOfArbitraryPrecision(LLVMTypeRef IntTy,
1483 const uint64_t Words[]);
1486 * Obtain a constant value for an integer parsed from a string.
1488 * A similar API, LLVMConstIntOfStringAndSize is also available. If the
1489 * string's length is available, it is preferred to call that function
1492 * @see llvm::ConstantInt::get()
1494 LLVMValueRef LLVMConstIntOfString(LLVMTypeRef IntTy, const char *Text,
1498 * Obtain a constant value for an integer parsed from a string with
1501 * @see llvm::ConstantInt::get()
1503 LLVMValueRef LLVMConstIntOfStringAndSize(LLVMTypeRef IntTy, const char *Text,
1504 unsigned SLen, uint8_t Radix);
1507 * Obtain a constant value referring to a double floating point value.
1509 LLVMValueRef LLVMConstReal(LLVMTypeRef RealTy, double N);
1512 * Obtain a constant for a floating point value parsed from a string.
1514 * A similar API, LLVMConstRealOfStringAndSize is also available. It
1515 * should be used if the input string's length is known.
1517 LLVMValueRef LLVMConstRealOfString(LLVMTypeRef RealTy, const char *Text);
1520 * Obtain a constant for a floating point value parsed from a string.
1522 LLVMValueRef LLVMConstRealOfStringAndSize(LLVMTypeRef RealTy, const char *Text,
1526 * Obtain the zero extended value for an integer constant value.
1528 * @see llvm::ConstantInt::getZExtValue()
1530 unsigned long long LLVMConstIntGetZExtValue(LLVMValueRef ConstantVal);
1533 * Obtain the sign extended value for an integer constant value.
1535 * @see llvm::ConstantInt::getSExtValue()
1537 long long LLVMConstIntGetSExtValue(LLVMValueRef ConstantVal);
1544 * @defgroup LLVMCCoreValueConstantComposite Composite Constants
1546 * Functions in this group operate on composite constants.
1552 * Create a ConstantDataSequential and initialize it with a string.
1554 * @see llvm::ConstantDataArray::getString()
1556 LLVMValueRef LLVMConstStringInContext(LLVMContextRef C, const char *Str,
1557 unsigned Length, LLVMBool DontNullTerminate);
1560 * Create a ConstantDataSequential with string content in the global context.
1562 * This is the same as LLVMConstStringInContext except it operates on the
1565 * @see LLVMConstStringInContext()
1566 * @see llvm::ConstantDataArray::getString()
1568 LLVMValueRef LLVMConstString(const char *Str, unsigned Length,
1569 LLVMBool DontNullTerminate);
1572 * Create an anonymous ConstantStruct with the specified values.
1574 * @see llvm::ConstantStruct::getAnon()
1576 LLVMValueRef LLVMConstStructInContext(LLVMContextRef C,
1577 LLVMValueRef *ConstantVals,
1578 unsigned Count, LLVMBool Packed);
1581 * Create a ConstantStruct in the global Context.
1583 * This is the same as LLVMConstStructInContext except it operates on the
1586 * @see LLVMConstStructInContext()
1588 LLVMValueRef LLVMConstStruct(LLVMValueRef *ConstantVals, unsigned Count,
1592 * Create a ConstantArray from values.
1594 * @see llvm::ConstantArray::get()
1596 LLVMValueRef LLVMConstArray(LLVMTypeRef ElementTy,
1597 LLVMValueRef *ConstantVals, unsigned Length);
1600 * Create a non-anonymous ConstantStruct from values.
1602 * @see llvm::ConstantStruct::get()
1604 LLVMValueRef LLVMConstNamedStruct(LLVMTypeRef StructTy,
1605 LLVMValueRef *ConstantVals,
1609 * Create a ConstantVector from values.
1611 * @see llvm::ConstantVector::get()
1613 LLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals, unsigned Size);
1620 * @defgroup LLVMCCoreValueConstantExpressions Constant Expressions
1622 * Functions in this group correspond to APIs on llvm::ConstantExpr.
1624 * @see llvm::ConstantExpr.
1628 LLVMOpcode LLVMGetConstOpcode(LLVMValueRef ConstantVal);
1629 LLVMValueRef LLVMAlignOf(LLVMTypeRef Ty);
1630 LLVMValueRef LLVMSizeOf(LLVMTypeRef Ty);
1631 LLVMValueRef LLVMConstNeg(LLVMValueRef ConstantVal);
1632 LLVMValueRef LLVMConstNSWNeg(LLVMValueRef ConstantVal);
1633 LLVMValueRef LLVMConstNUWNeg(LLVMValueRef ConstantVal);
1634 LLVMValueRef LLVMConstFNeg(LLVMValueRef ConstantVal);
1635 LLVMValueRef LLVMConstNot(LLVMValueRef ConstantVal);
1636 LLVMValueRef LLVMConstAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1637 LLVMValueRef LLVMConstNSWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1638 LLVMValueRef LLVMConstNUWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1639 LLVMValueRef LLVMConstFAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1640 LLVMValueRef LLVMConstSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1641 LLVMValueRef LLVMConstNSWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1642 LLVMValueRef LLVMConstNUWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1643 LLVMValueRef LLVMConstFSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1644 LLVMValueRef LLVMConstMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1645 LLVMValueRef LLVMConstNSWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1646 LLVMValueRef LLVMConstNUWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1647 LLVMValueRef LLVMConstFMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1648 LLVMValueRef LLVMConstUDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1649 LLVMValueRef LLVMConstSDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1650 LLVMValueRef LLVMConstExactSDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1651 LLVMValueRef LLVMConstFDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1652 LLVMValueRef LLVMConstURem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1653 LLVMValueRef LLVMConstSRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1654 LLVMValueRef LLVMConstFRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1655 LLVMValueRef LLVMConstAnd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1656 LLVMValueRef LLVMConstOr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1657 LLVMValueRef LLVMConstXor(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1658 LLVMValueRef LLVMConstICmp(LLVMIntPredicate Predicate,
1659 LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1660 LLVMValueRef LLVMConstFCmp(LLVMRealPredicate Predicate,
1661 LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1662 LLVMValueRef LLVMConstShl(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1663 LLVMValueRef LLVMConstLShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1664 LLVMValueRef LLVMConstAShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1665 LLVMValueRef LLVMConstGEP(LLVMValueRef ConstantVal,
1666 LLVMValueRef *ConstantIndices, unsigned NumIndices);
1667 LLVMValueRef LLVMConstInBoundsGEP(LLVMValueRef ConstantVal,
1668 LLVMValueRef *ConstantIndices,
1669 unsigned NumIndices);
1670 LLVMValueRef LLVMConstTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1671 LLVMValueRef LLVMConstSExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1672 LLVMValueRef LLVMConstZExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1673 LLVMValueRef LLVMConstFPTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1674 LLVMValueRef LLVMConstFPExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1675 LLVMValueRef LLVMConstUIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1676 LLVMValueRef LLVMConstSIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1677 LLVMValueRef LLVMConstFPToUI(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1678 LLVMValueRef LLVMConstFPToSI(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1679 LLVMValueRef LLVMConstPtrToInt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1680 LLVMValueRef LLVMConstIntToPtr(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1681 LLVMValueRef LLVMConstBitCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1682 LLVMValueRef LLVMConstAddrSpaceCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1683 LLVMValueRef LLVMConstZExtOrBitCast(LLVMValueRef ConstantVal,
1684 LLVMTypeRef ToType);
1685 LLVMValueRef LLVMConstSExtOrBitCast(LLVMValueRef ConstantVal,
1686 LLVMTypeRef ToType);
1687 LLVMValueRef LLVMConstTruncOrBitCast(LLVMValueRef ConstantVal,
1688 LLVMTypeRef ToType);
1689 LLVMValueRef LLVMConstPointerCast(LLVMValueRef ConstantVal,
1690 LLVMTypeRef ToType);
1691 LLVMValueRef LLVMConstIntCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType,
1693 LLVMValueRef LLVMConstFPCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1694 LLVMValueRef LLVMConstSelect(LLVMValueRef ConstantCondition,
1695 LLVMValueRef ConstantIfTrue,
1696 LLVMValueRef ConstantIfFalse);
1697 LLVMValueRef LLVMConstExtractElement(LLVMValueRef VectorConstant,
1698 LLVMValueRef IndexConstant);
1699 LLVMValueRef LLVMConstInsertElement(LLVMValueRef VectorConstant,
1700 LLVMValueRef ElementValueConstant,
1701 LLVMValueRef IndexConstant);
1702 LLVMValueRef LLVMConstShuffleVector(LLVMValueRef VectorAConstant,
1703 LLVMValueRef VectorBConstant,
1704 LLVMValueRef MaskConstant);
1705 LLVMValueRef LLVMConstExtractValue(LLVMValueRef AggConstant, unsigned *IdxList,
1707 LLVMValueRef LLVMConstInsertValue(LLVMValueRef AggConstant,
1708 LLVMValueRef ElementValueConstant,
1709 unsigned *IdxList, unsigned NumIdx);
1710 LLVMValueRef LLVMConstInlineAsm(LLVMTypeRef Ty,
1711 const char *AsmString, const char *Constraints,
1712 LLVMBool HasSideEffects, LLVMBool IsAlignStack);
1713 LLVMValueRef LLVMBlockAddress(LLVMValueRef F, LLVMBasicBlockRef BB);
1720 * @defgroup LLVMCCoreValueConstantGlobals Global Values
1722 * This group contains functions that operate on global values. Functions in
1723 * this group relate to functions in the llvm::GlobalValue class tree.
1725 * @see llvm::GlobalValue
1730 LLVMModuleRef LLVMGetGlobalParent(LLVMValueRef Global);
1731 LLVMBool LLVMIsDeclaration(LLVMValueRef Global);
1732 LLVMLinkage LLVMGetLinkage(LLVMValueRef Global);
1733 void LLVMSetLinkage(LLVMValueRef Global, LLVMLinkage Linkage);
1734 const char *LLVMGetSection(LLVMValueRef Global);
1735 void LLVMSetSection(LLVMValueRef Global, const char *Section);
1736 LLVMVisibility LLVMGetVisibility(LLVMValueRef Global);
1737 void LLVMSetVisibility(LLVMValueRef Global, LLVMVisibility Viz);
1738 LLVMDLLStorageClass LLVMGetDLLStorageClass(LLVMValueRef Global);
1739 void LLVMSetDLLStorageClass(LLVMValueRef Global, LLVMDLLStorageClass Class);
1740 LLVMBool LLVMHasUnnamedAddr(LLVMValueRef Global);
1741 void LLVMSetUnnamedAddr(LLVMValueRef Global, LLVMBool HasUnnamedAddr);
1744 * @defgroup LLVMCCoreValueWithAlignment Values with alignment
1746 * Functions in this group only apply to values with alignment, i.e.
1747 * global variables, load and store instructions.
1751 * Obtain the preferred alignment of the value.
1752 * @see llvm::AllocaInst::getAlignment()
1753 * @see llvm::LoadInst::getAlignment()
1754 * @see llvm::StoreInst::getAlignment()
1755 * @see llvm::GlobalValue::getAlignment()
1757 unsigned LLVMGetAlignment(LLVMValueRef V);
1760 * Set the preferred alignment of the value.
1761 * @see llvm::AllocaInst::setAlignment()
1762 * @see llvm::LoadInst::setAlignment()
1763 * @see llvm::StoreInst::setAlignment()
1764 * @see llvm::GlobalValue::setAlignment()
1766 void LLVMSetAlignment(LLVMValueRef V, unsigned Bytes);
1773 * @defgroup LLVMCoreValueConstantGlobalVariable Global Variables
1775 * This group contains functions that operate on global variable values.
1777 * @see llvm::GlobalVariable
1781 LLVMValueRef LLVMAddGlobal(LLVMModuleRef M, LLVMTypeRef Ty, const char *Name);
1782 LLVMValueRef LLVMAddGlobalInAddressSpace(LLVMModuleRef M, LLVMTypeRef Ty,
1784 unsigned AddressSpace);
1785 LLVMValueRef LLVMGetNamedGlobal(LLVMModuleRef M, const char *Name);
1786 LLVMValueRef LLVMGetFirstGlobal(LLVMModuleRef M);
1787 LLVMValueRef LLVMGetLastGlobal(LLVMModuleRef M);
1788 LLVMValueRef LLVMGetNextGlobal(LLVMValueRef GlobalVar);
1789 LLVMValueRef LLVMGetPreviousGlobal(LLVMValueRef GlobalVar);
1790 void LLVMDeleteGlobal(LLVMValueRef GlobalVar);
1791 LLVMValueRef LLVMGetInitializer(LLVMValueRef GlobalVar);
1792 void LLVMSetInitializer(LLVMValueRef GlobalVar, LLVMValueRef ConstantVal);
1793 LLVMBool LLVMIsThreadLocal(LLVMValueRef GlobalVar);
1794 void LLVMSetThreadLocal(LLVMValueRef GlobalVar, LLVMBool IsThreadLocal);
1795 LLVMBool LLVMIsGlobalConstant(LLVMValueRef GlobalVar);
1796 void LLVMSetGlobalConstant(LLVMValueRef GlobalVar, LLVMBool IsConstant);
1797 LLVMThreadLocalMode LLVMGetThreadLocalMode(LLVMValueRef GlobalVar);
1798 void LLVMSetThreadLocalMode(LLVMValueRef GlobalVar, LLVMThreadLocalMode Mode);
1799 LLVMBool LLVMIsExternallyInitialized(LLVMValueRef GlobalVar);
1800 void LLVMSetExternallyInitialized(LLVMValueRef GlobalVar, LLVMBool IsExtInit);
1807 * @defgroup LLVMCoreValueConstantGlobalAlias Global Aliases
1809 * This group contains function that operate on global alias values.
1811 * @see llvm::GlobalAlias
1815 LLVMValueRef LLVMAddAlias(LLVMModuleRef M, LLVMTypeRef Ty, LLVMValueRef Aliasee,
1823 * @defgroup LLVMCCoreValueFunction Function values
1825 * Functions in this group operate on LLVMValueRef instances that
1826 * correspond to llvm::Function instances.
1828 * @see llvm::Function
1834 * Remove a function from its containing module and deletes it.
1836 * @see llvm::Function::eraseFromParent()
1838 void LLVMDeleteFunction(LLVMValueRef Fn);
1841 * Obtain the ID number from a function instance.
1843 * @see llvm::Function::getIntrinsicID()
1845 unsigned LLVMGetIntrinsicID(LLVMValueRef Fn);
1848 * Obtain the calling function of a function.
1850 * The returned value corresponds to the LLVMCallConv enumeration.
1852 * @see llvm::Function::getCallingConv()
1854 unsigned LLVMGetFunctionCallConv(LLVMValueRef Fn);
1857 * Set the calling convention of a function.
1859 * @see llvm::Function::setCallingConv()
1861 * @param Fn Function to operate on
1862 * @param CC LLVMCallConv to set calling convention to
1864 void LLVMSetFunctionCallConv(LLVMValueRef Fn, unsigned CC);
1867 * Obtain the name of the garbage collector to use during code
1870 * @see llvm::Function::getGC()
1872 const char *LLVMGetGC(LLVMValueRef Fn);
1875 * Define the garbage collector to use during code generation.
1877 * @see llvm::Function::setGC()
1879 void LLVMSetGC(LLVMValueRef Fn, const char *Name);
1882 * Add an attribute to a function.
1884 * @see llvm::Function::addAttribute()
1886 void LLVMAddFunctionAttr(LLVMValueRef Fn, LLVMAttribute PA);
1889 * Add a target-dependent attribute to a fuction
1890 * @see llvm::AttrBuilder::addAttribute()
1892 void LLVMAddTargetDependentFunctionAttr(LLVMValueRef Fn, const char *A,
1896 * Obtain an attribute from a function.
1898 * @see llvm::Function::getAttributes()
1900 LLVMAttribute LLVMGetFunctionAttr(LLVMValueRef Fn);
1903 * Remove an attribute from a function.
1905 void LLVMRemoveFunctionAttr(LLVMValueRef Fn, LLVMAttribute PA);
1908 * @defgroup LLVMCCoreValueFunctionParameters Function Parameters
1910 * Functions in this group relate to arguments/parameters on functions.
1912 * Functions in this group expect LLVMValueRef instances that correspond
1913 * to llvm::Function instances.
1919 * Obtain the number of parameters in a function.
1921 * @see llvm::Function::arg_size()
1923 unsigned LLVMCountParams(LLVMValueRef Fn);
1926 * Obtain the parameters in a function.
1928 * The takes a pointer to a pre-allocated array of LLVMValueRef that is
1929 * at least LLVMCountParams() long. This array will be filled with
1930 * LLVMValueRef instances which correspond to the parameters the
1931 * function receives. Each LLVMValueRef corresponds to a llvm::Argument
1934 * @see llvm::Function::arg_begin()
1936 void LLVMGetParams(LLVMValueRef Fn, LLVMValueRef *Params);
1939 * Obtain the parameter at the specified index.
1941 * Parameters are indexed from 0.
1943 * @see llvm::Function::arg_begin()
1945 LLVMValueRef LLVMGetParam(LLVMValueRef Fn, unsigned Index);
1948 * Obtain the function to which this argument belongs.
1950 * Unlike other functions in this group, this one takes an LLVMValueRef
1951 * that corresponds to a llvm::Attribute.
1953 * The returned LLVMValueRef is the llvm::Function to which this
1956 LLVMValueRef LLVMGetParamParent(LLVMValueRef Inst);
1959 * Obtain the first parameter to a function.
1961 * @see llvm::Function::arg_begin()
1963 LLVMValueRef LLVMGetFirstParam(LLVMValueRef Fn);
1966 * Obtain the last parameter to a function.
1968 * @see llvm::Function::arg_end()
1970 LLVMValueRef LLVMGetLastParam(LLVMValueRef Fn);
1973 * Obtain the next parameter to a function.
1975 * This takes an LLVMValueRef obtained from LLVMGetFirstParam() (which is
1976 * actually a wrapped iterator) and obtains the next parameter from the
1977 * underlying iterator.
1979 LLVMValueRef LLVMGetNextParam(LLVMValueRef Arg);
1982 * Obtain the previous parameter to a function.
1984 * This is the opposite of LLVMGetNextParam().
1986 LLVMValueRef LLVMGetPreviousParam(LLVMValueRef Arg);
1989 * Add an attribute to a function argument.
1991 * @see llvm::Argument::addAttr()
1993 void LLVMAddAttribute(LLVMValueRef Arg, LLVMAttribute PA);
1996 * Remove an attribute from a function argument.
1998 * @see llvm::Argument::removeAttr()
2000 void LLVMRemoveAttribute(LLVMValueRef Arg, LLVMAttribute PA);
2003 * Get an attribute from a function argument.
2005 LLVMAttribute LLVMGetAttribute(LLVMValueRef Arg);
2008 * Set the alignment for a function parameter.
2010 * @see llvm::Argument::addAttr()
2011 * @see llvm::AttrBuilder::addAlignmentAttr()
2013 void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned align);
2032 * @defgroup LLVMCCoreValueMetadata Metadata
2038 * Obtain a MDString value from a context.
2040 * The returned instance corresponds to the llvm::MDString class.
2042 * The instance is specified by string data of a specified length. The
2043 * string content is copied, so the backing memory can be freed after
2044 * this function returns.
2046 LLVMValueRef LLVMMDStringInContext(LLVMContextRef C, const char *Str,
2050 * Obtain a MDString value from the global context.
2052 LLVMValueRef LLVMMDString(const char *Str, unsigned SLen);
2055 * Obtain a MDNode value from a context.
2057 * The returned value corresponds to the llvm::MDNode class.
2059 LLVMValueRef LLVMMDNodeInContext(LLVMContextRef C, LLVMValueRef *Vals,
2063 * Obtain a MDNode value from the global context.
2065 LLVMValueRef LLVMMDNode(LLVMValueRef *Vals, unsigned Count);
2068 * Obtain the underlying string from a MDString value.
2070 * @param V Instance to obtain string from.
2071 * @param Len Memory address which will hold length of returned string.
2072 * @return String data in MDString.
2074 const char *LLVMGetMDString(LLVMValueRef V, unsigned* Len);
2077 * Obtain the number of operands from an MDNode value.
2079 * @param V MDNode to get number of operands from.
2080 * @return Number of operands of the MDNode.
2082 unsigned LLVMGetMDNodeNumOperands(LLVMValueRef V);
2085 * Obtain the given MDNode's operands.
2087 * The passed LLVMValueRef pointer should point to enough memory to hold all of
2088 * the operands of the given MDNode (see LLVMGetMDNodeNumOperands) as
2089 * LLVMValueRefs. This memory will be populated with the LLVMValueRefs of the
2090 * MDNode's operands.
2092 * @param V MDNode to get the operands from.
2093 * @param Dest Destination array for operands.
2095 void LLVMGetMDNodeOperands(LLVMValueRef V, LLVMValueRef *Dest);
2102 * @defgroup LLVMCCoreValueBasicBlock Basic Block
2104 * A basic block represents a single entry single exit section of code.
2105 * Basic blocks contain a list of instructions which form the body of
2108 * Basic blocks belong to functions. They have the type of label.
2110 * Basic blocks are themselves values. However, the C API models them as
2111 * LLVMBasicBlockRef.
2113 * @see llvm::BasicBlock
2119 * Convert a basic block instance to a value type.
2121 LLVMValueRef LLVMBasicBlockAsValue(LLVMBasicBlockRef BB);
2124 * Determine whether an LLVMValueRef is itself a basic block.
2126 LLVMBool LLVMValueIsBasicBlock(LLVMValueRef Val);
2129 * Convert an LLVMValueRef to an LLVMBasicBlockRef instance.
2131 LLVMBasicBlockRef LLVMValueAsBasicBlock(LLVMValueRef Val);
2134 * Obtain the function to which a basic block belongs.
2136 * @see llvm::BasicBlock::getParent()
2138 LLVMValueRef LLVMGetBasicBlockParent(LLVMBasicBlockRef BB);
2141 * Obtain the terminator instruction for a basic block.
2143 * If the basic block does not have a terminator (it is not well-formed
2144 * if it doesn't), then NULL is returned.
2146 * The returned LLVMValueRef corresponds to a llvm::TerminatorInst.
2148 * @see llvm::BasicBlock::getTerminator()
2150 LLVMValueRef LLVMGetBasicBlockTerminator(LLVMBasicBlockRef BB);
2153 * Obtain the number of basic blocks in a function.
2155 * @param Fn Function value to operate on.
2157 unsigned LLVMCountBasicBlocks(LLVMValueRef Fn);
2160 * Obtain all of the basic blocks in a function.
2162 * This operates on a function value. The BasicBlocks parameter is a
2163 * pointer to a pre-allocated array of LLVMBasicBlockRef of at least
2164 * LLVMCountBasicBlocks() in length. This array is populated with
2165 * LLVMBasicBlockRef instances.
2167 void LLVMGetBasicBlocks(LLVMValueRef Fn, LLVMBasicBlockRef *BasicBlocks);
2170 * Obtain the first basic block in a function.
2172 * The returned basic block can be used as an iterator. You will likely
2173 * eventually call into LLVMGetNextBasicBlock() with it.
2175 * @see llvm::Function::begin()
2177 LLVMBasicBlockRef LLVMGetFirstBasicBlock(LLVMValueRef Fn);
2180 * Obtain the last basic block in a function.
2182 * @see llvm::Function::end()
2184 LLVMBasicBlockRef LLVMGetLastBasicBlock(LLVMValueRef Fn);
2187 * Advance a basic block iterator.
2189 LLVMBasicBlockRef LLVMGetNextBasicBlock(LLVMBasicBlockRef BB);
2192 * Go backwards in a basic block iterator.
2194 LLVMBasicBlockRef LLVMGetPreviousBasicBlock(LLVMBasicBlockRef BB);
2197 * Obtain the basic block that corresponds to the entry point of a
2200 * @see llvm::Function::getEntryBlock()
2202 LLVMBasicBlockRef LLVMGetEntryBasicBlock(LLVMValueRef Fn);
2205 * Append a basic block to the end of a function.
2207 * @see llvm::BasicBlock::Create()
2209 LLVMBasicBlockRef LLVMAppendBasicBlockInContext(LLVMContextRef C,
2214 * Append a basic block to the end of a function using the global
2217 * @see llvm::BasicBlock::Create()
2219 LLVMBasicBlockRef LLVMAppendBasicBlock(LLVMValueRef Fn, const char *Name);
2222 * Insert a basic block in a function before another basic block.
2224 * The function to add to is determined by the function of the
2225 * passed basic block.
2227 * @see llvm::BasicBlock::Create()
2229 LLVMBasicBlockRef LLVMInsertBasicBlockInContext(LLVMContextRef C,
2230 LLVMBasicBlockRef BB,
2234 * Insert a basic block in a function using the global context.
2236 * @see llvm::BasicBlock::Create()
2238 LLVMBasicBlockRef LLVMInsertBasicBlock(LLVMBasicBlockRef InsertBeforeBB,
2242 * Remove a basic block from a function and delete it.
2244 * This deletes the basic block from its containing function and deletes
2245 * the basic block itself.
2247 * @see llvm::BasicBlock::eraseFromParent()
2249 void LLVMDeleteBasicBlock(LLVMBasicBlockRef BB);
2252 * Remove a basic block from a function.
2254 * This deletes the basic block from its containing function but keep
2255 * the basic block alive.
2257 * @see llvm::BasicBlock::removeFromParent()
2259 void LLVMRemoveBasicBlockFromParent(LLVMBasicBlockRef BB);
2262 * Move a basic block to before another one.
2264 * @see llvm::BasicBlock::moveBefore()
2266 void LLVMMoveBasicBlockBefore(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos);
2269 * Move a basic block to after another one.
2271 * @see llvm::BasicBlock::moveAfter()
2273 void LLVMMoveBasicBlockAfter(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos);
2276 * Obtain the first instruction in a basic block.
2278 * The returned LLVMValueRef corresponds to a llvm::Instruction
2281 LLVMValueRef LLVMGetFirstInstruction(LLVMBasicBlockRef BB);
2284 * Obtain the last instruction in a basic block.
2286 * The returned LLVMValueRef corresponds to an LLVM:Instruction.
2288 LLVMValueRef LLVMGetLastInstruction(LLVMBasicBlockRef BB);
2295 * @defgroup LLVMCCoreValueInstruction Instructions
2297 * Functions in this group relate to the inspection and manipulation of
2298 * individual instructions.
2300 * In the C++ API, an instruction is modeled by llvm::Instruction. This
2301 * class has a large number of descendents. llvm::Instruction is a
2302 * llvm::Value and in the C API, instructions are modeled by
2305 * This group also contains sub-groups which operate on specific
2306 * llvm::Instruction types, e.g. llvm::CallInst.
2312 * Determine whether an instruction has any metadata attached.
2314 int LLVMHasMetadata(LLVMValueRef Val);
2317 * Return metadata associated with an instruction value.
2319 LLVMValueRef LLVMGetMetadata(LLVMValueRef Val, unsigned KindID);
2322 * Set metadata associated with an instruction value.
2324 void LLVMSetMetadata(LLVMValueRef Val, unsigned KindID, LLVMValueRef Node);
2327 * Obtain the basic block to which an instruction belongs.
2329 * @see llvm::Instruction::getParent()
2331 LLVMBasicBlockRef LLVMGetInstructionParent(LLVMValueRef Inst);
2334 * Obtain the instruction that occurs after the one specified.
2336 * The next instruction will be from the same basic block.
2338 * If this is the last instruction in a basic block, NULL will be
2341 LLVMValueRef LLVMGetNextInstruction(LLVMValueRef Inst);
2344 * Obtain the instruction that occurred before this one.
2346 * If the instruction is the first instruction in a basic block, NULL
2349 LLVMValueRef LLVMGetPreviousInstruction(LLVMValueRef Inst);
2352 * Remove and delete an instruction.
2354 * The instruction specified is removed from its containing building
2355 * block and then deleted.
2357 * @see llvm::Instruction::eraseFromParent()
2359 void LLVMInstructionEraseFromParent(LLVMValueRef Inst);
2362 * Obtain the code opcode for an individual instruction.
2364 * @see llvm::Instruction::getOpCode()
2366 LLVMOpcode LLVMGetInstructionOpcode(LLVMValueRef Inst);
2369 * Obtain the predicate of an instruction.
2371 * This is only valid for instructions that correspond to llvm::ICmpInst
2372 * or llvm::ConstantExpr whose opcode is llvm::Instruction::ICmp.
2374 * @see llvm::ICmpInst::getPredicate()
2376 LLVMIntPredicate LLVMGetICmpPredicate(LLVMValueRef Inst);
2379 * @defgroup LLVMCCoreValueInstructionCall Call Sites and Invocations
2381 * Functions in this group apply to instructions that refer to call
2382 * sites and invocations. These correspond to C++ types in the
2383 * llvm::CallInst class tree.
2389 * Set the calling convention for a call instruction.
2391 * This expects an LLVMValueRef that corresponds to a llvm::CallInst or
2394 * @see llvm::CallInst::setCallingConv()
2395 * @see llvm::InvokeInst::setCallingConv()
2397 void LLVMSetInstructionCallConv(LLVMValueRef Instr, unsigned CC);
2400 * Obtain the calling convention for a call instruction.
2402 * This is the opposite of LLVMSetInstructionCallConv(). Reads its
2405 * @see LLVMSetInstructionCallConv()
2407 unsigned LLVMGetInstructionCallConv(LLVMValueRef Instr);
2410 void LLVMAddInstrAttribute(LLVMValueRef Instr, unsigned index, LLVMAttribute);
2411 void LLVMRemoveInstrAttribute(LLVMValueRef Instr, unsigned index,
2413 void LLVMSetInstrParamAlignment(LLVMValueRef Instr, unsigned index,
2417 * Obtain whether a call instruction is a tail call.
2419 * This only works on llvm::CallInst instructions.
2421 * @see llvm::CallInst::isTailCall()
2423 LLVMBool LLVMIsTailCall(LLVMValueRef CallInst);
2426 * Set whether a call instruction is a tail call.
2428 * This only works on llvm::CallInst instructions.
2430 * @see llvm::CallInst::setTailCall()
2432 void LLVMSetTailCall(LLVMValueRef CallInst, LLVMBool IsTailCall);
2439 * Obtain the default destination basic block of a switch instruction.
2441 * This only works on llvm::SwitchInst instructions.
2443 * @see llvm::SwitchInst::getDefaultDest()
2445 LLVMBasicBlockRef LLVMGetSwitchDefaultDest(LLVMValueRef SwitchInstr);
2448 * @defgroup LLVMCCoreValueInstructionPHINode PHI Nodes
2450 * Functions in this group only apply to instructions that map to
2451 * llvm::PHINode instances.
2457 * Add an incoming value to the end of a PHI list.
2459 void LLVMAddIncoming(LLVMValueRef PhiNode, LLVMValueRef *IncomingValues,
2460 LLVMBasicBlockRef *IncomingBlocks, unsigned Count);
2463 * Obtain the number of incoming basic blocks to a PHI node.
2465 unsigned LLVMCountIncoming(LLVMValueRef PhiNode);
2468 * Obtain an incoming value to a PHI node as an LLVMValueRef.
2470 LLVMValueRef LLVMGetIncomingValue(LLVMValueRef PhiNode, unsigned Index);
2473 * Obtain an incoming value to a PHI node as an LLVMBasicBlockRef.
2475 LLVMBasicBlockRef LLVMGetIncomingBlock(LLVMValueRef PhiNode, unsigned Index);
2490 * @defgroup LLVMCCoreInstructionBuilder Instruction Builders
2492 * An instruction builder represents a point within a basic block and is
2493 * the exclusive means of building instructions using the C interface.
2498 LLVMBuilderRef LLVMCreateBuilderInContext(LLVMContextRef C);
2499 LLVMBuilderRef LLVMCreateBuilder(void);
2500 void LLVMPositionBuilder(LLVMBuilderRef Builder, LLVMBasicBlockRef Block,
2501 LLVMValueRef Instr);
2502 void LLVMPositionBuilderBefore(LLVMBuilderRef Builder, LLVMValueRef Instr);
2503 void LLVMPositionBuilderAtEnd(LLVMBuilderRef Builder, LLVMBasicBlockRef Block);
2504 LLVMBasicBlockRef LLVMGetInsertBlock(LLVMBuilderRef Builder);
2505 void LLVMClearInsertionPosition(LLVMBuilderRef Builder);
2506 void LLVMInsertIntoBuilder(LLVMBuilderRef Builder, LLVMValueRef Instr);
2507 void LLVMInsertIntoBuilderWithName(LLVMBuilderRef Builder, LLVMValueRef Instr,
2509 void LLVMDisposeBuilder(LLVMBuilderRef Builder);
2512 void LLVMSetCurrentDebugLocation(LLVMBuilderRef Builder, LLVMValueRef L);
2513 LLVMValueRef LLVMGetCurrentDebugLocation(LLVMBuilderRef Builder);
2514 void LLVMSetInstDebugLocation(LLVMBuilderRef Builder, LLVMValueRef Inst);
2517 LLVMValueRef LLVMBuildRetVoid(LLVMBuilderRef);
2518 LLVMValueRef LLVMBuildRet(LLVMBuilderRef, LLVMValueRef V);
2519 LLVMValueRef LLVMBuildAggregateRet(LLVMBuilderRef, LLVMValueRef *RetVals,
2521 LLVMValueRef LLVMBuildBr(LLVMBuilderRef, LLVMBasicBlockRef Dest);
2522 LLVMValueRef LLVMBuildCondBr(LLVMBuilderRef, LLVMValueRef If,
2523 LLVMBasicBlockRef Then, LLVMBasicBlockRef Else);
2524 LLVMValueRef LLVMBuildSwitch(LLVMBuilderRef, LLVMValueRef V,
2525 LLVMBasicBlockRef Else, unsigned NumCases);
2526 LLVMValueRef LLVMBuildIndirectBr(LLVMBuilderRef B, LLVMValueRef Addr,
2528 LLVMValueRef LLVMBuildInvoke(LLVMBuilderRef, LLVMValueRef Fn,
2529 LLVMValueRef *Args, unsigned NumArgs,
2530 LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch,
2532 LLVMValueRef LLVMBuildLandingPad(LLVMBuilderRef B, LLVMTypeRef Ty,
2533 LLVMValueRef PersFn, unsigned NumClauses,
2535 LLVMValueRef LLVMBuildResume(LLVMBuilderRef B, LLVMValueRef Exn);
2536 LLVMValueRef LLVMBuildUnreachable(LLVMBuilderRef);
2538 /* Add a case to the switch instruction */
2539 void LLVMAddCase(LLVMValueRef Switch, LLVMValueRef OnVal,
2540 LLVMBasicBlockRef Dest);
2542 /* Add a destination to the indirectbr instruction */
2543 void LLVMAddDestination(LLVMValueRef IndirectBr, LLVMBasicBlockRef Dest);
2545 /* Add a catch or filter clause to the landingpad instruction */
2546 void LLVMAddClause(LLVMValueRef LandingPad, LLVMValueRef ClauseVal);
2548 /* Set the 'cleanup' flag in the landingpad instruction */
2549 void LLVMSetCleanup(LLVMValueRef LandingPad, LLVMBool Val);
2552 LLVMValueRef LLVMBuildAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2554 LLVMValueRef LLVMBuildNSWAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2556 LLVMValueRef LLVMBuildNUWAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2558 LLVMValueRef LLVMBuildFAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2560 LLVMValueRef LLVMBuildSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2562 LLVMValueRef LLVMBuildNSWSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2564 LLVMValueRef LLVMBuildNUWSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2566 LLVMValueRef LLVMBuildFSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2568 LLVMValueRef LLVMBuildMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2570 LLVMValueRef LLVMBuildNSWMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2572 LLVMValueRef LLVMBuildNUWMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2574 LLVMValueRef LLVMBuildFMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2576 LLVMValueRef LLVMBuildUDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2578 LLVMValueRef LLVMBuildSDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2580 LLVMValueRef LLVMBuildExactSDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2582 LLVMValueRef LLVMBuildFDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2584 LLVMValueRef LLVMBuildURem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2586 LLVMValueRef LLVMBuildSRem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2588 LLVMValueRef LLVMBuildFRem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2590 LLVMValueRef LLVMBuildShl(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2592 LLVMValueRef LLVMBuildLShr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2594 LLVMValueRef LLVMBuildAShr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2596 LLVMValueRef LLVMBuildAnd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2598 LLVMValueRef LLVMBuildOr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2600 LLVMValueRef LLVMBuildXor(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2602 LLVMValueRef LLVMBuildBinOp(LLVMBuilderRef B, LLVMOpcode Op,
2603 LLVMValueRef LHS, LLVMValueRef RHS,
2605 LLVMValueRef LLVMBuildNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name);
2606 LLVMValueRef LLVMBuildNSWNeg(LLVMBuilderRef B, LLVMValueRef V,
2608 LLVMValueRef LLVMBuildNUWNeg(LLVMBuilderRef B, LLVMValueRef V,
2610 LLVMValueRef LLVMBuildFNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name);
2611 LLVMValueRef LLVMBuildNot(LLVMBuilderRef, LLVMValueRef V, const char *Name);
2614 LLVMValueRef LLVMBuildMalloc(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
2615 LLVMValueRef LLVMBuildArrayMalloc(LLVMBuilderRef, LLVMTypeRef Ty,
2616 LLVMValueRef Val, const char *Name);
2617 LLVMValueRef LLVMBuildAlloca(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
2618 LLVMValueRef LLVMBuildArrayAlloca(LLVMBuilderRef, LLVMTypeRef Ty,
2619 LLVMValueRef Val, const char *Name);
2620 LLVMValueRef LLVMBuildFree(LLVMBuilderRef, LLVMValueRef PointerVal);
2621 LLVMValueRef LLVMBuildLoad(LLVMBuilderRef, LLVMValueRef PointerVal,
2623 LLVMValueRef LLVMBuildStore(LLVMBuilderRef, LLVMValueRef Val, LLVMValueRef Ptr);
2624 LLVMValueRef LLVMBuildGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
2625 LLVMValueRef *Indices, unsigned NumIndices,
2627 LLVMValueRef LLVMBuildInBoundsGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
2628 LLVMValueRef *Indices, unsigned NumIndices,
2630 LLVMValueRef LLVMBuildStructGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
2631 unsigned Idx, const char *Name);
2632 LLVMValueRef LLVMBuildGlobalString(LLVMBuilderRef B, const char *Str,
2634 LLVMValueRef LLVMBuildGlobalStringPtr(LLVMBuilderRef B, const char *Str,
2636 LLVMBool LLVMGetVolatile(LLVMValueRef MemoryAccessInst);
2637 void LLVMSetVolatile(LLVMValueRef MemoryAccessInst, LLVMBool IsVolatile);
2640 LLVMValueRef LLVMBuildTrunc(LLVMBuilderRef, LLVMValueRef Val,
2641 LLVMTypeRef DestTy, const char *Name);
2642 LLVMValueRef LLVMBuildZExt(LLVMBuilderRef, LLVMValueRef Val,
2643 LLVMTypeRef DestTy, const char *Name);
2644 LLVMValueRef LLVMBuildSExt(LLVMBuilderRef, LLVMValueRef Val,
2645 LLVMTypeRef DestTy, const char *Name);
2646 LLVMValueRef LLVMBuildFPToUI(LLVMBuilderRef, LLVMValueRef Val,
2647 LLVMTypeRef DestTy, const char *Name);
2648 LLVMValueRef LLVMBuildFPToSI(LLVMBuilderRef, LLVMValueRef Val,
2649 LLVMTypeRef DestTy, const char *Name);
2650 LLVMValueRef LLVMBuildUIToFP(LLVMBuilderRef, LLVMValueRef Val,
2651 LLVMTypeRef DestTy, const char *Name);
2652 LLVMValueRef LLVMBuildSIToFP(LLVMBuilderRef, LLVMValueRef Val,
2653 LLVMTypeRef DestTy, const char *Name);
2654 LLVMValueRef LLVMBuildFPTrunc(LLVMBuilderRef, LLVMValueRef Val,
2655 LLVMTypeRef DestTy, const char *Name);
2656 LLVMValueRef LLVMBuildFPExt(LLVMBuilderRef, LLVMValueRef Val,
2657 LLVMTypeRef DestTy, const char *Name);
2658 LLVMValueRef LLVMBuildPtrToInt(LLVMBuilderRef, LLVMValueRef Val,
2659 LLVMTypeRef DestTy, const char *Name);
2660 LLVMValueRef LLVMBuildIntToPtr(LLVMBuilderRef, LLVMValueRef Val,
2661 LLVMTypeRef DestTy, const char *Name);
2662 LLVMValueRef LLVMBuildBitCast(LLVMBuilderRef, LLVMValueRef Val,
2663 LLVMTypeRef DestTy, const char *Name);
2664 LLVMValueRef LLVMBuildAddrSpaceCast(LLVMBuilderRef, LLVMValueRef Val,
2665 LLVMTypeRef DestTy, const char *Name);
2666 LLVMValueRef LLVMBuildZExtOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
2667 LLVMTypeRef DestTy, const char *Name);
2668 LLVMValueRef LLVMBuildSExtOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
2669 LLVMTypeRef DestTy, const char *Name);
2670 LLVMValueRef LLVMBuildTruncOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
2671 LLVMTypeRef DestTy, const char *Name);
2672 LLVMValueRef LLVMBuildCast(LLVMBuilderRef B, LLVMOpcode Op, LLVMValueRef Val,
2673 LLVMTypeRef DestTy, const char *Name);
2674 LLVMValueRef LLVMBuildPointerCast(LLVMBuilderRef, LLVMValueRef Val,
2675 LLVMTypeRef DestTy, const char *Name);
2676 LLVMValueRef LLVMBuildIntCast(LLVMBuilderRef, LLVMValueRef Val, /*Signed cast!*/
2677 LLVMTypeRef DestTy, const char *Name);
2678 LLVMValueRef LLVMBuildFPCast(LLVMBuilderRef, LLVMValueRef Val,
2679 LLVMTypeRef DestTy, const char *Name);
2682 LLVMValueRef LLVMBuildICmp(LLVMBuilderRef, LLVMIntPredicate Op,
2683 LLVMValueRef LHS, LLVMValueRef RHS,
2685 LLVMValueRef LLVMBuildFCmp(LLVMBuilderRef, LLVMRealPredicate Op,
2686 LLVMValueRef LHS, LLVMValueRef RHS,
2689 /* Miscellaneous instructions */
2690 LLVMValueRef LLVMBuildPhi(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
2691 LLVMValueRef LLVMBuildCall(LLVMBuilderRef, LLVMValueRef Fn,
2692 LLVMValueRef *Args, unsigned NumArgs,
2694 LLVMValueRef LLVMBuildSelect(LLVMBuilderRef, LLVMValueRef If,
2695 LLVMValueRef Then, LLVMValueRef Else,
2697 LLVMValueRef LLVMBuildVAArg(LLVMBuilderRef, LLVMValueRef List, LLVMTypeRef Ty,
2699 LLVMValueRef LLVMBuildExtractElement(LLVMBuilderRef, LLVMValueRef VecVal,
2700 LLVMValueRef Index, const char *Name);
2701 LLVMValueRef LLVMBuildInsertElement(LLVMBuilderRef, LLVMValueRef VecVal,
2702 LLVMValueRef EltVal, LLVMValueRef Index,
2704 LLVMValueRef LLVMBuildShuffleVector(LLVMBuilderRef, LLVMValueRef V1,
2705 LLVMValueRef V2, LLVMValueRef Mask,
2707 LLVMValueRef LLVMBuildExtractValue(LLVMBuilderRef, LLVMValueRef AggVal,
2708 unsigned Index, const char *Name);
2709 LLVMValueRef LLVMBuildInsertValue(LLVMBuilderRef, LLVMValueRef AggVal,
2710 LLVMValueRef EltVal, unsigned Index,
2713 LLVMValueRef LLVMBuildIsNull(LLVMBuilderRef, LLVMValueRef Val,
2715 LLVMValueRef LLVMBuildIsNotNull(LLVMBuilderRef, LLVMValueRef Val,
2717 LLVMValueRef LLVMBuildPtrDiff(LLVMBuilderRef, LLVMValueRef LHS,
2718 LLVMValueRef RHS, const char *Name);
2719 LLVMValueRef LLVMBuildFence(LLVMBuilderRef B, LLVMAtomicOrdering ordering,
2720 LLVMBool singleThread, const char *Name);
2721 LLVMValueRef LLVMBuildAtomicRMW(LLVMBuilderRef B, LLVMAtomicRMWBinOp op,
2722 LLVMValueRef PTR, LLVMValueRef Val,
2723 LLVMAtomicOrdering ordering,
2724 LLVMBool singleThread);
2731 * @defgroup LLVMCCoreModuleProvider Module Providers
2737 * Changes the type of M so it can be passed to FunctionPassManagers and the
2738 * JIT. They take ModuleProviders for historical reasons.
2740 LLVMModuleProviderRef
2741 LLVMCreateModuleProviderForExistingModule(LLVMModuleRef M);
2744 * Destroys the module M.
2746 void LLVMDisposeModuleProvider(LLVMModuleProviderRef M);
2753 * @defgroup LLVMCCoreMemoryBuffers Memory Buffers
2758 LLVMBool LLVMCreateMemoryBufferWithContentsOfFile(const char *Path,
2759 LLVMMemoryBufferRef *OutMemBuf,
2761 LLVMBool LLVMCreateMemoryBufferWithSTDIN(LLVMMemoryBufferRef *OutMemBuf,
2763 LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRange(const char *InputData,
2764 size_t InputDataLength,
2765 const char *BufferName,
2766 LLVMBool RequiresNullTerminator);
2767 LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRangeCopy(const char *InputData,
2768 size_t InputDataLength,
2769 const char *BufferName);
2770 const char *LLVMGetBufferStart(LLVMMemoryBufferRef MemBuf);
2771 size_t LLVMGetBufferSize(LLVMMemoryBufferRef MemBuf);
2772 void LLVMDisposeMemoryBuffer(LLVMMemoryBufferRef MemBuf);
2779 * @defgroup LLVMCCorePassRegistry Pass Registry
2784 /** Return the global pass registry, for use with initialization functions.
2785 @see llvm::PassRegistry::getPassRegistry */
2786 LLVMPassRegistryRef LLVMGetGlobalPassRegistry(void);
2793 * @defgroup LLVMCCorePassManagers Pass Managers
2798 /** Constructs a new whole-module pass pipeline. This type of pipeline is
2799 suitable for link-time optimization and whole-module transformations.
2800 @see llvm::PassManager::PassManager */
2801 LLVMPassManagerRef LLVMCreatePassManager(void);
2803 /** Constructs a new function-by-function pass pipeline over the module
2804 provider. It does not take ownership of the module provider. This type of
2805 pipeline is suitable for code generation and JIT compilation tasks.
2806 @see llvm::FunctionPassManager::FunctionPassManager */
2807 LLVMPassManagerRef LLVMCreateFunctionPassManagerForModule(LLVMModuleRef M);
2809 /** Deprecated: Use LLVMCreateFunctionPassManagerForModule instead. */
2810 LLVMPassManagerRef LLVMCreateFunctionPassManager(LLVMModuleProviderRef MP);
2812 /** Initializes, executes on the provided module, and finalizes all of the
2813 passes scheduled in the pass manager. Returns 1 if any of the passes
2814 modified the module, 0 otherwise.
2815 @see llvm::PassManager::run(Module&) */
2816 LLVMBool LLVMRunPassManager(LLVMPassManagerRef PM, LLVMModuleRef M);
2818 /** Initializes all of the function passes scheduled in the function pass
2819 manager. Returns 1 if any of the passes modified the module, 0 otherwise.
2820 @see llvm::FunctionPassManager::doInitialization */
2821 LLVMBool LLVMInitializeFunctionPassManager(LLVMPassManagerRef FPM);
2823 /** Executes all of the function passes scheduled in the function pass manager
2824 on the provided function. Returns 1 if any of the passes modified the
2825 function, false otherwise.
2826 @see llvm::FunctionPassManager::run(Function&) */
2827 LLVMBool LLVMRunFunctionPassManager(LLVMPassManagerRef FPM, LLVMValueRef F);
2829 /** Finalizes all of the function passes scheduled in in the function pass
2830 manager. Returns 1 if any of the passes modified the module, 0 otherwise.
2831 @see llvm::FunctionPassManager::doFinalization */
2832 LLVMBool LLVMFinalizeFunctionPassManager(LLVMPassManagerRef FPM);
2834 /** Frees the memory of a pass pipeline. For function pipelines, does not free
2835 the module provider.
2836 @see llvm::PassManagerBase::~PassManagerBase. */
2837 void LLVMDisposePassManager(LLVMPassManagerRef PM);
2844 * @defgroup LLVMCCoreThreading Threading
2846 * Handle the structures needed to make LLVM safe for multithreading.
2851 /** Deprecated: Multi-threading can only be enabled/disabled with the compile
2852 time define LLVM_ENABLE_THREADS. This function always returns
2853 LLVMIsMultithreaded(). */
2854 LLVMBool LLVMStartMultithreaded(void);
2856 /** Deprecated: Multi-threading can only be enabled/disabled with the compile
2857 time define LLVM_ENABLE_THREADS. */
2858 void LLVMStopMultithreaded(void);
2860 /** Check whether LLVM is executing in thread-safe mode or not.
2861 @see llvm::llvm_is_multithreaded */
2862 LLVMBool LLVMIsMultithreaded(void);
2878 #endif /* !defined(__cplusplus) */
2880 #endif /* !defined(LLVM_C_CORE_H) */