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
173 /* Terminator Instructions */
179 /* removed 6 due to API changes */
182 /* Standard Binary Operators */
196 /* Logical Operators */
204 /* Memory Operators */
208 LLVMGetElementPtr = 29,
224 /* Other Operators */
233 LLVMExtractElement = 50,
234 LLVMInsertElement = 51,
235 LLVMShuffleVector = 52,
236 LLVMExtractValue = 53,
237 LLVMInsertValue = 54,
239 /* Atomic operators */
241 LLVMAtomicCmpXchg = 56,
244 /* Exception Handling Operators */
251 LLVMVoidTypeKind, /**< type with no size */
252 LLVMHalfTypeKind, /**< 16 bit floating point type */
253 LLVMFloatTypeKind, /**< 32 bit floating point type */
254 LLVMDoubleTypeKind, /**< 64 bit floating point type */
255 LLVMX86_FP80TypeKind, /**< 80 bit floating point type (X87) */
256 LLVMFP128TypeKind, /**< 128 bit floating point type (112-bit mantissa)*/
257 LLVMPPC_FP128TypeKind, /**< 128 bit floating point type (two 64-bits) */
258 LLVMLabelTypeKind, /**< Labels */
259 LLVMIntegerTypeKind, /**< Arbitrary bit width integers */
260 LLVMFunctionTypeKind, /**< Functions */
261 LLVMStructTypeKind, /**< Structures */
262 LLVMArrayTypeKind, /**< Arrays */
263 LLVMPointerTypeKind, /**< Pointers */
264 LLVMVectorTypeKind, /**< SIMD 'packed' format, or other vector type */
265 LLVMMetadataTypeKind, /**< Metadata */
266 LLVMX86_MMXTypeKind /**< X86 MMX */
270 LLVMExternalLinkage, /**< Externally visible function */
271 LLVMAvailableExternallyLinkage,
272 LLVMLinkOnceAnyLinkage, /**< Keep one copy of function when linking (inline)*/
273 LLVMLinkOnceODRLinkage, /**< Same, but only replaced by something
275 LLVMLinkOnceODRAutoHideLinkage, /**< Like LinkOnceODR, but possibly hidden. */
276 LLVMWeakAnyLinkage, /**< Keep one copy of function when linking (weak) */
277 LLVMWeakODRLinkage, /**< Same, but only replaced by something
279 LLVMAppendingLinkage, /**< Special purpose, only applies to global arrays */
280 LLVMInternalLinkage, /**< Rename collisions when linking (static
282 LLVMPrivateLinkage, /**< Like Internal, but omit from symbol table */
283 LLVMDLLImportLinkage, /**< Function to be imported from DLL */
284 LLVMDLLExportLinkage, /**< Function to be accessible from DLL */
285 LLVMExternalWeakLinkage,/**< ExternalWeak linkage description */
286 LLVMGhostLinkage, /**< Obsolete */
287 LLVMCommonLinkage, /**< Tentative definitions */
288 LLVMLinkerPrivateLinkage, /**< Like Private, but linker removes. */
289 LLVMLinkerPrivateWeakLinkage /**< Like LinkerPrivate, but is weak. */
293 LLVMDefaultVisibility, /**< The GV is visible */
294 LLVMHiddenVisibility, /**< The GV is hidden */
295 LLVMProtectedVisibility /**< The GV is protected */
300 LLVMFastCallConv = 8,
301 LLVMColdCallConv = 9,
302 LLVMX86StdcallCallConv = 64,
303 LLVMX86FastcallCallConv = 65
307 LLVMIntEQ = 32, /**< equal */
308 LLVMIntNE, /**< not equal */
309 LLVMIntUGT, /**< unsigned greater than */
310 LLVMIntUGE, /**< unsigned greater or equal */
311 LLVMIntULT, /**< unsigned less than */
312 LLVMIntULE, /**< unsigned less or equal */
313 LLVMIntSGT, /**< signed greater than */
314 LLVMIntSGE, /**< signed greater or equal */
315 LLVMIntSLT, /**< signed less than */
316 LLVMIntSLE /**< signed less or equal */
320 LLVMRealPredicateFalse, /**< Always false (always folded) */
321 LLVMRealOEQ, /**< True if ordered and equal */
322 LLVMRealOGT, /**< True if ordered and greater than */
323 LLVMRealOGE, /**< True if ordered and greater than or equal */
324 LLVMRealOLT, /**< True if ordered and less than */
325 LLVMRealOLE, /**< True if ordered and less than or equal */
326 LLVMRealONE, /**< True if ordered and operands are unequal */
327 LLVMRealORD, /**< True if ordered (no nans) */
328 LLVMRealUNO, /**< True if unordered: isnan(X) | isnan(Y) */
329 LLVMRealUEQ, /**< True if unordered or equal */
330 LLVMRealUGT, /**< True if unordered or greater than */
331 LLVMRealUGE, /**< True if unordered, greater than, or equal */
332 LLVMRealULT, /**< True if unordered or less than */
333 LLVMRealULE, /**< True if unordered, less than, or equal */
334 LLVMRealUNE, /**< True if unordered or not equal */
335 LLVMRealPredicateTrue /**< Always true (always folded) */
339 LLVMLandingPadCatch, /**< A catch clause */
340 LLVMLandingPadFilter /**< A filter clause */
341 } LLVMLandingPadClauseTy;
344 LLVMNotThreadLocal = 0,
345 LLVMGeneralDynamicTLSModel,
346 LLVMLocalDynamicTLSModel,
347 LLVMInitialExecTLSModel,
348 LLVMLocalExecTLSModel
349 } LLVMThreadLocalMode;
355 void LLVMInitializeCore(LLVMPassRegistryRef R);
357 /** Deallocate and destroy all ManagedStatic variables.
358 @see llvm::llvm_shutdown
359 @see ManagedStatic */
363 /*===-- Error handling ----------------------------------------------------===*/
365 void LLVMDisposeMessage(char *Message);
369 * @defgroup LLVMCCoreContext Contexts
371 * Contexts are execution states for the core LLVM IR system.
373 * Most types are tied to a context instance. Multiple contexts can
374 * exist simultaneously. A single context is not thread safe. However,
375 * different contexts can execute on different threads simultaneously.
381 * Create a new context.
383 * Every call to this function should be paired with a call to
384 * LLVMContextDispose() or the context will leak memory.
386 LLVMContextRef LLVMContextCreate(void);
389 * Obtain the global context instance.
391 LLVMContextRef LLVMGetGlobalContext(void);
394 * Destroy a context instance.
396 * This should be called for every call to LLVMContextCreate() or memory
399 void LLVMContextDispose(LLVMContextRef C);
401 unsigned LLVMGetMDKindIDInContext(LLVMContextRef C, const char* Name,
403 unsigned LLVMGetMDKindID(const char* Name, unsigned SLen);
410 * @defgroup LLVMCCoreModule Modules
412 * Modules represent the top-level structure in a LLVM program. An LLVM
413 * module is effectively a translation unit or a collection of
414 * translation units merged together.
420 * Create a new, empty module in the global context.
422 * This is equivalent to calling LLVMModuleCreateWithNameInContext with
423 * LLVMGetGlobalContext() as the context parameter.
425 * Every invocation should be paired with LLVMDisposeModule() or memory
428 LLVMModuleRef LLVMModuleCreateWithName(const char *ModuleID);
431 * Create a new, empty module in a specific context.
433 * Every invocation should be paired with LLVMDisposeModule() or memory
436 LLVMModuleRef LLVMModuleCreateWithNameInContext(const char *ModuleID,
440 * Destroy a module instance.
442 * This must be called for every created module or memory will be
445 void LLVMDisposeModule(LLVMModuleRef M);
448 * Obtain the data layout for a module.
450 * @see Module::getDataLayout()
452 const char *LLVMGetDataLayout(LLVMModuleRef M);
455 * Set the data layout for a module.
457 * @see Module::setDataLayout()
459 void LLVMSetDataLayout(LLVMModuleRef M, const char *Triple);
462 * Obtain the target triple for a module.
464 * @see Module::getTargetTriple()
466 const char *LLVMGetTarget(LLVMModuleRef M);
469 * Set the target triple for a module.
471 * @see Module::setTargetTriple()
473 void LLVMSetTarget(LLVMModuleRef M, const char *Triple);
476 * Dump a representation of a module to stderr.
478 * @see Module::dump()
480 void LLVMDumpModule(LLVMModuleRef M);
483 * Print a representation of a module to a file. The ErrorMessage needs to be
484 * disposed with LLVMDisposeMessage. Returns 0 on success, 1 otherwise.
486 * @see Module::print()
488 LLVMBool LLVMPrintModuleToFile(LLVMModuleRef M, const char *Filename,
489 char **ErrorMessage);
492 * Set inline assembly for a module.
494 * @see Module::setModuleInlineAsm()
496 void LLVMSetModuleInlineAsm(LLVMModuleRef M, const char *Asm);
499 * Obtain the context to which this module is associated.
501 * @see Module::getContext()
503 LLVMContextRef LLVMGetModuleContext(LLVMModuleRef M);
506 * Obtain a Type from a module by its registered name.
508 LLVMTypeRef LLVMGetTypeByName(LLVMModuleRef M, const char *Name);
511 * Obtain the number of operands for named metadata in a module.
513 * @see llvm::Module::getNamedMetadata()
515 unsigned LLVMGetNamedMetadataNumOperands(LLVMModuleRef M, const char* name);
518 * Obtain the named metadata operands for a module.
520 * The passed LLVMValueRef pointer should refer to an array of
521 * LLVMValueRef at least LLVMGetNamedMetadataNumOperands long. This
522 * array will be populated with the LLVMValueRef instances. Each
523 * instance corresponds to a llvm::MDNode.
525 * @see llvm::Module::getNamedMetadata()
526 * @see llvm::MDNode::getOperand()
528 void LLVMGetNamedMetadataOperands(LLVMModuleRef M, const char* name, LLVMValueRef *Dest);
531 * Add an operand to named metadata.
533 * @see llvm::Module::getNamedMetadata()
534 * @see llvm::MDNode::addOperand()
536 void LLVMAddNamedMetadataOperand(LLVMModuleRef M, const char* name,
540 * Add a function to a module under a specified name.
542 * @see llvm::Function::Create()
544 LLVMValueRef LLVMAddFunction(LLVMModuleRef M, const char *Name,
545 LLVMTypeRef FunctionTy);
548 * Obtain a Function value from a Module by its name.
550 * The returned value corresponds to a llvm::Function value.
552 * @see llvm::Module::getFunction()
554 LLVMValueRef LLVMGetNamedFunction(LLVMModuleRef M, const char *Name);
557 * Obtain an iterator to the first Function in a Module.
559 * @see llvm::Module::begin()
561 LLVMValueRef LLVMGetFirstFunction(LLVMModuleRef M);
564 * Obtain an iterator to the last Function in a Module.
566 * @see llvm::Module::end()
568 LLVMValueRef LLVMGetLastFunction(LLVMModuleRef M);
571 * Advance a Function iterator to the next Function.
573 * Returns NULL if the iterator was already at the end and there are no more
576 LLVMValueRef LLVMGetNextFunction(LLVMValueRef Fn);
579 * Decrement a Function iterator to the previous Function.
581 * Returns NULL if the iterator was already at the beginning and there are
582 * no previous functions.
584 LLVMValueRef LLVMGetPreviousFunction(LLVMValueRef Fn);
591 * @defgroup LLVMCCoreType Types
593 * Types represent the type of a value.
595 * Types are associated with a context instance. The context internally
596 * deduplicates types so there is only 1 instance of a specific type
597 * alive at a time. In other words, a unique type is shared among all
598 * consumers within a context.
600 * A Type in the C API corresponds to llvm::Type.
602 * Types have the following hierarchy:
620 * Obtain the enumerated type of a Type instance.
622 * @see llvm::Type:getTypeID()
624 LLVMTypeKind LLVMGetTypeKind(LLVMTypeRef Ty);
627 * Whether the type has a known size.
629 * Things that don't have a size are abstract types, labels, and void.a
631 * @see llvm::Type::isSized()
633 LLVMBool LLVMTypeIsSized(LLVMTypeRef Ty);
636 * Obtain the context to which this type instance is associated.
638 * @see llvm::Type::getContext()
640 LLVMContextRef LLVMGetTypeContext(LLVMTypeRef Ty);
643 * @defgroup LLVMCCoreTypeInt Integer Types
645 * Functions in this section operate on integer types.
651 * Obtain an integer type from a context with specified bit width.
653 LLVMTypeRef LLVMInt1TypeInContext(LLVMContextRef C);
654 LLVMTypeRef LLVMInt8TypeInContext(LLVMContextRef C);
655 LLVMTypeRef LLVMInt16TypeInContext(LLVMContextRef C);
656 LLVMTypeRef LLVMInt32TypeInContext(LLVMContextRef C);
657 LLVMTypeRef LLVMInt64TypeInContext(LLVMContextRef C);
658 LLVMTypeRef LLVMIntTypeInContext(LLVMContextRef C, unsigned NumBits);
661 * Obtain an integer type from the global context with a specified bit
664 LLVMTypeRef LLVMInt1Type(void);
665 LLVMTypeRef LLVMInt8Type(void);
666 LLVMTypeRef LLVMInt16Type(void);
667 LLVMTypeRef LLVMInt32Type(void);
668 LLVMTypeRef LLVMInt64Type(void);
669 LLVMTypeRef LLVMIntType(unsigned NumBits);
670 unsigned LLVMGetIntTypeWidth(LLVMTypeRef IntegerTy);
677 * @defgroup LLVMCCoreTypeFloat Floating Point Types
683 * Obtain a 16-bit floating point type from a context.
685 LLVMTypeRef LLVMHalfTypeInContext(LLVMContextRef C);
688 * Obtain a 32-bit floating point type from a context.
690 LLVMTypeRef LLVMFloatTypeInContext(LLVMContextRef C);
693 * Obtain a 64-bit floating point type from a context.
695 LLVMTypeRef LLVMDoubleTypeInContext(LLVMContextRef C);
698 * Obtain a 80-bit floating point type (X87) from a context.
700 LLVMTypeRef LLVMX86FP80TypeInContext(LLVMContextRef C);
703 * Obtain a 128-bit floating point type (112-bit mantissa) from a
706 LLVMTypeRef LLVMFP128TypeInContext(LLVMContextRef C);
709 * Obtain a 128-bit floating point type (two 64-bits) from a context.
711 LLVMTypeRef LLVMPPCFP128TypeInContext(LLVMContextRef C);
714 * Obtain a floating point type from the global context.
716 * These map to the functions in this group of the same name.
718 LLVMTypeRef LLVMHalfType(void);
719 LLVMTypeRef LLVMFloatType(void);
720 LLVMTypeRef LLVMDoubleType(void);
721 LLVMTypeRef LLVMX86FP80Type(void);
722 LLVMTypeRef LLVMFP128Type(void);
723 LLVMTypeRef LLVMPPCFP128Type(void);
730 * @defgroup LLVMCCoreTypeFunction Function Types
736 * Obtain a function type consisting of a specified signature.
738 * The function is defined as a tuple of a return Type, a list of
739 * parameter types, and whether the function is variadic.
741 LLVMTypeRef LLVMFunctionType(LLVMTypeRef ReturnType,
742 LLVMTypeRef *ParamTypes, unsigned ParamCount,
746 * Returns whether a function type is variadic.
748 LLVMBool LLVMIsFunctionVarArg(LLVMTypeRef FunctionTy);
751 * Obtain the Type this function Type returns.
753 LLVMTypeRef LLVMGetReturnType(LLVMTypeRef FunctionTy);
756 * Obtain the number of parameters this function accepts.
758 unsigned LLVMCountParamTypes(LLVMTypeRef FunctionTy);
761 * Obtain the types of a function's parameters.
763 * The Dest parameter should point to a pre-allocated array of
764 * LLVMTypeRef at least LLVMCountParamTypes() large. On return, the
765 * first LLVMCountParamTypes() entries in the array will be populated
766 * with LLVMTypeRef instances.
768 * @param FunctionTy The function type to operate on.
769 * @param Dest Memory address of an array to be filled with result.
771 void LLVMGetParamTypes(LLVMTypeRef FunctionTy, LLVMTypeRef *Dest);
778 * @defgroup LLVMCCoreTypeStruct Structure Types
780 * These functions relate to LLVMTypeRef instances.
782 * @see llvm::StructType
788 * Create a new structure type in a context.
790 * A structure is specified by a list of inner elements/types and
791 * whether these can be packed together.
793 * @see llvm::StructType::create()
795 LLVMTypeRef LLVMStructTypeInContext(LLVMContextRef C, LLVMTypeRef *ElementTypes,
796 unsigned ElementCount, LLVMBool Packed);
799 * Create a new structure type in the global context.
801 * @see llvm::StructType::create()
803 LLVMTypeRef LLVMStructType(LLVMTypeRef *ElementTypes, unsigned ElementCount,
807 * Create an empty structure in a context having a specified name.
809 * @see llvm::StructType::create()
811 LLVMTypeRef LLVMStructCreateNamed(LLVMContextRef C, const char *Name);
814 * Obtain the name of a structure.
816 * @see llvm::StructType::getName()
818 const char *LLVMGetStructName(LLVMTypeRef Ty);
821 * Set the contents of a structure type.
823 * @see llvm::StructType::setBody()
825 void LLVMStructSetBody(LLVMTypeRef StructTy, LLVMTypeRef *ElementTypes,
826 unsigned ElementCount, LLVMBool Packed);
829 * Get the number of elements defined inside the structure.
831 * @see llvm::StructType::getNumElements()
833 unsigned LLVMCountStructElementTypes(LLVMTypeRef StructTy);
836 * Get the elements within a structure.
838 * The function is passed the address of a pre-allocated array of
839 * LLVMTypeRef at least LLVMCountStructElementTypes() long. After
840 * invocation, this array will be populated with the structure's
841 * elements. The objects in the destination array will have a lifetime
842 * of the structure type itself, which is the lifetime of the context it
845 void LLVMGetStructElementTypes(LLVMTypeRef StructTy, LLVMTypeRef *Dest);
848 * Determine whether a structure is packed.
850 * @see llvm::StructType::isPacked()
852 LLVMBool LLVMIsPackedStruct(LLVMTypeRef StructTy);
855 * Determine whether a structure is opaque.
857 * @see llvm::StructType::isOpaque()
859 LLVMBool LLVMIsOpaqueStruct(LLVMTypeRef StructTy);
867 * @defgroup LLVMCCoreTypeSequential Sequential Types
869 * Sequential types represents "arrays" of types. This is a super class
870 * for array, vector, and pointer types.
876 * Obtain the type of elements within a sequential type.
878 * This works on array, vector, and pointer types.
880 * @see llvm::SequentialType::getElementType()
882 LLVMTypeRef LLVMGetElementType(LLVMTypeRef Ty);
885 * Create a fixed size array type that refers to a specific type.
887 * The created type will exist in the context that its element type
890 * @see llvm::ArrayType::get()
892 LLVMTypeRef LLVMArrayType(LLVMTypeRef ElementType, unsigned ElementCount);
895 * Obtain the length of an array type.
897 * This only works on types that represent arrays.
899 * @see llvm::ArrayType::getNumElements()
901 unsigned LLVMGetArrayLength(LLVMTypeRef ArrayTy);
904 * Create a pointer type that points to a defined type.
906 * The created type will exist in the context that its pointee type
909 * @see llvm::PointerType::get()
911 LLVMTypeRef LLVMPointerType(LLVMTypeRef ElementType, unsigned AddressSpace);
914 * Obtain the address space of a pointer type.
916 * This only works on types that represent pointers.
918 * @see llvm::PointerType::getAddressSpace()
920 unsigned LLVMGetPointerAddressSpace(LLVMTypeRef PointerTy);
923 * Create a vector type that contains a defined type and has a specific
924 * number of elements.
926 * The created type will exist in the context thats its element type
929 * @see llvm::VectorType::get()
931 LLVMTypeRef LLVMVectorType(LLVMTypeRef ElementType, unsigned ElementCount);
934 * Obtain the number of elements in a vector type.
936 * This only works on types that represent vectors.
938 * @see llvm::VectorType::getNumElements()
940 unsigned LLVMGetVectorSize(LLVMTypeRef VectorTy);
947 * @defgroup LLVMCCoreTypeOther Other Types
953 * Create a void type in a context.
955 LLVMTypeRef LLVMVoidTypeInContext(LLVMContextRef C);
958 * Create a label type in a context.
960 LLVMTypeRef LLVMLabelTypeInContext(LLVMContextRef C);
963 * Create a X86 MMX type in a context.
965 LLVMTypeRef LLVMX86MMXTypeInContext(LLVMContextRef C);
968 * These are similar to the above functions except they operate on the
971 LLVMTypeRef LLVMVoidType(void);
972 LLVMTypeRef LLVMLabelType(void);
973 LLVMTypeRef LLVMX86MMXType(void);
984 * @defgroup LLVMCCoreValues Values
986 * The bulk of LLVM's object model consists of values, which comprise a very
987 * rich type hierarchy.
989 * LLVMValueRef essentially represents llvm::Value. There is a rich
990 * hierarchy of classes within this type. Depending on the instance
991 * obtained, not all APIs are available.
993 * Callers can determine the type of a LLVMValueRef by calling the
994 * LLVMIsA* family of functions (e.g. LLVMIsAArgument()). These
995 * functions are defined by a macro, so it isn't obvious which are
996 * available by looking at the Doxygen source code. Instead, look at the
997 * source definition of LLVM_FOR_EACH_VALUE_SUBCLASS and note the list
998 * of value names given. These value names also correspond to classes in
999 * the llvm::Value hierarchy.
1004 #define LLVM_FOR_EACH_VALUE_SUBCLASS(macro) \
1012 macro(BlockAddress) \
1013 macro(ConstantAggregateZero) \
1014 macro(ConstantArray) \
1015 macro(ConstantExpr) \
1017 macro(ConstantInt) \
1018 macro(ConstantPointerNull) \
1019 macro(ConstantStruct) \
1020 macro(ConstantVector) \
1021 macro(GlobalValue) \
1023 macro(GlobalAlias) \
1024 macro(GlobalVariable) \
1026 macro(Instruction) \
1027 macro(BinaryOperator) \
1029 macro(IntrinsicInst) \
1030 macro(DbgInfoIntrinsic) \
1031 macro(DbgDeclareInst) \
1032 macro(MemIntrinsic) \
1034 macro(MemMoveInst) \
1039 macro(ExtractElementInst) \
1040 macro(GetElementPtrInst) \
1041 macro(InsertElementInst) \
1042 macro(InsertValueInst) \
1043 macro(LandingPadInst) \
1046 macro(ShuffleVectorInst) \
1048 macro(TerminatorInst) \
1050 macro(IndirectBrInst) \
1054 macro(UnreachableInst) \
1056 macro(UnaryInstruction) \
1059 macro(BitCastInst) \
1063 macro(FPTruncInst) \
1064 macro(IntToPtrInst) \
1065 macro(PtrToIntInst) \
1071 macro(ExtractValueInst) \
1076 * @defgroup LLVMCCoreValueGeneral General APIs
1078 * Functions in this section work on all LLVMValueRef instances,
1079 * regardless of their sub-type. They correspond to functions available
1086 * Obtain the type of a value.
1088 * @see llvm::Value::getType()
1090 LLVMTypeRef LLVMTypeOf(LLVMValueRef Val);
1093 * Obtain the string name of a value.
1095 * @see llvm::Value::getName()
1097 const char *LLVMGetValueName(LLVMValueRef Val);
1100 * Set the string name of a value.
1102 * @see llvm::Value::setName()
1104 void LLVMSetValueName(LLVMValueRef Val, const char *Name);
1107 * Dump a representation of a value to stderr.
1109 * @see llvm::Value::dump()
1111 void LLVMDumpValue(LLVMValueRef Val);
1114 * Replace all uses of a value with another one.
1116 * @see llvm::Value::replaceAllUsesWith()
1118 void LLVMReplaceAllUsesWith(LLVMValueRef OldVal, LLVMValueRef NewVal);
1121 * Determine whether the specified constant instance is constant.
1123 LLVMBool LLVMIsConstant(LLVMValueRef Val);
1126 * Determine whether a value instance is undefined.
1128 LLVMBool LLVMIsUndef(LLVMValueRef Val);
1131 * Convert value instances between types.
1133 * Internally, a LLVMValueRef is "pinned" to a specific type. This
1134 * series of functions allows you to cast an instance to a specific
1137 * If the cast is not valid for the specified type, NULL is returned.
1139 * @see llvm::dyn_cast_or_null<>
1141 #define LLVM_DECLARE_VALUE_CAST(name) \
1142 LLVMValueRef LLVMIsA##name(LLVMValueRef Val);
1143 LLVM_FOR_EACH_VALUE_SUBCLASS(LLVM_DECLARE_VALUE_CAST)
1150 * @defgroup LLVMCCoreValueUses Usage
1152 * This module defines functions that allow you to inspect the uses of a
1155 * It is possible to obtain a LLVMUseRef for any LLVMValueRef instance.
1156 * Each LLVMUseRef (which corresponds to a llvm::Use instance) holds a
1157 * llvm::User and llvm::Value.
1163 * Obtain the first use of a value.
1165 * Uses are obtained in an iterator fashion. First, call this function
1166 * to obtain a reference to the first use. Then, call LLVMGetNextUse()
1167 * on that instance and all subsequently obtained instances until
1168 * LLVMGetNextUse() returns NULL.
1170 * @see llvm::Value::use_begin()
1172 LLVMUseRef LLVMGetFirstUse(LLVMValueRef Val);
1175 * Obtain the next use of a value.
1177 * This effectively advances the iterator. It returns NULL if you are on
1178 * the final use and no more are available.
1180 LLVMUseRef LLVMGetNextUse(LLVMUseRef U);
1183 * Obtain the user value for a user.
1185 * The returned value corresponds to a llvm::User type.
1187 * @see llvm::Use::getUser()
1189 LLVMValueRef LLVMGetUser(LLVMUseRef U);
1192 * Obtain the value this use corresponds to.
1194 * @see llvm::Use::get().
1196 LLVMValueRef LLVMGetUsedValue(LLVMUseRef U);
1203 * @defgroup LLVMCCoreValueUser User value
1205 * Function in this group pertain to LLVMValueRef instances that descent
1206 * from llvm::User. This includes constants, instructions, and
1213 * Obtain an operand at a specific index in a llvm::User value.
1215 * @see llvm::User::getOperand()
1217 LLVMValueRef LLVMGetOperand(LLVMValueRef Val, unsigned Index);
1220 * Set an operand at a specific index in a llvm::User value.
1222 * @see llvm::User::setOperand()
1224 void LLVMSetOperand(LLVMValueRef User, unsigned Index, LLVMValueRef Val);
1227 * Obtain the number of operands in a llvm::User value.
1229 * @see llvm::User::getNumOperands()
1231 int LLVMGetNumOperands(LLVMValueRef Val);
1238 * @defgroup LLVMCCoreValueConstant Constants
1240 * This section contains APIs for interacting with LLVMValueRef that
1241 * correspond to llvm::Constant instances.
1243 * These functions will work for any LLVMValueRef in the llvm::Constant
1250 * Obtain a constant value referring to the null instance of a type.
1252 * @see llvm::Constant::getNullValue()
1254 LLVMValueRef LLVMConstNull(LLVMTypeRef Ty); /* all zeroes */
1257 * Obtain a constant value referring to the instance of a type
1258 * consisting of all ones.
1260 * This is only valid for integer types.
1262 * @see llvm::Constant::getAllOnesValue()
1264 LLVMValueRef LLVMConstAllOnes(LLVMTypeRef Ty);
1267 * Obtain a constant value referring to an undefined value of a type.
1269 * @see llvm::UndefValue::get()
1271 LLVMValueRef LLVMGetUndef(LLVMTypeRef Ty);
1274 * Determine whether a value instance is null.
1276 * @see llvm::Constant::isNullValue()
1278 LLVMBool LLVMIsNull(LLVMValueRef Val);
1281 * Obtain a constant that is a constant pointer pointing to NULL for a
1284 LLVMValueRef LLVMConstPointerNull(LLVMTypeRef Ty);
1287 * @defgroup LLVMCCoreValueConstantScalar Scalar constants
1289 * Functions in this group model LLVMValueRef instances that correspond
1290 * to constants referring to scalar types.
1292 * For integer types, the LLVMTypeRef parameter should correspond to a
1293 * llvm::IntegerType instance and the returned LLVMValueRef will
1294 * correspond to a llvm::ConstantInt.
1296 * For floating point types, the LLVMTypeRef returned corresponds to a
1303 * Obtain a constant value for an integer type.
1305 * The returned value corresponds to a llvm::ConstantInt.
1307 * @see llvm::ConstantInt::get()
1309 * @param IntTy Integer type to obtain value of.
1310 * @param N The value the returned instance should refer to.
1311 * @param SignExtend Whether to sign extend the produced value.
1313 LLVMValueRef LLVMConstInt(LLVMTypeRef IntTy, unsigned long long N,
1314 LLVMBool SignExtend);
1317 * Obtain a constant value for an integer of arbitrary precision.
1319 * @see llvm::ConstantInt::get()
1321 LLVMValueRef LLVMConstIntOfArbitraryPrecision(LLVMTypeRef IntTy,
1323 const uint64_t Words[]);
1326 * Obtain a constant value for an integer parsed from a string.
1328 * A similar API, LLVMConstIntOfStringAndSize is also available. If the
1329 * string's length is available, it is preferred to call that function
1332 * @see llvm::ConstantInt::get()
1334 LLVMValueRef LLVMConstIntOfString(LLVMTypeRef IntTy, const char *Text,
1338 * Obtain a constant value for an integer parsed from a string with
1341 * @see llvm::ConstantInt::get()
1343 LLVMValueRef LLVMConstIntOfStringAndSize(LLVMTypeRef IntTy, const char *Text,
1344 unsigned SLen, uint8_t Radix);
1347 * Obtain a constant value referring to a double floating point value.
1349 LLVMValueRef LLVMConstReal(LLVMTypeRef RealTy, double N);
1352 * Obtain a constant for a floating point value parsed from a string.
1354 * A similar API, LLVMConstRealOfStringAndSize is also available. It
1355 * should be used if the input string's length is known.
1357 LLVMValueRef LLVMConstRealOfString(LLVMTypeRef RealTy, const char *Text);
1360 * Obtain a constant for a floating point value parsed from a string.
1362 LLVMValueRef LLVMConstRealOfStringAndSize(LLVMTypeRef RealTy, const char *Text,
1366 * Obtain the zero extended value for an integer constant value.
1368 * @see llvm::ConstantInt::getZExtValue()
1370 unsigned long long LLVMConstIntGetZExtValue(LLVMValueRef ConstantVal);
1373 * Obtain the sign extended value for an integer constant value.
1375 * @see llvm::ConstantInt::getSExtValue()
1377 long long LLVMConstIntGetSExtValue(LLVMValueRef ConstantVal);
1384 * @defgroup LLVMCCoreValueConstantComposite Composite Constants
1386 * Functions in this group operate on composite constants.
1392 * Create a ConstantDataSequential and initialize it with a string.
1394 * @see llvm::ConstantDataArray::getString()
1396 LLVMValueRef LLVMConstStringInContext(LLVMContextRef C, const char *Str,
1397 unsigned Length, LLVMBool DontNullTerminate);
1400 * Create a ConstantDataSequential with string content in the global context.
1402 * This is the same as LLVMConstStringInContext except it operates on the
1405 * @see LLVMConstStringInContext()
1406 * @see llvm::ConstantDataArray::getString()
1408 LLVMValueRef LLVMConstString(const char *Str, unsigned Length,
1409 LLVMBool DontNullTerminate);
1412 * Create an anonymous ConstantStruct with the specified values.
1414 * @see llvm::ConstantStruct::getAnon()
1416 LLVMValueRef LLVMConstStructInContext(LLVMContextRef C,
1417 LLVMValueRef *ConstantVals,
1418 unsigned Count, LLVMBool Packed);
1421 * Create a ConstantStruct in the global Context.
1423 * This is the same as LLVMConstStructInContext except it operates on the
1426 * @see LLVMConstStructInContext()
1428 LLVMValueRef LLVMConstStruct(LLVMValueRef *ConstantVals, unsigned Count,
1432 * Create a ConstantArray from values.
1434 * @see llvm::ConstantArray::get()
1436 LLVMValueRef LLVMConstArray(LLVMTypeRef ElementTy,
1437 LLVMValueRef *ConstantVals, unsigned Length);
1440 * Create a non-anonymous ConstantStruct from values.
1442 * @see llvm::ConstantStruct::get()
1444 LLVMValueRef LLVMConstNamedStruct(LLVMTypeRef StructTy,
1445 LLVMValueRef *ConstantVals,
1449 * Create a ConstantVector from values.
1451 * @see llvm::ConstantVector::get()
1453 LLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals, unsigned Size);
1460 * @defgroup LLVMCCoreValueConstantExpressions Constant Expressions
1462 * Functions in this group correspond to APIs on llvm::ConstantExpr.
1464 * @see llvm::ConstantExpr.
1468 LLVMOpcode LLVMGetConstOpcode(LLVMValueRef ConstantVal);
1469 LLVMValueRef LLVMAlignOf(LLVMTypeRef Ty);
1470 LLVMValueRef LLVMSizeOf(LLVMTypeRef Ty);
1471 LLVMValueRef LLVMConstNeg(LLVMValueRef ConstantVal);
1472 LLVMValueRef LLVMConstNSWNeg(LLVMValueRef ConstantVal);
1473 LLVMValueRef LLVMConstNUWNeg(LLVMValueRef ConstantVal);
1474 LLVMValueRef LLVMConstFNeg(LLVMValueRef ConstantVal);
1475 LLVMValueRef LLVMConstNot(LLVMValueRef ConstantVal);
1476 LLVMValueRef LLVMConstAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1477 LLVMValueRef LLVMConstNSWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1478 LLVMValueRef LLVMConstNUWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1479 LLVMValueRef LLVMConstFAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1480 LLVMValueRef LLVMConstSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1481 LLVMValueRef LLVMConstNSWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1482 LLVMValueRef LLVMConstNUWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1483 LLVMValueRef LLVMConstFSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1484 LLVMValueRef LLVMConstMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1485 LLVMValueRef LLVMConstNSWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1486 LLVMValueRef LLVMConstNUWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1487 LLVMValueRef LLVMConstFMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1488 LLVMValueRef LLVMConstUDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1489 LLVMValueRef LLVMConstSDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1490 LLVMValueRef LLVMConstExactSDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1491 LLVMValueRef LLVMConstFDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1492 LLVMValueRef LLVMConstURem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1493 LLVMValueRef LLVMConstSRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1494 LLVMValueRef LLVMConstFRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1495 LLVMValueRef LLVMConstAnd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1496 LLVMValueRef LLVMConstOr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1497 LLVMValueRef LLVMConstXor(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1498 LLVMValueRef LLVMConstICmp(LLVMIntPredicate Predicate,
1499 LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1500 LLVMValueRef LLVMConstFCmp(LLVMRealPredicate Predicate,
1501 LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1502 LLVMValueRef LLVMConstShl(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1503 LLVMValueRef LLVMConstLShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1504 LLVMValueRef LLVMConstAShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1505 LLVMValueRef LLVMConstGEP(LLVMValueRef ConstantVal,
1506 LLVMValueRef *ConstantIndices, unsigned NumIndices);
1507 LLVMValueRef LLVMConstInBoundsGEP(LLVMValueRef ConstantVal,
1508 LLVMValueRef *ConstantIndices,
1509 unsigned NumIndices);
1510 LLVMValueRef LLVMConstTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1511 LLVMValueRef LLVMConstSExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1512 LLVMValueRef LLVMConstZExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1513 LLVMValueRef LLVMConstFPTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1514 LLVMValueRef LLVMConstFPExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1515 LLVMValueRef LLVMConstUIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1516 LLVMValueRef LLVMConstSIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1517 LLVMValueRef LLVMConstFPToUI(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1518 LLVMValueRef LLVMConstFPToSI(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1519 LLVMValueRef LLVMConstPtrToInt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1520 LLVMValueRef LLVMConstIntToPtr(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1521 LLVMValueRef LLVMConstBitCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1522 LLVMValueRef LLVMConstZExtOrBitCast(LLVMValueRef ConstantVal,
1523 LLVMTypeRef ToType);
1524 LLVMValueRef LLVMConstSExtOrBitCast(LLVMValueRef ConstantVal,
1525 LLVMTypeRef ToType);
1526 LLVMValueRef LLVMConstTruncOrBitCast(LLVMValueRef ConstantVal,
1527 LLVMTypeRef ToType);
1528 LLVMValueRef LLVMConstPointerCast(LLVMValueRef ConstantVal,
1529 LLVMTypeRef ToType);
1530 LLVMValueRef LLVMConstIntCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType,
1532 LLVMValueRef LLVMConstFPCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1533 LLVMValueRef LLVMConstSelect(LLVMValueRef ConstantCondition,
1534 LLVMValueRef ConstantIfTrue,
1535 LLVMValueRef ConstantIfFalse);
1536 LLVMValueRef LLVMConstExtractElement(LLVMValueRef VectorConstant,
1537 LLVMValueRef IndexConstant);
1538 LLVMValueRef LLVMConstInsertElement(LLVMValueRef VectorConstant,
1539 LLVMValueRef ElementValueConstant,
1540 LLVMValueRef IndexConstant);
1541 LLVMValueRef LLVMConstShuffleVector(LLVMValueRef VectorAConstant,
1542 LLVMValueRef VectorBConstant,
1543 LLVMValueRef MaskConstant);
1544 LLVMValueRef LLVMConstExtractValue(LLVMValueRef AggConstant, unsigned *IdxList,
1546 LLVMValueRef LLVMConstInsertValue(LLVMValueRef AggConstant,
1547 LLVMValueRef ElementValueConstant,
1548 unsigned *IdxList, unsigned NumIdx);
1549 LLVMValueRef LLVMConstInlineAsm(LLVMTypeRef Ty,
1550 const char *AsmString, const char *Constraints,
1551 LLVMBool HasSideEffects, LLVMBool IsAlignStack);
1552 LLVMValueRef LLVMBlockAddress(LLVMValueRef F, LLVMBasicBlockRef BB);
1559 * @defgroup LLVMCCoreValueConstantGlobals Global Values
1561 * This group contains functions that operate on global values. Functions in
1562 * this group relate to functions in the llvm::GlobalValue class tree.
1564 * @see llvm::GlobalValue
1569 LLVMModuleRef LLVMGetGlobalParent(LLVMValueRef Global);
1570 LLVMBool LLVMIsDeclaration(LLVMValueRef Global);
1571 LLVMLinkage LLVMGetLinkage(LLVMValueRef Global);
1572 void LLVMSetLinkage(LLVMValueRef Global, LLVMLinkage Linkage);
1573 const char *LLVMGetSection(LLVMValueRef Global);
1574 void LLVMSetSection(LLVMValueRef Global, const char *Section);
1575 LLVMVisibility LLVMGetVisibility(LLVMValueRef Global);
1576 void LLVMSetVisibility(LLVMValueRef Global, LLVMVisibility Viz);
1577 unsigned LLVMGetAlignment(LLVMValueRef Global);
1578 void LLVMSetAlignment(LLVMValueRef Global, unsigned Bytes);
1581 * @defgroup LLVMCoreValueConstantGlobalVariable Global Variables
1583 * This group contains functions that operate on global variable values.
1585 * @see llvm::GlobalVariable
1589 LLVMValueRef LLVMAddGlobal(LLVMModuleRef M, LLVMTypeRef Ty, const char *Name);
1590 LLVMValueRef LLVMAddGlobalInAddressSpace(LLVMModuleRef M, LLVMTypeRef Ty,
1592 unsigned AddressSpace);
1593 LLVMValueRef LLVMGetNamedGlobal(LLVMModuleRef M, const char *Name);
1594 LLVMValueRef LLVMGetFirstGlobal(LLVMModuleRef M);
1595 LLVMValueRef LLVMGetLastGlobal(LLVMModuleRef M);
1596 LLVMValueRef LLVMGetNextGlobal(LLVMValueRef GlobalVar);
1597 LLVMValueRef LLVMGetPreviousGlobal(LLVMValueRef GlobalVar);
1598 void LLVMDeleteGlobal(LLVMValueRef GlobalVar);
1599 LLVMValueRef LLVMGetInitializer(LLVMValueRef GlobalVar);
1600 void LLVMSetInitializer(LLVMValueRef GlobalVar, LLVMValueRef ConstantVal);
1601 LLVMBool LLVMIsThreadLocal(LLVMValueRef GlobalVar);
1602 void LLVMSetThreadLocal(LLVMValueRef GlobalVar, LLVMBool IsThreadLocal);
1603 LLVMBool LLVMIsGlobalConstant(LLVMValueRef GlobalVar);
1604 void LLVMSetGlobalConstant(LLVMValueRef GlobalVar, LLVMBool IsConstant);
1605 LLVMThreadLocalMode LLVMGetThreadLocalMode(LLVMValueRef GlobalVar);
1606 void LLVMSetThreadLocalMode(LLVMValueRef GlobalVar, LLVMThreadLocalMode Mode);
1607 LLVMBool LLVMIsExternallyInitialized(LLVMValueRef GlobalVar);
1608 void LLVMSetExternallyInitialized(LLVMValueRef GlobalVar, LLVMBool IsExtInit);
1615 * @defgroup LLVMCoreValueConstantGlobalAlias Global Aliases
1617 * This group contains function that operate on global alias values.
1619 * @see llvm::GlobalAlias
1623 LLVMValueRef LLVMAddAlias(LLVMModuleRef M, LLVMTypeRef Ty, LLVMValueRef Aliasee,
1631 * @defgroup LLVMCCoreValueFunction Function values
1633 * Functions in this group operate on LLVMValueRef instances that
1634 * correspond to llvm::Function instances.
1636 * @see llvm::Function
1642 * Remove a function from its containing module and deletes it.
1644 * @see llvm::Function::eraseFromParent()
1646 void LLVMDeleteFunction(LLVMValueRef Fn);
1649 * Obtain the ID number from a function instance.
1651 * @see llvm::Function::getIntrinsicID()
1653 unsigned LLVMGetIntrinsicID(LLVMValueRef Fn);
1656 * Obtain the calling function of a function.
1658 * The returned value corresponds to the LLVMCallConv enumeration.
1660 * @see llvm::Function::getCallingConv()
1662 unsigned LLVMGetFunctionCallConv(LLVMValueRef Fn);
1665 * Set the calling convention of a function.
1667 * @see llvm::Function::setCallingConv()
1669 * @param Fn Function to operate on
1670 * @param CC LLVMCallConv to set calling convention to
1672 void LLVMSetFunctionCallConv(LLVMValueRef Fn, unsigned CC);
1675 * Obtain the name of the garbage collector to use during code
1678 * @see llvm::Function::getGC()
1680 const char *LLVMGetGC(LLVMValueRef Fn);
1683 * Define the garbage collector to use during code generation.
1685 * @see llvm::Function::setGC()
1687 void LLVMSetGC(LLVMValueRef Fn, const char *Name);
1690 * Add an attribute to a function.
1692 * @see llvm::Function::addAttribute()
1694 void LLVMAddFunctionAttr(LLVMValueRef Fn, LLVMAttribute PA);
1697 * Add a target-dependent attribute to a fuction
1698 * @see llvm::AttrBuilder::addAttribute()
1700 void LLVMAddTargetDependentFunctionAttr(LLVMValueRef Fn, const char *A,
1704 * Obtain an attribute from a function.
1706 * @see llvm::Function::getAttributes()
1708 LLVMAttribute LLVMGetFunctionAttr(LLVMValueRef Fn);
1711 * Remove an attribute from a function.
1713 void LLVMRemoveFunctionAttr(LLVMValueRef Fn, LLVMAttribute PA);
1716 * @defgroup LLVMCCoreValueFunctionParameters Function Parameters
1718 * Functions in this group relate to arguments/parameters on functions.
1720 * Functions in this group expect LLVMValueRef instances that correspond
1721 * to llvm::Function instances.
1727 * Obtain the number of parameters in a function.
1729 * @see llvm::Function::arg_size()
1731 unsigned LLVMCountParams(LLVMValueRef Fn);
1734 * Obtain the parameters in a function.
1736 * The takes a pointer to a pre-allocated array of LLVMValueRef that is
1737 * at least LLVMCountParams() long. This array will be filled with
1738 * LLVMValueRef instances which correspond to the parameters the
1739 * function receives. Each LLVMValueRef corresponds to a llvm::Argument
1742 * @see llvm::Function::arg_begin()
1744 void LLVMGetParams(LLVMValueRef Fn, LLVMValueRef *Params);
1747 * Obtain the parameter at the specified index.
1749 * Parameters are indexed from 0.
1751 * @see llvm::Function::arg_begin()
1753 LLVMValueRef LLVMGetParam(LLVMValueRef Fn, unsigned Index);
1756 * Obtain the function to which this argument belongs.
1758 * Unlike other functions in this group, this one takes a LLVMValueRef
1759 * that corresponds to a llvm::Attribute.
1761 * The returned LLVMValueRef is the llvm::Function to which this
1764 LLVMValueRef LLVMGetParamParent(LLVMValueRef Inst);
1767 * Obtain the first parameter to a function.
1769 * @see llvm::Function::arg_begin()
1771 LLVMValueRef LLVMGetFirstParam(LLVMValueRef Fn);
1774 * Obtain the last parameter to a function.
1776 * @see llvm::Function::arg_end()
1778 LLVMValueRef LLVMGetLastParam(LLVMValueRef Fn);
1781 * Obtain the next parameter to a function.
1783 * This takes a LLVMValueRef obtained from LLVMGetFirstParam() (which is
1784 * actually a wrapped iterator) and obtains the next parameter from the
1785 * underlying iterator.
1787 LLVMValueRef LLVMGetNextParam(LLVMValueRef Arg);
1790 * Obtain the previous parameter to a function.
1792 * This is the opposite of LLVMGetNextParam().
1794 LLVMValueRef LLVMGetPreviousParam(LLVMValueRef Arg);
1797 * Add an attribute to a function argument.
1799 * @see llvm::Argument::addAttr()
1801 void LLVMAddAttribute(LLVMValueRef Arg, LLVMAttribute PA);
1804 * Remove an attribute from a function argument.
1806 * @see llvm::Argument::removeAttr()
1808 void LLVMRemoveAttribute(LLVMValueRef Arg, LLVMAttribute PA);
1811 * Get an attribute from a function argument.
1813 LLVMAttribute LLVMGetAttribute(LLVMValueRef Arg);
1816 * Set the alignment for a function parameter.
1818 * @see llvm::Argument::addAttr()
1819 * @see llvm::AttrBuilder::addAlignmentAttr()
1821 void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned align);
1840 * @defgroup LLVMCCoreValueMetadata Metadata
1846 * Obtain a MDString value from a context.
1848 * The returned instance corresponds to the llvm::MDString class.
1850 * The instance is specified by string data of a specified length. The
1851 * string content is copied, so the backing memory can be freed after
1852 * this function returns.
1854 LLVMValueRef LLVMMDStringInContext(LLVMContextRef C, const char *Str,
1858 * Obtain a MDString value from the global context.
1860 LLVMValueRef LLVMMDString(const char *Str, unsigned SLen);
1863 * Obtain a MDNode value from a context.
1865 * The returned value corresponds to the llvm::MDNode class.
1867 LLVMValueRef LLVMMDNodeInContext(LLVMContextRef C, LLVMValueRef *Vals,
1871 * Obtain a MDNode value from the global context.
1873 LLVMValueRef LLVMMDNode(LLVMValueRef *Vals, unsigned Count);
1876 * Obtain the underlying string from a MDString value.
1878 * @param V Instance to obtain string from.
1879 * @param Len Memory address which will hold length of returned string.
1880 * @return String data in MDString.
1882 const char *LLVMGetMDString(LLVMValueRef V, unsigned* Len);
1885 * Obtain the number of operands from an MDNode value.
1887 * @param V MDNode to get number of operands from.
1888 * @return Number of operands of the MDNode.
1890 unsigned LLVMGetMDNodeNumOperands(LLVMValueRef V);
1893 * Obtain the given MDNode's operands.
1895 * The passed LLVMValueRef pointer should point to enough memory to hold all of
1896 * the operands of the given MDNode (see LLVMGetMDNodeNumOperands) as
1897 * LLVMValueRefs. This memory will be populated with the LLVMValueRefs of the
1898 * MDNode's operands.
1900 * @param V MDNode to get the operands from.
1901 * @param Dest Destination array for operands.
1903 void LLVMGetMDNodeOperands(LLVMValueRef V, LLVMValueRef *Dest);
1910 * @defgroup LLVMCCoreValueBasicBlock Basic Block
1912 * A basic block represents a single entry single exit section of code.
1913 * Basic blocks contain a list of instructions which form the body of
1916 * Basic blocks belong to functions. They have the type of label.
1918 * Basic blocks are themselves values. However, the C API models them as
1919 * LLVMBasicBlockRef.
1921 * @see llvm::BasicBlock
1927 * Convert a basic block instance to a value type.
1929 LLVMValueRef LLVMBasicBlockAsValue(LLVMBasicBlockRef BB);
1932 * Determine whether a LLVMValueRef is itself a basic block.
1934 LLVMBool LLVMValueIsBasicBlock(LLVMValueRef Val);
1937 * Convert a LLVMValueRef to a LLVMBasicBlockRef instance.
1939 LLVMBasicBlockRef LLVMValueAsBasicBlock(LLVMValueRef Val);
1942 * Obtain the function to which a basic block belongs.
1944 * @see llvm::BasicBlock::getParent()
1946 LLVMValueRef LLVMGetBasicBlockParent(LLVMBasicBlockRef BB);
1949 * Obtain the terminator instruction for a basic block.
1951 * If the basic block does not have a terminator (it is not well-formed
1952 * if it doesn't), then NULL is returned.
1954 * The returned LLVMValueRef corresponds to a llvm::TerminatorInst.
1956 * @see llvm::BasicBlock::getTerminator()
1958 LLVMValueRef LLVMGetBasicBlockTerminator(LLVMBasicBlockRef BB);
1961 * Obtain the number of basic blocks in a function.
1963 * @param Fn Function value to operate on.
1965 unsigned LLVMCountBasicBlocks(LLVMValueRef Fn);
1968 * Obtain all of the basic blocks in a function.
1970 * This operates on a function value. The BasicBlocks parameter is a
1971 * pointer to a pre-allocated array of LLVMBasicBlockRef of at least
1972 * LLVMCountBasicBlocks() in length. This array is populated with
1973 * LLVMBasicBlockRef instances.
1975 void LLVMGetBasicBlocks(LLVMValueRef Fn, LLVMBasicBlockRef *BasicBlocks);
1978 * Obtain the first basic block in a function.
1980 * The returned basic block can be used as an iterator. You will likely
1981 * eventually call into LLVMGetNextBasicBlock() with it.
1983 * @see llvm::Function::begin()
1985 LLVMBasicBlockRef LLVMGetFirstBasicBlock(LLVMValueRef Fn);
1988 * Obtain the last basic block in a function.
1990 * @see llvm::Function::end()
1992 LLVMBasicBlockRef LLVMGetLastBasicBlock(LLVMValueRef Fn);
1995 * Advance a basic block iterator.
1997 LLVMBasicBlockRef LLVMGetNextBasicBlock(LLVMBasicBlockRef BB);
2000 * Go backwards in a basic block iterator.
2002 LLVMBasicBlockRef LLVMGetPreviousBasicBlock(LLVMBasicBlockRef BB);
2005 * Obtain the basic block that corresponds to the entry point of a
2008 * @see llvm::Function::getEntryBlock()
2010 LLVMBasicBlockRef LLVMGetEntryBasicBlock(LLVMValueRef Fn);
2013 * Append a basic block to the end of a function.
2015 * @see llvm::BasicBlock::Create()
2017 LLVMBasicBlockRef LLVMAppendBasicBlockInContext(LLVMContextRef C,
2022 * Append a basic block to the end of a function using the global
2025 * @see llvm::BasicBlock::Create()
2027 LLVMBasicBlockRef LLVMAppendBasicBlock(LLVMValueRef Fn, const char *Name);
2030 * Insert a basic block in a function before another basic block.
2032 * The function to add to is determined by the function of the
2033 * passed basic block.
2035 * @see llvm::BasicBlock::Create()
2037 LLVMBasicBlockRef LLVMInsertBasicBlockInContext(LLVMContextRef C,
2038 LLVMBasicBlockRef BB,
2042 * Insert a basic block in a function using the global context.
2044 * @see llvm::BasicBlock::Create()
2046 LLVMBasicBlockRef LLVMInsertBasicBlock(LLVMBasicBlockRef InsertBeforeBB,
2050 * Remove a basic block from a function and delete it.
2052 * This deletes the basic block from its containing function and deletes
2053 * the basic block itself.
2055 * @see llvm::BasicBlock::eraseFromParent()
2057 void LLVMDeleteBasicBlock(LLVMBasicBlockRef BB);
2060 * Remove a basic block from a function.
2062 * This deletes the basic block from its containing function but keep
2063 * the basic block alive.
2065 * @see llvm::BasicBlock::removeFromParent()
2067 void LLVMRemoveBasicBlockFromParent(LLVMBasicBlockRef BB);
2070 * Move a basic block to before another one.
2072 * @see llvm::BasicBlock::moveBefore()
2074 void LLVMMoveBasicBlockBefore(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos);
2077 * Move a basic block to after another one.
2079 * @see llvm::BasicBlock::moveAfter()
2081 void LLVMMoveBasicBlockAfter(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos);
2084 * Obtain the first instruction in a basic block.
2086 * The returned LLVMValueRef corresponds to a llvm::Instruction
2089 LLVMValueRef LLVMGetFirstInstruction(LLVMBasicBlockRef BB);
2092 * Obtain the last instruction in a basic block.
2094 * The returned LLVMValueRef corresponds to a LLVM:Instruction.
2096 LLVMValueRef LLVMGetLastInstruction(LLVMBasicBlockRef BB);
2103 * @defgroup LLVMCCoreValueInstruction Instructions
2105 * Functions in this group relate to the inspection and manipulation of
2106 * individual instructions.
2108 * In the C++ API, an instruction is modeled by llvm::Instruction. This
2109 * class has a large number of descendents. llvm::Instruction is a
2110 * llvm::Value and in the C API, instructions are modeled by
2113 * This group also contains sub-groups which operate on specific
2114 * llvm::Instruction types, e.g. llvm::CallInst.
2120 * Determine whether an instruction has any metadata attached.
2122 int LLVMHasMetadata(LLVMValueRef Val);
2125 * Return metadata associated with an instruction value.
2127 LLVMValueRef LLVMGetMetadata(LLVMValueRef Val, unsigned KindID);
2130 * Set metadata associated with an instruction value.
2132 void LLVMSetMetadata(LLVMValueRef Val, unsigned KindID, LLVMValueRef Node);
2135 * Obtain the basic block to which an instruction belongs.
2137 * @see llvm::Instruction::getParent()
2139 LLVMBasicBlockRef LLVMGetInstructionParent(LLVMValueRef Inst);
2142 * Obtain the instruction that occurs after the one specified.
2144 * The next instruction will be from the same basic block.
2146 * If this is the last instruction in a basic block, NULL will be
2149 LLVMValueRef LLVMGetNextInstruction(LLVMValueRef Inst);
2152 * Obtain the instruction that occurred before this one.
2154 * If the instruction is the first instruction in a basic block, NULL
2157 LLVMValueRef LLVMGetPreviousInstruction(LLVMValueRef Inst);
2160 * Remove and delete an instruction.
2162 * The instruction specified is removed from its containing building
2163 * block and then deleted.
2165 * @see llvm::Instruction::eraseFromParent()
2167 void LLVMInstructionEraseFromParent(LLVMValueRef Inst);
2170 * Obtain the code opcode for an individual instruction.
2172 * @see llvm::Instruction::getOpCode()
2174 LLVMOpcode LLVMGetInstructionOpcode(LLVMValueRef Inst);
2177 * Obtain the predicate of an instruction.
2179 * This is only valid for instructions that correspond to llvm::ICmpInst
2180 * or llvm::ConstantExpr whose opcode is llvm::Instruction::ICmp.
2182 * @see llvm::ICmpInst::getPredicate()
2184 LLVMIntPredicate LLVMGetICmpPredicate(LLVMValueRef Inst);
2187 * @defgroup LLVMCCoreValueInstructionCall Call Sites and Invocations
2189 * Functions in this group apply to instructions that refer to call
2190 * sites and invocations. These correspond to C++ types in the
2191 * llvm::CallInst class tree.
2197 * Set the calling convention for a call instruction.
2199 * This expects an LLVMValueRef that corresponds to a llvm::CallInst or
2202 * @see llvm::CallInst::setCallingConv()
2203 * @see llvm::InvokeInst::setCallingConv()
2205 void LLVMSetInstructionCallConv(LLVMValueRef Instr, unsigned CC);
2208 * Obtain the calling convention for a call instruction.
2210 * This is the opposite of LLVMSetInstructionCallConv(). Reads its
2213 * @see LLVMSetInstructionCallConv()
2215 unsigned LLVMGetInstructionCallConv(LLVMValueRef Instr);
2218 void LLVMAddInstrAttribute(LLVMValueRef Instr, unsigned index, LLVMAttribute);
2219 void LLVMRemoveInstrAttribute(LLVMValueRef Instr, unsigned index,
2221 void LLVMSetInstrParamAlignment(LLVMValueRef Instr, unsigned index,
2225 * Obtain whether a call instruction is a tail call.
2227 * This only works on llvm::CallInst instructions.
2229 * @see llvm::CallInst::isTailCall()
2231 LLVMBool LLVMIsTailCall(LLVMValueRef CallInst);
2234 * Set whether a call instruction is a tail call.
2236 * This only works on llvm::CallInst instructions.
2238 * @see llvm::CallInst::setTailCall()
2240 void LLVMSetTailCall(LLVMValueRef CallInst, LLVMBool IsTailCall);
2247 * Obtain the default destination basic block of a switch instruction.
2249 * This only works on llvm::SwitchInst instructions.
2251 * @see llvm::SwitchInst::getDefaultDest()
2253 LLVMBasicBlockRef LLVMGetSwitchDefaultDest(LLVMValueRef SwitchInstr);
2256 * @defgroup LLVMCCoreValueInstructionPHINode PHI Nodes
2258 * Functions in this group only apply to instructions that map to
2259 * llvm::PHINode instances.
2265 * Add an incoming value to the end of a PHI list.
2267 void LLVMAddIncoming(LLVMValueRef PhiNode, LLVMValueRef *IncomingValues,
2268 LLVMBasicBlockRef *IncomingBlocks, unsigned Count);
2271 * Obtain the number of incoming basic blocks to a PHI node.
2273 unsigned LLVMCountIncoming(LLVMValueRef PhiNode);
2276 * Obtain an incoming value to a PHI node as a LLVMValueRef.
2278 LLVMValueRef LLVMGetIncomingValue(LLVMValueRef PhiNode, unsigned Index);
2281 * Obtain an incoming value to a PHI node as a LLVMBasicBlockRef.
2283 LLVMBasicBlockRef LLVMGetIncomingBlock(LLVMValueRef PhiNode, unsigned Index);
2298 * @defgroup LLVMCCoreInstructionBuilder Instruction Builders
2300 * An instruction builder represents a point within a basic block and is
2301 * the exclusive means of building instructions using the C interface.
2306 LLVMBuilderRef LLVMCreateBuilderInContext(LLVMContextRef C);
2307 LLVMBuilderRef LLVMCreateBuilder(void);
2308 void LLVMPositionBuilder(LLVMBuilderRef Builder, LLVMBasicBlockRef Block,
2309 LLVMValueRef Instr);
2310 void LLVMPositionBuilderBefore(LLVMBuilderRef Builder, LLVMValueRef Instr);
2311 void LLVMPositionBuilderAtEnd(LLVMBuilderRef Builder, LLVMBasicBlockRef Block);
2312 LLVMBasicBlockRef LLVMGetInsertBlock(LLVMBuilderRef Builder);
2313 void LLVMClearInsertionPosition(LLVMBuilderRef Builder);
2314 void LLVMInsertIntoBuilder(LLVMBuilderRef Builder, LLVMValueRef Instr);
2315 void LLVMInsertIntoBuilderWithName(LLVMBuilderRef Builder, LLVMValueRef Instr,
2317 void LLVMDisposeBuilder(LLVMBuilderRef Builder);
2320 void LLVMSetCurrentDebugLocation(LLVMBuilderRef Builder, LLVMValueRef L);
2321 LLVMValueRef LLVMGetCurrentDebugLocation(LLVMBuilderRef Builder);
2322 void LLVMSetInstDebugLocation(LLVMBuilderRef Builder, LLVMValueRef Inst);
2325 LLVMValueRef LLVMBuildRetVoid(LLVMBuilderRef);
2326 LLVMValueRef LLVMBuildRet(LLVMBuilderRef, LLVMValueRef V);
2327 LLVMValueRef LLVMBuildAggregateRet(LLVMBuilderRef, LLVMValueRef *RetVals,
2329 LLVMValueRef LLVMBuildBr(LLVMBuilderRef, LLVMBasicBlockRef Dest);
2330 LLVMValueRef LLVMBuildCondBr(LLVMBuilderRef, LLVMValueRef If,
2331 LLVMBasicBlockRef Then, LLVMBasicBlockRef Else);
2332 LLVMValueRef LLVMBuildSwitch(LLVMBuilderRef, LLVMValueRef V,
2333 LLVMBasicBlockRef Else, unsigned NumCases);
2334 LLVMValueRef LLVMBuildIndirectBr(LLVMBuilderRef B, LLVMValueRef Addr,
2336 LLVMValueRef LLVMBuildInvoke(LLVMBuilderRef, LLVMValueRef Fn,
2337 LLVMValueRef *Args, unsigned NumArgs,
2338 LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch,
2340 LLVMValueRef LLVMBuildLandingPad(LLVMBuilderRef B, LLVMTypeRef Ty,
2341 LLVMValueRef PersFn, unsigned NumClauses,
2343 LLVMValueRef LLVMBuildResume(LLVMBuilderRef B, LLVMValueRef Exn);
2344 LLVMValueRef LLVMBuildUnreachable(LLVMBuilderRef);
2346 /* Add a case to the switch instruction */
2347 void LLVMAddCase(LLVMValueRef Switch, LLVMValueRef OnVal,
2348 LLVMBasicBlockRef Dest);
2350 /* Add a destination to the indirectbr instruction */
2351 void LLVMAddDestination(LLVMValueRef IndirectBr, LLVMBasicBlockRef Dest);
2353 /* Add a catch or filter clause to the landingpad instruction */
2354 void LLVMAddClause(LLVMValueRef LandingPad, LLVMValueRef ClauseVal);
2356 /* Set the 'cleanup' flag in the landingpad instruction */
2357 void LLVMSetCleanup(LLVMValueRef LandingPad, LLVMBool Val);
2360 LLVMValueRef LLVMBuildAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2362 LLVMValueRef LLVMBuildNSWAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2364 LLVMValueRef LLVMBuildNUWAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2366 LLVMValueRef LLVMBuildFAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2368 LLVMValueRef LLVMBuildSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2370 LLVMValueRef LLVMBuildNSWSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2372 LLVMValueRef LLVMBuildNUWSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2374 LLVMValueRef LLVMBuildFSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2376 LLVMValueRef LLVMBuildMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2378 LLVMValueRef LLVMBuildNSWMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2380 LLVMValueRef LLVMBuildNUWMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2382 LLVMValueRef LLVMBuildFMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2384 LLVMValueRef LLVMBuildUDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2386 LLVMValueRef LLVMBuildSDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2388 LLVMValueRef LLVMBuildExactSDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2390 LLVMValueRef LLVMBuildFDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2392 LLVMValueRef LLVMBuildURem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2394 LLVMValueRef LLVMBuildSRem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2396 LLVMValueRef LLVMBuildFRem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2398 LLVMValueRef LLVMBuildShl(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2400 LLVMValueRef LLVMBuildLShr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2402 LLVMValueRef LLVMBuildAShr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2404 LLVMValueRef LLVMBuildAnd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2406 LLVMValueRef LLVMBuildOr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2408 LLVMValueRef LLVMBuildXor(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2410 LLVMValueRef LLVMBuildBinOp(LLVMBuilderRef B, LLVMOpcode Op,
2411 LLVMValueRef LHS, LLVMValueRef RHS,
2413 LLVMValueRef LLVMBuildNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name);
2414 LLVMValueRef LLVMBuildNSWNeg(LLVMBuilderRef B, LLVMValueRef V,
2416 LLVMValueRef LLVMBuildNUWNeg(LLVMBuilderRef B, LLVMValueRef V,
2418 LLVMValueRef LLVMBuildFNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name);
2419 LLVMValueRef LLVMBuildNot(LLVMBuilderRef, LLVMValueRef V, const char *Name);
2422 LLVMValueRef LLVMBuildMalloc(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
2423 LLVMValueRef LLVMBuildArrayMalloc(LLVMBuilderRef, LLVMTypeRef Ty,
2424 LLVMValueRef Val, const char *Name);
2425 LLVMValueRef LLVMBuildAlloca(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
2426 LLVMValueRef LLVMBuildArrayAlloca(LLVMBuilderRef, LLVMTypeRef Ty,
2427 LLVMValueRef Val, const char *Name);
2428 LLVMValueRef LLVMBuildFree(LLVMBuilderRef, LLVMValueRef PointerVal);
2429 LLVMValueRef LLVMBuildLoad(LLVMBuilderRef, LLVMValueRef PointerVal,
2431 LLVMValueRef LLVMBuildStore(LLVMBuilderRef, LLVMValueRef Val, LLVMValueRef Ptr);
2432 LLVMValueRef LLVMBuildGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
2433 LLVMValueRef *Indices, unsigned NumIndices,
2435 LLVMValueRef LLVMBuildInBoundsGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
2436 LLVMValueRef *Indices, unsigned NumIndices,
2438 LLVMValueRef LLVMBuildStructGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
2439 unsigned Idx, const char *Name);
2440 LLVMValueRef LLVMBuildGlobalString(LLVMBuilderRef B, const char *Str,
2442 LLVMValueRef LLVMBuildGlobalStringPtr(LLVMBuilderRef B, const char *Str,
2444 LLVMBool LLVMGetVolatile(LLVMValueRef MemoryAccessInst);
2445 void LLVMSetVolatile(LLVMValueRef MemoryAccessInst, LLVMBool IsVolatile);
2448 LLVMValueRef LLVMBuildTrunc(LLVMBuilderRef, LLVMValueRef Val,
2449 LLVMTypeRef DestTy, const char *Name);
2450 LLVMValueRef LLVMBuildZExt(LLVMBuilderRef, LLVMValueRef Val,
2451 LLVMTypeRef DestTy, const char *Name);
2452 LLVMValueRef LLVMBuildSExt(LLVMBuilderRef, LLVMValueRef Val,
2453 LLVMTypeRef DestTy, const char *Name);
2454 LLVMValueRef LLVMBuildFPToUI(LLVMBuilderRef, LLVMValueRef Val,
2455 LLVMTypeRef DestTy, const char *Name);
2456 LLVMValueRef LLVMBuildFPToSI(LLVMBuilderRef, LLVMValueRef Val,
2457 LLVMTypeRef DestTy, const char *Name);
2458 LLVMValueRef LLVMBuildUIToFP(LLVMBuilderRef, LLVMValueRef Val,
2459 LLVMTypeRef DestTy, const char *Name);
2460 LLVMValueRef LLVMBuildSIToFP(LLVMBuilderRef, LLVMValueRef Val,
2461 LLVMTypeRef DestTy, const char *Name);
2462 LLVMValueRef LLVMBuildFPTrunc(LLVMBuilderRef, LLVMValueRef Val,
2463 LLVMTypeRef DestTy, const char *Name);
2464 LLVMValueRef LLVMBuildFPExt(LLVMBuilderRef, LLVMValueRef Val,
2465 LLVMTypeRef DestTy, const char *Name);
2466 LLVMValueRef LLVMBuildPtrToInt(LLVMBuilderRef, LLVMValueRef Val,
2467 LLVMTypeRef DestTy, const char *Name);
2468 LLVMValueRef LLVMBuildIntToPtr(LLVMBuilderRef, LLVMValueRef Val,
2469 LLVMTypeRef DestTy, const char *Name);
2470 LLVMValueRef LLVMBuildBitCast(LLVMBuilderRef, LLVMValueRef Val,
2471 LLVMTypeRef DestTy, const char *Name);
2472 LLVMValueRef LLVMBuildZExtOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
2473 LLVMTypeRef DestTy, const char *Name);
2474 LLVMValueRef LLVMBuildSExtOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
2475 LLVMTypeRef DestTy, const char *Name);
2476 LLVMValueRef LLVMBuildTruncOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
2477 LLVMTypeRef DestTy, const char *Name);
2478 LLVMValueRef LLVMBuildCast(LLVMBuilderRef B, LLVMOpcode Op, LLVMValueRef Val,
2479 LLVMTypeRef DestTy, const char *Name);
2480 LLVMValueRef LLVMBuildPointerCast(LLVMBuilderRef, LLVMValueRef Val,
2481 LLVMTypeRef DestTy, const char *Name);
2482 LLVMValueRef LLVMBuildIntCast(LLVMBuilderRef, LLVMValueRef Val, /*Signed cast!*/
2483 LLVMTypeRef DestTy, const char *Name);
2484 LLVMValueRef LLVMBuildFPCast(LLVMBuilderRef, LLVMValueRef Val,
2485 LLVMTypeRef DestTy, const char *Name);
2488 LLVMValueRef LLVMBuildICmp(LLVMBuilderRef, LLVMIntPredicate Op,
2489 LLVMValueRef LHS, LLVMValueRef RHS,
2491 LLVMValueRef LLVMBuildFCmp(LLVMBuilderRef, LLVMRealPredicate Op,
2492 LLVMValueRef LHS, LLVMValueRef RHS,
2495 /* Miscellaneous instructions */
2496 LLVMValueRef LLVMBuildPhi(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
2497 LLVMValueRef LLVMBuildCall(LLVMBuilderRef, LLVMValueRef Fn,
2498 LLVMValueRef *Args, unsigned NumArgs,
2500 LLVMValueRef LLVMBuildSelect(LLVMBuilderRef, LLVMValueRef If,
2501 LLVMValueRef Then, LLVMValueRef Else,
2503 LLVMValueRef LLVMBuildVAArg(LLVMBuilderRef, LLVMValueRef List, LLVMTypeRef Ty,
2505 LLVMValueRef LLVMBuildExtractElement(LLVMBuilderRef, LLVMValueRef VecVal,
2506 LLVMValueRef Index, const char *Name);
2507 LLVMValueRef LLVMBuildInsertElement(LLVMBuilderRef, LLVMValueRef VecVal,
2508 LLVMValueRef EltVal, LLVMValueRef Index,
2510 LLVMValueRef LLVMBuildShuffleVector(LLVMBuilderRef, LLVMValueRef V1,
2511 LLVMValueRef V2, LLVMValueRef Mask,
2513 LLVMValueRef LLVMBuildExtractValue(LLVMBuilderRef, LLVMValueRef AggVal,
2514 unsigned Index, const char *Name);
2515 LLVMValueRef LLVMBuildInsertValue(LLVMBuilderRef, LLVMValueRef AggVal,
2516 LLVMValueRef EltVal, unsigned Index,
2519 LLVMValueRef LLVMBuildIsNull(LLVMBuilderRef, LLVMValueRef Val,
2521 LLVMValueRef LLVMBuildIsNotNull(LLVMBuilderRef, LLVMValueRef Val,
2523 LLVMValueRef LLVMBuildPtrDiff(LLVMBuilderRef, LLVMValueRef LHS,
2524 LLVMValueRef RHS, const char *Name);
2531 * @defgroup LLVMCCoreModuleProvider Module Providers
2537 * Changes the type of M so it can be passed to FunctionPassManagers and the
2538 * JIT. They take ModuleProviders for historical reasons.
2540 LLVMModuleProviderRef
2541 LLVMCreateModuleProviderForExistingModule(LLVMModuleRef M);
2544 * Destroys the module M.
2546 void LLVMDisposeModuleProvider(LLVMModuleProviderRef M);
2553 * @defgroup LLVMCCoreMemoryBuffers Memory Buffers
2558 LLVMBool LLVMCreateMemoryBufferWithContentsOfFile(const char *Path,
2559 LLVMMemoryBufferRef *OutMemBuf,
2561 LLVMBool LLVMCreateMemoryBufferWithSTDIN(LLVMMemoryBufferRef *OutMemBuf,
2563 LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRange(const char *InputData,
2564 size_t InputDataLength,
2565 const char *BufferName,
2566 LLVMBool RequiresNullTerminator);
2567 LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRangeCopy(const char *InputData,
2568 size_t InputDataLength,
2569 const char *BufferName);
2570 const char *LLVMGetBufferStart(LLVMMemoryBufferRef MemBuf);
2571 size_t LLVMGetBufferSize(LLVMMemoryBufferRef MemBuf);
2572 void LLVMDisposeMemoryBuffer(LLVMMemoryBufferRef MemBuf);
2579 * @defgroup LLVMCCorePassRegistry Pass Registry
2584 /** Return the global pass registry, for use with initialization functions.
2585 @see llvm::PassRegistry::getPassRegistry */
2586 LLVMPassRegistryRef LLVMGetGlobalPassRegistry(void);
2593 * @defgroup LLVMCCorePassManagers Pass Managers
2598 /** Constructs a new whole-module pass pipeline. This type of pipeline is
2599 suitable for link-time optimization and whole-module transformations.
2600 @see llvm::PassManager::PassManager */
2601 LLVMPassManagerRef LLVMCreatePassManager(void);
2603 /** Constructs a new function-by-function pass pipeline over the module
2604 provider. It does not take ownership of the module provider. This type of
2605 pipeline is suitable for code generation and JIT compilation tasks.
2606 @see llvm::FunctionPassManager::FunctionPassManager */
2607 LLVMPassManagerRef LLVMCreateFunctionPassManagerForModule(LLVMModuleRef M);
2609 /** Deprecated: Use LLVMCreateFunctionPassManagerForModule instead. */
2610 LLVMPassManagerRef LLVMCreateFunctionPassManager(LLVMModuleProviderRef MP);
2612 /** Initializes, executes on the provided module, and finalizes all of the
2613 passes scheduled in the pass manager. Returns 1 if any of the passes
2614 modified the module, 0 otherwise.
2615 @see llvm::PassManager::run(Module&) */
2616 LLVMBool LLVMRunPassManager(LLVMPassManagerRef PM, LLVMModuleRef M);
2618 /** Initializes all of the function passes scheduled in the function pass
2619 manager. Returns 1 if any of the passes modified the module, 0 otherwise.
2620 @see llvm::FunctionPassManager::doInitialization */
2621 LLVMBool LLVMInitializeFunctionPassManager(LLVMPassManagerRef FPM);
2623 /** Executes all of the function passes scheduled in the function pass manager
2624 on the provided function. Returns 1 if any of the passes modified the
2625 function, false otherwise.
2626 @see llvm::FunctionPassManager::run(Function&) */
2627 LLVMBool LLVMRunFunctionPassManager(LLVMPassManagerRef FPM, LLVMValueRef F);
2629 /** Finalizes all of the function passes scheduled in in the function pass
2630 manager. Returns 1 if any of the passes modified the module, 0 otherwise.
2631 @see llvm::FunctionPassManager::doFinalization */
2632 LLVMBool LLVMFinalizeFunctionPassManager(LLVMPassManagerRef FPM);
2634 /** Frees the memory of a pass pipeline. For function pipelines, does not free
2635 the module provider.
2636 @see llvm::PassManagerBase::~PassManagerBase. */
2637 void LLVMDisposePassManager(LLVMPassManagerRef PM);
2644 * @defgroup LLVMCCoreThreading Threading
2646 * Handle the structures needed to make LLVM safe for multithreading.
2651 /** Allocate and initialize structures needed to make LLVM safe for
2652 multithreading. The return value indicates whether multithreaded
2653 initialization succeeded. Must be executed in isolation from all
2654 other LLVM api calls.
2655 @see llvm::llvm_start_multithreaded */
2656 LLVMBool LLVMStartMultithreaded();
2658 /** Deallocate structures necessary to make LLVM safe for multithreading.
2659 Must be executed in isolation from all other LLVM api calls.
2660 @see llvm::llvm_stop_multithreaded */
2661 void LLVMStopMultithreaded();
2663 /** Check whether LLVM is executing in thread-safe mode or not.
2664 @see llvm::llvm_is_multithreaded */
2665 LLVMBool LLVMIsMultithreaded();
2681 #endif /* !defined(__cplusplus) */
2683 #endif /* !defined(LLVM_C_CORE_H) */