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) \
1177 macro(GlobalAlias) \
1178 macro(GlobalVariable) \
1180 macro(Instruction) \
1181 macro(BinaryOperator) \
1183 macro(IntrinsicInst) \
1184 macro(DbgInfoIntrinsic) \
1185 macro(DbgDeclareInst) \
1186 macro(MemIntrinsic) \
1188 macro(MemMoveInst) \
1193 macro(ExtractElementInst) \
1194 macro(GetElementPtrInst) \
1195 macro(InsertElementInst) \
1196 macro(InsertValueInst) \
1197 macro(LandingPadInst) \
1200 macro(ShuffleVectorInst) \
1202 macro(TerminatorInst) \
1204 macro(IndirectBrInst) \
1208 macro(UnreachableInst) \
1210 macro(UnaryInstruction) \
1213 macro(AddrSpaceCastInst) \
1214 macro(BitCastInst) \
1218 macro(FPTruncInst) \
1219 macro(IntToPtrInst) \
1220 macro(PtrToIntInst) \
1226 macro(ExtractValueInst) \
1231 * @defgroup LLVMCCoreValueGeneral General APIs
1233 * Functions in this section work on all LLVMValueRef instances,
1234 * regardless of their sub-type. They correspond to functions available
1241 * Obtain the type of a value.
1243 * @see llvm::Value::getType()
1245 LLVMTypeRef LLVMTypeOf(LLVMValueRef Val);
1248 * Obtain the string name of a value.
1250 * @see llvm::Value::getName()
1252 const char *LLVMGetValueName(LLVMValueRef Val);
1255 * Set the string name of a value.
1257 * @see llvm::Value::setName()
1259 void LLVMSetValueName(LLVMValueRef Val, const char *Name);
1262 * Dump a representation of a value to stderr.
1264 * @see llvm::Value::dump()
1266 void LLVMDumpValue(LLVMValueRef Val);
1269 * Return a string representation of the value. Use
1270 * LLVMDisposeMessage to free the string.
1272 * @see llvm::Value::print()
1274 char *LLVMPrintValueToString(LLVMValueRef Val);
1277 * Replace all uses of a value with another one.
1279 * @see llvm::Value::replaceAllUsesWith()
1281 void LLVMReplaceAllUsesWith(LLVMValueRef OldVal, LLVMValueRef NewVal);
1284 * Determine whether the specified constant instance is constant.
1286 LLVMBool LLVMIsConstant(LLVMValueRef Val);
1289 * Determine whether a value instance is undefined.
1291 LLVMBool LLVMIsUndef(LLVMValueRef Val);
1294 * Convert value instances between types.
1296 * Internally, an LLVMValueRef is "pinned" to a specific type. This
1297 * series of functions allows you to cast an instance to a specific
1300 * If the cast is not valid for the specified type, NULL is returned.
1302 * @see llvm::dyn_cast_or_null<>
1304 #define LLVM_DECLARE_VALUE_CAST(name) \
1305 LLVMValueRef LLVMIsA##name(LLVMValueRef Val);
1306 LLVM_FOR_EACH_VALUE_SUBCLASS(LLVM_DECLARE_VALUE_CAST)
1313 * @defgroup LLVMCCoreValueUses Usage
1315 * This module defines functions that allow you to inspect the uses of a
1318 * It is possible to obtain an LLVMUseRef for any LLVMValueRef instance.
1319 * Each LLVMUseRef (which corresponds to a llvm::Use instance) holds a
1320 * llvm::User and llvm::Value.
1326 * Obtain the first use of a value.
1328 * Uses are obtained in an iterator fashion. First, call this function
1329 * to obtain a reference to the first use. Then, call LLVMGetNextUse()
1330 * on that instance and all subsequently obtained instances until
1331 * LLVMGetNextUse() returns NULL.
1333 * @see llvm::Value::use_begin()
1335 LLVMUseRef LLVMGetFirstUse(LLVMValueRef Val);
1338 * Obtain the next use of a value.
1340 * This effectively advances the iterator. It returns NULL if you are on
1341 * the final use and no more are available.
1343 LLVMUseRef LLVMGetNextUse(LLVMUseRef U);
1346 * Obtain the user value for a user.
1348 * The returned value corresponds to a llvm::User type.
1350 * @see llvm::Use::getUser()
1352 LLVMValueRef LLVMGetUser(LLVMUseRef U);
1355 * Obtain the value this use corresponds to.
1357 * @see llvm::Use::get().
1359 LLVMValueRef LLVMGetUsedValue(LLVMUseRef U);
1366 * @defgroup LLVMCCoreValueUser User value
1368 * Function in this group pertain to LLVMValueRef instances that descent
1369 * from llvm::User. This includes constants, instructions, and
1376 * Obtain an operand at a specific index in a llvm::User value.
1378 * @see llvm::User::getOperand()
1380 LLVMValueRef LLVMGetOperand(LLVMValueRef Val, unsigned Index);
1383 * Set an operand at a specific index in a llvm::User value.
1385 * @see llvm::User::setOperand()
1387 void LLVMSetOperand(LLVMValueRef User, unsigned Index, LLVMValueRef Val);
1390 * Obtain the number of operands in a llvm::User value.
1392 * @see llvm::User::getNumOperands()
1394 int LLVMGetNumOperands(LLVMValueRef Val);
1401 * @defgroup LLVMCCoreValueConstant Constants
1403 * This section contains APIs for interacting with LLVMValueRef that
1404 * correspond to llvm::Constant instances.
1406 * These functions will work for any LLVMValueRef in the llvm::Constant
1413 * Obtain a constant value referring to the null instance of a type.
1415 * @see llvm::Constant::getNullValue()
1417 LLVMValueRef LLVMConstNull(LLVMTypeRef Ty); /* all zeroes */
1420 * Obtain a constant value referring to the instance of a type
1421 * consisting of all ones.
1423 * This is only valid for integer types.
1425 * @see llvm::Constant::getAllOnesValue()
1427 LLVMValueRef LLVMConstAllOnes(LLVMTypeRef Ty);
1430 * Obtain a constant value referring to an undefined value of a type.
1432 * @see llvm::UndefValue::get()
1434 LLVMValueRef LLVMGetUndef(LLVMTypeRef Ty);
1437 * Determine whether a value instance is null.
1439 * @see llvm::Constant::isNullValue()
1441 LLVMBool LLVMIsNull(LLVMValueRef Val);
1444 * Obtain a constant that is a constant pointer pointing to NULL for a
1447 LLVMValueRef LLVMConstPointerNull(LLVMTypeRef Ty);
1450 * @defgroup LLVMCCoreValueConstantScalar Scalar constants
1452 * Functions in this group model LLVMValueRef instances that correspond
1453 * to constants referring to scalar types.
1455 * For integer types, the LLVMTypeRef parameter should correspond to a
1456 * llvm::IntegerType instance and the returned LLVMValueRef will
1457 * correspond to a llvm::ConstantInt.
1459 * For floating point types, the LLVMTypeRef returned corresponds to a
1466 * Obtain a constant value for an integer type.
1468 * The returned value corresponds to a llvm::ConstantInt.
1470 * @see llvm::ConstantInt::get()
1472 * @param IntTy Integer type to obtain value of.
1473 * @param N The value the returned instance should refer to.
1474 * @param SignExtend Whether to sign extend the produced value.
1476 LLVMValueRef LLVMConstInt(LLVMTypeRef IntTy, unsigned long long N,
1477 LLVMBool SignExtend);
1480 * Obtain a constant value for an integer of arbitrary precision.
1482 * @see llvm::ConstantInt::get()
1484 LLVMValueRef LLVMConstIntOfArbitraryPrecision(LLVMTypeRef IntTy,
1486 const uint64_t Words[]);
1489 * Obtain a constant value for an integer parsed from a string.
1491 * A similar API, LLVMConstIntOfStringAndSize is also available. If the
1492 * string's length is available, it is preferred to call that function
1495 * @see llvm::ConstantInt::get()
1497 LLVMValueRef LLVMConstIntOfString(LLVMTypeRef IntTy, const char *Text,
1501 * Obtain a constant value for an integer parsed from a string with
1504 * @see llvm::ConstantInt::get()
1506 LLVMValueRef LLVMConstIntOfStringAndSize(LLVMTypeRef IntTy, const char *Text,
1507 unsigned SLen, uint8_t Radix);
1510 * Obtain a constant value referring to a double floating point value.
1512 LLVMValueRef LLVMConstReal(LLVMTypeRef RealTy, double N);
1515 * Obtain a constant for a floating point value parsed from a string.
1517 * A similar API, LLVMConstRealOfStringAndSize is also available. It
1518 * should be used if the input string's length is known.
1520 LLVMValueRef LLVMConstRealOfString(LLVMTypeRef RealTy, const char *Text);
1523 * Obtain a constant for a floating point value parsed from a string.
1525 LLVMValueRef LLVMConstRealOfStringAndSize(LLVMTypeRef RealTy, const char *Text,
1529 * Obtain the zero extended value for an integer constant value.
1531 * @see llvm::ConstantInt::getZExtValue()
1533 unsigned long long LLVMConstIntGetZExtValue(LLVMValueRef ConstantVal);
1536 * Obtain the sign extended value for an integer constant value.
1538 * @see llvm::ConstantInt::getSExtValue()
1540 long long LLVMConstIntGetSExtValue(LLVMValueRef ConstantVal);
1547 * @defgroup LLVMCCoreValueConstantComposite Composite Constants
1549 * Functions in this group operate on composite constants.
1555 * Create a ConstantDataSequential and initialize it with a string.
1557 * @see llvm::ConstantDataArray::getString()
1559 LLVMValueRef LLVMConstStringInContext(LLVMContextRef C, const char *Str,
1560 unsigned Length, LLVMBool DontNullTerminate);
1563 * Create a ConstantDataSequential with string content in the global context.
1565 * This is the same as LLVMConstStringInContext except it operates on the
1568 * @see LLVMConstStringInContext()
1569 * @see llvm::ConstantDataArray::getString()
1571 LLVMValueRef LLVMConstString(const char *Str, unsigned Length,
1572 LLVMBool DontNullTerminate);
1575 * Create an anonymous ConstantStruct with the specified values.
1577 * @see llvm::ConstantStruct::getAnon()
1579 LLVMValueRef LLVMConstStructInContext(LLVMContextRef C,
1580 LLVMValueRef *ConstantVals,
1581 unsigned Count, LLVMBool Packed);
1584 * Create a ConstantStruct in the global Context.
1586 * This is the same as LLVMConstStructInContext except it operates on the
1589 * @see LLVMConstStructInContext()
1591 LLVMValueRef LLVMConstStruct(LLVMValueRef *ConstantVals, unsigned Count,
1595 * Create a ConstantArray from values.
1597 * @see llvm::ConstantArray::get()
1599 LLVMValueRef LLVMConstArray(LLVMTypeRef ElementTy,
1600 LLVMValueRef *ConstantVals, unsigned Length);
1603 * Create a non-anonymous ConstantStruct from values.
1605 * @see llvm::ConstantStruct::get()
1607 LLVMValueRef LLVMConstNamedStruct(LLVMTypeRef StructTy,
1608 LLVMValueRef *ConstantVals,
1612 * Create a ConstantVector from values.
1614 * @see llvm::ConstantVector::get()
1616 LLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals, unsigned Size);
1623 * @defgroup LLVMCCoreValueConstantExpressions Constant Expressions
1625 * Functions in this group correspond to APIs on llvm::ConstantExpr.
1627 * @see llvm::ConstantExpr.
1631 LLVMOpcode LLVMGetConstOpcode(LLVMValueRef ConstantVal);
1632 LLVMValueRef LLVMAlignOf(LLVMTypeRef Ty);
1633 LLVMValueRef LLVMSizeOf(LLVMTypeRef Ty);
1634 LLVMValueRef LLVMConstNeg(LLVMValueRef ConstantVal);
1635 LLVMValueRef LLVMConstNSWNeg(LLVMValueRef ConstantVal);
1636 LLVMValueRef LLVMConstNUWNeg(LLVMValueRef ConstantVal);
1637 LLVMValueRef LLVMConstFNeg(LLVMValueRef ConstantVal);
1638 LLVMValueRef LLVMConstNot(LLVMValueRef ConstantVal);
1639 LLVMValueRef LLVMConstAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1640 LLVMValueRef LLVMConstNSWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1641 LLVMValueRef LLVMConstNUWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1642 LLVMValueRef LLVMConstFAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1643 LLVMValueRef LLVMConstSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1644 LLVMValueRef LLVMConstNSWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1645 LLVMValueRef LLVMConstNUWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1646 LLVMValueRef LLVMConstFSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1647 LLVMValueRef LLVMConstMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1648 LLVMValueRef LLVMConstNSWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1649 LLVMValueRef LLVMConstNUWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1650 LLVMValueRef LLVMConstFMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1651 LLVMValueRef LLVMConstUDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1652 LLVMValueRef LLVMConstSDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1653 LLVMValueRef LLVMConstExactSDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1654 LLVMValueRef LLVMConstFDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1655 LLVMValueRef LLVMConstURem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1656 LLVMValueRef LLVMConstSRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1657 LLVMValueRef LLVMConstFRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1658 LLVMValueRef LLVMConstAnd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1659 LLVMValueRef LLVMConstOr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1660 LLVMValueRef LLVMConstXor(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1661 LLVMValueRef LLVMConstICmp(LLVMIntPredicate Predicate,
1662 LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1663 LLVMValueRef LLVMConstFCmp(LLVMRealPredicate Predicate,
1664 LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1665 LLVMValueRef LLVMConstShl(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1666 LLVMValueRef LLVMConstLShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1667 LLVMValueRef LLVMConstAShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1668 LLVMValueRef LLVMConstGEP(LLVMValueRef ConstantVal,
1669 LLVMValueRef *ConstantIndices, unsigned NumIndices);
1670 LLVMValueRef LLVMConstInBoundsGEP(LLVMValueRef ConstantVal,
1671 LLVMValueRef *ConstantIndices,
1672 unsigned NumIndices);
1673 LLVMValueRef LLVMConstTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1674 LLVMValueRef LLVMConstSExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1675 LLVMValueRef LLVMConstZExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1676 LLVMValueRef LLVMConstFPTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1677 LLVMValueRef LLVMConstFPExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1678 LLVMValueRef LLVMConstUIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1679 LLVMValueRef LLVMConstSIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1680 LLVMValueRef LLVMConstFPToUI(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1681 LLVMValueRef LLVMConstFPToSI(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1682 LLVMValueRef LLVMConstPtrToInt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1683 LLVMValueRef LLVMConstIntToPtr(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1684 LLVMValueRef LLVMConstBitCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1685 LLVMValueRef LLVMConstAddrSpaceCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1686 LLVMValueRef LLVMConstZExtOrBitCast(LLVMValueRef ConstantVal,
1687 LLVMTypeRef ToType);
1688 LLVMValueRef LLVMConstSExtOrBitCast(LLVMValueRef ConstantVal,
1689 LLVMTypeRef ToType);
1690 LLVMValueRef LLVMConstTruncOrBitCast(LLVMValueRef ConstantVal,
1691 LLVMTypeRef ToType);
1692 LLVMValueRef LLVMConstPointerCast(LLVMValueRef ConstantVal,
1693 LLVMTypeRef ToType);
1694 LLVMValueRef LLVMConstIntCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType,
1696 LLVMValueRef LLVMConstFPCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1697 LLVMValueRef LLVMConstSelect(LLVMValueRef ConstantCondition,
1698 LLVMValueRef ConstantIfTrue,
1699 LLVMValueRef ConstantIfFalse);
1700 LLVMValueRef LLVMConstExtractElement(LLVMValueRef VectorConstant,
1701 LLVMValueRef IndexConstant);
1702 LLVMValueRef LLVMConstInsertElement(LLVMValueRef VectorConstant,
1703 LLVMValueRef ElementValueConstant,
1704 LLVMValueRef IndexConstant);
1705 LLVMValueRef LLVMConstShuffleVector(LLVMValueRef VectorAConstant,
1706 LLVMValueRef VectorBConstant,
1707 LLVMValueRef MaskConstant);
1708 LLVMValueRef LLVMConstExtractValue(LLVMValueRef AggConstant, unsigned *IdxList,
1710 LLVMValueRef LLVMConstInsertValue(LLVMValueRef AggConstant,
1711 LLVMValueRef ElementValueConstant,
1712 unsigned *IdxList, unsigned NumIdx);
1713 LLVMValueRef LLVMConstInlineAsm(LLVMTypeRef Ty,
1714 const char *AsmString, const char *Constraints,
1715 LLVMBool HasSideEffects, LLVMBool IsAlignStack);
1716 LLVMValueRef LLVMBlockAddress(LLVMValueRef F, LLVMBasicBlockRef BB);
1723 * @defgroup LLVMCCoreValueConstantGlobals Global Values
1725 * This group contains functions that operate on global values. Functions in
1726 * this group relate to functions in the llvm::GlobalValue class tree.
1728 * @see llvm::GlobalValue
1733 LLVMModuleRef LLVMGetGlobalParent(LLVMValueRef Global);
1734 LLVMBool LLVMIsDeclaration(LLVMValueRef Global);
1735 LLVMLinkage LLVMGetLinkage(LLVMValueRef Global);
1736 void LLVMSetLinkage(LLVMValueRef Global, LLVMLinkage Linkage);
1737 const char *LLVMGetSection(LLVMValueRef Global);
1738 void LLVMSetSection(LLVMValueRef Global, const char *Section);
1739 LLVMVisibility LLVMGetVisibility(LLVMValueRef Global);
1740 void LLVMSetVisibility(LLVMValueRef Global, LLVMVisibility Viz);
1741 LLVMDLLStorageClass LLVMGetDLLStorageClass(LLVMValueRef Global);
1742 void LLVMSetDLLStorageClass(LLVMValueRef Global, LLVMDLLStorageClass Class);
1743 LLVMBool LLVMHasUnnamedAddr(LLVMValueRef Global);
1744 void LLVMSetUnnamedAddr(LLVMValueRef Global, LLVMBool HasUnnamedAddr);
1747 * @defgroup LLVMCCoreValueWithAlignment Values with alignment
1749 * Functions in this group only apply to values with alignment, i.e.
1750 * global variables, load and store instructions.
1754 * Obtain the preferred alignment of the value.
1755 * @see llvm::AllocaInst::getAlignment()
1756 * @see llvm::LoadInst::getAlignment()
1757 * @see llvm::StoreInst::getAlignment()
1758 * @see llvm::GlobalValue::getAlignment()
1760 unsigned LLVMGetAlignment(LLVMValueRef V);
1763 * Set the preferred alignment of the value.
1764 * @see llvm::AllocaInst::setAlignment()
1765 * @see llvm::LoadInst::setAlignment()
1766 * @see llvm::StoreInst::setAlignment()
1767 * @see llvm::GlobalValue::setAlignment()
1769 void LLVMSetAlignment(LLVMValueRef V, unsigned Bytes);
1776 * @defgroup LLVMCoreValueConstantGlobalVariable Global Variables
1778 * This group contains functions that operate on global variable values.
1780 * @see llvm::GlobalVariable
1784 LLVMValueRef LLVMAddGlobal(LLVMModuleRef M, LLVMTypeRef Ty, const char *Name);
1785 LLVMValueRef LLVMAddGlobalInAddressSpace(LLVMModuleRef M, LLVMTypeRef Ty,
1787 unsigned AddressSpace);
1788 LLVMValueRef LLVMGetNamedGlobal(LLVMModuleRef M, const char *Name);
1789 LLVMValueRef LLVMGetFirstGlobal(LLVMModuleRef M);
1790 LLVMValueRef LLVMGetLastGlobal(LLVMModuleRef M);
1791 LLVMValueRef LLVMGetNextGlobal(LLVMValueRef GlobalVar);
1792 LLVMValueRef LLVMGetPreviousGlobal(LLVMValueRef GlobalVar);
1793 void LLVMDeleteGlobal(LLVMValueRef GlobalVar);
1794 LLVMValueRef LLVMGetInitializer(LLVMValueRef GlobalVar);
1795 void LLVMSetInitializer(LLVMValueRef GlobalVar, LLVMValueRef ConstantVal);
1796 LLVMBool LLVMIsThreadLocal(LLVMValueRef GlobalVar);
1797 void LLVMSetThreadLocal(LLVMValueRef GlobalVar, LLVMBool IsThreadLocal);
1798 LLVMBool LLVMIsGlobalConstant(LLVMValueRef GlobalVar);
1799 void LLVMSetGlobalConstant(LLVMValueRef GlobalVar, LLVMBool IsConstant);
1800 LLVMThreadLocalMode LLVMGetThreadLocalMode(LLVMValueRef GlobalVar);
1801 void LLVMSetThreadLocalMode(LLVMValueRef GlobalVar, LLVMThreadLocalMode Mode);
1802 LLVMBool LLVMIsExternallyInitialized(LLVMValueRef GlobalVar);
1803 void LLVMSetExternallyInitialized(LLVMValueRef GlobalVar, LLVMBool IsExtInit);
1810 * @defgroup LLVMCoreValueConstantGlobalAlias Global Aliases
1812 * This group contains function that operate on global alias values.
1814 * @see llvm::GlobalAlias
1818 LLVMValueRef LLVMAddAlias(LLVMModuleRef M, LLVMTypeRef Ty, LLVMValueRef Aliasee,
1826 * @defgroup LLVMCCoreValueFunction Function values
1828 * Functions in this group operate on LLVMValueRef instances that
1829 * correspond to llvm::Function instances.
1831 * @see llvm::Function
1837 * Remove a function from its containing module and deletes it.
1839 * @see llvm::Function::eraseFromParent()
1841 void LLVMDeleteFunction(LLVMValueRef Fn);
1844 * Obtain the ID number from a function instance.
1846 * @see llvm::Function::getIntrinsicID()
1848 unsigned LLVMGetIntrinsicID(LLVMValueRef Fn);
1851 * Obtain the calling function of a function.
1853 * The returned value corresponds to the LLVMCallConv enumeration.
1855 * @see llvm::Function::getCallingConv()
1857 unsigned LLVMGetFunctionCallConv(LLVMValueRef Fn);
1860 * Set the calling convention of a function.
1862 * @see llvm::Function::setCallingConv()
1864 * @param Fn Function to operate on
1865 * @param CC LLVMCallConv to set calling convention to
1867 void LLVMSetFunctionCallConv(LLVMValueRef Fn, unsigned CC);
1870 * Obtain the name of the garbage collector to use during code
1873 * @see llvm::Function::getGC()
1875 const char *LLVMGetGC(LLVMValueRef Fn);
1878 * Define the garbage collector to use during code generation.
1880 * @see llvm::Function::setGC()
1882 void LLVMSetGC(LLVMValueRef Fn, const char *Name);
1885 * Add an attribute to a function.
1887 * @see llvm::Function::addAttribute()
1889 void LLVMAddFunctionAttr(LLVMValueRef Fn, LLVMAttribute PA);
1892 * Add a target-dependent attribute to a fuction
1893 * @see llvm::AttrBuilder::addAttribute()
1895 void LLVMAddTargetDependentFunctionAttr(LLVMValueRef Fn, const char *A,
1899 * Obtain an attribute from a function.
1901 * @see llvm::Function::getAttributes()
1903 LLVMAttribute LLVMGetFunctionAttr(LLVMValueRef Fn);
1906 * Remove an attribute from a function.
1908 void LLVMRemoveFunctionAttr(LLVMValueRef Fn, LLVMAttribute PA);
1911 * @defgroup LLVMCCoreValueFunctionParameters Function Parameters
1913 * Functions in this group relate to arguments/parameters on functions.
1915 * Functions in this group expect LLVMValueRef instances that correspond
1916 * to llvm::Function instances.
1922 * Obtain the number of parameters in a function.
1924 * @see llvm::Function::arg_size()
1926 unsigned LLVMCountParams(LLVMValueRef Fn);
1929 * Obtain the parameters in a function.
1931 * The takes a pointer to a pre-allocated array of LLVMValueRef that is
1932 * at least LLVMCountParams() long. This array will be filled with
1933 * LLVMValueRef instances which correspond to the parameters the
1934 * function receives. Each LLVMValueRef corresponds to a llvm::Argument
1937 * @see llvm::Function::arg_begin()
1939 void LLVMGetParams(LLVMValueRef Fn, LLVMValueRef *Params);
1942 * Obtain the parameter at the specified index.
1944 * Parameters are indexed from 0.
1946 * @see llvm::Function::arg_begin()
1948 LLVMValueRef LLVMGetParam(LLVMValueRef Fn, unsigned Index);
1951 * Obtain the function to which this argument belongs.
1953 * Unlike other functions in this group, this one takes an LLVMValueRef
1954 * that corresponds to a llvm::Attribute.
1956 * The returned LLVMValueRef is the llvm::Function to which this
1959 LLVMValueRef LLVMGetParamParent(LLVMValueRef Inst);
1962 * Obtain the first parameter to a function.
1964 * @see llvm::Function::arg_begin()
1966 LLVMValueRef LLVMGetFirstParam(LLVMValueRef Fn);
1969 * Obtain the last parameter to a function.
1971 * @see llvm::Function::arg_end()
1973 LLVMValueRef LLVMGetLastParam(LLVMValueRef Fn);
1976 * Obtain the next parameter to a function.
1978 * This takes an LLVMValueRef obtained from LLVMGetFirstParam() (which is
1979 * actually a wrapped iterator) and obtains the next parameter from the
1980 * underlying iterator.
1982 LLVMValueRef LLVMGetNextParam(LLVMValueRef Arg);
1985 * Obtain the previous parameter to a function.
1987 * This is the opposite of LLVMGetNextParam().
1989 LLVMValueRef LLVMGetPreviousParam(LLVMValueRef Arg);
1992 * Add an attribute to a function argument.
1994 * @see llvm::Argument::addAttr()
1996 void LLVMAddAttribute(LLVMValueRef Arg, LLVMAttribute PA);
1999 * Remove an attribute from a function argument.
2001 * @see llvm::Argument::removeAttr()
2003 void LLVMRemoveAttribute(LLVMValueRef Arg, LLVMAttribute PA);
2006 * Get an attribute from a function argument.
2008 LLVMAttribute LLVMGetAttribute(LLVMValueRef Arg);
2011 * Set the alignment for a function parameter.
2013 * @see llvm::Argument::addAttr()
2014 * @see llvm::AttrBuilder::addAlignmentAttr()
2016 void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned align);
2035 * @defgroup LLVMCCoreValueMetadata Metadata
2041 * Obtain a MDString value from a context.
2043 * The returned instance corresponds to the llvm::MDString class.
2045 * The instance is specified by string data of a specified length. The
2046 * string content is copied, so the backing memory can be freed after
2047 * this function returns.
2049 LLVMValueRef LLVMMDStringInContext(LLVMContextRef C, const char *Str,
2053 * Obtain a MDString value from the global context.
2055 LLVMValueRef LLVMMDString(const char *Str, unsigned SLen);
2058 * Obtain a MDNode value from a context.
2060 * The returned value corresponds to the llvm::MDNode class.
2062 LLVMValueRef LLVMMDNodeInContext(LLVMContextRef C, LLVMValueRef *Vals,
2066 * Obtain a MDNode value from the global context.
2068 LLVMValueRef LLVMMDNode(LLVMValueRef *Vals, unsigned Count);
2071 * Obtain the underlying string from a MDString value.
2073 * @param V Instance to obtain string from.
2074 * @param Len Memory address which will hold length of returned string.
2075 * @return String data in MDString.
2077 const char *LLVMGetMDString(LLVMValueRef V, unsigned* Len);
2080 * Obtain the number of operands from an MDNode value.
2082 * @param V MDNode to get number of operands from.
2083 * @return Number of operands of the MDNode.
2085 unsigned LLVMGetMDNodeNumOperands(LLVMValueRef V);
2088 * Obtain the given MDNode's operands.
2090 * The passed LLVMValueRef pointer should point to enough memory to hold all of
2091 * the operands of the given MDNode (see LLVMGetMDNodeNumOperands) as
2092 * LLVMValueRefs. This memory will be populated with the LLVMValueRefs of the
2093 * MDNode's operands.
2095 * @param V MDNode to get the operands from.
2096 * @param Dest Destination array for operands.
2098 void LLVMGetMDNodeOperands(LLVMValueRef V, LLVMValueRef *Dest);
2105 * @defgroup LLVMCCoreValueBasicBlock Basic Block
2107 * A basic block represents a single entry single exit section of code.
2108 * Basic blocks contain a list of instructions which form the body of
2111 * Basic blocks belong to functions. They have the type of label.
2113 * Basic blocks are themselves values. However, the C API models them as
2114 * LLVMBasicBlockRef.
2116 * @see llvm::BasicBlock
2122 * Convert a basic block instance to a value type.
2124 LLVMValueRef LLVMBasicBlockAsValue(LLVMBasicBlockRef BB);
2127 * Determine whether an LLVMValueRef is itself a basic block.
2129 LLVMBool LLVMValueIsBasicBlock(LLVMValueRef Val);
2132 * Convert an LLVMValueRef to an LLVMBasicBlockRef instance.
2134 LLVMBasicBlockRef LLVMValueAsBasicBlock(LLVMValueRef Val);
2137 * Obtain the function to which a basic block belongs.
2139 * @see llvm::BasicBlock::getParent()
2141 LLVMValueRef LLVMGetBasicBlockParent(LLVMBasicBlockRef BB);
2144 * Obtain the terminator instruction for a basic block.
2146 * If the basic block does not have a terminator (it is not well-formed
2147 * if it doesn't), then NULL is returned.
2149 * The returned LLVMValueRef corresponds to a llvm::TerminatorInst.
2151 * @see llvm::BasicBlock::getTerminator()
2153 LLVMValueRef LLVMGetBasicBlockTerminator(LLVMBasicBlockRef BB);
2156 * Obtain the number of basic blocks in a function.
2158 * @param Fn Function value to operate on.
2160 unsigned LLVMCountBasicBlocks(LLVMValueRef Fn);
2163 * Obtain all of the basic blocks in a function.
2165 * This operates on a function value. The BasicBlocks parameter is a
2166 * pointer to a pre-allocated array of LLVMBasicBlockRef of at least
2167 * LLVMCountBasicBlocks() in length. This array is populated with
2168 * LLVMBasicBlockRef instances.
2170 void LLVMGetBasicBlocks(LLVMValueRef Fn, LLVMBasicBlockRef *BasicBlocks);
2173 * Obtain the first basic block in a function.
2175 * The returned basic block can be used as an iterator. You will likely
2176 * eventually call into LLVMGetNextBasicBlock() with it.
2178 * @see llvm::Function::begin()
2180 LLVMBasicBlockRef LLVMGetFirstBasicBlock(LLVMValueRef Fn);
2183 * Obtain the last basic block in a function.
2185 * @see llvm::Function::end()
2187 LLVMBasicBlockRef LLVMGetLastBasicBlock(LLVMValueRef Fn);
2190 * Advance a basic block iterator.
2192 LLVMBasicBlockRef LLVMGetNextBasicBlock(LLVMBasicBlockRef BB);
2195 * Go backwards in a basic block iterator.
2197 LLVMBasicBlockRef LLVMGetPreviousBasicBlock(LLVMBasicBlockRef BB);
2200 * Obtain the basic block that corresponds to the entry point of a
2203 * @see llvm::Function::getEntryBlock()
2205 LLVMBasicBlockRef LLVMGetEntryBasicBlock(LLVMValueRef Fn);
2208 * Append a basic block to the end of a function.
2210 * @see llvm::BasicBlock::Create()
2212 LLVMBasicBlockRef LLVMAppendBasicBlockInContext(LLVMContextRef C,
2217 * Append a basic block to the end of a function using the global
2220 * @see llvm::BasicBlock::Create()
2222 LLVMBasicBlockRef LLVMAppendBasicBlock(LLVMValueRef Fn, const char *Name);
2225 * Insert a basic block in a function before another basic block.
2227 * The function to add to is determined by the function of the
2228 * passed basic block.
2230 * @see llvm::BasicBlock::Create()
2232 LLVMBasicBlockRef LLVMInsertBasicBlockInContext(LLVMContextRef C,
2233 LLVMBasicBlockRef BB,
2237 * Insert a basic block in a function using the global context.
2239 * @see llvm::BasicBlock::Create()
2241 LLVMBasicBlockRef LLVMInsertBasicBlock(LLVMBasicBlockRef InsertBeforeBB,
2245 * Remove a basic block from a function and delete it.
2247 * This deletes the basic block from its containing function and deletes
2248 * the basic block itself.
2250 * @see llvm::BasicBlock::eraseFromParent()
2252 void LLVMDeleteBasicBlock(LLVMBasicBlockRef BB);
2255 * Remove a basic block from a function.
2257 * This deletes the basic block from its containing function but keep
2258 * the basic block alive.
2260 * @see llvm::BasicBlock::removeFromParent()
2262 void LLVMRemoveBasicBlockFromParent(LLVMBasicBlockRef BB);
2265 * Move a basic block to before another one.
2267 * @see llvm::BasicBlock::moveBefore()
2269 void LLVMMoveBasicBlockBefore(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos);
2272 * Move a basic block to after another one.
2274 * @see llvm::BasicBlock::moveAfter()
2276 void LLVMMoveBasicBlockAfter(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos);
2279 * Obtain the first instruction in a basic block.
2281 * The returned LLVMValueRef corresponds to a llvm::Instruction
2284 LLVMValueRef LLVMGetFirstInstruction(LLVMBasicBlockRef BB);
2287 * Obtain the last instruction in a basic block.
2289 * The returned LLVMValueRef corresponds to an LLVM:Instruction.
2291 LLVMValueRef LLVMGetLastInstruction(LLVMBasicBlockRef BB);
2298 * @defgroup LLVMCCoreValueInstruction Instructions
2300 * Functions in this group relate to the inspection and manipulation of
2301 * individual instructions.
2303 * In the C++ API, an instruction is modeled by llvm::Instruction. This
2304 * class has a large number of descendents. llvm::Instruction is a
2305 * llvm::Value and in the C API, instructions are modeled by
2308 * This group also contains sub-groups which operate on specific
2309 * llvm::Instruction types, e.g. llvm::CallInst.
2315 * Determine whether an instruction has any metadata attached.
2317 int LLVMHasMetadata(LLVMValueRef Val);
2320 * Return metadata associated with an instruction value.
2322 LLVMValueRef LLVMGetMetadata(LLVMValueRef Val, unsigned KindID);
2325 * Set metadata associated with an instruction value.
2327 void LLVMSetMetadata(LLVMValueRef Val, unsigned KindID, LLVMValueRef Node);
2330 * Obtain the basic block to which an instruction belongs.
2332 * @see llvm::Instruction::getParent()
2334 LLVMBasicBlockRef LLVMGetInstructionParent(LLVMValueRef Inst);
2337 * Obtain the instruction that occurs after the one specified.
2339 * The next instruction will be from the same basic block.
2341 * If this is the last instruction in a basic block, NULL will be
2344 LLVMValueRef LLVMGetNextInstruction(LLVMValueRef Inst);
2347 * Obtain the instruction that occurred before this one.
2349 * If the instruction is the first instruction in a basic block, NULL
2352 LLVMValueRef LLVMGetPreviousInstruction(LLVMValueRef Inst);
2355 * Remove and delete an instruction.
2357 * The instruction specified is removed from its containing building
2358 * block and then deleted.
2360 * @see llvm::Instruction::eraseFromParent()
2362 void LLVMInstructionEraseFromParent(LLVMValueRef Inst);
2365 * Obtain the code opcode for an individual instruction.
2367 * @see llvm::Instruction::getOpCode()
2369 LLVMOpcode LLVMGetInstructionOpcode(LLVMValueRef Inst);
2372 * Obtain the predicate of an instruction.
2374 * This is only valid for instructions that correspond to llvm::ICmpInst
2375 * or llvm::ConstantExpr whose opcode is llvm::Instruction::ICmp.
2377 * @see llvm::ICmpInst::getPredicate()
2379 LLVMIntPredicate LLVMGetICmpPredicate(LLVMValueRef Inst);
2382 * @defgroup LLVMCCoreValueInstructionCall Call Sites and Invocations
2384 * Functions in this group apply to instructions that refer to call
2385 * sites and invocations. These correspond to C++ types in the
2386 * llvm::CallInst class tree.
2392 * Set the calling convention for a call instruction.
2394 * This expects an LLVMValueRef that corresponds to a llvm::CallInst or
2397 * @see llvm::CallInst::setCallingConv()
2398 * @see llvm::InvokeInst::setCallingConv()
2400 void LLVMSetInstructionCallConv(LLVMValueRef Instr, unsigned CC);
2403 * Obtain the calling convention for a call instruction.
2405 * This is the opposite of LLVMSetInstructionCallConv(). Reads its
2408 * @see LLVMSetInstructionCallConv()
2410 unsigned LLVMGetInstructionCallConv(LLVMValueRef Instr);
2413 void LLVMAddInstrAttribute(LLVMValueRef Instr, unsigned index, LLVMAttribute);
2414 void LLVMRemoveInstrAttribute(LLVMValueRef Instr, unsigned index,
2416 void LLVMSetInstrParamAlignment(LLVMValueRef Instr, unsigned index,
2420 * Obtain whether a call instruction is a tail call.
2422 * This only works on llvm::CallInst instructions.
2424 * @see llvm::CallInst::isTailCall()
2426 LLVMBool LLVMIsTailCall(LLVMValueRef CallInst);
2429 * Set whether a call instruction is a tail call.
2431 * This only works on llvm::CallInst instructions.
2433 * @see llvm::CallInst::setTailCall()
2435 void LLVMSetTailCall(LLVMValueRef CallInst, LLVMBool IsTailCall);
2442 * Obtain the default destination basic block of a switch instruction.
2444 * This only works on llvm::SwitchInst instructions.
2446 * @see llvm::SwitchInst::getDefaultDest()
2448 LLVMBasicBlockRef LLVMGetSwitchDefaultDest(LLVMValueRef SwitchInstr);
2451 * @defgroup LLVMCCoreValueInstructionPHINode PHI Nodes
2453 * Functions in this group only apply to instructions that map to
2454 * llvm::PHINode instances.
2460 * Add an incoming value to the end of a PHI list.
2462 void LLVMAddIncoming(LLVMValueRef PhiNode, LLVMValueRef *IncomingValues,
2463 LLVMBasicBlockRef *IncomingBlocks, unsigned Count);
2466 * Obtain the number of incoming basic blocks to a PHI node.
2468 unsigned LLVMCountIncoming(LLVMValueRef PhiNode);
2471 * Obtain an incoming value to a PHI node as an LLVMValueRef.
2473 LLVMValueRef LLVMGetIncomingValue(LLVMValueRef PhiNode, unsigned Index);
2476 * Obtain an incoming value to a PHI node as an LLVMBasicBlockRef.
2478 LLVMBasicBlockRef LLVMGetIncomingBlock(LLVMValueRef PhiNode, unsigned Index);
2493 * @defgroup LLVMCCoreInstructionBuilder Instruction Builders
2495 * An instruction builder represents a point within a basic block and is
2496 * the exclusive means of building instructions using the C interface.
2501 LLVMBuilderRef LLVMCreateBuilderInContext(LLVMContextRef C);
2502 LLVMBuilderRef LLVMCreateBuilder(void);
2503 void LLVMPositionBuilder(LLVMBuilderRef Builder, LLVMBasicBlockRef Block,
2504 LLVMValueRef Instr);
2505 void LLVMPositionBuilderBefore(LLVMBuilderRef Builder, LLVMValueRef Instr);
2506 void LLVMPositionBuilderAtEnd(LLVMBuilderRef Builder, LLVMBasicBlockRef Block);
2507 LLVMBasicBlockRef LLVMGetInsertBlock(LLVMBuilderRef Builder);
2508 void LLVMClearInsertionPosition(LLVMBuilderRef Builder);
2509 void LLVMInsertIntoBuilder(LLVMBuilderRef Builder, LLVMValueRef Instr);
2510 void LLVMInsertIntoBuilderWithName(LLVMBuilderRef Builder, LLVMValueRef Instr,
2512 void LLVMDisposeBuilder(LLVMBuilderRef Builder);
2515 void LLVMSetCurrentDebugLocation(LLVMBuilderRef Builder, LLVMValueRef L);
2516 LLVMValueRef LLVMGetCurrentDebugLocation(LLVMBuilderRef Builder);
2517 void LLVMSetInstDebugLocation(LLVMBuilderRef Builder, LLVMValueRef Inst);
2520 LLVMValueRef LLVMBuildRetVoid(LLVMBuilderRef);
2521 LLVMValueRef LLVMBuildRet(LLVMBuilderRef, LLVMValueRef V);
2522 LLVMValueRef LLVMBuildAggregateRet(LLVMBuilderRef, LLVMValueRef *RetVals,
2524 LLVMValueRef LLVMBuildBr(LLVMBuilderRef, LLVMBasicBlockRef Dest);
2525 LLVMValueRef LLVMBuildCondBr(LLVMBuilderRef, LLVMValueRef If,
2526 LLVMBasicBlockRef Then, LLVMBasicBlockRef Else);
2527 LLVMValueRef LLVMBuildSwitch(LLVMBuilderRef, LLVMValueRef V,
2528 LLVMBasicBlockRef Else, unsigned NumCases);
2529 LLVMValueRef LLVMBuildIndirectBr(LLVMBuilderRef B, LLVMValueRef Addr,
2531 LLVMValueRef LLVMBuildInvoke(LLVMBuilderRef, LLVMValueRef Fn,
2532 LLVMValueRef *Args, unsigned NumArgs,
2533 LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch,
2535 LLVMValueRef LLVMBuildLandingPad(LLVMBuilderRef B, LLVMTypeRef Ty,
2536 LLVMValueRef PersFn, unsigned NumClauses,
2538 LLVMValueRef LLVMBuildResume(LLVMBuilderRef B, LLVMValueRef Exn);
2539 LLVMValueRef LLVMBuildUnreachable(LLVMBuilderRef);
2541 /* Add a case to the switch instruction */
2542 void LLVMAddCase(LLVMValueRef Switch, LLVMValueRef OnVal,
2543 LLVMBasicBlockRef Dest);
2545 /* Add a destination to the indirectbr instruction */
2546 void LLVMAddDestination(LLVMValueRef IndirectBr, LLVMBasicBlockRef Dest);
2548 /* Add a catch or filter clause to the landingpad instruction */
2549 void LLVMAddClause(LLVMValueRef LandingPad, LLVMValueRef ClauseVal);
2551 /* Set the 'cleanup' flag in the landingpad instruction */
2552 void LLVMSetCleanup(LLVMValueRef LandingPad, LLVMBool Val);
2555 LLVMValueRef LLVMBuildAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2557 LLVMValueRef LLVMBuildNSWAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2559 LLVMValueRef LLVMBuildNUWAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2561 LLVMValueRef LLVMBuildFAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2563 LLVMValueRef LLVMBuildSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2565 LLVMValueRef LLVMBuildNSWSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2567 LLVMValueRef LLVMBuildNUWSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2569 LLVMValueRef LLVMBuildFSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2571 LLVMValueRef LLVMBuildMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2573 LLVMValueRef LLVMBuildNSWMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2575 LLVMValueRef LLVMBuildNUWMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2577 LLVMValueRef LLVMBuildFMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2579 LLVMValueRef LLVMBuildUDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2581 LLVMValueRef LLVMBuildSDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2583 LLVMValueRef LLVMBuildExactSDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2585 LLVMValueRef LLVMBuildFDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2587 LLVMValueRef LLVMBuildURem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2589 LLVMValueRef LLVMBuildSRem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2591 LLVMValueRef LLVMBuildFRem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2593 LLVMValueRef LLVMBuildShl(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2595 LLVMValueRef LLVMBuildLShr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2597 LLVMValueRef LLVMBuildAShr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2599 LLVMValueRef LLVMBuildAnd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2601 LLVMValueRef LLVMBuildOr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2603 LLVMValueRef LLVMBuildXor(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2605 LLVMValueRef LLVMBuildBinOp(LLVMBuilderRef B, LLVMOpcode Op,
2606 LLVMValueRef LHS, LLVMValueRef RHS,
2608 LLVMValueRef LLVMBuildNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name);
2609 LLVMValueRef LLVMBuildNSWNeg(LLVMBuilderRef B, LLVMValueRef V,
2611 LLVMValueRef LLVMBuildNUWNeg(LLVMBuilderRef B, LLVMValueRef V,
2613 LLVMValueRef LLVMBuildFNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name);
2614 LLVMValueRef LLVMBuildNot(LLVMBuilderRef, LLVMValueRef V, const char *Name);
2617 LLVMValueRef LLVMBuildMalloc(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
2618 LLVMValueRef LLVMBuildArrayMalloc(LLVMBuilderRef, LLVMTypeRef Ty,
2619 LLVMValueRef Val, const char *Name);
2620 LLVMValueRef LLVMBuildAlloca(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
2621 LLVMValueRef LLVMBuildArrayAlloca(LLVMBuilderRef, LLVMTypeRef Ty,
2622 LLVMValueRef Val, const char *Name);
2623 LLVMValueRef LLVMBuildFree(LLVMBuilderRef, LLVMValueRef PointerVal);
2624 LLVMValueRef LLVMBuildLoad(LLVMBuilderRef, LLVMValueRef PointerVal,
2626 LLVMValueRef LLVMBuildStore(LLVMBuilderRef, LLVMValueRef Val, LLVMValueRef Ptr);
2627 LLVMValueRef LLVMBuildGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
2628 LLVMValueRef *Indices, unsigned NumIndices,
2630 LLVMValueRef LLVMBuildInBoundsGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
2631 LLVMValueRef *Indices, unsigned NumIndices,
2633 LLVMValueRef LLVMBuildStructGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
2634 unsigned Idx, const char *Name);
2635 LLVMValueRef LLVMBuildGlobalString(LLVMBuilderRef B, const char *Str,
2637 LLVMValueRef LLVMBuildGlobalStringPtr(LLVMBuilderRef B, const char *Str,
2639 LLVMBool LLVMGetVolatile(LLVMValueRef MemoryAccessInst);
2640 void LLVMSetVolatile(LLVMValueRef MemoryAccessInst, LLVMBool IsVolatile);
2643 LLVMValueRef LLVMBuildTrunc(LLVMBuilderRef, LLVMValueRef Val,
2644 LLVMTypeRef DestTy, const char *Name);
2645 LLVMValueRef LLVMBuildZExt(LLVMBuilderRef, LLVMValueRef Val,
2646 LLVMTypeRef DestTy, const char *Name);
2647 LLVMValueRef LLVMBuildSExt(LLVMBuilderRef, LLVMValueRef Val,
2648 LLVMTypeRef DestTy, const char *Name);
2649 LLVMValueRef LLVMBuildFPToUI(LLVMBuilderRef, LLVMValueRef Val,
2650 LLVMTypeRef DestTy, const char *Name);
2651 LLVMValueRef LLVMBuildFPToSI(LLVMBuilderRef, LLVMValueRef Val,
2652 LLVMTypeRef DestTy, const char *Name);
2653 LLVMValueRef LLVMBuildUIToFP(LLVMBuilderRef, LLVMValueRef Val,
2654 LLVMTypeRef DestTy, const char *Name);
2655 LLVMValueRef LLVMBuildSIToFP(LLVMBuilderRef, LLVMValueRef Val,
2656 LLVMTypeRef DestTy, const char *Name);
2657 LLVMValueRef LLVMBuildFPTrunc(LLVMBuilderRef, LLVMValueRef Val,
2658 LLVMTypeRef DestTy, const char *Name);
2659 LLVMValueRef LLVMBuildFPExt(LLVMBuilderRef, LLVMValueRef Val,
2660 LLVMTypeRef DestTy, const char *Name);
2661 LLVMValueRef LLVMBuildPtrToInt(LLVMBuilderRef, LLVMValueRef Val,
2662 LLVMTypeRef DestTy, const char *Name);
2663 LLVMValueRef LLVMBuildIntToPtr(LLVMBuilderRef, LLVMValueRef Val,
2664 LLVMTypeRef DestTy, const char *Name);
2665 LLVMValueRef LLVMBuildBitCast(LLVMBuilderRef, LLVMValueRef Val,
2666 LLVMTypeRef DestTy, const char *Name);
2667 LLVMValueRef LLVMBuildAddrSpaceCast(LLVMBuilderRef, LLVMValueRef Val,
2668 LLVMTypeRef DestTy, const char *Name);
2669 LLVMValueRef LLVMBuildZExtOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
2670 LLVMTypeRef DestTy, const char *Name);
2671 LLVMValueRef LLVMBuildSExtOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
2672 LLVMTypeRef DestTy, const char *Name);
2673 LLVMValueRef LLVMBuildTruncOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
2674 LLVMTypeRef DestTy, const char *Name);
2675 LLVMValueRef LLVMBuildCast(LLVMBuilderRef B, LLVMOpcode Op, LLVMValueRef Val,
2676 LLVMTypeRef DestTy, const char *Name);
2677 LLVMValueRef LLVMBuildPointerCast(LLVMBuilderRef, LLVMValueRef Val,
2678 LLVMTypeRef DestTy, const char *Name);
2679 LLVMValueRef LLVMBuildIntCast(LLVMBuilderRef, LLVMValueRef Val, /*Signed cast!*/
2680 LLVMTypeRef DestTy, const char *Name);
2681 LLVMValueRef LLVMBuildFPCast(LLVMBuilderRef, LLVMValueRef Val,
2682 LLVMTypeRef DestTy, const char *Name);
2685 LLVMValueRef LLVMBuildICmp(LLVMBuilderRef, LLVMIntPredicate Op,
2686 LLVMValueRef LHS, LLVMValueRef RHS,
2688 LLVMValueRef LLVMBuildFCmp(LLVMBuilderRef, LLVMRealPredicate Op,
2689 LLVMValueRef LHS, LLVMValueRef RHS,
2692 /* Miscellaneous instructions */
2693 LLVMValueRef LLVMBuildPhi(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
2694 LLVMValueRef LLVMBuildCall(LLVMBuilderRef, LLVMValueRef Fn,
2695 LLVMValueRef *Args, unsigned NumArgs,
2697 LLVMValueRef LLVMBuildSelect(LLVMBuilderRef, LLVMValueRef If,
2698 LLVMValueRef Then, LLVMValueRef Else,
2700 LLVMValueRef LLVMBuildVAArg(LLVMBuilderRef, LLVMValueRef List, LLVMTypeRef Ty,
2702 LLVMValueRef LLVMBuildExtractElement(LLVMBuilderRef, LLVMValueRef VecVal,
2703 LLVMValueRef Index, const char *Name);
2704 LLVMValueRef LLVMBuildInsertElement(LLVMBuilderRef, LLVMValueRef VecVal,
2705 LLVMValueRef EltVal, LLVMValueRef Index,
2707 LLVMValueRef LLVMBuildShuffleVector(LLVMBuilderRef, LLVMValueRef V1,
2708 LLVMValueRef V2, LLVMValueRef Mask,
2710 LLVMValueRef LLVMBuildExtractValue(LLVMBuilderRef, LLVMValueRef AggVal,
2711 unsigned Index, const char *Name);
2712 LLVMValueRef LLVMBuildInsertValue(LLVMBuilderRef, LLVMValueRef AggVal,
2713 LLVMValueRef EltVal, unsigned Index,
2716 LLVMValueRef LLVMBuildIsNull(LLVMBuilderRef, LLVMValueRef Val,
2718 LLVMValueRef LLVMBuildIsNotNull(LLVMBuilderRef, LLVMValueRef Val,
2720 LLVMValueRef LLVMBuildPtrDiff(LLVMBuilderRef, LLVMValueRef LHS,
2721 LLVMValueRef RHS, const char *Name);
2722 LLVMValueRef LLVMBuildFence(LLVMBuilderRef B, LLVMAtomicOrdering ordering,
2723 LLVMBool singleThread, const char *Name);
2724 LLVMValueRef LLVMBuildAtomicRMW(LLVMBuilderRef B, LLVMAtomicRMWBinOp op,
2725 LLVMValueRef PTR, LLVMValueRef Val,
2726 LLVMAtomicOrdering ordering,
2727 LLVMBool singleThread);
2734 * @defgroup LLVMCCoreModuleProvider Module Providers
2740 * Changes the type of M so it can be passed to FunctionPassManagers and the
2741 * JIT. They take ModuleProviders for historical reasons.
2743 LLVMModuleProviderRef
2744 LLVMCreateModuleProviderForExistingModule(LLVMModuleRef M);
2747 * Destroys the module M.
2749 void LLVMDisposeModuleProvider(LLVMModuleProviderRef M);
2756 * @defgroup LLVMCCoreMemoryBuffers Memory Buffers
2761 LLVMBool LLVMCreateMemoryBufferWithContentsOfFile(const char *Path,
2762 LLVMMemoryBufferRef *OutMemBuf,
2764 LLVMBool LLVMCreateMemoryBufferWithSTDIN(LLVMMemoryBufferRef *OutMemBuf,
2766 LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRange(const char *InputData,
2767 size_t InputDataLength,
2768 const char *BufferName,
2769 LLVMBool RequiresNullTerminator);
2770 LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRangeCopy(const char *InputData,
2771 size_t InputDataLength,
2772 const char *BufferName);
2773 const char *LLVMGetBufferStart(LLVMMemoryBufferRef MemBuf);
2774 size_t LLVMGetBufferSize(LLVMMemoryBufferRef MemBuf);
2775 void LLVMDisposeMemoryBuffer(LLVMMemoryBufferRef MemBuf);
2782 * @defgroup LLVMCCorePass Pass
2787 const char *LLVMGetPassName(LLVMPassRef);
2794 * @defgroup LLVMCCorePassRegistry Pass Registry
2799 /** Return the global pass registry, for use with initialization functions.
2800 @see llvm::PassRegistry::getPassRegistry */
2801 LLVMPassRegistryRef LLVMGetGlobalPassRegistry(void);
2808 * @defgroup LLVMCCorePassManagers Pass Managers
2813 /** Constructs a new whole-module pass pipeline. This type of pipeline is
2814 suitable for link-time optimization and whole-module transformations.
2815 @see llvm::PassManager::PassManager */
2816 LLVMPassManagerRef LLVMCreatePassManager(void);
2818 /** Constructs a new function-by-function pass pipeline over the module
2819 provider. It does not take ownership of the module provider. This type of
2820 pipeline is suitable for code generation and JIT compilation tasks.
2821 @see llvm::FunctionPassManager::FunctionPassManager */
2822 LLVMPassManagerRef LLVMCreateFunctionPassManagerForModule(LLVMModuleRef M);
2824 /** Deprecated: Use LLVMCreateFunctionPassManagerForModule instead. */
2825 LLVMPassManagerRef LLVMCreateFunctionPassManager(LLVMModuleProviderRef MP);
2827 /** Initializes, executes on the provided module, and finalizes all of the
2828 passes scheduled in the pass manager. Returns 1 if any of the passes
2829 modified the module, 0 otherwise.
2830 @see llvm::PassManager::run(Module&) */
2831 LLVMBool LLVMRunPassManager(LLVMPassManagerRef PM, LLVMModuleRef M);
2833 /** Initializes all of the function passes scheduled in the function pass
2834 manager. Returns 1 if any of the passes modified the module, 0 otherwise.
2835 @see llvm::FunctionPassManager::doInitialization */
2836 LLVMBool LLVMInitializeFunctionPassManager(LLVMPassManagerRef FPM);
2838 /** Executes all of the function passes scheduled in the function pass manager
2839 on the provided function. Returns 1 if any of the passes modified the
2840 function, false otherwise.
2841 @see llvm::FunctionPassManager::run(Function&) */
2842 LLVMBool LLVMRunFunctionPassManager(LLVMPassManagerRef FPM, LLVMValueRef F);
2844 /** Finalizes all of the function passes scheduled in in the function pass
2845 manager. Returns 1 if any of the passes modified the module, 0 otherwise.
2846 @see llvm::FunctionPassManager::doFinalization */
2847 LLVMBool LLVMFinalizeFunctionPassManager(LLVMPassManagerRef FPM);
2849 /** Frees the memory of a pass pipeline. For function pipelines, does not free
2850 the module provider.
2851 @see llvm::PassManagerBase::~PassManagerBase. */
2852 void LLVMDisposePassManager(LLVMPassManagerRef PM);
2859 * @defgroup LLVMCCoreThreading Threading
2861 * Handle the structures needed to make LLVM safe for multithreading.
2866 /** Allocate and initialize structures needed to make LLVM safe for
2867 multithreading. The return value indicates whether multithreaded
2868 initialization succeeded. Must be executed in isolation from all
2869 other LLVM api calls.
2870 @see llvm::llvm_start_multithreaded */
2871 LLVMBool LLVMStartMultithreaded(void);
2873 /** Deallocate structures necessary to make LLVM safe for multithreading.
2874 Must be executed in isolation from all other LLVM api calls.
2875 @see llvm::llvm_stop_multithreaded */
2876 void LLVMStopMultithreaded(void);
2878 /** Check whether LLVM is executing in thread-safe mode or not.
2879 @see llvm::llvm_is_multithreaded */
2880 LLVMBool LLVMIsMultithreaded(void);
2896 #endif /* !defined(__cplusplus) */
2898 #endif /* !defined(LLVM_C_CORE_H) */