[RISCV] Refactor predicates for rvv intrinsic patterns.
[llvm-project.git] / llvm / include / llvm-c / Core.h
blob78dff8a8c274f7799c49f9ab5a50c0686ddc984e
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/Deprecated.h"
19 #include "llvm-c/ErrorHandling.h"
20 #include "llvm-c/ExternC.h"
22 #include "llvm-c/Types.h"
24 LLVM_C_EXTERN_C_BEGIN
26 /**
27 * @defgroup LLVMC LLVM-C: C interface to LLVM
29 * This module exposes parts of the LLVM library as a C API.
31 * @{
34 /**
35 * @defgroup LLVMCTransforms Transforms
38 /**
39 * @defgroup LLVMCCore Core
41 * This modules provide an interface to libLLVMCore, which implements
42 * the LLVM intermediate representation as well as other related types
43 * and utilities.
45 * Many exotic languages can interoperate with C code but have a harder time
46 * with C++ due to name mangling. So in addition to C, this interface enables
47 * tools written in such languages.
49 * @{
52 /**
53 * @defgroup LLVMCCoreTypes Types and Enumerations
55 * @{
58 /// External users depend on the following values being stable. It is not safe
59 /// to reorder them.
60 typedef enum {
61 /* Terminator Instructions */
62 LLVMRet = 1,
63 LLVMBr = 2,
64 LLVMSwitch = 3,
65 LLVMIndirectBr = 4,
66 LLVMInvoke = 5,
67 /* removed 6 due to API changes */
68 LLVMUnreachable = 7,
69 LLVMCallBr = 67,
71 /* Standard Unary Operators */
72 LLVMFNeg = 66,
74 /* Standard Binary Operators */
75 LLVMAdd = 8,
76 LLVMFAdd = 9,
77 LLVMSub = 10,
78 LLVMFSub = 11,
79 LLVMMul = 12,
80 LLVMFMul = 13,
81 LLVMUDiv = 14,
82 LLVMSDiv = 15,
83 LLVMFDiv = 16,
84 LLVMURem = 17,
85 LLVMSRem = 18,
86 LLVMFRem = 19,
88 /* Logical Operators */
89 LLVMShl = 20,
90 LLVMLShr = 21,
91 LLVMAShr = 22,
92 LLVMAnd = 23,
93 LLVMOr = 24,
94 LLVMXor = 25,
96 /* Memory Operators */
97 LLVMAlloca = 26,
98 LLVMLoad = 27,
99 LLVMStore = 28,
100 LLVMGetElementPtr = 29,
102 /* Cast Operators */
103 LLVMTrunc = 30,
104 LLVMZExt = 31,
105 LLVMSExt = 32,
106 LLVMFPToUI = 33,
107 LLVMFPToSI = 34,
108 LLVMUIToFP = 35,
109 LLVMSIToFP = 36,
110 LLVMFPTrunc = 37,
111 LLVMFPExt = 38,
112 LLVMPtrToInt = 39,
113 LLVMIntToPtr = 40,
114 LLVMBitCast = 41,
115 LLVMAddrSpaceCast = 60,
117 /* Other Operators */
118 LLVMICmp = 42,
119 LLVMFCmp = 43,
120 LLVMPHI = 44,
121 LLVMCall = 45,
122 LLVMSelect = 46,
123 LLVMUserOp1 = 47,
124 LLVMUserOp2 = 48,
125 LLVMVAArg = 49,
126 LLVMExtractElement = 50,
127 LLVMInsertElement = 51,
128 LLVMShuffleVector = 52,
129 LLVMExtractValue = 53,
130 LLVMInsertValue = 54,
131 LLVMFreeze = 68,
133 /* Atomic operators */
134 LLVMFence = 55,
135 LLVMAtomicCmpXchg = 56,
136 LLVMAtomicRMW = 57,
138 /* Exception Handling Operators */
139 LLVMResume = 58,
140 LLVMLandingPad = 59,
141 LLVMCleanupRet = 61,
142 LLVMCatchRet = 62,
143 LLVMCatchPad = 63,
144 LLVMCleanupPad = 64,
145 LLVMCatchSwitch = 65
146 } LLVMOpcode;
148 typedef enum {
149 LLVMVoidTypeKind, /**< type with no size */
150 LLVMHalfTypeKind, /**< 16 bit floating point type */
151 LLVMFloatTypeKind, /**< 32 bit floating point type */
152 LLVMDoubleTypeKind, /**< 64 bit floating point type */
153 LLVMX86_FP80TypeKind, /**< 80 bit floating point type (X87) */
154 LLVMFP128TypeKind, /**< 128 bit floating point type (112-bit mantissa)*/
155 LLVMPPC_FP128TypeKind, /**< 128 bit floating point type (two 64-bits) */
156 LLVMLabelTypeKind, /**< Labels */
157 LLVMIntegerTypeKind, /**< Arbitrary bit width integers */
158 LLVMFunctionTypeKind, /**< Functions */
159 LLVMStructTypeKind, /**< Structures */
160 LLVMArrayTypeKind, /**< Arrays */
161 LLVMPointerTypeKind, /**< Pointers */
162 LLVMVectorTypeKind, /**< Fixed width SIMD vector type */
163 LLVMMetadataTypeKind, /**< Metadata */
164 LLVMX86_MMXTypeKind, /**< X86 MMX */
165 LLVMTokenTypeKind, /**< Tokens */
166 LLVMScalableVectorTypeKind, /**< Scalable SIMD vector type */
167 LLVMBFloatTypeKind, /**< 16 bit brain floating point type */
168 LLVMX86_AMXTypeKind, /**< X86 AMX */
169 LLVMTargetExtTypeKind, /**< Target extension type */
170 } LLVMTypeKind;
172 typedef enum {
173 LLVMExternalLinkage, /**< Externally visible function */
174 LLVMAvailableExternallyLinkage,
175 LLVMLinkOnceAnyLinkage, /**< Keep one copy of function when linking (inline)*/
176 LLVMLinkOnceODRLinkage, /**< Same, but only replaced by something
177 equivalent. */
178 LLVMLinkOnceODRAutoHideLinkage, /**< Obsolete */
179 LLVMWeakAnyLinkage, /**< Keep one copy of function when linking (weak) */
180 LLVMWeakODRLinkage, /**< Same, but only replaced by something
181 equivalent. */
182 LLVMAppendingLinkage, /**< Special purpose, only applies to global arrays */
183 LLVMInternalLinkage, /**< Rename collisions when linking (static
184 functions) */
185 LLVMPrivateLinkage, /**< Like Internal, but omit from symbol table */
186 LLVMDLLImportLinkage, /**< Obsolete */
187 LLVMDLLExportLinkage, /**< Obsolete */
188 LLVMExternalWeakLinkage,/**< ExternalWeak linkage description */
189 LLVMGhostLinkage, /**< Obsolete */
190 LLVMCommonLinkage, /**< Tentative definitions */
191 LLVMLinkerPrivateLinkage, /**< Like Private, but linker removes. */
192 LLVMLinkerPrivateWeakLinkage /**< Like LinkerPrivate, but is weak. */
193 } LLVMLinkage;
195 typedef enum {
196 LLVMDefaultVisibility, /**< The GV is visible */
197 LLVMHiddenVisibility, /**< The GV is hidden */
198 LLVMProtectedVisibility /**< The GV is protected */
199 } LLVMVisibility;
201 typedef enum {
202 LLVMNoUnnamedAddr, /**< Address of the GV is significant. */
203 LLVMLocalUnnamedAddr, /**< Address of the GV is locally insignificant. */
204 LLVMGlobalUnnamedAddr /**< Address of the GV is globally insignificant. */
205 } LLVMUnnamedAddr;
207 typedef enum {
208 LLVMDefaultStorageClass = 0,
209 LLVMDLLImportStorageClass = 1, /**< Function to be imported from DLL. */
210 LLVMDLLExportStorageClass = 2 /**< Function to be accessible from DLL. */
211 } LLVMDLLStorageClass;
213 typedef enum {
214 LLVMCCallConv = 0,
215 LLVMFastCallConv = 8,
216 LLVMColdCallConv = 9,
217 LLVMGHCCallConv = 10,
218 LLVMHiPECallConv = 11,
219 LLVMWebKitJSCallConv = 12,
220 LLVMAnyRegCallConv = 13,
221 LLVMPreserveMostCallConv = 14,
222 LLVMPreserveAllCallConv = 15,
223 LLVMSwiftCallConv = 16,
224 LLVMCXXFASTTLSCallConv = 17,
225 LLVMX86StdcallCallConv = 64,
226 LLVMX86FastcallCallConv = 65,
227 LLVMARMAPCSCallConv = 66,
228 LLVMARMAAPCSCallConv = 67,
229 LLVMARMAAPCSVFPCallConv = 68,
230 LLVMMSP430INTRCallConv = 69,
231 LLVMX86ThisCallCallConv = 70,
232 LLVMPTXKernelCallConv = 71,
233 LLVMPTXDeviceCallConv = 72,
234 LLVMSPIRFUNCCallConv = 75,
235 LLVMSPIRKERNELCallConv = 76,
236 LLVMIntelOCLBICallConv = 77,
237 LLVMX8664SysVCallConv = 78,
238 LLVMWin64CallConv = 79,
239 LLVMX86VectorCallCallConv = 80,
240 LLVMHHVMCallConv = 81,
241 LLVMHHVMCCallConv = 82,
242 LLVMX86INTRCallConv = 83,
243 LLVMAVRINTRCallConv = 84,
244 LLVMAVRSIGNALCallConv = 85,
245 LLVMAVRBUILTINCallConv = 86,
246 LLVMAMDGPUVSCallConv = 87,
247 LLVMAMDGPUGSCallConv = 88,
248 LLVMAMDGPUPSCallConv = 89,
249 LLVMAMDGPUCSCallConv = 90,
250 LLVMAMDGPUKERNELCallConv = 91,
251 LLVMX86RegCallCallConv = 92,
252 LLVMAMDGPUHSCallConv = 93,
253 LLVMMSP430BUILTINCallConv = 94,
254 LLVMAMDGPULSCallConv = 95,
255 LLVMAMDGPUESCallConv = 96
256 } LLVMCallConv;
258 typedef enum {
259 LLVMArgumentValueKind,
260 LLVMBasicBlockValueKind,
261 LLVMMemoryUseValueKind,
262 LLVMMemoryDefValueKind,
263 LLVMMemoryPhiValueKind,
265 LLVMFunctionValueKind,
266 LLVMGlobalAliasValueKind,
267 LLVMGlobalIFuncValueKind,
268 LLVMGlobalVariableValueKind,
269 LLVMBlockAddressValueKind,
270 LLVMConstantExprValueKind,
271 LLVMConstantArrayValueKind,
272 LLVMConstantStructValueKind,
273 LLVMConstantVectorValueKind,
275 LLVMUndefValueValueKind,
276 LLVMConstantAggregateZeroValueKind,
277 LLVMConstantDataArrayValueKind,
278 LLVMConstantDataVectorValueKind,
279 LLVMConstantIntValueKind,
280 LLVMConstantFPValueKind,
281 LLVMConstantPointerNullValueKind,
282 LLVMConstantTokenNoneValueKind,
284 LLVMMetadataAsValueValueKind,
285 LLVMInlineAsmValueKind,
287 LLVMInstructionValueKind,
288 LLVMPoisonValueValueKind,
289 LLVMConstantTargetNoneValueKind,
290 } LLVMValueKind;
292 typedef enum {
293 LLVMIntEQ = 32, /**< equal */
294 LLVMIntNE, /**< not equal */
295 LLVMIntUGT, /**< unsigned greater than */
296 LLVMIntUGE, /**< unsigned greater or equal */
297 LLVMIntULT, /**< unsigned less than */
298 LLVMIntULE, /**< unsigned less or equal */
299 LLVMIntSGT, /**< signed greater than */
300 LLVMIntSGE, /**< signed greater or equal */
301 LLVMIntSLT, /**< signed less than */
302 LLVMIntSLE /**< signed less or equal */
303 } LLVMIntPredicate;
305 typedef enum {
306 LLVMRealPredicateFalse, /**< Always false (always folded) */
307 LLVMRealOEQ, /**< True if ordered and equal */
308 LLVMRealOGT, /**< True if ordered and greater than */
309 LLVMRealOGE, /**< True if ordered and greater than or equal */
310 LLVMRealOLT, /**< True if ordered and less than */
311 LLVMRealOLE, /**< True if ordered and less than or equal */
312 LLVMRealONE, /**< True if ordered and operands are unequal */
313 LLVMRealORD, /**< True if ordered (no nans) */
314 LLVMRealUNO, /**< True if unordered: isnan(X) | isnan(Y) */
315 LLVMRealUEQ, /**< True if unordered or equal */
316 LLVMRealUGT, /**< True if unordered or greater than */
317 LLVMRealUGE, /**< True if unordered, greater than, or equal */
318 LLVMRealULT, /**< True if unordered or less than */
319 LLVMRealULE, /**< True if unordered, less than, or equal */
320 LLVMRealUNE, /**< True if unordered or not equal */
321 LLVMRealPredicateTrue /**< Always true (always folded) */
322 } LLVMRealPredicate;
324 typedef enum {
325 LLVMLandingPadCatch, /**< A catch clause */
326 LLVMLandingPadFilter /**< A filter clause */
327 } LLVMLandingPadClauseTy;
329 typedef enum {
330 LLVMNotThreadLocal = 0,
331 LLVMGeneralDynamicTLSModel,
332 LLVMLocalDynamicTLSModel,
333 LLVMInitialExecTLSModel,
334 LLVMLocalExecTLSModel
335 } LLVMThreadLocalMode;
337 typedef enum {
338 LLVMAtomicOrderingNotAtomic = 0, /**< A load or store which is not atomic */
339 LLVMAtomicOrderingUnordered = 1, /**< Lowest level of atomicity, guarantees
340 somewhat sane results, lock free. */
341 LLVMAtomicOrderingMonotonic = 2, /**< guarantees that if you take all the
342 operations affecting a specific address,
343 a consistent ordering exists */
344 LLVMAtomicOrderingAcquire = 4, /**< Acquire provides a barrier of the sort
345 necessary to acquire a lock to access other
346 memory with normal loads and stores. */
347 LLVMAtomicOrderingRelease = 5, /**< Release is similar to Acquire, but with
348 a barrier of the sort necessary to release
349 a lock. */
350 LLVMAtomicOrderingAcquireRelease = 6, /**< provides both an Acquire and a
351 Release barrier (for fences and
352 operations which both read and write
353 memory). */
354 LLVMAtomicOrderingSequentiallyConsistent = 7 /**< provides Acquire semantics
355 for loads and Release
356 semantics for stores.
357 Additionally, it guarantees
358 that a total ordering exists
359 between all
360 SequentiallyConsistent
361 operations. */
362 } LLVMAtomicOrdering;
364 typedef enum {
365 LLVMAtomicRMWBinOpXchg, /**< Set the new value and return the one old */
366 LLVMAtomicRMWBinOpAdd, /**< Add a value and return the old one */
367 LLVMAtomicRMWBinOpSub, /**< Subtract a value and return the old one */
368 LLVMAtomicRMWBinOpAnd, /**< And a value and return the old one */
369 LLVMAtomicRMWBinOpNand, /**< Not-And a value and return the old one */
370 LLVMAtomicRMWBinOpOr, /**< OR a value and return the old one */
371 LLVMAtomicRMWBinOpXor, /**< Xor a value and return the old one */
372 LLVMAtomicRMWBinOpMax, /**< Sets the value if it's greater than the
373 original using a signed comparison and return
374 the old one */
375 LLVMAtomicRMWBinOpMin, /**< Sets the value if it's Smaller than the
376 original using a signed comparison and return
377 the old one */
378 LLVMAtomicRMWBinOpUMax, /**< Sets the value if it's greater than the
379 original using an unsigned comparison and return
380 the old one */
381 LLVMAtomicRMWBinOpUMin, /**< Sets the value if it's greater than the
382 original using an unsigned comparison and return
383 the old one */
384 LLVMAtomicRMWBinOpFAdd, /**< Add a floating point value and return the
385 old one */
386 LLVMAtomicRMWBinOpFSub, /**< Subtract a floating point value and return the
387 old one */
388 LLVMAtomicRMWBinOpFMax, /**< Sets the value if it's greater than the
389 original using an floating point comparison and
390 return the old one */
391 LLVMAtomicRMWBinOpFMin, /**< Sets the value if it's smaller than the
392 original using an floating point comparison and
393 return the old one */
394 } LLVMAtomicRMWBinOp;
396 typedef enum {
397 LLVMDSError,
398 LLVMDSWarning,
399 LLVMDSRemark,
400 LLVMDSNote
401 } LLVMDiagnosticSeverity;
403 typedef enum {
404 LLVMInlineAsmDialectATT,
405 LLVMInlineAsmDialectIntel
406 } LLVMInlineAsmDialect;
408 typedef enum {
410 * Emits an error if two values disagree, otherwise the resulting value is
411 * that of the operands.
413 * @see Module::ModFlagBehavior::Error
415 LLVMModuleFlagBehaviorError,
417 * Emits a warning if two values disagree. The result value will be the
418 * operand for the flag from the first module being linked.
420 * @see Module::ModFlagBehavior::Warning
422 LLVMModuleFlagBehaviorWarning,
424 * Adds a requirement that another module flag be present and have a
425 * specified value after linking is performed. The value must be a metadata
426 * pair, where the first element of the pair is the ID of the module flag
427 * to be restricted, and the second element of the pair is the value the
428 * module flag should be restricted to. This behavior can be used to
429 * restrict the allowable results (via triggering of an error) of linking
430 * IDs with the **Override** behavior.
432 * @see Module::ModFlagBehavior::Require
434 LLVMModuleFlagBehaviorRequire,
436 * Uses the specified value, regardless of the behavior or value of the
437 * other module. If both modules specify **Override**, but the values
438 * differ, an error will be emitted.
440 * @see Module::ModFlagBehavior::Override
442 LLVMModuleFlagBehaviorOverride,
444 * Appends the two values, which are required to be metadata nodes.
446 * @see Module::ModFlagBehavior::Append
448 LLVMModuleFlagBehaviorAppend,
450 * Appends the two values, which are required to be metadata
451 * nodes. However, duplicate entries in the second list are dropped
452 * during the append operation.
454 * @see Module::ModFlagBehavior::AppendUnique
456 LLVMModuleFlagBehaviorAppendUnique,
457 } LLVMModuleFlagBehavior;
460 * Attribute index are either LLVMAttributeReturnIndex,
461 * LLVMAttributeFunctionIndex or a parameter number from 1 to N.
463 enum {
464 LLVMAttributeReturnIndex = 0U,
465 // ISO C restricts enumerator values to range of 'int'
466 // (4294967295 is too large)
467 // LLVMAttributeFunctionIndex = ~0U,
468 LLVMAttributeFunctionIndex = -1,
471 typedef unsigned LLVMAttributeIndex;
474 * @}
477 /** Deallocate and destroy all ManagedStatic variables.
478 @see llvm::llvm_shutdown
479 @see ManagedStatic */
480 void LLVMShutdown(void);
482 /*===-- Version query -----------------------------------------------------===*/
485 * Return the major, minor, and patch version of LLVM
487 * The version components are returned via the function's three output
488 * parameters or skipped if a NULL pointer was supplied.
490 void LLVMGetVersion(unsigned *Major, unsigned *Minor, unsigned *Patch);
492 /*===-- Error handling ----------------------------------------------------===*/
494 char *LLVMCreateMessage(const char *Message);
495 void LLVMDisposeMessage(char *Message);
498 * @defgroup LLVMCCoreContext Contexts
500 * Contexts are execution states for the core LLVM IR system.
502 * Most types are tied to a context instance. Multiple contexts can
503 * exist simultaneously. A single context is not thread safe. However,
504 * different contexts can execute on different threads simultaneously.
506 * @{
509 typedef void (*LLVMDiagnosticHandler)(LLVMDiagnosticInfoRef, void *);
510 typedef void (*LLVMYieldCallback)(LLVMContextRef, void *);
513 * Create a new context.
515 * Every call to this function should be paired with a call to
516 * LLVMContextDispose() or the context will leak memory.
518 LLVMContextRef LLVMContextCreate(void);
521 * Obtain the global context instance.
523 LLVMContextRef LLVMGetGlobalContext(void);
526 * Set the diagnostic handler for this context.
528 void LLVMContextSetDiagnosticHandler(LLVMContextRef C,
529 LLVMDiagnosticHandler Handler,
530 void *DiagnosticContext);
533 * Get the diagnostic handler of this context.
535 LLVMDiagnosticHandler LLVMContextGetDiagnosticHandler(LLVMContextRef C);
538 * Get the diagnostic context of this context.
540 void *LLVMContextGetDiagnosticContext(LLVMContextRef C);
543 * Set the yield callback function for this context.
545 * @see LLVMContext::setYieldCallback()
547 void LLVMContextSetYieldCallback(LLVMContextRef C, LLVMYieldCallback Callback,
548 void *OpaqueHandle);
551 * Retrieve whether the given context is set to discard all value names.
553 * @see LLVMContext::shouldDiscardValueNames()
555 LLVMBool LLVMContextShouldDiscardValueNames(LLVMContextRef C);
558 * Set whether the given context discards all value names.
560 * If true, only the names of GlobalValue objects will be available in the IR.
561 * This can be used to save memory and runtime, especially in release mode.
563 * @see LLVMContext::setDiscardValueNames()
565 void LLVMContextSetDiscardValueNames(LLVMContextRef C, LLVMBool Discard);
568 * Destroy a context instance.
570 * This should be called for every call to LLVMContextCreate() or memory
571 * will be leaked.
573 void LLVMContextDispose(LLVMContextRef C);
576 * Return a string representation of the DiagnosticInfo. Use
577 * LLVMDisposeMessage to free the string.
579 * @see DiagnosticInfo::print()
581 char *LLVMGetDiagInfoDescription(LLVMDiagnosticInfoRef DI);
584 * Return an enum LLVMDiagnosticSeverity.
586 * @see DiagnosticInfo::getSeverity()
588 LLVMDiagnosticSeverity LLVMGetDiagInfoSeverity(LLVMDiagnosticInfoRef DI);
590 unsigned LLVMGetMDKindIDInContext(LLVMContextRef C, const char *Name,
591 unsigned SLen);
592 unsigned LLVMGetMDKindID(const char *Name, unsigned SLen);
595 * Return an unique id given the name of a enum attribute,
596 * or 0 if no attribute by that name exists.
598 * See http://llvm.org/docs/LangRef.html#parameter-attributes
599 * and http://llvm.org/docs/LangRef.html#function-attributes
600 * for the list of available attributes.
602 * NB: Attribute names and/or id are subject to change without
603 * going through the C API deprecation cycle.
605 unsigned LLVMGetEnumAttributeKindForName(const char *Name, size_t SLen);
606 unsigned LLVMGetLastEnumAttributeKind(void);
609 * Create an enum attribute.
611 LLVMAttributeRef LLVMCreateEnumAttribute(LLVMContextRef C, unsigned KindID,
612 uint64_t Val);
615 * Get the unique id corresponding to the enum attribute
616 * passed as argument.
618 unsigned LLVMGetEnumAttributeKind(LLVMAttributeRef A);
621 * Get the enum attribute's value. 0 is returned if none exists.
623 uint64_t LLVMGetEnumAttributeValue(LLVMAttributeRef A);
626 * Create a type attribute
628 LLVMAttributeRef LLVMCreateTypeAttribute(LLVMContextRef C, unsigned KindID,
629 LLVMTypeRef type_ref);
632 * Get the type attribute's value.
634 LLVMTypeRef LLVMGetTypeAttributeValue(LLVMAttributeRef A);
637 * Create a string attribute.
639 LLVMAttributeRef LLVMCreateStringAttribute(LLVMContextRef C,
640 const char *K, unsigned KLength,
641 const char *V, unsigned VLength);
644 * Get the string attribute's kind.
646 const char *LLVMGetStringAttributeKind(LLVMAttributeRef A, unsigned *Length);
649 * Get the string attribute's value.
651 const char *LLVMGetStringAttributeValue(LLVMAttributeRef A, unsigned *Length);
654 * Check for the different types of attributes.
656 LLVMBool LLVMIsEnumAttribute(LLVMAttributeRef A);
657 LLVMBool LLVMIsStringAttribute(LLVMAttributeRef A);
658 LLVMBool LLVMIsTypeAttribute(LLVMAttributeRef A);
661 * Obtain a Type from a context by its registered name.
663 LLVMTypeRef LLVMGetTypeByName2(LLVMContextRef C, const char *Name);
666 * @}
670 * @defgroup LLVMCCoreModule Modules
672 * Modules represent the top-level structure in an LLVM program. An LLVM
673 * module is effectively a translation unit or a collection of
674 * translation units merged together.
676 * @{
680 * Create a new, empty module in the global context.
682 * This is equivalent to calling LLVMModuleCreateWithNameInContext with
683 * LLVMGetGlobalContext() as the context parameter.
685 * Every invocation should be paired with LLVMDisposeModule() or memory
686 * will be leaked.
688 LLVMModuleRef LLVMModuleCreateWithName(const char *ModuleID);
691 * Create a new, empty module in a specific context.
693 * Every invocation should be paired with LLVMDisposeModule() or memory
694 * will be leaked.
696 LLVMModuleRef LLVMModuleCreateWithNameInContext(const char *ModuleID,
697 LLVMContextRef C);
699 * Return an exact copy of the specified module.
701 LLVMModuleRef LLVMCloneModule(LLVMModuleRef M);
704 * Destroy a module instance.
706 * This must be called for every created module or memory will be
707 * leaked.
709 void LLVMDisposeModule(LLVMModuleRef M);
712 * Obtain the identifier of a module.
714 * @param M Module to obtain identifier of
715 * @param Len Out parameter which holds the length of the returned string.
716 * @return The identifier of M.
717 * @see Module::getModuleIdentifier()
719 const char *LLVMGetModuleIdentifier(LLVMModuleRef M, size_t *Len);
722 * Set the identifier of a module to a string Ident with length Len.
724 * @param M The module to set identifier
725 * @param Ident The string to set M's identifier to
726 * @param Len Length of Ident
727 * @see Module::setModuleIdentifier()
729 void LLVMSetModuleIdentifier(LLVMModuleRef M, const char *Ident, size_t Len);
732 * Obtain the module's original source file name.
734 * @param M Module to obtain the name of
735 * @param Len Out parameter which holds the length of the returned string
736 * @return The original source file name of M
737 * @see Module::getSourceFileName()
739 const char *LLVMGetSourceFileName(LLVMModuleRef M, size_t *Len);
742 * Set the original source file name of a module to a string Name with length
743 * Len.
745 * @param M The module to set the source file name of
746 * @param Name The string to set M's source file name to
747 * @param Len Length of Name
748 * @see Module::setSourceFileName()
750 void LLVMSetSourceFileName(LLVMModuleRef M, const char *Name, size_t Len);
753 * Obtain the data layout for a module.
755 * @see Module::getDataLayoutStr()
757 * LLVMGetDataLayout is DEPRECATED, as the name is not only incorrect,
758 * but match the name of another method on the module. Prefer the use
759 * of LLVMGetDataLayoutStr, which is not ambiguous.
761 const char *LLVMGetDataLayoutStr(LLVMModuleRef M);
762 const char *LLVMGetDataLayout(LLVMModuleRef M);
765 * Set the data layout for a module.
767 * @see Module::setDataLayout()
769 void LLVMSetDataLayout(LLVMModuleRef M, const char *DataLayoutStr);
772 * Obtain the target triple for a module.
774 * @see Module::getTargetTriple()
776 const char *LLVMGetTarget(LLVMModuleRef M);
779 * Set the target triple for a module.
781 * @see Module::setTargetTriple()
783 void LLVMSetTarget(LLVMModuleRef M, const char *Triple);
786 * Returns the module flags as an array of flag-key-value triples. The caller
787 * is responsible for freeing this array by calling
788 * \c LLVMDisposeModuleFlagsMetadata.
790 * @see Module::getModuleFlagsMetadata()
792 LLVMModuleFlagEntry *LLVMCopyModuleFlagsMetadata(LLVMModuleRef M, size_t *Len);
795 * Destroys module flags metadata entries.
797 void LLVMDisposeModuleFlagsMetadata(LLVMModuleFlagEntry *Entries);
800 * Returns the flag behavior for a module flag entry at a specific index.
802 * @see Module::ModuleFlagEntry::Behavior
804 LLVMModuleFlagBehavior
805 LLVMModuleFlagEntriesGetFlagBehavior(LLVMModuleFlagEntry *Entries,
806 unsigned Index);
809 * Returns the key for a module flag entry at a specific index.
811 * @see Module::ModuleFlagEntry::Key
813 const char *LLVMModuleFlagEntriesGetKey(LLVMModuleFlagEntry *Entries,
814 unsigned Index, size_t *Len);
817 * Returns the metadata for a module flag entry at a specific index.
819 * @see Module::ModuleFlagEntry::Val
821 LLVMMetadataRef LLVMModuleFlagEntriesGetMetadata(LLVMModuleFlagEntry *Entries,
822 unsigned Index);
825 * Add a module-level flag to the module-level flags metadata if it doesn't
826 * already exist.
828 * @see Module::getModuleFlag()
830 LLVMMetadataRef LLVMGetModuleFlag(LLVMModuleRef M,
831 const char *Key, size_t KeyLen);
834 * Add a module-level flag to the module-level flags metadata if it doesn't
835 * already exist.
837 * @see Module::addModuleFlag()
839 void LLVMAddModuleFlag(LLVMModuleRef M, LLVMModuleFlagBehavior Behavior,
840 const char *Key, size_t KeyLen,
841 LLVMMetadataRef Val);
844 * Dump a representation of a module to stderr.
846 * @see Module::dump()
848 void LLVMDumpModule(LLVMModuleRef M);
851 * Print a representation of a module to a file. The ErrorMessage needs to be
852 * disposed with LLVMDisposeMessage. Returns 0 on success, 1 otherwise.
854 * @see Module::print()
856 LLVMBool LLVMPrintModuleToFile(LLVMModuleRef M, const char *Filename,
857 char **ErrorMessage);
860 * Return a string representation of the module. Use
861 * LLVMDisposeMessage to free the string.
863 * @see Module::print()
865 char *LLVMPrintModuleToString(LLVMModuleRef M);
868 * Get inline assembly for a module.
870 * @see Module::getModuleInlineAsm()
872 const char *LLVMGetModuleInlineAsm(LLVMModuleRef M, size_t *Len);
875 * Set inline assembly for a module.
877 * @see Module::setModuleInlineAsm()
879 void LLVMSetModuleInlineAsm2(LLVMModuleRef M, const char *Asm, size_t Len);
882 * Append inline assembly to a module.
884 * @see Module::appendModuleInlineAsm()
886 void LLVMAppendModuleInlineAsm(LLVMModuleRef M, const char *Asm, size_t Len);
889 * Create the specified uniqued inline asm string.
891 * @see InlineAsm::get()
893 LLVMValueRef LLVMGetInlineAsm(LLVMTypeRef Ty, char *AsmString,
894 size_t AsmStringSize, char *Constraints,
895 size_t ConstraintsSize, LLVMBool HasSideEffects,
896 LLVMBool IsAlignStack,
897 LLVMInlineAsmDialect Dialect, LLVMBool CanThrow);
900 * Obtain the context to which this module is associated.
902 * @see Module::getContext()
904 LLVMContextRef LLVMGetModuleContext(LLVMModuleRef M);
906 /** Deprecated: Use LLVMGetTypeByName2 instead. */
907 LLVMTypeRef LLVMGetTypeByName(LLVMModuleRef M, const char *Name);
910 * Obtain an iterator to the first NamedMDNode in a Module.
912 * @see llvm::Module::named_metadata_begin()
914 LLVMNamedMDNodeRef LLVMGetFirstNamedMetadata(LLVMModuleRef M);
917 * Obtain an iterator to the last NamedMDNode in a Module.
919 * @see llvm::Module::named_metadata_end()
921 LLVMNamedMDNodeRef LLVMGetLastNamedMetadata(LLVMModuleRef M);
924 * Advance a NamedMDNode iterator to the next NamedMDNode.
926 * Returns NULL if the iterator was already at the end and there are no more
927 * named metadata nodes.
929 LLVMNamedMDNodeRef LLVMGetNextNamedMetadata(LLVMNamedMDNodeRef NamedMDNode);
932 * Decrement a NamedMDNode iterator to the previous NamedMDNode.
934 * Returns NULL if the iterator was already at the beginning and there are
935 * no previous named metadata nodes.
937 LLVMNamedMDNodeRef LLVMGetPreviousNamedMetadata(LLVMNamedMDNodeRef NamedMDNode);
940 * Retrieve a NamedMDNode with the given name, returning NULL if no such
941 * node exists.
943 * @see llvm::Module::getNamedMetadata()
945 LLVMNamedMDNodeRef LLVMGetNamedMetadata(LLVMModuleRef M,
946 const char *Name, size_t NameLen);
949 * Retrieve a NamedMDNode with the given name, creating a new node if no such
950 * node exists.
952 * @see llvm::Module::getOrInsertNamedMetadata()
954 LLVMNamedMDNodeRef LLVMGetOrInsertNamedMetadata(LLVMModuleRef M,
955 const char *Name,
956 size_t NameLen);
959 * Retrieve the name of a NamedMDNode.
961 * @see llvm::NamedMDNode::getName()
963 const char *LLVMGetNamedMetadataName(LLVMNamedMDNodeRef NamedMD,
964 size_t *NameLen);
967 * Obtain the number of operands for named metadata in a module.
969 * @see llvm::Module::getNamedMetadata()
971 unsigned LLVMGetNamedMetadataNumOperands(LLVMModuleRef M, const char *Name);
974 * Obtain the named metadata operands for a module.
976 * The passed LLVMValueRef pointer should refer to an array of
977 * LLVMValueRef at least LLVMGetNamedMetadataNumOperands long. This
978 * array will be populated with the LLVMValueRef instances. Each
979 * instance corresponds to a llvm::MDNode.
981 * @see llvm::Module::getNamedMetadata()
982 * @see llvm::MDNode::getOperand()
984 void LLVMGetNamedMetadataOperands(LLVMModuleRef M, const char *Name,
985 LLVMValueRef *Dest);
988 * Add an operand to named metadata.
990 * @see llvm::Module::getNamedMetadata()
991 * @see llvm::MDNode::addOperand()
993 void LLVMAddNamedMetadataOperand(LLVMModuleRef M, const char *Name,
994 LLVMValueRef Val);
997 * Return the directory of the debug location for this value, which must be
998 * an llvm::Instruction, llvm::GlobalVariable, or llvm::Function.
1000 * @see llvm::Instruction::getDebugLoc()
1001 * @see llvm::GlobalVariable::getDebugInfo()
1002 * @see llvm::Function::getSubprogram()
1004 const char *LLVMGetDebugLocDirectory(LLVMValueRef Val, unsigned *Length);
1007 * Return the filename of the debug location for this value, which must be
1008 * an llvm::Instruction, llvm::GlobalVariable, or llvm::Function.
1010 * @see llvm::Instruction::getDebugLoc()
1011 * @see llvm::GlobalVariable::getDebugInfo()
1012 * @see llvm::Function::getSubprogram()
1014 const char *LLVMGetDebugLocFilename(LLVMValueRef Val, unsigned *Length);
1017 * Return the line number of the debug location for this value, which must be
1018 * an llvm::Instruction, llvm::GlobalVariable, or llvm::Function.
1020 * @see llvm::Instruction::getDebugLoc()
1021 * @see llvm::GlobalVariable::getDebugInfo()
1022 * @see llvm::Function::getSubprogram()
1024 unsigned LLVMGetDebugLocLine(LLVMValueRef Val);
1027 * Return the column number of the debug location for this value, which must be
1028 * an llvm::Instruction.
1030 * @see llvm::Instruction::getDebugLoc()
1032 unsigned LLVMGetDebugLocColumn(LLVMValueRef Val);
1035 * Add a function to a module under a specified name.
1037 * @see llvm::Function::Create()
1039 LLVMValueRef LLVMAddFunction(LLVMModuleRef M, const char *Name,
1040 LLVMTypeRef FunctionTy);
1043 * Obtain a Function value from a Module by its name.
1045 * The returned value corresponds to a llvm::Function value.
1047 * @see llvm::Module::getFunction()
1049 LLVMValueRef LLVMGetNamedFunction(LLVMModuleRef M, const char *Name);
1052 * Obtain an iterator to the first Function in a Module.
1054 * @see llvm::Module::begin()
1056 LLVMValueRef LLVMGetFirstFunction(LLVMModuleRef M);
1059 * Obtain an iterator to the last Function in a Module.
1061 * @see llvm::Module::end()
1063 LLVMValueRef LLVMGetLastFunction(LLVMModuleRef M);
1066 * Advance a Function iterator to the next Function.
1068 * Returns NULL if the iterator was already at the end and there are no more
1069 * functions.
1071 LLVMValueRef LLVMGetNextFunction(LLVMValueRef Fn);
1074 * Decrement a Function iterator to the previous Function.
1076 * Returns NULL if the iterator was already at the beginning and there are
1077 * no previous functions.
1079 LLVMValueRef LLVMGetPreviousFunction(LLVMValueRef Fn);
1081 /** Deprecated: Use LLVMSetModuleInlineAsm2 instead. */
1082 void LLVMSetModuleInlineAsm(LLVMModuleRef M, const char *Asm);
1085 * @}
1089 * @defgroup LLVMCCoreType Types
1091 * Types represent the type of a value.
1093 * Types are associated with a context instance. The context internally
1094 * deduplicates types so there is only 1 instance of a specific type
1095 * alive at a time. In other words, a unique type is shared among all
1096 * consumers within a context.
1098 * A Type in the C API corresponds to llvm::Type.
1100 * Types have the following hierarchy:
1102 * types:
1103 * integer type
1104 * real type
1105 * function type
1106 * sequence types:
1107 * array type
1108 * pointer type
1109 * vector type
1110 * void type
1111 * label type
1112 * opaque type
1114 * @{
1118 * Obtain the enumerated type of a Type instance.
1120 * @see llvm::Type:getTypeID()
1122 LLVMTypeKind LLVMGetTypeKind(LLVMTypeRef Ty);
1125 * Whether the type has a known size.
1127 * Things that don't have a size are abstract types, labels, and void.a
1129 * @see llvm::Type::isSized()
1131 LLVMBool LLVMTypeIsSized(LLVMTypeRef Ty);
1134 * Obtain the context to which this type instance is associated.
1136 * @see llvm::Type::getContext()
1138 LLVMContextRef LLVMGetTypeContext(LLVMTypeRef Ty);
1141 * Dump a representation of a type to stderr.
1143 * @see llvm::Type::dump()
1145 void LLVMDumpType(LLVMTypeRef Val);
1148 * Return a string representation of the type. Use
1149 * LLVMDisposeMessage to free the string.
1151 * @see llvm::Type::print()
1153 char *LLVMPrintTypeToString(LLVMTypeRef Val);
1156 * @defgroup LLVMCCoreTypeInt Integer Types
1158 * Functions in this section operate on integer types.
1160 * @{
1164 * Obtain an integer type from a context with specified bit width.
1166 LLVMTypeRef LLVMInt1TypeInContext(LLVMContextRef C);
1167 LLVMTypeRef LLVMInt8TypeInContext(LLVMContextRef C);
1168 LLVMTypeRef LLVMInt16TypeInContext(LLVMContextRef C);
1169 LLVMTypeRef LLVMInt32TypeInContext(LLVMContextRef C);
1170 LLVMTypeRef LLVMInt64TypeInContext(LLVMContextRef C);
1171 LLVMTypeRef LLVMInt128TypeInContext(LLVMContextRef C);
1172 LLVMTypeRef LLVMIntTypeInContext(LLVMContextRef C, unsigned NumBits);
1175 * Obtain an integer type from the global context with a specified bit
1176 * width.
1178 LLVMTypeRef LLVMInt1Type(void);
1179 LLVMTypeRef LLVMInt8Type(void);
1180 LLVMTypeRef LLVMInt16Type(void);
1181 LLVMTypeRef LLVMInt32Type(void);
1182 LLVMTypeRef LLVMInt64Type(void);
1183 LLVMTypeRef LLVMInt128Type(void);
1184 LLVMTypeRef LLVMIntType(unsigned NumBits);
1185 unsigned LLVMGetIntTypeWidth(LLVMTypeRef IntegerTy);
1188 * @}
1192 * @defgroup LLVMCCoreTypeFloat Floating Point Types
1194 * @{
1198 * Obtain a 16-bit floating point type from a context.
1200 LLVMTypeRef LLVMHalfTypeInContext(LLVMContextRef C);
1203 * Obtain a 16-bit brain floating point type from a context.
1205 LLVMTypeRef LLVMBFloatTypeInContext(LLVMContextRef C);
1208 * Obtain a 32-bit floating point type from a context.
1210 LLVMTypeRef LLVMFloatTypeInContext(LLVMContextRef C);
1213 * Obtain a 64-bit floating point type from a context.
1215 LLVMTypeRef LLVMDoubleTypeInContext(LLVMContextRef C);
1218 * Obtain a 80-bit floating point type (X87) from a context.
1220 LLVMTypeRef LLVMX86FP80TypeInContext(LLVMContextRef C);
1223 * Obtain a 128-bit floating point type (112-bit mantissa) from a
1224 * context.
1226 LLVMTypeRef LLVMFP128TypeInContext(LLVMContextRef C);
1229 * Obtain a 128-bit floating point type (two 64-bits) from a context.
1231 LLVMTypeRef LLVMPPCFP128TypeInContext(LLVMContextRef C);
1234 * Obtain a floating point type from the global context.
1236 * These map to the functions in this group of the same name.
1238 LLVMTypeRef LLVMHalfType(void);
1239 LLVMTypeRef LLVMBFloatType(void);
1240 LLVMTypeRef LLVMFloatType(void);
1241 LLVMTypeRef LLVMDoubleType(void);
1242 LLVMTypeRef LLVMX86FP80Type(void);
1243 LLVMTypeRef LLVMFP128Type(void);
1244 LLVMTypeRef LLVMPPCFP128Type(void);
1247 * @}
1251 * @defgroup LLVMCCoreTypeFunction Function Types
1253 * @{
1257 * Obtain a function type consisting of a specified signature.
1259 * The function is defined as a tuple of a return Type, a list of
1260 * parameter types, and whether the function is variadic.
1262 LLVMTypeRef LLVMFunctionType(LLVMTypeRef ReturnType,
1263 LLVMTypeRef *ParamTypes, unsigned ParamCount,
1264 LLVMBool IsVarArg);
1267 * Returns whether a function type is variadic.
1269 LLVMBool LLVMIsFunctionVarArg(LLVMTypeRef FunctionTy);
1272 * Obtain the Type this function Type returns.
1274 LLVMTypeRef LLVMGetReturnType(LLVMTypeRef FunctionTy);
1277 * Obtain the number of parameters this function accepts.
1279 unsigned LLVMCountParamTypes(LLVMTypeRef FunctionTy);
1282 * Obtain the types of a function's parameters.
1284 * The Dest parameter should point to a pre-allocated array of
1285 * LLVMTypeRef at least LLVMCountParamTypes() large. On return, the
1286 * first LLVMCountParamTypes() entries in the array will be populated
1287 * with LLVMTypeRef instances.
1289 * @param FunctionTy The function type to operate on.
1290 * @param Dest Memory address of an array to be filled with result.
1292 void LLVMGetParamTypes(LLVMTypeRef FunctionTy, LLVMTypeRef *Dest);
1295 * @}
1299 * @defgroup LLVMCCoreTypeStruct Structure Types
1301 * These functions relate to LLVMTypeRef instances.
1303 * @see llvm::StructType
1305 * @{
1309 * Create a new structure type in a context.
1311 * A structure is specified by a list of inner elements/types and
1312 * whether these can be packed together.
1314 * @see llvm::StructType::create()
1316 LLVMTypeRef LLVMStructTypeInContext(LLVMContextRef C, LLVMTypeRef *ElementTypes,
1317 unsigned ElementCount, LLVMBool Packed);
1320 * Create a new structure type in the global context.
1322 * @see llvm::StructType::create()
1324 LLVMTypeRef LLVMStructType(LLVMTypeRef *ElementTypes, unsigned ElementCount,
1325 LLVMBool Packed);
1328 * Create an empty structure in a context having a specified name.
1330 * @see llvm::StructType::create()
1332 LLVMTypeRef LLVMStructCreateNamed(LLVMContextRef C, const char *Name);
1335 * Obtain the name of a structure.
1337 * @see llvm::StructType::getName()
1339 const char *LLVMGetStructName(LLVMTypeRef Ty);
1342 * Set the contents of a structure type.
1344 * @see llvm::StructType::setBody()
1346 void LLVMStructSetBody(LLVMTypeRef StructTy, LLVMTypeRef *ElementTypes,
1347 unsigned ElementCount, LLVMBool Packed);
1350 * Get the number of elements defined inside the structure.
1352 * @see llvm::StructType::getNumElements()
1354 unsigned LLVMCountStructElementTypes(LLVMTypeRef StructTy);
1357 * Get the elements within a structure.
1359 * The function is passed the address of a pre-allocated array of
1360 * LLVMTypeRef at least LLVMCountStructElementTypes() long. After
1361 * invocation, this array will be populated with the structure's
1362 * elements. The objects in the destination array will have a lifetime
1363 * of the structure type itself, which is the lifetime of the context it
1364 * is contained in.
1366 void LLVMGetStructElementTypes(LLVMTypeRef StructTy, LLVMTypeRef *Dest);
1369 * Get the type of the element at a given index in the structure.
1371 * @see llvm::StructType::getTypeAtIndex()
1373 LLVMTypeRef LLVMStructGetTypeAtIndex(LLVMTypeRef StructTy, unsigned i);
1376 * Determine whether a structure is packed.
1378 * @see llvm::StructType::isPacked()
1380 LLVMBool LLVMIsPackedStruct(LLVMTypeRef StructTy);
1383 * Determine whether a structure is opaque.
1385 * @see llvm::StructType::isOpaque()
1387 LLVMBool LLVMIsOpaqueStruct(LLVMTypeRef StructTy);
1390 * Determine whether a structure is literal.
1392 * @see llvm::StructType::isLiteral()
1394 LLVMBool LLVMIsLiteralStruct(LLVMTypeRef StructTy);
1397 * @}
1401 * @defgroup LLVMCCoreTypeSequential Sequential Types
1403 * Sequential types represents "arrays" of types. This is a super class
1404 * for array, vector, and pointer types.
1406 * @{
1410 * Obtain the element type of an array or vector type.
1412 * @see llvm::SequentialType::getElementType()
1414 LLVMTypeRef LLVMGetElementType(LLVMTypeRef Ty);
1417 * Returns type's subtypes
1419 * @see llvm::Type::subtypes()
1421 void LLVMGetSubtypes(LLVMTypeRef Tp, LLVMTypeRef *Arr);
1424 * Return the number of types in the derived type.
1426 * @see llvm::Type::getNumContainedTypes()
1428 unsigned LLVMGetNumContainedTypes(LLVMTypeRef Tp);
1431 * Create a fixed size array type that refers to a specific type.
1433 * The created type will exist in the context that its element type
1434 * exists in.
1436 * @deprecated LLVMArrayType is deprecated in favor of the API accurate
1437 * LLVMArrayType2
1438 * @see llvm::ArrayType::get()
1440 LLVMTypeRef LLVMArrayType(LLVMTypeRef ElementType, unsigned ElementCount);
1443 * Create a fixed size array type that refers to a specific type.
1445 * The created type will exist in the context that its element type
1446 * exists in.
1448 * @see llvm::ArrayType::get()
1450 LLVMTypeRef LLVMArrayType2(LLVMTypeRef ElementType, uint64_t ElementCount);
1453 * Obtain the length of an array type.
1455 * This only works on types that represent arrays.
1457 * @deprecated LLVMGetArrayLength is deprecated in favor of the API accurate
1458 * LLVMGetArrayLength2
1459 * @see llvm::ArrayType::getNumElements()
1461 unsigned LLVMGetArrayLength(LLVMTypeRef ArrayTy);
1464 * Obtain the length of an array type.
1466 * This only works on types that represent arrays.
1468 * @see llvm::ArrayType::getNumElements()
1470 uint64_t LLVMGetArrayLength2(LLVMTypeRef ArrayTy);
1473 * Create a pointer type that points to a defined type.
1475 * The created type will exist in the context that its pointee type
1476 * exists in.
1478 * @see llvm::PointerType::get()
1480 LLVMTypeRef LLVMPointerType(LLVMTypeRef ElementType, unsigned AddressSpace);
1483 * Determine whether a pointer is opaque.
1485 * True if this is an instance of an opaque PointerType.
1487 * @see llvm::Type::isOpaquePointerTy()
1489 LLVMBool LLVMPointerTypeIsOpaque(LLVMTypeRef Ty);
1492 * Create an opaque pointer type in a context.
1494 * @see llvm::PointerType::get()
1496 LLVMTypeRef LLVMPointerTypeInContext(LLVMContextRef C, unsigned AddressSpace);
1499 * Obtain the address space of a pointer type.
1501 * This only works on types that represent pointers.
1503 * @see llvm::PointerType::getAddressSpace()
1505 unsigned LLVMGetPointerAddressSpace(LLVMTypeRef PointerTy);
1508 * Create a vector type that contains a defined type and has a specific
1509 * number of elements.
1511 * The created type will exist in the context thats its element type
1512 * exists in.
1514 * @see llvm::VectorType::get()
1516 LLVMTypeRef LLVMVectorType(LLVMTypeRef ElementType, unsigned ElementCount);
1519 * Create a vector type that contains a defined type and has a scalable
1520 * number of elements.
1522 * The created type will exist in the context thats its element type
1523 * exists in.
1525 * @see llvm::ScalableVectorType::get()
1527 LLVMTypeRef LLVMScalableVectorType(LLVMTypeRef ElementType,
1528 unsigned ElementCount);
1531 * Obtain the (possibly scalable) number of elements in a vector type.
1533 * This only works on types that represent vectors (fixed or scalable).
1535 * @see llvm::VectorType::getNumElements()
1537 unsigned LLVMGetVectorSize(LLVMTypeRef VectorTy);
1540 * @}
1544 * @defgroup LLVMCCoreTypeOther Other Types
1546 * @{
1550 * Create a void type in a context.
1552 LLVMTypeRef LLVMVoidTypeInContext(LLVMContextRef C);
1555 * Create a label type in a context.
1557 LLVMTypeRef LLVMLabelTypeInContext(LLVMContextRef C);
1560 * Create a X86 MMX type in a context.
1562 LLVMTypeRef LLVMX86MMXTypeInContext(LLVMContextRef C);
1565 * Create a X86 AMX type in a context.
1567 LLVMTypeRef LLVMX86AMXTypeInContext(LLVMContextRef C);
1570 * Create a token type in a context.
1572 LLVMTypeRef LLVMTokenTypeInContext(LLVMContextRef C);
1575 * Create a metadata type in a context.
1577 LLVMTypeRef LLVMMetadataTypeInContext(LLVMContextRef C);
1580 * These are similar to the above functions except they operate on the
1581 * global context.
1583 LLVMTypeRef LLVMVoidType(void);
1584 LLVMTypeRef LLVMLabelType(void);
1585 LLVMTypeRef LLVMX86MMXType(void);
1586 LLVMTypeRef LLVMX86AMXType(void);
1589 * Create a target extension type in LLVM context.
1591 LLVMTypeRef LLVMTargetExtTypeInContext(LLVMContextRef C, const char *Name,
1592 LLVMTypeRef *TypeParams,
1593 unsigned TypeParamCount,
1594 unsigned *IntParams,
1595 unsigned IntParamCount);
1598 * @}
1602 * @}
1606 * @defgroup LLVMCCoreValues Values
1608 * The bulk of LLVM's object model consists of values, which comprise a very
1609 * rich type hierarchy.
1611 * LLVMValueRef essentially represents llvm::Value. There is a rich
1612 * hierarchy of classes within this type. Depending on the instance
1613 * obtained, not all APIs are available.
1615 * Callers can determine the type of an LLVMValueRef by calling the
1616 * LLVMIsA* family of functions (e.g. LLVMIsAArgument()). These
1617 * functions are defined by a macro, so it isn't obvious which are
1618 * available by looking at the Doxygen source code. Instead, look at the
1619 * source definition of LLVM_FOR_EACH_VALUE_SUBCLASS and note the list
1620 * of value names given. These value names also correspond to classes in
1621 * the llvm::Value hierarchy.
1623 * @{
1626 #define LLVM_FOR_EACH_VALUE_SUBCLASS(macro) \
1627 macro(Argument) \
1628 macro(BasicBlock) \
1629 macro(InlineAsm) \
1630 macro(User) \
1631 macro(Constant) \
1632 macro(BlockAddress) \
1633 macro(ConstantAggregateZero) \
1634 macro(ConstantArray) \
1635 macro(ConstantDataSequential) \
1636 macro(ConstantDataArray) \
1637 macro(ConstantDataVector) \
1638 macro(ConstantExpr) \
1639 macro(ConstantFP) \
1640 macro(ConstantInt) \
1641 macro(ConstantPointerNull) \
1642 macro(ConstantStruct) \
1643 macro(ConstantTokenNone) \
1644 macro(ConstantVector) \
1645 macro(GlobalValue) \
1646 macro(GlobalAlias) \
1647 macro(GlobalObject) \
1648 macro(Function) \
1649 macro(GlobalVariable) \
1650 macro(GlobalIFunc) \
1651 macro(UndefValue) \
1652 macro(PoisonValue) \
1653 macro(Instruction) \
1654 macro(UnaryOperator) \
1655 macro(BinaryOperator) \
1656 macro(CallInst) \
1657 macro(IntrinsicInst) \
1658 macro(DbgInfoIntrinsic) \
1659 macro(DbgVariableIntrinsic) \
1660 macro(DbgDeclareInst) \
1661 macro(DbgLabelInst) \
1662 macro(MemIntrinsic) \
1663 macro(MemCpyInst) \
1664 macro(MemMoveInst) \
1665 macro(MemSetInst) \
1666 macro(CmpInst) \
1667 macro(FCmpInst) \
1668 macro(ICmpInst) \
1669 macro(ExtractElementInst) \
1670 macro(GetElementPtrInst) \
1671 macro(InsertElementInst) \
1672 macro(InsertValueInst) \
1673 macro(LandingPadInst) \
1674 macro(PHINode) \
1675 macro(SelectInst) \
1676 macro(ShuffleVectorInst) \
1677 macro(StoreInst) \
1678 macro(BranchInst) \
1679 macro(IndirectBrInst) \
1680 macro(InvokeInst) \
1681 macro(ReturnInst) \
1682 macro(SwitchInst) \
1683 macro(UnreachableInst) \
1684 macro(ResumeInst) \
1685 macro(CleanupReturnInst) \
1686 macro(CatchReturnInst) \
1687 macro(CatchSwitchInst) \
1688 macro(CallBrInst) \
1689 macro(FuncletPadInst) \
1690 macro(CatchPadInst) \
1691 macro(CleanupPadInst) \
1692 macro(UnaryInstruction) \
1693 macro(AllocaInst) \
1694 macro(CastInst) \
1695 macro(AddrSpaceCastInst) \
1696 macro(BitCastInst) \
1697 macro(FPExtInst) \
1698 macro(FPToSIInst) \
1699 macro(FPToUIInst) \
1700 macro(FPTruncInst) \
1701 macro(IntToPtrInst) \
1702 macro(PtrToIntInst) \
1703 macro(SExtInst) \
1704 macro(SIToFPInst) \
1705 macro(TruncInst) \
1706 macro(UIToFPInst) \
1707 macro(ZExtInst) \
1708 macro(ExtractValueInst) \
1709 macro(LoadInst) \
1710 macro(VAArgInst) \
1711 macro(FreezeInst) \
1712 macro(AtomicCmpXchgInst) \
1713 macro(AtomicRMWInst) \
1714 macro(FenceInst)
1717 * @defgroup LLVMCCoreValueGeneral General APIs
1719 * Functions in this section work on all LLVMValueRef instances,
1720 * regardless of their sub-type. They correspond to functions available
1721 * on llvm::Value.
1723 * @{
1727 * Obtain the type of a value.
1729 * @see llvm::Value::getType()
1731 LLVMTypeRef LLVMTypeOf(LLVMValueRef Val);
1734 * Obtain the enumerated type of a Value instance.
1736 * @see llvm::Value::getValueID()
1738 LLVMValueKind LLVMGetValueKind(LLVMValueRef Val);
1741 * Obtain the string name of a value.
1743 * @see llvm::Value::getName()
1745 const char *LLVMGetValueName2(LLVMValueRef Val, size_t *Length);
1748 * Set the string name of a value.
1750 * @see llvm::Value::setName()
1752 void LLVMSetValueName2(LLVMValueRef Val, const char *Name, size_t NameLen);
1755 * Dump a representation of a value to stderr.
1757 * @see llvm::Value::dump()
1759 void LLVMDumpValue(LLVMValueRef Val);
1762 * Return a string representation of the value. Use
1763 * LLVMDisposeMessage to free the string.
1765 * @see llvm::Value::print()
1767 char *LLVMPrintValueToString(LLVMValueRef Val);
1770 * Replace all uses of a value with another one.
1772 * @see llvm::Value::replaceAllUsesWith()
1774 void LLVMReplaceAllUsesWith(LLVMValueRef OldVal, LLVMValueRef NewVal);
1777 * Determine whether the specified value instance is constant.
1779 LLVMBool LLVMIsConstant(LLVMValueRef Val);
1782 * Determine whether a value instance is undefined.
1784 LLVMBool LLVMIsUndef(LLVMValueRef Val);
1787 * Determine whether a value instance is poisonous.
1789 LLVMBool LLVMIsPoison(LLVMValueRef Val);
1792 * Convert value instances between types.
1794 * Internally, an LLVMValueRef is "pinned" to a specific type. This
1795 * series of functions allows you to cast an instance to a specific
1796 * type.
1798 * If the cast is not valid for the specified type, NULL is returned.
1800 * @see llvm::dyn_cast_or_null<>
1802 #define LLVM_DECLARE_VALUE_CAST(name) \
1803 LLVMValueRef LLVMIsA##name(LLVMValueRef Val);
1804 LLVM_FOR_EACH_VALUE_SUBCLASS(LLVM_DECLARE_VALUE_CAST)
1806 LLVMValueRef LLVMIsAMDNode(LLVMValueRef Val);
1807 LLVMValueRef LLVMIsAValueAsMetadata(LLVMValueRef Val);
1808 LLVMValueRef LLVMIsAMDString(LLVMValueRef Val);
1810 /** Deprecated: Use LLVMGetValueName2 instead. */
1811 const char *LLVMGetValueName(LLVMValueRef Val);
1812 /** Deprecated: Use LLVMSetValueName2 instead. */
1813 void LLVMSetValueName(LLVMValueRef Val, const char *Name);
1816 * @}
1820 * @defgroup LLVMCCoreValueUses Usage
1822 * This module defines functions that allow you to inspect the uses of a
1823 * LLVMValueRef.
1825 * It is possible to obtain an LLVMUseRef for any LLVMValueRef instance.
1826 * Each LLVMUseRef (which corresponds to a llvm::Use instance) holds a
1827 * llvm::User and llvm::Value.
1829 * @{
1833 * Obtain the first use of a value.
1835 * Uses are obtained in an iterator fashion. First, call this function
1836 * to obtain a reference to the first use. Then, call LLVMGetNextUse()
1837 * on that instance and all subsequently obtained instances until
1838 * LLVMGetNextUse() returns NULL.
1840 * @see llvm::Value::use_begin()
1842 LLVMUseRef LLVMGetFirstUse(LLVMValueRef Val);
1845 * Obtain the next use of a value.
1847 * This effectively advances the iterator. It returns NULL if you are on
1848 * the final use and no more are available.
1850 LLVMUseRef LLVMGetNextUse(LLVMUseRef U);
1853 * Obtain the user value for a user.
1855 * The returned value corresponds to a llvm::User type.
1857 * @see llvm::Use::getUser()
1859 LLVMValueRef LLVMGetUser(LLVMUseRef U);
1862 * Obtain the value this use corresponds to.
1864 * @see llvm::Use::get().
1866 LLVMValueRef LLVMGetUsedValue(LLVMUseRef U);
1869 * @}
1873 * @defgroup LLVMCCoreValueUser User value
1875 * Function in this group pertain to LLVMValueRef instances that descent
1876 * from llvm::User. This includes constants, instructions, and
1877 * operators.
1879 * @{
1883 * Obtain an operand at a specific index in a llvm::User value.
1885 * @see llvm::User::getOperand()
1887 LLVMValueRef LLVMGetOperand(LLVMValueRef Val, unsigned Index);
1890 * Obtain the use of an operand at a specific index in a llvm::User value.
1892 * @see llvm::User::getOperandUse()
1894 LLVMUseRef LLVMGetOperandUse(LLVMValueRef Val, unsigned Index);
1897 * Set an operand at a specific index in a llvm::User value.
1899 * @see llvm::User::setOperand()
1901 void LLVMSetOperand(LLVMValueRef User, unsigned Index, LLVMValueRef Val);
1904 * Obtain the number of operands in a llvm::User value.
1906 * @see llvm::User::getNumOperands()
1908 int LLVMGetNumOperands(LLVMValueRef Val);
1911 * @}
1915 * @defgroup LLVMCCoreValueConstant Constants
1917 * This section contains APIs for interacting with LLVMValueRef that
1918 * correspond to llvm::Constant instances.
1920 * These functions will work for any LLVMValueRef in the llvm::Constant
1921 * class hierarchy.
1923 * @{
1927 * Obtain a constant value referring to the null instance of a type.
1929 * @see llvm::Constant::getNullValue()
1931 LLVMValueRef LLVMConstNull(LLVMTypeRef Ty); /* all zeroes */
1934 * Obtain a constant value referring to the instance of a type
1935 * consisting of all ones.
1937 * This is only valid for integer types.
1939 * @see llvm::Constant::getAllOnesValue()
1941 LLVMValueRef LLVMConstAllOnes(LLVMTypeRef Ty);
1944 * Obtain a constant value referring to an undefined value of a type.
1946 * @see llvm::UndefValue::get()
1948 LLVMValueRef LLVMGetUndef(LLVMTypeRef Ty);
1951 * Obtain a constant value referring to a poison value of a type.
1953 * @see llvm::PoisonValue::get()
1955 LLVMValueRef LLVMGetPoison(LLVMTypeRef Ty);
1958 * Determine whether a value instance is null.
1960 * @see llvm::Constant::isNullValue()
1962 LLVMBool LLVMIsNull(LLVMValueRef Val);
1965 * Obtain a constant that is a constant pointer pointing to NULL for a
1966 * specified type.
1968 LLVMValueRef LLVMConstPointerNull(LLVMTypeRef Ty);
1971 * @defgroup LLVMCCoreValueConstantScalar Scalar constants
1973 * Functions in this group model LLVMValueRef instances that correspond
1974 * to constants referring to scalar types.
1976 * For integer types, the LLVMTypeRef parameter should correspond to a
1977 * llvm::IntegerType instance and the returned LLVMValueRef will
1978 * correspond to a llvm::ConstantInt.
1980 * For floating point types, the LLVMTypeRef returned corresponds to a
1981 * llvm::ConstantFP.
1983 * @{
1987 * Obtain a constant value for an integer type.
1989 * The returned value corresponds to a llvm::ConstantInt.
1991 * @see llvm::ConstantInt::get()
1993 * @param IntTy Integer type to obtain value of.
1994 * @param N The value the returned instance should refer to.
1995 * @param SignExtend Whether to sign extend the produced value.
1997 LLVMValueRef LLVMConstInt(LLVMTypeRef IntTy, unsigned long long N,
1998 LLVMBool SignExtend);
2001 * Obtain a constant value for an integer of arbitrary precision.
2003 * @see llvm::ConstantInt::get()
2005 LLVMValueRef LLVMConstIntOfArbitraryPrecision(LLVMTypeRef IntTy,
2006 unsigned NumWords,
2007 const uint64_t Words[]);
2010 * Obtain a constant value for an integer parsed from a string.
2012 * A similar API, LLVMConstIntOfStringAndSize is also available. If the
2013 * string's length is available, it is preferred to call that function
2014 * instead.
2016 * @see llvm::ConstantInt::get()
2018 LLVMValueRef LLVMConstIntOfString(LLVMTypeRef IntTy, const char *Text,
2019 uint8_t Radix);
2022 * Obtain a constant value for an integer parsed from a string with
2023 * specified length.
2025 * @see llvm::ConstantInt::get()
2027 LLVMValueRef LLVMConstIntOfStringAndSize(LLVMTypeRef IntTy, const char *Text,
2028 unsigned SLen, uint8_t Radix);
2031 * Obtain a constant value referring to a double floating point value.
2033 LLVMValueRef LLVMConstReal(LLVMTypeRef RealTy, double N);
2036 * Obtain a constant for a floating point value parsed from a string.
2038 * A similar API, LLVMConstRealOfStringAndSize is also available. It
2039 * should be used if the input string's length is known.
2041 LLVMValueRef LLVMConstRealOfString(LLVMTypeRef RealTy, const char *Text);
2044 * Obtain a constant for a floating point value parsed from a string.
2046 LLVMValueRef LLVMConstRealOfStringAndSize(LLVMTypeRef RealTy, const char *Text,
2047 unsigned SLen);
2050 * Obtain the zero extended value for an integer constant value.
2052 * @see llvm::ConstantInt::getZExtValue()
2054 unsigned long long LLVMConstIntGetZExtValue(LLVMValueRef ConstantVal);
2057 * Obtain the sign extended value for an integer constant value.
2059 * @see llvm::ConstantInt::getSExtValue()
2061 long long LLVMConstIntGetSExtValue(LLVMValueRef ConstantVal);
2064 * Obtain the double value for an floating point constant value.
2065 * losesInfo indicates if some precision was lost in the conversion.
2067 * @see llvm::ConstantFP::getDoubleValue
2069 double LLVMConstRealGetDouble(LLVMValueRef ConstantVal, LLVMBool *losesInfo);
2072 * @}
2076 * @defgroup LLVMCCoreValueConstantComposite Composite Constants
2078 * Functions in this group operate on composite constants.
2080 * @{
2084 * Create a ConstantDataSequential and initialize it with a string.
2086 * @see llvm::ConstantDataArray::getString()
2088 LLVMValueRef LLVMConstStringInContext(LLVMContextRef C, const char *Str,
2089 unsigned Length, LLVMBool DontNullTerminate);
2092 * Create a ConstantDataSequential with string content in the global context.
2094 * This is the same as LLVMConstStringInContext except it operates on the
2095 * global context.
2097 * @see LLVMConstStringInContext()
2098 * @see llvm::ConstantDataArray::getString()
2100 LLVMValueRef LLVMConstString(const char *Str, unsigned Length,
2101 LLVMBool DontNullTerminate);
2104 * Returns true if the specified constant is an array of i8.
2106 * @see ConstantDataSequential::getAsString()
2108 LLVMBool LLVMIsConstantString(LLVMValueRef c);
2111 * Get the given constant data sequential as a string.
2113 * @see ConstantDataSequential::getAsString()
2115 const char *LLVMGetAsString(LLVMValueRef c, size_t *Length);
2118 * Create an anonymous ConstantStruct with the specified values.
2120 * @see llvm::ConstantStruct::getAnon()
2122 LLVMValueRef LLVMConstStructInContext(LLVMContextRef C,
2123 LLVMValueRef *ConstantVals,
2124 unsigned Count, LLVMBool Packed);
2127 * Create a ConstantStruct in the global Context.
2129 * This is the same as LLVMConstStructInContext except it operates on the
2130 * global Context.
2132 * @see LLVMConstStructInContext()
2134 LLVMValueRef LLVMConstStruct(LLVMValueRef *ConstantVals, unsigned Count,
2135 LLVMBool Packed);
2138 * Create a ConstantArray from values.
2140 * @deprecated LLVMConstArray is deprecated in favor of the API accurate
2141 * LLVMConstArray2
2142 * @see llvm::ConstantArray::get()
2144 LLVMValueRef LLVMConstArray(LLVMTypeRef ElementTy,
2145 LLVMValueRef *ConstantVals, unsigned Length);
2148 * Create a ConstantArray from values.
2150 * @see llvm::ConstantArray::get()
2152 LLVMValueRef LLVMConstArray2(LLVMTypeRef ElementTy, LLVMValueRef *ConstantVals,
2153 uint64_t Length);
2156 * Create a non-anonymous ConstantStruct from values.
2158 * @see llvm::ConstantStruct::get()
2160 LLVMValueRef LLVMConstNamedStruct(LLVMTypeRef StructTy,
2161 LLVMValueRef *ConstantVals,
2162 unsigned Count);
2165 * Get element of a constant aggregate (struct, array or vector) at the
2166 * specified index. Returns null if the index is out of range, or it's not
2167 * possible to determine the element (e.g., because the constant is a
2168 * constant expression.)
2170 * @see llvm::Constant::getAggregateElement()
2172 LLVMValueRef LLVMGetAggregateElement(LLVMValueRef C, unsigned Idx);
2175 * Get an element at specified index as a constant.
2177 * @see ConstantDataSequential::getElementAsConstant()
2179 LLVM_ATTRIBUTE_C_DEPRECATED(
2180 LLVMValueRef LLVMGetElementAsConstant(LLVMValueRef C, unsigned idx),
2181 "Use LLVMGetAggregateElement instead");
2184 * Create a ConstantVector from values.
2186 * @see llvm::ConstantVector::get()
2188 LLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals, unsigned Size);
2191 * @}
2195 * @defgroup LLVMCCoreValueConstantExpressions Constant Expressions
2197 * Functions in this group correspond to APIs on llvm::ConstantExpr.
2199 * @see llvm::ConstantExpr.
2201 * @{
2203 LLVMOpcode LLVMGetConstOpcode(LLVMValueRef ConstantVal);
2204 LLVMValueRef LLVMAlignOf(LLVMTypeRef Ty);
2205 LLVMValueRef LLVMSizeOf(LLVMTypeRef Ty);
2206 LLVMValueRef LLVMConstNeg(LLVMValueRef ConstantVal);
2207 LLVMValueRef LLVMConstNSWNeg(LLVMValueRef ConstantVal);
2208 LLVMValueRef LLVMConstNUWNeg(LLVMValueRef ConstantVal);
2209 LLVMValueRef LLVMConstNot(LLVMValueRef ConstantVal);
2210 LLVMValueRef LLVMConstAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2211 LLVMValueRef LLVMConstNSWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2212 LLVMValueRef LLVMConstNUWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2213 LLVMValueRef LLVMConstSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2214 LLVMValueRef LLVMConstNSWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2215 LLVMValueRef LLVMConstNUWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2216 LLVMValueRef LLVMConstMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2217 LLVMValueRef LLVMConstNSWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2218 LLVMValueRef LLVMConstNUWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2219 LLVMValueRef LLVMConstAnd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2220 LLVMValueRef LLVMConstOr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2221 LLVMValueRef LLVMConstXor(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2222 LLVMValueRef LLVMConstICmp(LLVMIntPredicate Predicate,
2223 LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2224 LLVMValueRef LLVMConstFCmp(LLVMRealPredicate Predicate,
2225 LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2226 LLVMValueRef LLVMConstShl(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2227 LLVMValueRef LLVMConstLShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2228 LLVMValueRef LLVMConstAShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2229 LLVMValueRef LLVMConstGEP2(LLVMTypeRef Ty, LLVMValueRef ConstantVal,
2230 LLVMValueRef *ConstantIndices, unsigned NumIndices);
2231 LLVMValueRef LLVMConstInBoundsGEP2(LLVMTypeRef Ty, LLVMValueRef ConstantVal,
2232 LLVMValueRef *ConstantIndices,
2233 unsigned NumIndices);
2234 LLVMValueRef LLVMConstTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
2235 LLVMValueRef LLVMConstSExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
2236 LLVMValueRef LLVMConstZExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
2237 LLVMValueRef LLVMConstFPTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
2238 LLVMValueRef LLVMConstFPExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
2239 LLVMValueRef LLVMConstUIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
2240 LLVMValueRef LLVMConstSIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
2241 LLVMValueRef LLVMConstFPToUI(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
2242 LLVMValueRef LLVMConstFPToSI(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
2243 LLVMValueRef LLVMConstPtrToInt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
2244 LLVMValueRef LLVMConstIntToPtr(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
2245 LLVMValueRef LLVMConstBitCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
2246 LLVMValueRef LLVMConstAddrSpaceCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
2247 LLVMValueRef LLVMConstZExtOrBitCast(LLVMValueRef ConstantVal,
2248 LLVMTypeRef ToType);
2249 LLVMValueRef LLVMConstSExtOrBitCast(LLVMValueRef ConstantVal,
2250 LLVMTypeRef ToType);
2251 LLVMValueRef LLVMConstTruncOrBitCast(LLVMValueRef ConstantVal,
2252 LLVMTypeRef ToType);
2253 LLVMValueRef LLVMConstPointerCast(LLVMValueRef ConstantVal,
2254 LLVMTypeRef ToType);
2255 LLVMValueRef LLVMConstIntCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType,
2256 LLVMBool isSigned);
2257 LLVMValueRef LLVMConstFPCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
2258 LLVMValueRef LLVMConstExtractElement(LLVMValueRef VectorConstant,
2259 LLVMValueRef IndexConstant);
2260 LLVMValueRef LLVMConstInsertElement(LLVMValueRef VectorConstant,
2261 LLVMValueRef ElementValueConstant,
2262 LLVMValueRef IndexConstant);
2263 LLVMValueRef LLVMConstShuffleVector(LLVMValueRef VectorAConstant,
2264 LLVMValueRef VectorBConstant,
2265 LLVMValueRef MaskConstant);
2266 LLVMValueRef LLVMBlockAddress(LLVMValueRef F, LLVMBasicBlockRef BB);
2268 /** Deprecated: Use LLVMGetInlineAsm instead. */
2269 LLVMValueRef LLVMConstInlineAsm(LLVMTypeRef Ty,
2270 const char *AsmString, const char *Constraints,
2271 LLVMBool HasSideEffects, LLVMBool IsAlignStack);
2274 * @}
2278 * @defgroup LLVMCCoreValueConstantGlobals Global Values
2280 * This group contains functions that operate on global values. Functions in
2281 * this group relate to functions in the llvm::GlobalValue class tree.
2283 * @see llvm::GlobalValue
2285 * @{
2288 LLVMModuleRef LLVMGetGlobalParent(LLVMValueRef Global);
2289 LLVMBool LLVMIsDeclaration(LLVMValueRef Global);
2290 LLVMLinkage LLVMGetLinkage(LLVMValueRef Global);
2291 void LLVMSetLinkage(LLVMValueRef Global, LLVMLinkage Linkage);
2292 const char *LLVMGetSection(LLVMValueRef Global);
2293 void LLVMSetSection(LLVMValueRef Global, const char *Section);
2294 LLVMVisibility LLVMGetVisibility(LLVMValueRef Global);
2295 void LLVMSetVisibility(LLVMValueRef Global, LLVMVisibility Viz);
2296 LLVMDLLStorageClass LLVMGetDLLStorageClass(LLVMValueRef Global);
2297 void LLVMSetDLLStorageClass(LLVMValueRef Global, LLVMDLLStorageClass Class);
2298 LLVMUnnamedAddr LLVMGetUnnamedAddress(LLVMValueRef Global);
2299 void LLVMSetUnnamedAddress(LLVMValueRef Global, LLVMUnnamedAddr UnnamedAddr);
2302 * Returns the "value type" of a global value. This differs from the formal
2303 * type of a global value which is always a pointer type.
2305 * @see llvm::GlobalValue::getValueType()
2307 LLVMTypeRef LLVMGlobalGetValueType(LLVMValueRef Global);
2309 /** Deprecated: Use LLVMGetUnnamedAddress instead. */
2310 LLVMBool LLVMHasUnnamedAddr(LLVMValueRef Global);
2311 /** Deprecated: Use LLVMSetUnnamedAddress instead. */
2312 void LLVMSetUnnamedAddr(LLVMValueRef Global, LLVMBool HasUnnamedAddr);
2315 * @defgroup LLVMCCoreValueWithAlignment Values with alignment
2317 * Functions in this group only apply to values with alignment, i.e.
2318 * global variables, load and store instructions.
2322 * Obtain the preferred alignment of the value.
2323 * @see llvm::AllocaInst::getAlignment()
2324 * @see llvm::LoadInst::getAlignment()
2325 * @see llvm::StoreInst::getAlignment()
2326 * @see llvm::AtomicRMWInst::setAlignment()
2327 * @see llvm::AtomicCmpXchgInst::setAlignment()
2328 * @see llvm::GlobalValue::getAlignment()
2330 unsigned LLVMGetAlignment(LLVMValueRef V);
2333 * Set the preferred alignment of the value.
2334 * @see llvm::AllocaInst::setAlignment()
2335 * @see llvm::LoadInst::setAlignment()
2336 * @see llvm::StoreInst::setAlignment()
2337 * @see llvm::AtomicRMWInst::setAlignment()
2338 * @see llvm::AtomicCmpXchgInst::setAlignment()
2339 * @see llvm::GlobalValue::setAlignment()
2341 void LLVMSetAlignment(LLVMValueRef V, unsigned Bytes);
2344 * Sets a metadata attachment, erasing the existing metadata attachment if
2345 * it already exists for the given kind.
2347 * @see llvm::GlobalObject::setMetadata()
2349 void LLVMGlobalSetMetadata(LLVMValueRef Global, unsigned Kind,
2350 LLVMMetadataRef MD);
2353 * Erases a metadata attachment of the given kind if it exists.
2355 * @see llvm::GlobalObject::eraseMetadata()
2357 void LLVMGlobalEraseMetadata(LLVMValueRef Global, unsigned Kind);
2360 * Removes all metadata attachments from this value.
2362 * @see llvm::GlobalObject::clearMetadata()
2364 void LLVMGlobalClearMetadata(LLVMValueRef Global);
2367 * Retrieves an array of metadata entries representing the metadata attached to
2368 * this value. The caller is responsible for freeing this array by calling
2369 * \c LLVMDisposeValueMetadataEntries.
2371 * @see llvm::GlobalObject::getAllMetadata()
2373 LLVMValueMetadataEntry *LLVMGlobalCopyAllMetadata(LLVMValueRef Value,
2374 size_t *NumEntries);
2377 * Destroys value metadata entries.
2379 void LLVMDisposeValueMetadataEntries(LLVMValueMetadataEntry *Entries);
2382 * Returns the kind of a value metadata entry at a specific index.
2384 unsigned LLVMValueMetadataEntriesGetKind(LLVMValueMetadataEntry *Entries,
2385 unsigned Index);
2388 * Returns the underlying metadata node of a value metadata entry at a
2389 * specific index.
2391 LLVMMetadataRef
2392 LLVMValueMetadataEntriesGetMetadata(LLVMValueMetadataEntry *Entries,
2393 unsigned Index);
2396 * @}
2400 * @defgroup LLVMCoreValueConstantGlobalVariable Global Variables
2402 * This group contains functions that operate on global variable values.
2404 * @see llvm::GlobalVariable
2406 * @{
2408 LLVMValueRef LLVMAddGlobal(LLVMModuleRef M, LLVMTypeRef Ty, const char *Name);
2409 LLVMValueRef LLVMAddGlobalInAddressSpace(LLVMModuleRef M, LLVMTypeRef Ty,
2410 const char *Name,
2411 unsigned AddressSpace);
2412 LLVMValueRef LLVMGetNamedGlobal(LLVMModuleRef M, const char *Name);
2413 LLVMValueRef LLVMGetFirstGlobal(LLVMModuleRef M);
2414 LLVMValueRef LLVMGetLastGlobal(LLVMModuleRef M);
2415 LLVMValueRef LLVMGetNextGlobal(LLVMValueRef GlobalVar);
2416 LLVMValueRef LLVMGetPreviousGlobal(LLVMValueRef GlobalVar);
2417 void LLVMDeleteGlobal(LLVMValueRef GlobalVar);
2418 LLVMValueRef LLVMGetInitializer(LLVMValueRef GlobalVar);
2419 void LLVMSetInitializer(LLVMValueRef GlobalVar, LLVMValueRef ConstantVal);
2420 LLVMBool LLVMIsThreadLocal(LLVMValueRef GlobalVar);
2421 void LLVMSetThreadLocal(LLVMValueRef GlobalVar, LLVMBool IsThreadLocal);
2422 LLVMBool LLVMIsGlobalConstant(LLVMValueRef GlobalVar);
2423 void LLVMSetGlobalConstant(LLVMValueRef GlobalVar, LLVMBool IsConstant);
2424 LLVMThreadLocalMode LLVMGetThreadLocalMode(LLVMValueRef GlobalVar);
2425 void LLVMSetThreadLocalMode(LLVMValueRef GlobalVar, LLVMThreadLocalMode Mode);
2426 LLVMBool LLVMIsExternallyInitialized(LLVMValueRef GlobalVar);
2427 void LLVMSetExternallyInitialized(LLVMValueRef GlobalVar, LLVMBool IsExtInit);
2430 * @}
2434 * @defgroup LLVMCoreValueConstantGlobalAlias Global Aliases
2436 * This group contains function that operate on global alias values.
2438 * @see llvm::GlobalAlias
2440 * @{
2444 * Add a GlobalAlias with the given value type, address space and aliasee.
2446 * @see llvm::GlobalAlias::create()
2448 LLVMValueRef LLVMAddAlias2(LLVMModuleRef M, LLVMTypeRef ValueTy,
2449 unsigned AddrSpace, LLVMValueRef Aliasee,
2450 const char *Name);
2453 * Obtain a GlobalAlias value from a Module by its name.
2455 * The returned value corresponds to a llvm::GlobalAlias value.
2457 * @see llvm::Module::getNamedAlias()
2459 LLVMValueRef LLVMGetNamedGlobalAlias(LLVMModuleRef M,
2460 const char *Name, size_t NameLen);
2463 * Obtain an iterator to the first GlobalAlias in a Module.
2465 * @see llvm::Module::alias_begin()
2467 LLVMValueRef LLVMGetFirstGlobalAlias(LLVMModuleRef M);
2470 * Obtain an iterator to the last GlobalAlias in a Module.
2472 * @see llvm::Module::alias_end()
2474 LLVMValueRef LLVMGetLastGlobalAlias(LLVMModuleRef M);
2477 * Advance a GlobalAlias iterator to the next GlobalAlias.
2479 * Returns NULL if the iterator was already at the end and there are no more
2480 * global aliases.
2482 LLVMValueRef LLVMGetNextGlobalAlias(LLVMValueRef GA);
2485 * Decrement a GlobalAlias iterator to the previous GlobalAlias.
2487 * Returns NULL if the iterator was already at the beginning and there are
2488 * no previous global aliases.
2490 LLVMValueRef LLVMGetPreviousGlobalAlias(LLVMValueRef GA);
2493 * Retrieve the target value of an alias.
2495 LLVMValueRef LLVMAliasGetAliasee(LLVMValueRef Alias);
2498 * Set the target value of an alias.
2500 void LLVMAliasSetAliasee(LLVMValueRef Alias, LLVMValueRef Aliasee);
2503 * @}
2507 * @defgroup LLVMCCoreValueFunction Function values
2509 * Functions in this group operate on LLVMValueRef instances that
2510 * correspond to llvm::Function instances.
2512 * @see llvm::Function
2514 * @{
2518 * Remove a function from its containing module and deletes it.
2520 * @see llvm::Function::eraseFromParent()
2522 void LLVMDeleteFunction(LLVMValueRef Fn);
2525 * Check whether the given function has a personality function.
2527 * @see llvm::Function::hasPersonalityFn()
2529 LLVMBool LLVMHasPersonalityFn(LLVMValueRef Fn);
2532 * Obtain the personality function attached to the function.
2534 * @see llvm::Function::getPersonalityFn()
2536 LLVMValueRef LLVMGetPersonalityFn(LLVMValueRef Fn);
2539 * Set the personality function attached to the function.
2541 * @see llvm::Function::setPersonalityFn()
2543 void LLVMSetPersonalityFn(LLVMValueRef Fn, LLVMValueRef PersonalityFn);
2546 * Obtain the intrinsic ID number which matches the given function name.
2548 * @see llvm::Function::lookupIntrinsicID()
2550 unsigned LLVMLookupIntrinsicID(const char *Name, size_t NameLen);
2553 * Obtain the ID number from a function instance.
2555 * @see llvm::Function::getIntrinsicID()
2557 unsigned LLVMGetIntrinsicID(LLVMValueRef Fn);
2560 * Create or insert the declaration of an intrinsic. For overloaded intrinsics,
2561 * parameter types must be provided to uniquely identify an overload.
2563 * @see llvm::Intrinsic::getDeclaration()
2565 LLVMValueRef LLVMGetIntrinsicDeclaration(LLVMModuleRef Mod,
2566 unsigned ID,
2567 LLVMTypeRef *ParamTypes,
2568 size_t ParamCount);
2571 * Retrieves the type of an intrinsic. For overloaded intrinsics, parameter
2572 * types must be provided to uniquely identify an overload.
2574 * @see llvm::Intrinsic::getType()
2576 LLVMTypeRef LLVMIntrinsicGetType(LLVMContextRef Ctx, unsigned ID,
2577 LLVMTypeRef *ParamTypes, size_t ParamCount);
2580 * Retrieves the name of an intrinsic.
2582 * @see llvm::Intrinsic::getName()
2584 const char *LLVMIntrinsicGetName(unsigned ID, size_t *NameLength);
2586 /** Deprecated: Use LLVMIntrinsicCopyOverloadedName2 instead. */
2587 const char *LLVMIntrinsicCopyOverloadedName(unsigned ID,
2588 LLVMTypeRef *ParamTypes,
2589 size_t ParamCount,
2590 size_t *NameLength);
2593 * Copies the name of an overloaded intrinsic identified by a given list of
2594 * parameter types.
2596 * Unlike LLVMIntrinsicGetName, the caller is responsible for freeing the
2597 * returned string.
2599 * This version also supports unnamed types.
2601 * @see llvm::Intrinsic::getName()
2603 const char *LLVMIntrinsicCopyOverloadedName2(LLVMModuleRef Mod, unsigned ID,
2604 LLVMTypeRef *ParamTypes,
2605 size_t ParamCount,
2606 size_t *NameLength);
2609 * Obtain if the intrinsic identified by the given ID is overloaded.
2611 * @see llvm::Intrinsic::isOverloaded()
2613 LLVMBool LLVMIntrinsicIsOverloaded(unsigned ID);
2616 * Obtain the calling function of a function.
2618 * The returned value corresponds to the LLVMCallConv enumeration.
2620 * @see llvm::Function::getCallingConv()
2622 unsigned LLVMGetFunctionCallConv(LLVMValueRef Fn);
2625 * Set the calling convention of a function.
2627 * @see llvm::Function::setCallingConv()
2629 * @param Fn Function to operate on
2630 * @param CC LLVMCallConv to set calling convention to
2632 void LLVMSetFunctionCallConv(LLVMValueRef Fn, unsigned CC);
2635 * Obtain the name of the garbage collector to use during code
2636 * generation.
2638 * @see llvm::Function::getGC()
2640 const char *LLVMGetGC(LLVMValueRef Fn);
2643 * Define the garbage collector to use during code generation.
2645 * @see llvm::Function::setGC()
2647 void LLVMSetGC(LLVMValueRef Fn, const char *Name);
2650 * Add an attribute to a function.
2652 * @see llvm::Function::addAttribute()
2654 void LLVMAddAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx,
2655 LLVMAttributeRef A);
2656 unsigned LLVMGetAttributeCountAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx);
2657 void LLVMGetAttributesAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx,
2658 LLVMAttributeRef *Attrs);
2659 LLVMAttributeRef LLVMGetEnumAttributeAtIndex(LLVMValueRef F,
2660 LLVMAttributeIndex Idx,
2661 unsigned KindID);
2662 LLVMAttributeRef LLVMGetStringAttributeAtIndex(LLVMValueRef F,
2663 LLVMAttributeIndex Idx,
2664 const char *K, unsigned KLen);
2665 void LLVMRemoveEnumAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx,
2666 unsigned KindID);
2667 void LLVMRemoveStringAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx,
2668 const char *K, unsigned KLen);
2671 * Add a target-dependent attribute to a function
2672 * @see llvm::AttrBuilder::addAttribute()
2674 void LLVMAddTargetDependentFunctionAttr(LLVMValueRef Fn, const char *A,
2675 const char *V);
2678 * @defgroup LLVMCCoreValueFunctionParameters Function Parameters
2680 * Functions in this group relate to arguments/parameters on functions.
2682 * Functions in this group expect LLVMValueRef instances that correspond
2683 * to llvm::Function instances.
2685 * @{
2689 * Obtain the number of parameters in a function.
2691 * @see llvm::Function::arg_size()
2693 unsigned LLVMCountParams(LLVMValueRef Fn);
2696 * Obtain the parameters in a function.
2698 * The takes a pointer to a pre-allocated array of LLVMValueRef that is
2699 * at least LLVMCountParams() long. This array will be filled with
2700 * LLVMValueRef instances which correspond to the parameters the
2701 * function receives. Each LLVMValueRef corresponds to a llvm::Argument
2702 * instance.
2704 * @see llvm::Function::arg_begin()
2706 void LLVMGetParams(LLVMValueRef Fn, LLVMValueRef *Params);
2709 * Obtain the parameter at the specified index.
2711 * Parameters are indexed from 0.
2713 * @see llvm::Function::arg_begin()
2715 LLVMValueRef LLVMGetParam(LLVMValueRef Fn, unsigned Index);
2718 * Obtain the function to which this argument belongs.
2720 * Unlike other functions in this group, this one takes an LLVMValueRef
2721 * that corresponds to a llvm::Attribute.
2723 * The returned LLVMValueRef is the llvm::Function to which this
2724 * argument belongs.
2726 LLVMValueRef LLVMGetParamParent(LLVMValueRef Inst);
2729 * Obtain the first parameter to a function.
2731 * @see llvm::Function::arg_begin()
2733 LLVMValueRef LLVMGetFirstParam(LLVMValueRef Fn);
2736 * Obtain the last parameter to a function.
2738 * @see llvm::Function::arg_end()
2740 LLVMValueRef LLVMGetLastParam(LLVMValueRef Fn);
2743 * Obtain the next parameter to a function.
2745 * This takes an LLVMValueRef obtained from LLVMGetFirstParam() (which is
2746 * actually a wrapped iterator) and obtains the next parameter from the
2747 * underlying iterator.
2749 LLVMValueRef LLVMGetNextParam(LLVMValueRef Arg);
2752 * Obtain the previous parameter to a function.
2754 * This is the opposite of LLVMGetNextParam().
2756 LLVMValueRef LLVMGetPreviousParam(LLVMValueRef Arg);
2759 * Set the alignment for a function parameter.
2761 * @see llvm::Argument::addAttr()
2762 * @see llvm::AttrBuilder::addAlignmentAttr()
2764 void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned Align);
2767 * @}
2771 * @defgroup LLVMCCoreValueGlobalIFunc IFuncs
2773 * Functions in this group relate to indirect functions.
2775 * Functions in this group expect LLVMValueRef instances that correspond
2776 * to llvm::GlobalIFunc instances.
2778 * @{
2782 * Add a global indirect function to a module under a specified name.
2784 * @see llvm::GlobalIFunc::create()
2786 LLVMValueRef LLVMAddGlobalIFunc(LLVMModuleRef M,
2787 const char *Name, size_t NameLen,
2788 LLVMTypeRef Ty, unsigned AddrSpace,
2789 LLVMValueRef Resolver);
2792 * Obtain a GlobalIFunc value from a Module by its name.
2794 * The returned value corresponds to a llvm::GlobalIFunc value.
2796 * @see llvm::Module::getNamedIFunc()
2798 LLVMValueRef LLVMGetNamedGlobalIFunc(LLVMModuleRef M,
2799 const char *Name, size_t NameLen);
2802 * Obtain an iterator to the first GlobalIFunc in a Module.
2804 * @see llvm::Module::ifunc_begin()
2806 LLVMValueRef LLVMGetFirstGlobalIFunc(LLVMModuleRef M);
2809 * Obtain an iterator to the last GlobalIFunc in a Module.
2811 * @see llvm::Module::ifunc_end()
2813 LLVMValueRef LLVMGetLastGlobalIFunc(LLVMModuleRef M);
2816 * Advance a GlobalIFunc iterator to the next GlobalIFunc.
2818 * Returns NULL if the iterator was already at the end and there are no more
2819 * global aliases.
2821 LLVMValueRef LLVMGetNextGlobalIFunc(LLVMValueRef IFunc);
2824 * Decrement a GlobalIFunc iterator to the previous GlobalIFunc.
2826 * Returns NULL if the iterator was already at the beginning and there are
2827 * no previous global aliases.
2829 LLVMValueRef LLVMGetPreviousGlobalIFunc(LLVMValueRef IFunc);
2832 * Retrieves the resolver function associated with this indirect function, or
2833 * NULL if it doesn't not exist.
2835 * @see llvm::GlobalIFunc::getResolver()
2837 LLVMValueRef LLVMGetGlobalIFuncResolver(LLVMValueRef IFunc);
2840 * Sets the resolver function associated with this indirect function.
2842 * @see llvm::GlobalIFunc::setResolver()
2844 void LLVMSetGlobalIFuncResolver(LLVMValueRef IFunc, LLVMValueRef Resolver);
2847 * Remove a global indirect function from its parent module and delete it.
2849 * @see llvm::GlobalIFunc::eraseFromParent()
2851 void LLVMEraseGlobalIFunc(LLVMValueRef IFunc);
2854 * Remove a global indirect function from its parent module.
2856 * This unlinks the global indirect function from its containing module but
2857 * keeps it alive.
2859 * @see llvm::GlobalIFunc::removeFromParent()
2861 void LLVMRemoveGlobalIFunc(LLVMValueRef IFunc);
2864 * @}
2868 * @}
2872 * @}
2876 * @}
2880 * @defgroup LLVMCCoreValueMetadata Metadata
2882 * @{
2886 * Create an MDString value from a given string value.
2888 * The MDString value does not take ownership of the given string, it remains
2889 * the responsibility of the caller to free it.
2891 * @see llvm::MDString::get()
2893 LLVMMetadataRef LLVMMDStringInContext2(LLVMContextRef C, const char *Str,
2894 size_t SLen);
2897 * Create an MDNode value with the given array of operands.
2899 * @see llvm::MDNode::get()
2901 LLVMMetadataRef LLVMMDNodeInContext2(LLVMContextRef C, LLVMMetadataRef *MDs,
2902 size_t Count);
2905 * Obtain a Metadata as a Value.
2907 LLVMValueRef LLVMMetadataAsValue(LLVMContextRef C, LLVMMetadataRef MD);
2910 * Obtain a Value as a Metadata.
2912 LLVMMetadataRef LLVMValueAsMetadata(LLVMValueRef Val);
2915 * Obtain the underlying string from a MDString value.
2917 * @param V Instance to obtain string from.
2918 * @param Length Memory address which will hold length of returned string.
2919 * @return String data in MDString.
2921 const char *LLVMGetMDString(LLVMValueRef V, unsigned *Length);
2924 * Obtain the number of operands from an MDNode value.
2926 * @param V MDNode to get number of operands from.
2927 * @return Number of operands of the MDNode.
2929 unsigned LLVMGetMDNodeNumOperands(LLVMValueRef V);
2932 * Obtain the given MDNode's operands.
2934 * The passed LLVMValueRef pointer should point to enough memory to hold all of
2935 * the operands of the given MDNode (see LLVMGetMDNodeNumOperands) as
2936 * LLVMValueRefs. This memory will be populated with the LLVMValueRefs of the
2937 * MDNode's operands.
2939 * @param V MDNode to get the operands from.
2940 * @param Dest Destination array for operands.
2942 void LLVMGetMDNodeOperands(LLVMValueRef V, LLVMValueRef *Dest);
2945 * Replace an operand at a specific index in a llvm::MDNode value.
2947 * @see llvm::MDNode::replaceOperandWith()
2949 void LLVMReplaceMDNodeOperandWith(LLVMValueRef V, unsigned Index,
2950 LLVMMetadataRef Replacement);
2952 /** Deprecated: Use LLVMMDStringInContext2 instead. */
2953 LLVMValueRef LLVMMDStringInContext(LLVMContextRef C, const char *Str,
2954 unsigned SLen);
2955 /** Deprecated: Use LLVMMDStringInContext2 instead. */
2956 LLVMValueRef LLVMMDString(const char *Str, unsigned SLen);
2957 /** Deprecated: Use LLVMMDNodeInContext2 instead. */
2958 LLVMValueRef LLVMMDNodeInContext(LLVMContextRef C, LLVMValueRef *Vals,
2959 unsigned Count);
2960 /** Deprecated: Use LLVMMDNodeInContext2 instead. */
2961 LLVMValueRef LLVMMDNode(LLVMValueRef *Vals, unsigned Count);
2964 * @}
2968 * @defgroup LLVMCCoreValueBasicBlock Basic Block
2970 * A basic block represents a single entry single exit section of code.
2971 * Basic blocks contain a list of instructions which form the body of
2972 * the block.
2974 * Basic blocks belong to functions. They have the type of label.
2976 * Basic blocks are themselves values. However, the C API models them as
2977 * LLVMBasicBlockRef.
2979 * @see llvm::BasicBlock
2981 * @{
2985 * Convert a basic block instance to a value type.
2987 LLVMValueRef LLVMBasicBlockAsValue(LLVMBasicBlockRef BB);
2990 * Determine whether an LLVMValueRef is itself a basic block.
2992 LLVMBool LLVMValueIsBasicBlock(LLVMValueRef Val);
2995 * Convert an LLVMValueRef to an LLVMBasicBlockRef instance.
2997 LLVMBasicBlockRef LLVMValueAsBasicBlock(LLVMValueRef Val);
3000 * Obtain the string name of a basic block.
3002 const char *LLVMGetBasicBlockName(LLVMBasicBlockRef BB);
3005 * Obtain the function to which a basic block belongs.
3007 * @see llvm::BasicBlock::getParent()
3009 LLVMValueRef LLVMGetBasicBlockParent(LLVMBasicBlockRef BB);
3012 * Obtain the terminator instruction for a basic block.
3014 * If the basic block does not have a terminator (it is not well-formed
3015 * if it doesn't), then NULL is returned.
3017 * The returned LLVMValueRef corresponds to an llvm::Instruction.
3019 * @see llvm::BasicBlock::getTerminator()
3021 LLVMValueRef LLVMGetBasicBlockTerminator(LLVMBasicBlockRef BB);
3024 * Obtain the number of basic blocks in a function.
3026 * @param Fn Function value to operate on.
3028 unsigned LLVMCountBasicBlocks(LLVMValueRef Fn);
3031 * Obtain all of the basic blocks in a function.
3033 * This operates on a function value. The BasicBlocks parameter is a
3034 * pointer to a pre-allocated array of LLVMBasicBlockRef of at least
3035 * LLVMCountBasicBlocks() in length. This array is populated with
3036 * LLVMBasicBlockRef instances.
3038 void LLVMGetBasicBlocks(LLVMValueRef Fn, LLVMBasicBlockRef *BasicBlocks);
3041 * Obtain the first basic block in a function.
3043 * The returned basic block can be used as an iterator. You will likely
3044 * eventually call into LLVMGetNextBasicBlock() with it.
3046 * @see llvm::Function::begin()
3048 LLVMBasicBlockRef LLVMGetFirstBasicBlock(LLVMValueRef Fn);
3051 * Obtain the last basic block in a function.
3053 * @see llvm::Function::end()
3055 LLVMBasicBlockRef LLVMGetLastBasicBlock(LLVMValueRef Fn);
3058 * Advance a basic block iterator.
3060 LLVMBasicBlockRef LLVMGetNextBasicBlock(LLVMBasicBlockRef BB);
3063 * Go backwards in a basic block iterator.
3065 LLVMBasicBlockRef LLVMGetPreviousBasicBlock(LLVMBasicBlockRef BB);
3068 * Obtain the basic block that corresponds to the entry point of a
3069 * function.
3071 * @see llvm::Function::getEntryBlock()
3073 LLVMBasicBlockRef LLVMGetEntryBasicBlock(LLVMValueRef Fn);
3076 * Insert the given basic block after the insertion point of the given builder.
3078 * The insertion point must be valid.
3080 * @see llvm::Function::BasicBlockListType::insertAfter()
3082 void LLVMInsertExistingBasicBlockAfterInsertBlock(LLVMBuilderRef Builder,
3083 LLVMBasicBlockRef BB);
3086 * Append the given basic block to the basic block list of the given function.
3088 * @see llvm::Function::BasicBlockListType::push_back()
3090 void LLVMAppendExistingBasicBlock(LLVMValueRef Fn,
3091 LLVMBasicBlockRef BB);
3094 * Create a new basic block without inserting it into a function.
3096 * @see llvm::BasicBlock::Create()
3098 LLVMBasicBlockRef LLVMCreateBasicBlockInContext(LLVMContextRef C,
3099 const char *Name);
3102 * Append a basic block to the end of a function.
3104 * @see llvm::BasicBlock::Create()
3106 LLVMBasicBlockRef LLVMAppendBasicBlockInContext(LLVMContextRef C,
3107 LLVMValueRef Fn,
3108 const char *Name);
3111 * Append a basic block to the end of a function using the global
3112 * context.
3114 * @see llvm::BasicBlock::Create()
3116 LLVMBasicBlockRef LLVMAppendBasicBlock(LLVMValueRef Fn, const char *Name);
3119 * Insert a basic block in a function before another basic block.
3121 * The function to add to is determined by the function of the
3122 * passed basic block.
3124 * @see llvm::BasicBlock::Create()
3126 LLVMBasicBlockRef LLVMInsertBasicBlockInContext(LLVMContextRef C,
3127 LLVMBasicBlockRef BB,
3128 const char *Name);
3131 * Insert a basic block in a function using the global context.
3133 * @see llvm::BasicBlock::Create()
3135 LLVMBasicBlockRef LLVMInsertBasicBlock(LLVMBasicBlockRef InsertBeforeBB,
3136 const char *Name);
3139 * Remove a basic block from a function and delete it.
3141 * This deletes the basic block from its containing function and deletes
3142 * the basic block itself.
3144 * @see llvm::BasicBlock::eraseFromParent()
3146 void LLVMDeleteBasicBlock(LLVMBasicBlockRef BB);
3149 * Remove a basic block from a function.
3151 * This deletes the basic block from its containing function but keep
3152 * the basic block alive.
3154 * @see llvm::BasicBlock::removeFromParent()
3156 void LLVMRemoveBasicBlockFromParent(LLVMBasicBlockRef BB);
3159 * Move a basic block to before another one.
3161 * @see llvm::BasicBlock::moveBefore()
3163 void LLVMMoveBasicBlockBefore(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos);
3166 * Move a basic block to after another one.
3168 * @see llvm::BasicBlock::moveAfter()
3170 void LLVMMoveBasicBlockAfter(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos);
3173 * Obtain the first instruction in a basic block.
3175 * The returned LLVMValueRef corresponds to a llvm::Instruction
3176 * instance.
3178 LLVMValueRef LLVMGetFirstInstruction(LLVMBasicBlockRef BB);
3181 * Obtain the last instruction in a basic block.
3183 * The returned LLVMValueRef corresponds to an LLVM:Instruction.
3185 LLVMValueRef LLVMGetLastInstruction(LLVMBasicBlockRef BB);
3188 * @}
3192 * @defgroup LLVMCCoreValueInstruction Instructions
3194 * Functions in this group relate to the inspection and manipulation of
3195 * individual instructions.
3197 * In the C++ API, an instruction is modeled by llvm::Instruction. This
3198 * class has a large number of descendents. llvm::Instruction is a
3199 * llvm::Value and in the C API, instructions are modeled by
3200 * LLVMValueRef.
3202 * This group also contains sub-groups which operate on specific
3203 * llvm::Instruction types, e.g. llvm::CallInst.
3205 * @{
3209 * Determine whether an instruction has any metadata attached.
3211 int LLVMHasMetadata(LLVMValueRef Val);
3214 * Return metadata associated with an instruction value.
3216 LLVMValueRef LLVMGetMetadata(LLVMValueRef Val, unsigned KindID);
3219 * Set metadata associated with an instruction value.
3221 void LLVMSetMetadata(LLVMValueRef Val, unsigned KindID, LLVMValueRef Node);
3224 * Returns the metadata associated with an instruction value, but filters out
3225 * all the debug locations.
3227 * @see llvm::Instruction::getAllMetadataOtherThanDebugLoc()
3229 LLVMValueMetadataEntry *
3230 LLVMInstructionGetAllMetadataOtherThanDebugLoc(LLVMValueRef Instr,
3231 size_t *NumEntries);
3234 * Obtain the basic block to which an instruction belongs.
3236 * @see llvm::Instruction::getParent()
3238 LLVMBasicBlockRef LLVMGetInstructionParent(LLVMValueRef Inst);
3241 * Obtain the instruction that occurs after the one specified.
3243 * The next instruction will be from the same basic block.
3245 * If this is the last instruction in a basic block, NULL will be
3246 * returned.
3248 LLVMValueRef LLVMGetNextInstruction(LLVMValueRef Inst);
3251 * Obtain the instruction that occurred before this one.
3253 * If the instruction is the first instruction in a basic block, NULL
3254 * will be returned.
3256 LLVMValueRef LLVMGetPreviousInstruction(LLVMValueRef Inst);
3259 * Remove an instruction.
3261 * The instruction specified is removed from its containing building
3262 * block but is kept alive.
3264 * @see llvm::Instruction::removeFromParent()
3266 void LLVMInstructionRemoveFromParent(LLVMValueRef Inst);
3269 * Remove and delete an instruction.
3271 * The instruction specified is removed from its containing building
3272 * block and then deleted.
3274 * @see llvm::Instruction::eraseFromParent()
3276 void LLVMInstructionEraseFromParent(LLVMValueRef Inst);
3279 * Delete an instruction.
3281 * The instruction specified is deleted. It must have previously been
3282 * removed from its containing building block.
3284 * @see llvm::Value::deleteValue()
3286 void LLVMDeleteInstruction(LLVMValueRef Inst);
3289 * Obtain the code opcode for an individual instruction.
3291 * @see llvm::Instruction::getOpCode()
3293 LLVMOpcode LLVMGetInstructionOpcode(LLVMValueRef Inst);
3296 * Obtain the predicate of an instruction.
3298 * This is only valid for instructions that correspond to llvm::ICmpInst
3299 * or llvm::ConstantExpr whose opcode is llvm::Instruction::ICmp.
3301 * @see llvm::ICmpInst::getPredicate()
3303 LLVMIntPredicate LLVMGetICmpPredicate(LLVMValueRef Inst);
3306 * Obtain the float predicate of an instruction.
3308 * This is only valid for instructions that correspond to llvm::FCmpInst
3309 * or llvm::ConstantExpr whose opcode is llvm::Instruction::FCmp.
3311 * @see llvm::FCmpInst::getPredicate()
3313 LLVMRealPredicate LLVMGetFCmpPredicate(LLVMValueRef Inst);
3316 * Create a copy of 'this' instruction that is identical in all ways
3317 * except the following:
3318 * * The instruction has no parent
3319 * * The instruction has no name
3321 * @see llvm::Instruction::clone()
3323 LLVMValueRef LLVMInstructionClone(LLVMValueRef Inst);
3326 * Determine whether an instruction is a terminator. This routine is named to
3327 * be compatible with historical functions that did this by querying the
3328 * underlying C++ type.
3330 * @see llvm::Instruction::isTerminator()
3332 LLVMValueRef LLVMIsATerminatorInst(LLVMValueRef Inst);
3335 * @defgroup LLVMCCoreValueInstructionCall Call Sites and Invocations
3337 * Functions in this group apply to instructions that refer to call
3338 * sites and invocations. These correspond to C++ types in the
3339 * llvm::CallInst class tree.
3341 * @{
3345 * Obtain the argument count for a call instruction.
3347 * This expects an LLVMValueRef that corresponds to a llvm::CallInst,
3348 * llvm::InvokeInst, or llvm:FuncletPadInst.
3350 * @see llvm::CallInst::getNumArgOperands()
3351 * @see llvm::InvokeInst::getNumArgOperands()
3352 * @see llvm::FuncletPadInst::getNumArgOperands()
3354 unsigned LLVMGetNumArgOperands(LLVMValueRef Instr);
3357 * Set the calling convention for a call instruction.
3359 * This expects an LLVMValueRef that corresponds to a llvm::CallInst or
3360 * llvm::InvokeInst.
3362 * @see llvm::CallInst::setCallingConv()
3363 * @see llvm::InvokeInst::setCallingConv()
3365 void LLVMSetInstructionCallConv(LLVMValueRef Instr, unsigned CC);
3368 * Obtain the calling convention for a call instruction.
3370 * This is the opposite of LLVMSetInstructionCallConv(). Reads its
3371 * usage.
3373 * @see LLVMSetInstructionCallConv()
3375 unsigned LLVMGetInstructionCallConv(LLVMValueRef Instr);
3377 void LLVMSetInstrParamAlignment(LLVMValueRef Instr, LLVMAttributeIndex Idx,
3378 unsigned Align);
3380 void LLVMAddCallSiteAttribute(LLVMValueRef C, LLVMAttributeIndex Idx,
3381 LLVMAttributeRef A);
3382 unsigned LLVMGetCallSiteAttributeCount(LLVMValueRef C, LLVMAttributeIndex Idx);
3383 void LLVMGetCallSiteAttributes(LLVMValueRef C, LLVMAttributeIndex Idx,
3384 LLVMAttributeRef *Attrs);
3385 LLVMAttributeRef LLVMGetCallSiteEnumAttribute(LLVMValueRef C,
3386 LLVMAttributeIndex Idx,
3387 unsigned KindID);
3388 LLVMAttributeRef LLVMGetCallSiteStringAttribute(LLVMValueRef C,
3389 LLVMAttributeIndex Idx,
3390 const char *K, unsigned KLen);
3391 void LLVMRemoveCallSiteEnumAttribute(LLVMValueRef C, LLVMAttributeIndex Idx,
3392 unsigned KindID);
3393 void LLVMRemoveCallSiteStringAttribute(LLVMValueRef C, LLVMAttributeIndex Idx,
3394 const char *K, unsigned KLen);
3397 * Obtain the function type called by this instruction.
3399 * @see llvm::CallBase::getFunctionType()
3401 LLVMTypeRef LLVMGetCalledFunctionType(LLVMValueRef C);
3404 * Obtain the pointer to the function invoked by this instruction.
3406 * This expects an LLVMValueRef that corresponds to a llvm::CallInst or
3407 * llvm::InvokeInst.
3409 * @see llvm::CallInst::getCalledOperand()
3410 * @see llvm::InvokeInst::getCalledOperand()
3412 LLVMValueRef LLVMGetCalledValue(LLVMValueRef Instr);
3415 * Obtain whether a call instruction is a tail call.
3417 * This only works on llvm::CallInst instructions.
3419 * @see llvm::CallInst::isTailCall()
3421 LLVMBool LLVMIsTailCall(LLVMValueRef CallInst);
3424 * Set whether a call instruction is a tail call.
3426 * This only works on llvm::CallInst instructions.
3428 * @see llvm::CallInst::setTailCall()
3430 void LLVMSetTailCall(LLVMValueRef CallInst, LLVMBool IsTailCall);
3433 * Return the normal destination basic block.
3435 * This only works on llvm::InvokeInst instructions.
3437 * @see llvm::InvokeInst::getNormalDest()
3439 LLVMBasicBlockRef LLVMGetNormalDest(LLVMValueRef InvokeInst);
3442 * Return the unwind destination basic block.
3444 * Works on llvm::InvokeInst, llvm::CleanupReturnInst, and
3445 * llvm::CatchSwitchInst instructions.
3447 * @see llvm::InvokeInst::getUnwindDest()
3448 * @see llvm::CleanupReturnInst::getUnwindDest()
3449 * @see llvm::CatchSwitchInst::getUnwindDest()
3451 LLVMBasicBlockRef LLVMGetUnwindDest(LLVMValueRef InvokeInst);
3454 * Set the normal destination basic block.
3456 * This only works on llvm::InvokeInst instructions.
3458 * @see llvm::InvokeInst::setNormalDest()
3460 void LLVMSetNormalDest(LLVMValueRef InvokeInst, LLVMBasicBlockRef B);
3463 * Set the unwind destination basic block.
3465 * Works on llvm::InvokeInst, llvm::CleanupReturnInst, and
3466 * llvm::CatchSwitchInst instructions.
3468 * @see llvm::InvokeInst::setUnwindDest()
3469 * @see llvm::CleanupReturnInst::setUnwindDest()
3470 * @see llvm::CatchSwitchInst::setUnwindDest()
3472 void LLVMSetUnwindDest(LLVMValueRef InvokeInst, LLVMBasicBlockRef B);
3475 * @}
3479 * @defgroup LLVMCCoreValueInstructionTerminator Terminators
3481 * Functions in this group only apply to instructions for which
3482 * LLVMIsATerminatorInst returns true.
3484 * @{
3488 * Return the number of successors that this terminator has.
3490 * @see llvm::Instruction::getNumSuccessors
3492 unsigned LLVMGetNumSuccessors(LLVMValueRef Term);
3495 * Return the specified successor.
3497 * @see llvm::Instruction::getSuccessor
3499 LLVMBasicBlockRef LLVMGetSuccessor(LLVMValueRef Term, unsigned i);
3502 * Update the specified successor to point at the provided block.
3504 * @see llvm::Instruction::setSuccessor
3506 void LLVMSetSuccessor(LLVMValueRef Term, unsigned i, LLVMBasicBlockRef block);
3509 * Return if a branch is conditional.
3511 * This only works on llvm::BranchInst instructions.
3513 * @see llvm::BranchInst::isConditional
3515 LLVMBool LLVMIsConditional(LLVMValueRef Branch);
3518 * Return the condition of a branch instruction.
3520 * This only works on llvm::BranchInst instructions.
3522 * @see llvm::BranchInst::getCondition
3524 LLVMValueRef LLVMGetCondition(LLVMValueRef Branch);
3527 * Set the condition of a branch instruction.
3529 * This only works on llvm::BranchInst instructions.
3531 * @see llvm::BranchInst::setCondition
3533 void LLVMSetCondition(LLVMValueRef Branch, LLVMValueRef Cond);
3536 * Obtain the default destination basic block of a switch instruction.
3538 * This only works on llvm::SwitchInst instructions.
3540 * @see llvm::SwitchInst::getDefaultDest()
3542 LLVMBasicBlockRef LLVMGetSwitchDefaultDest(LLVMValueRef SwitchInstr);
3545 * @}
3549 * @defgroup LLVMCCoreValueInstructionAlloca Allocas
3551 * Functions in this group only apply to instructions that map to
3552 * llvm::AllocaInst instances.
3554 * @{
3558 * Obtain the type that is being allocated by the alloca instruction.
3560 LLVMTypeRef LLVMGetAllocatedType(LLVMValueRef Alloca);
3563 * @}
3567 * @defgroup LLVMCCoreValueInstructionGetElementPointer GEPs
3569 * Functions in this group only apply to instructions that map to
3570 * llvm::GetElementPtrInst instances.
3572 * @{
3576 * Check whether the given GEP operator is inbounds.
3578 LLVMBool LLVMIsInBounds(LLVMValueRef GEP);
3581 * Set the given GEP instruction to be inbounds or not.
3583 void LLVMSetIsInBounds(LLVMValueRef GEP, LLVMBool InBounds);
3586 * Get the source element type of the given GEP operator.
3588 LLVMTypeRef LLVMGetGEPSourceElementType(LLVMValueRef GEP);
3591 * @}
3595 * @defgroup LLVMCCoreValueInstructionPHINode PHI Nodes
3597 * Functions in this group only apply to instructions that map to
3598 * llvm::PHINode instances.
3600 * @{
3604 * Add an incoming value to the end of a PHI list.
3606 void LLVMAddIncoming(LLVMValueRef PhiNode, LLVMValueRef *IncomingValues,
3607 LLVMBasicBlockRef *IncomingBlocks, unsigned Count);
3610 * Obtain the number of incoming basic blocks to a PHI node.
3612 unsigned LLVMCountIncoming(LLVMValueRef PhiNode);
3615 * Obtain an incoming value to a PHI node as an LLVMValueRef.
3617 LLVMValueRef LLVMGetIncomingValue(LLVMValueRef PhiNode, unsigned Index);
3620 * Obtain an incoming value to a PHI node as an LLVMBasicBlockRef.
3622 LLVMBasicBlockRef LLVMGetIncomingBlock(LLVMValueRef PhiNode, unsigned Index);
3625 * @}
3629 * @defgroup LLVMCCoreValueInstructionExtractValue ExtractValue
3630 * @defgroup LLVMCCoreValueInstructionInsertValue InsertValue
3632 * Functions in this group only apply to instructions that map to
3633 * llvm::ExtractValue and llvm::InsertValue instances.
3635 * @{
3639 * Obtain the number of indices.
3640 * NB: This also works on GEP operators.
3642 unsigned LLVMGetNumIndices(LLVMValueRef Inst);
3645 * Obtain the indices as an array.
3647 const unsigned *LLVMGetIndices(LLVMValueRef Inst);
3650 * @}
3654 * @}
3658 * @}
3662 * @defgroup LLVMCCoreInstructionBuilder Instruction Builders
3664 * An instruction builder represents a point within a basic block and is
3665 * the exclusive means of building instructions using the C interface.
3667 * @{
3670 LLVMBuilderRef LLVMCreateBuilderInContext(LLVMContextRef C);
3671 LLVMBuilderRef LLVMCreateBuilder(void);
3672 void LLVMPositionBuilder(LLVMBuilderRef Builder, LLVMBasicBlockRef Block,
3673 LLVMValueRef Instr);
3674 void LLVMPositionBuilderBefore(LLVMBuilderRef Builder, LLVMValueRef Instr);
3675 void LLVMPositionBuilderAtEnd(LLVMBuilderRef Builder, LLVMBasicBlockRef Block);
3676 LLVMBasicBlockRef LLVMGetInsertBlock(LLVMBuilderRef Builder);
3677 void LLVMClearInsertionPosition(LLVMBuilderRef Builder);
3678 void LLVMInsertIntoBuilder(LLVMBuilderRef Builder, LLVMValueRef Instr);
3679 void LLVMInsertIntoBuilderWithName(LLVMBuilderRef Builder, LLVMValueRef Instr,
3680 const char *Name);
3681 void LLVMDisposeBuilder(LLVMBuilderRef Builder);
3683 /* Metadata */
3686 * Get location information used by debugging information.
3688 * @see llvm::IRBuilder::getCurrentDebugLocation()
3690 LLVMMetadataRef LLVMGetCurrentDebugLocation2(LLVMBuilderRef Builder);
3693 * Set location information used by debugging information.
3695 * To clear the location metadata of the given instruction, pass NULL to \p Loc.
3697 * @see llvm::IRBuilder::SetCurrentDebugLocation()
3699 void LLVMSetCurrentDebugLocation2(LLVMBuilderRef Builder, LLVMMetadataRef Loc);
3702 * Attempts to set the debug location for the given instruction using the
3703 * current debug location for the given builder. If the builder has no current
3704 * debug location, this function is a no-op.
3706 * @deprecated LLVMSetInstDebugLocation is deprecated in favor of the more general
3707 * LLVMAddMetadataToInst.
3709 * @see llvm::IRBuilder::SetInstDebugLocation()
3711 void LLVMSetInstDebugLocation(LLVMBuilderRef Builder, LLVMValueRef Inst);
3714 * Adds the metadata registered with the given builder to the given instruction.
3716 * @see llvm::IRBuilder::AddMetadataToInst()
3718 void LLVMAddMetadataToInst(LLVMBuilderRef Builder, LLVMValueRef Inst);
3721 * Get the dafult floating-point math metadata for a given builder.
3723 * @see llvm::IRBuilder::getDefaultFPMathTag()
3725 LLVMMetadataRef LLVMBuilderGetDefaultFPMathTag(LLVMBuilderRef Builder);
3728 * Set the default floating-point math metadata for the given builder.
3730 * To clear the metadata, pass NULL to \p FPMathTag.
3732 * @see llvm::IRBuilder::setDefaultFPMathTag()
3734 void LLVMBuilderSetDefaultFPMathTag(LLVMBuilderRef Builder,
3735 LLVMMetadataRef FPMathTag);
3738 * Deprecated: Passing the NULL location will crash.
3739 * Use LLVMGetCurrentDebugLocation2 instead.
3741 void LLVMSetCurrentDebugLocation(LLVMBuilderRef Builder, LLVMValueRef L);
3743 * Deprecated: Returning the NULL location will crash.
3744 * Use LLVMGetCurrentDebugLocation2 instead.
3746 LLVMValueRef LLVMGetCurrentDebugLocation(LLVMBuilderRef Builder);
3748 /* Terminators */
3749 LLVMValueRef LLVMBuildRetVoid(LLVMBuilderRef);
3750 LLVMValueRef LLVMBuildRet(LLVMBuilderRef, LLVMValueRef V);
3751 LLVMValueRef LLVMBuildAggregateRet(LLVMBuilderRef, LLVMValueRef *RetVals,
3752 unsigned N);
3753 LLVMValueRef LLVMBuildBr(LLVMBuilderRef, LLVMBasicBlockRef Dest);
3754 LLVMValueRef LLVMBuildCondBr(LLVMBuilderRef, LLVMValueRef If,
3755 LLVMBasicBlockRef Then, LLVMBasicBlockRef Else);
3756 LLVMValueRef LLVMBuildSwitch(LLVMBuilderRef, LLVMValueRef V,
3757 LLVMBasicBlockRef Else, unsigned NumCases);
3758 LLVMValueRef LLVMBuildIndirectBr(LLVMBuilderRef B, LLVMValueRef Addr,
3759 unsigned NumDests);
3760 LLVMValueRef LLVMBuildInvoke2(LLVMBuilderRef, LLVMTypeRef Ty, LLVMValueRef Fn,
3761 LLVMValueRef *Args, unsigned NumArgs,
3762 LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch,
3763 const char *Name);
3764 LLVMValueRef LLVMBuildUnreachable(LLVMBuilderRef);
3766 /* Exception Handling */
3767 LLVMValueRef LLVMBuildResume(LLVMBuilderRef B, LLVMValueRef Exn);
3768 LLVMValueRef LLVMBuildLandingPad(LLVMBuilderRef B, LLVMTypeRef Ty,
3769 LLVMValueRef PersFn, unsigned NumClauses,
3770 const char *Name);
3771 LLVMValueRef LLVMBuildCleanupRet(LLVMBuilderRef B, LLVMValueRef CatchPad,
3772 LLVMBasicBlockRef BB);
3773 LLVMValueRef LLVMBuildCatchRet(LLVMBuilderRef B, LLVMValueRef CatchPad,
3774 LLVMBasicBlockRef BB);
3775 LLVMValueRef LLVMBuildCatchPad(LLVMBuilderRef B, LLVMValueRef ParentPad,
3776 LLVMValueRef *Args, unsigned NumArgs,
3777 const char *Name);
3778 LLVMValueRef LLVMBuildCleanupPad(LLVMBuilderRef B, LLVMValueRef ParentPad,
3779 LLVMValueRef *Args, unsigned NumArgs,
3780 const char *Name);
3781 LLVMValueRef LLVMBuildCatchSwitch(LLVMBuilderRef B, LLVMValueRef ParentPad,
3782 LLVMBasicBlockRef UnwindBB,
3783 unsigned NumHandlers, const char *Name);
3785 /* Add a case to the switch instruction */
3786 void LLVMAddCase(LLVMValueRef Switch, LLVMValueRef OnVal,
3787 LLVMBasicBlockRef Dest);
3789 /* Add a destination to the indirectbr instruction */
3790 void LLVMAddDestination(LLVMValueRef IndirectBr, LLVMBasicBlockRef Dest);
3792 /* Get the number of clauses on the landingpad instruction */
3793 unsigned LLVMGetNumClauses(LLVMValueRef LandingPad);
3795 /* Get the value of the clause at index Idx on the landingpad instruction */
3796 LLVMValueRef LLVMGetClause(LLVMValueRef LandingPad, unsigned Idx);
3798 /* Add a catch or filter clause to the landingpad instruction */
3799 void LLVMAddClause(LLVMValueRef LandingPad, LLVMValueRef ClauseVal);
3801 /* Get the 'cleanup' flag in the landingpad instruction */
3802 LLVMBool LLVMIsCleanup(LLVMValueRef LandingPad);
3804 /* Set the 'cleanup' flag in the landingpad instruction */
3805 void LLVMSetCleanup(LLVMValueRef LandingPad, LLVMBool Val);
3807 /* Add a destination to the catchswitch instruction */
3808 void LLVMAddHandler(LLVMValueRef CatchSwitch, LLVMBasicBlockRef Dest);
3810 /* Get the number of handlers on the catchswitch instruction */
3811 unsigned LLVMGetNumHandlers(LLVMValueRef CatchSwitch);
3814 * Obtain the basic blocks acting as handlers for a catchswitch instruction.
3816 * The Handlers parameter should point to a pre-allocated array of
3817 * LLVMBasicBlockRefs at least LLVMGetNumHandlers() large. On return, the
3818 * first LLVMGetNumHandlers() entries in the array will be populated
3819 * with LLVMBasicBlockRef instances.
3821 * @param CatchSwitch The catchswitch instruction to operate on.
3822 * @param Handlers Memory address of an array to be filled with basic blocks.
3824 void LLVMGetHandlers(LLVMValueRef CatchSwitch, LLVMBasicBlockRef *Handlers);
3826 /* Funclets */
3828 /* Get the number of funcletpad arguments. */
3829 LLVMValueRef LLVMGetArgOperand(LLVMValueRef Funclet, unsigned i);
3831 /* Set a funcletpad argument at the given index. */
3832 void LLVMSetArgOperand(LLVMValueRef Funclet, unsigned i, LLVMValueRef value);
3835 * Get the parent catchswitch instruction of a catchpad instruction.
3837 * This only works on llvm::CatchPadInst instructions.
3839 * @see llvm::CatchPadInst::getCatchSwitch()
3841 LLVMValueRef LLVMGetParentCatchSwitch(LLVMValueRef CatchPad);
3844 * Set the parent catchswitch instruction of a catchpad instruction.
3846 * This only works on llvm::CatchPadInst instructions.
3848 * @see llvm::CatchPadInst::setCatchSwitch()
3850 void LLVMSetParentCatchSwitch(LLVMValueRef CatchPad, LLVMValueRef CatchSwitch);
3852 /* Arithmetic */
3853 LLVMValueRef LLVMBuildAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3854 const char *Name);
3855 LLVMValueRef LLVMBuildNSWAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3856 const char *Name);
3857 LLVMValueRef LLVMBuildNUWAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3858 const char *Name);
3859 LLVMValueRef LLVMBuildFAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3860 const char *Name);
3861 LLVMValueRef LLVMBuildSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3862 const char *Name);
3863 LLVMValueRef LLVMBuildNSWSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3864 const char *Name);
3865 LLVMValueRef LLVMBuildNUWSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3866 const char *Name);
3867 LLVMValueRef LLVMBuildFSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3868 const char *Name);
3869 LLVMValueRef LLVMBuildMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3870 const char *Name);
3871 LLVMValueRef LLVMBuildNSWMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3872 const char *Name);
3873 LLVMValueRef LLVMBuildNUWMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3874 const char *Name);
3875 LLVMValueRef LLVMBuildFMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3876 const char *Name);
3877 LLVMValueRef LLVMBuildUDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3878 const char *Name);
3879 LLVMValueRef LLVMBuildExactUDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3880 const char *Name);
3881 LLVMValueRef LLVMBuildSDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3882 const char *Name);
3883 LLVMValueRef LLVMBuildExactSDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3884 const char *Name);
3885 LLVMValueRef LLVMBuildFDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3886 const char *Name);
3887 LLVMValueRef LLVMBuildURem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3888 const char *Name);
3889 LLVMValueRef LLVMBuildSRem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3890 const char *Name);
3891 LLVMValueRef LLVMBuildFRem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3892 const char *Name);
3893 LLVMValueRef LLVMBuildShl(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3894 const char *Name);
3895 LLVMValueRef LLVMBuildLShr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3896 const char *Name);
3897 LLVMValueRef LLVMBuildAShr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3898 const char *Name);
3899 LLVMValueRef LLVMBuildAnd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3900 const char *Name);
3901 LLVMValueRef LLVMBuildOr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3902 const char *Name);
3903 LLVMValueRef LLVMBuildXor(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3904 const char *Name);
3905 LLVMValueRef LLVMBuildBinOp(LLVMBuilderRef B, LLVMOpcode Op,
3906 LLVMValueRef LHS, LLVMValueRef RHS,
3907 const char *Name);
3908 LLVMValueRef LLVMBuildNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name);
3909 LLVMValueRef LLVMBuildNSWNeg(LLVMBuilderRef B, LLVMValueRef V,
3910 const char *Name);
3911 LLVMValueRef LLVMBuildNUWNeg(LLVMBuilderRef B, LLVMValueRef V,
3912 const char *Name);
3913 LLVMValueRef LLVMBuildFNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name);
3914 LLVMValueRef LLVMBuildNot(LLVMBuilderRef, LLVMValueRef V, const char *Name);
3916 /* Memory */
3917 LLVMValueRef LLVMBuildMalloc(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
3918 LLVMValueRef LLVMBuildArrayMalloc(LLVMBuilderRef, LLVMTypeRef Ty,
3919 LLVMValueRef Val, const char *Name);
3922 * Creates and inserts a memset to the specified pointer and the
3923 * specified value.
3925 * @see llvm::IRRBuilder::CreateMemSet()
3927 LLVMValueRef LLVMBuildMemSet(LLVMBuilderRef B, LLVMValueRef Ptr,
3928 LLVMValueRef Val, LLVMValueRef Len,
3929 unsigned Align);
3931 * Creates and inserts a memcpy between the specified pointers.
3933 * @see llvm::IRRBuilder::CreateMemCpy()
3935 LLVMValueRef LLVMBuildMemCpy(LLVMBuilderRef B,
3936 LLVMValueRef Dst, unsigned DstAlign,
3937 LLVMValueRef Src, unsigned SrcAlign,
3938 LLVMValueRef Size);
3940 * Creates and inserts a memmove between the specified pointers.
3942 * @see llvm::IRRBuilder::CreateMemMove()
3944 LLVMValueRef LLVMBuildMemMove(LLVMBuilderRef B,
3945 LLVMValueRef Dst, unsigned DstAlign,
3946 LLVMValueRef Src, unsigned SrcAlign,
3947 LLVMValueRef Size);
3949 LLVMValueRef LLVMBuildAlloca(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
3950 LLVMValueRef LLVMBuildArrayAlloca(LLVMBuilderRef, LLVMTypeRef Ty,
3951 LLVMValueRef Val, const char *Name);
3952 LLVMValueRef LLVMBuildFree(LLVMBuilderRef, LLVMValueRef PointerVal);
3953 LLVMValueRef LLVMBuildLoad2(LLVMBuilderRef, LLVMTypeRef Ty,
3954 LLVMValueRef PointerVal, const char *Name);
3955 LLVMValueRef LLVMBuildStore(LLVMBuilderRef, LLVMValueRef Val, LLVMValueRef Ptr);
3956 LLVMValueRef LLVMBuildGEP2(LLVMBuilderRef B, LLVMTypeRef Ty,
3957 LLVMValueRef Pointer, LLVMValueRef *Indices,
3958 unsigned NumIndices, const char *Name);
3959 LLVMValueRef LLVMBuildInBoundsGEP2(LLVMBuilderRef B, LLVMTypeRef Ty,
3960 LLVMValueRef Pointer, LLVMValueRef *Indices,
3961 unsigned NumIndices, const char *Name);
3962 LLVMValueRef LLVMBuildStructGEP2(LLVMBuilderRef B, LLVMTypeRef Ty,
3963 LLVMValueRef Pointer, unsigned Idx,
3964 const char *Name);
3965 LLVMValueRef LLVMBuildGlobalString(LLVMBuilderRef B, const char *Str,
3966 const char *Name);
3967 LLVMValueRef LLVMBuildGlobalStringPtr(LLVMBuilderRef B, const char *Str,
3968 const char *Name);
3969 LLVMBool LLVMGetVolatile(LLVMValueRef MemoryAccessInst);
3970 void LLVMSetVolatile(LLVMValueRef MemoryAccessInst, LLVMBool IsVolatile);
3971 LLVMBool LLVMGetWeak(LLVMValueRef CmpXchgInst);
3972 void LLVMSetWeak(LLVMValueRef CmpXchgInst, LLVMBool IsWeak);
3973 LLVMAtomicOrdering LLVMGetOrdering(LLVMValueRef MemoryAccessInst);
3974 void LLVMSetOrdering(LLVMValueRef MemoryAccessInst, LLVMAtomicOrdering Ordering);
3975 LLVMAtomicRMWBinOp LLVMGetAtomicRMWBinOp(LLVMValueRef AtomicRMWInst);
3976 void LLVMSetAtomicRMWBinOp(LLVMValueRef AtomicRMWInst, LLVMAtomicRMWBinOp BinOp);
3978 /* Casts */
3979 LLVMValueRef LLVMBuildTrunc(LLVMBuilderRef, LLVMValueRef Val,
3980 LLVMTypeRef DestTy, const char *Name);
3981 LLVMValueRef LLVMBuildZExt(LLVMBuilderRef, LLVMValueRef Val,
3982 LLVMTypeRef DestTy, const char *Name);
3983 LLVMValueRef LLVMBuildSExt(LLVMBuilderRef, LLVMValueRef Val,
3984 LLVMTypeRef DestTy, const char *Name);
3985 LLVMValueRef LLVMBuildFPToUI(LLVMBuilderRef, LLVMValueRef Val,
3986 LLVMTypeRef DestTy, const char *Name);
3987 LLVMValueRef LLVMBuildFPToSI(LLVMBuilderRef, LLVMValueRef Val,
3988 LLVMTypeRef DestTy, const char *Name);
3989 LLVMValueRef LLVMBuildUIToFP(LLVMBuilderRef, LLVMValueRef Val,
3990 LLVMTypeRef DestTy, const char *Name);
3991 LLVMValueRef LLVMBuildSIToFP(LLVMBuilderRef, LLVMValueRef Val,
3992 LLVMTypeRef DestTy, const char *Name);
3993 LLVMValueRef LLVMBuildFPTrunc(LLVMBuilderRef, LLVMValueRef Val,
3994 LLVMTypeRef DestTy, const char *Name);
3995 LLVMValueRef LLVMBuildFPExt(LLVMBuilderRef, LLVMValueRef Val,
3996 LLVMTypeRef DestTy, const char *Name);
3997 LLVMValueRef LLVMBuildPtrToInt(LLVMBuilderRef, LLVMValueRef Val,
3998 LLVMTypeRef DestTy, const char *Name);
3999 LLVMValueRef LLVMBuildIntToPtr(LLVMBuilderRef, LLVMValueRef Val,
4000 LLVMTypeRef DestTy, const char *Name);
4001 LLVMValueRef LLVMBuildBitCast(LLVMBuilderRef, LLVMValueRef Val,
4002 LLVMTypeRef DestTy, const char *Name);
4003 LLVMValueRef LLVMBuildAddrSpaceCast(LLVMBuilderRef, LLVMValueRef Val,
4004 LLVMTypeRef DestTy, const char *Name);
4005 LLVMValueRef LLVMBuildZExtOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
4006 LLVMTypeRef DestTy, const char *Name);
4007 LLVMValueRef LLVMBuildSExtOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
4008 LLVMTypeRef DestTy, const char *Name);
4009 LLVMValueRef LLVMBuildTruncOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
4010 LLVMTypeRef DestTy, const char *Name);
4011 LLVMValueRef LLVMBuildCast(LLVMBuilderRef B, LLVMOpcode Op, LLVMValueRef Val,
4012 LLVMTypeRef DestTy, const char *Name);
4013 LLVMValueRef LLVMBuildPointerCast(LLVMBuilderRef, LLVMValueRef Val,
4014 LLVMTypeRef DestTy, const char *Name);
4015 LLVMValueRef LLVMBuildIntCast2(LLVMBuilderRef, LLVMValueRef Val,
4016 LLVMTypeRef DestTy, LLVMBool IsSigned,
4017 const char *Name);
4018 LLVMValueRef LLVMBuildFPCast(LLVMBuilderRef, LLVMValueRef Val,
4019 LLVMTypeRef DestTy, const char *Name);
4021 /** Deprecated: This cast is always signed. Use LLVMBuildIntCast2 instead. */
4022 LLVMValueRef LLVMBuildIntCast(LLVMBuilderRef, LLVMValueRef Val, /*Signed cast!*/
4023 LLVMTypeRef DestTy, const char *Name);
4025 LLVMOpcode LLVMGetCastOpcode(LLVMValueRef Src, LLVMBool SrcIsSigned,
4026 LLVMTypeRef DestTy, LLVMBool DestIsSigned);
4028 /* Comparisons */
4029 LLVMValueRef LLVMBuildICmp(LLVMBuilderRef, LLVMIntPredicate Op,
4030 LLVMValueRef LHS, LLVMValueRef RHS,
4031 const char *Name);
4032 LLVMValueRef LLVMBuildFCmp(LLVMBuilderRef, LLVMRealPredicate Op,
4033 LLVMValueRef LHS, LLVMValueRef RHS,
4034 const char *Name);
4036 /* Miscellaneous instructions */
4037 LLVMValueRef LLVMBuildPhi(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
4038 LLVMValueRef LLVMBuildCall2(LLVMBuilderRef, LLVMTypeRef, LLVMValueRef Fn,
4039 LLVMValueRef *Args, unsigned NumArgs,
4040 const char *Name);
4041 LLVMValueRef LLVMBuildSelect(LLVMBuilderRef, LLVMValueRef If,
4042 LLVMValueRef Then, LLVMValueRef Else,
4043 const char *Name);
4044 LLVMValueRef LLVMBuildVAArg(LLVMBuilderRef, LLVMValueRef List, LLVMTypeRef Ty,
4045 const char *Name);
4046 LLVMValueRef LLVMBuildExtractElement(LLVMBuilderRef, LLVMValueRef VecVal,
4047 LLVMValueRef Index, const char *Name);
4048 LLVMValueRef LLVMBuildInsertElement(LLVMBuilderRef, LLVMValueRef VecVal,
4049 LLVMValueRef EltVal, LLVMValueRef Index,
4050 const char *Name);
4051 LLVMValueRef LLVMBuildShuffleVector(LLVMBuilderRef, LLVMValueRef V1,
4052 LLVMValueRef V2, LLVMValueRef Mask,
4053 const char *Name);
4054 LLVMValueRef LLVMBuildExtractValue(LLVMBuilderRef, LLVMValueRef AggVal,
4055 unsigned Index, const char *Name);
4056 LLVMValueRef LLVMBuildInsertValue(LLVMBuilderRef, LLVMValueRef AggVal,
4057 LLVMValueRef EltVal, unsigned Index,
4058 const char *Name);
4059 LLVMValueRef LLVMBuildFreeze(LLVMBuilderRef, LLVMValueRef Val,
4060 const char *Name);
4062 LLVMValueRef LLVMBuildIsNull(LLVMBuilderRef, LLVMValueRef Val,
4063 const char *Name);
4064 LLVMValueRef LLVMBuildIsNotNull(LLVMBuilderRef, LLVMValueRef Val,
4065 const char *Name);
4066 LLVMValueRef LLVMBuildPtrDiff2(LLVMBuilderRef, LLVMTypeRef ElemTy,
4067 LLVMValueRef LHS, LLVMValueRef RHS,
4068 const char *Name);
4069 LLVMValueRef LLVMBuildFence(LLVMBuilderRef B, LLVMAtomicOrdering ordering,
4070 LLVMBool singleThread, const char *Name);
4071 LLVMValueRef LLVMBuildAtomicRMW(LLVMBuilderRef B, LLVMAtomicRMWBinOp op,
4072 LLVMValueRef PTR, LLVMValueRef Val,
4073 LLVMAtomicOrdering ordering,
4074 LLVMBool singleThread);
4075 LLVMValueRef LLVMBuildAtomicCmpXchg(LLVMBuilderRef B, LLVMValueRef Ptr,
4076 LLVMValueRef Cmp, LLVMValueRef New,
4077 LLVMAtomicOrdering SuccessOrdering,
4078 LLVMAtomicOrdering FailureOrdering,
4079 LLVMBool SingleThread);
4082 * Get the number of elements in the mask of a ShuffleVector instruction.
4084 unsigned LLVMGetNumMaskElements(LLVMValueRef ShuffleVectorInst);
4087 * \returns a constant that specifies that the result of a \c ShuffleVectorInst
4088 * is undefined.
4090 int LLVMGetUndefMaskElem(void);
4093 * Get the mask value at position Elt in the mask of a ShuffleVector
4094 * instruction.
4096 * \Returns the result of \c LLVMGetUndefMaskElem() if the mask value is
4097 * poison at that position.
4099 int LLVMGetMaskValue(LLVMValueRef ShuffleVectorInst, unsigned Elt);
4101 LLVMBool LLVMIsAtomicSingleThread(LLVMValueRef AtomicInst);
4102 void LLVMSetAtomicSingleThread(LLVMValueRef AtomicInst, LLVMBool SingleThread);
4104 LLVMAtomicOrdering LLVMGetCmpXchgSuccessOrdering(LLVMValueRef CmpXchgInst);
4105 void LLVMSetCmpXchgSuccessOrdering(LLVMValueRef CmpXchgInst,
4106 LLVMAtomicOrdering Ordering);
4107 LLVMAtomicOrdering LLVMGetCmpXchgFailureOrdering(LLVMValueRef CmpXchgInst);
4108 void LLVMSetCmpXchgFailureOrdering(LLVMValueRef CmpXchgInst,
4109 LLVMAtomicOrdering Ordering);
4112 * @}
4116 * @defgroup LLVMCCoreModuleProvider Module Providers
4118 * @{
4122 * Changes the type of M so it can be passed to FunctionPassManagers and the
4123 * JIT. They take ModuleProviders for historical reasons.
4125 LLVMModuleProviderRef
4126 LLVMCreateModuleProviderForExistingModule(LLVMModuleRef M);
4129 * Destroys the module M.
4131 void LLVMDisposeModuleProvider(LLVMModuleProviderRef M);
4134 * @}
4138 * @defgroup LLVMCCoreMemoryBuffers Memory Buffers
4140 * @{
4143 LLVMBool LLVMCreateMemoryBufferWithContentsOfFile(const char *Path,
4144 LLVMMemoryBufferRef *OutMemBuf,
4145 char **OutMessage);
4146 LLVMBool LLVMCreateMemoryBufferWithSTDIN(LLVMMemoryBufferRef *OutMemBuf,
4147 char **OutMessage);
4148 LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRange(const char *InputData,
4149 size_t InputDataLength,
4150 const char *BufferName,
4151 LLVMBool RequiresNullTerminator);
4152 LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRangeCopy(const char *InputData,
4153 size_t InputDataLength,
4154 const char *BufferName);
4155 const char *LLVMGetBufferStart(LLVMMemoryBufferRef MemBuf);
4156 size_t LLVMGetBufferSize(LLVMMemoryBufferRef MemBuf);
4157 void LLVMDisposeMemoryBuffer(LLVMMemoryBufferRef MemBuf);
4160 * @}
4164 * @defgroup LLVMCCorePassManagers Pass Managers
4165 * @ingroup LLVMCCore
4167 * @{
4170 /** Constructs a new whole-module pass pipeline. This type of pipeline is
4171 suitable for link-time optimization and whole-module transformations.
4172 @see llvm::PassManager::PassManager */
4173 LLVMPassManagerRef LLVMCreatePassManager(void);
4175 /** Constructs a new function-by-function pass pipeline over the module
4176 provider. It does not take ownership of the module provider. This type of
4177 pipeline is suitable for code generation and JIT compilation tasks.
4178 @see llvm::FunctionPassManager::FunctionPassManager */
4179 LLVMPassManagerRef LLVMCreateFunctionPassManagerForModule(LLVMModuleRef M);
4181 /** Deprecated: Use LLVMCreateFunctionPassManagerForModule instead. */
4182 LLVMPassManagerRef LLVMCreateFunctionPassManager(LLVMModuleProviderRef MP);
4184 /** Initializes, executes on the provided module, and finalizes all of the
4185 passes scheduled in the pass manager. Returns 1 if any of the passes
4186 modified the module, 0 otherwise.
4187 @see llvm::PassManager::run(Module&) */
4188 LLVMBool LLVMRunPassManager(LLVMPassManagerRef PM, LLVMModuleRef M);
4190 /** Initializes all of the function passes scheduled in the function pass
4191 manager. Returns 1 if any of the passes modified the module, 0 otherwise.
4192 @see llvm::FunctionPassManager::doInitialization */
4193 LLVMBool LLVMInitializeFunctionPassManager(LLVMPassManagerRef FPM);
4195 /** Executes all of the function passes scheduled in the function pass manager
4196 on the provided function. Returns 1 if any of the passes modified the
4197 function, false otherwise.
4198 @see llvm::FunctionPassManager::run(Function&) */
4199 LLVMBool LLVMRunFunctionPassManager(LLVMPassManagerRef FPM, LLVMValueRef F);
4201 /** Finalizes all of the function passes scheduled in the function pass
4202 manager. Returns 1 if any of the passes modified the module, 0 otherwise.
4203 @see llvm::FunctionPassManager::doFinalization */
4204 LLVMBool LLVMFinalizeFunctionPassManager(LLVMPassManagerRef FPM);
4206 /** Frees the memory of a pass pipeline. For function pipelines, does not free
4207 the module provider.
4208 @see llvm::PassManagerBase::~PassManagerBase. */
4209 void LLVMDisposePassManager(LLVMPassManagerRef PM);
4212 * @}
4216 * @defgroup LLVMCCoreThreading Threading
4218 * Handle the structures needed to make LLVM safe for multithreading.
4220 * @{
4223 /** Deprecated: Multi-threading can only be enabled/disabled with the compile
4224 time define LLVM_ENABLE_THREADS. This function always returns
4225 LLVMIsMultithreaded(). */
4226 LLVMBool LLVMStartMultithreaded(void);
4228 /** Deprecated: Multi-threading can only be enabled/disabled with the compile
4229 time define LLVM_ENABLE_THREADS. */
4230 void LLVMStopMultithreaded(void);
4232 /** Check whether LLVM is executing in thread-safe mode or not.
4233 @see llvm::llvm_is_multithreaded */
4234 LLVMBool LLVMIsMultithreaded(void);
4237 * @}
4241 * @}
4245 * @}
4248 LLVM_C_EXTERN_C_END
4250 #endif /* LLVM_C_CORE_H */