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
174 /* Terminator Instructions */
180 /* removed 6 due to API changes */
183 /* Standard Binary Operators */
197 /* Logical Operators */
205 /* Memory Operators */
209 LLVMGetElementPtr = 29,
225 /* Other Operators */
234 LLVMExtractElement = 50,
235 LLVMInsertElement = 51,
236 LLVMShuffleVector = 52,
237 LLVMExtractValue = 53,
238 LLVMInsertValue = 54,
240 /* Atomic operators */
242 LLVMAtomicCmpXchg = 56,
245 /* Exception Handling Operators */
252 LLVMVoidTypeKind, /**< type with no size */
253 LLVMHalfTypeKind, /**< 16 bit floating point type */
254 LLVMFloatTypeKind, /**< 32 bit floating point type */
255 LLVMDoubleTypeKind, /**< 64 bit floating point type */
256 LLVMX86_FP80TypeKind, /**< 80 bit floating point type (X87) */
257 LLVMFP128TypeKind, /**< 128 bit floating point type (112-bit mantissa)*/
258 LLVMPPC_FP128TypeKind, /**< 128 bit floating point type (two 64-bits) */
259 LLVMLabelTypeKind, /**< Labels */
260 LLVMIntegerTypeKind, /**< Arbitrary bit width integers */
261 LLVMFunctionTypeKind, /**< Functions */
262 LLVMStructTypeKind, /**< Structures */
263 LLVMArrayTypeKind, /**< Arrays */
264 LLVMPointerTypeKind, /**< Pointers */
265 LLVMVectorTypeKind, /**< SIMD 'packed' format, or other vector type */
266 LLVMMetadataTypeKind, /**< Metadata */
267 LLVMX86_MMXTypeKind /**< X86 MMX */
271 LLVMExternalLinkage, /**< Externally visible function */
272 LLVMAvailableExternallyLinkage,
273 LLVMLinkOnceAnyLinkage, /**< Keep one copy of function when linking (inline)*/
274 LLVMLinkOnceODRLinkage, /**< Same, but only replaced by something
276 LLVMLinkOnceODRAutoHideLinkage, /**< Like LinkOnceODR, but possibly hidden. */
277 LLVMWeakAnyLinkage, /**< Keep one copy of function when linking (weak) */
278 LLVMWeakODRLinkage, /**< Same, but only replaced by something
280 LLVMAppendingLinkage, /**< Special purpose, only applies to global arrays */
281 LLVMInternalLinkage, /**< Rename collisions when linking (static
283 LLVMPrivateLinkage, /**< Like Internal, but omit from symbol table */
284 LLVMDLLImportLinkage, /**< Function to be imported from DLL */
285 LLVMDLLExportLinkage, /**< Function to be accessible from DLL */
286 LLVMExternalWeakLinkage,/**< ExternalWeak linkage description */
287 LLVMGhostLinkage, /**< Obsolete */
288 LLVMCommonLinkage, /**< Tentative definitions */
289 LLVMLinkerPrivateLinkage, /**< Like Private, but linker removes. */
290 LLVMLinkerPrivateWeakLinkage /**< Like LinkerPrivate, but is weak. */
294 LLVMDefaultVisibility, /**< The GV is visible */
295 LLVMHiddenVisibility, /**< The GV is hidden */
296 LLVMProtectedVisibility /**< The GV is protected */
301 LLVMFastCallConv = 8,
302 LLVMColdCallConv = 9,
303 LLVMX86StdcallCallConv = 64,
304 LLVMX86FastcallCallConv = 65
308 LLVMIntEQ = 32, /**< equal */
309 LLVMIntNE, /**< not equal */
310 LLVMIntUGT, /**< unsigned greater than */
311 LLVMIntUGE, /**< unsigned greater or equal */
312 LLVMIntULT, /**< unsigned less than */
313 LLVMIntULE, /**< unsigned less or equal */
314 LLVMIntSGT, /**< signed greater than */
315 LLVMIntSGE, /**< signed greater or equal */
316 LLVMIntSLT, /**< signed less than */
317 LLVMIntSLE /**< signed less or equal */
321 LLVMRealPredicateFalse, /**< Always false (always folded) */
322 LLVMRealOEQ, /**< True if ordered and equal */
323 LLVMRealOGT, /**< True if ordered and greater than */
324 LLVMRealOGE, /**< True if ordered and greater than or equal */
325 LLVMRealOLT, /**< True if ordered and less than */
326 LLVMRealOLE, /**< True if ordered and less than or equal */
327 LLVMRealONE, /**< True if ordered and operands are unequal */
328 LLVMRealORD, /**< True if ordered (no nans) */
329 LLVMRealUNO, /**< True if unordered: isnan(X) | isnan(Y) */
330 LLVMRealUEQ, /**< True if unordered or equal */
331 LLVMRealUGT, /**< True if unordered or greater than */
332 LLVMRealUGE, /**< True if unordered, greater than, or equal */
333 LLVMRealULT, /**< True if unordered or less than */
334 LLVMRealULE, /**< True if unordered, less than, or equal */
335 LLVMRealUNE, /**< True if unordered or not equal */
336 LLVMRealPredicateTrue /**< Always true (always folded) */
340 LLVMLandingPadCatch, /**< A catch clause */
341 LLVMLandingPadFilter /**< A filter clause */
342 } LLVMLandingPadClauseTy;
345 LLVMNotThreadLocal = 0,
346 LLVMGeneralDynamicTLSModel,
347 LLVMLocalDynamicTLSModel,
348 LLVMInitialExecTLSModel,
349 LLVMLocalExecTLSModel
350 } LLVMThreadLocalMode;
353 LLVMAtomicOrderingNotAtomic = 0, /**< A load or store which is not atomic */
354 LLVMAtomicOrderingUnordered = 1, /**< Lowest level of atomicity, guarantees
355 somewhat sane results, lock free. */
356 LLVMAtomicOrderingMonotonic = 2, /**< guarantees that if you take all the
357 operations affecting a specific address,
358 a consistent ordering exists */
359 LLVMAtomicOrderingAcquire = 4, /**< Acquire provides a barrier of the sort
360 necessary to acquire a lock to access other
361 memory with normal loads and stores. */
362 LLVMAtomicOrderingRelease = 5, /**< Release is similar to Acquire, but with
363 a barrier of the sort necessary to release
365 LLVMAtomicOrderingAcquireRelease = 6, /**< provides both an Acquire and a
366 Release barrier (for fences and
367 operations which both read and write
369 LLVMAtomicOrderingSequentiallyConsistent = 7 /**< provides Acquire semantics
370 for loads and Release
371 semantics for stores.
372 Additionally, it guarantees
373 that a total ordering exists
375 SequentiallyConsistent
377 } LLVMAtomicOrdering;
380 LLVMAtomicRMWBinOpXchg, /**< Set the new value and return the one old */
381 LLVMAtomicRMWBinOpAdd, /**< Add a value and return the old one */
382 LLVMAtomicRMWBinOpSub, /**< Subtract a value and return the old one */
383 LLVMAtomicRMWBinOpAnd, /**< And a value and return the old one */
384 LLVMAtomicRMWBinOpNand, /**< Not-And a value and return the old one */
385 LLVMAtomicRMWBinOpOr, /**< OR a value and return the old one */
386 LLVMAtomicRMWBinOpXor, /**< Xor a value and return the old one */
387 LLVMAtomicRMWBinOpMax, /**< Sets the value if it's greater than the
388 original using a signed comparison and return
390 LLVMAtomicRMWBinOpMin, /**< Sets the value if it's Smaller than the
391 original using a signed comparison and return
393 LLVMAtomicRMWBinOpUMax, /**< Sets the value if it's greater than the
394 original using an unsigned comparison and return
396 LLVMAtomicRMWBinOpUMin /**< Sets the value if it's greater than the
397 original using an unsigned comparison and return
399 } LLVMAtomicRMWBinOp;
405 void LLVMInitializeCore(LLVMPassRegistryRef R);
407 /** Deallocate and destroy all ManagedStatic variables.
408 @see llvm::llvm_shutdown
409 @see ManagedStatic */
413 /*===-- Error handling ----------------------------------------------------===*/
415 char *LLVMCreateMessage(const char *Message);
416 void LLVMDisposeMessage(char *Message);
420 * @defgroup LLVMCCoreContext Contexts
422 * Contexts are execution states for the core LLVM IR system.
424 * Most types are tied to a context instance. Multiple contexts can
425 * exist simultaneously. A single context is not thread safe. However,
426 * different contexts can execute on different threads simultaneously.
432 * Create a new context.
434 * Every call to this function should be paired with a call to
435 * LLVMContextDispose() or the context will leak memory.
437 LLVMContextRef LLVMContextCreate(void);
440 * Obtain the global context instance.
442 LLVMContextRef LLVMGetGlobalContext(void);
445 * Destroy a context instance.
447 * This should be called for every call to LLVMContextCreate() or memory
450 void LLVMContextDispose(LLVMContextRef C);
452 unsigned LLVMGetMDKindIDInContext(LLVMContextRef C, const char* Name,
454 unsigned LLVMGetMDKindID(const char* Name, unsigned SLen);
461 * @defgroup LLVMCCoreModule Modules
463 * Modules represent the top-level structure in a LLVM program. An LLVM
464 * module is effectively a translation unit or a collection of
465 * translation units merged together.
471 * Create a new, empty module in the global context.
473 * This is equivalent to calling LLVMModuleCreateWithNameInContext with
474 * LLVMGetGlobalContext() as the context parameter.
476 * Every invocation should be paired with LLVMDisposeModule() or memory
479 LLVMModuleRef LLVMModuleCreateWithName(const char *ModuleID);
482 * Create a new, empty module in a specific context.
484 * Every invocation should be paired with LLVMDisposeModule() or memory
487 LLVMModuleRef LLVMModuleCreateWithNameInContext(const char *ModuleID,
491 * Destroy a module instance.
493 * This must be called for every created module or memory will be
496 void LLVMDisposeModule(LLVMModuleRef M);
499 * Obtain the data layout for a module.
501 * @see Module::getDataLayout()
503 const char *LLVMGetDataLayout(LLVMModuleRef M);
506 * Set the data layout for a module.
508 * @see Module::setDataLayout()
510 void LLVMSetDataLayout(LLVMModuleRef M, const char *Triple);
513 * Obtain the target triple for a module.
515 * @see Module::getTargetTriple()
517 const char *LLVMGetTarget(LLVMModuleRef M);
520 * Set the target triple for a module.
522 * @see Module::setTargetTriple()
524 void LLVMSetTarget(LLVMModuleRef M, const char *Triple);
527 * Dump a representation of a module to stderr.
529 * @see Module::dump()
531 void LLVMDumpModule(LLVMModuleRef M);
534 * Print a representation of a module to a file. The ErrorMessage needs to be
535 * disposed with LLVMDisposeMessage. Returns 0 on success, 1 otherwise.
537 * @see Module::print()
539 LLVMBool LLVMPrintModuleToFile(LLVMModuleRef M, const char *Filename,
540 char **ErrorMessage);
543 * Set inline assembly for a module.
545 * @see Module::setModuleInlineAsm()
547 void LLVMSetModuleInlineAsm(LLVMModuleRef M, const char *Asm);
550 * Obtain the context to which this module is associated.
552 * @see Module::getContext()
554 LLVMContextRef LLVMGetModuleContext(LLVMModuleRef M);
557 * Obtain a Type from a module by its registered name.
559 LLVMTypeRef LLVMGetTypeByName(LLVMModuleRef M, const char *Name);
562 * Obtain the number of operands for named metadata in a module.
564 * @see llvm::Module::getNamedMetadata()
566 unsigned LLVMGetNamedMetadataNumOperands(LLVMModuleRef M, const char* name);
569 * Obtain the named metadata operands for a module.
571 * The passed LLVMValueRef pointer should refer to an array of
572 * LLVMValueRef at least LLVMGetNamedMetadataNumOperands long. This
573 * array will be populated with the LLVMValueRef instances. Each
574 * instance corresponds to a llvm::MDNode.
576 * @see llvm::Module::getNamedMetadata()
577 * @see llvm::MDNode::getOperand()
579 void LLVMGetNamedMetadataOperands(LLVMModuleRef M, const char* name, LLVMValueRef *Dest);
582 * Add an operand to named metadata.
584 * @see llvm::Module::getNamedMetadata()
585 * @see llvm::MDNode::addOperand()
587 void LLVMAddNamedMetadataOperand(LLVMModuleRef M, const char* name,
591 * Add a function to a module under a specified name.
593 * @see llvm::Function::Create()
595 LLVMValueRef LLVMAddFunction(LLVMModuleRef M, const char *Name,
596 LLVMTypeRef FunctionTy);
599 * Obtain a Function value from a Module by its name.
601 * The returned value corresponds to a llvm::Function value.
603 * @see llvm::Module::getFunction()
605 LLVMValueRef LLVMGetNamedFunction(LLVMModuleRef M, const char *Name);
608 * Obtain an iterator to the first Function in a Module.
610 * @see llvm::Module::begin()
612 LLVMValueRef LLVMGetFirstFunction(LLVMModuleRef M);
615 * Obtain an iterator to the last Function in a Module.
617 * @see llvm::Module::end()
619 LLVMValueRef LLVMGetLastFunction(LLVMModuleRef M);
622 * Advance a Function iterator to the next Function.
624 * Returns NULL if the iterator was already at the end and there are no more
627 LLVMValueRef LLVMGetNextFunction(LLVMValueRef Fn);
630 * Decrement a Function iterator to the previous Function.
632 * Returns NULL if the iterator was already at the beginning and there are
633 * no previous functions.
635 LLVMValueRef LLVMGetPreviousFunction(LLVMValueRef Fn);
642 * @defgroup LLVMCCoreType Types
644 * Types represent the type of a value.
646 * Types are associated with a context instance. The context internally
647 * deduplicates types so there is only 1 instance of a specific type
648 * alive at a time. In other words, a unique type is shared among all
649 * consumers within a context.
651 * A Type in the C API corresponds to llvm::Type.
653 * Types have the following hierarchy:
671 * Obtain the enumerated type of a Type instance.
673 * @see llvm::Type:getTypeID()
675 LLVMTypeKind LLVMGetTypeKind(LLVMTypeRef Ty);
678 * Whether the type has a known size.
680 * Things that don't have a size are abstract types, labels, and void.a
682 * @see llvm::Type::isSized()
684 LLVMBool LLVMTypeIsSized(LLVMTypeRef Ty);
687 * Obtain the context to which this type instance is associated.
689 * @see llvm::Type::getContext()
691 LLVMContextRef LLVMGetTypeContext(LLVMTypeRef Ty);
694 * @defgroup LLVMCCoreTypeInt Integer Types
696 * Functions in this section operate on integer types.
702 * Obtain an integer type from a context with specified bit width.
704 LLVMTypeRef LLVMInt1TypeInContext(LLVMContextRef C);
705 LLVMTypeRef LLVMInt8TypeInContext(LLVMContextRef C);
706 LLVMTypeRef LLVMInt16TypeInContext(LLVMContextRef C);
707 LLVMTypeRef LLVMInt32TypeInContext(LLVMContextRef C);
708 LLVMTypeRef LLVMInt64TypeInContext(LLVMContextRef C);
709 LLVMTypeRef LLVMIntTypeInContext(LLVMContextRef C, unsigned NumBits);
712 * Obtain an integer type from the global context with a specified bit
715 LLVMTypeRef LLVMInt1Type(void);
716 LLVMTypeRef LLVMInt8Type(void);
717 LLVMTypeRef LLVMInt16Type(void);
718 LLVMTypeRef LLVMInt32Type(void);
719 LLVMTypeRef LLVMInt64Type(void);
720 LLVMTypeRef LLVMIntType(unsigned NumBits);
721 unsigned LLVMGetIntTypeWidth(LLVMTypeRef IntegerTy);
728 * @defgroup LLVMCCoreTypeFloat Floating Point Types
734 * Obtain a 16-bit floating point type from a context.
736 LLVMTypeRef LLVMHalfTypeInContext(LLVMContextRef C);
739 * Obtain a 32-bit floating point type from a context.
741 LLVMTypeRef LLVMFloatTypeInContext(LLVMContextRef C);
744 * Obtain a 64-bit floating point type from a context.
746 LLVMTypeRef LLVMDoubleTypeInContext(LLVMContextRef C);
749 * Obtain a 80-bit floating point type (X87) from a context.
751 LLVMTypeRef LLVMX86FP80TypeInContext(LLVMContextRef C);
754 * Obtain a 128-bit floating point type (112-bit mantissa) from a
757 LLVMTypeRef LLVMFP128TypeInContext(LLVMContextRef C);
760 * Obtain a 128-bit floating point type (two 64-bits) from a context.
762 LLVMTypeRef LLVMPPCFP128TypeInContext(LLVMContextRef C);
765 * Obtain a floating point type from the global context.
767 * These map to the functions in this group of the same name.
769 LLVMTypeRef LLVMHalfType(void);
770 LLVMTypeRef LLVMFloatType(void);
771 LLVMTypeRef LLVMDoubleType(void);
772 LLVMTypeRef LLVMX86FP80Type(void);
773 LLVMTypeRef LLVMFP128Type(void);
774 LLVMTypeRef LLVMPPCFP128Type(void);
781 * @defgroup LLVMCCoreTypeFunction Function Types
787 * Obtain a function type consisting of a specified signature.
789 * The function is defined as a tuple of a return Type, a list of
790 * parameter types, and whether the function is variadic.
792 LLVMTypeRef LLVMFunctionType(LLVMTypeRef ReturnType,
793 LLVMTypeRef *ParamTypes, unsigned ParamCount,
797 * Returns whether a function type is variadic.
799 LLVMBool LLVMIsFunctionVarArg(LLVMTypeRef FunctionTy);
802 * Obtain the Type this function Type returns.
804 LLVMTypeRef LLVMGetReturnType(LLVMTypeRef FunctionTy);
807 * Obtain the number of parameters this function accepts.
809 unsigned LLVMCountParamTypes(LLVMTypeRef FunctionTy);
812 * Obtain the types of a function's parameters.
814 * The Dest parameter should point to a pre-allocated array of
815 * LLVMTypeRef at least LLVMCountParamTypes() large. On return, the
816 * first LLVMCountParamTypes() entries in the array will be populated
817 * with LLVMTypeRef instances.
819 * @param FunctionTy The function type to operate on.
820 * @param Dest Memory address of an array to be filled with result.
822 void LLVMGetParamTypes(LLVMTypeRef FunctionTy, LLVMTypeRef *Dest);
829 * @defgroup LLVMCCoreTypeStruct Structure Types
831 * These functions relate to LLVMTypeRef instances.
833 * @see llvm::StructType
839 * Create a new structure type in a context.
841 * A structure is specified by a list of inner elements/types and
842 * whether these can be packed together.
844 * @see llvm::StructType::create()
846 LLVMTypeRef LLVMStructTypeInContext(LLVMContextRef C, LLVMTypeRef *ElementTypes,
847 unsigned ElementCount, LLVMBool Packed);
850 * Create a new structure type in the global context.
852 * @see llvm::StructType::create()
854 LLVMTypeRef LLVMStructType(LLVMTypeRef *ElementTypes, unsigned ElementCount,
858 * Create an empty structure in a context having a specified name.
860 * @see llvm::StructType::create()
862 LLVMTypeRef LLVMStructCreateNamed(LLVMContextRef C, const char *Name);
865 * Obtain the name of a structure.
867 * @see llvm::StructType::getName()
869 const char *LLVMGetStructName(LLVMTypeRef Ty);
872 * Set the contents of a structure type.
874 * @see llvm::StructType::setBody()
876 void LLVMStructSetBody(LLVMTypeRef StructTy, LLVMTypeRef *ElementTypes,
877 unsigned ElementCount, LLVMBool Packed);
880 * Get the number of elements defined inside the structure.
882 * @see llvm::StructType::getNumElements()
884 unsigned LLVMCountStructElementTypes(LLVMTypeRef StructTy);
887 * Get the elements within a structure.
889 * The function is passed the address of a pre-allocated array of
890 * LLVMTypeRef at least LLVMCountStructElementTypes() long. After
891 * invocation, this array will be populated with the structure's
892 * elements. The objects in the destination array will have a lifetime
893 * of the structure type itself, which is the lifetime of the context it
896 void LLVMGetStructElementTypes(LLVMTypeRef StructTy, LLVMTypeRef *Dest);
899 * Determine whether a structure is packed.
901 * @see llvm::StructType::isPacked()
903 LLVMBool LLVMIsPackedStruct(LLVMTypeRef StructTy);
906 * Determine whether a structure is opaque.
908 * @see llvm::StructType::isOpaque()
910 LLVMBool LLVMIsOpaqueStruct(LLVMTypeRef StructTy);
918 * @defgroup LLVMCCoreTypeSequential Sequential Types
920 * Sequential types represents "arrays" of types. This is a super class
921 * for array, vector, and pointer types.
927 * Obtain the type of elements within a sequential type.
929 * This works on array, vector, and pointer types.
931 * @see llvm::SequentialType::getElementType()
933 LLVMTypeRef LLVMGetElementType(LLVMTypeRef Ty);
936 * Create a fixed size array type that refers to a specific type.
938 * The created type will exist in the context that its element type
941 * @see llvm::ArrayType::get()
943 LLVMTypeRef LLVMArrayType(LLVMTypeRef ElementType, unsigned ElementCount);
946 * Obtain the length of an array type.
948 * This only works on types that represent arrays.
950 * @see llvm::ArrayType::getNumElements()
952 unsigned LLVMGetArrayLength(LLVMTypeRef ArrayTy);
955 * Create a pointer type that points to a defined type.
957 * The created type will exist in the context that its pointee type
960 * @see llvm::PointerType::get()
962 LLVMTypeRef LLVMPointerType(LLVMTypeRef ElementType, unsigned AddressSpace);
965 * Obtain the address space of a pointer type.
967 * This only works on types that represent pointers.
969 * @see llvm::PointerType::getAddressSpace()
971 unsigned LLVMGetPointerAddressSpace(LLVMTypeRef PointerTy);
974 * Create a vector type that contains a defined type and has a specific
975 * number of elements.
977 * The created type will exist in the context thats its element type
980 * @see llvm::VectorType::get()
982 LLVMTypeRef LLVMVectorType(LLVMTypeRef ElementType, unsigned ElementCount);
985 * Obtain the number of elements in a vector type.
987 * This only works on types that represent vectors.
989 * @see llvm::VectorType::getNumElements()
991 unsigned LLVMGetVectorSize(LLVMTypeRef VectorTy);
998 * @defgroup LLVMCCoreTypeOther Other Types
1004 * Create a void type in a context.
1006 LLVMTypeRef LLVMVoidTypeInContext(LLVMContextRef C);
1009 * Create a label type in a context.
1011 LLVMTypeRef LLVMLabelTypeInContext(LLVMContextRef C);
1014 * Create a X86 MMX type in a context.
1016 LLVMTypeRef LLVMX86MMXTypeInContext(LLVMContextRef C);
1019 * These are similar to the above functions except they operate on the
1022 LLVMTypeRef LLVMVoidType(void);
1023 LLVMTypeRef LLVMLabelType(void);
1024 LLVMTypeRef LLVMX86MMXType(void);
1035 * @defgroup LLVMCCoreValues Values
1037 * The bulk of LLVM's object model consists of values, which comprise a very
1038 * rich type hierarchy.
1040 * LLVMValueRef essentially represents llvm::Value. There is a rich
1041 * hierarchy of classes within this type. Depending on the instance
1042 * obtained, not all APIs are available.
1044 * Callers can determine the type of a LLVMValueRef by calling the
1045 * LLVMIsA* family of functions (e.g. LLVMIsAArgument()). These
1046 * functions are defined by a macro, so it isn't obvious which are
1047 * available by looking at the Doxygen source code. Instead, look at the
1048 * source definition of LLVM_FOR_EACH_VALUE_SUBCLASS and note the list
1049 * of value names given. These value names also correspond to classes in
1050 * the llvm::Value hierarchy.
1055 #define LLVM_FOR_EACH_VALUE_SUBCLASS(macro) \
1063 macro(BlockAddress) \
1064 macro(ConstantAggregateZero) \
1065 macro(ConstantArray) \
1066 macro(ConstantExpr) \
1068 macro(ConstantInt) \
1069 macro(ConstantPointerNull) \
1070 macro(ConstantStruct) \
1071 macro(ConstantVector) \
1072 macro(GlobalValue) \
1074 macro(GlobalAlias) \
1075 macro(GlobalVariable) \
1077 macro(Instruction) \
1078 macro(BinaryOperator) \
1080 macro(IntrinsicInst) \
1081 macro(DbgInfoIntrinsic) \
1082 macro(DbgDeclareInst) \
1083 macro(MemIntrinsic) \
1085 macro(MemMoveInst) \
1090 macro(ExtractElementInst) \
1091 macro(GetElementPtrInst) \
1092 macro(InsertElementInst) \
1093 macro(InsertValueInst) \
1094 macro(LandingPadInst) \
1097 macro(ShuffleVectorInst) \
1099 macro(TerminatorInst) \
1101 macro(IndirectBrInst) \
1105 macro(UnreachableInst) \
1107 macro(UnaryInstruction) \
1110 macro(BitCastInst) \
1114 macro(FPTruncInst) \
1115 macro(IntToPtrInst) \
1116 macro(PtrToIntInst) \
1122 macro(ExtractValueInst) \
1127 * @defgroup LLVMCCoreValueGeneral General APIs
1129 * Functions in this section work on all LLVMValueRef instances,
1130 * regardless of their sub-type. They correspond to functions available
1137 * Obtain the type of a value.
1139 * @see llvm::Value::getType()
1141 LLVMTypeRef LLVMTypeOf(LLVMValueRef Val);
1144 * Obtain the string name of a value.
1146 * @see llvm::Value::getName()
1148 const char *LLVMGetValueName(LLVMValueRef Val);
1151 * Set the string name of a value.
1153 * @see llvm::Value::setName()
1155 void LLVMSetValueName(LLVMValueRef Val, const char *Name);
1158 * Dump a representation of a value to stderr.
1160 * @see llvm::Value::dump()
1162 void LLVMDumpValue(LLVMValueRef Val);
1165 * Replace all uses of a value with another one.
1167 * @see llvm::Value::replaceAllUsesWith()
1169 void LLVMReplaceAllUsesWith(LLVMValueRef OldVal, LLVMValueRef NewVal);
1172 * Determine whether the specified constant instance is constant.
1174 LLVMBool LLVMIsConstant(LLVMValueRef Val);
1177 * Determine whether a value instance is undefined.
1179 LLVMBool LLVMIsUndef(LLVMValueRef Val);
1182 * Convert value instances between types.
1184 * Internally, a LLVMValueRef is "pinned" to a specific type. This
1185 * series of functions allows you to cast an instance to a specific
1188 * If the cast is not valid for the specified type, NULL is returned.
1190 * @see llvm::dyn_cast_or_null<>
1192 #define LLVM_DECLARE_VALUE_CAST(name) \
1193 LLVMValueRef LLVMIsA##name(LLVMValueRef Val);
1194 LLVM_FOR_EACH_VALUE_SUBCLASS(LLVM_DECLARE_VALUE_CAST)
1201 * @defgroup LLVMCCoreValueUses Usage
1203 * This module defines functions that allow you to inspect the uses of a
1206 * It is possible to obtain a LLVMUseRef for any LLVMValueRef instance.
1207 * Each LLVMUseRef (which corresponds to a llvm::Use instance) holds a
1208 * llvm::User and llvm::Value.
1214 * Obtain the first use of a value.
1216 * Uses are obtained in an iterator fashion. First, call this function
1217 * to obtain a reference to the first use. Then, call LLVMGetNextUse()
1218 * on that instance and all subsequently obtained instances until
1219 * LLVMGetNextUse() returns NULL.
1221 * @see llvm::Value::use_begin()
1223 LLVMUseRef LLVMGetFirstUse(LLVMValueRef Val);
1226 * Obtain the next use of a value.
1228 * This effectively advances the iterator. It returns NULL if you are on
1229 * the final use and no more are available.
1231 LLVMUseRef LLVMGetNextUse(LLVMUseRef U);
1234 * Obtain the user value for a user.
1236 * The returned value corresponds to a llvm::User type.
1238 * @see llvm::Use::getUser()
1240 LLVMValueRef LLVMGetUser(LLVMUseRef U);
1243 * Obtain the value this use corresponds to.
1245 * @see llvm::Use::get().
1247 LLVMValueRef LLVMGetUsedValue(LLVMUseRef U);
1254 * @defgroup LLVMCCoreValueUser User value
1256 * Function in this group pertain to LLVMValueRef instances that descent
1257 * from llvm::User. This includes constants, instructions, and
1264 * Obtain an operand at a specific index in a llvm::User value.
1266 * @see llvm::User::getOperand()
1268 LLVMValueRef LLVMGetOperand(LLVMValueRef Val, unsigned Index);
1271 * Set an operand at a specific index in a llvm::User value.
1273 * @see llvm::User::setOperand()
1275 void LLVMSetOperand(LLVMValueRef User, unsigned Index, LLVMValueRef Val);
1278 * Obtain the number of operands in a llvm::User value.
1280 * @see llvm::User::getNumOperands()
1282 int LLVMGetNumOperands(LLVMValueRef Val);
1289 * @defgroup LLVMCCoreValueConstant Constants
1291 * This section contains APIs for interacting with LLVMValueRef that
1292 * correspond to llvm::Constant instances.
1294 * These functions will work for any LLVMValueRef in the llvm::Constant
1301 * Obtain a constant value referring to the null instance of a type.
1303 * @see llvm::Constant::getNullValue()
1305 LLVMValueRef LLVMConstNull(LLVMTypeRef Ty); /* all zeroes */
1308 * Obtain a constant value referring to the instance of a type
1309 * consisting of all ones.
1311 * This is only valid for integer types.
1313 * @see llvm::Constant::getAllOnesValue()
1315 LLVMValueRef LLVMConstAllOnes(LLVMTypeRef Ty);
1318 * Obtain a constant value referring to an undefined value of a type.
1320 * @see llvm::UndefValue::get()
1322 LLVMValueRef LLVMGetUndef(LLVMTypeRef Ty);
1325 * Determine whether a value instance is null.
1327 * @see llvm::Constant::isNullValue()
1329 LLVMBool LLVMIsNull(LLVMValueRef Val);
1332 * Obtain a constant that is a constant pointer pointing to NULL for a
1335 LLVMValueRef LLVMConstPointerNull(LLVMTypeRef Ty);
1338 * @defgroup LLVMCCoreValueConstantScalar Scalar constants
1340 * Functions in this group model LLVMValueRef instances that correspond
1341 * to constants referring to scalar types.
1343 * For integer types, the LLVMTypeRef parameter should correspond to a
1344 * llvm::IntegerType instance and the returned LLVMValueRef will
1345 * correspond to a llvm::ConstantInt.
1347 * For floating point types, the LLVMTypeRef returned corresponds to a
1354 * Obtain a constant value for an integer type.
1356 * The returned value corresponds to a llvm::ConstantInt.
1358 * @see llvm::ConstantInt::get()
1360 * @param IntTy Integer type to obtain value of.
1361 * @param N The value the returned instance should refer to.
1362 * @param SignExtend Whether to sign extend the produced value.
1364 LLVMValueRef LLVMConstInt(LLVMTypeRef IntTy, unsigned long long N,
1365 LLVMBool SignExtend);
1368 * Obtain a constant value for an integer of arbitrary precision.
1370 * @see llvm::ConstantInt::get()
1372 LLVMValueRef LLVMConstIntOfArbitraryPrecision(LLVMTypeRef IntTy,
1374 const uint64_t Words[]);
1377 * Obtain a constant value for an integer parsed from a string.
1379 * A similar API, LLVMConstIntOfStringAndSize is also available. If the
1380 * string's length is available, it is preferred to call that function
1383 * @see llvm::ConstantInt::get()
1385 LLVMValueRef LLVMConstIntOfString(LLVMTypeRef IntTy, const char *Text,
1389 * Obtain a constant value for an integer parsed from a string with
1392 * @see llvm::ConstantInt::get()
1394 LLVMValueRef LLVMConstIntOfStringAndSize(LLVMTypeRef IntTy, const char *Text,
1395 unsigned SLen, uint8_t Radix);
1398 * Obtain a constant value referring to a double floating point value.
1400 LLVMValueRef LLVMConstReal(LLVMTypeRef RealTy, double N);
1403 * Obtain a constant for a floating point value parsed from a string.
1405 * A similar API, LLVMConstRealOfStringAndSize is also available. It
1406 * should be used if the input string's length is known.
1408 LLVMValueRef LLVMConstRealOfString(LLVMTypeRef RealTy, const char *Text);
1411 * Obtain a constant for a floating point value parsed from a string.
1413 LLVMValueRef LLVMConstRealOfStringAndSize(LLVMTypeRef RealTy, const char *Text,
1417 * Obtain the zero extended value for an integer constant value.
1419 * @see llvm::ConstantInt::getZExtValue()
1421 unsigned long long LLVMConstIntGetZExtValue(LLVMValueRef ConstantVal);
1424 * Obtain the sign extended value for an integer constant value.
1426 * @see llvm::ConstantInt::getSExtValue()
1428 long long LLVMConstIntGetSExtValue(LLVMValueRef ConstantVal);
1435 * @defgroup LLVMCCoreValueConstantComposite Composite Constants
1437 * Functions in this group operate on composite constants.
1443 * Create a ConstantDataSequential and initialize it with a string.
1445 * @see llvm::ConstantDataArray::getString()
1447 LLVMValueRef LLVMConstStringInContext(LLVMContextRef C, const char *Str,
1448 unsigned Length, LLVMBool DontNullTerminate);
1451 * Create a ConstantDataSequential with string content in the global context.
1453 * This is the same as LLVMConstStringInContext except it operates on the
1456 * @see LLVMConstStringInContext()
1457 * @see llvm::ConstantDataArray::getString()
1459 LLVMValueRef LLVMConstString(const char *Str, unsigned Length,
1460 LLVMBool DontNullTerminate);
1463 * Create an anonymous ConstantStruct with the specified values.
1465 * @see llvm::ConstantStruct::getAnon()
1467 LLVMValueRef LLVMConstStructInContext(LLVMContextRef C,
1468 LLVMValueRef *ConstantVals,
1469 unsigned Count, LLVMBool Packed);
1472 * Create a ConstantStruct in the global Context.
1474 * This is the same as LLVMConstStructInContext except it operates on the
1477 * @see LLVMConstStructInContext()
1479 LLVMValueRef LLVMConstStruct(LLVMValueRef *ConstantVals, unsigned Count,
1483 * Create a ConstantArray from values.
1485 * @see llvm::ConstantArray::get()
1487 LLVMValueRef LLVMConstArray(LLVMTypeRef ElementTy,
1488 LLVMValueRef *ConstantVals, unsigned Length);
1491 * Create a non-anonymous ConstantStruct from values.
1493 * @see llvm::ConstantStruct::get()
1495 LLVMValueRef LLVMConstNamedStruct(LLVMTypeRef StructTy,
1496 LLVMValueRef *ConstantVals,
1500 * Create a ConstantVector from values.
1502 * @see llvm::ConstantVector::get()
1504 LLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals, unsigned Size);
1511 * @defgroup LLVMCCoreValueConstantExpressions Constant Expressions
1513 * Functions in this group correspond to APIs on llvm::ConstantExpr.
1515 * @see llvm::ConstantExpr.
1519 LLVMOpcode LLVMGetConstOpcode(LLVMValueRef ConstantVal);
1520 LLVMValueRef LLVMAlignOf(LLVMTypeRef Ty);
1521 LLVMValueRef LLVMSizeOf(LLVMTypeRef Ty);
1522 LLVMValueRef LLVMConstNeg(LLVMValueRef ConstantVal);
1523 LLVMValueRef LLVMConstNSWNeg(LLVMValueRef ConstantVal);
1524 LLVMValueRef LLVMConstNUWNeg(LLVMValueRef ConstantVal);
1525 LLVMValueRef LLVMConstFNeg(LLVMValueRef ConstantVal);
1526 LLVMValueRef LLVMConstNot(LLVMValueRef ConstantVal);
1527 LLVMValueRef LLVMConstAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1528 LLVMValueRef LLVMConstNSWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1529 LLVMValueRef LLVMConstNUWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1530 LLVMValueRef LLVMConstFAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1531 LLVMValueRef LLVMConstSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1532 LLVMValueRef LLVMConstNSWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1533 LLVMValueRef LLVMConstNUWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1534 LLVMValueRef LLVMConstFSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1535 LLVMValueRef LLVMConstMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1536 LLVMValueRef LLVMConstNSWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1537 LLVMValueRef LLVMConstNUWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1538 LLVMValueRef LLVMConstFMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1539 LLVMValueRef LLVMConstUDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1540 LLVMValueRef LLVMConstSDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1541 LLVMValueRef LLVMConstExactSDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1542 LLVMValueRef LLVMConstFDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1543 LLVMValueRef LLVMConstURem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1544 LLVMValueRef LLVMConstSRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1545 LLVMValueRef LLVMConstFRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1546 LLVMValueRef LLVMConstAnd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1547 LLVMValueRef LLVMConstOr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1548 LLVMValueRef LLVMConstXor(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1549 LLVMValueRef LLVMConstICmp(LLVMIntPredicate Predicate,
1550 LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1551 LLVMValueRef LLVMConstFCmp(LLVMRealPredicate Predicate,
1552 LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1553 LLVMValueRef LLVMConstShl(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1554 LLVMValueRef LLVMConstLShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1555 LLVMValueRef LLVMConstAShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1556 LLVMValueRef LLVMConstGEP(LLVMValueRef ConstantVal,
1557 LLVMValueRef *ConstantIndices, unsigned NumIndices);
1558 LLVMValueRef LLVMConstInBoundsGEP(LLVMValueRef ConstantVal,
1559 LLVMValueRef *ConstantIndices,
1560 unsigned NumIndices);
1561 LLVMValueRef LLVMConstTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1562 LLVMValueRef LLVMConstSExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1563 LLVMValueRef LLVMConstZExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1564 LLVMValueRef LLVMConstFPTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1565 LLVMValueRef LLVMConstFPExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1566 LLVMValueRef LLVMConstUIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1567 LLVMValueRef LLVMConstSIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1568 LLVMValueRef LLVMConstFPToUI(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1569 LLVMValueRef LLVMConstFPToSI(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1570 LLVMValueRef LLVMConstPtrToInt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1571 LLVMValueRef LLVMConstIntToPtr(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1572 LLVMValueRef LLVMConstBitCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1573 LLVMValueRef LLVMConstZExtOrBitCast(LLVMValueRef ConstantVal,
1574 LLVMTypeRef ToType);
1575 LLVMValueRef LLVMConstSExtOrBitCast(LLVMValueRef ConstantVal,
1576 LLVMTypeRef ToType);
1577 LLVMValueRef LLVMConstTruncOrBitCast(LLVMValueRef ConstantVal,
1578 LLVMTypeRef ToType);
1579 LLVMValueRef LLVMConstPointerCast(LLVMValueRef ConstantVal,
1580 LLVMTypeRef ToType);
1581 LLVMValueRef LLVMConstIntCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType,
1583 LLVMValueRef LLVMConstFPCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1584 LLVMValueRef LLVMConstSelect(LLVMValueRef ConstantCondition,
1585 LLVMValueRef ConstantIfTrue,
1586 LLVMValueRef ConstantIfFalse);
1587 LLVMValueRef LLVMConstExtractElement(LLVMValueRef VectorConstant,
1588 LLVMValueRef IndexConstant);
1589 LLVMValueRef LLVMConstInsertElement(LLVMValueRef VectorConstant,
1590 LLVMValueRef ElementValueConstant,
1591 LLVMValueRef IndexConstant);
1592 LLVMValueRef LLVMConstShuffleVector(LLVMValueRef VectorAConstant,
1593 LLVMValueRef VectorBConstant,
1594 LLVMValueRef MaskConstant);
1595 LLVMValueRef LLVMConstExtractValue(LLVMValueRef AggConstant, unsigned *IdxList,
1597 LLVMValueRef LLVMConstInsertValue(LLVMValueRef AggConstant,
1598 LLVMValueRef ElementValueConstant,
1599 unsigned *IdxList, unsigned NumIdx);
1600 LLVMValueRef LLVMConstInlineAsm(LLVMTypeRef Ty,
1601 const char *AsmString, const char *Constraints,
1602 LLVMBool HasSideEffects, LLVMBool IsAlignStack);
1603 LLVMValueRef LLVMBlockAddress(LLVMValueRef F, LLVMBasicBlockRef BB);
1610 * @defgroup LLVMCCoreValueConstantGlobals Global Values
1612 * This group contains functions that operate on global values. Functions in
1613 * this group relate to functions in the llvm::GlobalValue class tree.
1615 * @see llvm::GlobalValue
1620 LLVMModuleRef LLVMGetGlobalParent(LLVMValueRef Global);
1621 LLVMBool LLVMIsDeclaration(LLVMValueRef Global);
1622 LLVMLinkage LLVMGetLinkage(LLVMValueRef Global);
1623 void LLVMSetLinkage(LLVMValueRef Global, LLVMLinkage Linkage);
1624 const char *LLVMGetSection(LLVMValueRef Global);
1625 void LLVMSetSection(LLVMValueRef Global, const char *Section);
1626 LLVMVisibility LLVMGetVisibility(LLVMValueRef Global);
1627 void LLVMSetVisibility(LLVMValueRef Global, LLVMVisibility Viz);
1628 unsigned LLVMGetAlignment(LLVMValueRef Global);
1629 void LLVMSetAlignment(LLVMValueRef Global, unsigned Bytes);
1632 * @defgroup LLVMCoreValueConstantGlobalVariable Global Variables
1634 * This group contains functions that operate on global variable values.
1636 * @see llvm::GlobalVariable
1640 LLVMValueRef LLVMAddGlobal(LLVMModuleRef M, LLVMTypeRef Ty, const char *Name);
1641 LLVMValueRef LLVMAddGlobalInAddressSpace(LLVMModuleRef M, LLVMTypeRef Ty,
1643 unsigned AddressSpace);
1644 LLVMValueRef LLVMGetNamedGlobal(LLVMModuleRef M, const char *Name);
1645 LLVMValueRef LLVMGetFirstGlobal(LLVMModuleRef M);
1646 LLVMValueRef LLVMGetLastGlobal(LLVMModuleRef M);
1647 LLVMValueRef LLVMGetNextGlobal(LLVMValueRef GlobalVar);
1648 LLVMValueRef LLVMGetPreviousGlobal(LLVMValueRef GlobalVar);
1649 void LLVMDeleteGlobal(LLVMValueRef GlobalVar);
1650 LLVMValueRef LLVMGetInitializer(LLVMValueRef GlobalVar);
1651 void LLVMSetInitializer(LLVMValueRef GlobalVar, LLVMValueRef ConstantVal);
1652 LLVMBool LLVMIsThreadLocal(LLVMValueRef GlobalVar);
1653 void LLVMSetThreadLocal(LLVMValueRef GlobalVar, LLVMBool IsThreadLocal);
1654 LLVMBool LLVMIsGlobalConstant(LLVMValueRef GlobalVar);
1655 void LLVMSetGlobalConstant(LLVMValueRef GlobalVar, LLVMBool IsConstant);
1656 LLVMThreadLocalMode LLVMGetThreadLocalMode(LLVMValueRef GlobalVar);
1657 void LLVMSetThreadLocalMode(LLVMValueRef GlobalVar, LLVMThreadLocalMode Mode);
1658 LLVMBool LLVMIsExternallyInitialized(LLVMValueRef GlobalVar);
1659 void LLVMSetExternallyInitialized(LLVMValueRef GlobalVar, LLVMBool IsExtInit);
1666 * @defgroup LLVMCoreValueConstantGlobalAlias Global Aliases
1668 * This group contains function that operate on global alias values.
1670 * @see llvm::GlobalAlias
1674 LLVMValueRef LLVMAddAlias(LLVMModuleRef M, LLVMTypeRef Ty, LLVMValueRef Aliasee,
1682 * @defgroup LLVMCCoreValueFunction Function values
1684 * Functions in this group operate on LLVMValueRef instances that
1685 * correspond to llvm::Function instances.
1687 * @see llvm::Function
1693 * Remove a function from its containing module and deletes it.
1695 * @see llvm::Function::eraseFromParent()
1697 void LLVMDeleteFunction(LLVMValueRef Fn);
1700 * Obtain the ID number from a function instance.
1702 * @see llvm::Function::getIntrinsicID()
1704 unsigned LLVMGetIntrinsicID(LLVMValueRef Fn);
1707 * Obtain the calling function of a function.
1709 * The returned value corresponds to the LLVMCallConv enumeration.
1711 * @see llvm::Function::getCallingConv()
1713 unsigned LLVMGetFunctionCallConv(LLVMValueRef Fn);
1716 * Set the calling convention of a function.
1718 * @see llvm::Function::setCallingConv()
1720 * @param Fn Function to operate on
1721 * @param CC LLVMCallConv to set calling convention to
1723 void LLVMSetFunctionCallConv(LLVMValueRef Fn, unsigned CC);
1726 * Obtain the name of the garbage collector to use during code
1729 * @see llvm::Function::getGC()
1731 const char *LLVMGetGC(LLVMValueRef Fn);
1734 * Define the garbage collector to use during code generation.
1736 * @see llvm::Function::setGC()
1738 void LLVMSetGC(LLVMValueRef Fn, const char *Name);
1741 * Add an attribute to a function.
1743 * @see llvm::Function::addAttribute()
1745 void LLVMAddFunctionAttr(LLVMValueRef Fn, LLVMAttribute PA);
1748 * Add a target-dependent attribute to a fuction
1749 * @see llvm::AttrBuilder::addAttribute()
1751 void LLVMAddTargetDependentFunctionAttr(LLVMValueRef Fn, const char *A,
1755 * Obtain an attribute from a function.
1757 * @see llvm::Function::getAttributes()
1759 LLVMAttribute LLVMGetFunctionAttr(LLVMValueRef Fn);
1762 * Remove an attribute from a function.
1764 void LLVMRemoveFunctionAttr(LLVMValueRef Fn, LLVMAttribute PA);
1767 * @defgroup LLVMCCoreValueFunctionParameters Function Parameters
1769 * Functions in this group relate to arguments/parameters on functions.
1771 * Functions in this group expect LLVMValueRef instances that correspond
1772 * to llvm::Function instances.
1778 * Obtain the number of parameters in a function.
1780 * @see llvm::Function::arg_size()
1782 unsigned LLVMCountParams(LLVMValueRef Fn);
1785 * Obtain the parameters in a function.
1787 * The takes a pointer to a pre-allocated array of LLVMValueRef that is
1788 * at least LLVMCountParams() long. This array will be filled with
1789 * LLVMValueRef instances which correspond to the parameters the
1790 * function receives. Each LLVMValueRef corresponds to a llvm::Argument
1793 * @see llvm::Function::arg_begin()
1795 void LLVMGetParams(LLVMValueRef Fn, LLVMValueRef *Params);
1798 * Obtain the parameter at the specified index.
1800 * Parameters are indexed from 0.
1802 * @see llvm::Function::arg_begin()
1804 LLVMValueRef LLVMGetParam(LLVMValueRef Fn, unsigned Index);
1807 * Obtain the function to which this argument belongs.
1809 * Unlike other functions in this group, this one takes a LLVMValueRef
1810 * that corresponds to a llvm::Attribute.
1812 * The returned LLVMValueRef is the llvm::Function to which this
1815 LLVMValueRef LLVMGetParamParent(LLVMValueRef Inst);
1818 * Obtain the first parameter to a function.
1820 * @see llvm::Function::arg_begin()
1822 LLVMValueRef LLVMGetFirstParam(LLVMValueRef Fn);
1825 * Obtain the last parameter to a function.
1827 * @see llvm::Function::arg_end()
1829 LLVMValueRef LLVMGetLastParam(LLVMValueRef Fn);
1832 * Obtain the next parameter to a function.
1834 * This takes a LLVMValueRef obtained from LLVMGetFirstParam() (which is
1835 * actually a wrapped iterator) and obtains the next parameter from the
1836 * underlying iterator.
1838 LLVMValueRef LLVMGetNextParam(LLVMValueRef Arg);
1841 * Obtain the previous parameter to a function.
1843 * This is the opposite of LLVMGetNextParam().
1845 LLVMValueRef LLVMGetPreviousParam(LLVMValueRef Arg);
1848 * Add an attribute to a function argument.
1850 * @see llvm::Argument::addAttr()
1852 void LLVMAddAttribute(LLVMValueRef Arg, LLVMAttribute PA);
1855 * Remove an attribute from a function argument.
1857 * @see llvm::Argument::removeAttr()
1859 void LLVMRemoveAttribute(LLVMValueRef Arg, LLVMAttribute PA);
1862 * Get an attribute from a function argument.
1864 LLVMAttribute LLVMGetAttribute(LLVMValueRef Arg);
1867 * Set the alignment for a function parameter.
1869 * @see llvm::Argument::addAttr()
1870 * @see llvm::AttrBuilder::addAlignmentAttr()
1872 void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned align);
1891 * @defgroup LLVMCCoreValueMetadata Metadata
1897 * Obtain a MDString value from a context.
1899 * The returned instance corresponds to the llvm::MDString class.
1901 * The instance is specified by string data of a specified length. The
1902 * string content is copied, so the backing memory can be freed after
1903 * this function returns.
1905 LLVMValueRef LLVMMDStringInContext(LLVMContextRef C, const char *Str,
1909 * Obtain a MDString value from the global context.
1911 LLVMValueRef LLVMMDString(const char *Str, unsigned SLen);
1914 * Obtain a MDNode value from a context.
1916 * The returned value corresponds to the llvm::MDNode class.
1918 LLVMValueRef LLVMMDNodeInContext(LLVMContextRef C, LLVMValueRef *Vals,
1922 * Obtain a MDNode value from the global context.
1924 LLVMValueRef LLVMMDNode(LLVMValueRef *Vals, unsigned Count);
1927 * Obtain the underlying string from a MDString value.
1929 * @param V Instance to obtain string from.
1930 * @param Len Memory address which will hold length of returned string.
1931 * @return String data in MDString.
1933 const char *LLVMGetMDString(LLVMValueRef V, unsigned* Len);
1936 * Obtain the number of operands from an MDNode value.
1938 * @param V MDNode to get number of operands from.
1939 * @return Number of operands of the MDNode.
1941 unsigned LLVMGetMDNodeNumOperands(LLVMValueRef V);
1944 * Obtain the given MDNode's operands.
1946 * The passed LLVMValueRef pointer should point to enough memory to hold all of
1947 * the operands of the given MDNode (see LLVMGetMDNodeNumOperands) as
1948 * LLVMValueRefs. This memory will be populated with the LLVMValueRefs of the
1949 * MDNode's operands.
1951 * @param V MDNode to get the operands from.
1952 * @param Dest Destination array for operands.
1954 void LLVMGetMDNodeOperands(LLVMValueRef V, LLVMValueRef *Dest);
1961 * @defgroup LLVMCCoreValueBasicBlock Basic Block
1963 * A basic block represents a single entry single exit section of code.
1964 * Basic blocks contain a list of instructions which form the body of
1967 * Basic blocks belong to functions. They have the type of label.
1969 * Basic blocks are themselves values. However, the C API models them as
1970 * LLVMBasicBlockRef.
1972 * @see llvm::BasicBlock
1978 * Convert a basic block instance to a value type.
1980 LLVMValueRef LLVMBasicBlockAsValue(LLVMBasicBlockRef BB);
1983 * Determine whether a LLVMValueRef is itself a basic block.
1985 LLVMBool LLVMValueIsBasicBlock(LLVMValueRef Val);
1988 * Convert a LLVMValueRef to a LLVMBasicBlockRef instance.
1990 LLVMBasicBlockRef LLVMValueAsBasicBlock(LLVMValueRef Val);
1993 * Obtain the function to which a basic block belongs.
1995 * @see llvm::BasicBlock::getParent()
1997 LLVMValueRef LLVMGetBasicBlockParent(LLVMBasicBlockRef BB);
2000 * Obtain the terminator instruction for a basic block.
2002 * If the basic block does not have a terminator (it is not well-formed
2003 * if it doesn't), then NULL is returned.
2005 * The returned LLVMValueRef corresponds to a llvm::TerminatorInst.
2007 * @see llvm::BasicBlock::getTerminator()
2009 LLVMValueRef LLVMGetBasicBlockTerminator(LLVMBasicBlockRef BB);
2012 * Obtain the number of basic blocks in a function.
2014 * @param Fn Function value to operate on.
2016 unsigned LLVMCountBasicBlocks(LLVMValueRef Fn);
2019 * Obtain all of the basic blocks in a function.
2021 * This operates on a function value. The BasicBlocks parameter is a
2022 * pointer to a pre-allocated array of LLVMBasicBlockRef of at least
2023 * LLVMCountBasicBlocks() in length. This array is populated with
2024 * LLVMBasicBlockRef instances.
2026 void LLVMGetBasicBlocks(LLVMValueRef Fn, LLVMBasicBlockRef *BasicBlocks);
2029 * Obtain the first basic block in a function.
2031 * The returned basic block can be used as an iterator. You will likely
2032 * eventually call into LLVMGetNextBasicBlock() with it.
2034 * @see llvm::Function::begin()
2036 LLVMBasicBlockRef LLVMGetFirstBasicBlock(LLVMValueRef Fn);
2039 * Obtain the last basic block in a function.
2041 * @see llvm::Function::end()
2043 LLVMBasicBlockRef LLVMGetLastBasicBlock(LLVMValueRef Fn);
2046 * Advance a basic block iterator.
2048 LLVMBasicBlockRef LLVMGetNextBasicBlock(LLVMBasicBlockRef BB);
2051 * Go backwards in a basic block iterator.
2053 LLVMBasicBlockRef LLVMGetPreviousBasicBlock(LLVMBasicBlockRef BB);
2056 * Obtain the basic block that corresponds to the entry point of a
2059 * @see llvm::Function::getEntryBlock()
2061 LLVMBasicBlockRef LLVMGetEntryBasicBlock(LLVMValueRef Fn);
2064 * Append a basic block to the end of a function.
2066 * @see llvm::BasicBlock::Create()
2068 LLVMBasicBlockRef LLVMAppendBasicBlockInContext(LLVMContextRef C,
2073 * Append a basic block to the end of a function using the global
2076 * @see llvm::BasicBlock::Create()
2078 LLVMBasicBlockRef LLVMAppendBasicBlock(LLVMValueRef Fn, const char *Name);
2081 * Insert a basic block in a function before another basic block.
2083 * The function to add to is determined by the function of the
2084 * passed basic block.
2086 * @see llvm::BasicBlock::Create()
2088 LLVMBasicBlockRef LLVMInsertBasicBlockInContext(LLVMContextRef C,
2089 LLVMBasicBlockRef BB,
2093 * Insert a basic block in a function using the global context.
2095 * @see llvm::BasicBlock::Create()
2097 LLVMBasicBlockRef LLVMInsertBasicBlock(LLVMBasicBlockRef InsertBeforeBB,
2101 * Remove a basic block from a function and delete it.
2103 * This deletes the basic block from its containing function and deletes
2104 * the basic block itself.
2106 * @see llvm::BasicBlock::eraseFromParent()
2108 void LLVMDeleteBasicBlock(LLVMBasicBlockRef BB);
2111 * Remove a basic block from a function.
2113 * This deletes the basic block from its containing function but keep
2114 * the basic block alive.
2116 * @see llvm::BasicBlock::removeFromParent()
2118 void LLVMRemoveBasicBlockFromParent(LLVMBasicBlockRef BB);
2121 * Move a basic block to before another one.
2123 * @see llvm::BasicBlock::moveBefore()
2125 void LLVMMoveBasicBlockBefore(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos);
2128 * Move a basic block to after another one.
2130 * @see llvm::BasicBlock::moveAfter()
2132 void LLVMMoveBasicBlockAfter(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos);
2135 * Obtain the first instruction in a basic block.
2137 * The returned LLVMValueRef corresponds to a llvm::Instruction
2140 LLVMValueRef LLVMGetFirstInstruction(LLVMBasicBlockRef BB);
2143 * Obtain the last instruction in a basic block.
2145 * The returned LLVMValueRef corresponds to a LLVM:Instruction.
2147 LLVMValueRef LLVMGetLastInstruction(LLVMBasicBlockRef BB);
2154 * @defgroup LLVMCCoreValueInstruction Instructions
2156 * Functions in this group relate to the inspection and manipulation of
2157 * individual instructions.
2159 * In the C++ API, an instruction is modeled by llvm::Instruction. This
2160 * class has a large number of descendents. llvm::Instruction is a
2161 * llvm::Value and in the C API, instructions are modeled by
2164 * This group also contains sub-groups which operate on specific
2165 * llvm::Instruction types, e.g. llvm::CallInst.
2171 * Determine whether an instruction has any metadata attached.
2173 int LLVMHasMetadata(LLVMValueRef Val);
2176 * Return metadata associated with an instruction value.
2178 LLVMValueRef LLVMGetMetadata(LLVMValueRef Val, unsigned KindID);
2181 * Set metadata associated with an instruction value.
2183 void LLVMSetMetadata(LLVMValueRef Val, unsigned KindID, LLVMValueRef Node);
2186 * Obtain the basic block to which an instruction belongs.
2188 * @see llvm::Instruction::getParent()
2190 LLVMBasicBlockRef LLVMGetInstructionParent(LLVMValueRef Inst);
2193 * Obtain the instruction that occurs after the one specified.
2195 * The next instruction will be from the same basic block.
2197 * If this is the last instruction in a basic block, NULL will be
2200 LLVMValueRef LLVMGetNextInstruction(LLVMValueRef Inst);
2203 * Obtain the instruction that occurred before this one.
2205 * If the instruction is the first instruction in a basic block, NULL
2208 LLVMValueRef LLVMGetPreviousInstruction(LLVMValueRef Inst);
2211 * Remove and delete an instruction.
2213 * The instruction specified is removed from its containing building
2214 * block and then deleted.
2216 * @see llvm::Instruction::eraseFromParent()
2218 void LLVMInstructionEraseFromParent(LLVMValueRef Inst);
2221 * Obtain the code opcode for an individual instruction.
2223 * @see llvm::Instruction::getOpCode()
2225 LLVMOpcode LLVMGetInstructionOpcode(LLVMValueRef Inst);
2228 * Obtain the predicate of an instruction.
2230 * This is only valid for instructions that correspond to llvm::ICmpInst
2231 * or llvm::ConstantExpr whose opcode is llvm::Instruction::ICmp.
2233 * @see llvm::ICmpInst::getPredicate()
2235 LLVMIntPredicate LLVMGetICmpPredicate(LLVMValueRef Inst);
2238 * @defgroup LLVMCCoreValueInstructionCall Call Sites and Invocations
2240 * Functions in this group apply to instructions that refer to call
2241 * sites and invocations. These correspond to C++ types in the
2242 * llvm::CallInst class tree.
2248 * Set the calling convention for a call instruction.
2250 * This expects an LLVMValueRef that corresponds to a llvm::CallInst or
2253 * @see llvm::CallInst::setCallingConv()
2254 * @see llvm::InvokeInst::setCallingConv()
2256 void LLVMSetInstructionCallConv(LLVMValueRef Instr, unsigned CC);
2259 * Obtain the calling convention for a call instruction.
2261 * This is the opposite of LLVMSetInstructionCallConv(). Reads its
2264 * @see LLVMSetInstructionCallConv()
2266 unsigned LLVMGetInstructionCallConv(LLVMValueRef Instr);
2269 void LLVMAddInstrAttribute(LLVMValueRef Instr, unsigned index, LLVMAttribute);
2270 void LLVMRemoveInstrAttribute(LLVMValueRef Instr, unsigned index,
2272 void LLVMSetInstrParamAlignment(LLVMValueRef Instr, unsigned index,
2276 * Obtain whether a call instruction is a tail call.
2278 * This only works on llvm::CallInst instructions.
2280 * @see llvm::CallInst::isTailCall()
2282 LLVMBool LLVMIsTailCall(LLVMValueRef CallInst);
2285 * Set whether a call instruction is a tail call.
2287 * This only works on llvm::CallInst instructions.
2289 * @see llvm::CallInst::setTailCall()
2291 void LLVMSetTailCall(LLVMValueRef CallInst, LLVMBool IsTailCall);
2298 * Obtain the default destination basic block of a switch instruction.
2300 * This only works on llvm::SwitchInst instructions.
2302 * @see llvm::SwitchInst::getDefaultDest()
2304 LLVMBasicBlockRef LLVMGetSwitchDefaultDest(LLVMValueRef SwitchInstr);
2307 * @defgroup LLVMCCoreValueInstructionPHINode PHI Nodes
2309 * Functions in this group only apply to instructions that map to
2310 * llvm::PHINode instances.
2316 * Add an incoming value to the end of a PHI list.
2318 void LLVMAddIncoming(LLVMValueRef PhiNode, LLVMValueRef *IncomingValues,
2319 LLVMBasicBlockRef *IncomingBlocks, unsigned Count);
2322 * Obtain the number of incoming basic blocks to a PHI node.
2324 unsigned LLVMCountIncoming(LLVMValueRef PhiNode);
2327 * Obtain an incoming value to a PHI node as a LLVMValueRef.
2329 LLVMValueRef LLVMGetIncomingValue(LLVMValueRef PhiNode, unsigned Index);
2332 * Obtain an incoming value to a PHI node as a LLVMBasicBlockRef.
2334 LLVMBasicBlockRef LLVMGetIncomingBlock(LLVMValueRef PhiNode, unsigned Index);
2349 * @defgroup LLVMCCoreInstructionBuilder Instruction Builders
2351 * An instruction builder represents a point within a basic block and is
2352 * the exclusive means of building instructions using the C interface.
2357 LLVMBuilderRef LLVMCreateBuilderInContext(LLVMContextRef C);
2358 LLVMBuilderRef LLVMCreateBuilder(void);
2359 void LLVMPositionBuilder(LLVMBuilderRef Builder, LLVMBasicBlockRef Block,
2360 LLVMValueRef Instr);
2361 void LLVMPositionBuilderBefore(LLVMBuilderRef Builder, LLVMValueRef Instr);
2362 void LLVMPositionBuilderAtEnd(LLVMBuilderRef Builder, LLVMBasicBlockRef Block);
2363 LLVMBasicBlockRef LLVMGetInsertBlock(LLVMBuilderRef Builder);
2364 void LLVMClearInsertionPosition(LLVMBuilderRef Builder);
2365 void LLVMInsertIntoBuilder(LLVMBuilderRef Builder, LLVMValueRef Instr);
2366 void LLVMInsertIntoBuilderWithName(LLVMBuilderRef Builder, LLVMValueRef Instr,
2368 void LLVMDisposeBuilder(LLVMBuilderRef Builder);
2371 void LLVMSetCurrentDebugLocation(LLVMBuilderRef Builder, LLVMValueRef L);
2372 LLVMValueRef LLVMGetCurrentDebugLocation(LLVMBuilderRef Builder);
2373 void LLVMSetInstDebugLocation(LLVMBuilderRef Builder, LLVMValueRef Inst);
2376 LLVMValueRef LLVMBuildRetVoid(LLVMBuilderRef);
2377 LLVMValueRef LLVMBuildRet(LLVMBuilderRef, LLVMValueRef V);
2378 LLVMValueRef LLVMBuildAggregateRet(LLVMBuilderRef, LLVMValueRef *RetVals,
2380 LLVMValueRef LLVMBuildBr(LLVMBuilderRef, LLVMBasicBlockRef Dest);
2381 LLVMValueRef LLVMBuildCondBr(LLVMBuilderRef, LLVMValueRef If,
2382 LLVMBasicBlockRef Then, LLVMBasicBlockRef Else);
2383 LLVMValueRef LLVMBuildSwitch(LLVMBuilderRef, LLVMValueRef V,
2384 LLVMBasicBlockRef Else, unsigned NumCases);
2385 LLVMValueRef LLVMBuildIndirectBr(LLVMBuilderRef B, LLVMValueRef Addr,
2387 LLVMValueRef LLVMBuildInvoke(LLVMBuilderRef, LLVMValueRef Fn,
2388 LLVMValueRef *Args, unsigned NumArgs,
2389 LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch,
2391 LLVMValueRef LLVMBuildLandingPad(LLVMBuilderRef B, LLVMTypeRef Ty,
2392 LLVMValueRef PersFn, unsigned NumClauses,
2394 LLVMValueRef LLVMBuildResume(LLVMBuilderRef B, LLVMValueRef Exn);
2395 LLVMValueRef LLVMBuildUnreachable(LLVMBuilderRef);
2397 /* Add a case to the switch instruction */
2398 void LLVMAddCase(LLVMValueRef Switch, LLVMValueRef OnVal,
2399 LLVMBasicBlockRef Dest);
2401 /* Add a destination to the indirectbr instruction */
2402 void LLVMAddDestination(LLVMValueRef IndirectBr, LLVMBasicBlockRef Dest);
2404 /* Add a catch or filter clause to the landingpad instruction */
2405 void LLVMAddClause(LLVMValueRef LandingPad, LLVMValueRef ClauseVal);
2407 /* Set the 'cleanup' flag in the landingpad instruction */
2408 void LLVMSetCleanup(LLVMValueRef LandingPad, LLVMBool Val);
2411 LLVMValueRef LLVMBuildAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2413 LLVMValueRef LLVMBuildNSWAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2415 LLVMValueRef LLVMBuildNUWAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2417 LLVMValueRef LLVMBuildFAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2419 LLVMValueRef LLVMBuildSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2421 LLVMValueRef LLVMBuildNSWSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2423 LLVMValueRef LLVMBuildNUWSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2425 LLVMValueRef LLVMBuildFSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2427 LLVMValueRef LLVMBuildMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2429 LLVMValueRef LLVMBuildNSWMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2431 LLVMValueRef LLVMBuildNUWMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2433 LLVMValueRef LLVMBuildFMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2435 LLVMValueRef LLVMBuildUDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2437 LLVMValueRef LLVMBuildSDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2439 LLVMValueRef LLVMBuildExactSDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2441 LLVMValueRef LLVMBuildFDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2443 LLVMValueRef LLVMBuildURem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2445 LLVMValueRef LLVMBuildSRem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2447 LLVMValueRef LLVMBuildFRem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2449 LLVMValueRef LLVMBuildShl(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2451 LLVMValueRef LLVMBuildLShr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2453 LLVMValueRef LLVMBuildAShr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2455 LLVMValueRef LLVMBuildAnd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2457 LLVMValueRef LLVMBuildOr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2459 LLVMValueRef LLVMBuildXor(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2461 LLVMValueRef LLVMBuildBinOp(LLVMBuilderRef B, LLVMOpcode Op,
2462 LLVMValueRef LHS, LLVMValueRef RHS,
2464 LLVMValueRef LLVMBuildNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name);
2465 LLVMValueRef LLVMBuildNSWNeg(LLVMBuilderRef B, LLVMValueRef V,
2467 LLVMValueRef LLVMBuildNUWNeg(LLVMBuilderRef B, LLVMValueRef V,
2469 LLVMValueRef LLVMBuildFNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name);
2470 LLVMValueRef LLVMBuildNot(LLVMBuilderRef, LLVMValueRef V, const char *Name);
2473 LLVMValueRef LLVMBuildMalloc(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
2474 LLVMValueRef LLVMBuildArrayMalloc(LLVMBuilderRef, LLVMTypeRef Ty,
2475 LLVMValueRef Val, const char *Name);
2476 LLVMValueRef LLVMBuildAlloca(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
2477 LLVMValueRef LLVMBuildArrayAlloca(LLVMBuilderRef, LLVMTypeRef Ty,
2478 LLVMValueRef Val, const char *Name);
2479 LLVMValueRef LLVMBuildFree(LLVMBuilderRef, LLVMValueRef PointerVal);
2480 LLVMValueRef LLVMBuildLoad(LLVMBuilderRef, LLVMValueRef PointerVal,
2482 LLVMValueRef LLVMBuildStore(LLVMBuilderRef, LLVMValueRef Val, LLVMValueRef Ptr);
2483 LLVMValueRef LLVMBuildGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
2484 LLVMValueRef *Indices, unsigned NumIndices,
2486 LLVMValueRef LLVMBuildInBoundsGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
2487 LLVMValueRef *Indices, unsigned NumIndices,
2489 LLVMValueRef LLVMBuildStructGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
2490 unsigned Idx, const char *Name);
2491 LLVMValueRef LLVMBuildGlobalString(LLVMBuilderRef B, const char *Str,
2493 LLVMValueRef LLVMBuildGlobalStringPtr(LLVMBuilderRef B, const char *Str,
2495 LLVMBool LLVMGetVolatile(LLVMValueRef MemoryAccessInst);
2496 void LLVMSetVolatile(LLVMValueRef MemoryAccessInst, LLVMBool IsVolatile);
2499 LLVMValueRef LLVMBuildTrunc(LLVMBuilderRef, LLVMValueRef Val,
2500 LLVMTypeRef DestTy, const char *Name);
2501 LLVMValueRef LLVMBuildZExt(LLVMBuilderRef, LLVMValueRef Val,
2502 LLVMTypeRef DestTy, const char *Name);
2503 LLVMValueRef LLVMBuildSExt(LLVMBuilderRef, LLVMValueRef Val,
2504 LLVMTypeRef DestTy, const char *Name);
2505 LLVMValueRef LLVMBuildFPToUI(LLVMBuilderRef, LLVMValueRef Val,
2506 LLVMTypeRef DestTy, const char *Name);
2507 LLVMValueRef LLVMBuildFPToSI(LLVMBuilderRef, LLVMValueRef Val,
2508 LLVMTypeRef DestTy, const char *Name);
2509 LLVMValueRef LLVMBuildUIToFP(LLVMBuilderRef, LLVMValueRef Val,
2510 LLVMTypeRef DestTy, const char *Name);
2511 LLVMValueRef LLVMBuildSIToFP(LLVMBuilderRef, LLVMValueRef Val,
2512 LLVMTypeRef DestTy, const char *Name);
2513 LLVMValueRef LLVMBuildFPTrunc(LLVMBuilderRef, LLVMValueRef Val,
2514 LLVMTypeRef DestTy, const char *Name);
2515 LLVMValueRef LLVMBuildFPExt(LLVMBuilderRef, LLVMValueRef Val,
2516 LLVMTypeRef DestTy, const char *Name);
2517 LLVMValueRef LLVMBuildPtrToInt(LLVMBuilderRef, LLVMValueRef Val,
2518 LLVMTypeRef DestTy, const char *Name);
2519 LLVMValueRef LLVMBuildIntToPtr(LLVMBuilderRef, LLVMValueRef Val,
2520 LLVMTypeRef DestTy, const char *Name);
2521 LLVMValueRef LLVMBuildBitCast(LLVMBuilderRef, LLVMValueRef Val,
2522 LLVMTypeRef DestTy, const char *Name);
2523 LLVMValueRef LLVMBuildZExtOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
2524 LLVMTypeRef DestTy, const char *Name);
2525 LLVMValueRef LLVMBuildSExtOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
2526 LLVMTypeRef DestTy, const char *Name);
2527 LLVMValueRef LLVMBuildTruncOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
2528 LLVMTypeRef DestTy, const char *Name);
2529 LLVMValueRef LLVMBuildCast(LLVMBuilderRef B, LLVMOpcode Op, LLVMValueRef Val,
2530 LLVMTypeRef DestTy, const char *Name);
2531 LLVMValueRef LLVMBuildPointerCast(LLVMBuilderRef, LLVMValueRef Val,
2532 LLVMTypeRef DestTy, const char *Name);
2533 LLVMValueRef LLVMBuildIntCast(LLVMBuilderRef, LLVMValueRef Val, /*Signed cast!*/
2534 LLVMTypeRef DestTy, const char *Name);
2535 LLVMValueRef LLVMBuildFPCast(LLVMBuilderRef, LLVMValueRef Val,
2536 LLVMTypeRef DestTy, const char *Name);
2539 LLVMValueRef LLVMBuildICmp(LLVMBuilderRef, LLVMIntPredicate Op,
2540 LLVMValueRef LHS, LLVMValueRef RHS,
2542 LLVMValueRef LLVMBuildFCmp(LLVMBuilderRef, LLVMRealPredicate Op,
2543 LLVMValueRef LHS, LLVMValueRef RHS,
2546 /* Miscellaneous instructions */
2547 LLVMValueRef LLVMBuildPhi(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
2548 LLVMValueRef LLVMBuildCall(LLVMBuilderRef, LLVMValueRef Fn,
2549 LLVMValueRef *Args, unsigned NumArgs,
2551 LLVMValueRef LLVMBuildSelect(LLVMBuilderRef, LLVMValueRef If,
2552 LLVMValueRef Then, LLVMValueRef Else,
2554 LLVMValueRef LLVMBuildVAArg(LLVMBuilderRef, LLVMValueRef List, LLVMTypeRef Ty,
2556 LLVMValueRef LLVMBuildExtractElement(LLVMBuilderRef, LLVMValueRef VecVal,
2557 LLVMValueRef Index, const char *Name);
2558 LLVMValueRef LLVMBuildInsertElement(LLVMBuilderRef, LLVMValueRef VecVal,
2559 LLVMValueRef EltVal, LLVMValueRef Index,
2561 LLVMValueRef LLVMBuildShuffleVector(LLVMBuilderRef, LLVMValueRef V1,
2562 LLVMValueRef V2, LLVMValueRef Mask,
2564 LLVMValueRef LLVMBuildExtractValue(LLVMBuilderRef, LLVMValueRef AggVal,
2565 unsigned Index, const char *Name);
2566 LLVMValueRef LLVMBuildInsertValue(LLVMBuilderRef, LLVMValueRef AggVal,
2567 LLVMValueRef EltVal, unsigned Index,
2570 LLVMValueRef LLVMBuildIsNull(LLVMBuilderRef, LLVMValueRef Val,
2572 LLVMValueRef LLVMBuildIsNotNull(LLVMBuilderRef, LLVMValueRef Val,
2574 LLVMValueRef LLVMBuildPtrDiff(LLVMBuilderRef, LLVMValueRef LHS,
2575 LLVMValueRef RHS, const char *Name);
2576 LLVMValueRef LLVMBuildAtomicRMW(LLVMBuilderRef B,LLVMAtomicRMWBinOp op,
2577 LLVMValueRef PTR, LLVMValueRef Val,
2578 LLVMAtomicOrdering ordering,
2579 LLVMBool singleThread);
2586 * @defgroup LLVMCCoreModuleProvider Module Providers
2592 * Changes the type of M so it can be passed to FunctionPassManagers and the
2593 * JIT. They take ModuleProviders for historical reasons.
2595 LLVMModuleProviderRef
2596 LLVMCreateModuleProviderForExistingModule(LLVMModuleRef M);
2599 * Destroys the module M.
2601 void LLVMDisposeModuleProvider(LLVMModuleProviderRef M);
2608 * @defgroup LLVMCCoreMemoryBuffers Memory Buffers
2613 LLVMBool LLVMCreateMemoryBufferWithContentsOfFile(const char *Path,
2614 LLVMMemoryBufferRef *OutMemBuf,
2616 LLVMBool LLVMCreateMemoryBufferWithSTDIN(LLVMMemoryBufferRef *OutMemBuf,
2618 LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRange(const char *InputData,
2619 size_t InputDataLength,
2620 const char *BufferName,
2621 LLVMBool RequiresNullTerminator);
2622 LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRangeCopy(const char *InputData,
2623 size_t InputDataLength,
2624 const char *BufferName);
2625 const char *LLVMGetBufferStart(LLVMMemoryBufferRef MemBuf);
2626 size_t LLVMGetBufferSize(LLVMMemoryBufferRef MemBuf);
2627 void LLVMDisposeMemoryBuffer(LLVMMemoryBufferRef MemBuf);
2634 * @defgroup LLVMCCorePassRegistry Pass Registry
2639 /** Return the global pass registry, for use with initialization functions.
2640 @see llvm::PassRegistry::getPassRegistry */
2641 LLVMPassRegistryRef LLVMGetGlobalPassRegistry(void);
2648 * @defgroup LLVMCCorePassManagers Pass Managers
2653 /** Constructs a new whole-module pass pipeline. This type of pipeline is
2654 suitable for link-time optimization and whole-module transformations.
2655 @see llvm::PassManager::PassManager */
2656 LLVMPassManagerRef LLVMCreatePassManager(void);
2658 /** Constructs a new function-by-function pass pipeline over the module
2659 provider. It does not take ownership of the module provider. This type of
2660 pipeline is suitable for code generation and JIT compilation tasks.
2661 @see llvm::FunctionPassManager::FunctionPassManager */
2662 LLVMPassManagerRef LLVMCreateFunctionPassManagerForModule(LLVMModuleRef M);
2664 /** Deprecated: Use LLVMCreateFunctionPassManagerForModule instead. */
2665 LLVMPassManagerRef LLVMCreateFunctionPassManager(LLVMModuleProviderRef MP);
2667 /** Initializes, executes on the provided module, and finalizes all of the
2668 passes scheduled in the pass manager. Returns 1 if any of the passes
2669 modified the module, 0 otherwise.
2670 @see llvm::PassManager::run(Module&) */
2671 LLVMBool LLVMRunPassManager(LLVMPassManagerRef PM, LLVMModuleRef M);
2673 /** Initializes all of the function passes scheduled in the function pass
2674 manager. Returns 1 if any of the passes modified the module, 0 otherwise.
2675 @see llvm::FunctionPassManager::doInitialization */
2676 LLVMBool LLVMInitializeFunctionPassManager(LLVMPassManagerRef FPM);
2678 /** Executes all of the function passes scheduled in the function pass manager
2679 on the provided function. Returns 1 if any of the passes modified the
2680 function, false otherwise.
2681 @see llvm::FunctionPassManager::run(Function&) */
2682 LLVMBool LLVMRunFunctionPassManager(LLVMPassManagerRef FPM, LLVMValueRef F);
2684 /** Finalizes all of the function passes scheduled in in the function pass
2685 manager. Returns 1 if any of the passes modified the module, 0 otherwise.
2686 @see llvm::FunctionPassManager::doFinalization */
2687 LLVMBool LLVMFinalizeFunctionPassManager(LLVMPassManagerRef FPM);
2689 /** Frees the memory of a pass pipeline. For function pipelines, does not free
2690 the module provider.
2691 @see llvm::PassManagerBase::~PassManagerBase. */
2692 void LLVMDisposePassManager(LLVMPassManagerRef PM);
2699 * @defgroup LLVMCCoreThreading Threading
2701 * Handle the structures needed to make LLVM safe for multithreading.
2706 /** Allocate and initialize structures needed to make LLVM safe for
2707 multithreading. The return value indicates whether multithreaded
2708 initialization succeeded. Must be executed in isolation from all
2709 other LLVM api calls.
2710 @see llvm::llvm_start_multithreaded */
2711 LLVMBool LLVMStartMultithreaded();
2713 /** Deallocate structures necessary to make LLVM safe for multithreading.
2714 Must be executed in isolation from all other LLVM api calls.
2715 @see llvm::llvm_stop_multithreaded */
2716 void LLVMStopMultithreaded();
2718 /** Check whether LLVM is executing in thread-safe mode or not.
2719 @see llvm::llvm_is_multithreaded */
2720 LLVMBool LLVMIsMultithreaded();
2736 #endif /* !defined(__cplusplus) */
2738 #endif /* !defined(LLVM_C_CORE_H) */