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/Support/DataTypes.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
70 * The top-level container for all LLVM global data. See the LLVMContext class.
72 typedef struct LLVMOpaqueContext *LLVMContextRef;
75 * The top-level container for all other LLVM Intermediate Representation (IR)
80 typedef struct LLVMOpaqueModule *LLVMModuleRef;
83 * Each value in the LLVM IR has a type, an LLVMTypeRef.
87 typedef struct LLVMOpaqueType *LLVMTypeRef;
90 * Represents an individual value in LLVM IR.
92 * This models llvm::Value.
94 typedef struct LLVMOpaqueValue *LLVMValueRef;
97 * Represents a basic block of instructions in LLVM IR.
99 * This models llvm::BasicBlock.
101 typedef struct LLVMOpaqueBasicBlock *LLVMBasicBlockRef;
104 * Represents an LLVM basic block builder.
106 * This models llvm::IRBuilder.
108 typedef struct LLVMOpaqueBuilder *LLVMBuilderRef;
111 * Interface used to provide a module to JIT or interpreter.
112 * This is now just a synonym for llvm::Module, but we have to keep using the
113 * different type to keep binary compatibility.
115 typedef struct LLVMOpaqueModuleProvider *LLVMModuleProviderRef;
118 * Used to provide a module to JIT or interpreter.
120 * @see llvm::MemoryBuffer
122 typedef struct LLVMOpaqueMemoryBuffer *LLVMMemoryBufferRef;
124 /** @see llvm::PassManagerBase */
125 typedef struct LLVMOpaquePassManager *LLVMPassManagerRef;
127 /** @see llvm::PassRegistry */
128 typedef struct LLVMOpaquePassRegistry *LLVMPassRegistryRef;
131 * Used to get the users and usees of a Value.
134 typedef struct LLVMOpaqueUse *LLVMUseRef;
137 LLVMZExtAttribute = 1<<0,
138 LLVMSExtAttribute = 1<<1,
139 LLVMNoReturnAttribute = 1<<2,
140 LLVMInRegAttribute = 1<<3,
141 LLVMStructRetAttribute = 1<<4,
142 LLVMNoUnwindAttribute = 1<<5,
143 LLVMNoAliasAttribute = 1<<6,
144 LLVMByValAttribute = 1<<7,
145 LLVMNestAttribute = 1<<8,
146 LLVMReadNoneAttribute = 1<<9,
147 LLVMReadOnlyAttribute = 1<<10,
148 LLVMNoInlineAttribute = 1<<11,
149 LLVMAlwaysInlineAttribute = 1<<12,
150 LLVMOptimizeForSizeAttribute = 1<<13,
151 LLVMStackProtectAttribute = 1<<14,
152 LLVMStackProtectReqAttribute = 1<<15,
153 LLVMAlignment = 31<<16,
154 LLVMNoCaptureAttribute = 1<<21,
155 LLVMNoRedZoneAttribute = 1<<22,
156 LLVMNoImplicitFloatAttribute = 1<<23,
157 LLVMNakedAttribute = 1<<24,
158 LLVMInlineHintAttribute = 1<<25,
159 LLVMStackAlignment = 7<<26,
160 LLVMReturnsTwice = 1 << 29,
161 LLVMUWTable = 1 << 30,
162 LLVMNonLazyBind = 1 << 31
164 /* FIXME: These attributes are currently not included in the C API as
165 a temporary measure until the API/ABI impact to the C API is understood
166 and the path forward agreed upon.
167 LLVMAddressSafety = 1ULL << 32,
168 LLVMStackProtectStrongAttribute = 1ULL<<33,
169 LLVMCold = 1ULL << 34,
170 LLVMOptimizeNone = 1ULL << 35,
171 LLVMInAllocaAttribute = 1ULL << 36
176 /* Terminator Instructions */
182 /* removed 6 due to API changes */
185 /* Standard Binary Operators */
199 /* Logical Operators */
207 /* Memory Operators */
211 LLVMGetElementPtr = 29,
226 LLVMAddrSpaceCast = 60,
228 /* Other Operators */
237 LLVMExtractElement = 50,
238 LLVMInsertElement = 51,
239 LLVMShuffleVector = 52,
240 LLVMExtractValue = 53,
241 LLVMInsertValue = 54,
243 /* Atomic operators */
245 LLVMAtomicCmpXchg = 56,
248 /* Exception Handling Operators */
255 LLVMVoidTypeKind, /**< type with no size */
256 LLVMHalfTypeKind, /**< 16 bit floating point type */
257 LLVMFloatTypeKind, /**< 32 bit floating point type */
258 LLVMDoubleTypeKind, /**< 64 bit floating point type */
259 LLVMX86_FP80TypeKind, /**< 80 bit floating point type (X87) */
260 LLVMFP128TypeKind, /**< 128 bit floating point type (112-bit mantissa)*/
261 LLVMPPC_FP128TypeKind, /**< 128 bit floating point type (two 64-bits) */
262 LLVMLabelTypeKind, /**< Labels */
263 LLVMIntegerTypeKind, /**< Arbitrary bit width integers */
264 LLVMFunctionTypeKind, /**< Functions */
265 LLVMStructTypeKind, /**< Structures */
266 LLVMArrayTypeKind, /**< Arrays */
267 LLVMPointerTypeKind, /**< Pointers */
268 LLVMVectorTypeKind, /**< SIMD 'packed' format, or other vector type */
269 LLVMMetadataTypeKind, /**< Metadata */
270 LLVMX86_MMXTypeKind /**< X86 MMX */
274 LLVMExternalLinkage, /**< Externally visible function */
275 LLVMAvailableExternallyLinkage,
276 LLVMLinkOnceAnyLinkage, /**< Keep one copy of function when linking (inline)*/
277 LLVMLinkOnceODRLinkage, /**< Same, but only replaced by something
279 LLVMLinkOnceODRAutoHideLinkage, /**< Obsolete */
280 LLVMWeakAnyLinkage, /**< Keep one copy of function when linking (weak) */
281 LLVMWeakODRLinkage, /**< Same, but only replaced by something
283 LLVMAppendingLinkage, /**< Special purpose, only applies to global arrays */
284 LLVMInternalLinkage, /**< Rename collisions when linking (static
286 LLVMPrivateLinkage, /**< Like Internal, but omit from symbol table */
287 LLVMDLLImportLinkage, /**< Obsolete */
288 LLVMDLLExportLinkage, /**< Obsolete */
289 LLVMExternalWeakLinkage,/**< ExternalWeak linkage description */
290 LLVMGhostLinkage, /**< Obsolete */
291 LLVMCommonLinkage, /**< Tentative definitions */
292 LLVMLinkerPrivateLinkage, /**< Like Private, but linker removes. */
293 LLVMLinkerPrivateWeakLinkage /**< Like LinkerPrivate, but is weak. */
297 LLVMDefaultVisibility, /**< The GV is visible */
298 LLVMHiddenVisibility, /**< The GV is hidden */
299 LLVMProtectedVisibility /**< The GV is protected */
304 LLVMFastCallConv = 8,
305 LLVMColdCallConv = 9,
306 LLVMWebKitJSCallConv = 12,
307 LLVMAnyRegCallConv = 13,
308 LLVMX86StdcallCallConv = 64,
309 LLVMX86FastcallCallConv = 65
313 LLVMIntEQ = 32, /**< equal */
314 LLVMIntNE, /**< not equal */
315 LLVMIntUGT, /**< unsigned greater than */
316 LLVMIntUGE, /**< unsigned greater or equal */
317 LLVMIntULT, /**< unsigned less than */
318 LLVMIntULE, /**< unsigned less or equal */
319 LLVMIntSGT, /**< signed greater than */
320 LLVMIntSGE, /**< signed greater or equal */
321 LLVMIntSLT, /**< signed less than */
322 LLVMIntSLE /**< signed less or equal */
326 LLVMRealPredicateFalse, /**< Always false (always folded) */
327 LLVMRealOEQ, /**< True if ordered and equal */
328 LLVMRealOGT, /**< True if ordered and greater than */
329 LLVMRealOGE, /**< True if ordered and greater than or equal */
330 LLVMRealOLT, /**< True if ordered and less than */
331 LLVMRealOLE, /**< True if ordered and less than or equal */
332 LLVMRealONE, /**< True if ordered and operands are unequal */
333 LLVMRealORD, /**< True if ordered (no nans) */
334 LLVMRealUNO, /**< True if unordered: isnan(X) | isnan(Y) */
335 LLVMRealUEQ, /**< True if unordered or equal */
336 LLVMRealUGT, /**< True if unordered or greater than */
337 LLVMRealUGE, /**< True if unordered, greater than, or equal */
338 LLVMRealULT, /**< True if unordered or less than */
339 LLVMRealULE, /**< True if unordered, less than, or equal */
340 LLVMRealUNE, /**< True if unordered or not equal */
341 LLVMRealPredicateTrue /**< Always true (always folded) */
345 LLVMLandingPadCatch, /**< A catch clause */
346 LLVMLandingPadFilter /**< A filter clause */
347 } LLVMLandingPadClauseTy;
350 LLVMNotThreadLocal = 0,
351 LLVMGeneralDynamicTLSModel,
352 LLVMLocalDynamicTLSModel,
353 LLVMInitialExecTLSModel,
354 LLVMLocalExecTLSModel
355 } LLVMThreadLocalMode;
358 LLVMAtomicOrderingNotAtomic = 0, /**< A load or store which is not atomic */
359 LLVMAtomicOrderingUnordered = 1, /**< Lowest level of atomicity, guarantees
360 somewhat sane results, lock free. */
361 LLVMAtomicOrderingMonotonic = 2, /**< guarantees that if you take all the
362 operations affecting a specific address,
363 a consistent ordering exists */
364 LLVMAtomicOrderingAcquire = 4, /**< Acquire provides a barrier of the sort
365 necessary to acquire a lock to access other
366 memory with normal loads and stores. */
367 LLVMAtomicOrderingRelease = 5, /**< Release is similar to Acquire, but with
368 a barrier of the sort necessary to release
370 LLVMAtomicOrderingAcquireRelease = 6, /**< provides both an Acquire and a
371 Release barrier (for fences and
372 operations which both read and write
374 LLVMAtomicOrderingSequentiallyConsistent = 7 /**< provides Acquire semantics
375 for loads and Release
376 semantics for stores.
377 Additionally, it guarantees
378 that a total ordering exists
380 SequentiallyConsistent
382 } LLVMAtomicOrdering;
385 LLVMAtomicRMWBinOpXchg, /**< Set the new value and return the one old */
386 LLVMAtomicRMWBinOpAdd, /**< Add a value and return the old one */
387 LLVMAtomicRMWBinOpSub, /**< Subtract a value and return the old one */
388 LLVMAtomicRMWBinOpAnd, /**< And a value and return the old one */
389 LLVMAtomicRMWBinOpNand, /**< Not-And a value and return the old one */
390 LLVMAtomicRMWBinOpOr, /**< OR a value and return the old one */
391 LLVMAtomicRMWBinOpXor, /**< Xor a value and return the old one */
392 LLVMAtomicRMWBinOpMax, /**< Sets the value if it's greater than the
393 original using a signed comparison and return
395 LLVMAtomicRMWBinOpMin, /**< Sets the value if it's Smaller than the
396 original using a signed comparison and return
398 LLVMAtomicRMWBinOpUMax, /**< Sets the value if it's greater than the
399 original using an unsigned comparison and return
401 LLVMAtomicRMWBinOpUMin /**< Sets the value if it's greater than the
402 original using an unsigned comparison and return
404 } LLVMAtomicRMWBinOp;
410 void LLVMInitializeCore(LLVMPassRegistryRef R);
412 /** Deallocate and destroy all ManagedStatic variables.
413 @see llvm::llvm_shutdown
414 @see ManagedStatic */
415 void LLVMShutdown(void);
418 /*===-- Error handling ----------------------------------------------------===*/
420 char *LLVMCreateMessage(const char *Message);
421 void LLVMDisposeMessage(char *Message);
423 typedef void (*LLVMFatalErrorHandler)(const char *Reason);
426 * Install a fatal error handler. By default, if LLVM detects a fatal error, it
427 * will call exit(1). This may not be appropriate in many contexts. For example,
428 * doing exit(1) will bypass many crash reporting/tracing system tools. This
429 * function allows you to install a callback that will be invoked prior to the
432 void LLVMInstallFatalErrorHandler(LLVMFatalErrorHandler Handler);
435 * Reset the fatal error handler. This resets LLVM's fatal error handling
436 * behavior to the default.
438 void LLVMResetFatalErrorHandler(void);
441 * Enable LLVM's built-in stack trace code. This intercepts the OS's crash
442 * signals and prints which component of LLVM you were in at the time if the
445 void LLVMEnablePrettyStackTrace(void);
448 * @defgroup LLVMCCoreContext Contexts
450 * Contexts are execution states for the core LLVM IR system.
452 * Most types are tied to a context instance. Multiple contexts can
453 * exist simultaneously. A single context is not thread safe. However,
454 * different contexts can execute on different threads simultaneously.
460 * Create a new context.
462 * Every call to this function should be paired with a call to
463 * LLVMContextDispose() or the context will leak memory.
465 LLVMContextRef LLVMContextCreate(void);
468 * Obtain the global context instance.
470 LLVMContextRef LLVMGetGlobalContext(void);
473 * Destroy a context instance.
475 * This should be called for every call to LLVMContextCreate() or memory
478 void LLVMContextDispose(LLVMContextRef C);
480 unsigned LLVMGetMDKindIDInContext(LLVMContextRef C, const char* Name,
482 unsigned LLVMGetMDKindID(const char* Name, unsigned SLen);
489 * @defgroup LLVMCCoreModule Modules
491 * Modules represent the top-level structure in an LLVM program. An LLVM
492 * module is effectively a translation unit or a collection of
493 * translation units merged together.
499 * Create a new, empty module in the global context.
501 * This is equivalent to calling LLVMModuleCreateWithNameInContext with
502 * LLVMGetGlobalContext() as the context parameter.
504 * Every invocation should be paired with LLVMDisposeModule() or memory
507 LLVMModuleRef LLVMModuleCreateWithName(const char *ModuleID);
510 * Create a new, empty module in a specific context.
512 * Every invocation should be paired with LLVMDisposeModule() or memory
515 LLVMModuleRef LLVMModuleCreateWithNameInContext(const char *ModuleID,
519 * Destroy a module instance.
521 * This must be called for every created module or memory will be
524 void LLVMDisposeModule(LLVMModuleRef M);
527 * Obtain the data layout for a module.
529 * @see Module::getDataLayout()
531 const char *LLVMGetDataLayout(LLVMModuleRef M);
534 * Set the data layout for a module.
536 * @see Module::setDataLayout()
538 void LLVMSetDataLayout(LLVMModuleRef M, const char *Triple);
541 * Obtain the target triple for a module.
543 * @see Module::getTargetTriple()
545 const char *LLVMGetTarget(LLVMModuleRef M);
548 * Set the target triple for a module.
550 * @see Module::setTargetTriple()
552 void LLVMSetTarget(LLVMModuleRef M, const char *Triple);
555 * Dump a representation of a module to stderr.
557 * @see Module::dump()
559 void LLVMDumpModule(LLVMModuleRef M);
562 * Print a representation of a module to a file. The ErrorMessage needs to be
563 * disposed with LLVMDisposeMessage. Returns 0 on success, 1 otherwise.
565 * @see Module::print()
567 LLVMBool LLVMPrintModuleToFile(LLVMModuleRef M, const char *Filename,
568 char **ErrorMessage);
571 * Return a string representation of the module. Use
572 * LLVMDisposeMessage to free the string.
574 * @see Module::print()
576 char *LLVMPrintModuleToString(LLVMModuleRef M);
579 * Set inline assembly for a module.
581 * @see Module::setModuleInlineAsm()
583 void LLVMSetModuleInlineAsm(LLVMModuleRef M, const char *Asm);
586 * Obtain the context to which this module is associated.
588 * @see Module::getContext()
590 LLVMContextRef LLVMGetModuleContext(LLVMModuleRef M);
593 * Obtain a Type from a module by its registered name.
595 LLVMTypeRef LLVMGetTypeByName(LLVMModuleRef M, const char *Name);
598 * Obtain the number of operands for named metadata in a module.
600 * @see llvm::Module::getNamedMetadata()
602 unsigned LLVMGetNamedMetadataNumOperands(LLVMModuleRef M, const char* name);
605 * Obtain the named metadata operands for a module.
607 * The passed LLVMValueRef pointer should refer to an array of
608 * LLVMValueRef at least LLVMGetNamedMetadataNumOperands long. This
609 * array will be populated with the LLVMValueRef instances. Each
610 * instance corresponds to a llvm::MDNode.
612 * @see llvm::Module::getNamedMetadata()
613 * @see llvm::MDNode::getOperand()
615 void LLVMGetNamedMetadataOperands(LLVMModuleRef M, const char* name, LLVMValueRef *Dest);
618 * Add an operand to named metadata.
620 * @see llvm::Module::getNamedMetadata()
621 * @see llvm::MDNode::addOperand()
623 void LLVMAddNamedMetadataOperand(LLVMModuleRef M, const char* name,
627 * Add a function to a module under a specified name.
629 * @see llvm::Function::Create()
631 LLVMValueRef LLVMAddFunction(LLVMModuleRef M, const char *Name,
632 LLVMTypeRef FunctionTy);
635 * Obtain a Function value from a Module by its name.
637 * The returned value corresponds to a llvm::Function value.
639 * @see llvm::Module::getFunction()
641 LLVMValueRef LLVMGetNamedFunction(LLVMModuleRef M, const char *Name);
644 * Obtain an iterator to the first Function in a Module.
646 * @see llvm::Module::begin()
648 LLVMValueRef LLVMGetFirstFunction(LLVMModuleRef M);
651 * Obtain an iterator to the last Function in a Module.
653 * @see llvm::Module::end()
655 LLVMValueRef LLVMGetLastFunction(LLVMModuleRef M);
658 * Advance a Function iterator to the next Function.
660 * Returns NULL if the iterator was already at the end and there are no more
663 LLVMValueRef LLVMGetNextFunction(LLVMValueRef Fn);
666 * Decrement a Function iterator to the previous Function.
668 * Returns NULL if the iterator was already at the beginning and there are
669 * no previous functions.
671 LLVMValueRef LLVMGetPreviousFunction(LLVMValueRef Fn);
678 * @defgroup LLVMCCoreType Types
680 * Types represent the type of a value.
682 * Types are associated with a context instance. The context internally
683 * deduplicates types so there is only 1 instance of a specific type
684 * alive at a time. In other words, a unique type is shared among all
685 * consumers within a context.
687 * A Type in the C API corresponds to llvm::Type.
689 * Types have the following hierarchy:
707 * Obtain the enumerated type of a Type instance.
709 * @see llvm::Type:getTypeID()
711 LLVMTypeKind LLVMGetTypeKind(LLVMTypeRef Ty);
714 * Whether the type has a known size.
716 * Things that don't have a size are abstract types, labels, and void.a
718 * @see llvm::Type::isSized()
720 LLVMBool LLVMTypeIsSized(LLVMTypeRef Ty);
723 * Obtain the context to which this type instance is associated.
725 * @see llvm::Type::getContext()
727 LLVMContextRef LLVMGetTypeContext(LLVMTypeRef Ty);
730 * Dump a representation of a type to stderr.
732 * @see llvm::Type::dump()
734 void LLVMDumpType(LLVMTypeRef Val);
737 * Return a string representation of the type. Use
738 * LLVMDisposeMessage to free the string.
740 * @see llvm::Type::print()
742 char *LLVMPrintTypeToString(LLVMTypeRef Val);
745 * @defgroup LLVMCCoreTypeInt Integer Types
747 * Functions in this section operate on integer types.
753 * Obtain an integer type from a context with specified bit width.
755 LLVMTypeRef LLVMInt1TypeInContext(LLVMContextRef C);
756 LLVMTypeRef LLVMInt8TypeInContext(LLVMContextRef C);
757 LLVMTypeRef LLVMInt16TypeInContext(LLVMContextRef C);
758 LLVMTypeRef LLVMInt32TypeInContext(LLVMContextRef C);
759 LLVMTypeRef LLVMInt64TypeInContext(LLVMContextRef C);
760 LLVMTypeRef LLVMIntTypeInContext(LLVMContextRef C, unsigned NumBits);
763 * Obtain an integer type from the global context with a specified bit
766 LLVMTypeRef LLVMInt1Type(void);
767 LLVMTypeRef LLVMInt8Type(void);
768 LLVMTypeRef LLVMInt16Type(void);
769 LLVMTypeRef LLVMInt32Type(void);
770 LLVMTypeRef LLVMInt64Type(void);
771 LLVMTypeRef LLVMIntType(unsigned NumBits);
772 unsigned LLVMGetIntTypeWidth(LLVMTypeRef IntegerTy);
779 * @defgroup LLVMCCoreTypeFloat Floating Point Types
785 * Obtain a 16-bit floating point type from a context.
787 LLVMTypeRef LLVMHalfTypeInContext(LLVMContextRef C);
790 * Obtain a 32-bit floating point type from a context.
792 LLVMTypeRef LLVMFloatTypeInContext(LLVMContextRef C);
795 * Obtain a 64-bit floating point type from a context.
797 LLVMTypeRef LLVMDoubleTypeInContext(LLVMContextRef C);
800 * Obtain a 80-bit floating point type (X87) from a context.
802 LLVMTypeRef LLVMX86FP80TypeInContext(LLVMContextRef C);
805 * Obtain a 128-bit floating point type (112-bit mantissa) from a
808 LLVMTypeRef LLVMFP128TypeInContext(LLVMContextRef C);
811 * Obtain a 128-bit floating point type (two 64-bits) from a context.
813 LLVMTypeRef LLVMPPCFP128TypeInContext(LLVMContextRef C);
816 * Obtain a floating point type from the global context.
818 * These map to the functions in this group of the same name.
820 LLVMTypeRef LLVMHalfType(void);
821 LLVMTypeRef LLVMFloatType(void);
822 LLVMTypeRef LLVMDoubleType(void);
823 LLVMTypeRef LLVMX86FP80Type(void);
824 LLVMTypeRef LLVMFP128Type(void);
825 LLVMTypeRef LLVMPPCFP128Type(void);
832 * @defgroup LLVMCCoreTypeFunction Function Types
838 * Obtain a function type consisting of a specified signature.
840 * The function is defined as a tuple of a return Type, a list of
841 * parameter types, and whether the function is variadic.
843 LLVMTypeRef LLVMFunctionType(LLVMTypeRef ReturnType,
844 LLVMTypeRef *ParamTypes, unsigned ParamCount,
848 * Returns whether a function type is variadic.
850 LLVMBool LLVMIsFunctionVarArg(LLVMTypeRef FunctionTy);
853 * Obtain the Type this function Type returns.
855 LLVMTypeRef LLVMGetReturnType(LLVMTypeRef FunctionTy);
858 * Obtain the number of parameters this function accepts.
860 unsigned LLVMCountParamTypes(LLVMTypeRef FunctionTy);
863 * Obtain the types of a function's parameters.
865 * The Dest parameter should point to a pre-allocated array of
866 * LLVMTypeRef at least LLVMCountParamTypes() large. On return, the
867 * first LLVMCountParamTypes() entries in the array will be populated
868 * with LLVMTypeRef instances.
870 * @param FunctionTy The function type to operate on.
871 * @param Dest Memory address of an array to be filled with result.
873 void LLVMGetParamTypes(LLVMTypeRef FunctionTy, LLVMTypeRef *Dest);
880 * @defgroup LLVMCCoreTypeStruct Structure Types
882 * These functions relate to LLVMTypeRef instances.
884 * @see llvm::StructType
890 * Create a new structure type in a context.
892 * A structure is specified by a list of inner elements/types and
893 * whether these can be packed together.
895 * @see llvm::StructType::create()
897 LLVMTypeRef LLVMStructTypeInContext(LLVMContextRef C, LLVMTypeRef *ElementTypes,
898 unsigned ElementCount, LLVMBool Packed);
901 * Create a new structure type in the global context.
903 * @see llvm::StructType::create()
905 LLVMTypeRef LLVMStructType(LLVMTypeRef *ElementTypes, unsigned ElementCount,
909 * Create an empty structure in a context having a specified name.
911 * @see llvm::StructType::create()
913 LLVMTypeRef LLVMStructCreateNamed(LLVMContextRef C, const char *Name);
916 * Obtain the name of a structure.
918 * @see llvm::StructType::getName()
920 const char *LLVMGetStructName(LLVMTypeRef Ty);
923 * Set the contents of a structure type.
925 * @see llvm::StructType::setBody()
927 void LLVMStructSetBody(LLVMTypeRef StructTy, LLVMTypeRef *ElementTypes,
928 unsigned ElementCount, LLVMBool Packed);
931 * Get the number of elements defined inside the structure.
933 * @see llvm::StructType::getNumElements()
935 unsigned LLVMCountStructElementTypes(LLVMTypeRef StructTy);
938 * Get the elements within a structure.
940 * The function is passed the address of a pre-allocated array of
941 * LLVMTypeRef at least LLVMCountStructElementTypes() long. After
942 * invocation, this array will be populated with the structure's
943 * elements. The objects in the destination array will have a lifetime
944 * of the structure type itself, which is the lifetime of the context it
947 void LLVMGetStructElementTypes(LLVMTypeRef StructTy, LLVMTypeRef *Dest);
950 * Determine whether a structure is packed.
952 * @see llvm::StructType::isPacked()
954 LLVMBool LLVMIsPackedStruct(LLVMTypeRef StructTy);
957 * Determine whether a structure is opaque.
959 * @see llvm::StructType::isOpaque()
961 LLVMBool LLVMIsOpaqueStruct(LLVMTypeRef StructTy);
969 * @defgroup LLVMCCoreTypeSequential Sequential Types
971 * Sequential types represents "arrays" of types. This is a super class
972 * for array, vector, and pointer types.
978 * Obtain the type of elements within a sequential type.
980 * This works on array, vector, and pointer types.
982 * @see llvm::SequentialType::getElementType()
984 LLVMTypeRef LLVMGetElementType(LLVMTypeRef Ty);
987 * Create a fixed size array type that refers to a specific type.
989 * The created type will exist in the context that its element type
992 * @see llvm::ArrayType::get()
994 LLVMTypeRef LLVMArrayType(LLVMTypeRef ElementType, unsigned ElementCount);
997 * Obtain the length of an array type.
999 * This only works on types that represent arrays.
1001 * @see llvm::ArrayType::getNumElements()
1003 unsigned LLVMGetArrayLength(LLVMTypeRef ArrayTy);
1006 * Create a pointer type that points to a defined type.
1008 * The created type will exist in the context that its pointee type
1011 * @see llvm::PointerType::get()
1013 LLVMTypeRef LLVMPointerType(LLVMTypeRef ElementType, unsigned AddressSpace);
1016 * Obtain the address space of a pointer type.
1018 * This only works on types that represent pointers.
1020 * @see llvm::PointerType::getAddressSpace()
1022 unsigned LLVMGetPointerAddressSpace(LLVMTypeRef PointerTy);
1025 * Create a vector type that contains a defined type and has a specific
1026 * number of elements.
1028 * The created type will exist in the context thats its element type
1031 * @see llvm::VectorType::get()
1033 LLVMTypeRef LLVMVectorType(LLVMTypeRef ElementType, unsigned ElementCount);
1036 * Obtain the number of elements in a vector type.
1038 * This only works on types that represent vectors.
1040 * @see llvm::VectorType::getNumElements()
1042 unsigned LLVMGetVectorSize(LLVMTypeRef VectorTy);
1049 * @defgroup LLVMCCoreTypeOther Other Types
1055 * Create a void type in a context.
1057 LLVMTypeRef LLVMVoidTypeInContext(LLVMContextRef C);
1060 * Create a label type in a context.
1062 LLVMTypeRef LLVMLabelTypeInContext(LLVMContextRef C);
1065 * Create a X86 MMX type in a context.
1067 LLVMTypeRef LLVMX86MMXTypeInContext(LLVMContextRef C);
1070 * These are similar to the above functions except they operate on the
1073 LLVMTypeRef LLVMVoidType(void);
1074 LLVMTypeRef LLVMLabelType(void);
1075 LLVMTypeRef LLVMX86MMXType(void);
1086 * @defgroup LLVMCCoreValues Values
1088 * The bulk of LLVM's object model consists of values, which comprise a very
1089 * rich type hierarchy.
1091 * LLVMValueRef essentially represents llvm::Value. There is a rich
1092 * hierarchy of classes within this type. Depending on the instance
1093 * obtained, not all APIs are available.
1095 * Callers can determine the type of an LLVMValueRef by calling the
1096 * LLVMIsA* family of functions (e.g. LLVMIsAArgument()). These
1097 * functions are defined by a macro, so it isn't obvious which are
1098 * available by looking at the Doxygen source code. Instead, look at the
1099 * source definition of LLVM_FOR_EACH_VALUE_SUBCLASS and note the list
1100 * of value names given. These value names also correspond to classes in
1101 * the llvm::Value hierarchy.
1106 #define LLVM_FOR_EACH_VALUE_SUBCLASS(macro) \
1114 macro(BlockAddress) \
1115 macro(ConstantAggregateZero) \
1116 macro(ConstantArray) \
1117 macro(ConstantDataSequential) \
1118 macro(ConstantDataArray) \
1119 macro(ConstantDataVector) \
1120 macro(ConstantExpr) \
1122 macro(ConstantInt) \
1123 macro(ConstantPointerNull) \
1124 macro(ConstantStruct) \
1125 macro(ConstantVector) \
1126 macro(GlobalValue) \
1128 macro(GlobalAlias) \
1129 macro(GlobalVariable) \
1131 macro(Instruction) \
1132 macro(BinaryOperator) \
1134 macro(IntrinsicInst) \
1135 macro(DbgInfoIntrinsic) \
1136 macro(DbgDeclareInst) \
1137 macro(MemIntrinsic) \
1139 macro(MemMoveInst) \
1144 macro(ExtractElementInst) \
1145 macro(GetElementPtrInst) \
1146 macro(InsertElementInst) \
1147 macro(InsertValueInst) \
1148 macro(LandingPadInst) \
1151 macro(ShuffleVectorInst) \
1153 macro(TerminatorInst) \
1155 macro(IndirectBrInst) \
1159 macro(UnreachableInst) \
1161 macro(UnaryInstruction) \
1164 macro(AddrSpaceCastInst) \
1165 macro(BitCastInst) \
1169 macro(FPTruncInst) \
1170 macro(IntToPtrInst) \
1171 macro(PtrToIntInst) \
1177 macro(ExtractValueInst) \
1182 * @defgroup LLVMCCoreValueGeneral General APIs
1184 * Functions in this section work on all LLVMValueRef instances,
1185 * regardless of their sub-type. They correspond to functions available
1192 * Obtain the type of a value.
1194 * @see llvm::Value::getType()
1196 LLVMTypeRef LLVMTypeOf(LLVMValueRef Val);
1199 * Obtain the string name of a value.
1201 * @see llvm::Value::getName()
1203 const char *LLVMGetValueName(LLVMValueRef Val);
1206 * Set the string name of a value.
1208 * @see llvm::Value::setName()
1210 void LLVMSetValueName(LLVMValueRef Val, const char *Name);
1213 * Dump a representation of a value to stderr.
1215 * @see llvm::Value::dump()
1217 void LLVMDumpValue(LLVMValueRef Val);
1220 * Return a string representation of the value. Use
1221 * LLVMDisposeMessage to free the string.
1223 * @see llvm::Value::print()
1225 char *LLVMPrintValueToString(LLVMValueRef Val);
1228 * Replace all uses of a value with another one.
1230 * @see llvm::Value::replaceAllUsesWith()
1232 void LLVMReplaceAllUsesWith(LLVMValueRef OldVal, LLVMValueRef NewVal);
1235 * Determine whether the specified constant instance is constant.
1237 LLVMBool LLVMIsConstant(LLVMValueRef Val);
1240 * Determine whether a value instance is undefined.
1242 LLVMBool LLVMIsUndef(LLVMValueRef Val);
1245 * Convert value instances between types.
1247 * Internally, an LLVMValueRef is "pinned" to a specific type. This
1248 * series of functions allows you to cast an instance to a specific
1251 * If the cast is not valid for the specified type, NULL is returned.
1253 * @see llvm::dyn_cast_or_null<>
1255 #define LLVM_DECLARE_VALUE_CAST(name) \
1256 LLVMValueRef LLVMIsA##name(LLVMValueRef Val);
1257 LLVM_FOR_EACH_VALUE_SUBCLASS(LLVM_DECLARE_VALUE_CAST)
1264 * @defgroup LLVMCCoreValueUses Usage
1266 * This module defines functions that allow you to inspect the uses of a
1269 * It is possible to obtain an LLVMUseRef for any LLVMValueRef instance.
1270 * Each LLVMUseRef (which corresponds to a llvm::Use instance) holds a
1271 * llvm::User and llvm::Value.
1277 * Obtain the first use of a value.
1279 * Uses are obtained in an iterator fashion. First, call this function
1280 * to obtain a reference to the first use. Then, call LLVMGetNextUse()
1281 * on that instance and all subsequently obtained instances until
1282 * LLVMGetNextUse() returns NULL.
1284 * @see llvm::Value::use_begin()
1286 LLVMUseRef LLVMGetFirstUse(LLVMValueRef Val);
1289 * Obtain the next use of a value.
1291 * This effectively advances the iterator. It returns NULL if you are on
1292 * the final use and no more are available.
1294 LLVMUseRef LLVMGetNextUse(LLVMUseRef U);
1297 * Obtain the user value for a user.
1299 * The returned value corresponds to a llvm::User type.
1301 * @see llvm::Use::getUser()
1303 LLVMValueRef LLVMGetUser(LLVMUseRef U);
1306 * Obtain the value this use corresponds to.
1308 * @see llvm::Use::get().
1310 LLVMValueRef LLVMGetUsedValue(LLVMUseRef U);
1317 * @defgroup LLVMCCoreValueUser User value
1319 * Function in this group pertain to LLVMValueRef instances that descent
1320 * from llvm::User. This includes constants, instructions, and
1327 * Obtain an operand at a specific index in a llvm::User value.
1329 * @see llvm::User::getOperand()
1331 LLVMValueRef LLVMGetOperand(LLVMValueRef Val, unsigned Index);
1334 * Set an operand at a specific index in a llvm::User value.
1336 * @see llvm::User::setOperand()
1338 void LLVMSetOperand(LLVMValueRef User, unsigned Index, LLVMValueRef Val);
1341 * Obtain the number of operands in a llvm::User value.
1343 * @see llvm::User::getNumOperands()
1345 int LLVMGetNumOperands(LLVMValueRef Val);
1352 * @defgroup LLVMCCoreValueConstant Constants
1354 * This section contains APIs for interacting with LLVMValueRef that
1355 * correspond to llvm::Constant instances.
1357 * These functions will work for any LLVMValueRef in the llvm::Constant
1364 * Obtain a constant value referring to the null instance of a type.
1366 * @see llvm::Constant::getNullValue()
1368 LLVMValueRef LLVMConstNull(LLVMTypeRef Ty); /* all zeroes */
1371 * Obtain a constant value referring to the instance of a type
1372 * consisting of all ones.
1374 * This is only valid for integer types.
1376 * @see llvm::Constant::getAllOnesValue()
1378 LLVMValueRef LLVMConstAllOnes(LLVMTypeRef Ty);
1381 * Obtain a constant value referring to an undefined value of a type.
1383 * @see llvm::UndefValue::get()
1385 LLVMValueRef LLVMGetUndef(LLVMTypeRef Ty);
1388 * Determine whether a value instance is null.
1390 * @see llvm::Constant::isNullValue()
1392 LLVMBool LLVMIsNull(LLVMValueRef Val);
1395 * Obtain a constant that is a constant pointer pointing to NULL for a
1398 LLVMValueRef LLVMConstPointerNull(LLVMTypeRef Ty);
1401 * @defgroup LLVMCCoreValueConstantScalar Scalar constants
1403 * Functions in this group model LLVMValueRef instances that correspond
1404 * to constants referring to scalar types.
1406 * For integer types, the LLVMTypeRef parameter should correspond to a
1407 * llvm::IntegerType instance and the returned LLVMValueRef will
1408 * correspond to a llvm::ConstantInt.
1410 * For floating point types, the LLVMTypeRef returned corresponds to a
1417 * Obtain a constant value for an integer type.
1419 * The returned value corresponds to a llvm::ConstantInt.
1421 * @see llvm::ConstantInt::get()
1423 * @param IntTy Integer type to obtain value of.
1424 * @param N The value the returned instance should refer to.
1425 * @param SignExtend Whether to sign extend the produced value.
1427 LLVMValueRef LLVMConstInt(LLVMTypeRef IntTy, unsigned long long N,
1428 LLVMBool SignExtend);
1431 * Obtain a constant value for an integer of arbitrary precision.
1433 * @see llvm::ConstantInt::get()
1435 LLVMValueRef LLVMConstIntOfArbitraryPrecision(LLVMTypeRef IntTy,
1437 const uint64_t Words[]);
1440 * Obtain a constant value for an integer parsed from a string.
1442 * A similar API, LLVMConstIntOfStringAndSize is also available. If the
1443 * string's length is available, it is preferred to call that function
1446 * @see llvm::ConstantInt::get()
1448 LLVMValueRef LLVMConstIntOfString(LLVMTypeRef IntTy, const char *Text,
1452 * Obtain a constant value for an integer parsed from a string with
1455 * @see llvm::ConstantInt::get()
1457 LLVMValueRef LLVMConstIntOfStringAndSize(LLVMTypeRef IntTy, const char *Text,
1458 unsigned SLen, uint8_t Radix);
1461 * Obtain a constant value referring to a double floating point value.
1463 LLVMValueRef LLVMConstReal(LLVMTypeRef RealTy, double N);
1466 * Obtain a constant for a floating point value parsed from a string.
1468 * A similar API, LLVMConstRealOfStringAndSize is also available. It
1469 * should be used if the input string's length is known.
1471 LLVMValueRef LLVMConstRealOfString(LLVMTypeRef RealTy, const char *Text);
1474 * Obtain a constant for a floating point value parsed from a string.
1476 LLVMValueRef LLVMConstRealOfStringAndSize(LLVMTypeRef RealTy, const char *Text,
1480 * Obtain the zero extended value for an integer constant value.
1482 * @see llvm::ConstantInt::getZExtValue()
1484 unsigned long long LLVMConstIntGetZExtValue(LLVMValueRef ConstantVal);
1487 * Obtain the sign extended value for an integer constant value.
1489 * @see llvm::ConstantInt::getSExtValue()
1491 long long LLVMConstIntGetSExtValue(LLVMValueRef ConstantVal);
1498 * @defgroup LLVMCCoreValueConstantComposite Composite Constants
1500 * Functions in this group operate on composite constants.
1506 * Create a ConstantDataSequential and initialize it with a string.
1508 * @see llvm::ConstantDataArray::getString()
1510 LLVMValueRef LLVMConstStringInContext(LLVMContextRef C, const char *Str,
1511 unsigned Length, LLVMBool DontNullTerminate);
1514 * Create a ConstantDataSequential with string content in the global context.
1516 * This is the same as LLVMConstStringInContext except it operates on the
1519 * @see LLVMConstStringInContext()
1520 * @see llvm::ConstantDataArray::getString()
1522 LLVMValueRef LLVMConstString(const char *Str, unsigned Length,
1523 LLVMBool DontNullTerminate);
1526 * Create an anonymous ConstantStruct with the specified values.
1528 * @see llvm::ConstantStruct::getAnon()
1530 LLVMValueRef LLVMConstStructInContext(LLVMContextRef C,
1531 LLVMValueRef *ConstantVals,
1532 unsigned Count, LLVMBool Packed);
1535 * Create a ConstantStruct in the global Context.
1537 * This is the same as LLVMConstStructInContext except it operates on the
1540 * @see LLVMConstStructInContext()
1542 LLVMValueRef LLVMConstStruct(LLVMValueRef *ConstantVals, unsigned Count,
1546 * Create a ConstantArray from values.
1548 * @see llvm::ConstantArray::get()
1550 LLVMValueRef LLVMConstArray(LLVMTypeRef ElementTy,
1551 LLVMValueRef *ConstantVals, unsigned Length);
1554 * Create a non-anonymous ConstantStruct from values.
1556 * @see llvm::ConstantStruct::get()
1558 LLVMValueRef LLVMConstNamedStruct(LLVMTypeRef StructTy,
1559 LLVMValueRef *ConstantVals,
1563 * Create a ConstantVector from values.
1565 * @see llvm::ConstantVector::get()
1567 LLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals, unsigned Size);
1574 * @defgroup LLVMCCoreValueConstantExpressions Constant Expressions
1576 * Functions in this group correspond to APIs on llvm::ConstantExpr.
1578 * @see llvm::ConstantExpr.
1582 LLVMOpcode LLVMGetConstOpcode(LLVMValueRef ConstantVal);
1583 LLVMValueRef LLVMAlignOf(LLVMTypeRef Ty);
1584 LLVMValueRef LLVMSizeOf(LLVMTypeRef Ty);
1585 LLVMValueRef LLVMConstNeg(LLVMValueRef ConstantVal);
1586 LLVMValueRef LLVMConstNSWNeg(LLVMValueRef ConstantVal);
1587 LLVMValueRef LLVMConstNUWNeg(LLVMValueRef ConstantVal);
1588 LLVMValueRef LLVMConstFNeg(LLVMValueRef ConstantVal);
1589 LLVMValueRef LLVMConstNot(LLVMValueRef ConstantVal);
1590 LLVMValueRef LLVMConstAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1591 LLVMValueRef LLVMConstNSWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1592 LLVMValueRef LLVMConstNUWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1593 LLVMValueRef LLVMConstFAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1594 LLVMValueRef LLVMConstSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1595 LLVMValueRef LLVMConstNSWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1596 LLVMValueRef LLVMConstNUWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1597 LLVMValueRef LLVMConstFSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1598 LLVMValueRef LLVMConstMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1599 LLVMValueRef LLVMConstNSWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1600 LLVMValueRef LLVMConstNUWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1601 LLVMValueRef LLVMConstFMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1602 LLVMValueRef LLVMConstUDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1603 LLVMValueRef LLVMConstSDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1604 LLVMValueRef LLVMConstExactSDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1605 LLVMValueRef LLVMConstFDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1606 LLVMValueRef LLVMConstURem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1607 LLVMValueRef LLVMConstSRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1608 LLVMValueRef LLVMConstFRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1609 LLVMValueRef LLVMConstAnd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1610 LLVMValueRef LLVMConstOr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1611 LLVMValueRef LLVMConstXor(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1612 LLVMValueRef LLVMConstICmp(LLVMIntPredicate Predicate,
1613 LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1614 LLVMValueRef LLVMConstFCmp(LLVMRealPredicate Predicate,
1615 LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1616 LLVMValueRef LLVMConstShl(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1617 LLVMValueRef LLVMConstLShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1618 LLVMValueRef LLVMConstAShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1619 LLVMValueRef LLVMConstGEP(LLVMValueRef ConstantVal,
1620 LLVMValueRef *ConstantIndices, unsigned NumIndices);
1621 LLVMValueRef LLVMConstInBoundsGEP(LLVMValueRef ConstantVal,
1622 LLVMValueRef *ConstantIndices,
1623 unsigned NumIndices);
1624 LLVMValueRef LLVMConstTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1625 LLVMValueRef LLVMConstSExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1626 LLVMValueRef LLVMConstZExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1627 LLVMValueRef LLVMConstFPTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1628 LLVMValueRef LLVMConstFPExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1629 LLVMValueRef LLVMConstUIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1630 LLVMValueRef LLVMConstSIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1631 LLVMValueRef LLVMConstFPToUI(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1632 LLVMValueRef LLVMConstFPToSI(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1633 LLVMValueRef LLVMConstPtrToInt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1634 LLVMValueRef LLVMConstIntToPtr(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1635 LLVMValueRef LLVMConstBitCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1636 LLVMValueRef LLVMConstAddrSpaceCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1637 LLVMValueRef LLVMConstZExtOrBitCast(LLVMValueRef ConstantVal,
1638 LLVMTypeRef ToType);
1639 LLVMValueRef LLVMConstSExtOrBitCast(LLVMValueRef ConstantVal,
1640 LLVMTypeRef ToType);
1641 LLVMValueRef LLVMConstTruncOrBitCast(LLVMValueRef ConstantVal,
1642 LLVMTypeRef ToType);
1643 LLVMValueRef LLVMConstPointerCast(LLVMValueRef ConstantVal,
1644 LLVMTypeRef ToType);
1645 LLVMValueRef LLVMConstIntCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType,
1647 LLVMValueRef LLVMConstFPCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1648 LLVMValueRef LLVMConstSelect(LLVMValueRef ConstantCondition,
1649 LLVMValueRef ConstantIfTrue,
1650 LLVMValueRef ConstantIfFalse);
1651 LLVMValueRef LLVMConstExtractElement(LLVMValueRef VectorConstant,
1652 LLVMValueRef IndexConstant);
1653 LLVMValueRef LLVMConstInsertElement(LLVMValueRef VectorConstant,
1654 LLVMValueRef ElementValueConstant,
1655 LLVMValueRef IndexConstant);
1656 LLVMValueRef LLVMConstShuffleVector(LLVMValueRef VectorAConstant,
1657 LLVMValueRef VectorBConstant,
1658 LLVMValueRef MaskConstant);
1659 LLVMValueRef LLVMConstExtractValue(LLVMValueRef AggConstant, unsigned *IdxList,
1661 LLVMValueRef LLVMConstInsertValue(LLVMValueRef AggConstant,
1662 LLVMValueRef ElementValueConstant,
1663 unsigned *IdxList, unsigned NumIdx);
1664 LLVMValueRef LLVMConstInlineAsm(LLVMTypeRef Ty,
1665 const char *AsmString, const char *Constraints,
1666 LLVMBool HasSideEffects, LLVMBool IsAlignStack);
1667 LLVMValueRef LLVMBlockAddress(LLVMValueRef F, LLVMBasicBlockRef BB);
1674 * @defgroup LLVMCCoreValueConstantGlobals Global Values
1676 * This group contains functions that operate on global values. Functions in
1677 * this group relate to functions in the llvm::GlobalValue class tree.
1679 * @see llvm::GlobalValue
1684 LLVMModuleRef LLVMGetGlobalParent(LLVMValueRef Global);
1685 LLVMBool LLVMIsDeclaration(LLVMValueRef Global);
1686 LLVMLinkage LLVMGetLinkage(LLVMValueRef Global);
1687 void LLVMSetLinkage(LLVMValueRef Global, LLVMLinkage Linkage);
1688 const char *LLVMGetSection(LLVMValueRef Global);
1689 void LLVMSetSection(LLVMValueRef Global, const char *Section);
1690 LLVMVisibility LLVMGetVisibility(LLVMValueRef Global);
1691 void LLVMSetVisibility(LLVMValueRef Global, LLVMVisibility Viz);
1694 * @defgroup LLVMCCoreValueWithAlignment Values with alignment
1696 * Functions in this group only apply to values with alignment, i.e.
1697 * global variables, load and store instructions.
1701 * Obtain the preferred alignment of the value.
1702 * @see llvm::LoadInst::getAlignment()
1703 * @see llvm::StoreInst::getAlignment()
1704 * @see llvm::GlobalValue::getAlignment()
1706 unsigned LLVMGetAlignment(LLVMValueRef V);
1709 * Set the preferred alignment of the value.
1710 * @see llvm::LoadInst::setAlignment()
1711 * @see llvm::StoreInst::setAlignment()
1712 * @see llvm::GlobalValue::setAlignment()
1714 void LLVMSetAlignment(LLVMValueRef V, unsigned Bytes);
1721 * @defgroup LLVMCoreValueConstantGlobalVariable Global Variables
1723 * This group contains functions that operate on global variable values.
1725 * @see llvm::GlobalVariable
1729 LLVMValueRef LLVMAddGlobal(LLVMModuleRef M, LLVMTypeRef Ty, const char *Name);
1730 LLVMValueRef LLVMAddGlobalInAddressSpace(LLVMModuleRef M, LLVMTypeRef Ty,
1732 unsigned AddressSpace);
1733 LLVMValueRef LLVMGetNamedGlobal(LLVMModuleRef M, const char *Name);
1734 LLVMValueRef LLVMGetFirstGlobal(LLVMModuleRef M);
1735 LLVMValueRef LLVMGetLastGlobal(LLVMModuleRef M);
1736 LLVMValueRef LLVMGetNextGlobal(LLVMValueRef GlobalVar);
1737 LLVMValueRef LLVMGetPreviousGlobal(LLVMValueRef GlobalVar);
1738 void LLVMDeleteGlobal(LLVMValueRef GlobalVar);
1739 LLVMValueRef LLVMGetInitializer(LLVMValueRef GlobalVar);
1740 void LLVMSetInitializer(LLVMValueRef GlobalVar, LLVMValueRef ConstantVal);
1741 LLVMBool LLVMIsThreadLocal(LLVMValueRef GlobalVar);
1742 void LLVMSetThreadLocal(LLVMValueRef GlobalVar, LLVMBool IsThreadLocal);
1743 LLVMBool LLVMIsGlobalConstant(LLVMValueRef GlobalVar);
1744 void LLVMSetGlobalConstant(LLVMValueRef GlobalVar, LLVMBool IsConstant);
1745 LLVMThreadLocalMode LLVMGetThreadLocalMode(LLVMValueRef GlobalVar);
1746 void LLVMSetThreadLocalMode(LLVMValueRef GlobalVar, LLVMThreadLocalMode Mode);
1747 LLVMBool LLVMIsExternallyInitialized(LLVMValueRef GlobalVar);
1748 void LLVMSetExternallyInitialized(LLVMValueRef GlobalVar, LLVMBool IsExtInit);
1755 * @defgroup LLVMCoreValueConstantGlobalAlias Global Aliases
1757 * This group contains function that operate on global alias values.
1759 * @see llvm::GlobalAlias
1763 LLVMValueRef LLVMAddAlias(LLVMModuleRef M, LLVMTypeRef Ty, LLVMValueRef Aliasee,
1771 * @defgroup LLVMCCoreValueFunction Function values
1773 * Functions in this group operate on LLVMValueRef instances that
1774 * correspond to llvm::Function instances.
1776 * @see llvm::Function
1782 * Remove a function from its containing module and deletes it.
1784 * @see llvm::Function::eraseFromParent()
1786 void LLVMDeleteFunction(LLVMValueRef Fn);
1789 * Obtain the ID number from a function instance.
1791 * @see llvm::Function::getIntrinsicID()
1793 unsigned LLVMGetIntrinsicID(LLVMValueRef Fn);
1796 * Obtain the calling function of a function.
1798 * The returned value corresponds to the LLVMCallConv enumeration.
1800 * @see llvm::Function::getCallingConv()
1802 unsigned LLVMGetFunctionCallConv(LLVMValueRef Fn);
1805 * Set the calling convention of a function.
1807 * @see llvm::Function::setCallingConv()
1809 * @param Fn Function to operate on
1810 * @param CC LLVMCallConv to set calling convention to
1812 void LLVMSetFunctionCallConv(LLVMValueRef Fn, unsigned CC);
1815 * Obtain the name of the garbage collector to use during code
1818 * @see llvm::Function::getGC()
1820 const char *LLVMGetGC(LLVMValueRef Fn);
1823 * Define the garbage collector to use during code generation.
1825 * @see llvm::Function::setGC()
1827 void LLVMSetGC(LLVMValueRef Fn, const char *Name);
1830 * Add an attribute to a function.
1832 * @see llvm::Function::addAttribute()
1834 void LLVMAddFunctionAttr(LLVMValueRef Fn, LLVMAttribute PA);
1837 * Add a target-dependent attribute to a fuction
1838 * @see llvm::AttrBuilder::addAttribute()
1840 void LLVMAddTargetDependentFunctionAttr(LLVMValueRef Fn, const char *A,
1844 * Obtain an attribute from a function.
1846 * @see llvm::Function::getAttributes()
1848 LLVMAttribute LLVMGetFunctionAttr(LLVMValueRef Fn);
1851 * Remove an attribute from a function.
1853 void LLVMRemoveFunctionAttr(LLVMValueRef Fn, LLVMAttribute PA);
1856 * @defgroup LLVMCCoreValueFunctionParameters Function Parameters
1858 * Functions in this group relate to arguments/parameters on functions.
1860 * Functions in this group expect LLVMValueRef instances that correspond
1861 * to llvm::Function instances.
1867 * Obtain the number of parameters in a function.
1869 * @see llvm::Function::arg_size()
1871 unsigned LLVMCountParams(LLVMValueRef Fn);
1874 * Obtain the parameters in a function.
1876 * The takes a pointer to a pre-allocated array of LLVMValueRef that is
1877 * at least LLVMCountParams() long. This array will be filled with
1878 * LLVMValueRef instances which correspond to the parameters the
1879 * function receives. Each LLVMValueRef corresponds to a llvm::Argument
1882 * @see llvm::Function::arg_begin()
1884 void LLVMGetParams(LLVMValueRef Fn, LLVMValueRef *Params);
1887 * Obtain the parameter at the specified index.
1889 * Parameters are indexed from 0.
1891 * @see llvm::Function::arg_begin()
1893 LLVMValueRef LLVMGetParam(LLVMValueRef Fn, unsigned Index);
1896 * Obtain the function to which this argument belongs.
1898 * Unlike other functions in this group, this one takes an LLVMValueRef
1899 * that corresponds to a llvm::Attribute.
1901 * The returned LLVMValueRef is the llvm::Function to which this
1904 LLVMValueRef LLVMGetParamParent(LLVMValueRef Inst);
1907 * Obtain the first parameter to a function.
1909 * @see llvm::Function::arg_begin()
1911 LLVMValueRef LLVMGetFirstParam(LLVMValueRef Fn);
1914 * Obtain the last parameter to a function.
1916 * @see llvm::Function::arg_end()
1918 LLVMValueRef LLVMGetLastParam(LLVMValueRef Fn);
1921 * Obtain the next parameter to a function.
1923 * This takes an LLVMValueRef obtained from LLVMGetFirstParam() (which is
1924 * actually a wrapped iterator) and obtains the next parameter from the
1925 * underlying iterator.
1927 LLVMValueRef LLVMGetNextParam(LLVMValueRef Arg);
1930 * Obtain the previous parameter to a function.
1932 * This is the opposite of LLVMGetNextParam().
1934 LLVMValueRef LLVMGetPreviousParam(LLVMValueRef Arg);
1937 * Add an attribute to a function argument.
1939 * @see llvm::Argument::addAttr()
1941 void LLVMAddAttribute(LLVMValueRef Arg, LLVMAttribute PA);
1944 * Remove an attribute from a function argument.
1946 * @see llvm::Argument::removeAttr()
1948 void LLVMRemoveAttribute(LLVMValueRef Arg, LLVMAttribute PA);
1951 * Get an attribute from a function argument.
1953 LLVMAttribute LLVMGetAttribute(LLVMValueRef Arg);
1956 * Set the alignment for a function parameter.
1958 * @see llvm::Argument::addAttr()
1959 * @see llvm::AttrBuilder::addAlignmentAttr()
1961 void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned align);
1980 * @defgroup LLVMCCoreValueMetadata Metadata
1986 * Obtain a MDString value from a context.
1988 * The returned instance corresponds to the llvm::MDString class.
1990 * The instance is specified by string data of a specified length. The
1991 * string content is copied, so the backing memory can be freed after
1992 * this function returns.
1994 LLVMValueRef LLVMMDStringInContext(LLVMContextRef C, const char *Str,
1998 * Obtain a MDString value from the global context.
2000 LLVMValueRef LLVMMDString(const char *Str, unsigned SLen);
2003 * Obtain a MDNode value from a context.
2005 * The returned value corresponds to the llvm::MDNode class.
2007 LLVMValueRef LLVMMDNodeInContext(LLVMContextRef C, LLVMValueRef *Vals,
2011 * Obtain a MDNode value from the global context.
2013 LLVMValueRef LLVMMDNode(LLVMValueRef *Vals, unsigned Count);
2016 * Obtain the underlying string from a MDString value.
2018 * @param V Instance to obtain string from.
2019 * @param Len Memory address which will hold length of returned string.
2020 * @return String data in MDString.
2022 const char *LLVMGetMDString(LLVMValueRef V, unsigned* Len);
2025 * Obtain the number of operands from an MDNode value.
2027 * @param V MDNode to get number of operands from.
2028 * @return Number of operands of the MDNode.
2030 unsigned LLVMGetMDNodeNumOperands(LLVMValueRef V);
2033 * Obtain the given MDNode's operands.
2035 * The passed LLVMValueRef pointer should point to enough memory to hold all of
2036 * the operands of the given MDNode (see LLVMGetMDNodeNumOperands) as
2037 * LLVMValueRefs. This memory will be populated with the LLVMValueRefs of the
2038 * MDNode's operands.
2040 * @param V MDNode to get the operands from.
2041 * @param Dest Destination array for operands.
2043 void LLVMGetMDNodeOperands(LLVMValueRef V, LLVMValueRef *Dest);
2050 * @defgroup LLVMCCoreValueBasicBlock Basic Block
2052 * A basic block represents a single entry single exit section of code.
2053 * Basic blocks contain a list of instructions which form the body of
2056 * Basic blocks belong to functions. They have the type of label.
2058 * Basic blocks are themselves values. However, the C API models them as
2059 * LLVMBasicBlockRef.
2061 * @see llvm::BasicBlock
2067 * Convert a basic block instance to a value type.
2069 LLVMValueRef LLVMBasicBlockAsValue(LLVMBasicBlockRef BB);
2072 * Determine whether an LLVMValueRef is itself a basic block.
2074 LLVMBool LLVMValueIsBasicBlock(LLVMValueRef Val);
2077 * Convert an LLVMValueRef to an LLVMBasicBlockRef instance.
2079 LLVMBasicBlockRef LLVMValueAsBasicBlock(LLVMValueRef Val);
2082 * Obtain the function to which a basic block belongs.
2084 * @see llvm::BasicBlock::getParent()
2086 LLVMValueRef LLVMGetBasicBlockParent(LLVMBasicBlockRef BB);
2089 * Obtain the terminator instruction for a basic block.
2091 * If the basic block does not have a terminator (it is not well-formed
2092 * if it doesn't), then NULL is returned.
2094 * The returned LLVMValueRef corresponds to a llvm::TerminatorInst.
2096 * @see llvm::BasicBlock::getTerminator()
2098 LLVMValueRef LLVMGetBasicBlockTerminator(LLVMBasicBlockRef BB);
2101 * Obtain the number of basic blocks in a function.
2103 * @param Fn Function value to operate on.
2105 unsigned LLVMCountBasicBlocks(LLVMValueRef Fn);
2108 * Obtain all of the basic blocks in a function.
2110 * This operates on a function value. The BasicBlocks parameter is a
2111 * pointer to a pre-allocated array of LLVMBasicBlockRef of at least
2112 * LLVMCountBasicBlocks() in length. This array is populated with
2113 * LLVMBasicBlockRef instances.
2115 void LLVMGetBasicBlocks(LLVMValueRef Fn, LLVMBasicBlockRef *BasicBlocks);
2118 * Obtain the first basic block in a function.
2120 * The returned basic block can be used as an iterator. You will likely
2121 * eventually call into LLVMGetNextBasicBlock() with it.
2123 * @see llvm::Function::begin()
2125 LLVMBasicBlockRef LLVMGetFirstBasicBlock(LLVMValueRef Fn);
2128 * Obtain the last basic block in a function.
2130 * @see llvm::Function::end()
2132 LLVMBasicBlockRef LLVMGetLastBasicBlock(LLVMValueRef Fn);
2135 * Advance a basic block iterator.
2137 LLVMBasicBlockRef LLVMGetNextBasicBlock(LLVMBasicBlockRef BB);
2140 * Go backwards in a basic block iterator.
2142 LLVMBasicBlockRef LLVMGetPreviousBasicBlock(LLVMBasicBlockRef BB);
2145 * Obtain the basic block that corresponds to the entry point of a
2148 * @see llvm::Function::getEntryBlock()
2150 LLVMBasicBlockRef LLVMGetEntryBasicBlock(LLVMValueRef Fn);
2153 * Append a basic block to the end of a function.
2155 * @see llvm::BasicBlock::Create()
2157 LLVMBasicBlockRef LLVMAppendBasicBlockInContext(LLVMContextRef C,
2162 * Append a basic block to the end of a function using the global
2165 * @see llvm::BasicBlock::Create()
2167 LLVMBasicBlockRef LLVMAppendBasicBlock(LLVMValueRef Fn, const char *Name);
2170 * Insert a basic block in a function before another basic block.
2172 * The function to add to is determined by the function of the
2173 * passed basic block.
2175 * @see llvm::BasicBlock::Create()
2177 LLVMBasicBlockRef LLVMInsertBasicBlockInContext(LLVMContextRef C,
2178 LLVMBasicBlockRef BB,
2182 * Insert a basic block in a function using the global context.
2184 * @see llvm::BasicBlock::Create()
2186 LLVMBasicBlockRef LLVMInsertBasicBlock(LLVMBasicBlockRef InsertBeforeBB,
2190 * Remove a basic block from a function and delete it.
2192 * This deletes the basic block from its containing function and deletes
2193 * the basic block itself.
2195 * @see llvm::BasicBlock::eraseFromParent()
2197 void LLVMDeleteBasicBlock(LLVMBasicBlockRef BB);
2200 * Remove a basic block from a function.
2202 * This deletes the basic block from its containing function but keep
2203 * the basic block alive.
2205 * @see llvm::BasicBlock::removeFromParent()
2207 void LLVMRemoveBasicBlockFromParent(LLVMBasicBlockRef BB);
2210 * Move a basic block to before another one.
2212 * @see llvm::BasicBlock::moveBefore()
2214 void LLVMMoveBasicBlockBefore(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos);
2217 * Move a basic block to after another one.
2219 * @see llvm::BasicBlock::moveAfter()
2221 void LLVMMoveBasicBlockAfter(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos);
2224 * Obtain the first instruction in a basic block.
2226 * The returned LLVMValueRef corresponds to a llvm::Instruction
2229 LLVMValueRef LLVMGetFirstInstruction(LLVMBasicBlockRef BB);
2232 * Obtain the last instruction in a basic block.
2234 * The returned LLVMValueRef corresponds to an LLVM:Instruction.
2236 LLVMValueRef LLVMGetLastInstruction(LLVMBasicBlockRef BB);
2243 * @defgroup LLVMCCoreValueInstruction Instructions
2245 * Functions in this group relate to the inspection and manipulation of
2246 * individual instructions.
2248 * In the C++ API, an instruction is modeled by llvm::Instruction. This
2249 * class has a large number of descendents. llvm::Instruction is a
2250 * llvm::Value and in the C API, instructions are modeled by
2253 * This group also contains sub-groups which operate on specific
2254 * llvm::Instruction types, e.g. llvm::CallInst.
2260 * Determine whether an instruction has any metadata attached.
2262 int LLVMHasMetadata(LLVMValueRef Val);
2265 * Return metadata associated with an instruction value.
2267 LLVMValueRef LLVMGetMetadata(LLVMValueRef Val, unsigned KindID);
2270 * Set metadata associated with an instruction value.
2272 void LLVMSetMetadata(LLVMValueRef Val, unsigned KindID, LLVMValueRef Node);
2275 * Obtain the basic block to which an instruction belongs.
2277 * @see llvm::Instruction::getParent()
2279 LLVMBasicBlockRef LLVMGetInstructionParent(LLVMValueRef Inst);
2282 * Obtain the instruction that occurs after the one specified.
2284 * The next instruction will be from the same basic block.
2286 * If this is the last instruction in a basic block, NULL will be
2289 LLVMValueRef LLVMGetNextInstruction(LLVMValueRef Inst);
2292 * Obtain the instruction that occurred before this one.
2294 * If the instruction is the first instruction in a basic block, NULL
2297 LLVMValueRef LLVMGetPreviousInstruction(LLVMValueRef Inst);
2300 * Remove and delete an instruction.
2302 * The instruction specified is removed from its containing building
2303 * block and then deleted.
2305 * @see llvm::Instruction::eraseFromParent()
2307 void LLVMInstructionEraseFromParent(LLVMValueRef Inst);
2310 * Obtain the code opcode for an individual instruction.
2312 * @see llvm::Instruction::getOpCode()
2314 LLVMOpcode LLVMGetInstructionOpcode(LLVMValueRef Inst);
2317 * Obtain the predicate of an instruction.
2319 * This is only valid for instructions that correspond to llvm::ICmpInst
2320 * or llvm::ConstantExpr whose opcode is llvm::Instruction::ICmp.
2322 * @see llvm::ICmpInst::getPredicate()
2324 LLVMIntPredicate LLVMGetICmpPredicate(LLVMValueRef Inst);
2327 * @defgroup LLVMCCoreValueInstructionCall Call Sites and Invocations
2329 * Functions in this group apply to instructions that refer to call
2330 * sites and invocations. These correspond to C++ types in the
2331 * llvm::CallInst class tree.
2337 * Set the calling convention for a call instruction.
2339 * This expects an LLVMValueRef that corresponds to a llvm::CallInst or
2342 * @see llvm::CallInst::setCallingConv()
2343 * @see llvm::InvokeInst::setCallingConv()
2345 void LLVMSetInstructionCallConv(LLVMValueRef Instr, unsigned CC);
2348 * Obtain the calling convention for a call instruction.
2350 * This is the opposite of LLVMSetInstructionCallConv(). Reads its
2353 * @see LLVMSetInstructionCallConv()
2355 unsigned LLVMGetInstructionCallConv(LLVMValueRef Instr);
2358 void LLVMAddInstrAttribute(LLVMValueRef Instr, unsigned index, LLVMAttribute);
2359 void LLVMRemoveInstrAttribute(LLVMValueRef Instr, unsigned index,
2361 void LLVMSetInstrParamAlignment(LLVMValueRef Instr, unsigned index,
2365 * Obtain whether a call instruction is a tail call.
2367 * This only works on llvm::CallInst instructions.
2369 * @see llvm::CallInst::isTailCall()
2371 LLVMBool LLVMIsTailCall(LLVMValueRef CallInst);
2374 * Set whether a call instruction is a tail call.
2376 * This only works on llvm::CallInst instructions.
2378 * @see llvm::CallInst::setTailCall()
2380 void LLVMSetTailCall(LLVMValueRef CallInst, LLVMBool IsTailCall);
2387 * Obtain the default destination basic block of a switch instruction.
2389 * This only works on llvm::SwitchInst instructions.
2391 * @see llvm::SwitchInst::getDefaultDest()
2393 LLVMBasicBlockRef LLVMGetSwitchDefaultDest(LLVMValueRef SwitchInstr);
2396 * @defgroup LLVMCCoreValueInstructionPHINode PHI Nodes
2398 * Functions in this group only apply to instructions that map to
2399 * llvm::PHINode instances.
2405 * Add an incoming value to the end of a PHI list.
2407 void LLVMAddIncoming(LLVMValueRef PhiNode, LLVMValueRef *IncomingValues,
2408 LLVMBasicBlockRef *IncomingBlocks, unsigned Count);
2411 * Obtain the number of incoming basic blocks to a PHI node.
2413 unsigned LLVMCountIncoming(LLVMValueRef PhiNode);
2416 * Obtain an incoming value to a PHI node as an LLVMValueRef.
2418 LLVMValueRef LLVMGetIncomingValue(LLVMValueRef PhiNode, unsigned Index);
2421 * Obtain an incoming value to a PHI node as an LLVMBasicBlockRef.
2423 LLVMBasicBlockRef LLVMGetIncomingBlock(LLVMValueRef PhiNode, unsigned Index);
2438 * @defgroup LLVMCCoreInstructionBuilder Instruction Builders
2440 * An instruction builder represents a point within a basic block and is
2441 * the exclusive means of building instructions using the C interface.
2446 LLVMBuilderRef LLVMCreateBuilderInContext(LLVMContextRef C);
2447 LLVMBuilderRef LLVMCreateBuilder(void);
2448 void LLVMPositionBuilder(LLVMBuilderRef Builder, LLVMBasicBlockRef Block,
2449 LLVMValueRef Instr);
2450 void LLVMPositionBuilderBefore(LLVMBuilderRef Builder, LLVMValueRef Instr);
2451 void LLVMPositionBuilderAtEnd(LLVMBuilderRef Builder, LLVMBasicBlockRef Block);
2452 LLVMBasicBlockRef LLVMGetInsertBlock(LLVMBuilderRef Builder);
2453 void LLVMClearInsertionPosition(LLVMBuilderRef Builder);
2454 void LLVMInsertIntoBuilder(LLVMBuilderRef Builder, LLVMValueRef Instr);
2455 void LLVMInsertIntoBuilderWithName(LLVMBuilderRef Builder, LLVMValueRef Instr,
2457 void LLVMDisposeBuilder(LLVMBuilderRef Builder);
2460 void LLVMSetCurrentDebugLocation(LLVMBuilderRef Builder, LLVMValueRef L);
2461 LLVMValueRef LLVMGetCurrentDebugLocation(LLVMBuilderRef Builder);
2462 void LLVMSetInstDebugLocation(LLVMBuilderRef Builder, LLVMValueRef Inst);
2465 LLVMValueRef LLVMBuildRetVoid(LLVMBuilderRef);
2466 LLVMValueRef LLVMBuildRet(LLVMBuilderRef, LLVMValueRef V);
2467 LLVMValueRef LLVMBuildAggregateRet(LLVMBuilderRef, LLVMValueRef *RetVals,
2469 LLVMValueRef LLVMBuildBr(LLVMBuilderRef, LLVMBasicBlockRef Dest);
2470 LLVMValueRef LLVMBuildCondBr(LLVMBuilderRef, LLVMValueRef If,
2471 LLVMBasicBlockRef Then, LLVMBasicBlockRef Else);
2472 LLVMValueRef LLVMBuildSwitch(LLVMBuilderRef, LLVMValueRef V,
2473 LLVMBasicBlockRef Else, unsigned NumCases);
2474 LLVMValueRef LLVMBuildIndirectBr(LLVMBuilderRef B, LLVMValueRef Addr,
2476 LLVMValueRef LLVMBuildInvoke(LLVMBuilderRef, LLVMValueRef Fn,
2477 LLVMValueRef *Args, unsigned NumArgs,
2478 LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch,
2480 LLVMValueRef LLVMBuildLandingPad(LLVMBuilderRef B, LLVMTypeRef Ty,
2481 LLVMValueRef PersFn, unsigned NumClauses,
2483 LLVMValueRef LLVMBuildResume(LLVMBuilderRef B, LLVMValueRef Exn);
2484 LLVMValueRef LLVMBuildUnreachable(LLVMBuilderRef);
2486 /* Add a case to the switch instruction */
2487 void LLVMAddCase(LLVMValueRef Switch, LLVMValueRef OnVal,
2488 LLVMBasicBlockRef Dest);
2490 /* Add a destination to the indirectbr instruction */
2491 void LLVMAddDestination(LLVMValueRef IndirectBr, LLVMBasicBlockRef Dest);
2493 /* Add a catch or filter clause to the landingpad instruction */
2494 void LLVMAddClause(LLVMValueRef LandingPad, LLVMValueRef ClauseVal);
2496 /* Set the 'cleanup' flag in the landingpad instruction */
2497 void LLVMSetCleanup(LLVMValueRef LandingPad, LLVMBool Val);
2500 LLVMValueRef LLVMBuildAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2502 LLVMValueRef LLVMBuildNSWAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2504 LLVMValueRef LLVMBuildNUWAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2506 LLVMValueRef LLVMBuildFAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2508 LLVMValueRef LLVMBuildSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2510 LLVMValueRef LLVMBuildNSWSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2512 LLVMValueRef LLVMBuildNUWSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2514 LLVMValueRef LLVMBuildFSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2516 LLVMValueRef LLVMBuildMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2518 LLVMValueRef LLVMBuildNSWMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2520 LLVMValueRef LLVMBuildNUWMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2522 LLVMValueRef LLVMBuildFMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2524 LLVMValueRef LLVMBuildUDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2526 LLVMValueRef LLVMBuildSDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2528 LLVMValueRef LLVMBuildExactSDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2530 LLVMValueRef LLVMBuildFDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2532 LLVMValueRef LLVMBuildURem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2534 LLVMValueRef LLVMBuildSRem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2536 LLVMValueRef LLVMBuildFRem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2538 LLVMValueRef LLVMBuildShl(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2540 LLVMValueRef LLVMBuildLShr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2542 LLVMValueRef LLVMBuildAShr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2544 LLVMValueRef LLVMBuildAnd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2546 LLVMValueRef LLVMBuildOr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2548 LLVMValueRef LLVMBuildXor(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2550 LLVMValueRef LLVMBuildBinOp(LLVMBuilderRef B, LLVMOpcode Op,
2551 LLVMValueRef LHS, LLVMValueRef RHS,
2553 LLVMValueRef LLVMBuildNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name);
2554 LLVMValueRef LLVMBuildNSWNeg(LLVMBuilderRef B, LLVMValueRef V,
2556 LLVMValueRef LLVMBuildNUWNeg(LLVMBuilderRef B, LLVMValueRef V,
2558 LLVMValueRef LLVMBuildFNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name);
2559 LLVMValueRef LLVMBuildNot(LLVMBuilderRef, LLVMValueRef V, const char *Name);
2562 LLVMValueRef LLVMBuildMalloc(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
2563 LLVMValueRef LLVMBuildArrayMalloc(LLVMBuilderRef, LLVMTypeRef Ty,
2564 LLVMValueRef Val, const char *Name);
2565 LLVMValueRef LLVMBuildAlloca(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
2566 LLVMValueRef LLVMBuildArrayAlloca(LLVMBuilderRef, LLVMTypeRef Ty,
2567 LLVMValueRef Val, const char *Name);
2568 LLVMValueRef LLVMBuildFree(LLVMBuilderRef, LLVMValueRef PointerVal);
2569 LLVMValueRef LLVMBuildLoad(LLVMBuilderRef, LLVMValueRef PointerVal,
2571 LLVMValueRef LLVMBuildStore(LLVMBuilderRef, LLVMValueRef Val, LLVMValueRef Ptr);
2572 LLVMValueRef LLVMBuildGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
2573 LLVMValueRef *Indices, unsigned NumIndices,
2575 LLVMValueRef LLVMBuildInBoundsGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
2576 LLVMValueRef *Indices, unsigned NumIndices,
2578 LLVMValueRef LLVMBuildStructGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
2579 unsigned Idx, const char *Name);
2580 LLVMValueRef LLVMBuildGlobalString(LLVMBuilderRef B, const char *Str,
2582 LLVMValueRef LLVMBuildGlobalStringPtr(LLVMBuilderRef B, const char *Str,
2584 LLVMBool LLVMGetVolatile(LLVMValueRef MemoryAccessInst);
2585 void LLVMSetVolatile(LLVMValueRef MemoryAccessInst, LLVMBool IsVolatile);
2588 LLVMValueRef LLVMBuildTrunc(LLVMBuilderRef, LLVMValueRef Val,
2589 LLVMTypeRef DestTy, const char *Name);
2590 LLVMValueRef LLVMBuildZExt(LLVMBuilderRef, LLVMValueRef Val,
2591 LLVMTypeRef DestTy, const char *Name);
2592 LLVMValueRef LLVMBuildSExt(LLVMBuilderRef, LLVMValueRef Val,
2593 LLVMTypeRef DestTy, const char *Name);
2594 LLVMValueRef LLVMBuildFPToUI(LLVMBuilderRef, LLVMValueRef Val,
2595 LLVMTypeRef DestTy, const char *Name);
2596 LLVMValueRef LLVMBuildFPToSI(LLVMBuilderRef, LLVMValueRef Val,
2597 LLVMTypeRef DestTy, const char *Name);
2598 LLVMValueRef LLVMBuildUIToFP(LLVMBuilderRef, LLVMValueRef Val,
2599 LLVMTypeRef DestTy, const char *Name);
2600 LLVMValueRef LLVMBuildSIToFP(LLVMBuilderRef, LLVMValueRef Val,
2601 LLVMTypeRef DestTy, const char *Name);
2602 LLVMValueRef LLVMBuildFPTrunc(LLVMBuilderRef, LLVMValueRef Val,
2603 LLVMTypeRef DestTy, const char *Name);
2604 LLVMValueRef LLVMBuildFPExt(LLVMBuilderRef, LLVMValueRef Val,
2605 LLVMTypeRef DestTy, const char *Name);
2606 LLVMValueRef LLVMBuildPtrToInt(LLVMBuilderRef, LLVMValueRef Val,
2607 LLVMTypeRef DestTy, const char *Name);
2608 LLVMValueRef LLVMBuildIntToPtr(LLVMBuilderRef, LLVMValueRef Val,
2609 LLVMTypeRef DestTy, const char *Name);
2610 LLVMValueRef LLVMBuildBitCast(LLVMBuilderRef, LLVMValueRef Val,
2611 LLVMTypeRef DestTy, const char *Name);
2612 LLVMValueRef LLVMBuildAddrSpaceCast(LLVMBuilderRef, LLVMValueRef Val,
2613 LLVMTypeRef DestTy, const char *Name);
2614 LLVMValueRef LLVMBuildZExtOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
2615 LLVMTypeRef DestTy, const char *Name);
2616 LLVMValueRef LLVMBuildSExtOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
2617 LLVMTypeRef DestTy, const char *Name);
2618 LLVMValueRef LLVMBuildTruncOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
2619 LLVMTypeRef DestTy, const char *Name);
2620 LLVMValueRef LLVMBuildCast(LLVMBuilderRef B, LLVMOpcode Op, LLVMValueRef Val,
2621 LLVMTypeRef DestTy, const char *Name);
2622 LLVMValueRef LLVMBuildPointerCast(LLVMBuilderRef, LLVMValueRef Val,
2623 LLVMTypeRef DestTy, const char *Name);
2624 LLVMValueRef LLVMBuildIntCast(LLVMBuilderRef, LLVMValueRef Val, /*Signed cast!*/
2625 LLVMTypeRef DestTy, const char *Name);
2626 LLVMValueRef LLVMBuildFPCast(LLVMBuilderRef, LLVMValueRef Val,
2627 LLVMTypeRef DestTy, const char *Name);
2630 LLVMValueRef LLVMBuildICmp(LLVMBuilderRef, LLVMIntPredicate Op,
2631 LLVMValueRef LHS, LLVMValueRef RHS,
2633 LLVMValueRef LLVMBuildFCmp(LLVMBuilderRef, LLVMRealPredicate Op,
2634 LLVMValueRef LHS, LLVMValueRef RHS,
2637 /* Miscellaneous instructions */
2638 LLVMValueRef LLVMBuildPhi(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
2639 LLVMValueRef LLVMBuildCall(LLVMBuilderRef, LLVMValueRef Fn,
2640 LLVMValueRef *Args, unsigned NumArgs,
2642 LLVMValueRef LLVMBuildSelect(LLVMBuilderRef, LLVMValueRef If,
2643 LLVMValueRef Then, LLVMValueRef Else,
2645 LLVMValueRef LLVMBuildVAArg(LLVMBuilderRef, LLVMValueRef List, LLVMTypeRef Ty,
2647 LLVMValueRef LLVMBuildExtractElement(LLVMBuilderRef, LLVMValueRef VecVal,
2648 LLVMValueRef Index, const char *Name);
2649 LLVMValueRef LLVMBuildInsertElement(LLVMBuilderRef, LLVMValueRef VecVal,
2650 LLVMValueRef EltVal, LLVMValueRef Index,
2652 LLVMValueRef LLVMBuildShuffleVector(LLVMBuilderRef, LLVMValueRef V1,
2653 LLVMValueRef V2, LLVMValueRef Mask,
2655 LLVMValueRef LLVMBuildExtractValue(LLVMBuilderRef, LLVMValueRef AggVal,
2656 unsigned Index, const char *Name);
2657 LLVMValueRef LLVMBuildInsertValue(LLVMBuilderRef, LLVMValueRef AggVal,
2658 LLVMValueRef EltVal, unsigned Index,
2661 LLVMValueRef LLVMBuildIsNull(LLVMBuilderRef, LLVMValueRef Val,
2663 LLVMValueRef LLVMBuildIsNotNull(LLVMBuilderRef, LLVMValueRef Val,
2665 LLVMValueRef LLVMBuildPtrDiff(LLVMBuilderRef, LLVMValueRef LHS,
2666 LLVMValueRef RHS, const char *Name);
2667 LLVMValueRef LLVMBuildFence(LLVMBuilderRef B, LLVMAtomicOrdering ordering,
2668 LLVMBool singleThread, const char *Name);
2669 LLVMValueRef LLVMBuildAtomicRMW(LLVMBuilderRef B, LLVMAtomicRMWBinOp op,
2670 LLVMValueRef PTR, LLVMValueRef Val,
2671 LLVMAtomicOrdering ordering,
2672 LLVMBool singleThread);
2679 * @defgroup LLVMCCoreModuleProvider Module Providers
2685 * Changes the type of M so it can be passed to FunctionPassManagers and the
2686 * JIT. They take ModuleProviders for historical reasons.
2688 LLVMModuleProviderRef
2689 LLVMCreateModuleProviderForExistingModule(LLVMModuleRef M);
2692 * Destroys the module M.
2694 void LLVMDisposeModuleProvider(LLVMModuleProviderRef M);
2701 * @defgroup LLVMCCoreMemoryBuffers Memory Buffers
2706 LLVMBool LLVMCreateMemoryBufferWithContentsOfFile(const char *Path,
2707 LLVMMemoryBufferRef *OutMemBuf,
2709 LLVMBool LLVMCreateMemoryBufferWithSTDIN(LLVMMemoryBufferRef *OutMemBuf,
2711 LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRange(const char *InputData,
2712 size_t InputDataLength,
2713 const char *BufferName,
2714 LLVMBool RequiresNullTerminator);
2715 LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRangeCopy(const char *InputData,
2716 size_t InputDataLength,
2717 const char *BufferName);
2718 const char *LLVMGetBufferStart(LLVMMemoryBufferRef MemBuf);
2719 size_t LLVMGetBufferSize(LLVMMemoryBufferRef MemBuf);
2720 void LLVMDisposeMemoryBuffer(LLVMMemoryBufferRef MemBuf);
2727 * @defgroup LLVMCCorePassRegistry Pass Registry
2732 /** Return the global pass registry, for use with initialization functions.
2733 @see llvm::PassRegistry::getPassRegistry */
2734 LLVMPassRegistryRef LLVMGetGlobalPassRegistry(void);
2741 * @defgroup LLVMCCorePassManagers Pass Managers
2746 /** Constructs a new whole-module pass pipeline. This type of pipeline is
2747 suitable for link-time optimization and whole-module transformations.
2748 @see llvm::PassManager::PassManager */
2749 LLVMPassManagerRef LLVMCreatePassManager(void);
2751 /** Constructs a new function-by-function pass pipeline over the module
2752 provider. It does not take ownership of the module provider. This type of
2753 pipeline is suitable for code generation and JIT compilation tasks.
2754 @see llvm::FunctionPassManager::FunctionPassManager */
2755 LLVMPassManagerRef LLVMCreateFunctionPassManagerForModule(LLVMModuleRef M);
2757 /** Deprecated: Use LLVMCreateFunctionPassManagerForModule instead. */
2758 LLVMPassManagerRef LLVMCreateFunctionPassManager(LLVMModuleProviderRef MP);
2760 /** Initializes, executes on the provided module, and finalizes all of the
2761 passes scheduled in the pass manager. Returns 1 if any of the passes
2762 modified the module, 0 otherwise.
2763 @see llvm::PassManager::run(Module&) */
2764 LLVMBool LLVMRunPassManager(LLVMPassManagerRef PM, LLVMModuleRef M);
2766 /** Initializes all of the function passes scheduled in the function pass
2767 manager. Returns 1 if any of the passes modified the module, 0 otherwise.
2768 @see llvm::FunctionPassManager::doInitialization */
2769 LLVMBool LLVMInitializeFunctionPassManager(LLVMPassManagerRef FPM);
2771 /** Executes all of the function passes scheduled in the function pass manager
2772 on the provided function. Returns 1 if any of the passes modified the
2773 function, false otherwise.
2774 @see llvm::FunctionPassManager::run(Function&) */
2775 LLVMBool LLVMRunFunctionPassManager(LLVMPassManagerRef FPM, LLVMValueRef F);
2777 /** Finalizes all of the function passes scheduled in in the function pass
2778 manager. Returns 1 if any of the passes modified the module, 0 otherwise.
2779 @see llvm::FunctionPassManager::doFinalization */
2780 LLVMBool LLVMFinalizeFunctionPassManager(LLVMPassManagerRef FPM);
2782 /** Frees the memory of a pass pipeline. For function pipelines, does not free
2783 the module provider.
2784 @see llvm::PassManagerBase::~PassManagerBase. */
2785 void LLVMDisposePassManager(LLVMPassManagerRef PM);
2792 * @defgroup LLVMCCoreThreading Threading
2794 * Handle the structures needed to make LLVM safe for multithreading.
2799 /** Allocate and initialize structures needed to make LLVM safe for
2800 multithreading. The return value indicates whether multithreaded
2801 initialization succeeded. Must be executed in isolation from all
2802 other LLVM api calls.
2803 @see llvm::llvm_start_multithreaded */
2804 LLVMBool LLVMStartMultithreaded(void);
2806 /** Deallocate structures necessary to make LLVM safe for multithreading.
2807 Must be executed in isolation from all other LLVM api calls.
2808 @see llvm::llvm_stop_multithreaded */
2809 void LLVMStopMultithreaded(void);
2811 /** Check whether LLVM is executing in thread-safe mode or not.
2812 @see llvm::llvm_is_multithreaded */
2813 LLVMBool LLVMIsMultithreaded(void);
2829 #endif /* !defined(__cplusplus) */
2831 #endif /* !defined(LLVM_C_CORE_H) */