[DAGCombiner] Add target hook function to decide folding (mul (add x, c1), c2)
[llvm-project.git] / llvm / include / llvm-c / Core.h
blob1a5e763cfc600f1664d9f6039946c5223f2dd395
1 /*===-- llvm-c/Core.h - Core Library C Interface ------------------*- C -*-===*\
2 |* *|
3 |* Part of the LLVM Project, under the Apache License v2.0 with LLVM *|
4 |* Exceptions. *|
5 |* See https://llvm.org/LICENSE.txt for license information. *|
6 |* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *|
7 |* *|
8 |*===----------------------------------------------------------------------===*|
9 |* *|
10 |* This header declares the C interface to libLLVMCore.a, which implements *|
11 |* the LLVM intermediate representation. *|
12 |* *|
13 \*===----------------------------------------------------------------------===*/
15 #ifndef LLVM_C_CORE_H
16 #define LLVM_C_CORE_H
18 #include "llvm-c/ErrorHandling.h"
19 #include "llvm-c/ExternC.h"
20 #include "llvm-c/Types.h"
22 LLVM_C_EXTERN_C_BEGIN
24 /**
25 * @defgroup LLVMC LLVM-C: C interface to LLVM
27 * This module exposes parts of the LLVM library as a C API.
29 * @{
32 /**
33 * @defgroup LLVMCTransforms Transforms
36 /**
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
41 * and utilities.
43 * Many exotic languages can interoperate with C code but have a harder time
44 * with C++ due to name mangling. So in addition to C, this interface enables
45 * tools written in such languages.
47 * @{
50 /**
51 * @defgroup LLVMCCoreTypes Types and Enumerations
53 * @{
56 /// External users depend on the following values being stable. It is not safe
57 /// to reorder them.
58 typedef enum {
59 /* Terminator Instructions */
60 LLVMRet = 1,
61 LLVMBr = 2,
62 LLVMSwitch = 3,
63 LLVMIndirectBr = 4,
64 LLVMInvoke = 5,
65 /* removed 6 due to API changes */
66 LLVMUnreachable = 7,
67 LLVMCallBr = 67,
69 /* Standard Unary Operators */
70 LLVMFNeg = 66,
72 /* Standard Binary Operators */
73 LLVMAdd = 8,
74 LLVMFAdd = 9,
75 LLVMSub = 10,
76 LLVMFSub = 11,
77 LLVMMul = 12,
78 LLVMFMul = 13,
79 LLVMUDiv = 14,
80 LLVMSDiv = 15,
81 LLVMFDiv = 16,
82 LLVMURem = 17,
83 LLVMSRem = 18,
84 LLVMFRem = 19,
86 /* Logical Operators */
87 LLVMShl = 20,
88 LLVMLShr = 21,
89 LLVMAShr = 22,
90 LLVMAnd = 23,
91 LLVMOr = 24,
92 LLVMXor = 25,
94 /* Memory Operators */
95 LLVMAlloca = 26,
96 LLVMLoad = 27,
97 LLVMStore = 28,
98 LLVMGetElementPtr = 29,
100 /* Cast Operators */
101 LLVMTrunc = 30,
102 LLVMZExt = 31,
103 LLVMSExt = 32,
104 LLVMFPToUI = 33,
105 LLVMFPToSI = 34,
106 LLVMUIToFP = 35,
107 LLVMSIToFP = 36,
108 LLVMFPTrunc = 37,
109 LLVMFPExt = 38,
110 LLVMPtrToInt = 39,
111 LLVMIntToPtr = 40,
112 LLVMBitCast = 41,
113 LLVMAddrSpaceCast = 60,
115 /* Other Operators */
116 LLVMICmp = 42,
117 LLVMFCmp = 43,
118 LLVMPHI = 44,
119 LLVMCall = 45,
120 LLVMSelect = 46,
121 LLVMUserOp1 = 47,
122 LLVMUserOp2 = 48,
123 LLVMVAArg = 49,
124 LLVMExtractElement = 50,
125 LLVMInsertElement = 51,
126 LLVMShuffleVector = 52,
127 LLVMExtractValue = 53,
128 LLVMInsertValue = 54,
129 LLVMFreeze = 68,
131 /* Atomic operators */
132 LLVMFence = 55,
133 LLVMAtomicCmpXchg = 56,
134 LLVMAtomicRMW = 57,
136 /* Exception Handling Operators */
137 LLVMResume = 58,
138 LLVMLandingPad = 59,
139 LLVMCleanupRet = 61,
140 LLVMCatchRet = 62,
141 LLVMCatchPad = 63,
142 LLVMCleanupPad = 64,
143 LLVMCatchSwitch = 65
144 } LLVMOpcode;
146 typedef enum {
147 LLVMVoidTypeKind, /**< type with no size */
148 LLVMHalfTypeKind, /**< 16 bit floating point type */
149 LLVMFloatTypeKind, /**< 32 bit floating point type */
150 LLVMDoubleTypeKind, /**< 64 bit floating point type */
151 LLVMX86_FP80TypeKind, /**< 80 bit floating point type (X87) */
152 LLVMFP128TypeKind, /**< 128 bit floating point type (112-bit mantissa)*/
153 LLVMPPC_FP128TypeKind, /**< 128 bit floating point type (two 64-bits) */
154 LLVMLabelTypeKind, /**< Labels */
155 LLVMIntegerTypeKind, /**< Arbitrary bit width integers */
156 LLVMFunctionTypeKind, /**< Functions */
157 LLVMStructTypeKind, /**< Structures */
158 LLVMArrayTypeKind, /**< Arrays */
159 LLVMPointerTypeKind, /**< Pointers */
160 LLVMVectorTypeKind, /**< Fixed width SIMD vector type */
161 LLVMMetadataTypeKind, /**< Metadata */
162 LLVMX86_MMXTypeKind, /**< X86 MMX */
163 LLVMTokenTypeKind, /**< Tokens */
164 LLVMScalableVectorTypeKind, /**< Scalable SIMD vector type */
165 LLVMBFloatTypeKind, /**< 16 bit brain floating point type */
166 LLVMX86_AMXTypeKind /**< X86 AMX */
167 } LLVMTypeKind;
169 typedef enum {
170 LLVMExternalLinkage, /**< Externally visible function */
171 LLVMAvailableExternallyLinkage,
172 LLVMLinkOnceAnyLinkage, /**< Keep one copy of function when linking (inline)*/
173 LLVMLinkOnceODRLinkage, /**< Same, but only replaced by something
174 equivalent. */
175 LLVMLinkOnceODRAutoHideLinkage, /**< Obsolete */
176 LLVMWeakAnyLinkage, /**< Keep one copy of function when linking (weak) */
177 LLVMWeakODRLinkage, /**< Same, but only replaced by something
178 equivalent. */
179 LLVMAppendingLinkage, /**< Special purpose, only applies to global arrays */
180 LLVMInternalLinkage, /**< Rename collisions when linking (static
181 functions) */
182 LLVMPrivateLinkage, /**< Like Internal, but omit from symbol table */
183 LLVMDLLImportLinkage, /**< Obsolete */
184 LLVMDLLExportLinkage, /**< Obsolete */
185 LLVMExternalWeakLinkage,/**< ExternalWeak linkage description */
186 LLVMGhostLinkage, /**< Obsolete */
187 LLVMCommonLinkage, /**< Tentative definitions */
188 LLVMLinkerPrivateLinkage, /**< Like Private, but linker removes. */
189 LLVMLinkerPrivateWeakLinkage /**< Like LinkerPrivate, but is weak. */
190 } LLVMLinkage;
192 typedef enum {
193 LLVMDefaultVisibility, /**< The GV is visible */
194 LLVMHiddenVisibility, /**< The GV is hidden */
195 LLVMProtectedVisibility /**< The GV is protected */
196 } LLVMVisibility;
198 typedef enum {
199 LLVMNoUnnamedAddr, /**< Address of the GV is significant. */
200 LLVMLocalUnnamedAddr, /**< Address of the GV is locally insignificant. */
201 LLVMGlobalUnnamedAddr /**< Address of the GV is globally insignificant. */
202 } LLVMUnnamedAddr;
204 typedef enum {
205 LLVMDefaultStorageClass = 0,
206 LLVMDLLImportStorageClass = 1, /**< Function to be imported from DLL. */
207 LLVMDLLExportStorageClass = 2 /**< Function to be accessible from DLL. */
208 } LLVMDLLStorageClass;
210 typedef enum {
211 LLVMCCallConv = 0,
212 LLVMFastCallConv = 8,
213 LLVMColdCallConv = 9,
214 LLVMGHCCallConv = 10,
215 LLVMHiPECallConv = 11,
216 LLVMWebKitJSCallConv = 12,
217 LLVMAnyRegCallConv = 13,
218 LLVMPreserveMostCallConv = 14,
219 LLVMPreserveAllCallConv = 15,
220 LLVMSwiftCallConv = 16,
221 LLVMCXXFASTTLSCallConv = 17,
222 LLVMX86StdcallCallConv = 64,
223 LLVMX86FastcallCallConv = 65,
224 LLVMARMAPCSCallConv = 66,
225 LLVMARMAAPCSCallConv = 67,
226 LLVMARMAAPCSVFPCallConv = 68,
227 LLVMMSP430INTRCallConv = 69,
228 LLVMX86ThisCallCallConv = 70,
229 LLVMPTXKernelCallConv = 71,
230 LLVMPTXDeviceCallConv = 72,
231 LLVMSPIRFUNCCallConv = 75,
232 LLVMSPIRKERNELCallConv = 76,
233 LLVMIntelOCLBICallConv = 77,
234 LLVMX8664SysVCallConv = 78,
235 LLVMWin64CallConv = 79,
236 LLVMX86VectorCallCallConv = 80,
237 LLVMHHVMCallConv = 81,
238 LLVMHHVMCCallConv = 82,
239 LLVMX86INTRCallConv = 83,
240 LLVMAVRINTRCallConv = 84,
241 LLVMAVRSIGNALCallConv = 85,
242 LLVMAVRBUILTINCallConv = 86,
243 LLVMAMDGPUVSCallConv = 87,
244 LLVMAMDGPUGSCallConv = 88,
245 LLVMAMDGPUPSCallConv = 89,
246 LLVMAMDGPUCSCallConv = 90,
247 LLVMAMDGPUKERNELCallConv = 91,
248 LLVMX86RegCallCallConv = 92,
249 LLVMAMDGPUHSCallConv = 93,
250 LLVMMSP430BUILTINCallConv = 94,
251 LLVMAMDGPULSCallConv = 95,
252 LLVMAMDGPUESCallConv = 96
253 } LLVMCallConv;
255 typedef enum {
256 LLVMArgumentValueKind,
257 LLVMBasicBlockValueKind,
258 LLVMMemoryUseValueKind,
259 LLVMMemoryDefValueKind,
260 LLVMMemoryPhiValueKind,
262 LLVMFunctionValueKind,
263 LLVMGlobalAliasValueKind,
264 LLVMGlobalIFuncValueKind,
265 LLVMGlobalVariableValueKind,
266 LLVMBlockAddressValueKind,
267 LLVMConstantExprValueKind,
268 LLVMConstantArrayValueKind,
269 LLVMConstantStructValueKind,
270 LLVMConstantVectorValueKind,
272 LLVMUndefValueValueKind,
273 LLVMConstantAggregateZeroValueKind,
274 LLVMConstantDataArrayValueKind,
275 LLVMConstantDataVectorValueKind,
276 LLVMConstantIntValueKind,
277 LLVMConstantFPValueKind,
278 LLVMConstantPointerNullValueKind,
279 LLVMConstantTokenNoneValueKind,
281 LLVMMetadataAsValueValueKind,
282 LLVMInlineAsmValueKind,
284 LLVMInstructionValueKind,
285 LLVMPoisonValueValueKind
286 } LLVMValueKind;
288 typedef enum {
289 LLVMIntEQ = 32, /**< equal */
290 LLVMIntNE, /**< not equal */
291 LLVMIntUGT, /**< unsigned greater than */
292 LLVMIntUGE, /**< unsigned greater or equal */
293 LLVMIntULT, /**< unsigned less than */
294 LLVMIntULE, /**< unsigned less or equal */
295 LLVMIntSGT, /**< signed greater than */
296 LLVMIntSGE, /**< signed greater or equal */
297 LLVMIntSLT, /**< signed less than */
298 LLVMIntSLE /**< signed less or equal */
299 } LLVMIntPredicate;
301 typedef enum {
302 LLVMRealPredicateFalse, /**< Always false (always folded) */
303 LLVMRealOEQ, /**< True if ordered and equal */
304 LLVMRealOGT, /**< True if ordered and greater than */
305 LLVMRealOGE, /**< True if ordered and greater than or equal */
306 LLVMRealOLT, /**< True if ordered and less than */
307 LLVMRealOLE, /**< True if ordered and less than or equal */
308 LLVMRealONE, /**< True if ordered and operands are unequal */
309 LLVMRealORD, /**< True if ordered (no nans) */
310 LLVMRealUNO, /**< True if unordered: isnan(X) | isnan(Y) */
311 LLVMRealUEQ, /**< True if unordered or equal */
312 LLVMRealUGT, /**< True if unordered or greater than */
313 LLVMRealUGE, /**< True if unordered, greater than, or equal */
314 LLVMRealULT, /**< True if unordered or less than */
315 LLVMRealULE, /**< True if unordered, less than, or equal */
316 LLVMRealUNE, /**< True if unordered or not equal */
317 LLVMRealPredicateTrue /**< Always true (always folded) */
318 } LLVMRealPredicate;
320 typedef enum {
321 LLVMLandingPadCatch, /**< A catch clause */
322 LLVMLandingPadFilter /**< A filter clause */
323 } LLVMLandingPadClauseTy;
325 typedef enum {
326 LLVMNotThreadLocal = 0,
327 LLVMGeneralDynamicTLSModel,
328 LLVMLocalDynamicTLSModel,
329 LLVMInitialExecTLSModel,
330 LLVMLocalExecTLSModel
331 } LLVMThreadLocalMode;
333 typedef enum {
334 LLVMAtomicOrderingNotAtomic = 0, /**< A load or store which is not atomic */
335 LLVMAtomicOrderingUnordered = 1, /**< Lowest level of atomicity, guarantees
336 somewhat sane results, lock free. */
337 LLVMAtomicOrderingMonotonic = 2, /**< guarantees that if you take all the
338 operations affecting a specific address,
339 a consistent ordering exists */
340 LLVMAtomicOrderingAcquire = 4, /**< Acquire provides a barrier of the sort
341 necessary to acquire a lock to access other
342 memory with normal loads and stores. */
343 LLVMAtomicOrderingRelease = 5, /**< Release is similar to Acquire, but with
344 a barrier of the sort necessary to release
345 a lock. */
346 LLVMAtomicOrderingAcquireRelease = 6, /**< provides both an Acquire and a
347 Release barrier (for fences and
348 operations which both read and write
349 memory). */
350 LLVMAtomicOrderingSequentiallyConsistent = 7 /**< provides Acquire semantics
351 for loads and Release
352 semantics for stores.
353 Additionally, it guarantees
354 that a total ordering exists
355 between all
356 SequentiallyConsistent
357 operations. */
358 } LLVMAtomicOrdering;
360 typedef enum {
361 LLVMAtomicRMWBinOpXchg, /**< Set the new value and return the one old */
362 LLVMAtomicRMWBinOpAdd, /**< Add a value and return the old one */
363 LLVMAtomicRMWBinOpSub, /**< Subtract a value and return the old one */
364 LLVMAtomicRMWBinOpAnd, /**< And a value and return the old one */
365 LLVMAtomicRMWBinOpNand, /**< Not-And a value and return the old one */
366 LLVMAtomicRMWBinOpOr, /**< OR a value and return the old one */
367 LLVMAtomicRMWBinOpXor, /**< Xor a value and return the old one */
368 LLVMAtomicRMWBinOpMax, /**< Sets the value if it's greater than the
369 original using a signed comparison and return
370 the old one */
371 LLVMAtomicRMWBinOpMin, /**< Sets the value if it's Smaller than the
372 original using a signed comparison and return
373 the old one */
374 LLVMAtomicRMWBinOpUMax, /**< Sets the value if it's greater than the
375 original using an unsigned comparison and return
376 the old one */
377 LLVMAtomicRMWBinOpUMin, /**< Sets the value if it's greater than the
378 original using an unsigned comparison and return
379 the old one */
380 LLVMAtomicRMWBinOpFAdd, /**< Add a floating point value and return the
381 old one */
382 LLVMAtomicRMWBinOpFSub /**< Subtract a floating point value and return the
383 old one */
384 } LLVMAtomicRMWBinOp;
386 typedef enum {
387 LLVMDSError,
388 LLVMDSWarning,
389 LLVMDSRemark,
390 LLVMDSNote
391 } LLVMDiagnosticSeverity;
393 typedef enum {
394 LLVMInlineAsmDialectATT,
395 LLVMInlineAsmDialectIntel
396 } LLVMInlineAsmDialect;
398 typedef enum {
400 * Emits an error if two values disagree, otherwise the resulting value is
401 * that of the operands.
403 * @see Module::ModFlagBehavior::Error
405 LLVMModuleFlagBehaviorError,
407 * Emits a warning if two values disagree. The result value will be the
408 * operand for the flag from the first module being linked.
410 * @see Module::ModFlagBehavior::Warning
412 LLVMModuleFlagBehaviorWarning,
414 * Adds a requirement that another module flag be present and have a
415 * specified value after linking is performed. The value must be a metadata
416 * pair, where the first element of the pair is the ID of the module flag
417 * to be restricted, and the second element of the pair is the value the
418 * module flag should be restricted to. This behavior can be used to
419 * restrict the allowable results (via triggering of an error) of linking
420 * IDs with the **Override** behavior.
422 * @see Module::ModFlagBehavior::Require
424 LLVMModuleFlagBehaviorRequire,
426 * Uses the specified value, regardless of the behavior or value of the
427 * other module. If both modules specify **Override**, but the values
428 * differ, an error will be emitted.
430 * @see Module::ModFlagBehavior::Override
432 LLVMModuleFlagBehaviorOverride,
434 * Appends the two values, which are required to be metadata nodes.
436 * @see Module::ModFlagBehavior::Append
438 LLVMModuleFlagBehaviorAppend,
440 * Appends the two values, which are required to be metadata
441 * nodes. However, duplicate entries in the second list are dropped
442 * during the append operation.
444 * @see Module::ModFlagBehavior::AppendUnique
446 LLVMModuleFlagBehaviorAppendUnique,
447 } LLVMModuleFlagBehavior;
450 * Attribute index are either LLVMAttributeReturnIndex,
451 * LLVMAttributeFunctionIndex or a parameter number from 1 to N.
453 enum {
454 LLVMAttributeReturnIndex = 0U,
455 // ISO C restricts enumerator values to range of 'int'
456 // (4294967295 is too large)
457 // LLVMAttributeFunctionIndex = ~0U,
458 LLVMAttributeFunctionIndex = -1,
461 typedef unsigned LLVMAttributeIndex;
464 * @}
467 void LLVMInitializeCore(LLVMPassRegistryRef R);
469 /** Deallocate and destroy all ManagedStatic variables.
470 @see llvm::llvm_shutdown
471 @see ManagedStatic */
472 void LLVMShutdown(void);
474 /*===-- Error handling ----------------------------------------------------===*/
476 char *LLVMCreateMessage(const char *Message);
477 void LLVMDisposeMessage(char *Message);
480 * @defgroup LLVMCCoreContext Contexts
482 * Contexts are execution states for the core LLVM IR system.
484 * Most types are tied to a context instance. Multiple contexts can
485 * exist simultaneously. A single context is not thread safe. However,
486 * different contexts can execute on different threads simultaneously.
488 * @{
491 typedef void (*LLVMDiagnosticHandler)(LLVMDiagnosticInfoRef, void *);
492 typedef void (*LLVMYieldCallback)(LLVMContextRef, void *);
495 * Create a new context.
497 * Every call to this function should be paired with a call to
498 * LLVMContextDispose() or the context will leak memory.
500 LLVMContextRef LLVMContextCreate(void);
503 * Obtain the global context instance.
505 LLVMContextRef LLVMGetGlobalContext(void);
508 * Set the diagnostic handler for this context.
510 void LLVMContextSetDiagnosticHandler(LLVMContextRef C,
511 LLVMDiagnosticHandler Handler,
512 void *DiagnosticContext);
515 * Get the diagnostic handler of this context.
517 LLVMDiagnosticHandler LLVMContextGetDiagnosticHandler(LLVMContextRef C);
520 * Get the diagnostic context of this context.
522 void *LLVMContextGetDiagnosticContext(LLVMContextRef C);
525 * Set the yield callback function for this context.
527 * @see LLVMContext::setYieldCallback()
529 void LLVMContextSetYieldCallback(LLVMContextRef C, LLVMYieldCallback Callback,
530 void *OpaqueHandle);
533 * Retrieve whether the given context is set to discard all value names.
535 * @see LLVMContext::shouldDiscardValueNames()
537 LLVMBool LLVMContextShouldDiscardValueNames(LLVMContextRef C);
540 * Set whether the given context discards all value names.
542 * If true, only the names of GlobalValue objects will be available in the IR.
543 * This can be used to save memory and runtime, especially in release mode.
545 * @see LLVMContext::setDiscardValueNames()
547 void LLVMContextSetDiscardValueNames(LLVMContextRef C, LLVMBool Discard);
550 * Destroy a context instance.
552 * This should be called for every call to LLVMContextCreate() or memory
553 * will be leaked.
555 void LLVMContextDispose(LLVMContextRef C);
558 * Return a string representation of the DiagnosticInfo. Use
559 * LLVMDisposeMessage to free the string.
561 * @see DiagnosticInfo::print()
563 char *LLVMGetDiagInfoDescription(LLVMDiagnosticInfoRef DI);
566 * Return an enum LLVMDiagnosticSeverity.
568 * @see DiagnosticInfo::getSeverity()
570 LLVMDiagnosticSeverity LLVMGetDiagInfoSeverity(LLVMDiagnosticInfoRef DI);
572 unsigned LLVMGetMDKindIDInContext(LLVMContextRef C, const char *Name,
573 unsigned SLen);
574 unsigned LLVMGetMDKindID(const char *Name, unsigned SLen);
577 * Return an unique id given the name of a enum attribute,
578 * or 0 if no attribute by that name exists.
580 * See http://llvm.org/docs/LangRef.html#parameter-attributes
581 * and http://llvm.org/docs/LangRef.html#function-attributes
582 * for the list of available attributes.
584 * NB: Attribute names and/or id are subject to change without
585 * going through the C API deprecation cycle.
587 unsigned LLVMGetEnumAttributeKindForName(const char *Name, size_t SLen);
588 unsigned LLVMGetLastEnumAttributeKind(void);
591 * Create an enum attribute.
593 LLVMAttributeRef LLVMCreateEnumAttribute(LLVMContextRef C, unsigned KindID,
594 uint64_t Val);
597 * Get the unique id corresponding to the enum attribute
598 * passed as argument.
600 unsigned LLVMGetEnumAttributeKind(LLVMAttributeRef A);
603 * Get the enum attribute's value. 0 is returned if none exists.
605 uint64_t LLVMGetEnumAttributeValue(LLVMAttributeRef A);
608 * Create a type attribute
610 LLVMAttributeRef LLVMCreateTypeAttribute(LLVMContextRef C, unsigned KindID,
611 LLVMTypeRef type_ref);
614 * Get the type attribute's value.
616 LLVMTypeRef LLVMGetTypeAttributeValue(LLVMAttributeRef A);
619 * Create a string attribute.
621 LLVMAttributeRef LLVMCreateStringAttribute(LLVMContextRef C,
622 const char *K, unsigned KLength,
623 const char *V, unsigned VLength);
626 * Get the string attribute's kind.
628 const char *LLVMGetStringAttributeKind(LLVMAttributeRef A, unsigned *Length);
631 * Get the string attribute's value.
633 const char *LLVMGetStringAttributeValue(LLVMAttributeRef A, unsigned *Length);
636 * Check for the different types of attributes.
638 LLVMBool LLVMIsEnumAttribute(LLVMAttributeRef A);
639 LLVMBool LLVMIsStringAttribute(LLVMAttributeRef A);
640 LLVMBool LLVMIsTypeAttribute(LLVMAttributeRef A);
643 * Obtain a Type from a context by its registered name.
645 LLVMTypeRef LLVMGetTypeByName2(LLVMContextRef C, const char *Name);
648 * @}
652 * @defgroup LLVMCCoreModule Modules
654 * Modules represent the top-level structure in an LLVM program. An LLVM
655 * module is effectively a translation unit or a collection of
656 * translation units merged together.
658 * @{
662 * Create a new, empty module in the global context.
664 * This is equivalent to calling LLVMModuleCreateWithNameInContext with
665 * LLVMGetGlobalContext() as the context parameter.
667 * Every invocation should be paired with LLVMDisposeModule() or memory
668 * will be leaked.
670 LLVMModuleRef LLVMModuleCreateWithName(const char *ModuleID);
673 * Create a new, empty module in a specific context.
675 * Every invocation should be paired with LLVMDisposeModule() or memory
676 * will be leaked.
678 LLVMModuleRef LLVMModuleCreateWithNameInContext(const char *ModuleID,
679 LLVMContextRef C);
681 * Return an exact copy of the specified module.
683 LLVMModuleRef LLVMCloneModule(LLVMModuleRef M);
686 * Destroy a module instance.
688 * This must be called for every created module or memory will be
689 * leaked.
691 void LLVMDisposeModule(LLVMModuleRef M);
694 * Obtain the identifier of a module.
696 * @param M Module to obtain identifier of
697 * @param Len Out parameter which holds the length of the returned string.
698 * @return The identifier of M.
699 * @see Module::getModuleIdentifier()
701 const char *LLVMGetModuleIdentifier(LLVMModuleRef M, size_t *Len);
704 * Set the identifier of a module to a string Ident with length Len.
706 * @param M The module to set identifier
707 * @param Ident The string to set M's identifier to
708 * @param Len Length of Ident
709 * @see Module::setModuleIdentifier()
711 void LLVMSetModuleIdentifier(LLVMModuleRef M, const char *Ident, size_t Len);
714 * Obtain the module's original source file name.
716 * @param M Module to obtain the name of
717 * @param Len Out parameter which holds the length of the returned string
718 * @return The original source file name of M
719 * @see Module::getSourceFileName()
721 const char *LLVMGetSourceFileName(LLVMModuleRef M, size_t *Len);
724 * Set the original source file name of a module to a string Name with length
725 * Len.
727 * @param M The module to set the source file name of
728 * @param Name The string to set M's source file name to
729 * @param Len Length of Name
730 * @see Module::setSourceFileName()
732 void LLVMSetSourceFileName(LLVMModuleRef M, const char *Name, size_t Len);
735 * Obtain the data layout for a module.
737 * @see Module::getDataLayoutStr()
739 * LLVMGetDataLayout is DEPRECATED, as the name is not only incorrect,
740 * but match the name of another method on the module. Prefer the use
741 * of LLVMGetDataLayoutStr, which is not ambiguous.
743 const char *LLVMGetDataLayoutStr(LLVMModuleRef M);
744 const char *LLVMGetDataLayout(LLVMModuleRef M);
747 * Set the data layout for a module.
749 * @see Module::setDataLayout()
751 void LLVMSetDataLayout(LLVMModuleRef M, const char *DataLayoutStr);
754 * Obtain the target triple for a module.
756 * @see Module::getTargetTriple()
758 const char *LLVMGetTarget(LLVMModuleRef M);
761 * Set the target triple for a module.
763 * @see Module::setTargetTriple()
765 void LLVMSetTarget(LLVMModuleRef M, const char *Triple);
768 * Returns the module flags as an array of flag-key-value triples. The caller
769 * is responsible for freeing this array by calling
770 * \c LLVMDisposeModuleFlagsMetadata.
772 * @see Module::getModuleFlagsMetadata()
774 LLVMModuleFlagEntry *LLVMCopyModuleFlagsMetadata(LLVMModuleRef M, size_t *Len);
777 * Destroys module flags metadata entries.
779 void LLVMDisposeModuleFlagsMetadata(LLVMModuleFlagEntry *Entries);
782 * Returns the flag behavior for a module flag entry at a specific index.
784 * @see Module::ModuleFlagEntry::Behavior
786 LLVMModuleFlagBehavior
787 LLVMModuleFlagEntriesGetFlagBehavior(LLVMModuleFlagEntry *Entries,
788 unsigned Index);
791 * Returns the key for a module flag entry at a specific index.
793 * @see Module::ModuleFlagEntry::Key
795 const char *LLVMModuleFlagEntriesGetKey(LLVMModuleFlagEntry *Entries,
796 unsigned Index, size_t *Len);
799 * Returns the metadata for a module flag entry at a specific index.
801 * @see Module::ModuleFlagEntry::Val
803 LLVMMetadataRef LLVMModuleFlagEntriesGetMetadata(LLVMModuleFlagEntry *Entries,
804 unsigned Index);
807 * Add a module-level flag to the module-level flags metadata if it doesn't
808 * already exist.
810 * @see Module::getModuleFlag()
812 LLVMMetadataRef LLVMGetModuleFlag(LLVMModuleRef M,
813 const char *Key, size_t KeyLen);
816 * Add a module-level flag to the module-level flags metadata if it doesn't
817 * already exist.
819 * @see Module::addModuleFlag()
821 void LLVMAddModuleFlag(LLVMModuleRef M, LLVMModuleFlagBehavior Behavior,
822 const char *Key, size_t KeyLen,
823 LLVMMetadataRef Val);
826 * Dump a representation of a module to stderr.
828 * @see Module::dump()
830 void LLVMDumpModule(LLVMModuleRef M);
833 * Print a representation of a module to a file. The ErrorMessage needs to be
834 * disposed with LLVMDisposeMessage. Returns 0 on success, 1 otherwise.
836 * @see Module::print()
838 LLVMBool LLVMPrintModuleToFile(LLVMModuleRef M, const char *Filename,
839 char **ErrorMessage);
842 * Return a string representation of the module. Use
843 * LLVMDisposeMessage to free the string.
845 * @see Module::print()
847 char *LLVMPrintModuleToString(LLVMModuleRef M);
850 * Get inline assembly for a module.
852 * @see Module::getModuleInlineAsm()
854 const char *LLVMGetModuleInlineAsm(LLVMModuleRef M, size_t *Len);
857 * Set inline assembly for a module.
859 * @see Module::setModuleInlineAsm()
861 void LLVMSetModuleInlineAsm2(LLVMModuleRef M, const char *Asm, size_t Len);
864 * Append inline assembly to a module.
866 * @see Module::appendModuleInlineAsm()
868 void LLVMAppendModuleInlineAsm(LLVMModuleRef M, const char *Asm, size_t Len);
871 * Create the specified uniqued inline asm string.
873 * @see InlineAsm::get()
875 LLVMValueRef LLVMGetInlineAsm(LLVMTypeRef Ty, char *AsmString,
876 size_t AsmStringSize, char *Constraints,
877 size_t ConstraintsSize, LLVMBool HasSideEffects,
878 LLVMBool IsAlignStack,
879 LLVMInlineAsmDialect Dialect, LLVMBool CanThrow);
882 * Obtain the context to which this module is associated.
884 * @see Module::getContext()
886 LLVMContextRef LLVMGetModuleContext(LLVMModuleRef M);
888 /** Deprecated: Use LLVMGetTypeByName2 instead. */
889 LLVMTypeRef LLVMGetTypeByName(LLVMModuleRef M, const char *Name);
892 * Obtain an iterator to the first NamedMDNode in a Module.
894 * @see llvm::Module::named_metadata_begin()
896 LLVMNamedMDNodeRef LLVMGetFirstNamedMetadata(LLVMModuleRef M);
899 * Obtain an iterator to the last NamedMDNode in a Module.
901 * @see llvm::Module::named_metadata_end()
903 LLVMNamedMDNodeRef LLVMGetLastNamedMetadata(LLVMModuleRef M);
906 * Advance a NamedMDNode iterator to the next NamedMDNode.
908 * Returns NULL if the iterator was already at the end and there are no more
909 * named metadata nodes.
911 LLVMNamedMDNodeRef LLVMGetNextNamedMetadata(LLVMNamedMDNodeRef NamedMDNode);
914 * Decrement a NamedMDNode iterator to the previous NamedMDNode.
916 * Returns NULL if the iterator was already at the beginning and there are
917 * no previous named metadata nodes.
919 LLVMNamedMDNodeRef LLVMGetPreviousNamedMetadata(LLVMNamedMDNodeRef NamedMDNode);
922 * Retrieve a NamedMDNode with the given name, returning NULL if no such
923 * node exists.
925 * @see llvm::Module::getNamedMetadata()
927 LLVMNamedMDNodeRef LLVMGetNamedMetadata(LLVMModuleRef M,
928 const char *Name, size_t NameLen);
931 * Retrieve a NamedMDNode with the given name, creating a new node if no such
932 * node exists.
934 * @see llvm::Module::getOrInsertNamedMetadata()
936 LLVMNamedMDNodeRef LLVMGetOrInsertNamedMetadata(LLVMModuleRef M,
937 const char *Name,
938 size_t NameLen);
941 * Retrieve the name of a NamedMDNode.
943 * @see llvm::NamedMDNode::getName()
945 const char *LLVMGetNamedMetadataName(LLVMNamedMDNodeRef NamedMD,
946 size_t *NameLen);
949 * Obtain the number of operands for named metadata in a module.
951 * @see llvm::Module::getNamedMetadata()
953 unsigned LLVMGetNamedMetadataNumOperands(LLVMModuleRef M, const char *Name);
956 * Obtain the named metadata operands for a module.
958 * The passed LLVMValueRef pointer should refer to an array of
959 * LLVMValueRef at least LLVMGetNamedMetadataNumOperands long. This
960 * array will be populated with the LLVMValueRef instances. Each
961 * instance corresponds to a llvm::MDNode.
963 * @see llvm::Module::getNamedMetadata()
964 * @see llvm::MDNode::getOperand()
966 void LLVMGetNamedMetadataOperands(LLVMModuleRef M, const char *Name,
967 LLVMValueRef *Dest);
970 * Add an operand to named metadata.
972 * @see llvm::Module::getNamedMetadata()
973 * @see llvm::MDNode::addOperand()
975 void LLVMAddNamedMetadataOperand(LLVMModuleRef M, const char *Name,
976 LLVMValueRef Val);
979 * Return the directory of the debug location for this value, which must be
980 * an llvm::Instruction, llvm::GlobalVariable, or llvm::Function.
982 * @see llvm::Instruction::getDebugLoc()
983 * @see llvm::GlobalVariable::getDebugInfo()
984 * @see llvm::Function::getSubprogram()
986 const char *LLVMGetDebugLocDirectory(LLVMValueRef Val, unsigned *Length);
989 * Return the filename of the debug location for this value, which must be
990 * an llvm::Instruction, llvm::GlobalVariable, or llvm::Function.
992 * @see llvm::Instruction::getDebugLoc()
993 * @see llvm::GlobalVariable::getDebugInfo()
994 * @see llvm::Function::getSubprogram()
996 const char *LLVMGetDebugLocFilename(LLVMValueRef Val, unsigned *Length);
999 * Return the line number of the debug location for this value, which must be
1000 * an llvm::Instruction, llvm::GlobalVariable, or llvm::Function.
1002 * @see llvm::Instruction::getDebugLoc()
1003 * @see llvm::GlobalVariable::getDebugInfo()
1004 * @see llvm::Function::getSubprogram()
1006 unsigned LLVMGetDebugLocLine(LLVMValueRef Val);
1009 * Return the column number of the debug location for this value, which must be
1010 * an llvm::Instruction.
1012 * @see llvm::Instruction::getDebugLoc()
1014 unsigned LLVMGetDebugLocColumn(LLVMValueRef Val);
1017 * Add a function to a module under a specified name.
1019 * @see llvm::Function::Create()
1021 LLVMValueRef LLVMAddFunction(LLVMModuleRef M, const char *Name,
1022 LLVMTypeRef FunctionTy);
1025 * Obtain a Function value from a Module by its name.
1027 * The returned value corresponds to a llvm::Function value.
1029 * @see llvm::Module::getFunction()
1031 LLVMValueRef LLVMGetNamedFunction(LLVMModuleRef M, const char *Name);
1034 * Obtain an iterator to the first Function in a Module.
1036 * @see llvm::Module::begin()
1038 LLVMValueRef LLVMGetFirstFunction(LLVMModuleRef M);
1041 * Obtain an iterator to the last Function in a Module.
1043 * @see llvm::Module::end()
1045 LLVMValueRef LLVMGetLastFunction(LLVMModuleRef M);
1048 * Advance a Function iterator to the next Function.
1050 * Returns NULL if the iterator was already at the end and there are no more
1051 * functions.
1053 LLVMValueRef LLVMGetNextFunction(LLVMValueRef Fn);
1056 * Decrement a Function iterator to the previous Function.
1058 * Returns NULL if the iterator was already at the beginning and there are
1059 * no previous functions.
1061 LLVMValueRef LLVMGetPreviousFunction(LLVMValueRef Fn);
1063 /** Deprecated: Use LLVMSetModuleInlineAsm2 instead. */
1064 void LLVMSetModuleInlineAsm(LLVMModuleRef M, const char *Asm);
1067 * @}
1071 * @defgroup LLVMCCoreType Types
1073 * Types represent the type of a value.
1075 * Types are associated with a context instance. The context internally
1076 * deduplicates types so there is only 1 instance of a specific type
1077 * alive at a time. In other words, a unique type is shared among all
1078 * consumers within a context.
1080 * A Type in the C API corresponds to llvm::Type.
1082 * Types have the following hierarchy:
1084 * types:
1085 * integer type
1086 * real type
1087 * function type
1088 * sequence types:
1089 * array type
1090 * pointer type
1091 * vector type
1092 * void type
1093 * label type
1094 * opaque type
1096 * @{
1100 * Obtain the enumerated type of a Type instance.
1102 * @see llvm::Type:getTypeID()
1104 LLVMTypeKind LLVMGetTypeKind(LLVMTypeRef Ty);
1107 * Whether the type has a known size.
1109 * Things that don't have a size are abstract types, labels, and void.a
1111 * @see llvm::Type::isSized()
1113 LLVMBool LLVMTypeIsSized(LLVMTypeRef Ty);
1116 * Obtain the context to which this type instance is associated.
1118 * @see llvm::Type::getContext()
1120 LLVMContextRef LLVMGetTypeContext(LLVMTypeRef Ty);
1123 * Dump a representation of a type to stderr.
1125 * @see llvm::Type::dump()
1127 void LLVMDumpType(LLVMTypeRef Val);
1130 * Return a string representation of the type. Use
1131 * LLVMDisposeMessage to free the string.
1133 * @see llvm::Type::print()
1135 char *LLVMPrintTypeToString(LLVMTypeRef Val);
1138 * @defgroup LLVMCCoreTypeInt Integer Types
1140 * Functions in this section operate on integer types.
1142 * @{
1146 * Obtain an integer type from a context with specified bit width.
1148 LLVMTypeRef LLVMInt1TypeInContext(LLVMContextRef C);
1149 LLVMTypeRef LLVMInt8TypeInContext(LLVMContextRef C);
1150 LLVMTypeRef LLVMInt16TypeInContext(LLVMContextRef C);
1151 LLVMTypeRef LLVMInt32TypeInContext(LLVMContextRef C);
1152 LLVMTypeRef LLVMInt64TypeInContext(LLVMContextRef C);
1153 LLVMTypeRef LLVMInt128TypeInContext(LLVMContextRef C);
1154 LLVMTypeRef LLVMIntTypeInContext(LLVMContextRef C, unsigned NumBits);
1157 * Obtain an integer type from the global context with a specified bit
1158 * width.
1160 LLVMTypeRef LLVMInt1Type(void);
1161 LLVMTypeRef LLVMInt8Type(void);
1162 LLVMTypeRef LLVMInt16Type(void);
1163 LLVMTypeRef LLVMInt32Type(void);
1164 LLVMTypeRef LLVMInt64Type(void);
1165 LLVMTypeRef LLVMInt128Type(void);
1166 LLVMTypeRef LLVMIntType(unsigned NumBits);
1167 unsigned LLVMGetIntTypeWidth(LLVMTypeRef IntegerTy);
1170 * @}
1174 * @defgroup LLVMCCoreTypeFloat Floating Point Types
1176 * @{
1180 * Obtain a 16-bit floating point type from a context.
1182 LLVMTypeRef LLVMHalfTypeInContext(LLVMContextRef C);
1185 * Obtain a 16-bit brain floating point type from a context.
1187 LLVMTypeRef LLVMBFloatTypeInContext(LLVMContextRef C);
1190 * Obtain a 32-bit floating point type from a context.
1192 LLVMTypeRef LLVMFloatTypeInContext(LLVMContextRef C);
1195 * Obtain a 64-bit floating point type from a context.
1197 LLVMTypeRef LLVMDoubleTypeInContext(LLVMContextRef C);
1200 * Obtain a 80-bit floating point type (X87) from a context.
1202 LLVMTypeRef LLVMX86FP80TypeInContext(LLVMContextRef C);
1205 * Obtain a 128-bit floating point type (112-bit mantissa) from a
1206 * context.
1208 LLVMTypeRef LLVMFP128TypeInContext(LLVMContextRef C);
1211 * Obtain a 128-bit floating point type (two 64-bits) from a context.
1213 LLVMTypeRef LLVMPPCFP128TypeInContext(LLVMContextRef C);
1216 * Obtain a floating point type from the global context.
1218 * These map to the functions in this group of the same name.
1220 LLVMTypeRef LLVMHalfType(void);
1221 LLVMTypeRef LLVMBFloatType(void);
1222 LLVMTypeRef LLVMFloatType(void);
1223 LLVMTypeRef LLVMDoubleType(void);
1224 LLVMTypeRef LLVMX86FP80Type(void);
1225 LLVMTypeRef LLVMFP128Type(void);
1226 LLVMTypeRef LLVMPPCFP128Type(void);
1229 * @}
1233 * @defgroup LLVMCCoreTypeFunction Function Types
1235 * @{
1239 * Obtain a function type consisting of a specified signature.
1241 * The function is defined as a tuple of a return Type, a list of
1242 * parameter types, and whether the function is variadic.
1244 LLVMTypeRef LLVMFunctionType(LLVMTypeRef ReturnType,
1245 LLVMTypeRef *ParamTypes, unsigned ParamCount,
1246 LLVMBool IsVarArg);
1249 * Returns whether a function type is variadic.
1251 LLVMBool LLVMIsFunctionVarArg(LLVMTypeRef FunctionTy);
1254 * Obtain the Type this function Type returns.
1256 LLVMTypeRef LLVMGetReturnType(LLVMTypeRef FunctionTy);
1259 * Obtain the number of parameters this function accepts.
1261 unsigned LLVMCountParamTypes(LLVMTypeRef FunctionTy);
1264 * Obtain the types of a function's parameters.
1266 * The Dest parameter should point to a pre-allocated array of
1267 * LLVMTypeRef at least LLVMCountParamTypes() large. On return, the
1268 * first LLVMCountParamTypes() entries in the array will be populated
1269 * with LLVMTypeRef instances.
1271 * @param FunctionTy The function type to operate on.
1272 * @param Dest Memory address of an array to be filled with result.
1274 void LLVMGetParamTypes(LLVMTypeRef FunctionTy, LLVMTypeRef *Dest);
1277 * @}
1281 * @defgroup LLVMCCoreTypeStruct Structure Types
1283 * These functions relate to LLVMTypeRef instances.
1285 * @see llvm::StructType
1287 * @{
1291 * Create a new structure type in a context.
1293 * A structure is specified by a list of inner elements/types and
1294 * whether these can be packed together.
1296 * @see llvm::StructType::create()
1298 LLVMTypeRef LLVMStructTypeInContext(LLVMContextRef C, LLVMTypeRef *ElementTypes,
1299 unsigned ElementCount, LLVMBool Packed);
1302 * Create a new structure type in the global context.
1304 * @see llvm::StructType::create()
1306 LLVMTypeRef LLVMStructType(LLVMTypeRef *ElementTypes, unsigned ElementCount,
1307 LLVMBool Packed);
1310 * Create an empty structure in a context having a specified name.
1312 * @see llvm::StructType::create()
1314 LLVMTypeRef LLVMStructCreateNamed(LLVMContextRef C, const char *Name);
1317 * Obtain the name of a structure.
1319 * @see llvm::StructType::getName()
1321 const char *LLVMGetStructName(LLVMTypeRef Ty);
1324 * Set the contents of a structure type.
1326 * @see llvm::StructType::setBody()
1328 void LLVMStructSetBody(LLVMTypeRef StructTy, LLVMTypeRef *ElementTypes,
1329 unsigned ElementCount, LLVMBool Packed);
1332 * Get the number of elements defined inside the structure.
1334 * @see llvm::StructType::getNumElements()
1336 unsigned LLVMCountStructElementTypes(LLVMTypeRef StructTy);
1339 * Get the elements within a structure.
1341 * The function is passed the address of a pre-allocated array of
1342 * LLVMTypeRef at least LLVMCountStructElementTypes() long. After
1343 * invocation, this array will be populated with the structure's
1344 * elements. The objects in the destination array will have a lifetime
1345 * of the structure type itself, which is the lifetime of the context it
1346 * is contained in.
1348 void LLVMGetStructElementTypes(LLVMTypeRef StructTy, LLVMTypeRef *Dest);
1351 * Get the type of the element at a given index in the structure.
1353 * @see llvm::StructType::getTypeAtIndex()
1355 LLVMTypeRef LLVMStructGetTypeAtIndex(LLVMTypeRef StructTy, unsigned i);
1358 * Determine whether a structure is packed.
1360 * @see llvm::StructType::isPacked()
1362 LLVMBool LLVMIsPackedStruct(LLVMTypeRef StructTy);
1365 * Determine whether a structure is opaque.
1367 * @see llvm::StructType::isOpaque()
1369 LLVMBool LLVMIsOpaqueStruct(LLVMTypeRef StructTy);
1372 * Determine whether a structure is literal.
1374 * @see llvm::StructType::isLiteral()
1376 LLVMBool LLVMIsLiteralStruct(LLVMTypeRef StructTy);
1379 * @}
1383 * @defgroup LLVMCCoreTypeSequential Sequential Types
1385 * Sequential types represents "arrays" of types. This is a super class
1386 * for array, vector, and pointer types.
1388 * @{
1392 * Obtain the type of elements within a sequential type.
1394 * This works on array, vector, and pointer types.
1396 * @see llvm::SequentialType::getElementType()
1398 LLVMTypeRef LLVMGetElementType(LLVMTypeRef Ty);
1401 * Returns type's subtypes
1403 * @see llvm::Type::subtypes()
1405 void LLVMGetSubtypes(LLVMTypeRef Tp, LLVMTypeRef *Arr);
1408 * Return the number of types in the derived type.
1410 * @see llvm::Type::getNumContainedTypes()
1412 unsigned LLVMGetNumContainedTypes(LLVMTypeRef Tp);
1415 * Create a fixed size array type that refers to a specific type.
1417 * The created type will exist in the context that its element type
1418 * exists in.
1420 * @see llvm::ArrayType::get()
1422 LLVMTypeRef LLVMArrayType(LLVMTypeRef ElementType, unsigned ElementCount);
1425 * Obtain the length of an array type.
1427 * This only works on types that represent arrays.
1429 * @see llvm::ArrayType::getNumElements()
1431 unsigned LLVMGetArrayLength(LLVMTypeRef ArrayTy);
1434 * Create a pointer type that points to a defined type.
1436 * The created type will exist in the context that its pointee type
1437 * exists in.
1439 * @see llvm::PointerType::get()
1441 LLVMTypeRef LLVMPointerType(LLVMTypeRef ElementType, unsigned AddressSpace);
1444 * Obtain the address space of a pointer type.
1446 * This only works on types that represent pointers.
1448 * @see llvm::PointerType::getAddressSpace()
1450 unsigned LLVMGetPointerAddressSpace(LLVMTypeRef PointerTy);
1453 * Create a vector type that contains a defined type and has a specific
1454 * number of elements.
1456 * The created type will exist in the context thats its element type
1457 * exists in.
1459 * @see llvm::VectorType::get()
1461 LLVMTypeRef LLVMVectorType(LLVMTypeRef ElementType, unsigned ElementCount);
1464 * Create a vector type that contains a defined type and has a scalable
1465 * number of elements.
1467 * The created type will exist in the context thats its element type
1468 * exists in.
1470 * @see llvm::ScalableVectorType::get()
1472 LLVMTypeRef LLVMScalableVectorType(LLVMTypeRef ElementType,
1473 unsigned ElementCount);
1476 * Obtain the (possibly scalable) number of elements in a vector type.
1478 * This only works on types that represent vectors (fixed or scalable).
1480 * @see llvm::VectorType::getNumElements()
1482 unsigned LLVMGetVectorSize(LLVMTypeRef VectorTy);
1485 * @}
1489 * @defgroup LLVMCCoreTypeOther Other Types
1491 * @{
1495 * Create a void type in a context.
1497 LLVMTypeRef LLVMVoidTypeInContext(LLVMContextRef C);
1500 * Create a label type in a context.
1502 LLVMTypeRef LLVMLabelTypeInContext(LLVMContextRef C);
1505 * Create a X86 MMX type in a context.
1507 LLVMTypeRef LLVMX86MMXTypeInContext(LLVMContextRef C);
1510 * Create a X86 AMX type in a context.
1512 LLVMTypeRef LLVMX86AMXTypeInContext(LLVMContextRef C);
1515 * Create a token type in a context.
1517 LLVMTypeRef LLVMTokenTypeInContext(LLVMContextRef C);
1520 * Create a metadata type in a context.
1522 LLVMTypeRef LLVMMetadataTypeInContext(LLVMContextRef C);
1525 * These are similar to the above functions except they operate on the
1526 * global context.
1528 LLVMTypeRef LLVMVoidType(void);
1529 LLVMTypeRef LLVMLabelType(void);
1530 LLVMTypeRef LLVMX86MMXType(void);
1531 LLVMTypeRef LLVMX86AMXType(void);
1534 * @}
1538 * @}
1542 * @defgroup LLVMCCoreValues Values
1544 * The bulk of LLVM's object model consists of values, which comprise a very
1545 * rich type hierarchy.
1547 * LLVMValueRef essentially represents llvm::Value. There is a rich
1548 * hierarchy of classes within this type. Depending on the instance
1549 * obtained, not all APIs are available.
1551 * Callers can determine the type of an LLVMValueRef by calling the
1552 * LLVMIsA* family of functions (e.g. LLVMIsAArgument()). These
1553 * functions are defined by a macro, so it isn't obvious which are
1554 * available by looking at the Doxygen source code. Instead, look at the
1555 * source definition of LLVM_FOR_EACH_VALUE_SUBCLASS and note the list
1556 * of value names given. These value names also correspond to classes in
1557 * the llvm::Value hierarchy.
1559 * @{
1562 #define LLVM_FOR_EACH_VALUE_SUBCLASS(macro) \
1563 macro(Argument) \
1564 macro(BasicBlock) \
1565 macro(InlineAsm) \
1566 macro(User) \
1567 macro(Constant) \
1568 macro(BlockAddress) \
1569 macro(ConstantAggregateZero) \
1570 macro(ConstantArray) \
1571 macro(ConstantDataSequential) \
1572 macro(ConstantDataArray) \
1573 macro(ConstantDataVector) \
1574 macro(ConstantExpr) \
1575 macro(ConstantFP) \
1576 macro(ConstantInt) \
1577 macro(ConstantPointerNull) \
1578 macro(ConstantStruct) \
1579 macro(ConstantTokenNone) \
1580 macro(ConstantVector) \
1581 macro(GlobalValue) \
1582 macro(GlobalAlias) \
1583 macro(GlobalIFunc) \
1584 macro(GlobalObject) \
1585 macro(Function) \
1586 macro(GlobalVariable) \
1587 macro(UndefValue) \
1588 macro(PoisonValue) \
1589 macro(Instruction) \
1590 macro(UnaryOperator) \
1591 macro(BinaryOperator) \
1592 macro(CallInst) \
1593 macro(IntrinsicInst) \
1594 macro(DbgInfoIntrinsic) \
1595 macro(DbgVariableIntrinsic) \
1596 macro(DbgDeclareInst) \
1597 macro(DbgLabelInst) \
1598 macro(MemIntrinsic) \
1599 macro(MemCpyInst) \
1600 macro(MemMoveInst) \
1601 macro(MemSetInst) \
1602 macro(CmpInst) \
1603 macro(FCmpInst) \
1604 macro(ICmpInst) \
1605 macro(ExtractElementInst) \
1606 macro(GetElementPtrInst) \
1607 macro(InsertElementInst) \
1608 macro(InsertValueInst) \
1609 macro(LandingPadInst) \
1610 macro(PHINode) \
1611 macro(SelectInst) \
1612 macro(ShuffleVectorInst) \
1613 macro(StoreInst) \
1614 macro(BranchInst) \
1615 macro(IndirectBrInst) \
1616 macro(InvokeInst) \
1617 macro(ReturnInst) \
1618 macro(SwitchInst) \
1619 macro(UnreachableInst) \
1620 macro(ResumeInst) \
1621 macro(CleanupReturnInst) \
1622 macro(CatchReturnInst) \
1623 macro(CatchSwitchInst) \
1624 macro(CallBrInst) \
1625 macro(FuncletPadInst) \
1626 macro(CatchPadInst) \
1627 macro(CleanupPadInst) \
1628 macro(UnaryInstruction) \
1629 macro(AllocaInst) \
1630 macro(CastInst) \
1631 macro(AddrSpaceCastInst) \
1632 macro(BitCastInst) \
1633 macro(FPExtInst) \
1634 macro(FPToSIInst) \
1635 macro(FPToUIInst) \
1636 macro(FPTruncInst) \
1637 macro(IntToPtrInst) \
1638 macro(PtrToIntInst) \
1639 macro(SExtInst) \
1640 macro(SIToFPInst) \
1641 macro(TruncInst) \
1642 macro(UIToFPInst) \
1643 macro(ZExtInst) \
1644 macro(ExtractValueInst) \
1645 macro(LoadInst) \
1646 macro(VAArgInst) \
1647 macro(FreezeInst) \
1648 macro(AtomicCmpXchgInst) \
1649 macro(AtomicRMWInst) \
1650 macro(FenceInst)
1653 * @defgroup LLVMCCoreValueGeneral General APIs
1655 * Functions in this section work on all LLVMValueRef instances,
1656 * regardless of their sub-type. They correspond to functions available
1657 * on llvm::Value.
1659 * @{
1663 * Obtain the type of a value.
1665 * @see llvm::Value::getType()
1667 LLVMTypeRef LLVMTypeOf(LLVMValueRef Val);
1670 * Obtain the enumerated type of a Value instance.
1672 * @see llvm::Value::getValueID()
1674 LLVMValueKind LLVMGetValueKind(LLVMValueRef Val);
1677 * Obtain the string name of a value.
1679 * @see llvm::Value::getName()
1681 const char *LLVMGetValueName2(LLVMValueRef Val, size_t *Length);
1684 * Set the string name of a value.
1686 * @see llvm::Value::setName()
1688 void LLVMSetValueName2(LLVMValueRef Val, const char *Name, size_t NameLen);
1691 * Dump a representation of a value to stderr.
1693 * @see llvm::Value::dump()
1695 void LLVMDumpValue(LLVMValueRef Val);
1698 * Return a string representation of the value. Use
1699 * LLVMDisposeMessage to free the string.
1701 * @see llvm::Value::print()
1703 char *LLVMPrintValueToString(LLVMValueRef Val);
1706 * Replace all uses of a value with another one.
1708 * @see llvm::Value::replaceAllUsesWith()
1710 void LLVMReplaceAllUsesWith(LLVMValueRef OldVal, LLVMValueRef NewVal);
1713 * Determine whether the specified value instance is constant.
1715 LLVMBool LLVMIsConstant(LLVMValueRef Val);
1718 * Determine whether a value instance is undefined.
1720 LLVMBool LLVMIsUndef(LLVMValueRef Val);
1723 * Determine whether a value instance is poisonous.
1725 LLVMBool LLVMIsPoison(LLVMValueRef Val);
1728 * Convert value instances between types.
1730 * Internally, an LLVMValueRef is "pinned" to a specific type. This
1731 * series of functions allows you to cast an instance to a specific
1732 * type.
1734 * If the cast is not valid for the specified type, NULL is returned.
1736 * @see llvm::dyn_cast_or_null<>
1738 #define LLVM_DECLARE_VALUE_CAST(name) \
1739 LLVMValueRef LLVMIsA##name(LLVMValueRef Val);
1740 LLVM_FOR_EACH_VALUE_SUBCLASS(LLVM_DECLARE_VALUE_CAST)
1742 LLVMValueRef LLVMIsAMDNode(LLVMValueRef Val);
1743 LLVMValueRef LLVMIsAMDString(LLVMValueRef Val);
1745 /** Deprecated: Use LLVMGetValueName2 instead. */
1746 const char *LLVMGetValueName(LLVMValueRef Val);
1747 /** Deprecated: Use LLVMSetValueName2 instead. */
1748 void LLVMSetValueName(LLVMValueRef Val, const char *Name);
1751 * @}
1755 * @defgroup LLVMCCoreValueUses Usage
1757 * This module defines functions that allow you to inspect the uses of a
1758 * LLVMValueRef.
1760 * It is possible to obtain an LLVMUseRef for any LLVMValueRef instance.
1761 * Each LLVMUseRef (which corresponds to a llvm::Use instance) holds a
1762 * llvm::User and llvm::Value.
1764 * @{
1768 * Obtain the first use of a value.
1770 * Uses are obtained in an iterator fashion. First, call this function
1771 * to obtain a reference to the first use. Then, call LLVMGetNextUse()
1772 * on that instance and all subsequently obtained instances until
1773 * LLVMGetNextUse() returns NULL.
1775 * @see llvm::Value::use_begin()
1777 LLVMUseRef LLVMGetFirstUse(LLVMValueRef Val);
1780 * Obtain the next use of a value.
1782 * This effectively advances the iterator. It returns NULL if you are on
1783 * the final use and no more are available.
1785 LLVMUseRef LLVMGetNextUse(LLVMUseRef U);
1788 * Obtain the user value for a user.
1790 * The returned value corresponds to a llvm::User type.
1792 * @see llvm::Use::getUser()
1794 LLVMValueRef LLVMGetUser(LLVMUseRef U);
1797 * Obtain the value this use corresponds to.
1799 * @see llvm::Use::get().
1801 LLVMValueRef LLVMGetUsedValue(LLVMUseRef U);
1804 * @}
1808 * @defgroup LLVMCCoreValueUser User value
1810 * Function in this group pertain to LLVMValueRef instances that descent
1811 * from llvm::User. This includes constants, instructions, and
1812 * operators.
1814 * @{
1818 * Obtain an operand at a specific index in a llvm::User value.
1820 * @see llvm::User::getOperand()
1822 LLVMValueRef LLVMGetOperand(LLVMValueRef Val, unsigned Index);
1825 * Obtain the use of an operand at a specific index in a llvm::User value.
1827 * @see llvm::User::getOperandUse()
1829 LLVMUseRef LLVMGetOperandUse(LLVMValueRef Val, unsigned Index);
1832 * Set an operand at a specific index in a llvm::User value.
1834 * @see llvm::User::setOperand()
1836 void LLVMSetOperand(LLVMValueRef User, unsigned Index, LLVMValueRef Val);
1839 * Obtain the number of operands in a llvm::User value.
1841 * @see llvm::User::getNumOperands()
1843 int LLVMGetNumOperands(LLVMValueRef Val);
1846 * @}
1850 * @defgroup LLVMCCoreValueConstant Constants
1852 * This section contains APIs for interacting with LLVMValueRef that
1853 * correspond to llvm::Constant instances.
1855 * These functions will work for any LLVMValueRef in the llvm::Constant
1856 * class hierarchy.
1858 * @{
1862 * Obtain a constant value referring to the null instance of a type.
1864 * @see llvm::Constant::getNullValue()
1866 LLVMValueRef LLVMConstNull(LLVMTypeRef Ty); /* all zeroes */
1869 * Obtain a constant value referring to the instance of a type
1870 * consisting of all ones.
1872 * This is only valid for integer types.
1874 * @see llvm::Constant::getAllOnesValue()
1876 LLVMValueRef LLVMConstAllOnes(LLVMTypeRef Ty);
1879 * Obtain a constant value referring to an undefined value of a type.
1881 * @see llvm::UndefValue::get()
1883 LLVMValueRef LLVMGetUndef(LLVMTypeRef Ty);
1886 * Obtain a constant value referring to a poison value of a type.
1888 * @see llvm::PoisonValue::get()
1890 LLVMValueRef LLVMGetPoison(LLVMTypeRef Ty);
1893 * Determine whether a value instance is null.
1895 * @see llvm::Constant::isNullValue()
1897 LLVMBool LLVMIsNull(LLVMValueRef Val);
1900 * Obtain a constant that is a constant pointer pointing to NULL for a
1901 * specified type.
1903 LLVMValueRef LLVMConstPointerNull(LLVMTypeRef Ty);
1906 * @defgroup LLVMCCoreValueConstantScalar Scalar constants
1908 * Functions in this group model LLVMValueRef instances that correspond
1909 * to constants referring to scalar types.
1911 * For integer types, the LLVMTypeRef parameter should correspond to a
1912 * llvm::IntegerType instance and the returned LLVMValueRef will
1913 * correspond to a llvm::ConstantInt.
1915 * For floating point types, the LLVMTypeRef returned corresponds to a
1916 * llvm::ConstantFP.
1918 * @{
1922 * Obtain a constant value for an integer type.
1924 * The returned value corresponds to a llvm::ConstantInt.
1926 * @see llvm::ConstantInt::get()
1928 * @param IntTy Integer type to obtain value of.
1929 * @param N The value the returned instance should refer to.
1930 * @param SignExtend Whether to sign extend the produced value.
1932 LLVMValueRef LLVMConstInt(LLVMTypeRef IntTy, unsigned long long N,
1933 LLVMBool SignExtend);
1936 * Obtain a constant value for an integer of arbitrary precision.
1938 * @see llvm::ConstantInt::get()
1940 LLVMValueRef LLVMConstIntOfArbitraryPrecision(LLVMTypeRef IntTy,
1941 unsigned NumWords,
1942 const uint64_t Words[]);
1945 * Obtain a constant value for an integer parsed from a string.
1947 * A similar API, LLVMConstIntOfStringAndSize is also available. If the
1948 * string's length is available, it is preferred to call that function
1949 * instead.
1951 * @see llvm::ConstantInt::get()
1953 LLVMValueRef LLVMConstIntOfString(LLVMTypeRef IntTy, const char *Text,
1954 uint8_t Radix);
1957 * Obtain a constant value for an integer parsed from a string with
1958 * specified length.
1960 * @see llvm::ConstantInt::get()
1962 LLVMValueRef LLVMConstIntOfStringAndSize(LLVMTypeRef IntTy, const char *Text,
1963 unsigned SLen, uint8_t Radix);
1966 * Obtain a constant value referring to a double floating point value.
1968 LLVMValueRef LLVMConstReal(LLVMTypeRef RealTy, double N);
1971 * Obtain a constant for a floating point value parsed from a string.
1973 * A similar API, LLVMConstRealOfStringAndSize is also available. It
1974 * should be used if the input string's length is known.
1976 LLVMValueRef LLVMConstRealOfString(LLVMTypeRef RealTy, const char *Text);
1979 * Obtain a constant for a floating point value parsed from a string.
1981 LLVMValueRef LLVMConstRealOfStringAndSize(LLVMTypeRef RealTy, const char *Text,
1982 unsigned SLen);
1985 * Obtain the zero extended value for an integer constant value.
1987 * @see llvm::ConstantInt::getZExtValue()
1989 unsigned long long LLVMConstIntGetZExtValue(LLVMValueRef ConstantVal);
1992 * Obtain the sign extended value for an integer constant value.
1994 * @see llvm::ConstantInt::getSExtValue()
1996 long long LLVMConstIntGetSExtValue(LLVMValueRef ConstantVal);
1999 * Obtain the double value for an floating point constant value.
2000 * losesInfo indicates if some precision was lost in the conversion.
2002 * @see llvm::ConstantFP::getDoubleValue
2004 double LLVMConstRealGetDouble(LLVMValueRef ConstantVal, LLVMBool *losesInfo);
2007 * @}
2011 * @defgroup LLVMCCoreValueConstantComposite Composite Constants
2013 * Functions in this group operate on composite constants.
2015 * @{
2019 * Create a ConstantDataSequential and initialize it with a string.
2021 * @see llvm::ConstantDataArray::getString()
2023 LLVMValueRef LLVMConstStringInContext(LLVMContextRef C, const char *Str,
2024 unsigned Length, LLVMBool DontNullTerminate);
2027 * Create a ConstantDataSequential with string content in the global context.
2029 * This is the same as LLVMConstStringInContext except it operates on the
2030 * global context.
2032 * @see LLVMConstStringInContext()
2033 * @see llvm::ConstantDataArray::getString()
2035 LLVMValueRef LLVMConstString(const char *Str, unsigned Length,
2036 LLVMBool DontNullTerminate);
2039 * Returns true if the specified constant is an array of i8.
2041 * @see ConstantDataSequential::getAsString()
2043 LLVMBool LLVMIsConstantString(LLVMValueRef c);
2046 * Get the given constant data sequential as a string.
2048 * @see ConstantDataSequential::getAsString()
2050 const char *LLVMGetAsString(LLVMValueRef c, size_t *Length);
2053 * Create an anonymous ConstantStruct with the specified values.
2055 * @see llvm::ConstantStruct::getAnon()
2057 LLVMValueRef LLVMConstStructInContext(LLVMContextRef C,
2058 LLVMValueRef *ConstantVals,
2059 unsigned Count, LLVMBool Packed);
2062 * Create a ConstantStruct in the global Context.
2064 * This is the same as LLVMConstStructInContext except it operates on the
2065 * global Context.
2067 * @see LLVMConstStructInContext()
2069 LLVMValueRef LLVMConstStruct(LLVMValueRef *ConstantVals, unsigned Count,
2070 LLVMBool Packed);
2073 * Create a ConstantArray from values.
2075 * @see llvm::ConstantArray::get()
2077 LLVMValueRef LLVMConstArray(LLVMTypeRef ElementTy,
2078 LLVMValueRef *ConstantVals, unsigned Length);
2081 * Create a non-anonymous ConstantStruct from values.
2083 * @see llvm::ConstantStruct::get()
2085 LLVMValueRef LLVMConstNamedStruct(LLVMTypeRef StructTy,
2086 LLVMValueRef *ConstantVals,
2087 unsigned Count);
2090 * Get an element at specified index as a constant.
2092 * @see ConstantDataSequential::getElementAsConstant()
2094 LLVMValueRef LLVMGetElementAsConstant(LLVMValueRef C, unsigned idx);
2097 * Create a ConstantVector from values.
2099 * @see llvm::ConstantVector::get()
2101 LLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals, unsigned Size);
2104 * @}
2108 * @defgroup LLVMCCoreValueConstantExpressions Constant Expressions
2110 * Functions in this group correspond to APIs on llvm::ConstantExpr.
2112 * @see llvm::ConstantExpr.
2114 * @{
2116 LLVMOpcode LLVMGetConstOpcode(LLVMValueRef ConstantVal);
2117 LLVMValueRef LLVMAlignOf(LLVMTypeRef Ty);
2118 LLVMValueRef LLVMSizeOf(LLVMTypeRef Ty);
2119 LLVMValueRef LLVMConstNeg(LLVMValueRef ConstantVal);
2120 LLVMValueRef LLVMConstNSWNeg(LLVMValueRef ConstantVal);
2121 LLVMValueRef LLVMConstNUWNeg(LLVMValueRef ConstantVal);
2122 LLVMValueRef LLVMConstFNeg(LLVMValueRef ConstantVal);
2123 LLVMValueRef LLVMConstNot(LLVMValueRef ConstantVal);
2124 LLVMValueRef LLVMConstAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2125 LLVMValueRef LLVMConstNSWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2126 LLVMValueRef LLVMConstNUWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2127 LLVMValueRef LLVMConstFAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2128 LLVMValueRef LLVMConstSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2129 LLVMValueRef LLVMConstNSWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2130 LLVMValueRef LLVMConstNUWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2131 LLVMValueRef LLVMConstFSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2132 LLVMValueRef LLVMConstMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2133 LLVMValueRef LLVMConstNSWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2134 LLVMValueRef LLVMConstNUWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2135 LLVMValueRef LLVMConstFMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2136 LLVMValueRef LLVMConstUDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2137 LLVMValueRef LLVMConstExactUDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2138 LLVMValueRef LLVMConstSDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2139 LLVMValueRef LLVMConstExactSDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2140 LLVMValueRef LLVMConstFDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2141 LLVMValueRef LLVMConstURem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2142 LLVMValueRef LLVMConstSRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2143 LLVMValueRef LLVMConstFRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2144 LLVMValueRef LLVMConstAnd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2145 LLVMValueRef LLVMConstOr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2146 LLVMValueRef LLVMConstXor(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2147 LLVMValueRef LLVMConstICmp(LLVMIntPredicate Predicate,
2148 LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2149 LLVMValueRef LLVMConstFCmp(LLVMRealPredicate Predicate,
2150 LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2151 LLVMValueRef LLVMConstShl(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2152 LLVMValueRef LLVMConstLShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2153 LLVMValueRef LLVMConstAShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2154 LLVMValueRef LLVMConstGEP(LLVMValueRef ConstantVal,
2155 LLVMValueRef *ConstantIndices, unsigned NumIndices);
2156 LLVMValueRef LLVMConstGEP2(LLVMTypeRef Ty, LLVMValueRef ConstantVal,
2157 LLVMValueRef *ConstantIndices, unsigned NumIndices);
2158 LLVMValueRef LLVMConstInBoundsGEP(LLVMValueRef ConstantVal,
2159 LLVMValueRef *ConstantIndices,
2160 unsigned NumIndices);
2161 LLVMValueRef LLVMConstInBoundsGEP2(LLVMTypeRef Ty, LLVMValueRef ConstantVal,
2162 LLVMValueRef *ConstantIndices,
2163 unsigned NumIndices);
2164 LLVMValueRef LLVMConstTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
2165 LLVMValueRef LLVMConstSExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
2166 LLVMValueRef LLVMConstZExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
2167 LLVMValueRef LLVMConstFPTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
2168 LLVMValueRef LLVMConstFPExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
2169 LLVMValueRef LLVMConstUIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
2170 LLVMValueRef LLVMConstSIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
2171 LLVMValueRef LLVMConstFPToUI(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
2172 LLVMValueRef LLVMConstFPToSI(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
2173 LLVMValueRef LLVMConstPtrToInt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
2174 LLVMValueRef LLVMConstIntToPtr(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
2175 LLVMValueRef LLVMConstBitCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
2176 LLVMValueRef LLVMConstAddrSpaceCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
2177 LLVMValueRef LLVMConstZExtOrBitCast(LLVMValueRef ConstantVal,
2178 LLVMTypeRef ToType);
2179 LLVMValueRef LLVMConstSExtOrBitCast(LLVMValueRef ConstantVal,
2180 LLVMTypeRef ToType);
2181 LLVMValueRef LLVMConstTruncOrBitCast(LLVMValueRef ConstantVal,
2182 LLVMTypeRef ToType);
2183 LLVMValueRef LLVMConstPointerCast(LLVMValueRef ConstantVal,
2184 LLVMTypeRef ToType);
2185 LLVMValueRef LLVMConstIntCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType,
2186 LLVMBool isSigned);
2187 LLVMValueRef LLVMConstFPCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
2188 LLVMValueRef LLVMConstSelect(LLVMValueRef ConstantCondition,
2189 LLVMValueRef ConstantIfTrue,
2190 LLVMValueRef ConstantIfFalse);
2191 LLVMValueRef LLVMConstExtractElement(LLVMValueRef VectorConstant,
2192 LLVMValueRef IndexConstant);
2193 LLVMValueRef LLVMConstInsertElement(LLVMValueRef VectorConstant,
2194 LLVMValueRef ElementValueConstant,
2195 LLVMValueRef IndexConstant);
2196 LLVMValueRef LLVMConstShuffleVector(LLVMValueRef VectorAConstant,
2197 LLVMValueRef VectorBConstant,
2198 LLVMValueRef MaskConstant);
2199 LLVMValueRef LLVMConstExtractValue(LLVMValueRef AggConstant, unsigned *IdxList,
2200 unsigned NumIdx);
2201 LLVMValueRef LLVMConstInsertValue(LLVMValueRef AggConstant,
2202 LLVMValueRef ElementValueConstant,
2203 unsigned *IdxList, unsigned NumIdx);
2204 LLVMValueRef LLVMBlockAddress(LLVMValueRef F, LLVMBasicBlockRef BB);
2206 /** Deprecated: Use LLVMGetInlineAsm instead. */
2207 LLVMValueRef LLVMConstInlineAsm(LLVMTypeRef Ty,
2208 const char *AsmString, const char *Constraints,
2209 LLVMBool HasSideEffects, LLVMBool IsAlignStack);
2212 * @}
2216 * @defgroup LLVMCCoreValueConstantGlobals Global Values
2218 * This group contains functions that operate on global values. Functions in
2219 * this group relate to functions in the llvm::GlobalValue class tree.
2221 * @see llvm::GlobalValue
2223 * @{
2226 LLVMModuleRef LLVMGetGlobalParent(LLVMValueRef Global);
2227 LLVMBool LLVMIsDeclaration(LLVMValueRef Global);
2228 LLVMLinkage LLVMGetLinkage(LLVMValueRef Global);
2229 void LLVMSetLinkage(LLVMValueRef Global, LLVMLinkage Linkage);
2230 const char *LLVMGetSection(LLVMValueRef Global);
2231 void LLVMSetSection(LLVMValueRef Global, const char *Section);
2232 LLVMVisibility LLVMGetVisibility(LLVMValueRef Global);
2233 void LLVMSetVisibility(LLVMValueRef Global, LLVMVisibility Viz);
2234 LLVMDLLStorageClass LLVMGetDLLStorageClass(LLVMValueRef Global);
2235 void LLVMSetDLLStorageClass(LLVMValueRef Global, LLVMDLLStorageClass Class);
2236 LLVMUnnamedAddr LLVMGetUnnamedAddress(LLVMValueRef Global);
2237 void LLVMSetUnnamedAddress(LLVMValueRef Global, LLVMUnnamedAddr UnnamedAddr);
2240 * Returns the "value type" of a global value. This differs from the formal
2241 * type of a global value which is always a pointer type.
2243 * @see llvm::GlobalValue::getValueType()
2245 LLVMTypeRef LLVMGlobalGetValueType(LLVMValueRef Global);
2247 /** Deprecated: Use LLVMGetUnnamedAddress instead. */
2248 LLVMBool LLVMHasUnnamedAddr(LLVMValueRef Global);
2249 /** Deprecated: Use LLVMSetUnnamedAddress instead. */
2250 void LLVMSetUnnamedAddr(LLVMValueRef Global, LLVMBool HasUnnamedAddr);
2253 * @defgroup LLVMCCoreValueWithAlignment Values with alignment
2255 * Functions in this group only apply to values with alignment, i.e.
2256 * global variables, load and store instructions.
2260 * Obtain the preferred alignment of the value.
2261 * @see llvm::AllocaInst::getAlignment()
2262 * @see llvm::LoadInst::getAlignment()
2263 * @see llvm::StoreInst::getAlignment()
2264 * @see llvm::AtomicRMWInst::setAlignment()
2265 * @see llvm::AtomicCmpXchgInst::setAlignment()
2266 * @see llvm::GlobalValue::getAlignment()
2268 unsigned LLVMGetAlignment(LLVMValueRef V);
2271 * Set the preferred alignment of the value.
2272 * @see llvm::AllocaInst::setAlignment()
2273 * @see llvm::LoadInst::setAlignment()
2274 * @see llvm::StoreInst::setAlignment()
2275 * @see llvm::AtomicRMWInst::setAlignment()
2276 * @see llvm::AtomicCmpXchgInst::setAlignment()
2277 * @see llvm::GlobalValue::setAlignment()
2279 void LLVMSetAlignment(LLVMValueRef V, unsigned Bytes);
2282 * Sets a metadata attachment, erasing the existing metadata attachment if
2283 * it already exists for the given kind.
2285 * @see llvm::GlobalObject::setMetadata()
2287 void LLVMGlobalSetMetadata(LLVMValueRef Global, unsigned Kind,
2288 LLVMMetadataRef MD);
2291 * Erases a metadata attachment of the given kind if it exists.
2293 * @see llvm::GlobalObject::eraseMetadata()
2295 void LLVMGlobalEraseMetadata(LLVMValueRef Global, unsigned Kind);
2298 * Removes all metadata attachments from this value.
2300 * @see llvm::GlobalObject::clearMetadata()
2302 void LLVMGlobalClearMetadata(LLVMValueRef Global);
2305 * Retrieves an array of metadata entries representing the metadata attached to
2306 * this value. The caller is responsible for freeing this array by calling
2307 * \c LLVMDisposeValueMetadataEntries.
2309 * @see llvm::GlobalObject::getAllMetadata()
2311 LLVMValueMetadataEntry *LLVMGlobalCopyAllMetadata(LLVMValueRef Value,
2312 size_t *NumEntries);
2315 * Destroys value metadata entries.
2317 void LLVMDisposeValueMetadataEntries(LLVMValueMetadataEntry *Entries);
2320 * Returns the kind of a value metadata entry at a specific index.
2322 unsigned LLVMValueMetadataEntriesGetKind(LLVMValueMetadataEntry *Entries,
2323 unsigned Index);
2326 * Returns the underlying metadata node of a value metadata entry at a
2327 * specific index.
2329 LLVMMetadataRef
2330 LLVMValueMetadataEntriesGetMetadata(LLVMValueMetadataEntry *Entries,
2331 unsigned Index);
2334 * @}
2338 * @defgroup LLVMCoreValueConstantGlobalVariable Global Variables
2340 * This group contains functions that operate on global variable values.
2342 * @see llvm::GlobalVariable
2344 * @{
2346 LLVMValueRef LLVMAddGlobal(LLVMModuleRef M, LLVMTypeRef Ty, const char *Name);
2347 LLVMValueRef LLVMAddGlobalInAddressSpace(LLVMModuleRef M, LLVMTypeRef Ty,
2348 const char *Name,
2349 unsigned AddressSpace);
2350 LLVMValueRef LLVMGetNamedGlobal(LLVMModuleRef M, const char *Name);
2351 LLVMValueRef LLVMGetFirstGlobal(LLVMModuleRef M);
2352 LLVMValueRef LLVMGetLastGlobal(LLVMModuleRef M);
2353 LLVMValueRef LLVMGetNextGlobal(LLVMValueRef GlobalVar);
2354 LLVMValueRef LLVMGetPreviousGlobal(LLVMValueRef GlobalVar);
2355 void LLVMDeleteGlobal(LLVMValueRef GlobalVar);
2356 LLVMValueRef LLVMGetInitializer(LLVMValueRef GlobalVar);
2357 void LLVMSetInitializer(LLVMValueRef GlobalVar, LLVMValueRef ConstantVal);
2358 LLVMBool LLVMIsThreadLocal(LLVMValueRef GlobalVar);
2359 void LLVMSetThreadLocal(LLVMValueRef GlobalVar, LLVMBool IsThreadLocal);
2360 LLVMBool LLVMIsGlobalConstant(LLVMValueRef GlobalVar);
2361 void LLVMSetGlobalConstant(LLVMValueRef GlobalVar, LLVMBool IsConstant);
2362 LLVMThreadLocalMode LLVMGetThreadLocalMode(LLVMValueRef GlobalVar);
2363 void LLVMSetThreadLocalMode(LLVMValueRef GlobalVar, LLVMThreadLocalMode Mode);
2364 LLVMBool LLVMIsExternallyInitialized(LLVMValueRef GlobalVar);
2365 void LLVMSetExternallyInitialized(LLVMValueRef GlobalVar, LLVMBool IsExtInit);
2368 * @}
2372 * @defgroup LLVMCoreValueConstantGlobalAlias Global Aliases
2374 * This group contains function that operate on global alias values.
2376 * @see llvm::GlobalAlias
2378 * @{
2380 LLVMValueRef LLVMAddAlias(LLVMModuleRef M, LLVMTypeRef Ty, LLVMValueRef Aliasee,
2381 const char *Name);
2384 * Obtain a GlobalAlias value from a Module by its name.
2386 * The returned value corresponds to a llvm::GlobalAlias value.
2388 * @see llvm::Module::getNamedAlias()
2390 LLVMValueRef LLVMGetNamedGlobalAlias(LLVMModuleRef M,
2391 const char *Name, size_t NameLen);
2394 * Obtain an iterator to the first GlobalAlias in a Module.
2396 * @see llvm::Module::alias_begin()
2398 LLVMValueRef LLVMGetFirstGlobalAlias(LLVMModuleRef M);
2401 * Obtain an iterator to the last GlobalAlias in a Module.
2403 * @see llvm::Module::alias_end()
2405 LLVMValueRef LLVMGetLastGlobalAlias(LLVMModuleRef M);
2408 * Advance a GlobalAlias iterator to the next GlobalAlias.
2410 * Returns NULL if the iterator was already at the end and there are no more
2411 * global aliases.
2413 LLVMValueRef LLVMGetNextGlobalAlias(LLVMValueRef GA);
2416 * Decrement a GlobalAlias iterator to the previous GlobalAlias.
2418 * Returns NULL if the iterator was already at the beginning and there are
2419 * no previous global aliases.
2421 LLVMValueRef LLVMGetPreviousGlobalAlias(LLVMValueRef GA);
2424 * Retrieve the target value of an alias.
2426 LLVMValueRef LLVMAliasGetAliasee(LLVMValueRef Alias);
2429 * Set the target value of an alias.
2431 void LLVMAliasSetAliasee(LLVMValueRef Alias, LLVMValueRef Aliasee);
2434 * @}
2438 * @defgroup LLVMCCoreValueFunction Function values
2440 * Functions in this group operate on LLVMValueRef instances that
2441 * correspond to llvm::Function instances.
2443 * @see llvm::Function
2445 * @{
2449 * Remove a function from its containing module and deletes it.
2451 * @see llvm::Function::eraseFromParent()
2453 void LLVMDeleteFunction(LLVMValueRef Fn);
2456 * Check whether the given function has a personality function.
2458 * @see llvm::Function::hasPersonalityFn()
2460 LLVMBool LLVMHasPersonalityFn(LLVMValueRef Fn);
2463 * Obtain the personality function attached to the function.
2465 * @see llvm::Function::getPersonalityFn()
2467 LLVMValueRef LLVMGetPersonalityFn(LLVMValueRef Fn);
2470 * Set the personality function attached to the function.
2472 * @see llvm::Function::setPersonalityFn()
2474 void LLVMSetPersonalityFn(LLVMValueRef Fn, LLVMValueRef PersonalityFn);
2477 * Obtain the intrinsic ID number which matches the given function name.
2479 * @see llvm::Function::lookupIntrinsicID()
2481 unsigned LLVMLookupIntrinsicID(const char *Name, size_t NameLen);
2484 * Obtain the ID number from a function instance.
2486 * @see llvm::Function::getIntrinsicID()
2488 unsigned LLVMGetIntrinsicID(LLVMValueRef Fn);
2491 * Create or insert the declaration of an intrinsic. For overloaded intrinsics,
2492 * parameter types must be provided to uniquely identify an overload.
2494 * @see llvm::Intrinsic::getDeclaration()
2496 LLVMValueRef LLVMGetIntrinsicDeclaration(LLVMModuleRef Mod,
2497 unsigned ID,
2498 LLVMTypeRef *ParamTypes,
2499 size_t ParamCount);
2502 * Retrieves the type of an intrinsic. For overloaded intrinsics, parameter
2503 * types must be provided to uniquely identify an overload.
2505 * @see llvm::Intrinsic::getType()
2507 LLVMTypeRef LLVMIntrinsicGetType(LLVMContextRef Ctx, unsigned ID,
2508 LLVMTypeRef *ParamTypes, size_t ParamCount);
2511 * Retrieves the name of an intrinsic.
2513 * @see llvm::Intrinsic::getName()
2515 const char *LLVMIntrinsicGetName(unsigned ID, size_t *NameLength);
2517 /** Deprecated: Use LLVMIntrinsicCopyOverloadedName2 instead. */
2518 const char *LLVMIntrinsicCopyOverloadedName(unsigned ID,
2519 LLVMTypeRef *ParamTypes,
2520 size_t ParamCount,
2521 size_t *NameLength);
2524 * Copies the name of an overloaded intrinsic identified by a given list of
2525 * parameter types.
2527 * Unlike LLVMIntrinsicGetName, the caller is responsible for freeing the
2528 * returned string.
2530 * This version also supports unnamed types.
2532 * @see llvm::Intrinsic::getName()
2534 const char *LLVMIntrinsicCopyOverloadedName2(LLVMModuleRef Mod, unsigned ID,
2535 LLVMTypeRef *ParamTypes,
2536 size_t ParamCount,
2537 size_t *NameLength);
2540 * Obtain if the intrinsic identified by the given ID is overloaded.
2542 * @see llvm::Intrinsic::isOverloaded()
2544 LLVMBool LLVMIntrinsicIsOverloaded(unsigned ID);
2547 * Obtain the calling function of a function.
2549 * The returned value corresponds to the LLVMCallConv enumeration.
2551 * @see llvm::Function::getCallingConv()
2553 unsigned LLVMGetFunctionCallConv(LLVMValueRef Fn);
2556 * Set the calling convention of a function.
2558 * @see llvm::Function::setCallingConv()
2560 * @param Fn Function to operate on
2561 * @param CC LLVMCallConv to set calling convention to
2563 void LLVMSetFunctionCallConv(LLVMValueRef Fn, unsigned CC);
2566 * Obtain the name of the garbage collector to use during code
2567 * generation.
2569 * @see llvm::Function::getGC()
2571 const char *LLVMGetGC(LLVMValueRef Fn);
2574 * Define the garbage collector to use during code generation.
2576 * @see llvm::Function::setGC()
2578 void LLVMSetGC(LLVMValueRef Fn, const char *Name);
2581 * Add an attribute to a function.
2583 * @see llvm::Function::addAttribute()
2585 void LLVMAddAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx,
2586 LLVMAttributeRef A);
2587 unsigned LLVMGetAttributeCountAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx);
2588 void LLVMGetAttributesAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx,
2589 LLVMAttributeRef *Attrs);
2590 LLVMAttributeRef LLVMGetEnumAttributeAtIndex(LLVMValueRef F,
2591 LLVMAttributeIndex Idx,
2592 unsigned KindID);
2593 LLVMAttributeRef LLVMGetStringAttributeAtIndex(LLVMValueRef F,
2594 LLVMAttributeIndex Idx,
2595 const char *K, unsigned KLen);
2596 void LLVMRemoveEnumAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx,
2597 unsigned KindID);
2598 void LLVMRemoveStringAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx,
2599 const char *K, unsigned KLen);
2602 * Add a target-dependent attribute to a function
2603 * @see llvm::AttrBuilder::addAttribute()
2605 void LLVMAddTargetDependentFunctionAttr(LLVMValueRef Fn, const char *A,
2606 const char *V);
2609 * @defgroup LLVMCCoreValueFunctionParameters Function Parameters
2611 * Functions in this group relate to arguments/parameters on functions.
2613 * Functions in this group expect LLVMValueRef instances that correspond
2614 * to llvm::Function instances.
2616 * @{
2620 * Obtain the number of parameters in a function.
2622 * @see llvm::Function::arg_size()
2624 unsigned LLVMCountParams(LLVMValueRef Fn);
2627 * Obtain the parameters in a function.
2629 * The takes a pointer to a pre-allocated array of LLVMValueRef that is
2630 * at least LLVMCountParams() long. This array will be filled with
2631 * LLVMValueRef instances which correspond to the parameters the
2632 * function receives. Each LLVMValueRef corresponds to a llvm::Argument
2633 * instance.
2635 * @see llvm::Function::arg_begin()
2637 void LLVMGetParams(LLVMValueRef Fn, LLVMValueRef *Params);
2640 * Obtain the parameter at the specified index.
2642 * Parameters are indexed from 0.
2644 * @see llvm::Function::arg_begin()
2646 LLVMValueRef LLVMGetParam(LLVMValueRef Fn, unsigned Index);
2649 * Obtain the function to which this argument belongs.
2651 * Unlike other functions in this group, this one takes an LLVMValueRef
2652 * that corresponds to a llvm::Attribute.
2654 * The returned LLVMValueRef is the llvm::Function to which this
2655 * argument belongs.
2657 LLVMValueRef LLVMGetParamParent(LLVMValueRef Inst);
2660 * Obtain the first parameter to a function.
2662 * @see llvm::Function::arg_begin()
2664 LLVMValueRef LLVMGetFirstParam(LLVMValueRef Fn);
2667 * Obtain the last parameter to a function.
2669 * @see llvm::Function::arg_end()
2671 LLVMValueRef LLVMGetLastParam(LLVMValueRef Fn);
2674 * Obtain the next parameter to a function.
2676 * This takes an LLVMValueRef obtained from LLVMGetFirstParam() (which is
2677 * actually a wrapped iterator) and obtains the next parameter from the
2678 * underlying iterator.
2680 LLVMValueRef LLVMGetNextParam(LLVMValueRef Arg);
2683 * Obtain the previous parameter to a function.
2685 * This is the opposite of LLVMGetNextParam().
2687 LLVMValueRef LLVMGetPreviousParam(LLVMValueRef Arg);
2690 * Set the alignment for a function parameter.
2692 * @see llvm::Argument::addAttr()
2693 * @see llvm::AttrBuilder::addAlignmentAttr()
2695 void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned Align);
2698 * @}
2702 * @defgroup LLVMCCoreValueGlobalIFunc IFuncs
2704 * Functions in this group relate to indirect functions.
2706 * Functions in this group expect LLVMValueRef instances that correspond
2707 * to llvm::GlobalIFunc instances.
2709 * @{
2713 * Add a global indirect function to a module under a specified name.
2715 * @see llvm::GlobalIFunc::create()
2717 LLVMValueRef LLVMAddGlobalIFunc(LLVMModuleRef M,
2718 const char *Name, size_t NameLen,
2719 LLVMTypeRef Ty, unsigned AddrSpace,
2720 LLVMValueRef Resolver);
2723 * Obtain a GlobalIFunc value from a Module by its name.
2725 * The returned value corresponds to a llvm::GlobalIFunc value.
2727 * @see llvm::Module::getNamedIFunc()
2729 LLVMValueRef LLVMGetNamedGlobalIFunc(LLVMModuleRef M,
2730 const char *Name, size_t NameLen);
2733 * Obtain an iterator to the first GlobalIFunc in a Module.
2735 * @see llvm::Module::ifunc_begin()
2737 LLVMValueRef LLVMGetFirstGlobalIFunc(LLVMModuleRef M);
2740 * Obtain an iterator to the last GlobalIFunc in a Module.
2742 * @see llvm::Module::ifunc_end()
2744 LLVMValueRef LLVMGetLastGlobalIFunc(LLVMModuleRef M);
2747 * Advance a GlobalIFunc iterator to the next GlobalIFunc.
2749 * Returns NULL if the iterator was already at the end and there are no more
2750 * global aliases.
2752 LLVMValueRef LLVMGetNextGlobalIFunc(LLVMValueRef IFunc);
2755 * Decrement a GlobalIFunc iterator to the previous GlobalIFunc.
2757 * Returns NULL if the iterator was already at the beginning and there are
2758 * no previous global aliases.
2760 LLVMValueRef LLVMGetPreviousGlobalIFunc(LLVMValueRef IFunc);
2763 * Retrieves the resolver function associated with this indirect function, or
2764 * NULL if it doesn't not exist.
2766 * @see llvm::GlobalIFunc::getResolver()
2768 LLVMValueRef LLVMGetGlobalIFuncResolver(LLVMValueRef IFunc);
2771 * Sets the resolver function associated with this indirect function.
2773 * @see llvm::GlobalIFunc::setResolver()
2775 void LLVMSetGlobalIFuncResolver(LLVMValueRef IFunc, LLVMValueRef Resolver);
2778 * Remove a global indirect function from its parent module and delete it.
2780 * @see llvm::GlobalIFunc::eraseFromParent()
2782 void LLVMEraseGlobalIFunc(LLVMValueRef IFunc);
2785 * Remove a global indirect function from its parent module.
2787 * This unlinks the global indirect function from its containing module but
2788 * keeps it alive.
2790 * @see llvm::GlobalIFunc::removeFromParent()
2792 void LLVMRemoveGlobalIFunc(LLVMValueRef IFunc);
2795 * @}
2799 * @}
2803 * @}
2807 * @}
2811 * @defgroup LLVMCCoreValueMetadata Metadata
2813 * @{
2817 * Create an MDString value from a given string value.
2819 * The MDString value does not take ownership of the given string, it remains
2820 * the responsibility of the caller to free it.
2822 * @see llvm::MDString::get()
2824 LLVMMetadataRef LLVMMDStringInContext2(LLVMContextRef C, const char *Str,
2825 size_t SLen);
2828 * Create an MDNode value with the given array of operands.
2830 * @see llvm::MDNode::get()
2832 LLVMMetadataRef LLVMMDNodeInContext2(LLVMContextRef C, LLVMMetadataRef *MDs,
2833 size_t Count);
2836 * Obtain a Metadata as a Value.
2838 LLVMValueRef LLVMMetadataAsValue(LLVMContextRef C, LLVMMetadataRef MD);
2841 * Obtain a Value as a Metadata.
2843 LLVMMetadataRef LLVMValueAsMetadata(LLVMValueRef Val);
2846 * Obtain the underlying string from a MDString value.
2848 * @param V Instance to obtain string from.
2849 * @param Length Memory address which will hold length of returned string.
2850 * @return String data in MDString.
2852 const char *LLVMGetMDString(LLVMValueRef V, unsigned *Length);
2855 * Obtain the number of operands from an MDNode value.
2857 * @param V MDNode to get number of operands from.
2858 * @return Number of operands of the MDNode.
2860 unsigned LLVMGetMDNodeNumOperands(LLVMValueRef V);
2863 * Obtain the given MDNode's operands.
2865 * The passed LLVMValueRef pointer should point to enough memory to hold all of
2866 * the operands of the given MDNode (see LLVMGetMDNodeNumOperands) as
2867 * LLVMValueRefs. This memory will be populated with the LLVMValueRefs of the
2868 * MDNode's operands.
2870 * @param V MDNode to get the operands from.
2871 * @param Dest Destination array for operands.
2873 void LLVMGetMDNodeOperands(LLVMValueRef V, LLVMValueRef *Dest);
2875 /** Deprecated: Use LLVMMDStringInContext2 instead. */
2876 LLVMValueRef LLVMMDStringInContext(LLVMContextRef C, const char *Str,
2877 unsigned SLen);
2878 /** Deprecated: Use LLVMMDStringInContext2 instead. */
2879 LLVMValueRef LLVMMDString(const char *Str, unsigned SLen);
2880 /** Deprecated: Use LLVMMDNodeInContext2 instead. */
2881 LLVMValueRef LLVMMDNodeInContext(LLVMContextRef C, LLVMValueRef *Vals,
2882 unsigned Count);
2883 /** Deprecated: Use LLVMMDNodeInContext2 instead. */
2884 LLVMValueRef LLVMMDNode(LLVMValueRef *Vals, unsigned Count);
2887 * @}
2891 * @defgroup LLVMCCoreValueBasicBlock Basic Block
2893 * A basic block represents a single entry single exit section of code.
2894 * Basic blocks contain a list of instructions which form the body of
2895 * the block.
2897 * Basic blocks belong to functions. They have the type of label.
2899 * Basic blocks are themselves values. However, the C API models them as
2900 * LLVMBasicBlockRef.
2902 * @see llvm::BasicBlock
2904 * @{
2908 * Convert a basic block instance to a value type.
2910 LLVMValueRef LLVMBasicBlockAsValue(LLVMBasicBlockRef BB);
2913 * Determine whether an LLVMValueRef is itself a basic block.
2915 LLVMBool LLVMValueIsBasicBlock(LLVMValueRef Val);
2918 * Convert an LLVMValueRef to an LLVMBasicBlockRef instance.
2920 LLVMBasicBlockRef LLVMValueAsBasicBlock(LLVMValueRef Val);
2923 * Obtain the string name of a basic block.
2925 const char *LLVMGetBasicBlockName(LLVMBasicBlockRef BB);
2928 * Obtain the function to which a basic block belongs.
2930 * @see llvm::BasicBlock::getParent()
2932 LLVMValueRef LLVMGetBasicBlockParent(LLVMBasicBlockRef BB);
2935 * Obtain the terminator instruction for a basic block.
2937 * If the basic block does not have a terminator (it is not well-formed
2938 * if it doesn't), then NULL is returned.
2940 * The returned LLVMValueRef corresponds to an llvm::Instruction.
2942 * @see llvm::BasicBlock::getTerminator()
2944 LLVMValueRef LLVMGetBasicBlockTerminator(LLVMBasicBlockRef BB);
2947 * Obtain the number of basic blocks in a function.
2949 * @param Fn Function value to operate on.
2951 unsigned LLVMCountBasicBlocks(LLVMValueRef Fn);
2954 * Obtain all of the basic blocks in a function.
2956 * This operates on a function value. The BasicBlocks parameter is a
2957 * pointer to a pre-allocated array of LLVMBasicBlockRef of at least
2958 * LLVMCountBasicBlocks() in length. This array is populated with
2959 * LLVMBasicBlockRef instances.
2961 void LLVMGetBasicBlocks(LLVMValueRef Fn, LLVMBasicBlockRef *BasicBlocks);
2964 * Obtain the first basic block in a function.
2966 * The returned basic block can be used as an iterator. You will likely
2967 * eventually call into LLVMGetNextBasicBlock() with it.
2969 * @see llvm::Function::begin()
2971 LLVMBasicBlockRef LLVMGetFirstBasicBlock(LLVMValueRef Fn);
2974 * Obtain the last basic block in a function.
2976 * @see llvm::Function::end()
2978 LLVMBasicBlockRef LLVMGetLastBasicBlock(LLVMValueRef Fn);
2981 * Advance a basic block iterator.
2983 LLVMBasicBlockRef LLVMGetNextBasicBlock(LLVMBasicBlockRef BB);
2986 * Go backwards in a basic block iterator.
2988 LLVMBasicBlockRef LLVMGetPreviousBasicBlock(LLVMBasicBlockRef BB);
2991 * Obtain the basic block that corresponds to the entry point of a
2992 * function.
2994 * @see llvm::Function::getEntryBlock()
2996 LLVMBasicBlockRef LLVMGetEntryBasicBlock(LLVMValueRef Fn);
2999 * Insert the given basic block after the insertion point of the given builder.
3001 * The insertion point must be valid.
3003 * @see llvm::Function::BasicBlockListType::insertAfter()
3005 void LLVMInsertExistingBasicBlockAfterInsertBlock(LLVMBuilderRef Builder,
3006 LLVMBasicBlockRef BB);
3009 * Append the given basic block to the basic block list of the given function.
3011 * @see llvm::Function::BasicBlockListType::push_back()
3013 void LLVMAppendExistingBasicBlock(LLVMValueRef Fn,
3014 LLVMBasicBlockRef BB);
3017 * Create a new basic block without inserting it into a function.
3019 * @see llvm::BasicBlock::Create()
3021 LLVMBasicBlockRef LLVMCreateBasicBlockInContext(LLVMContextRef C,
3022 const char *Name);
3025 * Append a basic block to the end of a function.
3027 * @see llvm::BasicBlock::Create()
3029 LLVMBasicBlockRef LLVMAppendBasicBlockInContext(LLVMContextRef C,
3030 LLVMValueRef Fn,
3031 const char *Name);
3034 * Append a basic block to the end of a function using the global
3035 * context.
3037 * @see llvm::BasicBlock::Create()
3039 LLVMBasicBlockRef LLVMAppendBasicBlock(LLVMValueRef Fn, const char *Name);
3042 * Insert a basic block in a function before another basic block.
3044 * The function to add to is determined by the function of the
3045 * passed basic block.
3047 * @see llvm::BasicBlock::Create()
3049 LLVMBasicBlockRef LLVMInsertBasicBlockInContext(LLVMContextRef C,
3050 LLVMBasicBlockRef BB,
3051 const char *Name);
3054 * Insert a basic block in a function using the global context.
3056 * @see llvm::BasicBlock::Create()
3058 LLVMBasicBlockRef LLVMInsertBasicBlock(LLVMBasicBlockRef InsertBeforeBB,
3059 const char *Name);
3062 * Remove a basic block from a function and delete it.
3064 * This deletes the basic block from its containing function and deletes
3065 * the basic block itself.
3067 * @see llvm::BasicBlock::eraseFromParent()
3069 void LLVMDeleteBasicBlock(LLVMBasicBlockRef BB);
3072 * Remove a basic block from a function.
3074 * This deletes the basic block from its containing function but keep
3075 * the basic block alive.
3077 * @see llvm::BasicBlock::removeFromParent()
3079 void LLVMRemoveBasicBlockFromParent(LLVMBasicBlockRef BB);
3082 * Move a basic block to before another one.
3084 * @see llvm::BasicBlock::moveBefore()
3086 void LLVMMoveBasicBlockBefore(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos);
3089 * Move a basic block to after another one.
3091 * @see llvm::BasicBlock::moveAfter()
3093 void LLVMMoveBasicBlockAfter(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos);
3096 * Obtain the first instruction in a basic block.
3098 * The returned LLVMValueRef corresponds to a llvm::Instruction
3099 * instance.
3101 LLVMValueRef LLVMGetFirstInstruction(LLVMBasicBlockRef BB);
3104 * Obtain the last instruction in a basic block.
3106 * The returned LLVMValueRef corresponds to an LLVM:Instruction.
3108 LLVMValueRef LLVMGetLastInstruction(LLVMBasicBlockRef BB);
3111 * @}
3115 * @defgroup LLVMCCoreValueInstruction Instructions
3117 * Functions in this group relate to the inspection and manipulation of
3118 * individual instructions.
3120 * In the C++ API, an instruction is modeled by llvm::Instruction. This
3121 * class has a large number of descendents. llvm::Instruction is a
3122 * llvm::Value and in the C API, instructions are modeled by
3123 * LLVMValueRef.
3125 * This group also contains sub-groups which operate on specific
3126 * llvm::Instruction types, e.g. llvm::CallInst.
3128 * @{
3132 * Determine whether an instruction has any metadata attached.
3134 int LLVMHasMetadata(LLVMValueRef Val);
3137 * Return metadata associated with an instruction value.
3139 LLVMValueRef LLVMGetMetadata(LLVMValueRef Val, unsigned KindID);
3142 * Set metadata associated with an instruction value.
3144 void LLVMSetMetadata(LLVMValueRef Val, unsigned KindID, LLVMValueRef Node);
3147 * Returns the metadata associated with an instruction value, but filters out
3148 * all the debug locations.
3150 * @see llvm::Instruction::getAllMetadataOtherThanDebugLoc()
3152 LLVMValueMetadataEntry *
3153 LLVMInstructionGetAllMetadataOtherThanDebugLoc(LLVMValueRef Instr,
3154 size_t *NumEntries);
3157 * Obtain the basic block to which an instruction belongs.
3159 * @see llvm::Instruction::getParent()
3161 LLVMBasicBlockRef LLVMGetInstructionParent(LLVMValueRef Inst);
3164 * Obtain the instruction that occurs after the one specified.
3166 * The next instruction will be from the same basic block.
3168 * If this is the last instruction in a basic block, NULL will be
3169 * returned.
3171 LLVMValueRef LLVMGetNextInstruction(LLVMValueRef Inst);
3174 * Obtain the instruction that occurred before this one.
3176 * If the instruction is the first instruction in a basic block, NULL
3177 * will be returned.
3179 LLVMValueRef LLVMGetPreviousInstruction(LLVMValueRef Inst);
3182 * Remove and delete an instruction.
3184 * The instruction specified is removed from its containing building
3185 * block but is kept alive.
3187 * @see llvm::Instruction::removeFromParent()
3189 void LLVMInstructionRemoveFromParent(LLVMValueRef Inst);
3192 * Remove and delete an instruction.
3194 * The instruction specified is removed from its containing building
3195 * block and then deleted.
3197 * @see llvm::Instruction::eraseFromParent()
3199 void LLVMInstructionEraseFromParent(LLVMValueRef Inst);
3202 * Obtain the code opcode for an individual instruction.
3204 * @see llvm::Instruction::getOpCode()
3206 LLVMOpcode LLVMGetInstructionOpcode(LLVMValueRef Inst);
3209 * Obtain the predicate of an instruction.
3211 * This is only valid for instructions that correspond to llvm::ICmpInst
3212 * or llvm::ConstantExpr whose opcode is llvm::Instruction::ICmp.
3214 * @see llvm::ICmpInst::getPredicate()
3216 LLVMIntPredicate LLVMGetICmpPredicate(LLVMValueRef Inst);
3219 * Obtain the float predicate of an instruction.
3221 * This is only valid for instructions that correspond to llvm::FCmpInst
3222 * or llvm::ConstantExpr whose opcode is llvm::Instruction::FCmp.
3224 * @see llvm::FCmpInst::getPredicate()
3226 LLVMRealPredicate LLVMGetFCmpPredicate(LLVMValueRef Inst);
3229 * Create a copy of 'this' instruction that is identical in all ways
3230 * except the following:
3231 * * The instruction has no parent
3232 * * The instruction has no name
3234 * @see llvm::Instruction::clone()
3236 LLVMValueRef LLVMInstructionClone(LLVMValueRef Inst);
3239 * Determine whether an instruction is a terminator. This routine is named to
3240 * be compatible with historical functions that did this by querying the
3241 * underlying C++ type.
3243 * @see llvm::Instruction::isTerminator()
3245 LLVMValueRef LLVMIsATerminatorInst(LLVMValueRef Inst);
3248 * @defgroup LLVMCCoreValueInstructionCall Call Sites and Invocations
3250 * Functions in this group apply to instructions that refer to call
3251 * sites and invocations. These correspond to C++ types in the
3252 * llvm::CallInst class tree.
3254 * @{
3258 * Obtain the argument count for a call instruction.
3260 * This expects an LLVMValueRef that corresponds to a llvm::CallInst,
3261 * llvm::InvokeInst, or llvm:FuncletPadInst.
3263 * @see llvm::CallInst::getNumArgOperands()
3264 * @see llvm::InvokeInst::getNumArgOperands()
3265 * @see llvm::FuncletPadInst::getNumArgOperands()
3267 unsigned LLVMGetNumArgOperands(LLVMValueRef Instr);
3270 * Set the calling convention for a call instruction.
3272 * This expects an LLVMValueRef that corresponds to a llvm::CallInst or
3273 * llvm::InvokeInst.
3275 * @see llvm::CallInst::setCallingConv()
3276 * @see llvm::InvokeInst::setCallingConv()
3278 void LLVMSetInstructionCallConv(LLVMValueRef Instr, unsigned CC);
3281 * Obtain the calling convention for a call instruction.
3283 * This is the opposite of LLVMSetInstructionCallConv(). Reads its
3284 * usage.
3286 * @see LLVMSetInstructionCallConv()
3288 unsigned LLVMGetInstructionCallConv(LLVMValueRef Instr);
3290 void LLVMSetInstrParamAlignment(LLVMValueRef Instr, unsigned index,
3291 unsigned Align);
3293 void LLVMAddCallSiteAttribute(LLVMValueRef C, LLVMAttributeIndex Idx,
3294 LLVMAttributeRef A);
3295 unsigned LLVMGetCallSiteAttributeCount(LLVMValueRef C, LLVMAttributeIndex Idx);
3296 void LLVMGetCallSiteAttributes(LLVMValueRef C, LLVMAttributeIndex Idx,
3297 LLVMAttributeRef *Attrs);
3298 LLVMAttributeRef LLVMGetCallSiteEnumAttribute(LLVMValueRef C,
3299 LLVMAttributeIndex Idx,
3300 unsigned KindID);
3301 LLVMAttributeRef LLVMGetCallSiteStringAttribute(LLVMValueRef C,
3302 LLVMAttributeIndex Idx,
3303 const char *K, unsigned KLen);
3304 void LLVMRemoveCallSiteEnumAttribute(LLVMValueRef C, LLVMAttributeIndex Idx,
3305 unsigned KindID);
3306 void LLVMRemoveCallSiteStringAttribute(LLVMValueRef C, LLVMAttributeIndex Idx,
3307 const char *K, unsigned KLen);
3310 * Obtain the function type called by this instruction.
3312 * @see llvm::CallBase::getFunctionType()
3314 LLVMTypeRef LLVMGetCalledFunctionType(LLVMValueRef C);
3317 * Obtain the pointer to the function invoked by this instruction.
3319 * This expects an LLVMValueRef that corresponds to a llvm::CallInst or
3320 * llvm::InvokeInst.
3322 * @see llvm::CallInst::getCalledOperand()
3323 * @see llvm::InvokeInst::getCalledOperand()
3325 LLVMValueRef LLVMGetCalledValue(LLVMValueRef Instr);
3328 * Obtain whether a call instruction is a tail call.
3330 * This only works on llvm::CallInst instructions.
3332 * @see llvm::CallInst::isTailCall()
3334 LLVMBool LLVMIsTailCall(LLVMValueRef CallInst);
3337 * Set whether a call instruction is a tail call.
3339 * This only works on llvm::CallInst instructions.
3341 * @see llvm::CallInst::setTailCall()
3343 void LLVMSetTailCall(LLVMValueRef CallInst, LLVMBool IsTailCall);
3346 * Return the normal destination basic block.
3348 * This only works on llvm::InvokeInst instructions.
3350 * @see llvm::InvokeInst::getNormalDest()
3352 LLVMBasicBlockRef LLVMGetNormalDest(LLVMValueRef InvokeInst);
3355 * Return the unwind destination basic block.
3357 * Works on llvm::InvokeInst, llvm::CleanupReturnInst, and
3358 * llvm::CatchSwitchInst instructions.
3360 * @see llvm::InvokeInst::getUnwindDest()
3361 * @see llvm::CleanupReturnInst::getUnwindDest()
3362 * @see llvm::CatchSwitchInst::getUnwindDest()
3364 LLVMBasicBlockRef LLVMGetUnwindDest(LLVMValueRef InvokeInst);
3367 * Set the normal destination basic block.
3369 * This only works on llvm::InvokeInst instructions.
3371 * @see llvm::InvokeInst::setNormalDest()
3373 void LLVMSetNormalDest(LLVMValueRef InvokeInst, LLVMBasicBlockRef B);
3376 * Set the unwind destination basic block.
3378 * Works on llvm::InvokeInst, llvm::CleanupReturnInst, and
3379 * llvm::CatchSwitchInst instructions.
3381 * @see llvm::InvokeInst::setUnwindDest()
3382 * @see llvm::CleanupReturnInst::setUnwindDest()
3383 * @see llvm::CatchSwitchInst::setUnwindDest()
3385 void LLVMSetUnwindDest(LLVMValueRef InvokeInst, LLVMBasicBlockRef B);
3388 * @}
3392 * @defgroup LLVMCCoreValueInstructionTerminator Terminators
3394 * Functions in this group only apply to instructions for which
3395 * LLVMIsATerminatorInst returns true.
3397 * @{
3401 * Return the number of successors that this terminator has.
3403 * @see llvm::Instruction::getNumSuccessors
3405 unsigned LLVMGetNumSuccessors(LLVMValueRef Term);
3408 * Return the specified successor.
3410 * @see llvm::Instruction::getSuccessor
3412 LLVMBasicBlockRef LLVMGetSuccessor(LLVMValueRef Term, unsigned i);
3415 * Update the specified successor to point at the provided block.
3417 * @see llvm::Instruction::setSuccessor
3419 void LLVMSetSuccessor(LLVMValueRef Term, unsigned i, LLVMBasicBlockRef block);
3422 * Return if a branch is conditional.
3424 * This only works on llvm::BranchInst instructions.
3426 * @see llvm::BranchInst::isConditional
3428 LLVMBool LLVMIsConditional(LLVMValueRef Branch);
3431 * Return the condition of a branch instruction.
3433 * This only works on llvm::BranchInst instructions.
3435 * @see llvm::BranchInst::getCondition
3437 LLVMValueRef LLVMGetCondition(LLVMValueRef Branch);
3440 * Set the condition of a branch instruction.
3442 * This only works on llvm::BranchInst instructions.
3444 * @see llvm::BranchInst::setCondition
3446 void LLVMSetCondition(LLVMValueRef Branch, LLVMValueRef Cond);
3449 * Obtain the default destination basic block of a switch instruction.
3451 * This only works on llvm::SwitchInst instructions.
3453 * @see llvm::SwitchInst::getDefaultDest()
3455 LLVMBasicBlockRef LLVMGetSwitchDefaultDest(LLVMValueRef SwitchInstr);
3458 * @}
3462 * @defgroup LLVMCCoreValueInstructionAlloca Allocas
3464 * Functions in this group only apply to instructions that map to
3465 * llvm::AllocaInst instances.
3467 * @{
3471 * Obtain the type that is being allocated by the alloca instruction.
3473 LLVMTypeRef LLVMGetAllocatedType(LLVMValueRef Alloca);
3476 * @}
3480 * @defgroup LLVMCCoreValueInstructionGetElementPointer GEPs
3482 * Functions in this group only apply to instructions that map to
3483 * llvm::GetElementPtrInst instances.
3485 * @{
3489 * Check whether the given GEP instruction is inbounds.
3491 LLVMBool LLVMIsInBounds(LLVMValueRef GEP);
3494 * Set the given GEP instruction to be inbounds or not.
3496 void LLVMSetIsInBounds(LLVMValueRef GEP, LLVMBool InBounds);
3499 * @}
3503 * @defgroup LLVMCCoreValueInstructionPHINode PHI Nodes
3505 * Functions in this group only apply to instructions that map to
3506 * llvm::PHINode instances.
3508 * @{
3512 * Add an incoming value to the end of a PHI list.
3514 void LLVMAddIncoming(LLVMValueRef PhiNode, LLVMValueRef *IncomingValues,
3515 LLVMBasicBlockRef *IncomingBlocks, unsigned Count);
3518 * Obtain the number of incoming basic blocks to a PHI node.
3520 unsigned LLVMCountIncoming(LLVMValueRef PhiNode);
3523 * Obtain an incoming value to a PHI node as an LLVMValueRef.
3525 LLVMValueRef LLVMGetIncomingValue(LLVMValueRef PhiNode, unsigned Index);
3528 * Obtain an incoming value to a PHI node as an LLVMBasicBlockRef.
3530 LLVMBasicBlockRef LLVMGetIncomingBlock(LLVMValueRef PhiNode, unsigned Index);
3533 * @}
3537 * @defgroup LLVMCCoreValueInstructionExtractValue ExtractValue
3538 * @defgroup LLVMCCoreValueInstructionInsertValue InsertValue
3540 * Functions in this group only apply to instructions that map to
3541 * llvm::ExtractValue and llvm::InsertValue instances.
3543 * @{
3547 * Obtain the number of indices.
3548 * NB: This also works on GEP.
3550 unsigned LLVMGetNumIndices(LLVMValueRef Inst);
3553 * Obtain the indices as an array.
3555 const unsigned *LLVMGetIndices(LLVMValueRef Inst);
3558 * @}
3562 * @}
3566 * @}
3570 * @defgroup LLVMCCoreInstructionBuilder Instruction Builders
3572 * An instruction builder represents a point within a basic block and is
3573 * the exclusive means of building instructions using the C interface.
3575 * @{
3578 LLVMBuilderRef LLVMCreateBuilderInContext(LLVMContextRef C);
3579 LLVMBuilderRef LLVMCreateBuilder(void);
3580 void LLVMPositionBuilder(LLVMBuilderRef Builder, LLVMBasicBlockRef Block,
3581 LLVMValueRef Instr);
3582 void LLVMPositionBuilderBefore(LLVMBuilderRef Builder, LLVMValueRef Instr);
3583 void LLVMPositionBuilderAtEnd(LLVMBuilderRef Builder, LLVMBasicBlockRef Block);
3584 LLVMBasicBlockRef LLVMGetInsertBlock(LLVMBuilderRef Builder);
3585 void LLVMClearInsertionPosition(LLVMBuilderRef Builder);
3586 void LLVMInsertIntoBuilder(LLVMBuilderRef Builder, LLVMValueRef Instr);
3587 void LLVMInsertIntoBuilderWithName(LLVMBuilderRef Builder, LLVMValueRef Instr,
3588 const char *Name);
3589 void LLVMDisposeBuilder(LLVMBuilderRef Builder);
3591 /* Metadata */
3594 * Get location information used by debugging information.
3596 * @see llvm::IRBuilder::getCurrentDebugLocation()
3598 LLVMMetadataRef LLVMGetCurrentDebugLocation2(LLVMBuilderRef Builder);
3601 * Set location information used by debugging information.
3603 * To clear the location metadata of the given instruction, pass NULL to \p Loc.
3605 * @see llvm::IRBuilder::SetCurrentDebugLocation()
3607 void LLVMSetCurrentDebugLocation2(LLVMBuilderRef Builder, LLVMMetadataRef Loc);
3610 * Attempts to set the debug location for the given instruction using the
3611 * current debug location for the given builder. If the builder has no current
3612 * debug location, this function is a no-op.
3614 * @see llvm::IRBuilder::SetInstDebugLocation()
3616 void LLVMSetInstDebugLocation(LLVMBuilderRef Builder, LLVMValueRef Inst);
3619 * Get the dafult floating-point math metadata for a given builder.
3621 * @see llvm::IRBuilder::getDefaultFPMathTag()
3623 LLVMMetadataRef LLVMBuilderGetDefaultFPMathTag(LLVMBuilderRef Builder);
3626 * Set the default floating-point math metadata for the given builder.
3628 * To clear the metadata, pass NULL to \p FPMathTag.
3630 * @see llvm::IRBuilder::setDefaultFPMathTag()
3632 void LLVMBuilderSetDefaultFPMathTag(LLVMBuilderRef Builder,
3633 LLVMMetadataRef FPMathTag);
3636 * Deprecated: Passing the NULL location will crash.
3637 * Use LLVMGetCurrentDebugLocation2 instead.
3639 void LLVMSetCurrentDebugLocation(LLVMBuilderRef Builder, LLVMValueRef L);
3641 * Deprecated: Returning the NULL location will crash.
3642 * Use LLVMGetCurrentDebugLocation2 instead.
3644 LLVMValueRef LLVMGetCurrentDebugLocation(LLVMBuilderRef Builder);
3646 /* Terminators */
3647 LLVMValueRef LLVMBuildRetVoid(LLVMBuilderRef);
3648 LLVMValueRef LLVMBuildRet(LLVMBuilderRef, LLVMValueRef V);
3649 LLVMValueRef LLVMBuildAggregateRet(LLVMBuilderRef, LLVMValueRef *RetVals,
3650 unsigned N);
3651 LLVMValueRef LLVMBuildBr(LLVMBuilderRef, LLVMBasicBlockRef Dest);
3652 LLVMValueRef LLVMBuildCondBr(LLVMBuilderRef, LLVMValueRef If,
3653 LLVMBasicBlockRef Then, LLVMBasicBlockRef Else);
3654 LLVMValueRef LLVMBuildSwitch(LLVMBuilderRef, LLVMValueRef V,
3655 LLVMBasicBlockRef Else, unsigned NumCases);
3656 LLVMValueRef LLVMBuildIndirectBr(LLVMBuilderRef B, LLVMValueRef Addr,
3657 unsigned NumDests);
3658 // LLVMBuildInvoke is deprecated in favor of LLVMBuildInvoke2, in preparation
3659 // for opaque pointer types.
3660 LLVMValueRef LLVMBuildInvoke(LLVMBuilderRef, LLVMValueRef Fn,
3661 LLVMValueRef *Args, unsigned NumArgs,
3662 LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch,
3663 const char *Name);
3664 LLVMValueRef LLVMBuildInvoke2(LLVMBuilderRef, LLVMTypeRef Ty, LLVMValueRef Fn,
3665 LLVMValueRef *Args, unsigned NumArgs,
3666 LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch,
3667 const char *Name);
3668 LLVMValueRef LLVMBuildUnreachable(LLVMBuilderRef);
3670 /* Exception Handling */
3671 LLVMValueRef LLVMBuildResume(LLVMBuilderRef B, LLVMValueRef Exn);
3672 LLVMValueRef LLVMBuildLandingPad(LLVMBuilderRef B, LLVMTypeRef Ty,
3673 LLVMValueRef PersFn, unsigned NumClauses,
3674 const char *Name);
3675 LLVMValueRef LLVMBuildCleanupRet(LLVMBuilderRef B, LLVMValueRef CatchPad,
3676 LLVMBasicBlockRef BB);
3677 LLVMValueRef LLVMBuildCatchRet(LLVMBuilderRef B, LLVMValueRef CatchPad,
3678 LLVMBasicBlockRef BB);
3679 LLVMValueRef LLVMBuildCatchPad(LLVMBuilderRef B, LLVMValueRef ParentPad,
3680 LLVMValueRef *Args, unsigned NumArgs,
3681 const char *Name);
3682 LLVMValueRef LLVMBuildCleanupPad(LLVMBuilderRef B, LLVMValueRef ParentPad,
3683 LLVMValueRef *Args, unsigned NumArgs,
3684 const char *Name);
3685 LLVMValueRef LLVMBuildCatchSwitch(LLVMBuilderRef B, LLVMValueRef ParentPad,
3686 LLVMBasicBlockRef UnwindBB,
3687 unsigned NumHandlers, const char *Name);
3689 /* Add a case to the switch instruction */
3690 void LLVMAddCase(LLVMValueRef Switch, LLVMValueRef OnVal,
3691 LLVMBasicBlockRef Dest);
3693 /* Add a destination to the indirectbr instruction */
3694 void LLVMAddDestination(LLVMValueRef IndirectBr, LLVMBasicBlockRef Dest);
3696 /* Get the number of clauses on the landingpad instruction */
3697 unsigned LLVMGetNumClauses(LLVMValueRef LandingPad);
3699 /* Get the value of the clause at index Idx on the landingpad instruction */
3700 LLVMValueRef LLVMGetClause(LLVMValueRef LandingPad, unsigned Idx);
3702 /* Add a catch or filter clause to the landingpad instruction */
3703 void LLVMAddClause(LLVMValueRef LandingPad, LLVMValueRef ClauseVal);
3705 /* Get the 'cleanup' flag in the landingpad instruction */
3706 LLVMBool LLVMIsCleanup(LLVMValueRef LandingPad);
3708 /* Set the 'cleanup' flag in the landingpad instruction */
3709 void LLVMSetCleanup(LLVMValueRef LandingPad, LLVMBool Val);
3711 /* Add a destination to the catchswitch instruction */
3712 void LLVMAddHandler(LLVMValueRef CatchSwitch, LLVMBasicBlockRef Dest);
3714 /* Get the number of handlers on the catchswitch instruction */
3715 unsigned LLVMGetNumHandlers(LLVMValueRef CatchSwitch);
3718 * Obtain the basic blocks acting as handlers for a catchswitch instruction.
3720 * The Handlers parameter should point to a pre-allocated array of
3721 * LLVMBasicBlockRefs at least LLVMGetNumHandlers() large. On return, the
3722 * first LLVMGetNumHandlers() entries in the array will be populated
3723 * with LLVMBasicBlockRef instances.
3725 * @param CatchSwitch The catchswitch instruction to operate on.
3726 * @param Handlers Memory address of an array to be filled with basic blocks.
3728 void LLVMGetHandlers(LLVMValueRef CatchSwitch, LLVMBasicBlockRef *Handlers);
3730 /* Funclets */
3732 /* Get the number of funcletpad arguments. */
3733 LLVMValueRef LLVMGetArgOperand(LLVMValueRef Funclet, unsigned i);
3735 /* Set a funcletpad argument at the given index. */
3736 void LLVMSetArgOperand(LLVMValueRef Funclet, unsigned i, LLVMValueRef value);
3739 * Get the parent catchswitch instruction of a catchpad instruction.
3741 * This only works on llvm::CatchPadInst instructions.
3743 * @see llvm::CatchPadInst::getCatchSwitch()
3745 LLVMValueRef LLVMGetParentCatchSwitch(LLVMValueRef CatchPad);
3748 * Set the parent catchswitch instruction of a catchpad instruction.
3750 * This only works on llvm::CatchPadInst instructions.
3752 * @see llvm::CatchPadInst::setCatchSwitch()
3754 void LLVMSetParentCatchSwitch(LLVMValueRef CatchPad, LLVMValueRef CatchSwitch);
3756 /* Arithmetic */
3757 LLVMValueRef LLVMBuildAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3758 const char *Name);
3759 LLVMValueRef LLVMBuildNSWAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3760 const char *Name);
3761 LLVMValueRef LLVMBuildNUWAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3762 const char *Name);
3763 LLVMValueRef LLVMBuildFAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3764 const char *Name);
3765 LLVMValueRef LLVMBuildSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3766 const char *Name);
3767 LLVMValueRef LLVMBuildNSWSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3768 const char *Name);
3769 LLVMValueRef LLVMBuildNUWSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3770 const char *Name);
3771 LLVMValueRef LLVMBuildFSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3772 const char *Name);
3773 LLVMValueRef LLVMBuildMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3774 const char *Name);
3775 LLVMValueRef LLVMBuildNSWMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3776 const char *Name);
3777 LLVMValueRef LLVMBuildNUWMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3778 const char *Name);
3779 LLVMValueRef LLVMBuildFMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3780 const char *Name);
3781 LLVMValueRef LLVMBuildUDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3782 const char *Name);
3783 LLVMValueRef LLVMBuildExactUDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3784 const char *Name);
3785 LLVMValueRef LLVMBuildSDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3786 const char *Name);
3787 LLVMValueRef LLVMBuildExactSDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3788 const char *Name);
3789 LLVMValueRef LLVMBuildFDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3790 const char *Name);
3791 LLVMValueRef LLVMBuildURem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3792 const char *Name);
3793 LLVMValueRef LLVMBuildSRem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3794 const char *Name);
3795 LLVMValueRef LLVMBuildFRem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3796 const char *Name);
3797 LLVMValueRef LLVMBuildShl(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3798 const char *Name);
3799 LLVMValueRef LLVMBuildLShr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3800 const char *Name);
3801 LLVMValueRef LLVMBuildAShr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3802 const char *Name);
3803 LLVMValueRef LLVMBuildAnd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3804 const char *Name);
3805 LLVMValueRef LLVMBuildOr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3806 const char *Name);
3807 LLVMValueRef LLVMBuildXor(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3808 const char *Name);
3809 LLVMValueRef LLVMBuildBinOp(LLVMBuilderRef B, LLVMOpcode Op,
3810 LLVMValueRef LHS, LLVMValueRef RHS,
3811 const char *Name);
3812 LLVMValueRef LLVMBuildNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name);
3813 LLVMValueRef LLVMBuildNSWNeg(LLVMBuilderRef B, LLVMValueRef V,
3814 const char *Name);
3815 LLVMValueRef LLVMBuildNUWNeg(LLVMBuilderRef B, LLVMValueRef V,
3816 const char *Name);
3817 LLVMValueRef LLVMBuildFNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name);
3818 LLVMValueRef LLVMBuildNot(LLVMBuilderRef, LLVMValueRef V, const char *Name);
3820 /* Memory */
3821 LLVMValueRef LLVMBuildMalloc(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
3822 LLVMValueRef LLVMBuildArrayMalloc(LLVMBuilderRef, LLVMTypeRef Ty,
3823 LLVMValueRef Val, const char *Name);
3826 * Creates and inserts a memset to the specified pointer and the
3827 * specified value.
3829 * @see llvm::IRRBuilder::CreateMemSet()
3831 LLVMValueRef LLVMBuildMemSet(LLVMBuilderRef B, LLVMValueRef Ptr,
3832 LLVMValueRef Val, LLVMValueRef Len,
3833 unsigned Align);
3835 * Creates and inserts a memcpy between the specified pointers.
3837 * @see llvm::IRRBuilder::CreateMemCpy()
3839 LLVMValueRef LLVMBuildMemCpy(LLVMBuilderRef B,
3840 LLVMValueRef Dst, unsigned DstAlign,
3841 LLVMValueRef Src, unsigned SrcAlign,
3842 LLVMValueRef Size);
3844 * Creates and inserts a memmove between the specified pointers.
3846 * @see llvm::IRRBuilder::CreateMemMove()
3848 LLVMValueRef LLVMBuildMemMove(LLVMBuilderRef B,
3849 LLVMValueRef Dst, unsigned DstAlign,
3850 LLVMValueRef Src, unsigned SrcAlign,
3851 LLVMValueRef Size);
3853 LLVMValueRef LLVMBuildAlloca(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
3854 LLVMValueRef LLVMBuildArrayAlloca(LLVMBuilderRef, LLVMTypeRef Ty,
3855 LLVMValueRef Val, const char *Name);
3856 LLVMValueRef LLVMBuildFree(LLVMBuilderRef, LLVMValueRef PointerVal);
3857 // LLVMBuildLoad is deprecated in favor of LLVMBuildLoad2, in preparation for
3858 // opaque pointer types.
3859 LLVMValueRef LLVMBuildLoad(LLVMBuilderRef, LLVMValueRef PointerVal,
3860 const char *Name);
3861 LLVMValueRef LLVMBuildLoad2(LLVMBuilderRef, LLVMTypeRef Ty,
3862 LLVMValueRef PointerVal, const char *Name);
3863 LLVMValueRef LLVMBuildStore(LLVMBuilderRef, LLVMValueRef Val, LLVMValueRef Ptr);
3864 // LLVMBuildGEP, LLVMBuildInBoundsGEP, and LLVMBuildStructGEP are deprecated in
3865 // favor of LLVMBuild*GEP2, in preparation for opaque pointer types.
3866 LLVMValueRef LLVMBuildGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
3867 LLVMValueRef *Indices, unsigned NumIndices,
3868 const char *Name);
3869 LLVMValueRef LLVMBuildInBoundsGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
3870 LLVMValueRef *Indices, unsigned NumIndices,
3871 const char *Name);
3872 LLVMValueRef LLVMBuildStructGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
3873 unsigned Idx, const char *Name);
3874 LLVMValueRef LLVMBuildGEP2(LLVMBuilderRef B, LLVMTypeRef Ty,
3875 LLVMValueRef Pointer, LLVMValueRef *Indices,
3876 unsigned NumIndices, const char *Name);
3877 LLVMValueRef LLVMBuildInBoundsGEP2(LLVMBuilderRef B, LLVMTypeRef Ty,
3878 LLVMValueRef Pointer, LLVMValueRef *Indices,
3879 unsigned NumIndices, const char *Name);
3880 LLVMValueRef LLVMBuildStructGEP2(LLVMBuilderRef B, LLVMTypeRef Ty,
3881 LLVMValueRef Pointer, unsigned Idx,
3882 const char *Name);
3883 LLVMValueRef LLVMBuildGlobalString(LLVMBuilderRef B, const char *Str,
3884 const char *Name);
3885 LLVMValueRef LLVMBuildGlobalStringPtr(LLVMBuilderRef B, const char *Str,
3886 const char *Name);
3887 LLVMBool LLVMGetVolatile(LLVMValueRef MemoryAccessInst);
3888 void LLVMSetVolatile(LLVMValueRef MemoryAccessInst, LLVMBool IsVolatile);
3889 LLVMBool LLVMGetWeak(LLVMValueRef CmpXchgInst);
3890 void LLVMSetWeak(LLVMValueRef CmpXchgInst, LLVMBool IsWeak);
3891 LLVMAtomicOrdering LLVMGetOrdering(LLVMValueRef MemoryAccessInst);
3892 void LLVMSetOrdering(LLVMValueRef MemoryAccessInst, LLVMAtomicOrdering Ordering);
3893 LLVMAtomicRMWBinOp LLVMGetAtomicRMWBinOp(LLVMValueRef AtomicRMWInst);
3894 void LLVMSetAtomicRMWBinOp(LLVMValueRef AtomicRMWInst, LLVMAtomicRMWBinOp BinOp);
3896 /* Casts */
3897 LLVMValueRef LLVMBuildTrunc(LLVMBuilderRef, LLVMValueRef Val,
3898 LLVMTypeRef DestTy, const char *Name);
3899 LLVMValueRef LLVMBuildZExt(LLVMBuilderRef, LLVMValueRef Val,
3900 LLVMTypeRef DestTy, const char *Name);
3901 LLVMValueRef LLVMBuildSExt(LLVMBuilderRef, LLVMValueRef Val,
3902 LLVMTypeRef DestTy, const char *Name);
3903 LLVMValueRef LLVMBuildFPToUI(LLVMBuilderRef, LLVMValueRef Val,
3904 LLVMTypeRef DestTy, const char *Name);
3905 LLVMValueRef LLVMBuildFPToSI(LLVMBuilderRef, LLVMValueRef Val,
3906 LLVMTypeRef DestTy, const char *Name);
3907 LLVMValueRef LLVMBuildUIToFP(LLVMBuilderRef, LLVMValueRef Val,
3908 LLVMTypeRef DestTy, const char *Name);
3909 LLVMValueRef LLVMBuildSIToFP(LLVMBuilderRef, LLVMValueRef Val,
3910 LLVMTypeRef DestTy, const char *Name);
3911 LLVMValueRef LLVMBuildFPTrunc(LLVMBuilderRef, LLVMValueRef Val,
3912 LLVMTypeRef DestTy, const char *Name);
3913 LLVMValueRef LLVMBuildFPExt(LLVMBuilderRef, LLVMValueRef Val,
3914 LLVMTypeRef DestTy, const char *Name);
3915 LLVMValueRef LLVMBuildPtrToInt(LLVMBuilderRef, LLVMValueRef Val,
3916 LLVMTypeRef DestTy, const char *Name);
3917 LLVMValueRef LLVMBuildIntToPtr(LLVMBuilderRef, LLVMValueRef Val,
3918 LLVMTypeRef DestTy, const char *Name);
3919 LLVMValueRef LLVMBuildBitCast(LLVMBuilderRef, LLVMValueRef Val,
3920 LLVMTypeRef DestTy, const char *Name);
3921 LLVMValueRef LLVMBuildAddrSpaceCast(LLVMBuilderRef, LLVMValueRef Val,
3922 LLVMTypeRef DestTy, const char *Name);
3923 LLVMValueRef LLVMBuildZExtOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
3924 LLVMTypeRef DestTy, const char *Name);
3925 LLVMValueRef LLVMBuildSExtOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
3926 LLVMTypeRef DestTy, const char *Name);
3927 LLVMValueRef LLVMBuildTruncOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
3928 LLVMTypeRef DestTy, const char *Name);
3929 LLVMValueRef LLVMBuildCast(LLVMBuilderRef B, LLVMOpcode Op, LLVMValueRef Val,
3930 LLVMTypeRef DestTy, const char *Name);
3931 LLVMValueRef LLVMBuildPointerCast(LLVMBuilderRef, LLVMValueRef Val,
3932 LLVMTypeRef DestTy, const char *Name);
3933 LLVMValueRef LLVMBuildIntCast2(LLVMBuilderRef, LLVMValueRef Val,
3934 LLVMTypeRef DestTy, LLVMBool IsSigned,
3935 const char *Name);
3936 LLVMValueRef LLVMBuildFPCast(LLVMBuilderRef, LLVMValueRef Val,
3937 LLVMTypeRef DestTy, const char *Name);
3939 /** Deprecated: This cast is always signed. Use LLVMBuildIntCast2 instead. */
3940 LLVMValueRef LLVMBuildIntCast(LLVMBuilderRef, LLVMValueRef Val, /*Signed cast!*/
3941 LLVMTypeRef DestTy, const char *Name);
3943 /* Comparisons */
3944 LLVMValueRef LLVMBuildICmp(LLVMBuilderRef, LLVMIntPredicate Op,
3945 LLVMValueRef LHS, LLVMValueRef RHS,
3946 const char *Name);
3947 LLVMValueRef LLVMBuildFCmp(LLVMBuilderRef, LLVMRealPredicate Op,
3948 LLVMValueRef LHS, LLVMValueRef RHS,
3949 const char *Name);
3951 /* Miscellaneous instructions */
3952 LLVMValueRef LLVMBuildPhi(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
3953 // LLVMBuildCall is deprecated in favor of LLVMBuildCall2, in preparation for
3954 // opaque pointer types.
3955 LLVMValueRef LLVMBuildCall(LLVMBuilderRef, LLVMValueRef Fn,
3956 LLVMValueRef *Args, unsigned NumArgs,
3957 const char *Name);
3958 LLVMValueRef LLVMBuildCall2(LLVMBuilderRef, LLVMTypeRef, LLVMValueRef Fn,
3959 LLVMValueRef *Args, unsigned NumArgs,
3960 const char *Name);
3961 LLVMValueRef LLVMBuildSelect(LLVMBuilderRef, LLVMValueRef If,
3962 LLVMValueRef Then, LLVMValueRef Else,
3963 const char *Name);
3964 LLVMValueRef LLVMBuildVAArg(LLVMBuilderRef, LLVMValueRef List, LLVMTypeRef Ty,
3965 const char *Name);
3966 LLVMValueRef LLVMBuildExtractElement(LLVMBuilderRef, LLVMValueRef VecVal,
3967 LLVMValueRef Index, const char *Name);
3968 LLVMValueRef LLVMBuildInsertElement(LLVMBuilderRef, LLVMValueRef VecVal,
3969 LLVMValueRef EltVal, LLVMValueRef Index,
3970 const char *Name);
3971 LLVMValueRef LLVMBuildShuffleVector(LLVMBuilderRef, LLVMValueRef V1,
3972 LLVMValueRef V2, LLVMValueRef Mask,
3973 const char *Name);
3974 LLVMValueRef LLVMBuildExtractValue(LLVMBuilderRef, LLVMValueRef AggVal,
3975 unsigned Index, const char *Name);
3976 LLVMValueRef LLVMBuildInsertValue(LLVMBuilderRef, LLVMValueRef AggVal,
3977 LLVMValueRef EltVal, unsigned Index,
3978 const char *Name);
3979 LLVMValueRef LLVMBuildFreeze(LLVMBuilderRef, LLVMValueRef Val,
3980 const char *Name);
3982 LLVMValueRef LLVMBuildIsNull(LLVMBuilderRef, LLVMValueRef Val,
3983 const char *Name);
3984 LLVMValueRef LLVMBuildIsNotNull(LLVMBuilderRef, LLVMValueRef Val,
3985 const char *Name);
3986 LLVMValueRef LLVMBuildPtrDiff(LLVMBuilderRef, LLVMValueRef LHS,
3987 LLVMValueRef RHS, const char *Name);
3988 LLVMValueRef LLVMBuildFence(LLVMBuilderRef B, LLVMAtomicOrdering ordering,
3989 LLVMBool singleThread, const char *Name);
3990 LLVMValueRef LLVMBuildAtomicRMW(LLVMBuilderRef B, LLVMAtomicRMWBinOp op,
3991 LLVMValueRef PTR, LLVMValueRef Val,
3992 LLVMAtomicOrdering ordering,
3993 LLVMBool singleThread);
3994 LLVMValueRef LLVMBuildAtomicCmpXchg(LLVMBuilderRef B, LLVMValueRef Ptr,
3995 LLVMValueRef Cmp, LLVMValueRef New,
3996 LLVMAtomicOrdering SuccessOrdering,
3997 LLVMAtomicOrdering FailureOrdering,
3998 LLVMBool SingleThread);
4001 * Get the number of elements in the mask of a ShuffleVector instruction.
4003 unsigned LLVMGetNumMaskElements(LLVMValueRef ShuffleVectorInst);
4006 * \returns a constant that specifies that the result of a \c ShuffleVectorInst
4007 * is undefined.
4009 int LLVMGetUndefMaskElem(void);
4012 * Get the mask value at position Elt in the mask of a ShuffleVector
4013 * instruction.
4015 * \Returns the result of \c LLVMGetUndefMaskElem() if the mask value is undef
4016 * at that position.
4018 int LLVMGetMaskValue(LLVMValueRef ShuffleVectorInst, unsigned Elt);
4020 LLVMBool LLVMIsAtomicSingleThread(LLVMValueRef AtomicInst);
4021 void LLVMSetAtomicSingleThread(LLVMValueRef AtomicInst, LLVMBool SingleThread);
4023 LLVMAtomicOrdering LLVMGetCmpXchgSuccessOrdering(LLVMValueRef CmpXchgInst);
4024 void LLVMSetCmpXchgSuccessOrdering(LLVMValueRef CmpXchgInst,
4025 LLVMAtomicOrdering Ordering);
4026 LLVMAtomicOrdering LLVMGetCmpXchgFailureOrdering(LLVMValueRef CmpXchgInst);
4027 void LLVMSetCmpXchgFailureOrdering(LLVMValueRef CmpXchgInst,
4028 LLVMAtomicOrdering Ordering);
4031 * @}
4035 * @defgroup LLVMCCoreModuleProvider Module Providers
4037 * @{
4041 * Changes the type of M so it can be passed to FunctionPassManagers and the
4042 * JIT. They take ModuleProviders for historical reasons.
4044 LLVMModuleProviderRef
4045 LLVMCreateModuleProviderForExistingModule(LLVMModuleRef M);
4048 * Destroys the module M.
4050 void LLVMDisposeModuleProvider(LLVMModuleProviderRef M);
4053 * @}
4057 * @defgroup LLVMCCoreMemoryBuffers Memory Buffers
4059 * @{
4062 LLVMBool LLVMCreateMemoryBufferWithContentsOfFile(const char *Path,
4063 LLVMMemoryBufferRef *OutMemBuf,
4064 char **OutMessage);
4065 LLVMBool LLVMCreateMemoryBufferWithSTDIN(LLVMMemoryBufferRef *OutMemBuf,
4066 char **OutMessage);
4067 LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRange(const char *InputData,
4068 size_t InputDataLength,
4069 const char *BufferName,
4070 LLVMBool RequiresNullTerminator);
4071 LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRangeCopy(const char *InputData,
4072 size_t InputDataLength,
4073 const char *BufferName);
4074 const char *LLVMGetBufferStart(LLVMMemoryBufferRef MemBuf);
4075 size_t LLVMGetBufferSize(LLVMMemoryBufferRef MemBuf);
4076 void LLVMDisposeMemoryBuffer(LLVMMemoryBufferRef MemBuf);
4079 * @}
4083 * @defgroup LLVMCCorePassRegistry Pass Registry
4085 * @{
4088 /** Return the global pass registry, for use with initialization functions.
4089 @see llvm::PassRegistry::getPassRegistry */
4090 LLVMPassRegistryRef LLVMGetGlobalPassRegistry(void);
4093 * @}
4097 * @defgroup LLVMCCorePassManagers Pass Managers
4099 * @{
4102 /** Constructs a new whole-module pass pipeline. This type of pipeline is
4103 suitable for link-time optimization and whole-module transformations.
4104 @see llvm::PassManager::PassManager */
4105 LLVMPassManagerRef LLVMCreatePassManager(void);
4107 /** Constructs a new function-by-function pass pipeline over the module
4108 provider. It does not take ownership of the module provider. This type of
4109 pipeline is suitable for code generation and JIT compilation tasks.
4110 @see llvm::FunctionPassManager::FunctionPassManager */
4111 LLVMPassManagerRef LLVMCreateFunctionPassManagerForModule(LLVMModuleRef M);
4113 /** Deprecated: Use LLVMCreateFunctionPassManagerForModule instead. */
4114 LLVMPassManagerRef LLVMCreateFunctionPassManager(LLVMModuleProviderRef MP);
4116 /** Initializes, executes on the provided module, and finalizes all of the
4117 passes scheduled in the pass manager. Returns 1 if any of the passes
4118 modified the module, 0 otherwise.
4119 @see llvm::PassManager::run(Module&) */
4120 LLVMBool LLVMRunPassManager(LLVMPassManagerRef PM, LLVMModuleRef M);
4122 /** Initializes all of the function passes scheduled in the function pass
4123 manager. Returns 1 if any of the passes modified the module, 0 otherwise.
4124 @see llvm::FunctionPassManager::doInitialization */
4125 LLVMBool LLVMInitializeFunctionPassManager(LLVMPassManagerRef FPM);
4127 /** Executes all of the function passes scheduled in the function pass manager
4128 on the provided function. Returns 1 if any of the passes modified the
4129 function, false otherwise.
4130 @see llvm::FunctionPassManager::run(Function&) */
4131 LLVMBool LLVMRunFunctionPassManager(LLVMPassManagerRef FPM, LLVMValueRef F);
4133 /** Finalizes all of the function passes scheduled in the function pass
4134 manager. Returns 1 if any of the passes modified the module, 0 otherwise.
4135 @see llvm::FunctionPassManager::doFinalization */
4136 LLVMBool LLVMFinalizeFunctionPassManager(LLVMPassManagerRef FPM);
4138 /** Frees the memory of a pass pipeline. For function pipelines, does not free
4139 the module provider.
4140 @see llvm::PassManagerBase::~PassManagerBase. */
4141 void LLVMDisposePassManager(LLVMPassManagerRef PM);
4144 * @}
4148 * @defgroup LLVMCCoreThreading Threading
4150 * Handle the structures needed to make LLVM safe for multithreading.
4152 * @{
4155 /** Deprecated: Multi-threading can only be enabled/disabled with the compile
4156 time define LLVM_ENABLE_THREADS. This function always returns
4157 LLVMIsMultithreaded(). */
4158 LLVMBool LLVMStartMultithreaded(void);
4160 /** Deprecated: Multi-threading can only be enabled/disabled with the compile
4161 time define LLVM_ENABLE_THREADS. */
4162 void LLVMStopMultithreaded(void);
4164 /** Check whether LLVM is executing in thread-safe mode or not.
4165 @see llvm::llvm_is_multithreaded */
4166 LLVMBool LLVMIsMultithreaded(void);
4169 * @}
4173 * @}
4177 * @}
4180 LLVM_C_EXTERN_C_END
4182 #endif /* LLVM_C_CORE_H */