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::Pass */
116 typedef struct LLVMOpaquePass *LLVMPassRef;
118 /** @see llvm::PassManagerBase */
119 typedef struct LLVMOpaquePassManager *LLVMPassManagerRef;
121 /** @see llvm::PassRegistry */
122 typedef struct LLVMOpaquePassRegistry *LLVMPassRegistryRef;
124 /** @see llvm::PassRunListener */
125 typedef struct LLVMOpaquePassRunListener *LLVMPassRunListenerRef;
127 /** @see llvm::LLVMPassRunListener */
128 typedef void (*LLVMPassRunListenerHandlerTy)(LLVMContextRef, LLVMPassRef,
129 LLVMModuleRef, LLVMValueRef,
133 * Used to get the users and usees of a Value.
136 typedef struct LLVMOpaqueUse *LLVMUseRef;
140 * @see llvm::DiagnosticInfo
142 typedef struct LLVMOpaqueDiagnosticInfo *LLVMDiagnosticInfoRef;
145 LLVMZExtAttribute = 1<<0,
146 LLVMSExtAttribute = 1<<1,
147 LLVMNoReturnAttribute = 1<<2,
148 LLVMInRegAttribute = 1<<3,
149 LLVMStructRetAttribute = 1<<4,
150 LLVMNoUnwindAttribute = 1<<5,
151 LLVMNoAliasAttribute = 1<<6,
152 LLVMByValAttribute = 1<<7,
153 LLVMNestAttribute = 1<<8,
154 LLVMReadNoneAttribute = 1<<9,
155 LLVMReadOnlyAttribute = 1<<10,
156 LLVMNoInlineAttribute = 1<<11,
157 LLVMAlwaysInlineAttribute = 1<<12,
158 LLVMOptimizeForSizeAttribute = 1<<13,
159 LLVMStackProtectAttribute = 1<<14,
160 LLVMStackProtectReqAttribute = 1<<15,
161 LLVMAlignment = 31<<16,
162 LLVMNoCaptureAttribute = 1<<21,
163 LLVMNoRedZoneAttribute = 1<<22,
164 LLVMNoImplicitFloatAttribute = 1<<23,
165 LLVMNakedAttribute = 1<<24,
166 LLVMInlineHintAttribute = 1<<25,
167 LLVMStackAlignment = 7<<26,
168 LLVMReturnsTwice = 1 << 29,
169 LLVMUWTable = 1 << 30,
170 LLVMNonLazyBind = 1 << 31
172 /* FIXME: These attributes are currently not included in the C API as
173 a temporary measure until the API/ABI impact to the C API is understood
174 and the path forward agreed upon.
175 LLVMAddressSafety = 1ULL << 32,
176 LLVMStackProtectStrongAttribute = 1ULL<<33,
177 LLVMCold = 1ULL << 34,
178 LLVMOptimizeNone = 1ULL << 35,
179 LLVMInAllocaAttribute = 1ULL << 36
184 /* Terminator Instructions */
190 /* removed 6 due to API changes */
193 /* Standard Binary Operators */
207 /* Logical Operators */
215 /* Memory Operators */
219 LLVMGetElementPtr = 29,
234 LLVMAddrSpaceCast = 60,
236 /* Other Operators */
245 LLVMExtractElement = 50,
246 LLVMInsertElement = 51,
247 LLVMShuffleVector = 52,
248 LLVMExtractValue = 53,
249 LLVMInsertValue = 54,
251 /* Atomic operators */
253 LLVMAtomicCmpXchg = 56,
256 /* Exception Handling Operators */
263 LLVMVoidTypeKind, /**< type with no size */
264 LLVMHalfTypeKind, /**< 16 bit floating point type */
265 LLVMFloatTypeKind, /**< 32 bit floating point type */
266 LLVMDoubleTypeKind, /**< 64 bit floating point type */
267 LLVMX86_FP80TypeKind, /**< 80 bit floating point type (X87) */
268 LLVMFP128TypeKind, /**< 128 bit floating point type (112-bit mantissa)*/
269 LLVMPPC_FP128TypeKind, /**< 128 bit floating point type (two 64-bits) */
270 LLVMLabelTypeKind, /**< Labels */
271 LLVMIntegerTypeKind, /**< Arbitrary bit width integers */
272 LLVMFunctionTypeKind, /**< Functions */
273 LLVMStructTypeKind, /**< Structures */
274 LLVMArrayTypeKind, /**< Arrays */
275 LLVMPointerTypeKind, /**< Pointers */
276 LLVMVectorTypeKind, /**< SIMD 'packed' format, or other vector type */
277 LLVMMetadataTypeKind, /**< Metadata */
278 LLVMX86_MMXTypeKind /**< X86 MMX */
282 LLVMExternalLinkage, /**< Externally visible function */
283 LLVMAvailableExternallyLinkage,
284 LLVMLinkOnceAnyLinkage, /**< Keep one copy of function when linking (inline)*/
285 LLVMLinkOnceODRLinkage, /**< Same, but only replaced by something
287 LLVMLinkOnceODRAutoHideLinkage, /**< Obsolete */
288 LLVMWeakAnyLinkage, /**< Keep one copy of function when linking (weak) */
289 LLVMWeakODRLinkage, /**< Same, but only replaced by something
291 LLVMAppendingLinkage, /**< Special purpose, only applies to global arrays */
292 LLVMInternalLinkage, /**< Rename collisions when linking (static
294 LLVMPrivateLinkage, /**< Like Internal, but omit from symbol table */
295 LLVMDLLImportLinkage, /**< Obsolete */
296 LLVMDLLExportLinkage, /**< Obsolete */
297 LLVMExternalWeakLinkage,/**< ExternalWeak linkage description */
298 LLVMGhostLinkage, /**< Obsolete */
299 LLVMCommonLinkage, /**< Tentative definitions */
300 LLVMLinkerPrivateLinkage, /**< Like Private, but linker removes. */
301 LLVMLinkerPrivateWeakLinkage /**< Like LinkerPrivate, but is weak. */
305 LLVMDefaultVisibility, /**< The GV is visible */
306 LLVMHiddenVisibility, /**< The GV is hidden */
307 LLVMProtectedVisibility /**< The GV is protected */
311 LLVMDefaultStorageClass = 0,
312 LLVMDLLImportStorageClass = 1, /**< Function to be imported from DLL. */
313 LLVMDLLExportStorageClass = 2 /**< Function to be accessible from DLL. */
314 } LLVMDLLStorageClass;
318 LLVMFastCallConv = 8,
319 LLVMColdCallConv = 9,
320 LLVMWebKitJSCallConv = 12,
321 LLVMAnyRegCallConv = 13,
322 LLVMX86StdcallCallConv = 64,
323 LLVMX86FastcallCallConv = 65
327 LLVMIntEQ = 32, /**< equal */
328 LLVMIntNE, /**< not equal */
329 LLVMIntUGT, /**< unsigned greater than */
330 LLVMIntUGE, /**< unsigned greater or equal */
331 LLVMIntULT, /**< unsigned less than */
332 LLVMIntULE, /**< unsigned less or equal */
333 LLVMIntSGT, /**< signed greater than */
334 LLVMIntSGE, /**< signed greater or equal */
335 LLVMIntSLT, /**< signed less than */
336 LLVMIntSLE /**< signed less or equal */
340 LLVMRealPredicateFalse, /**< Always false (always folded) */
341 LLVMRealOEQ, /**< True if ordered and equal */
342 LLVMRealOGT, /**< True if ordered and greater than */
343 LLVMRealOGE, /**< True if ordered and greater than or equal */
344 LLVMRealOLT, /**< True if ordered and less than */
345 LLVMRealOLE, /**< True if ordered and less than or equal */
346 LLVMRealONE, /**< True if ordered and operands are unequal */
347 LLVMRealORD, /**< True if ordered (no nans) */
348 LLVMRealUNO, /**< True if unordered: isnan(X) | isnan(Y) */
349 LLVMRealUEQ, /**< True if unordered or equal */
350 LLVMRealUGT, /**< True if unordered or greater than */
351 LLVMRealUGE, /**< True if unordered, greater than, or equal */
352 LLVMRealULT, /**< True if unordered or less than */
353 LLVMRealULE, /**< True if unordered, less than, or equal */
354 LLVMRealUNE, /**< True if unordered or not equal */
355 LLVMRealPredicateTrue /**< Always true (always folded) */
359 LLVMLandingPadCatch, /**< A catch clause */
360 LLVMLandingPadFilter /**< A filter clause */
361 } LLVMLandingPadClauseTy;
364 LLVMNotThreadLocal = 0,
365 LLVMGeneralDynamicTLSModel,
366 LLVMLocalDynamicTLSModel,
367 LLVMInitialExecTLSModel,
368 LLVMLocalExecTLSModel
369 } LLVMThreadLocalMode;
372 LLVMAtomicOrderingNotAtomic = 0, /**< A load or store which is not atomic */
373 LLVMAtomicOrderingUnordered = 1, /**< Lowest level of atomicity, guarantees
374 somewhat sane results, lock free. */
375 LLVMAtomicOrderingMonotonic = 2, /**< guarantees that if you take all the
376 operations affecting a specific address,
377 a consistent ordering exists */
378 LLVMAtomicOrderingAcquire = 4, /**< Acquire provides a barrier of the sort
379 necessary to acquire a lock to access other
380 memory with normal loads and stores. */
381 LLVMAtomicOrderingRelease = 5, /**< Release is similar to Acquire, but with
382 a barrier of the sort necessary to release
384 LLVMAtomicOrderingAcquireRelease = 6, /**< provides both an Acquire and a
385 Release barrier (for fences and
386 operations which both read and write
388 LLVMAtomicOrderingSequentiallyConsistent = 7 /**< provides Acquire semantics
389 for loads and Release
390 semantics for stores.
391 Additionally, it guarantees
392 that a total ordering exists
394 SequentiallyConsistent
396 } LLVMAtomicOrdering;
399 LLVMAtomicRMWBinOpXchg, /**< Set the new value and return the one old */
400 LLVMAtomicRMWBinOpAdd, /**< Add a value and return the old one */
401 LLVMAtomicRMWBinOpSub, /**< Subtract a value and return the old one */
402 LLVMAtomicRMWBinOpAnd, /**< And a value and return the old one */
403 LLVMAtomicRMWBinOpNand, /**< Not-And a value and return the old one */
404 LLVMAtomicRMWBinOpOr, /**< OR a value and return the old one */
405 LLVMAtomicRMWBinOpXor, /**< Xor a value and return the old one */
406 LLVMAtomicRMWBinOpMax, /**< Sets the value if it's greater than the
407 original using a signed comparison and return
409 LLVMAtomicRMWBinOpMin, /**< Sets the value if it's Smaller than the
410 original using a signed comparison and return
412 LLVMAtomicRMWBinOpUMax, /**< Sets the value if it's greater than the
413 original using an unsigned comparison and return
415 LLVMAtomicRMWBinOpUMin /**< Sets the value if it's greater than the
416 original using an unsigned comparison and return
418 } LLVMAtomicRMWBinOp;
425 } LLVMDiagnosticSeverity;
431 void LLVMInitializeCore(LLVMPassRegistryRef R);
433 /** Deallocate and destroy all ManagedStatic variables.
434 @see llvm::llvm_shutdown
435 @see ManagedStatic */
436 void LLVMShutdown(void);
439 /*===-- Error handling ----------------------------------------------------===*/
441 char *LLVMCreateMessage(const char *Message);
442 void LLVMDisposeMessage(char *Message);
444 typedef void (*LLVMFatalErrorHandler)(const char *Reason);
447 * Install a fatal error handler. By default, if LLVM detects a fatal error, it
448 * will call exit(1). This may not be appropriate in many contexts. For example,
449 * doing exit(1) will bypass many crash reporting/tracing system tools. This
450 * function allows you to install a callback that will be invoked prior to the
453 void LLVMInstallFatalErrorHandler(LLVMFatalErrorHandler Handler);
456 * Reset the fatal error handler. This resets LLVM's fatal error handling
457 * behavior to the default.
459 void LLVMResetFatalErrorHandler(void);
462 * Enable LLVM's built-in stack trace code. This intercepts the OS's crash
463 * signals and prints which component of LLVM you were in at the time if the
466 void LLVMEnablePrettyStackTrace(void);
469 * @defgroup LLVMCCoreContext Contexts
471 * Contexts are execution states for the core LLVM IR system.
473 * Most types are tied to a context instance. Multiple contexts can
474 * exist simultaneously. A single context is not thread safe. However,
475 * different contexts can execute on different threads simultaneously.
480 typedef void (*LLVMDiagnosticHandler)(LLVMDiagnosticInfoRef, void *);
483 * Create a new context.
485 * Every call to this function should be paired with a call to
486 * LLVMContextDispose() or the context will leak memory.
488 LLVMContextRef LLVMContextCreate(void);
491 * Obtain the global context instance.
493 LLVMContextRef LLVMGetGlobalContext(void);
496 * Set the diagnostic handler for this context.
498 void LLVMContextSetDiagnosticHandler(LLVMContextRef C,
499 LLVMDiagnosticHandler Handler,
500 void *DiagnosticContext);
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);
529 LLVMPassRunListenerRef LLVMAddPassRunListener(LLVMContextRef,
530 LLVMPassRunListenerHandlerTy);
531 void LLVMRemovePassRunListener(LLVMContextRef, LLVMPassRunListenerRef);
538 * @defgroup LLVMCCoreModule Modules
540 * Modules represent the top-level structure in an LLVM program. An LLVM
541 * module is effectively a translation unit or a collection of
542 * translation units merged together.
548 * Create a new, empty module in the global context.
550 * This is equivalent to calling LLVMModuleCreateWithNameInContext with
551 * LLVMGetGlobalContext() as the context parameter.
553 * Every invocation should be paired with LLVMDisposeModule() or memory
556 LLVMModuleRef LLVMModuleCreateWithName(const char *ModuleID);
559 * Create a new, empty module in a specific context.
561 * Every invocation should be paired with LLVMDisposeModule() or memory
564 LLVMModuleRef LLVMModuleCreateWithNameInContext(const char *ModuleID,
568 * Destroy a module instance.
570 * This must be called for every created module or memory will be
573 void LLVMDisposeModule(LLVMModuleRef M);
576 * Obtain the data layout for a module.
578 * @see Module::getDataLayout()
580 const char *LLVMGetDataLayout(LLVMModuleRef M);
583 * Set the data layout for a module.
585 * @see Module::setDataLayout()
587 void LLVMSetDataLayout(LLVMModuleRef M, const char *Triple);
590 * Obtain the target triple for a module.
592 * @see Module::getTargetTriple()
594 const char *LLVMGetTarget(LLVMModuleRef M);
597 * Set the target triple for a module.
599 * @see Module::setTargetTriple()
601 void LLVMSetTarget(LLVMModuleRef M, const char *Triple);
604 * Dump a representation of a module to stderr.
606 * @see Module::dump()
608 void LLVMDumpModule(LLVMModuleRef M);
611 * Print a representation of a module to a file. The ErrorMessage needs to be
612 * disposed with LLVMDisposeMessage. Returns 0 on success, 1 otherwise.
614 * @see Module::print()
616 LLVMBool LLVMPrintModuleToFile(LLVMModuleRef M, const char *Filename,
617 char **ErrorMessage);
620 * Return a string representation of the module. Use
621 * LLVMDisposeMessage to free the string.
623 * @see Module::print()
625 char *LLVMPrintModuleToString(LLVMModuleRef M);
628 * Set inline assembly for a module.
630 * @see Module::setModuleInlineAsm()
632 void LLVMSetModuleInlineAsm(LLVMModuleRef M, const char *Asm);
635 * Obtain the context to which this module is associated.
637 * @see Module::getContext()
639 LLVMContextRef LLVMGetModuleContext(LLVMModuleRef M);
642 * Obtain a Type from a module by its registered name.
644 LLVMTypeRef LLVMGetTypeByName(LLVMModuleRef M, const char *Name);
647 * Obtain the number of operands for named metadata in a module.
649 * @see llvm::Module::getNamedMetadata()
651 unsigned LLVMGetNamedMetadataNumOperands(LLVMModuleRef M, const char* name);
654 * Obtain the named metadata operands for a module.
656 * The passed LLVMValueRef pointer should refer to an array of
657 * LLVMValueRef at least LLVMGetNamedMetadataNumOperands long. This
658 * array will be populated with the LLVMValueRef instances. Each
659 * instance corresponds to a llvm::MDNode.
661 * @see llvm::Module::getNamedMetadata()
662 * @see llvm::MDNode::getOperand()
664 void LLVMGetNamedMetadataOperands(LLVMModuleRef M, const char* name, LLVMValueRef *Dest);
667 * Add an operand to named metadata.
669 * @see llvm::Module::getNamedMetadata()
670 * @see llvm::MDNode::addOperand()
672 void LLVMAddNamedMetadataOperand(LLVMModuleRef M, const char* name,
676 * Add a function to a module under a specified name.
678 * @see llvm::Function::Create()
680 LLVMValueRef LLVMAddFunction(LLVMModuleRef M, const char *Name,
681 LLVMTypeRef FunctionTy);
684 * Obtain a Function value from a Module by its name.
686 * The returned value corresponds to a llvm::Function value.
688 * @see llvm::Module::getFunction()
690 LLVMValueRef LLVMGetNamedFunction(LLVMModuleRef M, const char *Name);
693 * Obtain an iterator to the first Function in a Module.
695 * @see llvm::Module::begin()
697 LLVMValueRef LLVMGetFirstFunction(LLVMModuleRef M);
700 * Obtain an iterator to the last Function in a Module.
702 * @see llvm::Module::end()
704 LLVMValueRef LLVMGetLastFunction(LLVMModuleRef M);
707 * Advance a Function iterator to the next Function.
709 * Returns NULL if the iterator was already at the end and there are no more
712 LLVMValueRef LLVMGetNextFunction(LLVMValueRef Fn);
715 * Decrement a Function iterator to the previous Function.
717 * Returns NULL if the iterator was already at the beginning and there are
718 * no previous functions.
720 LLVMValueRef LLVMGetPreviousFunction(LLVMValueRef Fn);
727 * @defgroup LLVMCCoreType Types
729 * Types represent the type of a value.
731 * Types are associated with a context instance. The context internally
732 * deduplicates types so there is only 1 instance of a specific type
733 * alive at a time. In other words, a unique type is shared among all
734 * consumers within a context.
736 * A Type in the C API corresponds to llvm::Type.
738 * Types have the following hierarchy:
756 * Obtain the enumerated type of a Type instance.
758 * @see llvm::Type:getTypeID()
760 LLVMTypeKind LLVMGetTypeKind(LLVMTypeRef Ty);
763 * Whether the type has a known size.
765 * Things that don't have a size are abstract types, labels, and void.a
767 * @see llvm::Type::isSized()
769 LLVMBool LLVMTypeIsSized(LLVMTypeRef Ty);
772 * Obtain the context to which this type instance is associated.
774 * @see llvm::Type::getContext()
776 LLVMContextRef LLVMGetTypeContext(LLVMTypeRef Ty);
779 * Dump a representation of a type to stderr.
781 * @see llvm::Type::dump()
783 void LLVMDumpType(LLVMTypeRef Val);
786 * Return a string representation of the type. Use
787 * LLVMDisposeMessage to free the string.
789 * @see llvm::Type::print()
791 char *LLVMPrintTypeToString(LLVMTypeRef Val);
794 * @defgroup LLVMCCoreTypeInt Integer Types
796 * Functions in this section operate on integer types.
802 * Obtain an integer type from a context with specified bit width.
804 LLVMTypeRef LLVMInt1TypeInContext(LLVMContextRef C);
805 LLVMTypeRef LLVMInt8TypeInContext(LLVMContextRef C);
806 LLVMTypeRef LLVMInt16TypeInContext(LLVMContextRef C);
807 LLVMTypeRef LLVMInt32TypeInContext(LLVMContextRef C);
808 LLVMTypeRef LLVMInt64TypeInContext(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 LLVMIntType(unsigned NumBits);
821 unsigned LLVMGetIntTypeWidth(LLVMTypeRef IntegerTy);
828 * @defgroup LLVMCCoreTypeFloat Floating Point Types
834 * Obtain a 16-bit floating point type from a context.
836 LLVMTypeRef LLVMHalfTypeInContext(LLVMContextRef C);
839 * Obtain a 32-bit floating point type from a context.
841 LLVMTypeRef LLVMFloatTypeInContext(LLVMContextRef C);
844 * Obtain a 64-bit floating point type from a context.
846 LLVMTypeRef LLVMDoubleTypeInContext(LLVMContextRef C);
849 * Obtain a 80-bit floating point type (X87) from a context.
851 LLVMTypeRef LLVMX86FP80TypeInContext(LLVMContextRef C);
854 * Obtain a 128-bit floating point type (112-bit mantissa) from a
857 LLVMTypeRef LLVMFP128TypeInContext(LLVMContextRef C);
860 * Obtain a 128-bit floating point type (two 64-bits) from a context.
862 LLVMTypeRef LLVMPPCFP128TypeInContext(LLVMContextRef C);
865 * Obtain a floating point type from the global context.
867 * These map to the functions in this group of the same name.
869 LLVMTypeRef LLVMHalfType(void);
870 LLVMTypeRef LLVMFloatType(void);
871 LLVMTypeRef LLVMDoubleType(void);
872 LLVMTypeRef LLVMX86FP80Type(void);
873 LLVMTypeRef LLVMFP128Type(void);
874 LLVMTypeRef LLVMPPCFP128Type(void);
881 * @defgroup LLVMCCoreTypeFunction Function Types
887 * Obtain a function type consisting of a specified signature.
889 * The function is defined as a tuple of a return Type, a list of
890 * parameter types, and whether the function is variadic.
892 LLVMTypeRef LLVMFunctionType(LLVMTypeRef ReturnType,
893 LLVMTypeRef *ParamTypes, unsigned ParamCount,
897 * Returns whether a function type is variadic.
899 LLVMBool LLVMIsFunctionVarArg(LLVMTypeRef FunctionTy);
902 * Obtain the Type this function Type returns.
904 LLVMTypeRef LLVMGetReturnType(LLVMTypeRef FunctionTy);
907 * Obtain the number of parameters this function accepts.
909 unsigned LLVMCountParamTypes(LLVMTypeRef FunctionTy);
912 * Obtain the types of a function's parameters.
914 * The Dest parameter should point to a pre-allocated array of
915 * LLVMTypeRef at least LLVMCountParamTypes() large. On return, the
916 * first LLVMCountParamTypes() entries in the array will be populated
917 * with LLVMTypeRef instances.
919 * @param FunctionTy The function type to operate on.
920 * @param Dest Memory address of an array to be filled with result.
922 void LLVMGetParamTypes(LLVMTypeRef FunctionTy, LLVMTypeRef *Dest);
929 * @defgroup LLVMCCoreTypeStruct Structure Types
931 * These functions relate to LLVMTypeRef instances.
933 * @see llvm::StructType
939 * Create a new structure type in a context.
941 * A structure is specified by a list of inner elements/types and
942 * whether these can be packed together.
944 * @see llvm::StructType::create()
946 LLVMTypeRef LLVMStructTypeInContext(LLVMContextRef C, LLVMTypeRef *ElementTypes,
947 unsigned ElementCount, LLVMBool Packed);
950 * Create a new structure type in the global context.
952 * @see llvm::StructType::create()
954 LLVMTypeRef LLVMStructType(LLVMTypeRef *ElementTypes, unsigned ElementCount,
958 * Create an empty structure in a context having a specified name.
960 * @see llvm::StructType::create()
962 LLVMTypeRef LLVMStructCreateNamed(LLVMContextRef C, const char *Name);
965 * Obtain the name of a structure.
967 * @see llvm::StructType::getName()
969 const char *LLVMGetStructName(LLVMTypeRef Ty);
972 * Set the contents of a structure type.
974 * @see llvm::StructType::setBody()
976 void LLVMStructSetBody(LLVMTypeRef StructTy, LLVMTypeRef *ElementTypes,
977 unsigned ElementCount, LLVMBool Packed);
980 * Get the number of elements defined inside the structure.
982 * @see llvm::StructType::getNumElements()
984 unsigned LLVMCountStructElementTypes(LLVMTypeRef StructTy);
987 * Get the elements within a structure.
989 * The function is passed the address of a pre-allocated array of
990 * LLVMTypeRef at least LLVMCountStructElementTypes() long. After
991 * invocation, this array will be populated with the structure's
992 * elements. The objects in the destination array will have a lifetime
993 * of the structure type itself, which is the lifetime of the context it
996 void LLVMGetStructElementTypes(LLVMTypeRef StructTy, LLVMTypeRef *Dest);
999 * Determine whether a structure is packed.
1001 * @see llvm::StructType::isPacked()
1003 LLVMBool LLVMIsPackedStruct(LLVMTypeRef StructTy);
1006 * Determine whether a structure is opaque.
1008 * @see llvm::StructType::isOpaque()
1010 LLVMBool LLVMIsOpaqueStruct(LLVMTypeRef StructTy);
1018 * @defgroup LLVMCCoreTypeSequential Sequential Types
1020 * Sequential types represents "arrays" of types. This is a super class
1021 * for array, vector, and pointer types.
1027 * Obtain the type of elements within a sequential type.
1029 * This works on array, vector, and pointer types.
1031 * @see llvm::SequentialType::getElementType()
1033 LLVMTypeRef LLVMGetElementType(LLVMTypeRef Ty);
1036 * Create a fixed size array type that refers to a specific type.
1038 * The created type will exist in the context that its element type
1041 * @see llvm::ArrayType::get()
1043 LLVMTypeRef LLVMArrayType(LLVMTypeRef ElementType, unsigned ElementCount);
1046 * Obtain the length of an array type.
1048 * This only works on types that represent arrays.
1050 * @see llvm::ArrayType::getNumElements()
1052 unsigned LLVMGetArrayLength(LLVMTypeRef ArrayTy);
1055 * Create a pointer type that points to a defined type.
1057 * The created type will exist in the context that its pointee type
1060 * @see llvm::PointerType::get()
1062 LLVMTypeRef LLVMPointerType(LLVMTypeRef ElementType, unsigned AddressSpace);
1065 * Obtain the address space of a pointer type.
1067 * This only works on types that represent pointers.
1069 * @see llvm::PointerType::getAddressSpace()
1071 unsigned LLVMGetPointerAddressSpace(LLVMTypeRef PointerTy);
1074 * Create a vector type that contains a defined type and has a specific
1075 * number of elements.
1077 * The created type will exist in the context thats its element type
1080 * @see llvm::VectorType::get()
1082 LLVMTypeRef LLVMVectorType(LLVMTypeRef ElementType, unsigned ElementCount);
1085 * Obtain the number of elements in a vector type.
1087 * This only works on types that represent vectors.
1089 * @see llvm::VectorType::getNumElements()
1091 unsigned LLVMGetVectorSize(LLVMTypeRef VectorTy);
1098 * @defgroup LLVMCCoreTypeOther Other Types
1104 * Create a void type in a context.
1106 LLVMTypeRef LLVMVoidTypeInContext(LLVMContextRef C);
1109 * Create a label type in a context.
1111 LLVMTypeRef LLVMLabelTypeInContext(LLVMContextRef C);
1114 * Create a X86 MMX type in a context.
1116 LLVMTypeRef LLVMX86MMXTypeInContext(LLVMContextRef C);
1119 * These are similar to the above functions except they operate on the
1122 LLVMTypeRef LLVMVoidType(void);
1123 LLVMTypeRef LLVMLabelType(void);
1124 LLVMTypeRef LLVMX86MMXType(void);
1135 * @defgroup LLVMCCoreValues Values
1137 * The bulk of LLVM's object model consists of values, which comprise a very
1138 * rich type hierarchy.
1140 * LLVMValueRef essentially represents llvm::Value. There is a rich
1141 * hierarchy of classes within this type. Depending on the instance
1142 * obtained, not all APIs are available.
1144 * Callers can determine the type of an LLVMValueRef by calling the
1145 * LLVMIsA* family of functions (e.g. LLVMIsAArgument()). These
1146 * functions are defined by a macro, so it isn't obvious which are
1147 * available by looking at the Doxygen source code. Instead, look at the
1148 * source definition of LLVM_FOR_EACH_VALUE_SUBCLASS and note the list
1149 * of value names given. These value names also correspond to classes in
1150 * the llvm::Value hierarchy.
1155 #define LLVM_FOR_EACH_VALUE_SUBCLASS(macro) \
1163 macro(BlockAddress) \
1164 macro(ConstantAggregateZero) \
1165 macro(ConstantArray) \
1166 macro(ConstantDataSequential) \
1167 macro(ConstantDataArray) \
1168 macro(ConstantDataVector) \
1169 macro(ConstantExpr) \
1171 macro(ConstantInt) \
1172 macro(ConstantPointerNull) \
1173 macro(ConstantStruct) \
1174 macro(ConstantVector) \
1175 macro(GlobalValue) \
1176 macro(GlobalAlias) \
1177 macro(GlobalObject) \
1179 macro(GlobalVariable) \
1181 macro(Instruction) \
1182 macro(BinaryOperator) \
1184 macro(IntrinsicInst) \
1185 macro(DbgInfoIntrinsic) \
1186 macro(DbgDeclareInst) \
1187 macro(MemIntrinsic) \
1189 macro(MemMoveInst) \
1194 macro(ExtractElementInst) \
1195 macro(GetElementPtrInst) \
1196 macro(InsertElementInst) \
1197 macro(InsertValueInst) \
1198 macro(LandingPadInst) \
1201 macro(ShuffleVectorInst) \
1203 macro(TerminatorInst) \
1205 macro(IndirectBrInst) \
1209 macro(UnreachableInst) \
1211 macro(UnaryInstruction) \
1214 macro(AddrSpaceCastInst) \
1215 macro(BitCastInst) \
1219 macro(FPTruncInst) \
1220 macro(IntToPtrInst) \
1221 macro(PtrToIntInst) \
1227 macro(ExtractValueInst) \
1232 * @defgroup LLVMCCoreValueGeneral General APIs
1234 * Functions in this section work on all LLVMValueRef instances,
1235 * regardless of their sub-type. They correspond to functions available
1242 * Obtain the type of a value.
1244 * @see llvm::Value::getType()
1246 LLVMTypeRef LLVMTypeOf(LLVMValueRef Val);
1249 * Obtain the string name of a value.
1251 * @see llvm::Value::getName()
1253 const char *LLVMGetValueName(LLVMValueRef Val);
1256 * Set the string name of a value.
1258 * @see llvm::Value::setName()
1260 void LLVMSetValueName(LLVMValueRef Val, const char *Name);
1263 * Dump a representation of a value to stderr.
1265 * @see llvm::Value::dump()
1267 void LLVMDumpValue(LLVMValueRef Val);
1270 * Return a string representation of the value. Use
1271 * LLVMDisposeMessage to free the string.
1273 * @see llvm::Value::print()
1275 char *LLVMPrintValueToString(LLVMValueRef Val);
1278 * Replace all uses of a value with another one.
1280 * @see llvm::Value::replaceAllUsesWith()
1282 void LLVMReplaceAllUsesWith(LLVMValueRef OldVal, LLVMValueRef NewVal);
1285 * Determine whether the specified constant instance is constant.
1287 LLVMBool LLVMIsConstant(LLVMValueRef Val);
1290 * Determine whether a value instance is undefined.
1292 LLVMBool LLVMIsUndef(LLVMValueRef Val);
1295 * Convert value instances between types.
1297 * Internally, an LLVMValueRef is "pinned" to a specific type. This
1298 * series of functions allows you to cast an instance to a specific
1301 * If the cast is not valid for the specified type, NULL is returned.
1303 * @see llvm::dyn_cast_or_null<>
1305 #define LLVM_DECLARE_VALUE_CAST(name) \
1306 LLVMValueRef LLVMIsA##name(LLVMValueRef Val);
1307 LLVM_FOR_EACH_VALUE_SUBCLASS(LLVM_DECLARE_VALUE_CAST)
1314 * @defgroup LLVMCCoreValueUses Usage
1316 * This module defines functions that allow you to inspect the uses of a
1319 * It is possible to obtain an LLVMUseRef for any LLVMValueRef instance.
1320 * Each LLVMUseRef (which corresponds to a llvm::Use instance) holds a
1321 * llvm::User and llvm::Value.
1327 * Obtain the first use of a value.
1329 * Uses are obtained in an iterator fashion. First, call this function
1330 * to obtain a reference to the first use. Then, call LLVMGetNextUse()
1331 * on that instance and all subsequently obtained instances until
1332 * LLVMGetNextUse() returns NULL.
1334 * @see llvm::Value::use_begin()
1336 LLVMUseRef LLVMGetFirstUse(LLVMValueRef Val);
1339 * Obtain the next use of a value.
1341 * This effectively advances the iterator. It returns NULL if you are on
1342 * the final use and no more are available.
1344 LLVMUseRef LLVMGetNextUse(LLVMUseRef U);
1347 * Obtain the user value for a user.
1349 * The returned value corresponds to a llvm::User type.
1351 * @see llvm::Use::getUser()
1353 LLVMValueRef LLVMGetUser(LLVMUseRef U);
1356 * Obtain the value this use corresponds to.
1358 * @see llvm::Use::get().
1360 LLVMValueRef LLVMGetUsedValue(LLVMUseRef U);
1367 * @defgroup LLVMCCoreValueUser User value
1369 * Function in this group pertain to LLVMValueRef instances that descent
1370 * from llvm::User. This includes constants, instructions, and
1377 * Obtain an operand at a specific index in a llvm::User value.
1379 * @see llvm::User::getOperand()
1381 LLVMValueRef LLVMGetOperand(LLVMValueRef Val, unsigned Index);
1384 * Set an operand at a specific index in a llvm::User value.
1386 * @see llvm::User::setOperand()
1388 void LLVMSetOperand(LLVMValueRef User, unsigned Index, LLVMValueRef Val);
1391 * Obtain the number of operands in a llvm::User value.
1393 * @see llvm::User::getNumOperands()
1395 int LLVMGetNumOperands(LLVMValueRef Val);
1402 * @defgroup LLVMCCoreValueConstant Constants
1404 * This section contains APIs for interacting with LLVMValueRef that
1405 * correspond to llvm::Constant instances.
1407 * These functions will work for any LLVMValueRef in the llvm::Constant
1414 * Obtain a constant value referring to the null instance of a type.
1416 * @see llvm::Constant::getNullValue()
1418 LLVMValueRef LLVMConstNull(LLVMTypeRef Ty); /* all zeroes */
1421 * Obtain a constant value referring to the instance of a type
1422 * consisting of all ones.
1424 * This is only valid for integer types.
1426 * @see llvm::Constant::getAllOnesValue()
1428 LLVMValueRef LLVMConstAllOnes(LLVMTypeRef Ty);
1431 * Obtain a constant value referring to an undefined value of a type.
1433 * @see llvm::UndefValue::get()
1435 LLVMValueRef LLVMGetUndef(LLVMTypeRef Ty);
1438 * Determine whether a value instance is null.
1440 * @see llvm::Constant::isNullValue()
1442 LLVMBool LLVMIsNull(LLVMValueRef Val);
1445 * Obtain a constant that is a constant pointer pointing to NULL for a
1448 LLVMValueRef LLVMConstPointerNull(LLVMTypeRef Ty);
1451 * @defgroup LLVMCCoreValueConstantScalar Scalar constants
1453 * Functions in this group model LLVMValueRef instances that correspond
1454 * to constants referring to scalar types.
1456 * For integer types, the LLVMTypeRef parameter should correspond to a
1457 * llvm::IntegerType instance and the returned LLVMValueRef will
1458 * correspond to a llvm::ConstantInt.
1460 * For floating point types, the LLVMTypeRef returned corresponds to a
1467 * Obtain a constant value for an integer type.
1469 * The returned value corresponds to a llvm::ConstantInt.
1471 * @see llvm::ConstantInt::get()
1473 * @param IntTy Integer type to obtain value of.
1474 * @param N The value the returned instance should refer to.
1475 * @param SignExtend Whether to sign extend the produced value.
1477 LLVMValueRef LLVMConstInt(LLVMTypeRef IntTy, unsigned long long N,
1478 LLVMBool SignExtend);
1481 * Obtain a constant value for an integer of arbitrary precision.
1483 * @see llvm::ConstantInt::get()
1485 LLVMValueRef LLVMConstIntOfArbitraryPrecision(LLVMTypeRef IntTy,
1487 const uint64_t Words[]);
1490 * Obtain a constant value for an integer parsed from a string.
1492 * A similar API, LLVMConstIntOfStringAndSize is also available. If the
1493 * string's length is available, it is preferred to call that function
1496 * @see llvm::ConstantInt::get()
1498 LLVMValueRef LLVMConstIntOfString(LLVMTypeRef IntTy, const char *Text,
1502 * Obtain a constant value for an integer parsed from a string with
1505 * @see llvm::ConstantInt::get()
1507 LLVMValueRef LLVMConstIntOfStringAndSize(LLVMTypeRef IntTy, const char *Text,
1508 unsigned SLen, uint8_t Radix);
1511 * Obtain a constant value referring to a double floating point value.
1513 LLVMValueRef LLVMConstReal(LLVMTypeRef RealTy, double N);
1516 * Obtain a constant for a floating point value parsed from a string.
1518 * A similar API, LLVMConstRealOfStringAndSize is also available. It
1519 * should be used if the input string's length is known.
1521 LLVMValueRef LLVMConstRealOfString(LLVMTypeRef RealTy, const char *Text);
1524 * Obtain a constant for a floating point value parsed from a string.
1526 LLVMValueRef LLVMConstRealOfStringAndSize(LLVMTypeRef RealTy, const char *Text,
1530 * Obtain the zero extended value for an integer constant value.
1532 * @see llvm::ConstantInt::getZExtValue()
1534 unsigned long long LLVMConstIntGetZExtValue(LLVMValueRef ConstantVal);
1537 * Obtain the sign extended value for an integer constant value.
1539 * @see llvm::ConstantInt::getSExtValue()
1541 long long LLVMConstIntGetSExtValue(LLVMValueRef ConstantVal);
1548 * @defgroup LLVMCCoreValueConstantComposite Composite Constants
1550 * Functions in this group operate on composite constants.
1556 * Create a ConstantDataSequential and initialize it with a string.
1558 * @see llvm::ConstantDataArray::getString()
1560 LLVMValueRef LLVMConstStringInContext(LLVMContextRef C, const char *Str,
1561 unsigned Length, LLVMBool DontNullTerminate);
1564 * Create a ConstantDataSequential with string content in the global context.
1566 * This is the same as LLVMConstStringInContext except it operates on the
1569 * @see LLVMConstStringInContext()
1570 * @see llvm::ConstantDataArray::getString()
1572 LLVMValueRef LLVMConstString(const char *Str, unsigned Length,
1573 LLVMBool DontNullTerminate);
1576 * Create an anonymous ConstantStruct with the specified values.
1578 * @see llvm::ConstantStruct::getAnon()
1580 LLVMValueRef LLVMConstStructInContext(LLVMContextRef C,
1581 LLVMValueRef *ConstantVals,
1582 unsigned Count, LLVMBool Packed);
1585 * Create a ConstantStruct in the global Context.
1587 * This is the same as LLVMConstStructInContext except it operates on the
1590 * @see LLVMConstStructInContext()
1592 LLVMValueRef LLVMConstStruct(LLVMValueRef *ConstantVals, unsigned Count,
1596 * Create a ConstantArray from values.
1598 * @see llvm::ConstantArray::get()
1600 LLVMValueRef LLVMConstArray(LLVMTypeRef ElementTy,
1601 LLVMValueRef *ConstantVals, unsigned Length);
1604 * Create a non-anonymous ConstantStruct from values.
1606 * @see llvm::ConstantStruct::get()
1608 LLVMValueRef LLVMConstNamedStruct(LLVMTypeRef StructTy,
1609 LLVMValueRef *ConstantVals,
1613 * Create a ConstantVector from values.
1615 * @see llvm::ConstantVector::get()
1617 LLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals, unsigned Size);
1624 * @defgroup LLVMCCoreValueConstantExpressions Constant Expressions
1626 * Functions in this group correspond to APIs on llvm::ConstantExpr.
1628 * @see llvm::ConstantExpr.
1632 LLVMOpcode LLVMGetConstOpcode(LLVMValueRef ConstantVal);
1633 LLVMValueRef LLVMAlignOf(LLVMTypeRef Ty);
1634 LLVMValueRef LLVMSizeOf(LLVMTypeRef Ty);
1635 LLVMValueRef LLVMConstNeg(LLVMValueRef ConstantVal);
1636 LLVMValueRef LLVMConstNSWNeg(LLVMValueRef ConstantVal);
1637 LLVMValueRef LLVMConstNUWNeg(LLVMValueRef ConstantVal);
1638 LLVMValueRef LLVMConstFNeg(LLVMValueRef ConstantVal);
1639 LLVMValueRef LLVMConstNot(LLVMValueRef ConstantVal);
1640 LLVMValueRef LLVMConstAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1641 LLVMValueRef LLVMConstNSWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1642 LLVMValueRef LLVMConstNUWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1643 LLVMValueRef LLVMConstFAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1644 LLVMValueRef LLVMConstSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1645 LLVMValueRef LLVMConstNSWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1646 LLVMValueRef LLVMConstNUWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1647 LLVMValueRef LLVMConstFSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1648 LLVMValueRef LLVMConstMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1649 LLVMValueRef LLVMConstNSWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1650 LLVMValueRef LLVMConstNUWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1651 LLVMValueRef LLVMConstFMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1652 LLVMValueRef LLVMConstUDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1653 LLVMValueRef LLVMConstSDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1654 LLVMValueRef LLVMConstExactSDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1655 LLVMValueRef LLVMConstFDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1656 LLVMValueRef LLVMConstURem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1657 LLVMValueRef LLVMConstSRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1658 LLVMValueRef LLVMConstFRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1659 LLVMValueRef LLVMConstAnd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1660 LLVMValueRef LLVMConstOr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1661 LLVMValueRef LLVMConstXor(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1662 LLVMValueRef LLVMConstICmp(LLVMIntPredicate Predicate,
1663 LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1664 LLVMValueRef LLVMConstFCmp(LLVMRealPredicate Predicate,
1665 LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1666 LLVMValueRef LLVMConstShl(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1667 LLVMValueRef LLVMConstLShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1668 LLVMValueRef LLVMConstAShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1669 LLVMValueRef LLVMConstGEP(LLVMValueRef ConstantVal,
1670 LLVMValueRef *ConstantIndices, unsigned NumIndices);
1671 LLVMValueRef LLVMConstInBoundsGEP(LLVMValueRef ConstantVal,
1672 LLVMValueRef *ConstantIndices,
1673 unsigned NumIndices);
1674 LLVMValueRef LLVMConstTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1675 LLVMValueRef LLVMConstSExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1676 LLVMValueRef LLVMConstZExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1677 LLVMValueRef LLVMConstFPTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1678 LLVMValueRef LLVMConstFPExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1679 LLVMValueRef LLVMConstUIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1680 LLVMValueRef LLVMConstSIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1681 LLVMValueRef LLVMConstFPToUI(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1682 LLVMValueRef LLVMConstFPToSI(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1683 LLVMValueRef LLVMConstPtrToInt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1684 LLVMValueRef LLVMConstIntToPtr(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1685 LLVMValueRef LLVMConstBitCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1686 LLVMValueRef LLVMConstAddrSpaceCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1687 LLVMValueRef LLVMConstZExtOrBitCast(LLVMValueRef ConstantVal,
1688 LLVMTypeRef ToType);
1689 LLVMValueRef LLVMConstSExtOrBitCast(LLVMValueRef ConstantVal,
1690 LLVMTypeRef ToType);
1691 LLVMValueRef LLVMConstTruncOrBitCast(LLVMValueRef ConstantVal,
1692 LLVMTypeRef ToType);
1693 LLVMValueRef LLVMConstPointerCast(LLVMValueRef ConstantVal,
1694 LLVMTypeRef ToType);
1695 LLVMValueRef LLVMConstIntCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType,
1697 LLVMValueRef LLVMConstFPCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1698 LLVMValueRef LLVMConstSelect(LLVMValueRef ConstantCondition,
1699 LLVMValueRef ConstantIfTrue,
1700 LLVMValueRef ConstantIfFalse);
1701 LLVMValueRef LLVMConstExtractElement(LLVMValueRef VectorConstant,
1702 LLVMValueRef IndexConstant);
1703 LLVMValueRef LLVMConstInsertElement(LLVMValueRef VectorConstant,
1704 LLVMValueRef ElementValueConstant,
1705 LLVMValueRef IndexConstant);
1706 LLVMValueRef LLVMConstShuffleVector(LLVMValueRef VectorAConstant,
1707 LLVMValueRef VectorBConstant,
1708 LLVMValueRef MaskConstant);
1709 LLVMValueRef LLVMConstExtractValue(LLVMValueRef AggConstant, unsigned *IdxList,
1711 LLVMValueRef LLVMConstInsertValue(LLVMValueRef AggConstant,
1712 LLVMValueRef ElementValueConstant,
1713 unsigned *IdxList, unsigned NumIdx);
1714 LLVMValueRef LLVMConstInlineAsm(LLVMTypeRef Ty,
1715 const char *AsmString, const char *Constraints,
1716 LLVMBool HasSideEffects, LLVMBool IsAlignStack);
1717 LLVMValueRef LLVMBlockAddress(LLVMValueRef F, LLVMBasicBlockRef BB);
1724 * @defgroup LLVMCCoreValueConstantGlobals Global Values
1726 * This group contains functions that operate on global values. Functions in
1727 * this group relate to functions in the llvm::GlobalValue class tree.
1729 * @see llvm::GlobalValue
1734 LLVMModuleRef LLVMGetGlobalParent(LLVMValueRef Global);
1735 LLVMBool LLVMIsDeclaration(LLVMValueRef Global);
1736 LLVMLinkage LLVMGetLinkage(LLVMValueRef Global);
1737 void LLVMSetLinkage(LLVMValueRef Global, LLVMLinkage Linkage);
1738 const char *LLVMGetSection(LLVMValueRef Global);
1739 void LLVMSetSection(LLVMValueRef Global, const char *Section);
1740 LLVMVisibility LLVMGetVisibility(LLVMValueRef Global);
1741 void LLVMSetVisibility(LLVMValueRef Global, LLVMVisibility Viz);
1742 LLVMDLLStorageClass LLVMGetDLLStorageClass(LLVMValueRef Global);
1743 void LLVMSetDLLStorageClass(LLVMValueRef Global, LLVMDLLStorageClass Class);
1744 LLVMBool LLVMHasUnnamedAddr(LLVMValueRef Global);
1745 void LLVMSetUnnamedAddr(LLVMValueRef Global, LLVMBool HasUnnamedAddr);
1748 * @defgroup LLVMCCoreValueWithAlignment Values with alignment
1750 * Functions in this group only apply to values with alignment, i.e.
1751 * global variables, load and store instructions.
1755 * Obtain the preferred alignment of the value.
1756 * @see llvm::AllocaInst::getAlignment()
1757 * @see llvm::LoadInst::getAlignment()
1758 * @see llvm::StoreInst::getAlignment()
1759 * @see llvm::GlobalValue::getAlignment()
1761 unsigned LLVMGetAlignment(LLVMValueRef V);
1764 * Set the preferred alignment of the value.
1765 * @see llvm::AllocaInst::setAlignment()
1766 * @see llvm::LoadInst::setAlignment()
1767 * @see llvm::StoreInst::setAlignment()
1768 * @see llvm::GlobalValue::setAlignment()
1770 void LLVMSetAlignment(LLVMValueRef V, unsigned Bytes);
1777 * @defgroup LLVMCoreValueConstantGlobalVariable Global Variables
1779 * This group contains functions that operate on global variable values.
1781 * @see llvm::GlobalVariable
1785 LLVMValueRef LLVMAddGlobal(LLVMModuleRef M, LLVMTypeRef Ty, const char *Name);
1786 LLVMValueRef LLVMAddGlobalInAddressSpace(LLVMModuleRef M, LLVMTypeRef Ty,
1788 unsigned AddressSpace);
1789 LLVMValueRef LLVMGetNamedGlobal(LLVMModuleRef M, const char *Name);
1790 LLVMValueRef LLVMGetFirstGlobal(LLVMModuleRef M);
1791 LLVMValueRef LLVMGetLastGlobal(LLVMModuleRef M);
1792 LLVMValueRef LLVMGetNextGlobal(LLVMValueRef GlobalVar);
1793 LLVMValueRef LLVMGetPreviousGlobal(LLVMValueRef GlobalVar);
1794 void LLVMDeleteGlobal(LLVMValueRef GlobalVar);
1795 LLVMValueRef LLVMGetInitializer(LLVMValueRef GlobalVar);
1796 void LLVMSetInitializer(LLVMValueRef GlobalVar, LLVMValueRef ConstantVal);
1797 LLVMBool LLVMIsThreadLocal(LLVMValueRef GlobalVar);
1798 void LLVMSetThreadLocal(LLVMValueRef GlobalVar, LLVMBool IsThreadLocal);
1799 LLVMBool LLVMIsGlobalConstant(LLVMValueRef GlobalVar);
1800 void LLVMSetGlobalConstant(LLVMValueRef GlobalVar, LLVMBool IsConstant);
1801 LLVMThreadLocalMode LLVMGetThreadLocalMode(LLVMValueRef GlobalVar);
1802 void LLVMSetThreadLocalMode(LLVMValueRef GlobalVar, LLVMThreadLocalMode Mode);
1803 LLVMBool LLVMIsExternallyInitialized(LLVMValueRef GlobalVar);
1804 void LLVMSetExternallyInitialized(LLVMValueRef GlobalVar, LLVMBool IsExtInit);
1811 * @defgroup LLVMCoreValueConstantGlobalAlias Global Aliases
1813 * This group contains function that operate on global alias values.
1815 * @see llvm::GlobalAlias
1819 LLVMValueRef LLVMAddAlias(LLVMModuleRef M, LLVMTypeRef Ty, LLVMValueRef Aliasee,
1827 * @defgroup LLVMCCoreValueFunction Function values
1829 * Functions in this group operate on LLVMValueRef instances that
1830 * correspond to llvm::Function instances.
1832 * @see llvm::Function
1838 * Remove a function from its containing module and deletes it.
1840 * @see llvm::Function::eraseFromParent()
1842 void LLVMDeleteFunction(LLVMValueRef Fn);
1845 * Obtain the ID number from a function instance.
1847 * @see llvm::Function::getIntrinsicID()
1849 unsigned LLVMGetIntrinsicID(LLVMValueRef Fn);
1852 * Obtain the calling function of a function.
1854 * The returned value corresponds to the LLVMCallConv enumeration.
1856 * @see llvm::Function::getCallingConv()
1858 unsigned LLVMGetFunctionCallConv(LLVMValueRef Fn);
1861 * Set the calling convention of a function.
1863 * @see llvm::Function::setCallingConv()
1865 * @param Fn Function to operate on
1866 * @param CC LLVMCallConv to set calling convention to
1868 void LLVMSetFunctionCallConv(LLVMValueRef Fn, unsigned CC);
1871 * Obtain the name of the garbage collector to use during code
1874 * @see llvm::Function::getGC()
1876 const char *LLVMGetGC(LLVMValueRef Fn);
1879 * Define the garbage collector to use during code generation.
1881 * @see llvm::Function::setGC()
1883 void LLVMSetGC(LLVMValueRef Fn, const char *Name);
1886 * Add an attribute to a function.
1888 * @see llvm::Function::addAttribute()
1890 void LLVMAddFunctionAttr(LLVMValueRef Fn, LLVMAttribute PA);
1893 * Add a target-dependent attribute to a fuction
1894 * @see llvm::AttrBuilder::addAttribute()
1896 void LLVMAddTargetDependentFunctionAttr(LLVMValueRef Fn, const char *A,
1900 * Obtain an attribute from a function.
1902 * @see llvm::Function::getAttributes()
1904 LLVMAttribute LLVMGetFunctionAttr(LLVMValueRef Fn);
1907 * Remove an attribute from a function.
1909 void LLVMRemoveFunctionAttr(LLVMValueRef Fn, LLVMAttribute PA);
1912 * @defgroup LLVMCCoreValueFunctionParameters Function Parameters
1914 * Functions in this group relate to arguments/parameters on functions.
1916 * Functions in this group expect LLVMValueRef instances that correspond
1917 * to llvm::Function instances.
1923 * Obtain the number of parameters in a function.
1925 * @see llvm::Function::arg_size()
1927 unsigned LLVMCountParams(LLVMValueRef Fn);
1930 * Obtain the parameters in a function.
1932 * The takes a pointer to a pre-allocated array of LLVMValueRef that is
1933 * at least LLVMCountParams() long. This array will be filled with
1934 * LLVMValueRef instances which correspond to the parameters the
1935 * function receives. Each LLVMValueRef corresponds to a llvm::Argument
1938 * @see llvm::Function::arg_begin()
1940 void LLVMGetParams(LLVMValueRef Fn, LLVMValueRef *Params);
1943 * Obtain the parameter at the specified index.
1945 * Parameters are indexed from 0.
1947 * @see llvm::Function::arg_begin()
1949 LLVMValueRef LLVMGetParam(LLVMValueRef Fn, unsigned Index);
1952 * Obtain the function to which this argument belongs.
1954 * Unlike other functions in this group, this one takes an LLVMValueRef
1955 * that corresponds to a llvm::Attribute.
1957 * The returned LLVMValueRef is the llvm::Function to which this
1960 LLVMValueRef LLVMGetParamParent(LLVMValueRef Inst);
1963 * Obtain the first parameter to a function.
1965 * @see llvm::Function::arg_begin()
1967 LLVMValueRef LLVMGetFirstParam(LLVMValueRef Fn);
1970 * Obtain the last parameter to a function.
1972 * @see llvm::Function::arg_end()
1974 LLVMValueRef LLVMGetLastParam(LLVMValueRef Fn);
1977 * Obtain the next parameter to a function.
1979 * This takes an LLVMValueRef obtained from LLVMGetFirstParam() (which is
1980 * actually a wrapped iterator) and obtains the next parameter from the
1981 * underlying iterator.
1983 LLVMValueRef LLVMGetNextParam(LLVMValueRef Arg);
1986 * Obtain the previous parameter to a function.
1988 * This is the opposite of LLVMGetNextParam().
1990 LLVMValueRef LLVMGetPreviousParam(LLVMValueRef Arg);
1993 * Add an attribute to a function argument.
1995 * @see llvm::Argument::addAttr()
1997 void LLVMAddAttribute(LLVMValueRef Arg, LLVMAttribute PA);
2000 * Remove an attribute from a function argument.
2002 * @see llvm::Argument::removeAttr()
2004 void LLVMRemoveAttribute(LLVMValueRef Arg, LLVMAttribute PA);
2007 * Get an attribute from a function argument.
2009 LLVMAttribute LLVMGetAttribute(LLVMValueRef Arg);
2012 * Set the alignment for a function parameter.
2014 * @see llvm::Argument::addAttr()
2015 * @see llvm::AttrBuilder::addAlignmentAttr()
2017 void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned align);
2036 * @defgroup LLVMCCoreValueMetadata Metadata
2042 * Obtain a MDString value from a context.
2044 * The returned instance corresponds to the llvm::MDString class.
2046 * The instance is specified by string data of a specified length. The
2047 * string content is copied, so the backing memory can be freed after
2048 * this function returns.
2050 LLVMValueRef LLVMMDStringInContext(LLVMContextRef C, const char *Str,
2054 * Obtain a MDString value from the global context.
2056 LLVMValueRef LLVMMDString(const char *Str, unsigned SLen);
2059 * Obtain a MDNode value from a context.
2061 * The returned value corresponds to the llvm::MDNode class.
2063 LLVMValueRef LLVMMDNodeInContext(LLVMContextRef C, LLVMValueRef *Vals,
2067 * Obtain a MDNode value from the global context.
2069 LLVMValueRef LLVMMDNode(LLVMValueRef *Vals, unsigned Count);
2072 * Obtain the underlying string from a MDString value.
2074 * @param V Instance to obtain string from.
2075 * @param Len Memory address which will hold length of returned string.
2076 * @return String data in MDString.
2078 const char *LLVMGetMDString(LLVMValueRef V, unsigned* Len);
2081 * Obtain the number of operands from an MDNode value.
2083 * @param V MDNode to get number of operands from.
2084 * @return Number of operands of the MDNode.
2086 unsigned LLVMGetMDNodeNumOperands(LLVMValueRef V);
2089 * Obtain the given MDNode's operands.
2091 * The passed LLVMValueRef pointer should point to enough memory to hold all of
2092 * the operands of the given MDNode (see LLVMGetMDNodeNumOperands) as
2093 * LLVMValueRefs. This memory will be populated with the LLVMValueRefs of the
2094 * MDNode's operands.
2096 * @param V MDNode to get the operands from.
2097 * @param Dest Destination array for operands.
2099 void LLVMGetMDNodeOperands(LLVMValueRef V, LLVMValueRef *Dest);
2106 * @defgroup LLVMCCoreValueBasicBlock Basic Block
2108 * A basic block represents a single entry single exit section of code.
2109 * Basic blocks contain a list of instructions which form the body of
2112 * Basic blocks belong to functions. They have the type of label.
2114 * Basic blocks are themselves values. However, the C API models them as
2115 * LLVMBasicBlockRef.
2117 * @see llvm::BasicBlock
2123 * Convert a basic block instance to a value type.
2125 LLVMValueRef LLVMBasicBlockAsValue(LLVMBasicBlockRef BB);
2128 * Determine whether an LLVMValueRef is itself a basic block.
2130 LLVMBool LLVMValueIsBasicBlock(LLVMValueRef Val);
2133 * Convert an LLVMValueRef to an LLVMBasicBlockRef instance.
2135 LLVMBasicBlockRef LLVMValueAsBasicBlock(LLVMValueRef Val);
2138 * Obtain the function to which a basic block belongs.
2140 * @see llvm::BasicBlock::getParent()
2142 LLVMValueRef LLVMGetBasicBlockParent(LLVMBasicBlockRef BB);
2145 * Obtain the terminator instruction for a basic block.
2147 * If the basic block does not have a terminator (it is not well-formed
2148 * if it doesn't), then NULL is returned.
2150 * The returned LLVMValueRef corresponds to a llvm::TerminatorInst.
2152 * @see llvm::BasicBlock::getTerminator()
2154 LLVMValueRef LLVMGetBasicBlockTerminator(LLVMBasicBlockRef BB);
2157 * Obtain the number of basic blocks in a function.
2159 * @param Fn Function value to operate on.
2161 unsigned LLVMCountBasicBlocks(LLVMValueRef Fn);
2164 * Obtain all of the basic blocks in a function.
2166 * This operates on a function value. The BasicBlocks parameter is a
2167 * pointer to a pre-allocated array of LLVMBasicBlockRef of at least
2168 * LLVMCountBasicBlocks() in length. This array is populated with
2169 * LLVMBasicBlockRef instances.
2171 void LLVMGetBasicBlocks(LLVMValueRef Fn, LLVMBasicBlockRef *BasicBlocks);
2174 * Obtain the first basic block in a function.
2176 * The returned basic block can be used as an iterator. You will likely
2177 * eventually call into LLVMGetNextBasicBlock() with it.
2179 * @see llvm::Function::begin()
2181 LLVMBasicBlockRef LLVMGetFirstBasicBlock(LLVMValueRef Fn);
2184 * Obtain the last basic block in a function.
2186 * @see llvm::Function::end()
2188 LLVMBasicBlockRef LLVMGetLastBasicBlock(LLVMValueRef Fn);
2191 * Advance a basic block iterator.
2193 LLVMBasicBlockRef LLVMGetNextBasicBlock(LLVMBasicBlockRef BB);
2196 * Go backwards in a basic block iterator.
2198 LLVMBasicBlockRef LLVMGetPreviousBasicBlock(LLVMBasicBlockRef BB);
2201 * Obtain the basic block that corresponds to the entry point of a
2204 * @see llvm::Function::getEntryBlock()
2206 LLVMBasicBlockRef LLVMGetEntryBasicBlock(LLVMValueRef Fn);
2209 * Append a basic block to the end of a function.
2211 * @see llvm::BasicBlock::Create()
2213 LLVMBasicBlockRef LLVMAppendBasicBlockInContext(LLVMContextRef C,
2218 * Append a basic block to the end of a function using the global
2221 * @see llvm::BasicBlock::Create()
2223 LLVMBasicBlockRef LLVMAppendBasicBlock(LLVMValueRef Fn, const char *Name);
2226 * Insert a basic block in a function before another basic block.
2228 * The function to add to is determined by the function of the
2229 * passed basic block.
2231 * @see llvm::BasicBlock::Create()
2233 LLVMBasicBlockRef LLVMInsertBasicBlockInContext(LLVMContextRef C,
2234 LLVMBasicBlockRef BB,
2238 * Insert a basic block in a function using the global context.
2240 * @see llvm::BasicBlock::Create()
2242 LLVMBasicBlockRef LLVMInsertBasicBlock(LLVMBasicBlockRef InsertBeforeBB,
2246 * Remove a basic block from a function and delete it.
2248 * This deletes the basic block from its containing function and deletes
2249 * the basic block itself.
2251 * @see llvm::BasicBlock::eraseFromParent()
2253 void LLVMDeleteBasicBlock(LLVMBasicBlockRef BB);
2256 * Remove a basic block from a function.
2258 * This deletes the basic block from its containing function but keep
2259 * the basic block alive.
2261 * @see llvm::BasicBlock::removeFromParent()
2263 void LLVMRemoveBasicBlockFromParent(LLVMBasicBlockRef BB);
2266 * Move a basic block to before another one.
2268 * @see llvm::BasicBlock::moveBefore()
2270 void LLVMMoveBasicBlockBefore(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos);
2273 * Move a basic block to after another one.
2275 * @see llvm::BasicBlock::moveAfter()
2277 void LLVMMoveBasicBlockAfter(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos);
2280 * Obtain the first instruction in a basic block.
2282 * The returned LLVMValueRef corresponds to a llvm::Instruction
2285 LLVMValueRef LLVMGetFirstInstruction(LLVMBasicBlockRef BB);
2288 * Obtain the last instruction in a basic block.
2290 * The returned LLVMValueRef corresponds to an LLVM:Instruction.
2292 LLVMValueRef LLVMGetLastInstruction(LLVMBasicBlockRef BB);
2299 * @defgroup LLVMCCoreValueInstruction Instructions
2301 * Functions in this group relate to the inspection and manipulation of
2302 * individual instructions.
2304 * In the C++ API, an instruction is modeled by llvm::Instruction. This
2305 * class has a large number of descendents. llvm::Instruction is a
2306 * llvm::Value and in the C API, instructions are modeled by
2309 * This group also contains sub-groups which operate on specific
2310 * llvm::Instruction types, e.g. llvm::CallInst.
2316 * Determine whether an instruction has any metadata attached.
2318 int LLVMHasMetadata(LLVMValueRef Val);
2321 * Return metadata associated with an instruction value.
2323 LLVMValueRef LLVMGetMetadata(LLVMValueRef Val, unsigned KindID);
2326 * Set metadata associated with an instruction value.
2328 void LLVMSetMetadata(LLVMValueRef Val, unsigned KindID, LLVMValueRef Node);
2331 * Obtain the basic block to which an instruction belongs.
2333 * @see llvm::Instruction::getParent()
2335 LLVMBasicBlockRef LLVMGetInstructionParent(LLVMValueRef Inst);
2338 * Obtain the instruction that occurs after the one specified.
2340 * The next instruction will be from the same basic block.
2342 * If this is the last instruction in a basic block, NULL will be
2345 LLVMValueRef LLVMGetNextInstruction(LLVMValueRef Inst);
2348 * Obtain the instruction that occurred before this one.
2350 * If the instruction is the first instruction in a basic block, NULL
2353 LLVMValueRef LLVMGetPreviousInstruction(LLVMValueRef Inst);
2356 * Remove and delete an instruction.
2358 * The instruction specified is removed from its containing building
2359 * block and then deleted.
2361 * @see llvm::Instruction::eraseFromParent()
2363 void LLVMInstructionEraseFromParent(LLVMValueRef Inst);
2366 * Obtain the code opcode for an individual instruction.
2368 * @see llvm::Instruction::getOpCode()
2370 LLVMOpcode LLVMGetInstructionOpcode(LLVMValueRef Inst);
2373 * Obtain the predicate of an instruction.
2375 * This is only valid for instructions that correspond to llvm::ICmpInst
2376 * or llvm::ConstantExpr whose opcode is llvm::Instruction::ICmp.
2378 * @see llvm::ICmpInst::getPredicate()
2380 LLVMIntPredicate LLVMGetICmpPredicate(LLVMValueRef Inst);
2383 * @defgroup LLVMCCoreValueInstructionCall Call Sites and Invocations
2385 * Functions in this group apply to instructions that refer to call
2386 * sites and invocations. These correspond to C++ types in the
2387 * llvm::CallInst class tree.
2393 * Set the calling convention for a call instruction.
2395 * This expects an LLVMValueRef that corresponds to a llvm::CallInst or
2398 * @see llvm::CallInst::setCallingConv()
2399 * @see llvm::InvokeInst::setCallingConv()
2401 void LLVMSetInstructionCallConv(LLVMValueRef Instr, unsigned CC);
2404 * Obtain the calling convention for a call instruction.
2406 * This is the opposite of LLVMSetInstructionCallConv(). Reads its
2409 * @see LLVMSetInstructionCallConv()
2411 unsigned LLVMGetInstructionCallConv(LLVMValueRef Instr);
2414 void LLVMAddInstrAttribute(LLVMValueRef Instr, unsigned index, LLVMAttribute);
2415 void LLVMRemoveInstrAttribute(LLVMValueRef Instr, unsigned index,
2417 void LLVMSetInstrParamAlignment(LLVMValueRef Instr, unsigned index,
2421 * Obtain whether a call instruction is a tail call.
2423 * This only works on llvm::CallInst instructions.
2425 * @see llvm::CallInst::isTailCall()
2427 LLVMBool LLVMIsTailCall(LLVMValueRef CallInst);
2430 * Set whether a call instruction is a tail call.
2432 * This only works on llvm::CallInst instructions.
2434 * @see llvm::CallInst::setTailCall()
2436 void LLVMSetTailCall(LLVMValueRef CallInst, LLVMBool IsTailCall);
2443 * Obtain the default destination basic block of a switch instruction.
2445 * This only works on llvm::SwitchInst instructions.
2447 * @see llvm::SwitchInst::getDefaultDest()
2449 LLVMBasicBlockRef LLVMGetSwitchDefaultDest(LLVMValueRef SwitchInstr);
2452 * @defgroup LLVMCCoreValueInstructionPHINode PHI Nodes
2454 * Functions in this group only apply to instructions that map to
2455 * llvm::PHINode instances.
2461 * Add an incoming value to the end of a PHI list.
2463 void LLVMAddIncoming(LLVMValueRef PhiNode, LLVMValueRef *IncomingValues,
2464 LLVMBasicBlockRef *IncomingBlocks, unsigned Count);
2467 * Obtain the number of incoming basic blocks to a PHI node.
2469 unsigned LLVMCountIncoming(LLVMValueRef PhiNode);
2472 * Obtain an incoming value to a PHI node as an LLVMValueRef.
2474 LLVMValueRef LLVMGetIncomingValue(LLVMValueRef PhiNode, unsigned Index);
2477 * Obtain an incoming value to a PHI node as an LLVMBasicBlockRef.
2479 LLVMBasicBlockRef LLVMGetIncomingBlock(LLVMValueRef PhiNode, unsigned Index);
2494 * @defgroup LLVMCCoreInstructionBuilder Instruction Builders
2496 * An instruction builder represents a point within a basic block and is
2497 * the exclusive means of building instructions using the C interface.
2502 LLVMBuilderRef LLVMCreateBuilderInContext(LLVMContextRef C);
2503 LLVMBuilderRef LLVMCreateBuilder(void);
2504 void LLVMPositionBuilder(LLVMBuilderRef Builder, LLVMBasicBlockRef Block,
2505 LLVMValueRef Instr);
2506 void LLVMPositionBuilderBefore(LLVMBuilderRef Builder, LLVMValueRef Instr);
2507 void LLVMPositionBuilderAtEnd(LLVMBuilderRef Builder, LLVMBasicBlockRef Block);
2508 LLVMBasicBlockRef LLVMGetInsertBlock(LLVMBuilderRef Builder);
2509 void LLVMClearInsertionPosition(LLVMBuilderRef Builder);
2510 void LLVMInsertIntoBuilder(LLVMBuilderRef Builder, LLVMValueRef Instr);
2511 void LLVMInsertIntoBuilderWithName(LLVMBuilderRef Builder, LLVMValueRef Instr,
2513 void LLVMDisposeBuilder(LLVMBuilderRef Builder);
2516 void LLVMSetCurrentDebugLocation(LLVMBuilderRef Builder, LLVMValueRef L);
2517 LLVMValueRef LLVMGetCurrentDebugLocation(LLVMBuilderRef Builder);
2518 void LLVMSetInstDebugLocation(LLVMBuilderRef Builder, LLVMValueRef Inst);
2521 LLVMValueRef LLVMBuildRetVoid(LLVMBuilderRef);
2522 LLVMValueRef LLVMBuildRet(LLVMBuilderRef, LLVMValueRef V);
2523 LLVMValueRef LLVMBuildAggregateRet(LLVMBuilderRef, LLVMValueRef *RetVals,
2525 LLVMValueRef LLVMBuildBr(LLVMBuilderRef, LLVMBasicBlockRef Dest);
2526 LLVMValueRef LLVMBuildCondBr(LLVMBuilderRef, LLVMValueRef If,
2527 LLVMBasicBlockRef Then, LLVMBasicBlockRef Else);
2528 LLVMValueRef LLVMBuildSwitch(LLVMBuilderRef, LLVMValueRef V,
2529 LLVMBasicBlockRef Else, unsigned NumCases);
2530 LLVMValueRef LLVMBuildIndirectBr(LLVMBuilderRef B, LLVMValueRef Addr,
2532 LLVMValueRef LLVMBuildInvoke(LLVMBuilderRef, LLVMValueRef Fn,
2533 LLVMValueRef *Args, unsigned NumArgs,
2534 LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch,
2536 LLVMValueRef LLVMBuildLandingPad(LLVMBuilderRef B, LLVMTypeRef Ty,
2537 LLVMValueRef PersFn, unsigned NumClauses,
2539 LLVMValueRef LLVMBuildResume(LLVMBuilderRef B, LLVMValueRef Exn);
2540 LLVMValueRef LLVMBuildUnreachable(LLVMBuilderRef);
2542 /* Add a case to the switch instruction */
2543 void LLVMAddCase(LLVMValueRef Switch, LLVMValueRef OnVal,
2544 LLVMBasicBlockRef Dest);
2546 /* Add a destination to the indirectbr instruction */
2547 void LLVMAddDestination(LLVMValueRef IndirectBr, LLVMBasicBlockRef Dest);
2549 /* Add a catch or filter clause to the landingpad instruction */
2550 void LLVMAddClause(LLVMValueRef LandingPad, LLVMValueRef ClauseVal);
2552 /* Set the 'cleanup' flag in the landingpad instruction */
2553 void LLVMSetCleanup(LLVMValueRef LandingPad, LLVMBool Val);
2556 LLVMValueRef LLVMBuildAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2558 LLVMValueRef LLVMBuildNSWAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2560 LLVMValueRef LLVMBuildNUWAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2562 LLVMValueRef LLVMBuildFAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2564 LLVMValueRef LLVMBuildSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2566 LLVMValueRef LLVMBuildNSWSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2568 LLVMValueRef LLVMBuildNUWSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2570 LLVMValueRef LLVMBuildFSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2572 LLVMValueRef LLVMBuildMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2574 LLVMValueRef LLVMBuildNSWMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2576 LLVMValueRef LLVMBuildNUWMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2578 LLVMValueRef LLVMBuildFMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2580 LLVMValueRef LLVMBuildUDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2582 LLVMValueRef LLVMBuildSDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2584 LLVMValueRef LLVMBuildExactSDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2586 LLVMValueRef LLVMBuildFDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2588 LLVMValueRef LLVMBuildURem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2590 LLVMValueRef LLVMBuildSRem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2592 LLVMValueRef LLVMBuildFRem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2594 LLVMValueRef LLVMBuildShl(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2596 LLVMValueRef LLVMBuildLShr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2598 LLVMValueRef LLVMBuildAShr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2600 LLVMValueRef LLVMBuildAnd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2602 LLVMValueRef LLVMBuildOr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2604 LLVMValueRef LLVMBuildXor(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2606 LLVMValueRef LLVMBuildBinOp(LLVMBuilderRef B, LLVMOpcode Op,
2607 LLVMValueRef LHS, LLVMValueRef RHS,
2609 LLVMValueRef LLVMBuildNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name);
2610 LLVMValueRef LLVMBuildNSWNeg(LLVMBuilderRef B, LLVMValueRef V,
2612 LLVMValueRef LLVMBuildNUWNeg(LLVMBuilderRef B, LLVMValueRef V,
2614 LLVMValueRef LLVMBuildFNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name);
2615 LLVMValueRef LLVMBuildNot(LLVMBuilderRef, LLVMValueRef V, const char *Name);
2618 LLVMValueRef LLVMBuildMalloc(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
2619 LLVMValueRef LLVMBuildArrayMalloc(LLVMBuilderRef, LLVMTypeRef Ty,
2620 LLVMValueRef Val, const char *Name);
2621 LLVMValueRef LLVMBuildAlloca(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
2622 LLVMValueRef LLVMBuildArrayAlloca(LLVMBuilderRef, LLVMTypeRef Ty,
2623 LLVMValueRef Val, const char *Name);
2624 LLVMValueRef LLVMBuildFree(LLVMBuilderRef, LLVMValueRef PointerVal);
2625 LLVMValueRef LLVMBuildLoad(LLVMBuilderRef, LLVMValueRef PointerVal,
2627 LLVMValueRef LLVMBuildStore(LLVMBuilderRef, LLVMValueRef Val, LLVMValueRef Ptr);
2628 LLVMValueRef LLVMBuildGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
2629 LLVMValueRef *Indices, unsigned NumIndices,
2631 LLVMValueRef LLVMBuildInBoundsGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
2632 LLVMValueRef *Indices, unsigned NumIndices,
2634 LLVMValueRef LLVMBuildStructGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
2635 unsigned Idx, const char *Name);
2636 LLVMValueRef LLVMBuildGlobalString(LLVMBuilderRef B, const char *Str,
2638 LLVMValueRef LLVMBuildGlobalStringPtr(LLVMBuilderRef B, const char *Str,
2640 LLVMBool LLVMGetVolatile(LLVMValueRef MemoryAccessInst);
2641 void LLVMSetVolatile(LLVMValueRef MemoryAccessInst, LLVMBool IsVolatile);
2644 LLVMValueRef LLVMBuildTrunc(LLVMBuilderRef, LLVMValueRef Val,
2645 LLVMTypeRef DestTy, const char *Name);
2646 LLVMValueRef LLVMBuildZExt(LLVMBuilderRef, LLVMValueRef Val,
2647 LLVMTypeRef DestTy, const char *Name);
2648 LLVMValueRef LLVMBuildSExt(LLVMBuilderRef, LLVMValueRef Val,
2649 LLVMTypeRef DestTy, const char *Name);
2650 LLVMValueRef LLVMBuildFPToUI(LLVMBuilderRef, LLVMValueRef Val,
2651 LLVMTypeRef DestTy, const char *Name);
2652 LLVMValueRef LLVMBuildFPToSI(LLVMBuilderRef, LLVMValueRef Val,
2653 LLVMTypeRef DestTy, const char *Name);
2654 LLVMValueRef LLVMBuildUIToFP(LLVMBuilderRef, LLVMValueRef Val,
2655 LLVMTypeRef DestTy, const char *Name);
2656 LLVMValueRef LLVMBuildSIToFP(LLVMBuilderRef, LLVMValueRef Val,
2657 LLVMTypeRef DestTy, const char *Name);
2658 LLVMValueRef LLVMBuildFPTrunc(LLVMBuilderRef, LLVMValueRef Val,
2659 LLVMTypeRef DestTy, const char *Name);
2660 LLVMValueRef LLVMBuildFPExt(LLVMBuilderRef, LLVMValueRef Val,
2661 LLVMTypeRef DestTy, const char *Name);
2662 LLVMValueRef LLVMBuildPtrToInt(LLVMBuilderRef, LLVMValueRef Val,
2663 LLVMTypeRef DestTy, const char *Name);
2664 LLVMValueRef LLVMBuildIntToPtr(LLVMBuilderRef, LLVMValueRef Val,
2665 LLVMTypeRef DestTy, const char *Name);
2666 LLVMValueRef LLVMBuildBitCast(LLVMBuilderRef, LLVMValueRef Val,
2667 LLVMTypeRef DestTy, const char *Name);
2668 LLVMValueRef LLVMBuildAddrSpaceCast(LLVMBuilderRef, LLVMValueRef Val,
2669 LLVMTypeRef DestTy, const char *Name);
2670 LLVMValueRef LLVMBuildZExtOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
2671 LLVMTypeRef DestTy, const char *Name);
2672 LLVMValueRef LLVMBuildSExtOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
2673 LLVMTypeRef DestTy, const char *Name);
2674 LLVMValueRef LLVMBuildTruncOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
2675 LLVMTypeRef DestTy, const char *Name);
2676 LLVMValueRef LLVMBuildCast(LLVMBuilderRef B, LLVMOpcode Op, LLVMValueRef Val,
2677 LLVMTypeRef DestTy, const char *Name);
2678 LLVMValueRef LLVMBuildPointerCast(LLVMBuilderRef, LLVMValueRef Val,
2679 LLVMTypeRef DestTy, const char *Name);
2680 LLVMValueRef LLVMBuildIntCast(LLVMBuilderRef, LLVMValueRef Val, /*Signed cast!*/
2681 LLVMTypeRef DestTy, const char *Name);
2682 LLVMValueRef LLVMBuildFPCast(LLVMBuilderRef, LLVMValueRef Val,
2683 LLVMTypeRef DestTy, const char *Name);
2686 LLVMValueRef LLVMBuildICmp(LLVMBuilderRef, LLVMIntPredicate Op,
2687 LLVMValueRef LHS, LLVMValueRef RHS,
2689 LLVMValueRef LLVMBuildFCmp(LLVMBuilderRef, LLVMRealPredicate Op,
2690 LLVMValueRef LHS, LLVMValueRef RHS,
2693 /* Miscellaneous instructions */
2694 LLVMValueRef LLVMBuildPhi(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
2695 LLVMValueRef LLVMBuildCall(LLVMBuilderRef, LLVMValueRef Fn,
2696 LLVMValueRef *Args, unsigned NumArgs,
2698 LLVMValueRef LLVMBuildSelect(LLVMBuilderRef, LLVMValueRef If,
2699 LLVMValueRef Then, LLVMValueRef Else,
2701 LLVMValueRef LLVMBuildVAArg(LLVMBuilderRef, LLVMValueRef List, LLVMTypeRef Ty,
2703 LLVMValueRef LLVMBuildExtractElement(LLVMBuilderRef, LLVMValueRef VecVal,
2704 LLVMValueRef Index, const char *Name);
2705 LLVMValueRef LLVMBuildInsertElement(LLVMBuilderRef, LLVMValueRef VecVal,
2706 LLVMValueRef EltVal, LLVMValueRef Index,
2708 LLVMValueRef LLVMBuildShuffleVector(LLVMBuilderRef, LLVMValueRef V1,
2709 LLVMValueRef V2, LLVMValueRef Mask,
2711 LLVMValueRef LLVMBuildExtractValue(LLVMBuilderRef, LLVMValueRef AggVal,
2712 unsigned Index, const char *Name);
2713 LLVMValueRef LLVMBuildInsertValue(LLVMBuilderRef, LLVMValueRef AggVal,
2714 LLVMValueRef EltVal, unsigned Index,
2717 LLVMValueRef LLVMBuildIsNull(LLVMBuilderRef, LLVMValueRef Val,
2719 LLVMValueRef LLVMBuildIsNotNull(LLVMBuilderRef, LLVMValueRef Val,
2721 LLVMValueRef LLVMBuildPtrDiff(LLVMBuilderRef, LLVMValueRef LHS,
2722 LLVMValueRef RHS, const char *Name);
2723 LLVMValueRef LLVMBuildFence(LLVMBuilderRef B, LLVMAtomicOrdering ordering,
2724 LLVMBool singleThread, const char *Name);
2725 LLVMValueRef LLVMBuildAtomicRMW(LLVMBuilderRef B, LLVMAtomicRMWBinOp op,
2726 LLVMValueRef PTR, LLVMValueRef Val,
2727 LLVMAtomicOrdering ordering,
2728 LLVMBool singleThread);
2735 * @defgroup LLVMCCoreModuleProvider Module Providers
2741 * Changes the type of M so it can be passed to FunctionPassManagers and the
2742 * JIT. They take ModuleProviders for historical reasons.
2744 LLVMModuleProviderRef
2745 LLVMCreateModuleProviderForExistingModule(LLVMModuleRef M);
2748 * Destroys the module M.
2750 void LLVMDisposeModuleProvider(LLVMModuleProviderRef M);
2757 * @defgroup LLVMCCoreMemoryBuffers Memory Buffers
2762 LLVMBool LLVMCreateMemoryBufferWithContentsOfFile(const char *Path,
2763 LLVMMemoryBufferRef *OutMemBuf,
2765 LLVMBool LLVMCreateMemoryBufferWithSTDIN(LLVMMemoryBufferRef *OutMemBuf,
2767 LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRange(const char *InputData,
2768 size_t InputDataLength,
2769 const char *BufferName,
2770 LLVMBool RequiresNullTerminator);
2771 LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRangeCopy(const char *InputData,
2772 size_t InputDataLength,
2773 const char *BufferName);
2774 const char *LLVMGetBufferStart(LLVMMemoryBufferRef MemBuf);
2775 size_t LLVMGetBufferSize(LLVMMemoryBufferRef MemBuf);
2776 void LLVMDisposeMemoryBuffer(LLVMMemoryBufferRef MemBuf);
2783 * @defgroup LLVMCCorePass Pass
2788 const char *LLVMGetPassName(LLVMPassRef);
2795 * @defgroup LLVMCCorePassRegistry Pass Registry
2800 /** Return the global pass registry, for use with initialization functions.
2801 @see llvm::PassRegistry::getPassRegistry */
2802 LLVMPassRegistryRef LLVMGetGlobalPassRegistry(void);
2809 * @defgroup LLVMCCorePassManagers Pass Managers
2814 /** Constructs a new whole-module pass pipeline. This type of pipeline is
2815 suitable for link-time optimization and whole-module transformations.
2816 @see llvm::PassManager::PassManager */
2817 LLVMPassManagerRef LLVMCreatePassManager(void);
2819 /** Constructs a new function-by-function pass pipeline over the module
2820 provider. It does not take ownership of the module provider. This type of
2821 pipeline is suitable for code generation and JIT compilation tasks.
2822 @see llvm::FunctionPassManager::FunctionPassManager */
2823 LLVMPassManagerRef LLVMCreateFunctionPassManagerForModule(LLVMModuleRef M);
2825 /** Deprecated: Use LLVMCreateFunctionPassManagerForModule instead. */
2826 LLVMPassManagerRef LLVMCreateFunctionPassManager(LLVMModuleProviderRef MP);
2828 /** Initializes, executes on the provided module, and finalizes all of the
2829 passes scheduled in the pass manager. Returns 1 if any of the passes
2830 modified the module, 0 otherwise.
2831 @see llvm::PassManager::run(Module&) */
2832 LLVMBool LLVMRunPassManager(LLVMPassManagerRef PM, LLVMModuleRef M);
2834 /** Initializes all of the function passes scheduled in the function pass
2835 manager. Returns 1 if any of the passes modified the module, 0 otherwise.
2836 @see llvm::FunctionPassManager::doInitialization */
2837 LLVMBool LLVMInitializeFunctionPassManager(LLVMPassManagerRef FPM);
2839 /** Executes all of the function passes scheduled in the function pass manager
2840 on the provided function. Returns 1 if any of the passes modified the
2841 function, false otherwise.
2842 @see llvm::FunctionPassManager::run(Function&) */
2843 LLVMBool LLVMRunFunctionPassManager(LLVMPassManagerRef FPM, LLVMValueRef F);
2845 /** Finalizes all of the function passes scheduled in in the function pass
2846 manager. Returns 1 if any of the passes modified the module, 0 otherwise.
2847 @see llvm::FunctionPassManager::doFinalization */
2848 LLVMBool LLVMFinalizeFunctionPassManager(LLVMPassManagerRef FPM);
2850 /** Frees the memory of a pass pipeline. For function pipelines, does not free
2851 the module provider.
2852 @see llvm::PassManagerBase::~PassManagerBase. */
2853 void LLVMDisposePassManager(LLVMPassManagerRef PM);
2860 * @defgroup LLVMCCoreThreading Threading
2862 * Handle the structures needed to make LLVM safe for multithreading.
2867 /** Allocate and initialize structures needed to make LLVM safe for
2868 multithreading. The return value indicates whether multithreaded
2869 initialization succeeded. Must be executed in isolation from all
2870 other LLVM api calls.
2871 @see llvm::llvm_start_multithreaded */
2872 LLVMBool LLVMStartMultithreaded(void);
2874 /** Deallocate structures necessary to make LLVM safe for multithreading.
2875 Must be executed in isolation from all other LLVM api calls.
2876 @see llvm::llvm_stop_multithreaded */
2877 void LLVMStopMultithreaded(void);
2879 /** Check whether LLVM is executing in thread-safe mode or not.
2880 @see llvm::llvm_is_multithreaded */
2881 LLVMBool LLVMIsMultithreaded(void);
2897 #endif /* !defined(__cplusplus) */
2899 #endif /* !defined(LLVM_C_CORE_H) */