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\*===----------------------------------------------------------------------===*/
14
15#ifndef LLVM_C_CORE_H
16#define LLVM_C_CORE_H
17
18#include "llvm-c/Deprecated.h"
19#include "llvm-c/ErrorHandling.h"
20#include "llvm-c/ExternC.h"
21#include "llvm-c/Visibility.h"
22
23#include "llvm-c/Types.h"
24
25LLVM_C_EXTERN_C_BEGIN
26
27/**
28 * @defgroup LLVMC LLVM-C: C interface to LLVM
29 *
30 * This module exposes parts of the LLVM library as a C API.
31 *
32 * @{
33 */
34
35/**
36 * @defgroup LLVMCTransforms Transforms
37 */
38
39/**
40 * @defgroup LLVMCCore Core
41 *
42 * This modules provide an interface to libLLVMCore, which implements
43 * the LLVM intermediate representation as well as other related types
44 * and utilities.
45 *
46 * Many exotic languages can interoperate with C code but have a harder time
47 * with C++ due to name mangling. So in addition to C, this interface enables
48 * tools written in such languages.
49 *
50 * @{
51 */
52
53/**
54 * @defgroup LLVMCCoreTypes Types and Enumerations
55 *
56 * @{
57 */
58
59/// External users depend on the following values being stable. It is not safe
60/// to reorder them.
61typedef enum {
62 /* Terminator Instructions */
63 LLVMRet = 1,
64 /* removed 2 due to API changes */
65 LLVMUncondBr = 70,
66 LLVMCondBr = 71,
67 LLVMSwitch = 3,
68 LLVMIndirectBr = 4,
69 LLVMInvoke = 5,
70 /* removed 6 due to API changes */
71 LLVMUnreachable = 7,
72 LLVMCallBr = 67,
73
74 /* Standard Unary Operators */
75 LLVMFNeg = 66,
76
77 /* Standard Binary Operators */
78 LLVMAdd = 8,
79 LLVMFAdd = 9,
80 LLVMSub = 10,
81 LLVMFSub = 11,
82 LLVMMul = 12,
83 LLVMFMul = 13,
84 LLVMUDiv = 14,
85 LLVMSDiv = 15,
86 LLVMFDiv = 16,
87 LLVMURem = 17,
88 LLVMSRem = 18,
89 LLVMFRem = 19,
90
91 /* Logical Operators */
92 LLVMShl = 20,
93 LLVMLShr = 21,
94 LLVMAShr = 22,
95 LLVMAnd = 23,
96 LLVMOr = 24,
97 LLVMXor = 25,
98
99 /* Memory Operators */
100 LLVMAlloca = 26,
101 LLVMLoad = 27,
102 LLVMStore = 28,
103 LLVMGetElementPtr = 29,
104
105 /* Cast Operators */
106 LLVMTrunc = 30,
107 LLVMZExt = 31,
108 LLVMSExt = 32,
109 LLVMFPToUI = 33,
110 LLVMFPToSI = 34,
111 LLVMUIToFP = 35,
112 LLVMSIToFP = 36,
113 LLVMFPTrunc = 37,
114 LLVMFPExt = 38,
115 LLVMPtrToInt = 39,
116 LLVMPtrToAddr = 69,
117 LLVMIntToPtr = 40,
118 LLVMBitCast = 41,
119 LLVMAddrSpaceCast = 60,
120
121 /* Other Operators */
122 LLVMICmp = 42,
123 LLVMFCmp = 43,
124 LLVMPHI = 44,
125 LLVMCall = 45,
126 LLVMSelect = 46,
127 LLVMUserOp1 = 47,
128 LLVMUserOp2 = 48,
129 LLVMVAArg = 49,
130 LLVMExtractElement = 50,
131 LLVMInsertElement = 51,
132 LLVMShuffleVector = 52,
133 LLVMExtractValue = 53,
134 LLVMInsertValue = 54,
135 LLVMFreeze = 68,
136
137 /* Atomic operators */
138 LLVMFence = 55,
139 LLVMAtomicCmpXchg = 56,
140 LLVMAtomicRMW = 57,
141
142 /* Exception Handling Operators */
143 LLVMResume = 58,
144 LLVMLandingPad = 59,
145 LLVMCleanupRet = 61,
146 LLVMCatchRet = 62,
147 LLVMCatchPad = 63,
148 LLVMCleanupPad = 64,
149 LLVMCatchSwitch = 65
150} LLVMOpcode;
151
152typedef enum {
153 LLVMVoidTypeKind = 0, /**< type with no size */
154 LLVMHalfTypeKind = 1, /**< 16 bit floating point type */
155 LLVMFloatTypeKind = 2, /**< 32 bit floating point type */
156 LLVMDoubleTypeKind = 3, /**< 64 bit floating point type */
157 LLVMX86_FP80TypeKind = 4, /**< 80 bit floating point type (X87) */
158 LLVMFP128TypeKind = 5, /**< 128 bit floating point type (112-bit mantissa)*/
159 LLVMPPC_FP128TypeKind = 6, /**< 128 bit floating point type (two 64-bits) */
160 LLVMLabelTypeKind = 7, /**< Labels */
161 LLVMIntegerTypeKind = 8, /**< Arbitrary bit width integers */
162 LLVMFunctionTypeKind = 9, /**< Functions */
163 LLVMStructTypeKind = 10, /**< Structures */
164 LLVMArrayTypeKind = 11, /**< Arrays */
165 LLVMPointerTypeKind = 12, /**< Pointers */
166 LLVMVectorTypeKind = 13, /**< Fixed width SIMD vector type */
167 LLVMMetadataTypeKind = 14, /**< Metadata */
168 /* 15 previously used by LLVMX86_MMXTypeKind */
169 LLVMTokenTypeKind = 16, /**< Tokens */
170 LLVMScalableVectorTypeKind = 17, /**< Scalable SIMD vector type */
171 LLVMBFloatTypeKind = 18, /**< 16 bit brain floating point type */
172 LLVMX86_AMXTypeKind = 19, /**< X86 AMX */
173 LLVMTargetExtTypeKind = 20, /**< Target extension type */
174 LLVMByteTypeKind = 21, /**< Arbitrary bit width bytes */
175} LLVMTypeKind;
176
177typedef enum {
178 LLVMExternalLinkage, /**< Externally visible function */
179 LLVMAvailableExternallyLinkage,
180 LLVMLinkOnceAnyLinkage, /**< Keep one copy of function when linking (inline)*/
181 LLVMLinkOnceODRLinkage, /**< Same, but only replaced by something
182 equivalent. */
183 LLVMLinkOnceODRAutoHideLinkage, /**< Obsolete */
184 LLVMWeakAnyLinkage, /**< Keep one copy of function when linking (weak) */
185 LLVMWeakODRLinkage, /**< Same, but only replaced by something
186 equivalent. */
187 LLVMAppendingLinkage, /**< Special purpose, only applies to global arrays */
188 LLVMInternalLinkage, /**< Rename collisions when linking (static
189 functions) */
190 LLVMPrivateLinkage, /**< Like Internal, but omit from symbol table */
191 LLVMDLLImportLinkage, /**< Obsolete */
192 LLVMDLLExportLinkage, /**< Obsolete */
193 LLVMExternalWeakLinkage,/**< ExternalWeak linkage description */
194 LLVMGhostLinkage, /**< Obsolete */
195 LLVMCommonLinkage, /**< Tentative definitions */
196 LLVMLinkerPrivateLinkage, /**< Like Private, but linker removes. */
197 LLVMLinkerPrivateWeakLinkage /**< Like LinkerPrivate, but is weak. */
198} LLVMLinkage;
199
200typedef enum {
201 LLVMDefaultVisibility, /**< The GV is visible */
202 LLVMHiddenVisibility, /**< The GV is hidden */
203 LLVMProtectedVisibility /**< The GV is protected */
204} LLVMVisibility;
205
206typedef enum {
207 LLVMNoUnnamedAddr, /**< Address of the GV is significant. */
208 LLVMLocalUnnamedAddr, /**< Address of the GV is locally insignificant. */
209 LLVMGlobalUnnamedAddr /**< Address of the GV is globally insignificant. */
210} LLVMUnnamedAddr;
211
212typedef enum {
213 LLVMDefaultStorageClass = 0,
214 LLVMDLLImportStorageClass = 1, /**< Function to be imported from DLL. */
215 LLVMDLLExportStorageClass = 2 /**< Function to be accessible from DLL. */
216} LLVMDLLStorageClass;
217
218typedef enum {
219 LLVMCCallConv = 0,
220 LLVMFastCallConv = 8,
221 LLVMColdCallConv = 9,
222 LLVMGHCCallConv = 10,
223 LLVMHiPECallConv = 11,
224 LLVMAnyRegCallConv = 13,
225 LLVMPreserveMostCallConv = 14,
226 LLVMPreserveAllCallConv = 15,
227 LLVMSwiftCallConv = 16,
228 LLVMCXXFASTTLSCallConv = 17,
229 LLVMX86StdcallCallConv = 64,
230 LLVMX86FastcallCallConv = 65,
231 LLVMARMAPCSCallConv = 66,
232 LLVMARMAAPCSCallConv = 67,
233 LLVMARMAAPCSVFPCallConv = 68,
234 LLVMMSP430INTRCallConv = 69,
235 LLVMX86ThisCallCallConv = 70,
236 LLVMPTXKernelCallConv = 71,
237 LLVMPTXDeviceCallConv = 72,
238 LLVMSPIRFUNCCallConv = 75,
239 LLVMSPIRKERNELCallConv = 76,
240 LLVMIntelOCLBICallConv = 77,
241 LLVMX8664SysVCallConv = 78,
242 LLVMWin64CallConv = 79,
243 LLVMX86VectorCallCallConv = 80,
244 LLVMHHVMCallConv = 81,
245 LLVMHHVMCCallConv = 82,
246 LLVMX86INTRCallConv = 83,
247 LLVMAVRINTRCallConv = 84,
248 LLVMAVRSIGNALCallConv = 85,
249 LLVMAVRBUILTINCallConv = 86,
250 LLVMAMDGPUVSCallConv = 87,
251 LLVMAMDGPUGSCallConv = 88,
252 LLVMAMDGPUPSCallConv = 89,
253 LLVMAMDGPUCSCallConv = 90,
254 LLVMAMDGPUKERNELCallConv = 91,
255 LLVMX86RegCallCallConv = 92,
256 LLVMAMDGPUHSCallConv = 93,
257 LLVMMSP430BUILTINCallConv = 94,
258 LLVMAMDGPULSCallConv = 95,
259 LLVMAMDGPUESCallConv = 96
260} LLVMCallConv;
261
262typedef enum {
263 LLVMArgumentValueKind,
264 LLVMBasicBlockValueKind,
265 LLVMMemoryUseValueKind,
266 LLVMMemoryDefValueKind,
267 LLVMMemoryPhiValueKind,
268
269 LLVMFunctionValueKind,
270 LLVMGlobalAliasValueKind,
271 LLVMGlobalIFuncValueKind,
272 LLVMGlobalVariableValueKind,
273 LLVMBlockAddressValueKind,
274 LLVMConstantExprValueKind,
275 LLVMConstantArrayValueKind,
276 LLVMConstantStructValueKind,
277 LLVMConstantVectorValueKind,
278
279 LLVMUndefValueValueKind,
280 LLVMConstantAggregateZeroValueKind,
281 LLVMConstantDataArrayValueKind,
282 LLVMConstantDataVectorValueKind,
283 LLVMConstantIntValueKind,
284 LLVMConstantByteValueKind,
285 LLVMConstantFPValueKind,
286 LLVMConstantPointerNullValueKind,
287 LLVMConstantTokenNoneValueKind,
288
289 LLVMMetadataAsValueValueKind,
290 LLVMInlineAsmValueKind,
291
292 LLVMInstructionValueKind,
293 LLVMPoisonValueValueKind,
294 LLVMConstantTargetNoneValueKind,
295 LLVMConstantPtrAuthValueKind,
296} LLVMValueKind;
297
298typedef enum {
299 LLVMIntEQ = 32, /**< equal */
300 LLVMIntNE, /**< not equal */
301 LLVMIntUGT, /**< unsigned greater than */
302 LLVMIntUGE, /**< unsigned greater or equal */
303 LLVMIntULT, /**< unsigned less than */
304 LLVMIntULE, /**< unsigned less or equal */
305 LLVMIntSGT, /**< signed greater than */
306 LLVMIntSGE, /**< signed greater or equal */
307 LLVMIntSLT, /**< signed less than */
308 LLVMIntSLE /**< signed less or equal */
309} LLVMIntPredicate;
310
311typedef enum {
312 LLVMRealPredicateFalse, /**< Always false (always folded) */
313 LLVMRealOEQ, /**< True if ordered and equal */
314 LLVMRealOGT, /**< True if ordered and greater than */
315 LLVMRealOGE, /**< True if ordered and greater than or equal */
316 LLVMRealOLT, /**< True if ordered and less than */
317 LLVMRealOLE, /**< True if ordered and less than or equal */
318 LLVMRealONE, /**< True if ordered and operands are unequal */
319 LLVMRealORD, /**< True if ordered (no nans) */
320 LLVMRealUNO, /**< True if unordered: isnan(X) | isnan(Y) */
321 LLVMRealUEQ, /**< True if unordered or equal */
322 LLVMRealUGT, /**< True if unordered or greater than */
323 LLVMRealUGE, /**< True if unordered, greater than, or equal */
324 LLVMRealULT, /**< True if unordered or less than */
325 LLVMRealULE, /**< True if unordered, less than, or equal */
326 LLVMRealUNE, /**< True if unordered or not equal */
327 LLVMRealPredicateTrue /**< Always true (always folded) */
328} LLVMRealPredicate;
329
330typedef enum {
331 LLVMNotThreadLocal = 0,
332 LLVMGeneralDynamicTLSModel,
333 LLVMLocalDynamicTLSModel,
334 LLVMInitialExecTLSModel,
335 LLVMLocalExecTLSModel
336} LLVMThreadLocalMode;
337
338typedef enum {
339 LLVMAtomicOrderingNotAtomic = 0, /**< A load or store which is not atomic */
340 LLVMAtomicOrderingUnordered = 1, /**< Lowest level of atomicity, guarantees
341 somewhat sane results, lock free. */
342 LLVMAtomicOrderingMonotonic = 2, /**< guarantees that if you take all the
343 operations affecting a specific address,
344 a consistent ordering exists */
345 LLVMAtomicOrderingAcquire = 4, /**< Acquire provides a barrier of the sort
346 necessary to acquire a lock to access other
347 memory with normal loads and stores. */
348 LLVMAtomicOrderingRelease = 5, /**< Release is similar to Acquire, but with
349 a barrier of the sort necessary to release
350 a lock. */
351 LLVMAtomicOrderingAcquireRelease = 6, /**< provides both an Acquire and a
352 Release barrier (for fences and
353 operations which both read and write
354 memory). */
355 LLVMAtomicOrderingSequentiallyConsistent = 7 /**< provides Acquire semantics
356 for loads and Release
357 semantics for stores.
358 Additionally, it guarantees
359 that a total ordering exists
360 between all
361 SequentiallyConsistent
362 operations. */
363} LLVMAtomicOrdering;
364
365typedef enum {
366 LLVMAtomicRMWBinOpXchg, /**< Set the new value and return the one old */
367 LLVMAtomicRMWBinOpAdd, /**< Add a value and return the old one */
368 LLVMAtomicRMWBinOpSub, /**< Subtract a value and return the old one */
369 LLVMAtomicRMWBinOpAnd, /**< And a value and return the old one */
370 LLVMAtomicRMWBinOpNand, /**< Not-And a value and return the old one */
371 LLVMAtomicRMWBinOpOr, /**< OR a value and return the old one */
372 LLVMAtomicRMWBinOpXor, /**< Xor a value and return the old one */
373 LLVMAtomicRMWBinOpMax, /**< Sets the value if it's greater than the
374 original using a signed comparison and return
375 the old one */
376 LLVMAtomicRMWBinOpMin, /**< Sets the value if it's Smaller than the
377 original using a signed comparison and return
378 the old one */
379 LLVMAtomicRMWBinOpUMax, /**< Sets the value if it's greater than the
380 original using an unsigned comparison and return
381 the old one */
382 LLVMAtomicRMWBinOpUMin, /**< Sets the value if it's greater than the
383 original using an unsigned comparison and return
384 the old one */
385 LLVMAtomicRMWBinOpFAdd, /**< Add a floating point value and return the
386 old one */
387 LLVMAtomicRMWBinOpFSub, /**< Subtract a floating point value and return the
388 old one */
389 LLVMAtomicRMWBinOpFMax, /**< Sets the value if it's greater than the
390 original using an floating point comparison and
391 return the old one */
392 LLVMAtomicRMWBinOpFMin, /**< Sets the value if it's smaller than the
393 original using an floating point comparison and
394 return the old one */
395 LLVMAtomicRMWBinOpUIncWrap, /**< Increments the value, wrapping back to zero
396 when incremented above input value */
397 LLVMAtomicRMWBinOpUDecWrap, /**< Decrements the value, wrapping back to
398 the input value when decremented below zero */
399 LLVMAtomicRMWBinOpUSubCond, /**<Subtracts the value only if no unsigned
400 overflow */
401 LLVMAtomicRMWBinOpUSubSat, /**<Subtracts the value, clamping to zero */
402 LLVMAtomicRMWBinOpFMaximum, /**< Sets the value if it's greater than the
403 original using an floating point comparison and
404 return the old one */
405 LLVMAtomicRMWBinOpFMinimum, /**< Sets the value if it's smaller than the
406 original using an floating point comparison and
407 return the old one */
408} LLVMAtomicRMWBinOp;
409
410typedef enum {
411 LLVMDSError,
412 LLVMDSWarning,
413 LLVMDSRemark,
414 LLVMDSNote
415} LLVMDiagnosticSeverity;
416
417typedef enum {
418 LLVMInlineAsmDialectATT,
419 LLVMInlineAsmDialectIntel
420} LLVMInlineAsmDialect;
421
422typedef enum {
423 /**
424 * Emits an error if two values disagree, otherwise the resulting value is
425 * that of the operands.
426 *
427 * @see Module::ModFlagBehavior::Error
428 */
429 LLVMModuleFlagBehaviorError,
430 /**
431 * Emits a warning if two values disagree. The result value will be the
432 * operand for the flag from the first module being linked.
433 *
434 * @see Module::ModFlagBehavior::Warning
435 */
436 LLVMModuleFlagBehaviorWarning,
437 /**
438 * Adds a requirement that another module flag be present and have a
439 * specified value after linking is performed. The value must be a metadata
440 * pair, where the first element of the pair is the ID of the module flag
441 * to be restricted, and the second element of the pair is the value the
442 * module flag should be restricted to. This behavior can be used to
443 * restrict the allowable results (via triggering of an error) of linking
444 * IDs with the **Override** behavior.
445 *
446 * @see Module::ModFlagBehavior::Require
447 */
448 LLVMModuleFlagBehaviorRequire,
449 /**
450 * Uses the specified value, regardless of the behavior or value of the
451 * other module. If both modules specify **Override**, but the values
452 * differ, an error will be emitted.
453 *
454 * @see Module::ModFlagBehavior::Override
455 */
456 LLVMModuleFlagBehaviorOverride,
457 /**
458 * Appends the two values, which are required to be metadata nodes.
459 *
460 * @see Module::ModFlagBehavior::Append
461 */
462 LLVMModuleFlagBehaviorAppend,
463 /**
464 * Appends the two values, which are required to be metadata
465 * nodes. However, duplicate entries in the second list are dropped
466 * during the append operation.
467 *
468 * @see Module::ModFlagBehavior::AppendUnique
469 */
470 LLVMModuleFlagBehaviorAppendUnique,
471} LLVMModuleFlagBehavior;
472
473/**
474 * Attribute index are either LLVMAttributeReturnIndex,
475 * LLVMAttributeFunctionIndex or a parameter number from 1 to N.
476 */
477enum {
478 LLVMAttributeReturnIndex = 0U,
479 // ISO C restricts enumerator values to range of 'int'
480 // (4294967295 is too large)
481 // LLVMAttributeFunctionIndex = ~0U,
482 LLVMAttributeFunctionIndex = -1,
483};
484
485typedef unsigned LLVMAttributeIndex;
486
487/**
488 * Tail call kind for LLVMSetTailCallKind and LLVMGetTailCallKind.
489 *
490 * Note that 'musttail' implies 'tail'.
491 *
492 * @see CallInst::TailCallKind
493 */
494typedef enum {
495 LLVMTailCallKindNone = 0,
496 LLVMTailCallKindTail = 1,
497 LLVMTailCallKindMustTail = 2,
498 LLVMTailCallKindNoTail = 3,
499} LLVMTailCallKind;
500
501enum {
502 LLVMFastMathAllowReassoc = (1 << 0),
503 LLVMFastMathNoNaNs = (1 << 1),
504 LLVMFastMathNoInfs = (1 << 2),
505 LLVMFastMathNoSignedZeros = (1 << 3),
506 LLVMFastMathAllowReciprocal = (1 << 4),
507 LLVMFastMathAllowContract = (1 << 5),
508 LLVMFastMathApproxFunc = (1 << 6),
509 LLVMFastMathNone = 0,
510 LLVMFastMathAll = LLVMFastMathAllowReassoc | LLVMFastMathNoNaNs |
511 LLVMFastMathNoInfs | LLVMFastMathNoSignedZeros |
512 LLVMFastMathAllowReciprocal | LLVMFastMathAllowContract |
513 LLVMFastMathApproxFunc,
514};
515
516/**
517 * Flags to indicate what fast-math-style optimizations are allowed
518 * on operations.
519 *
520 * See https://llvm.org/docs/LangRef.html#fast-math-flags
521 */
522typedef unsigned LLVMFastMathFlags;
523
524enum {
525 LLVMGEPFlagInBounds = (1 << 0),
526 LLVMGEPFlagNUSW = (1 << 1),
527 LLVMGEPFlagNUW = (1 << 2),
528};
529
530/**
531 * Flags that constrain the allowed wrap semantics of a getelementptr
532 * instruction.
533 *
534 * See https://llvm.org/docs/LangRef.html#getelementptr-instruction
535 */
536typedef unsigned LLVMGEPNoWrapFlags;
537
538typedef enum {
539 LLVMDbgRecordLabel,
540 LLVMDbgRecordDeclare,
541 LLVMDbgRecordValue,
542 LLVMDbgRecordAssign,
543} LLVMDbgRecordKind;
544
545/**
546 * @}
547 */
548
549/** Deallocate and destroy all ManagedStatic variables.
550 @see llvm::llvm_shutdown
551 @see ManagedStatic */
552LLVM_C_ABI void LLVMShutdown(void);
553
554/*===-- Version query -----------------------------------------------------===*/
555
556/**
557 * Return the major, minor, and patch version of LLVM
558 *
559 * The version components are returned via the function's three output
560 * parameters or skipped if a NULL pointer was supplied.
561 */
562LLVM_C_ABI void LLVMGetVersion(unsigned *Major, unsigned *Minor,
563 unsigned *Patch);
564
565/*===-- Error handling ----------------------------------------------------===*/
566
567LLVM_C_ABI char *LLVMCreateMessage(const char *Message);
568LLVM_C_ABI void LLVMDisposeMessage(char *Message);
569
570/**
571 * @defgroup LLVMCCoreContext Contexts
572 *
573 * Contexts are execution states for the core LLVM IR system.
574 *
575 * Most types are tied to a context instance. Multiple contexts can
576 * exist simultaneously. A single context is not thread safe. However,
577 * different contexts can execute on different threads simultaneously.
578 *
579 * @{
580 */
581
582typedef void (*LLVMDiagnosticHandler)(LLVMDiagnosticInfoRef, void *);
583typedef void (*LLVMYieldCallback)(LLVMContextRef, void *);
584
585/**
586 * Create a new context.
587 *
588 * Every call to this function should be paired with a call to
589 * LLVMContextDispose() or the context will leak memory.
590 */
591LLVM_C_ABI LLVMContextRef LLVMContextCreate(void);
592
593/**
594 * Obtain the global context instance.
595 */
596LLVM_C_ABI
597LLVM_ATTRIBUTE_C_DEPRECATED(LLVMContextRef LLVMGetGlobalContext(void),
598 "Use of the global context is deprecated, create "
599 "one using LLVMContextCreate instead");
600
601/**
602 * Set the diagnostic handler for this context.
603 */
604LLVM_C_ABI void LLVMContextSetDiagnosticHandler(LLVMContextRef C,
605 LLVMDiagnosticHandler Handler,
606 void *DiagnosticContext);
607
608/**
609 * Get the diagnostic handler of this context.
610 */
611LLVM_C_ABI LLVMDiagnosticHandler
612LLVMContextGetDiagnosticHandler(LLVMContextRef C);
613
614/**
615 * Get the diagnostic context of this context.
616 */
617LLVM_C_ABI void *LLVMContextGetDiagnosticContext(LLVMContextRef C);
618
619/**
620 * Set the yield callback function for this context.
621 *
622 * @see LLVMContext::setYieldCallback()
623 */
624LLVM_C_ABI void LLVMContextSetYieldCallback(LLVMContextRef C,
625 LLVMYieldCallback Callback,
626 void *OpaqueHandle);
627
628/**
629 * Retrieve whether the given context is set to discard all value names.
630 *
631 * @see LLVMContext::shouldDiscardValueNames()
632 */
633LLVM_C_ABI LLVMBool LLVMContextShouldDiscardValueNames(LLVMContextRef C);
634
635/**
636 * Set whether the given context discards all value names.
637 *
638 * If true, only the names of GlobalValue objects will be available in the IR.
639 * This can be used to save memory and runtime, especially in release mode.
640 *
641 * @see LLVMContext::setDiscardValueNames()
642 */
643LLVM_C_ABI void LLVMContextSetDiscardValueNames(LLVMContextRef C,
644 LLVMBool Discard);
645
646/**
647 * Destroy a context instance.
648 *
649 * This should be called for every call to LLVMContextCreate() or memory
650 * will be leaked.
651 */
652LLVM_C_ABI void LLVMContextDispose(LLVMContextRef C);
653
654/**
655 * Return a string representation of the DiagnosticInfo. Use
656 * LLVMDisposeMessage to free the string.
657 *
658 * @see DiagnosticInfo::print()
659 */
660LLVM_C_ABI char *LLVMGetDiagInfoDescription(LLVMDiagnosticInfoRef DI);
661
662/**
663 * Return an enum LLVMDiagnosticSeverity.
664 *
665 * @see DiagnosticInfo::getSeverity()
666 */
667LLVM_C_ABI LLVMDiagnosticSeverity
668LLVMGetDiagInfoSeverity(LLVMDiagnosticInfoRef DI);
669
670LLVM_C_ABI unsigned LLVMGetMDKindIDInContext(LLVMContextRef C, const char *Name,
671 unsigned SLen);
672LLVM_C_ABI LLVM_ATTRIBUTE_C_DEPRECATED(
673 unsigned LLVMGetMDKindID(const char *Name, unsigned SLen),
674 "Use of the global context is deprecated, use LLVMGetMDKindIDInContext "
675 "instead");
676
677/**
678 * Maps a synchronization scope name to a ID unique within this context.
679 */
680LLVM_C_ABI unsigned LLVMGetSyncScopeID(LLVMContextRef C, const char *Name,
681 size_t SLen);
682
683/**
684 * Return an unique id given the name of a enum attribute,
685 * or 0 if no attribute by that name exists.
686 *
687 * See http://llvm.org/docs/LangRef.html#parameter-attributes
688 * and http://llvm.org/docs/LangRef.html#function-attributes
689 * for the list of available attributes.
690 *
691 * NB: Attribute names and/or id are subject to change without
692 * going through the C API deprecation cycle.
693 */
694LLVM_C_ABI unsigned LLVMGetEnumAttributeKindForName(const char *Name,
695 size_t SLen);
696LLVM_C_ABI unsigned LLVMGetLastEnumAttributeKind(void);
697
698/**
699 * Create an enum attribute.
700 */
701LLVM_C_ABI LLVMAttributeRef LLVMCreateEnumAttribute(LLVMContextRef C,
702 unsigned KindID,
703 uint64_t Val);
704
705/**
706 * Get the unique id corresponding to the enum attribute
707 * passed as argument.
708 */
709LLVM_C_ABI unsigned LLVMGetEnumAttributeKind(LLVMAttributeRef A);
710
711/**
712 * Get the enum attribute's value. 0 is returned if none exists.
713 */
714LLVM_C_ABI uint64_t LLVMGetEnumAttributeValue(LLVMAttributeRef A);
715
716/**
717 * Create a type attribute
718 */
719LLVM_C_ABI LLVMAttributeRef LLVMCreateTypeAttribute(LLVMContextRef C,
720 unsigned KindID,
721 LLVMTypeRef type_ref);
722
723/**
724 * Get the type attribute's value.
725 */
726LLVM_C_ABI LLVMTypeRef LLVMGetTypeAttributeValue(LLVMAttributeRef A);
727
728/**
729 * Create a ConstantRange attribute.
730 *
731 * LowerWords and UpperWords need to be NumBits divided by 64 rounded up
732 * elements long.
733 */
734LLVM_C_ABI LLVMAttributeRef LLVMCreateConstantRangeAttribute(
735 LLVMContextRef C, unsigned KindID, unsigned NumBits,
736 const uint64_t LowerWords[], const uint64_t UpperWords[]);
737
738/**
739 * Represent different denormal handling kinds for use with
740 * LLVMCreateDenormalFPEnvAttribute.
741 */
742typedef enum {
743 LLVMDenormalModeKindIEEE = 0,
744 LLVMDenormalModeKindPreserveSign = 1,
745 LLVMDenormalModeKindPositiveZero = 2,
746 LLVMDenormalModeKindDynamic = 3
747} LLVMDenormalModeKind;
748
749/**
750 * Create a DenormalFPEnv attribute.
751 *
752 * \p DefaultModeOutput is the assumed denormal handling for the outputs of most
753 * floating-point types.
754 *
755 * \p DefaultModeInput is the assumed denormal handling for the inputs of most
756 * floating-point types.
757 *
758 * \p FloatModeOutput is the assumed denormal handling for the outputs of
759 * float. This should always be the same as as DefaultModeOutput for most
760 * targets.
761 *
762 * \p FloatModeInput is the assumed denormal handling for the inputs of
763 * float. This should always be the same as as DefaultModeInput for most
764 * targets.
765 *
766 */
767LLVM_C_ABI LLVMAttributeRef LLVMCreateDenormalFPEnvAttribute(
768 LLVMContextRef C, LLVMDenormalModeKind DefaultModeOutput,
769 LLVMDenormalModeKind DefaultModeInput, LLVMDenormalModeKind FloatModeOutput,
770 LLVMDenormalModeKind FloatModeInput);
771
772/**
773 * Create a string attribute.
774 */
775LLVM_C_ABI LLVMAttributeRef LLVMCreateStringAttribute(LLVMContextRef C,
776 const char *K,
777 unsigned KLength,
778 const char *V,
779 unsigned VLength);
780
781/**
782 * Get the string attribute's kind.
783 */
784LLVM_C_ABI const char *LLVMGetStringAttributeKind(LLVMAttributeRef A,
785 unsigned *Length);
786
787/**
788 * Get the string attribute's value.
789 */
790LLVM_C_ABI const char *LLVMGetStringAttributeValue(LLVMAttributeRef A,
791 unsigned *Length);
792
793/**
794 * Check for the different types of attributes.
795 */
796LLVM_C_ABI LLVMBool LLVMIsEnumAttribute(LLVMAttributeRef A);
797LLVM_C_ABI LLVMBool LLVMIsStringAttribute(LLVMAttributeRef A);
798LLVM_C_ABI LLVMBool LLVMIsTypeAttribute(LLVMAttributeRef A);
799
800/**
801 * Obtain a Type from a context by its registered name.
802 */
803LLVM_C_ABI LLVMTypeRef LLVMGetTypeByName2(LLVMContextRef C, const char *Name);
804
805/**
806 * @}
807 */
808
809/**
810 * @defgroup LLVMCCoreModule Modules
811 *
812 * Modules represent the top-level structure in an LLVM program. An LLVM
813 * module is effectively a translation unit or a collection of
814 * translation units merged together.
815 *
816 * @{
817 */
818
819/**
820 * Create a new, empty module in the global context.
821 *
822 * This is equivalent to calling LLVMModuleCreateWithNameInContext with
823 * LLVMGetGlobalContext() as the context parameter.
824 *
825 * Every invocation should be paired with LLVMDisposeModule() or memory
826 * will be leaked.
827 */
828LLVM_C_ABI LLVM_ATTRIBUTE_C_DEPRECATED(
829 LLVMModuleRef LLVMModuleCreateWithName(const char *ModuleID),
830 "Use of the global context is deprecated, use "
831 "LLVMModuleCreateWithNameInContext instead");
832
833/**
834 * Create a new, empty module in a specific context.
835 *
836 * Every invocation should be paired with LLVMDisposeModule() or memory
837 * will be leaked.
838 */
839LLVM_C_ABI LLVMModuleRef LLVMModuleCreateWithNameInContext(const char *ModuleID,
840 LLVMContextRef C);
841/**
842 * Return an exact copy of the specified module.
843 */
844LLVM_C_ABI LLVMModuleRef LLVMCloneModule(LLVMModuleRef M);
845
846/**
847 * Destroy a module instance.
848 *
849 * This must be called for every created module or memory will be
850 * leaked.
851 */
852LLVM_C_ABI void LLVMDisposeModule(LLVMModuleRef M);
853
854/**
855 * Soon to be deprecated.
856 * See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes
857 *
858 * Returns true if the module is in the new debug info mode which uses
859 * non-instruction debug records instead of debug intrinsics for variable
860 * location tracking.
861 */
862LLVM_C_ABI LLVMBool LLVMIsNewDbgInfoFormat(LLVMModuleRef M);
863
864/**
865 * Soon to be deprecated.
866 * See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes
867 *
868 * Convert module into desired debug info format.
869 */
870LLVM_C_ABI void LLVMSetIsNewDbgInfoFormat(LLVMModuleRef M,
871 LLVMBool UseNewFormat);
872
873/**
874 * Obtain the identifier of a module.
875 *
876 * @param M Module to obtain identifier of
877 * @param Len Out parameter which holds the length of the returned string.
878 * @return The identifier of M.
879 * @see Module::getModuleIdentifier()
880 */
881LLVM_C_ABI const char *LLVMGetModuleIdentifier(LLVMModuleRef M, size_t *Len);
882
883/**
884 * Set the identifier of a module to a string Ident with length Len.
885 *
886 * @param M The module to set identifier
887 * @param Ident The string to set M's identifier to
888 * @param Len Length of Ident
889 * @see Module::setModuleIdentifier()
890 */
891LLVM_C_ABI void LLVMSetModuleIdentifier(LLVMModuleRef M, const char *Ident,
892 size_t Len);
893
894/**
895 * Obtain the module's original source file name.
896 *
897 * @param M Module to obtain the name of
898 * @param Len Out parameter which holds the length of the returned string
899 * @return The original source file name of M
900 * @see Module::getSourceFileName()
901 */
902LLVM_C_ABI const char *LLVMGetSourceFileName(LLVMModuleRef M, size_t *Len);
903
904/**
905 * Set the original source file name of a module to a string Name with length
906 * Len.
907 *
908 * @param M The module to set the source file name of
909 * @param Name The string to set M's source file name to
910 * @param Len Length of Name
911 * @see Module::setSourceFileName()
912 */
913LLVM_C_ABI void LLVMSetSourceFileName(LLVMModuleRef M, const char *Name,
914 size_t Len);
915
916/**
917 * Obtain the data layout for a module.
918 *
919 * @see Module::getDataLayoutStr()
920 *
921 * LLVMGetDataLayout is DEPRECATED, as the name is not only incorrect,
922 * but match the name of another method on the module. Prefer the use
923 * of LLVMGetDataLayoutStr, which is not ambiguous.
924 */
925LLVM_C_ABI const char *LLVMGetDataLayoutStr(LLVMModuleRef M);
926LLVM_C_ABI const char *LLVMGetDataLayout(LLVMModuleRef M);
927
928/**
929 * Set the data layout for a module.
930 *
931 * @see Module::setDataLayout()
932 */
933LLVM_C_ABI void LLVMSetDataLayout(LLVMModuleRef M, const char *DataLayoutStr);
934
935/**
936 * Obtain the target triple for a module.
937 *
938 * @see Module::getTargetTriple()
939 */
940LLVM_C_ABI const char *LLVMGetTarget(LLVMModuleRef M);
941
942/**
943 * Set the target triple for a module.
944 *
945 * @see Module::setTargetTriple()
946 */
947LLVM_C_ABI void LLVMSetTarget(LLVMModuleRef M, const char *Triple);
948
949/**
950 * Returns the module flags as an array of flag-key-value triples. The caller
951 * is responsible for freeing this array by calling
952 * \c LLVMDisposeModuleFlagsMetadata.
953 *
954 * @see Module::getModuleFlagsMetadata()
955 */
956LLVM_C_ABI LLVMModuleFlagEntry *LLVMCopyModuleFlagsMetadata(LLVMModuleRef M,
957 size_t *Len);
958
959/**
960 * Destroys module flags metadata entries.
961 */
962LLVM_C_ABI void LLVMDisposeModuleFlagsMetadata(LLVMModuleFlagEntry *Entries);
963
964/**
965 * Returns the flag behavior for a module flag entry at a specific index.
966 *
967 * @see Module::ModuleFlagEntry::Behavior
968 */
969LLVM_C_ABI LLVMModuleFlagBehavior LLVMModuleFlagEntriesGetFlagBehavior(
970 LLVMModuleFlagEntry *Entries, unsigned Index);
971
972/**
973 * Returns the key for a module flag entry at a specific index.
974 *
975 * @see Module::ModuleFlagEntry::Key
976 */
977LLVM_C_ABI const char *LLVMModuleFlagEntriesGetKey(LLVMModuleFlagEntry *Entries,
978 unsigned Index, size_t *Len);
979
980/**
981 * Returns the metadata for a module flag entry at a specific index.
982 *
983 * @see Module::ModuleFlagEntry::Val
984 */
985LLVM_C_ABI LLVMMetadataRef
986LLVMModuleFlagEntriesGetMetadata(LLVMModuleFlagEntry *Entries, unsigned Index);
987
988/**
989 * Add a module-level flag to the module-level flags metadata if it doesn't
990 * already exist.
991 *
992 * @see Module::getModuleFlag()
993 */
994LLVM_C_ABI LLVMMetadataRef LLVMGetModuleFlag(LLVMModuleRef M, const char *Key,
995 size_t KeyLen);
996
997/**
998 * Add a module-level flag to the module-level flags metadata if it doesn't
999 * already exist.
1000 *
1001 * @see Module::addModuleFlag()
1002 */
1003LLVM_C_ABI void LLVMAddModuleFlag(LLVMModuleRef M,
1004 LLVMModuleFlagBehavior Behavior,
1005 const char *Key, size_t KeyLen,
1006 LLVMMetadataRef Val);
1007
1008/**
1009 * Dump a representation of a module to stderr.
1010 *
1011 * @see Module::dump()
1012 */
1013LLVM_C_ABI void LLVMDumpModule(LLVMModuleRef M);
1014
1015/**
1016 * Print a representation of a module to a file. The ErrorMessage needs to be
1017 * disposed with LLVMDisposeMessage. Returns 0 on success, 1 otherwise.
1018 *
1019 * @see Module::print()
1020 */
1021LLVM_C_ABI LLVMBool LLVMPrintModuleToFile(LLVMModuleRef M, const char *Filename,
1022 char **ErrorMessage);
1023
1024/**
1025 * Return a string representation of the module. Use
1026 * LLVMDisposeMessage to free the string.
1027 *
1028 * @see Module::print()
1029 */
1030LLVM_C_ABI char *LLVMPrintModuleToString(LLVMModuleRef M);
1031
1032/**
1033 * Get inline assembly for a module.
1034 *
1035 * @see Module::getModuleInlineAsm()
1036 */
1037LLVM_C_ABI const char *LLVMGetModuleInlineAsm(LLVMModuleRef M, size_t *Len);
1038
1039/**
1040 * Set inline assembly for a module.
1041 *
1042 * @see Module::setModuleInlineAsm()
1043 */
1044LLVM_C_ABI void LLVMSetModuleInlineAsm2(LLVMModuleRef M, const char *Asm,
1045 size_t Len);
1046
1047/**
1048 * Append inline assembly to a module.
1049 *
1050 * @see Module::appendModuleInlineAsm()
1051 */
1052LLVM_C_ABI void LLVMAppendModuleInlineAsm(LLVMModuleRef M, const char *Asm,
1053 size_t Len);
1054
1055/**
1056 * Create the specified uniqued inline asm string.
1057 *
1058 * @see InlineAsm::get()
1059 */
1060LLVM_C_ABI LLVMValueRef LLVMGetInlineAsm(
1061 LLVMTypeRef Ty, const char *AsmString, size_t AsmStringSize,
1062 const char *Constraints, size_t ConstraintsSize, LLVMBool HasSideEffects,
1063 LLVMBool IsAlignStack, LLVMInlineAsmDialect Dialect, LLVMBool CanThrow);
1064
1065/**
1066 * Get the template string used for an inline assembly snippet
1067 *
1068 */
1069LLVM_C_ABI const char *LLVMGetInlineAsmAsmString(LLVMValueRef InlineAsmVal,
1070 size_t *Len);
1071
1072/**
1073 * Get the raw constraint string for an inline assembly snippet
1074 *
1075 */
1076LLVM_C_ABI const char *
1077LLVMGetInlineAsmConstraintString(LLVMValueRef InlineAsmVal, size_t *Len);
1078
1079/**
1080 * Get the dialect used by the inline asm snippet
1081 *
1082 */
1083LLVM_C_ABI LLVMInlineAsmDialect
1084LLVMGetInlineAsmDialect(LLVMValueRef InlineAsmVal);
1085
1086/**
1087 * Get the function type of the inline assembly snippet. The same type that
1088 * was passed into LLVMGetInlineAsm originally
1089 *
1090 * @see LLVMGetInlineAsm
1091 *
1092 */
1093LLVM_C_ABI LLVMTypeRef LLVMGetInlineAsmFunctionType(LLVMValueRef InlineAsmVal);
1094
1095/**
1096 * Get if the inline asm snippet has side effects
1097 *
1098 */
1099LLVM_C_ABI LLVMBool LLVMGetInlineAsmHasSideEffects(LLVMValueRef InlineAsmVal);
1100
1101/**
1102 * Get if the inline asm snippet needs an aligned stack
1103 *
1104 */
1105LLVM_C_ABI LLVMBool
1106LLVMGetInlineAsmNeedsAlignedStack(LLVMValueRef InlineAsmVal);
1107
1108/**
1109 * Get if the inline asm snippet may unwind the stack
1110 *
1111 */
1112LLVM_C_ABI LLVMBool LLVMGetInlineAsmCanUnwind(LLVMValueRef InlineAsmVal);
1113
1114/**
1115 * Obtain the context to which this module is associated.
1116 *
1117 * @see Module::getContext()
1118 */
1119LLVM_C_ABI LLVMContextRef LLVMGetModuleContext(LLVMModuleRef M);
1120
1121/** Deprecated: Use LLVMGetTypeByName2 instead. */
1122LLVM_C_ABI LLVMTypeRef LLVMGetTypeByName(LLVMModuleRef M, const char *Name);
1123
1124/**
1125 * Obtain an iterator to the first NamedMDNode in a Module.
1126 *
1127 * @see llvm::Module::named_metadata_begin()
1128 */
1129LLVM_C_ABI LLVMNamedMDNodeRef LLVMGetFirstNamedMetadata(LLVMModuleRef M);
1130
1131/**
1132 * Obtain an iterator to the last NamedMDNode in a Module.
1133 *
1134 * @see llvm::Module::named_metadata_end()
1135 */
1136LLVM_C_ABI LLVMNamedMDNodeRef LLVMGetLastNamedMetadata(LLVMModuleRef M);
1137
1138/**
1139 * Advance a NamedMDNode iterator to the next NamedMDNode.
1140 *
1141 * Returns NULL if the iterator was already at the end and there are no more
1142 * named metadata nodes.
1143 */
1144LLVM_C_ABI LLVMNamedMDNodeRef
1145LLVMGetNextNamedMetadata(LLVMNamedMDNodeRef NamedMDNode);
1146
1147/**
1148 * Decrement a NamedMDNode iterator to the previous NamedMDNode.
1149 *
1150 * Returns NULL if the iterator was already at the beginning and there are
1151 * no previous named metadata nodes.
1152 */
1153LLVM_C_ABI LLVMNamedMDNodeRef
1154LLVMGetPreviousNamedMetadata(LLVMNamedMDNodeRef NamedMDNode);
1155
1156/**
1157 * Retrieve a NamedMDNode with the given name, returning NULL if no such
1158 * node exists.
1159 *
1160 * @see llvm::Module::getNamedMetadata()
1161 */
1162LLVM_C_ABI LLVMNamedMDNodeRef LLVMGetNamedMetadata(LLVMModuleRef M,
1163 const char *Name,
1164 size_t NameLen);
1165
1166/**
1167 * Retrieve a NamedMDNode with the given name, creating a new node if no such
1168 * node exists.
1169 *
1170 * @see llvm::Module::getOrInsertNamedMetadata()
1171 */
1172LLVM_C_ABI LLVMNamedMDNodeRef LLVMGetOrInsertNamedMetadata(LLVMModuleRef M,
1173 const char *Name,
1174 size_t NameLen);
1175
1176/**
1177 * Retrieve the name of a NamedMDNode.
1178 *
1179 * @see llvm::NamedMDNode::getName()
1180 */
1181LLVM_C_ABI const char *LLVMGetNamedMetadataName(LLVMNamedMDNodeRef NamedMD,
1182 size_t *NameLen);
1183
1184/**
1185 * Obtain the number of operands for named metadata in a module.
1186 *
1187 * @see llvm::Module::getNamedMetadata()
1188 */
1189LLVM_C_ABI unsigned LLVMGetNamedMetadataNumOperands(LLVMModuleRef M,
1190 const char *Name);
1191
1192/**
1193 * Obtain the named metadata operands for a module.
1194 *
1195 * The passed LLVMValueRef pointer should refer to an array of
1196 * LLVMValueRef at least LLVMGetNamedMetadataNumOperands long. This
1197 * array will be populated with the LLVMValueRef instances. Each
1198 * instance corresponds to a llvm::MDNode.
1199 *
1200 * @see llvm::Module::getNamedMetadata()
1201 * @see llvm::MDNode::getOperand()
1202 */
1203LLVM_C_ABI void LLVMGetNamedMetadataOperands(LLVMModuleRef M, const char *Name,
1204 LLVMValueRef *Dest);
1205
1206/**
1207 * Add an operand to named metadata.
1208 *
1209 * @see llvm::Module::getNamedMetadata()
1210 * @see llvm::MDNode::addOperand()
1211 */
1212LLVM_C_ABI void LLVMAddNamedMetadataOperand(LLVMModuleRef M, const char *Name,
1213 LLVMValueRef Val);
1214
1215/**
1216 * Return the directory of the debug location for this value, which must be
1217 * an llvm::Instruction, llvm::GlobalVariable, or llvm::Function.
1218 *
1219 * @see llvm::Instruction::getDebugLoc()
1220 * @see llvm::GlobalVariable::getDebugInfo()
1221 * @see llvm::Function::getSubprogram()
1222 */
1223LLVM_C_ABI const char *LLVMGetDebugLocDirectory(LLVMValueRef Val,
1224 unsigned *Length);
1225
1226/**
1227 * Return the filename of the debug location for this value, which must be
1228 * an llvm::Instruction, llvm::GlobalVariable, or llvm::Function.
1229 *
1230 * @see llvm::Instruction::getDebugLoc()
1231 * @see llvm::GlobalVariable::getDebugInfo()
1232 * @see llvm::Function::getSubprogram()
1233 */
1234LLVM_C_ABI const char *LLVMGetDebugLocFilename(LLVMValueRef Val,
1235 unsigned *Length);
1236
1237/**
1238 * Return the line number of the debug location for this value, which must be
1239 * an llvm::Instruction, llvm::GlobalVariable, or llvm::Function.
1240 *
1241 * @see llvm::Instruction::getDebugLoc()
1242 * @see llvm::GlobalVariable::getDebugInfo()
1243 * @see llvm::Function::getSubprogram()
1244 */
1245LLVM_C_ABI unsigned LLVMGetDebugLocLine(LLVMValueRef Val);
1246
1247/**
1248 * Return the column number of the debug location for this value, which must be
1249 * an llvm::Instruction.
1250 *
1251 * @see llvm::Instruction::getDebugLoc()
1252 */
1253LLVM_C_ABI unsigned LLVMGetDebugLocColumn(LLVMValueRef Val);
1254
1255/**
1256 * Add a function to a module under a specified name.
1257 *
1258 * @see llvm::Function::Create()
1259 */
1260LLVM_C_ABI LLVMValueRef LLVMAddFunction(LLVMModuleRef M, const char *Name,
1261 LLVMTypeRef FunctionTy);
1262
1263/**
1264 * Obtain or insert a function into a module.
1265 *
1266 * If a function with the specified name already exists in the module, it
1267 * is returned. Otherwise, a new function is created in the module with the
1268 * specified name and type and is returned.
1269 *
1270 * The returned value corresponds to a llvm::Function instance.
1271 *
1272 * @see llvm::Module::getOrInsertFunction()
1273 */
1274LLVM_C_ABI LLVMValueRef LLVMGetOrInsertFunction(LLVMModuleRef M,
1275 const char *Name,
1276 size_t NameLen,
1277 LLVMTypeRef FunctionTy);
1278
1279/**
1280 * Obtain a Function value from a Module by its name.
1281 *
1282 * The returned value corresponds to a llvm::Function value.
1283 *
1284 * @see llvm::Module::getFunction()
1285 */
1286LLVM_C_ABI LLVMValueRef LLVMGetNamedFunction(LLVMModuleRef M, const char *Name);
1287
1288/**
1289 * Obtain a Function value from a Module by its name.
1290 *
1291 * The returned value corresponds to a llvm::Function value.
1292 *
1293 * @see llvm::Module::getFunction()
1294 */
1295LLVM_C_ABI LLVMValueRef LLVMGetNamedFunctionWithLength(LLVMModuleRef M,
1296 const char *Name,
1297 size_t Length);
1298
1299/**
1300 * Obtain an iterator to the first Function in a Module.
1301 *
1302 * @see llvm::Module::begin()
1303 */
1304LLVM_C_ABI LLVMValueRef LLVMGetFirstFunction(LLVMModuleRef M);
1305
1306/**
1307 * Obtain an iterator to the last Function in a Module.
1308 *
1309 * @see llvm::Module::end()
1310 */
1311LLVM_C_ABI LLVMValueRef LLVMGetLastFunction(LLVMModuleRef M);
1312
1313/**
1314 * Advance a Function iterator to the next Function.
1315 *
1316 * Returns NULL if the iterator was already at the end and there are no more
1317 * functions.
1318 */
1319LLVM_C_ABI LLVMValueRef LLVMGetNextFunction(LLVMValueRef Fn);
1320
1321/**
1322 * Decrement a Function iterator to the previous Function.
1323 *
1324 * Returns NULL if the iterator was already at the beginning and there are
1325 * no previous functions.
1326 */
1327LLVM_C_ABI LLVMValueRef LLVMGetPreviousFunction(LLVMValueRef Fn);
1328
1329/** Deprecated: Use LLVMSetModuleInlineAsm2 instead. */
1330LLVM_C_ABI void LLVMSetModuleInlineAsm(LLVMModuleRef M, const char *Asm);
1331
1332/**
1333 * @}
1334 */
1335
1336/**
1337 * @defgroup LLVMCCoreType Types
1338 *
1339 * Types represent the type of a value.
1340 *
1341 * Types are associated with a context instance. The context internally
1342 * deduplicates types so there is only 1 instance of a specific type
1343 * alive at a time. In other words, a unique type is shared among all
1344 * consumers within a context.
1345 *
1346 * A Type in the C API corresponds to llvm::Type.
1347 *
1348 * Types have the following hierarchy:
1349 *
1350 * types:
1351 * integer type
1352 * byte type
1353 * real type
1354 * function type
1355 * sequence types:
1356 * array type
1357 * pointer type
1358 * vector type
1359 * void type
1360 * label type
1361 * opaque type
1362 *
1363 * @{
1364 */
1365
1366/**
1367 * Obtain the enumerated type of a Type instance.
1368 *
1369 * @see llvm::Type:getTypeID()
1370 */
1371LLVM_C_ABI LLVMTypeKind LLVMGetTypeKind(LLVMTypeRef Ty);
1372
1373/**
1374 * Whether the type has a known size.
1375 *
1376 * Things that don't have a size are abstract types, labels, and void.a
1377 *
1378 * @see llvm::Type::isSized()
1379 */
1380LLVM_C_ABI LLVMBool LLVMTypeIsSized(LLVMTypeRef Ty);
1381
1382/**
1383 * Obtain the context to which this type instance is associated.
1384 *
1385 * @see llvm::Type::getContext()
1386 */
1387LLVM_C_ABI LLVMContextRef LLVMGetTypeContext(LLVMTypeRef Ty);
1388
1389/**
1390 * Dump a representation of a type to stderr.
1391 *
1392 * @see llvm::Type::dump()
1393 */
1394LLVM_C_ABI void LLVMDumpType(LLVMTypeRef Val);
1395
1396/**
1397 * Return a string representation of the type. Use
1398 * LLVMDisposeMessage to free the string.
1399 *
1400 * @see llvm::Type::print()
1401 */
1402LLVM_C_ABI char *LLVMPrintTypeToString(LLVMTypeRef Val);
1403
1404/**
1405 * @}
1406 */
1407
1408/**
1409 * @defgroup LLVMCCoreTypeByte Byte Types
1410 *
1411 * Functions in this section operate on byte types.
1412 *
1413 * @{
1414 */
1415
1416/**
1417 * Obtain a byte type from a context with specified bit width.
1418 */
1419LLVM_C_ABI LLVMTypeRef LLVMByteTypeInContext(LLVMContextRef C,
1420 unsigned NumBits);
1421LLVM_C_ABI unsigned LLVMGetByteTypeWidth(LLVMTypeRef ByteTy);
1422
1423/**
1424 * @defgroup LLVMCCoreTypeInt Integer Types
1425 *
1426 * Functions in this section operate on integer types.
1427 *
1428 * @{
1429 */
1430
1431/**
1432 * Obtain an integer type from a context with specified bit width.
1433 */
1434LLVM_C_ABI LLVMTypeRef LLVMInt1TypeInContext(LLVMContextRef C);
1435LLVM_C_ABI LLVMTypeRef LLVMInt8TypeInContext(LLVMContextRef C);
1436LLVM_C_ABI LLVMTypeRef LLVMInt16TypeInContext(LLVMContextRef C);
1437LLVM_C_ABI LLVMTypeRef LLVMInt32TypeInContext(LLVMContextRef C);
1438LLVM_C_ABI LLVMTypeRef LLVMInt64TypeInContext(LLVMContextRef C);
1439LLVM_C_ABI LLVMTypeRef LLVMInt128TypeInContext(LLVMContextRef C);
1440LLVM_C_ABI LLVMTypeRef LLVMIntTypeInContext(LLVMContextRef C, unsigned NumBits);
1441
1442/**
1443 * Obtain an integer type from the global context with a specified bit
1444 * width.
1445 */
1446LLVM_C_ABI
1447LLVM_ATTRIBUTE_C_DEPRECATED(LLVMTypeRef LLVMInt1Type(void),
1448 "Use of the global context is deprecated, use "
1449 "LLVMInt1TypeInContext instead");
1450LLVM_C_ABI
1451LLVM_ATTRIBUTE_C_DEPRECATED(LLVMTypeRef LLVMInt8Type(void),
1452 "Use of the global context is deprecated, use "
1453 "LLVMInt8TypeInContext instead");
1454LLVM_C_ABI
1455LLVM_ATTRIBUTE_C_DEPRECATED(LLVMTypeRef LLVMInt16Type(void),
1456 "Use of the global context is deprecated, use "
1457 "LLVMInt16TypeInContext instead");
1458LLVM_C_ABI
1459LLVM_ATTRIBUTE_C_DEPRECATED(LLVMTypeRef LLVMInt32Type(void),
1460 "Use of the global context is deprecated, use "
1461 "LLVMInt32TypeInContext instead");
1462LLVM_C_ABI
1463LLVM_ATTRIBUTE_C_DEPRECATED(LLVMTypeRef LLVMInt64Type(void),
1464 "Use of the global context is deprecated, use "
1465 "LLVMInt64TypeInContext instead");
1466LLVM_C_ABI
1467LLVM_ATTRIBUTE_C_DEPRECATED(LLVMTypeRef LLVMInt128Type(void),
1468 "Use of the global context is deprecated, use "
1469 "LLVMInt128TypeInContext instead");
1470LLVM_C_ABI
1471LLVM_ATTRIBUTE_C_DEPRECATED(LLVMTypeRef LLVMIntType(unsigned NumBits),
1472 "Use of the global context is deprecated, use "
1473 "LLVMIntTypeInContext instead");
1474
1475LLVM_C_ABI unsigned LLVMGetIntTypeWidth(LLVMTypeRef IntegerTy);
1476
1477/**
1478 * @}
1479 */
1480
1481/**
1482 * @defgroup LLVMCCoreTypeFloat Floating Point Types
1483 *
1484 * @{
1485 */
1486
1487/**
1488 * Obtain a 16-bit floating point type from a context.
1489 */
1490LLVM_C_ABI LLVMTypeRef LLVMHalfTypeInContext(LLVMContextRef C);
1491
1492/**
1493 * Obtain a 16-bit brain floating point type from a context.
1494 */
1495LLVM_C_ABI LLVMTypeRef LLVMBFloatTypeInContext(LLVMContextRef C);
1496
1497/**
1498 * Obtain a 32-bit floating point type from a context.
1499 */
1500LLVM_C_ABI LLVMTypeRef LLVMFloatTypeInContext(LLVMContextRef C);
1501
1502/**
1503 * Obtain a 64-bit floating point type from a context.
1504 */
1505LLVM_C_ABI LLVMTypeRef LLVMDoubleTypeInContext(LLVMContextRef C);
1506
1507/**
1508 * Obtain a 80-bit floating point type (X87) from a context.
1509 */
1510LLVM_C_ABI LLVMTypeRef LLVMX86FP80TypeInContext(LLVMContextRef C);
1511
1512/**
1513 * Obtain a 128-bit floating point type (112-bit mantissa) from a
1514 * context.
1515 */
1516LLVM_C_ABI LLVMTypeRef LLVMFP128TypeInContext(LLVMContextRef C);
1517
1518/**
1519 * Obtain a 128-bit floating point type (two 64-bits) from a context.
1520 */
1521LLVM_C_ABI LLVMTypeRef LLVMPPCFP128TypeInContext(LLVMContextRef C);
1522
1523/**
1524 * Obtain a floating point type from the global context.
1525 *
1526 * These map to the functions in this group of the same name.
1527 */
1528LLVM_C_ABI
1529LLVM_ATTRIBUTE_C_DEPRECATED(LLVMTypeRef LLVMHalfType(void),
1530 "Use of the global context is deprecated, use "
1531 "LLVMHalfTypeInContext instead");
1532LLVM_C_ABI
1533LLVM_ATTRIBUTE_C_DEPRECATED(LLVMTypeRef LLVMBFloatType(void),
1534 "Use of the global context is deprecated, use "
1535 "LLVMBFloatTypeInContext instead");
1536LLVM_C_ABI
1537LLVM_ATTRIBUTE_C_DEPRECATED(LLVMTypeRef LLVMFloatType(void),
1538 "Use of the global context is deprecated, use "
1539 "LLVMFloatTypeInContext instead");
1540LLVM_C_ABI
1541LLVM_ATTRIBUTE_C_DEPRECATED(LLVMTypeRef LLVMDoubleType(void),
1542 "Use of the global context is deprecated, use "
1543 "LLVMDoubleTypeInContext instead");
1544LLVM_C_ABI
1545LLVM_ATTRIBUTE_C_DEPRECATED(LLVMTypeRef LLVMX86FP80Type(void),
1546 "Use of the global context is deprecated, use "
1547 "LLVMX86FP80TypeInContext instead");
1548LLVM_C_ABI
1549LLVM_ATTRIBUTE_C_DEPRECATED(LLVMTypeRef LLVMFP128Type(void),
1550 "Use of the global context is deprecated, use "
1551 "LLVMFP128TypeInContext instead");
1552LLVM_C_ABI
1553LLVM_ATTRIBUTE_C_DEPRECATED(LLVMTypeRef LLVMPPCFP128Type(void),
1554 "Use of the global context is deprecated, use "
1555 "LLVMPPCFP128TypeInContext instead");
1556
1557/**
1558 * @}
1559 */
1560
1561/**
1562 * @defgroup LLVMCCoreTypeFunction Function Types
1563 *
1564 * @{
1565 */
1566
1567/**
1568 * Obtain a function type consisting of a specified signature.
1569 *
1570 * The function is defined as a tuple of a return Type, a list of
1571 * parameter types, and whether the function is variadic.
1572 */
1573LLVM_C_ABI LLVMTypeRef LLVMFunctionType(LLVMTypeRef ReturnType,
1574 LLVMTypeRef *ParamTypes,
1575 unsigned ParamCount, LLVMBool IsVarArg);
1576
1577/**
1578 * Returns whether a function type is variadic.
1579 */
1580LLVM_C_ABI LLVMBool LLVMIsFunctionVarArg(LLVMTypeRef FunctionTy);
1581
1582/**
1583 * Obtain the Type this function Type returns.
1584 */
1585LLVM_C_ABI LLVMTypeRef LLVMGetReturnType(LLVMTypeRef FunctionTy);
1586
1587/**
1588 * Obtain the number of parameters this function accepts.
1589 */
1590LLVM_C_ABI unsigned LLVMCountParamTypes(LLVMTypeRef FunctionTy);
1591
1592/**
1593 * Obtain the types of a function's parameters.
1594 *
1595 * The Dest parameter should point to a pre-allocated array of
1596 * LLVMTypeRef at least LLVMCountParamTypes() large. On return, the
1597 * first LLVMCountParamTypes() entries in the array will be populated
1598 * with LLVMTypeRef instances.
1599 *
1600 * @param FunctionTy The function type to operate on.
1601 * @param Dest Memory address of an array to be filled with result.
1602 */
1603LLVM_C_ABI void LLVMGetParamTypes(LLVMTypeRef FunctionTy, LLVMTypeRef *Dest);
1604
1605/**
1606 * @}
1607 */
1608
1609/**
1610 * @defgroup LLVMCCoreTypeStruct Structure Types
1611 *
1612 * These functions relate to LLVMTypeRef instances.
1613 *
1614 * @see llvm::StructType
1615 *
1616 * @{
1617 */
1618
1619/**
1620 * Create a new structure type in a context.
1621 *
1622 * A structure is specified by a list of inner elements/types and
1623 * whether these can be packed together.
1624 *
1625 * @see llvm::StructType::create()
1626 */
1627LLVM_C_ABI LLVMTypeRef LLVMStructTypeInContext(LLVMContextRef C,
1628 LLVMTypeRef *ElementTypes,
1629 unsigned ElementCount,
1630 LLVMBool Packed);
1631
1632/**
1633 * Create a new structure type in the global context.
1634 *
1635 * @see llvm::StructType::create()
1636 */
1637LLVM_C_ABI LLVM_ATTRIBUTE_C_DEPRECATED(
1638 LLVMTypeRef LLVMStructType(LLVMTypeRef *ElementTypes, unsigned ElementCount,
1639 LLVMBool Packed),
1640 "Use of the global context is deprecated, use LLVMStructTypeInContext "
1641 "instead");
1642
1643/**
1644 * Create an empty structure in a context having a specified name.
1645 *
1646 * @see llvm::StructType::create()
1647 */
1648LLVM_C_ABI LLVMTypeRef LLVMStructCreateNamed(LLVMContextRef C,
1649 const char *Name);
1650
1651/**
1652 * Obtain the name of a structure.
1653 *
1654 * @see llvm::StructType::getName()
1655 */
1656LLVM_C_ABI const char *LLVMGetStructName(LLVMTypeRef Ty);
1657
1658/**
1659 * Set the contents of a structure type.
1660 *
1661 * @see llvm::StructType::setBody()
1662 */
1663LLVM_C_ABI void LLVMStructSetBody(LLVMTypeRef StructTy,
1664 LLVMTypeRef *ElementTypes,
1665 unsigned ElementCount, LLVMBool Packed);
1666
1667/**
1668 * Get the number of elements defined inside the structure.
1669 *
1670 * @see llvm::StructType::getNumElements()
1671 */
1672LLVM_C_ABI unsigned LLVMCountStructElementTypes(LLVMTypeRef StructTy);
1673
1674/**
1675 * Get the elements within a structure.
1676 *
1677 * The function is passed the address of a pre-allocated array of
1678 * LLVMTypeRef at least LLVMCountStructElementTypes() long. After
1679 * invocation, this array will be populated with the structure's
1680 * elements. The objects in the destination array will have a lifetime
1681 * of the structure type itself, which is the lifetime of the context it
1682 * is contained in.
1683 */
1684LLVM_C_ABI void LLVMGetStructElementTypes(LLVMTypeRef StructTy,
1685 LLVMTypeRef *Dest);
1686
1687/**
1688 * Get the type of the element at a given index in the structure.
1689 *
1690 * @see llvm::StructType::getTypeAtIndex()
1691 */
1692LLVM_C_ABI LLVMTypeRef LLVMStructGetTypeAtIndex(LLVMTypeRef StructTy,
1693 unsigned i);
1694
1695/**
1696 * Determine whether a structure is packed.
1697 *
1698 * @see llvm::StructType::isPacked()
1699 */
1700LLVM_C_ABI LLVMBool LLVMIsPackedStruct(LLVMTypeRef StructTy);
1701
1702/**
1703 * Determine whether a structure is opaque.
1704 *
1705 * @see llvm::StructType::isOpaque()
1706 */
1707LLVM_C_ABI LLVMBool LLVMIsOpaqueStruct(LLVMTypeRef StructTy);
1708
1709/**
1710 * Determine whether a structure is literal.
1711 *
1712 * @see llvm::StructType::isLiteral()
1713 */
1714LLVM_C_ABI LLVMBool LLVMIsLiteralStruct(LLVMTypeRef StructTy);
1715
1716/**
1717 * @}
1718 */
1719
1720/**
1721 * @defgroup LLVMCCoreTypeSequential Sequential Types
1722 *
1723 * Sequential types represents "arrays" of types. This is a super class
1724 * for array, vector, and pointer types.
1725 *
1726 * @{
1727 */
1728
1729/**
1730 * Obtain the element type of an array or vector type.
1731 *
1732 * @see llvm::SequentialType::getElementType()
1733 */
1734LLVM_C_ABI LLVMTypeRef LLVMGetElementType(LLVMTypeRef Ty);
1735
1736/**
1737 * Returns type's subtypes
1738 *
1739 * @see llvm::Type::subtypes()
1740 */
1741LLVM_C_ABI void LLVMGetSubtypes(LLVMTypeRef Tp, LLVMTypeRef *Arr);
1742
1743/**
1744 * Return the number of types in the derived type.
1745 *
1746 * @see llvm::Type::getNumContainedTypes()
1747 */
1748LLVM_C_ABI unsigned LLVMGetNumContainedTypes(LLVMTypeRef Tp);
1749
1750/**
1751 * Create a fixed size array type that refers to a specific type.
1752 *
1753 * The created type will exist in the context that its element type
1754 * exists in.
1755 *
1756 * @deprecated LLVMArrayType is deprecated in favor of the API accurate
1757 * LLVMArrayType2
1758 * @see llvm::ArrayType::get()
1759 */
1760LLVM_C_ABI LLVMTypeRef LLVMArrayType(LLVMTypeRef ElementType,
1761 unsigned ElementCount);
1762
1763/**
1764 * Create a fixed size array type that refers to a specific type.
1765 *
1766 * The created type will exist in the context that its element type
1767 * exists in.
1768 *
1769 * @see llvm::ArrayType::get()
1770 */
1771LLVM_C_ABI LLVMTypeRef LLVMArrayType2(LLVMTypeRef ElementType,
1772 uint64_t ElementCount);
1773
1774/**
1775 * Obtain the length of an array type.
1776 *
1777 * This only works on types that represent arrays.
1778 *
1779 * @deprecated LLVMGetArrayLength is deprecated in favor of the API accurate
1780 * LLVMGetArrayLength2
1781 * @see llvm::ArrayType::getNumElements()
1782 */
1783LLVM_C_ABI unsigned LLVMGetArrayLength(LLVMTypeRef ArrayTy);
1784
1785/**
1786 * Obtain the length of an array type.
1787 *
1788 * This only works on types that represent arrays.
1789 *
1790 * @see llvm::ArrayType::getNumElements()
1791 */
1792LLVM_C_ABI uint64_t LLVMGetArrayLength2(LLVMTypeRef ArrayTy);
1793
1794/**
1795 * Create a pointer type that points to a defined type.
1796 *
1797 * The created type will exist in the context that its pointee type
1798 * exists in.
1799 *
1800 * @see llvm::PointerType::get()
1801 */
1802LLVM_C_ABI LLVMTypeRef LLVMPointerType(LLVMTypeRef ElementType,
1803 unsigned AddressSpace);
1804
1805/**
1806 * Determine whether a pointer is opaque.
1807 *
1808 * True if this is an instance of an opaque PointerType.
1809 *
1810 * @see llvm::Type::isOpaquePointerTy()
1811 */
1812LLVM_C_ABI LLVMBool LLVMPointerTypeIsOpaque(LLVMTypeRef Ty);
1813
1814/**
1815 * Create an opaque pointer type in a context.
1816 *
1817 * @see llvm::PointerType::get()
1818 */
1819LLVM_C_ABI LLVMTypeRef LLVMPointerTypeInContext(LLVMContextRef C,
1820 unsigned AddressSpace);
1821
1822/**
1823 * Obtain the address space of a pointer type.
1824 *
1825 * This only works on types that represent pointers.
1826 *
1827 * @see llvm::PointerType::getAddressSpace()
1828 */
1829LLVM_C_ABI unsigned LLVMGetPointerAddressSpace(LLVMTypeRef PointerTy);
1830
1831/**
1832 * Create a vector type that contains a defined type and has a specific
1833 * number of elements.
1834 *
1835 * The created type will exist in the context thats its element type
1836 * exists in.
1837 *
1838 * @see llvm::VectorType::get()
1839 */
1840LLVM_C_ABI LLVMTypeRef LLVMVectorType(LLVMTypeRef ElementType,
1841 unsigned ElementCount);
1842
1843/**
1844 * Create a vector type that contains a defined type and has a scalable
1845 * number of elements.
1846 *
1847 * The created type will exist in the context thats its element type
1848 * exists in.
1849 *
1850 * @see llvm::ScalableVectorType::get()
1851 */
1852LLVM_C_ABI LLVMTypeRef LLVMScalableVectorType(LLVMTypeRef ElementType,
1853 unsigned ElementCount);
1854
1855/**
1856 * Obtain the (possibly scalable) number of elements in a vector type.
1857 *
1858 * This only works on types that represent vectors (fixed or scalable).
1859 *
1860 * @see llvm::VectorType::getNumElements()
1861 */
1862LLVM_C_ABI unsigned LLVMGetVectorSize(LLVMTypeRef VectorTy);
1863
1864/**
1865 * Get the pointer value for the associated ConstantPtrAuth constant.
1866 *
1867 * @see llvm::ConstantPtrAuth::getPointer
1868 */
1869LLVM_C_ABI LLVMValueRef LLVMGetConstantPtrAuthPointer(LLVMValueRef PtrAuth);
1870
1871/**
1872 * Get the key value for the associated ConstantPtrAuth constant.
1873 *
1874 * @see llvm::ConstantPtrAuth::getKey
1875 */
1876LLVM_C_ABI LLVMValueRef LLVMGetConstantPtrAuthKey(LLVMValueRef PtrAuth);
1877
1878/**
1879 * Get the discriminator value for the associated ConstantPtrAuth constant.
1880 *
1881 * @see llvm::ConstantPtrAuth::getDiscriminator
1882 */
1883LLVM_C_ABI LLVMValueRef
1884LLVMGetConstantPtrAuthDiscriminator(LLVMValueRef PtrAuth);
1885
1886/**
1887 * Get the address discriminator value for the associated ConstantPtrAuth
1888 * constant.
1889 *
1890 * @see llvm::ConstantPtrAuth::getAddrDiscriminator
1891 */
1892LLVM_C_ABI LLVMValueRef
1893LLVMGetConstantPtrAuthAddrDiscriminator(LLVMValueRef PtrAuth);
1894
1895/**
1896 * @}
1897 */
1898
1899/**
1900 * @defgroup LLVMCCoreTypeOther Other Types
1901 *
1902 * @{
1903 */
1904
1905/**
1906 * Create a void type in a context.
1907 */
1908LLVM_C_ABI LLVMTypeRef LLVMVoidTypeInContext(LLVMContextRef C);
1909
1910/**
1911 * Create a label type in a context.
1912 */
1913LLVM_C_ABI LLVMTypeRef LLVMLabelTypeInContext(LLVMContextRef C);
1914
1915/**
1916 * Create a X86 AMX type in a context.
1917 */
1918LLVM_C_ABI LLVMTypeRef LLVMX86AMXTypeInContext(LLVMContextRef C);
1919
1920/**
1921 * Create a token type in a context.
1922 */
1923LLVM_C_ABI LLVMTypeRef LLVMTokenTypeInContext(LLVMContextRef C);
1924
1925/**
1926 * Create a metadata type in a context.
1927 */
1928LLVM_C_ABI LLVMTypeRef LLVMMetadataTypeInContext(LLVMContextRef C);
1929
1930/**
1931 * These are similar to the above functions except they operate on the
1932 * global context.
1933 */
1934LLVM_C_ABI
1935LLVM_ATTRIBUTE_C_DEPRECATED(LLVMTypeRef LLVMVoidType(void),
1936 "Use of the global context is deprecated, use "
1937 "LLVMVoidTypeInContext instead");
1938LLVM_C_ABI
1939LLVM_ATTRIBUTE_C_DEPRECATED(LLVMTypeRef LLVMLabelType(void),
1940 "Use of the global context is deprecated, use "
1941 "LLVMLabelTypeInContext instead");
1942LLVM_C_ABI
1943LLVM_ATTRIBUTE_C_DEPRECATED(LLVMTypeRef LLVMX86AMXType(void),
1944 "Use of the global context is deprecated, use "
1945 "LLVMX86AMXTypeInContext instead");
1946
1947/**
1948 * Create a target extension type in LLVM context.
1949 */
1950LLVM_C_ABI LLVMTypeRef LLVMTargetExtTypeInContext(
1951 LLVMContextRef C, const char *Name, LLVMTypeRef *TypeParams,
1952 unsigned TypeParamCount, unsigned *IntParams, unsigned IntParamCount);
1953
1954/**
1955 * Obtain the name for this target extension type.
1956 *
1957 * @see llvm::TargetExtType::getName()
1958 */
1959LLVM_C_ABI const char *LLVMGetTargetExtTypeName(LLVMTypeRef TargetExtTy);
1960
1961/**
1962 * Obtain the number of type parameters for this target extension type.
1963 *
1964 * @see llvm::TargetExtType::getNumTypeParameters()
1965 */
1966LLVM_C_ABI unsigned LLVMGetTargetExtTypeNumTypeParams(LLVMTypeRef TargetExtTy);
1967
1968/**
1969 * Get the type parameter at the given index for the target extension type.
1970 *
1971 * @see llvm::TargetExtType::getTypeParameter()
1972 */
1973LLVM_C_ABI LLVMTypeRef LLVMGetTargetExtTypeTypeParam(LLVMTypeRef TargetExtTy,
1974 unsigned Idx);
1975
1976/**
1977 * Obtain the number of int parameters for this target extension type.
1978 *
1979 * @see llvm::TargetExtType::getNumIntParameters()
1980 */
1981LLVM_C_ABI unsigned LLVMGetTargetExtTypeNumIntParams(LLVMTypeRef TargetExtTy);
1982
1983/**
1984 * Get the int parameter at the given index for the target extension type.
1985 *
1986 * @see llvm::TargetExtType::getIntParameter()
1987 */
1988LLVM_C_ABI unsigned LLVMGetTargetExtTypeIntParam(LLVMTypeRef TargetExtTy,
1989 unsigned Idx);
1990
1991/**
1992 * @}
1993 */
1994
1995/**
1996 * @}
1997 */
1998
1999/**
2000 * @defgroup LLVMCCoreValues Values
2001 *
2002 * The bulk of LLVM's object model consists of values, which comprise a very
2003 * rich type hierarchy.
2004 *
2005 * LLVMValueRef essentially represents llvm::Value. There is a rich
2006 * hierarchy of classes within this type. Depending on the instance
2007 * obtained, not all APIs are available.
2008 *
2009 * Callers can determine the type of an LLVMValueRef by calling the
2010 * LLVMIsA* family of functions (e.g. LLVMIsAArgument()). These
2011 * functions are defined by a macro, so it isn't obvious which are
2012 * available by looking at the Doxygen source code. Instead, look at the
2013 * source definition of LLVM_FOR_EACH_VALUE_SUBCLASS and note the list
2014 * of value names given. These value names also correspond to classes in
2015 * the llvm::Value hierarchy.
2016 *
2017 * @{
2018 */
2019
2020// Currently, clang-format tries to format the LLVM_FOR_EACH_VALUE_SUBCLASS
2021// macro in a progressively-indented fashion, which is not desired
2022// clang-format off
2023
2024#define LLVM_FOR_EACH_VALUE_SUBCLASS(macro) \
2025 macro(Argument) \
2026 macro(BasicBlock) \
2027 macro(InlineAsm) \
2028 macro(User) \
2029 macro(Constant) \
2030 macro(BlockAddress) \
2031 macro(ConstantAggregateZero) \
2032 macro(ConstantArray) \
2033 macro(ConstantDataSequential) \
2034 macro(ConstantDataArray) \
2035 macro(ConstantDataVector) \
2036 macro(ConstantExpr) \
2037 macro(ConstantFP) \
2038 macro(ConstantInt) \
2039 macro(ConstantByte) \
2040 macro(ConstantPointerNull) \
2041 macro(ConstantStruct) \
2042 macro(ConstantTokenNone) \
2043 macro(ConstantVector) \
2044 macro(ConstantPtrAuth) \
2045 macro(GlobalValue) \
2046 macro(GlobalAlias) \
2047 macro(GlobalObject) \
2048 macro(Function) \
2049 macro(GlobalVariable) \
2050 macro(GlobalIFunc) \
2051 macro(UndefValue) \
2052 macro(PoisonValue) \
2053 macro(Instruction) \
2054 macro(UnaryOperator) \
2055 macro(BinaryOperator) \
2056 macro(CallInst) \
2057 macro(IntrinsicInst) \
2058 macro(DbgInfoIntrinsic) \
2059 macro(DbgVariableIntrinsic) \
2060 macro(DbgDeclareInst) \
2061 macro(DbgLabelInst) \
2062 macro(MemIntrinsic) \
2063 macro(MemCpyInst) \
2064 macro(MemMoveInst) \
2065 macro(MemSetInst) \
2066 macro(CmpInst) \
2067 macro(FCmpInst) \
2068 macro(ICmpInst) \
2069 macro(ExtractElementInst) \
2070 macro(GetElementPtrInst) \
2071 macro(InsertElementInst) \
2072 macro(InsertValueInst) \
2073 macro(LandingPadInst) \
2074 macro(PHINode) \
2075 macro(SelectInst) \
2076 macro(ShuffleVectorInst) \
2077 macro(StoreInst) \
2078 macro(BranchInst) \
2079 macro(UncondBrInst) \
2080 macro(CondBrInst) \
2081 macro(IndirectBrInst) \
2082 macro(InvokeInst) \
2083 macro(ReturnInst) \
2084 macro(SwitchInst) \
2085 macro(UnreachableInst) \
2086 macro(ResumeInst) \
2087 macro(CleanupReturnInst) \
2088 macro(CatchReturnInst) \
2089 macro(CatchSwitchInst) \
2090 macro(CallBrInst) \
2091 macro(FuncletPadInst) \
2092 macro(CatchPadInst) \
2093 macro(CleanupPadInst) \
2094 macro(UnaryInstruction) \
2095 macro(AllocaInst) \
2096 macro(CastInst) \
2097 macro(AddrSpaceCastInst) \
2098 macro(BitCastInst) \
2099 macro(FPExtInst) \
2100 macro(FPToSIInst) \
2101 macro(FPToUIInst) \
2102 macro(FPTruncInst) \
2103 macro(IntToPtrInst) \
2104 macro(PtrToIntInst) \
2105 macro(SExtInst) \
2106 macro(SIToFPInst) \
2107 macro(TruncInst) \
2108 macro(UIToFPInst) \
2109 macro(ZExtInst) \
2110 macro(ExtractValueInst) \
2111 macro(LoadInst) \
2112 macro(VAArgInst) \
2113 macro(FreezeInst) \
2114 macro(AtomicCmpXchgInst) \
2115 macro(AtomicRMWInst) \
2116 macro(FenceInst)
2117
2118// clang-format on
2119
2120/**
2121 * @defgroup LLVMCCoreValueGeneral General APIs
2122 *
2123 * Functions in this section work on all LLVMValueRef instances,
2124 * regardless of their sub-type. They correspond to functions available
2125 * on llvm::Value.
2126 *
2127 * @{
2128 */
2129
2130/**
2131 * Obtain the type of a value.
2132 *
2133 * @see llvm::Value::getType()
2134 */
2135LLVM_C_ABI LLVMTypeRef LLVMTypeOf(LLVMValueRef Val);
2136
2137/**
2138 * Obtain the enumerated type of a Value instance.
2139 *
2140 * @see llvm::Value::getValueID()
2141 */
2142LLVM_C_ABI LLVMValueKind LLVMGetValueKind(LLVMValueRef Val);
2143
2144/**
2145 * Obtain the string name of a value.
2146 *
2147 * @see llvm::Value::getName()
2148 */
2149LLVM_C_ABI const char *LLVMGetValueName2(LLVMValueRef Val, size_t *Length);
2150
2151/**
2152 * Set the string name of a value.
2153 *
2154 * @see llvm::Value::setName()
2155 */
2156LLVM_C_ABI void LLVMSetValueName2(LLVMValueRef Val, const char *Name,
2157 size_t NameLen);
2158
2159/**
2160 * Dump a representation of a value to stderr.
2161 *
2162 * @see llvm::Value::dump()
2163 */
2164LLVM_C_ABI void LLVMDumpValue(LLVMValueRef Val);
2165
2166/**
2167 * Return a string representation of the value. Use
2168 * LLVMDisposeMessage to free the string.
2169 *
2170 * @see llvm::Value::print()
2171 */
2172LLVM_C_ABI char *LLVMPrintValueToString(LLVMValueRef Val);
2173
2174/**
2175 * Obtain the context to which this value is associated.
2176 *
2177 * @see llvm::Value::getContext()
2178 */
2179LLVM_C_ABI LLVMContextRef LLVMGetValueContext(LLVMValueRef Val);
2180
2181/**
2182 * Return a string representation of the DbgRecord. Use
2183 * LLVMDisposeMessage to free the string.
2184 *
2185 * @see llvm::DbgRecord::print()
2186 */
2187LLVM_C_ABI char *LLVMPrintDbgRecordToString(LLVMDbgRecordRef Record);
2188
2189/**
2190 * Replace all uses of a value with another one.
2191 *
2192 * @see llvm::Value::replaceAllUsesWith()
2193 */
2194LLVM_C_ABI void LLVMReplaceAllUsesWith(LLVMValueRef OldVal,
2195 LLVMValueRef NewVal);
2196
2197/**
2198 * Determine whether the specified value instance is constant.
2199 */
2200LLVM_C_ABI LLVMBool LLVMIsConstant(LLVMValueRef Val);
2201
2202/**
2203 * Determine whether a value instance is undefined.
2204 */
2205LLVM_C_ABI LLVMBool LLVMIsUndef(LLVMValueRef Val);
2206
2207/**
2208 * Determine whether a value instance is poisonous.
2209 */
2210LLVM_C_ABI LLVMBool LLVMIsPoison(LLVMValueRef Val);
2211
2212/**
2213 * Convert value instances between types.
2214 *
2215 * Internally, an LLVMValueRef is "pinned" to a specific type. This
2216 * series of functions allows you to cast an instance to a specific
2217 * type.
2218 *
2219 * If the cast is not valid for the specified type, NULL is returned.
2220 *
2221 * @see llvm::dyn_cast_or_null<>
2222 */
2223#define LLVM_DECLARE_VALUE_CAST(name) \
2224 LLVM_C_ABI LLVMValueRef LLVMIsA##name(LLVMValueRef Val);
2225LLVM_FOR_EACH_VALUE_SUBCLASS(LLVM_DECLARE_VALUE_CAST)
2226
2227LLVM_C_ABI LLVMValueRef LLVMIsAMDNode(LLVMValueRef Val);
2228LLVM_C_ABI LLVMValueRef LLVMIsAValueAsMetadata(LLVMValueRef Val);
2229LLVM_C_ABI LLVMValueRef LLVMIsAMDString(LLVMValueRef Val);
2230
2231/** Deprecated: Use LLVMGetValueName2 instead. */
2232LLVM_C_ABI const char *LLVMGetValueName(LLVMValueRef Val);
2233/** Deprecated: Use LLVMSetValueName2 instead. */
2234LLVM_C_ABI void LLVMSetValueName(LLVMValueRef Val, const char *Name);
2235
2236/**
2237 * @}
2238 */
2239
2240/**
2241 * @defgroup LLVMCCoreValueUses Usage
2242 *
2243 * This module defines functions that allow you to inspect the uses of a
2244 * LLVMValueRef.
2245 *
2246 * It is possible to obtain an LLVMUseRef for any LLVMValueRef instance.
2247 * Each LLVMUseRef (which corresponds to a llvm::Use instance) holds a
2248 * llvm::User and llvm::Value.
2249 *
2250 * @{
2251 */
2252
2253/**
2254 * Obtain the first use of a value.
2255 *
2256 * Uses are obtained in an iterator fashion. First, call this function
2257 * to obtain a reference to the first use. Then, call LLVMGetNextUse()
2258 * on that instance and all subsequently obtained instances until
2259 * LLVMGetNextUse() returns NULL.
2260 *
2261 * @see llvm::Value::use_begin()
2262 */
2263LLVM_C_ABI LLVMUseRef LLVMGetFirstUse(LLVMValueRef Val);
2264
2265/**
2266 * Obtain the next use of a value.
2267 *
2268 * This effectively advances the iterator. It returns NULL if you are on
2269 * the final use and no more are available.
2270 */
2271LLVM_C_ABI LLVMUseRef LLVMGetNextUse(LLVMUseRef U);
2272
2273/**
2274 * Obtain the user value for a user.
2275 *
2276 * The returned value corresponds to a llvm::User type.
2277 *
2278 * @see llvm::Use::getUser()
2279 */
2280LLVM_C_ABI LLVMValueRef LLVMGetUser(LLVMUseRef U);
2281
2282/**
2283 * Obtain the value this use corresponds to.
2284 *
2285 * @see llvm::Use::get().
2286 */
2287LLVM_C_ABI LLVMValueRef LLVMGetUsedValue(LLVMUseRef U);
2288
2289/**
2290 * @}
2291 */
2292
2293/**
2294 * @defgroup LLVMCCoreValueUser User value
2295 *
2296 * Function in this group pertain to LLVMValueRef instances that descent
2297 * from llvm::User. This includes constants, instructions, and
2298 * operators.
2299 *
2300 * @{
2301 */
2302
2303/**
2304 * Obtain an operand at a specific index in a llvm::User value.
2305 *
2306 * @see llvm::User::getOperand()
2307 */
2308LLVM_C_ABI LLVMValueRef LLVMGetOperand(LLVMValueRef Val, unsigned Index);
2309
2310/**
2311 * Obtain the use of an operand at a specific index in a llvm::User value.
2312 *
2313 * @see llvm::User::getOperandUse()
2314 */
2315LLVM_C_ABI LLVMUseRef LLVMGetOperandUse(LLVMValueRef Val, unsigned Index);
2316
2317/**
2318 * Set an operand at a specific index in a llvm::User value.
2319 *
2320 * @see llvm::User::setOperand()
2321 */
2322LLVM_C_ABI void LLVMSetOperand(LLVMValueRef User, unsigned Index,
2323 LLVMValueRef Val);
2324
2325/**
2326 * Obtain the number of operands in a llvm::User value.
2327 *
2328 * @see llvm::User::getNumOperands()
2329 */
2330LLVM_C_ABI int LLVMGetNumOperands(LLVMValueRef Val);
2331
2332/**
2333 * @}
2334 */
2335
2336/**
2337 * @defgroup LLVMCCoreValueConstant Constants
2338 *
2339 * This section contains APIs for interacting with LLVMValueRef that
2340 * correspond to llvm::Constant instances.
2341 *
2342 * These functions will work for any LLVMValueRef in the llvm::Constant
2343 * class hierarchy.
2344 *
2345 * @{
2346 */
2347
2348/**
2349 * Obtain a constant value referring to the null instance of a type.
2350 *
2351 * @see llvm::Constant::getNullValue()
2352 */
2353LLVM_C_ABI LLVMValueRef LLVMConstNull(LLVMTypeRef Ty); /* all zeroes */
2354
2355/**
2356 * Obtain a constant value referring to the instance of a type
2357 * consisting of all ones.
2358 *
2359 * This is only valid for integer types.
2360 *
2361 * @see llvm::Constant::getAllOnesValue()
2362 */
2363LLVM_C_ABI LLVMValueRef LLVMConstAllOnes(LLVMTypeRef Ty);
2364
2365/**
2366 * Obtain a constant value referring to an undefined value of a type.
2367 *
2368 * @see llvm::UndefValue::get()
2369 */
2370LLVM_C_ABI LLVMValueRef LLVMGetUndef(LLVMTypeRef Ty);
2371
2372/**
2373 * Obtain a constant value referring to a poison value of a type.
2374 *
2375 * @see llvm::PoisonValue::get()
2376 */
2377LLVM_C_ABI LLVMValueRef LLVMGetPoison(LLVMTypeRef Ty);
2378
2379/**
2380 * Determine whether a value instance is null.
2381 *
2382 * @see llvm::Constant::isNullValue()
2383 */
2384LLVM_C_ABI LLVMBool LLVMIsNull(LLVMValueRef Val);
2385
2386/**
2387 * Obtain a constant that is a constant pointer pointing to NULL for a
2388 * specified type.
2389 */
2390LLVM_C_ABI LLVMValueRef LLVMConstPointerNull(LLVMTypeRef Ty);
2391
2392/**
2393 * @defgroup LLVMCCoreValueConstantScalar Scalar constants
2394 *
2395 * Functions in this group model LLVMValueRef instances that correspond
2396 * to constants referring to scalar types.
2397 *
2398 * For integer types, the LLVMTypeRef parameter should correspond to a
2399 * llvm::IntegerType instance and the returned LLVMValueRef will
2400 * correspond to a llvm::ConstantInt.
2401 *
2402 * For floating point types, the LLVMTypeRef returned corresponds to a
2403 * llvm::ConstantFP.
2404 *
2405 * @{
2406 */
2407
2408/**
2409 * Obtain a constant value for an integer type.
2410 *
2411 * The returned value corresponds to a llvm::ConstantInt.
2412 *
2413 * @see llvm::ConstantInt::get()
2414 *
2415 * @param IntTy Integer type to obtain value of.
2416 * @param N The value the returned instance should refer to.
2417 * @param SignExtend Whether to sign extend the produced value.
2418 */
2419LLVM_C_ABI LLVMValueRef LLVMConstInt(LLVMTypeRef IntTy, unsigned long long N,
2420 LLVMBool SignExtend);
2421
2422/**
2423 * Obtain a constant value for an integer of arbitrary precision.
2424 *
2425 * @see llvm::ConstantInt::get()
2426 */
2427LLVM_C_ABI LLVMValueRef LLVMConstIntOfArbitraryPrecision(
2428 LLVMTypeRef IntTy, unsigned NumWords, const uint64_t Words[]);
2429
2430/**
2431 * Obtain a constant value for an integer parsed from a string.
2432 *
2433 * A similar API, LLVMConstIntOfStringAndSize is also available. If the
2434 * string's length is available, it is preferred to call that function
2435 * instead.
2436 *
2437 * @see llvm::ConstantInt::get()
2438 */
2439LLVM_C_ABI LLVMValueRef LLVMConstIntOfString(LLVMTypeRef IntTy,
2440 const char *Text, uint8_t Radix);
2441
2442/**
2443 * Obtain a constant value for an integer parsed from a string with
2444 * specified length.
2445 *
2446 * @see llvm::ConstantInt::get()
2447 */
2448LLVM_C_ABI LLVMValueRef LLVMConstIntOfStringAndSize(LLVMTypeRef IntTy,
2449 const char *Text,
2450 unsigned SLen,
2451 uint8_t Radix);
2452
2453/**
2454 * Obtain a constant value for a byte type.
2455 *
2456 * The returned value corresponds to a llvm::ConstantByte.
2457 *
2458 * @see llvm::ConstantByte::get()
2459 *
2460 * @param ByteTy Byte type to obtain value of.
2461 * @param N The value the returned instance should refer to.
2462 */
2463LLVM_C_ABI LLVMValueRef LLVMConstByte(LLVMTypeRef ByteTy, unsigned long long N);
2464
2465/**
2466 * Obtain a constant value for a byte of arbitrary precision.
2467 *
2468 * @see llvm::ConstantByte::get()
2469 */
2470LLVM_C_ABI LLVMValueRef LLVMConstByteOfArbitraryPrecision(
2471 LLVMTypeRef ByteTy, unsigned NumWords, const uint64_t Words[]);
2472
2473/**
2474 * Obtain a constant value for a byte parsed from a string with specified
2475 * length.
2476 * @see llvm::ConstantByte::get()
2477 */
2478LLVM_C_ABI LLVMValueRef LLVMConstByteOfStringAndSize(LLVMTypeRef ByteTy,
2479 const char *Text,
2480 size_t SLen,
2481 uint8_t Radix);
2482
2483/**
2484 * Obtain a constant value referring to a double floating point value.
2485 */
2486LLVM_C_ABI LLVMValueRef LLVMConstReal(LLVMTypeRef RealTy, double N);
2487
2488/**
2489 * Obtain a constant for a floating point value parsed from a string.
2490 *
2491 * A similar API, LLVMConstRealOfStringAndSize is also available. It
2492 * should be used if the input string's length is known.
2493 */
2494LLVM_C_ABI LLVMValueRef LLVMConstRealOfString(LLVMTypeRef RealTy,
2495 const char *Text);
2496
2497/**
2498 * Obtain a constant for a floating point value parsed from a string.
2499 */
2500LLVM_C_ABI LLVMValueRef LLVMConstRealOfStringAndSize(LLVMTypeRef RealTy,
2501 const char *Text,
2502 unsigned SLen);
2503
2504/**
2505 * Obtain a constant for a floating point value from array of 64 bit values.
2506 * The length of the array N must be ceildiv(bits, 64), where bits is the
2507 * scalar size in bits of the floating-point type.
2508 */
2509
2510LLVM_C_ABI LLVMValueRef LLVMConstFPFromBits(LLVMTypeRef Ty, const uint64_t N[]);
2511
2512/**
2513 * Obtain the zero extended value for an integer constant value.
2514 *
2515 * @see llvm::ConstantInt::getZExtValue()
2516 */
2517LLVM_C_ABI unsigned long long
2518LLVMConstIntGetZExtValue(LLVMValueRef ConstantVal);
2519
2520/**
2521 * Obtain the sign extended value for an integer constant value.
2522 *
2523 * @see llvm::ConstantInt::getSExtValue()
2524 */
2525LLVM_C_ABI long long LLVMConstIntGetSExtValue(LLVMValueRef ConstantVal);
2526
2527/**
2528 * Obtain the zero extended value for a byte constant value.
2529 *
2530 * @see llvm::ConstantByte::getZExtValue()
2531 */
2532LLVM_C_ABI unsigned long long
2533LLVMConstByteGetZExtValue(LLVMValueRef ConstantVal);
2534
2535/**
2536 * Obtain the sign extended value for a byte constant value.
2537 *
2538 * @see llvm::ConstantByte::getSExtValue()
2539 */
2540LLVM_C_ABI long long LLVMConstByteGetSExtValue(LLVMValueRef ConstantVal);
2541
2542/**
2543 * Obtain the double value for an floating point constant value.
2544 * losesInfo indicates if some precision was lost in the conversion.
2545 *
2546 * @see llvm::ConstantFP::getDoubleValue
2547 */
2548LLVM_C_ABI double LLVMConstRealGetDouble(LLVMValueRef ConstantVal,
2549 LLVMBool *losesInfo);
2550
2551/**
2552 * @}
2553 */
2554
2555/**
2556 * @defgroup LLVMCCoreValueConstantComposite Composite Constants
2557 *
2558 * Functions in this group operate on composite constants.
2559 *
2560 * @{
2561 */
2562
2563/**
2564 * Create a ConstantDataSequential and initialize it with a string.
2565 *
2566 * @deprecated LLVMConstStringInContext is deprecated in favor of the API
2567 * accurate LLVMConstStringInContext2
2568 * @see llvm::ConstantDataArray::getString()
2569 */
2570LLVM_C_ABI LLVMValueRef LLVMConstStringInContext(LLVMContextRef C,
2571 const char *Str,
2572 unsigned Length,
2573 LLVMBool DontNullTerminate);
2574
2575/**
2576 * Create a ConstantDataSequential and initialize it with a string.
2577 *
2578 * @see llvm::ConstantDataArray::getString()
2579 */
2580LLVM_C_ABI LLVMValueRef LLVMConstStringInContext2(LLVMContextRef C,
2581 const char *Str,
2582 size_t Length,
2583 LLVMBool DontNullTerminate);
2584
2585/**
2586 * Create a ConstantDataSequential with string content in the global context.
2587 *
2588 * This is the same as LLVMConstStringInContext except it operates on the
2589 * global context.
2590 *
2591 * @see LLVMConstStringInContext()
2592 * @see llvm::ConstantDataArray::getString()
2593 */
2594LLVM_C_ABI LLVM_ATTRIBUTE_C_DEPRECATED(
2595 LLVMValueRef LLVMConstString(const char *Str, unsigned Length,
2596 LLVMBool DontNullTerminate),
2597 "Use of the global context is deprecated, use LLVMConstStringInContext2 "
2598 "instead");
2599
2600/**
2601 * Returns true if the specified constant is an array of i8.
2602 *
2603 * @see ConstantDataSequential::getAsString()
2604 */
2605LLVM_C_ABI LLVMBool LLVMIsConstantString(LLVMValueRef c);
2606
2607/**
2608 * Get the given constant data sequential as a string.
2609 *
2610 * @see ConstantDataSequential::getAsString()
2611 */
2612LLVM_C_ABI const char *LLVMGetAsString(LLVMValueRef c, size_t *Length);
2613
2614/**
2615 * Get the raw, underlying bytes of the given constant data sequential.
2616 *
2617 * This is the same as LLVMGetAsString except it works for all constant data
2618 * sequentials, not just i8 arrays.
2619 *
2620 * @see ConstantDataSequential::getRawDataValues()
2621 */
2622LLVM_C_ABI const char *LLVMGetRawDataValues(LLVMValueRef c,
2623 size_t *SizeInBytes);
2624
2625/**
2626 * Create an anonymous ConstantStruct with the specified values.
2627 *
2628 * @see llvm::ConstantStruct::getAnon()
2629 */
2630LLVM_C_ABI LLVMValueRef LLVMConstStructInContext(LLVMContextRef C,
2631 LLVMValueRef *ConstantVals,
2632 unsigned Count,
2633 LLVMBool Packed);
2634
2635/**
2636 * Create a ConstantStruct in the global Context.
2637 *
2638 * This is the same as LLVMConstStructInContext except it operates on the
2639 * global Context.
2640 *
2641 * @see LLVMConstStructInContext()
2642 */
2643LLVM_C_ABI LLVM_ATTRIBUTE_C_DEPRECATED(
2644 LLVMValueRef LLVMConstStruct(LLVMValueRef *ConstantVals, unsigned Count,
2645 LLVMBool Packed),
2646 "Use of the global context is deprecated, use LLVMConstStructInContext "
2647 "instead");
2648
2649/**
2650 * Create a ConstantArray from values.
2651 *
2652 * @deprecated LLVMConstArray is deprecated in favor of the API accurate
2653 * LLVMConstArray2
2654 * @see llvm::ConstantArray::get()
2655 */
2656LLVM_C_ABI LLVMValueRef LLVMConstArray(LLVMTypeRef ElementTy,
2657 LLVMValueRef *ConstantVals,
2658 unsigned Length);
2659
2660/**
2661 * Create a ConstantArray from values.
2662 *
2663 * @see llvm::ConstantArray::get()
2664 */
2665LLVM_C_ABI LLVMValueRef LLVMConstArray2(LLVMTypeRef ElementTy,
2666 LLVMValueRef *ConstantVals,
2667 uint64_t Length);
2668
2669/**
2670 * Create a ConstantDataArray from raw values.
2671 *
2672 * ElementTy must be one of i8, i16, i32, i64, half, bfloat, float, or double.
2673 * Data points to a contiguous buffer of raw values in the host endianness. The
2674 * element count is inferred from the element type and the data size in bytes.
2675 *
2676 * @see llvm::ConstantDataArray::getRaw()
2677 */
2678LLVM_C_ABI LLVMValueRef LLVMConstDataArray(LLVMTypeRef ElementTy,
2679 const char *Data,
2680 size_t SizeInBytes);
2681
2682/**
2683 * Create a non-anonymous ConstantStruct from values.
2684 *
2685 * @see llvm::ConstantStruct::get()
2686 */
2687LLVM_C_ABI LLVMValueRef LLVMConstNamedStruct(LLVMTypeRef StructTy,
2688 LLVMValueRef *ConstantVals,
2689 unsigned Count);
2690
2691/**
2692 * Get element of a constant aggregate (struct, array or vector) at the
2693 * specified index. Returns null if the index is out of range, or it's not
2694 * possible to determine the element (e.g., because the constant is a
2695 * constant expression.)
2696 *
2697 * @see llvm::Constant::getAggregateElement()
2698 */
2699LLVM_C_ABI LLVMValueRef LLVMGetAggregateElement(LLVMValueRef C, unsigned Idx);
2700
2701/**
2702 * Get an element at specified index as a constant.
2703 *
2704 * @see ConstantDataSequential::getElementAsConstant()
2705 */
2706LLVM_C_ABI LLVM_ATTRIBUTE_C_DEPRECATED(
2707 LLVMValueRef LLVMGetElementAsConstant(LLVMValueRef C, unsigned idx),
2708 "Use LLVMGetAggregateElement instead");
2709
2710/**
2711 * Create a ConstantVector from values.
2712 *
2713 * @see llvm::ConstantVector::get()
2714 */
2715LLVM_C_ABI LLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals,
2716 unsigned Size);
2717
2718/**
2719 * Create a ConstantPtrAuth constant with the given values.
2720 *
2721 * @see llvm::ConstantPtrAuth::get()
2722 */
2723LLVM_C_ABI LLVMValueRef LLVMConstantPtrAuth(LLVMValueRef Ptr, LLVMValueRef Key,
2724 LLVMValueRef Disc,
2725 LLVMValueRef AddrDisc);
2726
2727/**
2728 * @}
2729 */
2730
2731/**
2732 * @defgroup LLVMCCoreValueConstantExpressions Constant Expressions
2733 *
2734 * Functions in this group correspond to APIs on llvm::ConstantExpr.
2735 *
2736 * @see llvm::ConstantExpr.
2737 *
2738 * @{
2739 */
2740LLVM_C_ABI LLVMOpcode LLVMGetConstOpcode(LLVMValueRef ConstantVal);
2741LLVM_C_ABI LLVMValueRef LLVMAlignOf(LLVMTypeRef Ty);
2742LLVM_C_ABI LLVMValueRef LLVMSizeOf(LLVMTypeRef Ty);
2743LLVM_C_ABI LLVMValueRef LLVMConstNeg(LLVMValueRef ConstantVal);
2744LLVM_C_ABI LLVMValueRef LLVMConstNSWNeg(LLVMValueRef ConstantVal);
2745LLVM_C_ABI LLVM_ATTRIBUTE_C_DEPRECATED(
2746 LLVMValueRef LLVMConstNUWNeg(LLVMValueRef ConstantVal),
2747 "Use LLVMConstNull instead.");
2748LLVM_C_ABI LLVMValueRef LLVMConstNot(LLVMValueRef ConstantVal);
2749LLVM_C_ABI LLVMValueRef LLVMConstAdd(LLVMValueRef LHSConstant,
2750 LLVMValueRef RHSConstant);
2751LLVM_C_ABI LLVMValueRef LLVMConstNSWAdd(LLVMValueRef LHSConstant,
2752 LLVMValueRef RHSConstant);
2753LLVM_C_ABI LLVMValueRef LLVMConstNUWAdd(LLVMValueRef LHSConstant,
2754 LLVMValueRef RHSConstant);
2755LLVM_C_ABI LLVMValueRef LLVMConstSub(LLVMValueRef LHSConstant,
2756 LLVMValueRef RHSConstant);
2757LLVM_C_ABI LLVMValueRef LLVMConstNSWSub(LLVMValueRef LHSConstant,
2758 LLVMValueRef RHSConstant);
2759LLVM_C_ABI LLVMValueRef LLVMConstNUWSub(LLVMValueRef LHSConstant,
2760 LLVMValueRef RHSConstant);
2761LLVM_C_ABI LLVMValueRef LLVMConstXor(LLVMValueRef LHSConstant,
2762 LLVMValueRef RHSConstant);
2763LLVM_C_ABI LLVMValueRef LLVMConstGEP2(LLVMTypeRef Ty, LLVMValueRef ConstantVal,
2764 LLVMValueRef *ConstantIndices,
2765 unsigned NumIndices);
2766LLVM_C_ABI LLVMValueRef LLVMConstInBoundsGEP2(LLVMTypeRef Ty,
2767 LLVMValueRef ConstantVal,
2768 LLVMValueRef *ConstantIndices,
2769 unsigned NumIndices);
2770/**
2771 * Creates a constant GetElementPtr expression. Similar to LLVMConstGEP2, but
2772 * allows specifying the no-wrap flags.
2773 *
2774 * @see llvm::ConstantExpr::getGetElementPtr()
2775 */
2776LLVM_C_ABI LLVMValueRef LLVMConstGEPWithNoWrapFlags(
2777 LLVMTypeRef Ty, LLVMValueRef ConstantVal, LLVMValueRef *ConstantIndices,
2778 unsigned NumIndices, LLVMGEPNoWrapFlags NoWrapFlags);
2779LLVM_C_ABI LLVMValueRef LLVMConstTrunc(LLVMValueRef ConstantVal,
2780 LLVMTypeRef ToType);
2781LLVM_C_ABI LLVMValueRef LLVMConstPtrToInt(LLVMValueRef ConstantVal,
2782 LLVMTypeRef ToType);
2783LLVM_C_ABI LLVMValueRef LLVMConstIntToPtr(LLVMValueRef ConstantVal,
2784 LLVMTypeRef ToType);
2785LLVM_C_ABI LLVMValueRef LLVMConstBitCast(LLVMValueRef ConstantVal,
2786 LLVMTypeRef ToType);
2787LLVM_C_ABI LLVMValueRef LLVMConstAddrSpaceCast(LLVMValueRef ConstantVal,
2788 LLVMTypeRef ToType);
2789LLVM_C_ABI LLVMValueRef LLVMConstTruncOrBitCast(LLVMValueRef ConstantVal,
2790 LLVMTypeRef ToType);
2791LLVM_C_ABI LLVMValueRef LLVMConstPointerCast(LLVMValueRef ConstantVal,
2792 LLVMTypeRef ToType);
2793LLVM_C_ABI LLVMValueRef LLVMConstExtractElement(LLVMValueRef VectorConstant,
2794 LLVMValueRef IndexConstant);
2795LLVM_C_ABI LLVMValueRef LLVMConstInsertElement(
2796 LLVMValueRef VectorConstant, LLVMValueRef ElementValueConstant,
2797 LLVMValueRef IndexConstant);
2798LLVM_C_ABI LLVMValueRef LLVMConstShuffleVector(LLVMValueRef VectorAConstant,
2799 LLVMValueRef VectorBConstant,
2800 LLVMValueRef MaskConstant);
2801LLVM_C_ABI LLVMValueRef LLVMBlockAddress(LLVMValueRef F, LLVMBasicBlockRef BB);
2802
2803/**
2804 * Gets the function associated with a given BlockAddress constant value.
2805 */
2806LLVM_C_ABI LLVMValueRef LLVMGetBlockAddressFunction(LLVMValueRef BlockAddr);
2807
2808/**
2809 * Gets the basic block associated with a given BlockAddress constant value.
2810 */
2811LLVM_C_ABI LLVMBasicBlockRef
2812LLVMGetBlockAddressBasicBlock(LLVMValueRef BlockAddr);
2813
2814/** Deprecated: Use LLVMGetInlineAsm instead. */
2815LLVM_C_ABI LLVMValueRef LLVMConstInlineAsm(LLVMTypeRef Ty,
2816 const char *AsmString,
2817 const char *Constraints,
2818 LLVMBool HasSideEffects,
2819 LLVMBool IsAlignStack);
2820
2821/**
2822 * @}
2823 */
2824
2825/**
2826 * @defgroup LLVMCCoreValueConstantGlobals Global Values
2827 *
2828 * This group contains functions that operate on global values. Functions in
2829 * this group relate to functions in the llvm::GlobalValue class tree.
2830 *
2831 * @see llvm::GlobalValue
2832 *
2833 * @{
2834 */
2835
2836LLVM_C_ABI LLVMModuleRef LLVMGetGlobalParent(LLVMValueRef Global);
2837LLVM_C_ABI LLVMBool LLVMIsDeclaration(LLVMValueRef Global);
2838LLVM_C_ABI LLVMLinkage LLVMGetLinkage(LLVMValueRef Global);
2839LLVM_C_ABI void LLVMSetLinkage(LLVMValueRef Global, LLVMLinkage Linkage);
2840LLVM_C_ABI const char *LLVMGetSection(LLVMValueRef Global);
2841LLVM_C_ABI void LLVMSetSection(LLVMValueRef Global, const char *Section);
2842LLVM_C_ABI LLVMVisibility LLVMGetVisibility(LLVMValueRef Global);
2843LLVM_C_ABI void LLVMSetVisibility(LLVMValueRef Global, LLVMVisibility Viz);
2844LLVM_C_ABI LLVMDLLStorageClass LLVMGetDLLStorageClass(LLVMValueRef Global);
2845LLVM_C_ABI void LLVMSetDLLStorageClass(LLVMValueRef Global,
2846 LLVMDLLStorageClass Class);
2847LLVM_C_ABI LLVMUnnamedAddr LLVMGetUnnamedAddress(LLVMValueRef Global);
2848LLVM_C_ABI void LLVMSetUnnamedAddress(LLVMValueRef Global,
2849 LLVMUnnamedAddr UnnamedAddr);
2850
2851/**
2852 * Returns the "value type" of a global value. This differs from the formal
2853 * type of a global value which is always a pointer type.
2854 *
2855 * @see llvm::GlobalValue::getValueType()
2856 * @see llvm::Function::getFunctionType()
2857 */
2858LLVM_C_ABI LLVMTypeRef LLVMGlobalGetValueType(LLVMValueRef Global);
2859
2860/** Deprecated: Use LLVMGetUnnamedAddress instead. */
2861LLVM_C_ABI LLVMBool LLVMHasUnnamedAddr(LLVMValueRef Global);
2862/** Deprecated: Use LLVMSetUnnamedAddress instead. */
2863LLVM_C_ABI void LLVMSetUnnamedAddr(LLVMValueRef Global,
2864 LLVMBool HasUnnamedAddr);
2865
2866/**
2867 * @defgroup LLVMCCoreValueWithAlignment Values with alignment
2868 *
2869 * Functions in this group only apply to values with alignment, i.e.
2870 * global variables, load and store instructions.
2871 */
2872
2873/**
2874 * Obtain the preferred alignment of the value.
2875 * @see llvm::AllocaInst::getAlignment()
2876 * @see llvm::LoadInst::getAlignment()
2877 * @see llvm::StoreInst::getAlignment()
2878 * @see llvm::AtomicRMWInst::setAlignment()
2879 * @see llvm::AtomicCmpXchgInst::setAlignment()
2880 * @see llvm::GlobalValue::getAlignment()
2881 */
2882LLVM_C_ABI unsigned LLVMGetAlignment(LLVMValueRef V);
2883
2884/**
2885 * Set the preferred alignment of the value.
2886 * @see llvm::AllocaInst::setAlignment()
2887 * @see llvm::LoadInst::setAlignment()
2888 * @see llvm::StoreInst::setAlignment()
2889 * @see llvm::AtomicRMWInst::setAlignment()
2890 * @see llvm::AtomicCmpXchgInst::setAlignment()
2891 * @see llvm::GlobalValue::setAlignment()
2892 */
2893LLVM_C_ABI void LLVMSetAlignment(LLVMValueRef V, unsigned Bytes);
2894
2895/**
2896 * Sets a metadata attachment, erasing the existing metadata attachment if
2897 * it already exists for the given kind.
2898 *
2899 * @see llvm::GlobalObject::setMetadata()
2900 */
2901LLVM_C_ABI void LLVMGlobalSetMetadata(LLVMValueRef Global, unsigned Kind,
2902 LLVMMetadataRef MD);
2903
2904/**
2905 * Adds a metadata attachment.
2906 *
2907 * @see llvm::GlobalObject::addMetadata()
2908 */
2909LLVM_C_ABI void LLVMGlobalAddMetadata(LLVMValueRef Global, unsigned Kind,
2910 LLVMMetadataRef MD);
2911
2912/**
2913 * Erases a metadata attachment of the given kind if it exists.
2914 *
2915 * @see llvm::GlobalObject::eraseMetadata()
2916 */
2917LLVM_C_ABI void LLVMGlobalEraseMetadata(LLVMValueRef Global, unsigned Kind);
2918
2919/**
2920 * Removes all metadata attachments from this value.
2921 *
2922 * @see llvm::GlobalObject::clearMetadata()
2923 */
2924LLVM_C_ABI void LLVMGlobalClearMetadata(LLVMValueRef Global);
2925
2926/**
2927 * Add debuginfo metadata to this global.
2928 *
2929 * @see llvm::GlobalVariable::addDebugInfo()
2930 */
2931LLVM_C_ABI void LLVMGlobalAddDebugInfo(LLVMValueRef Global,
2932 LLVMMetadataRef GVE);
2933
2934/**
2935 * Retrieves an array of metadata entries representing the metadata attached to
2936 * this value. The caller is responsible for freeing this array by calling
2937 * \c LLVMDisposeValueMetadataEntries.
2938 *
2939 * @see llvm::GlobalObject::getAllMetadata()
2940 */
2941LLVM_C_ABI LLVMValueMetadataEntry *
2942LLVMGlobalCopyAllMetadata(LLVMValueRef Value, size_t *NumEntries);
2943
2944/**
2945 * Destroys value metadata entries.
2946 */
2947LLVM_C_ABI void
2948LLVMDisposeValueMetadataEntries(LLVMValueMetadataEntry *Entries);
2949
2950/**
2951 * Returns the kind of a value metadata entry at a specific index.
2952 */
2953LLVM_C_ABI unsigned
2954LLVMValueMetadataEntriesGetKind(LLVMValueMetadataEntry *Entries,
2955 unsigned Index);
2956
2957/**
2958 * Returns the underlying metadata node of a value metadata entry at a
2959 * specific index.
2960 */
2961LLVM_C_ABI LLVMMetadataRef LLVMValueMetadataEntriesGetMetadata(
2962 LLVMValueMetadataEntry *Entries, unsigned Index);
2963
2964/**
2965 * @}
2966 */
2967
2968/**
2969 * @defgroup LLVMCoreValueConstantGlobalVariable Global Variables
2970 *
2971 * This group contains functions that operate on global variable values.
2972 *
2973 * @see llvm::GlobalVariable
2974 *
2975 * @{
2976 */
2977LLVM_C_ABI LLVMValueRef LLVMAddGlobal(LLVMModuleRef M, LLVMTypeRef Ty,
2978 const char *Name);
2979LLVM_C_ABI LLVMValueRef LLVMAddGlobalInAddressSpace(LLVMModuleRef M,
2980 LLVMTypeRef Ty,
2981 const char *Name,
2982 unsigned AddressSpace);
2983LLVM_C_ABI LLVMValueRef LLVMGetNamedGlobal(LLVMModuleRef M, const char *Name);
2984LLVM_C_ABI LLVMValueRef LLVMGetNamedGlobalWithLength(LLVMModuleRef M,
2985 const char *Name,
2986 size_t Length);
2987LLVM_C_ABI LLVMValueRef LLVMGetFirstGlobal(LLVMModuleRef M);
2988LLVM_C_ABI LLVMValueRef LLVMGetLastGlobal(LLVMModuleRef M);
2989LLVM_C_ABI LLVMValueRef LLVMGetNextGlobal(LLVMValueRef GlobalVar);
2990LLVM_C_ABI LLVMValueRef LLVMGetPreviousGlobal(LLVMValueRef GlobalVar);
2991LLVM_C_ABI void LLVMDeleteGlobal(LLVMValueRef GlobalVar);
2992LLVM_C_ABI LLVMValueRef LLVMGetInitializer(LLVMValueRef GlobalVar);
2993LLVM_C_ABI void LLVMSetInitializer(LLVMValueRef GlobalVar,
2994 LLVMValueRef ConstantVal);
2995LLVM_C_ABI LLVMBool LLVMIsThreadLocal(LLVMValueRef GlobalVar);
2996LLVM_C_ABI void LLVMSetThreadLocal(LLVMValueRef GlobalVar,
2997 LLVMBool IsThreadLocal);
2998LLVM_C_ABI LLVMBool LLVMIsGlobalConstant(LLVMValueRef GlobalVar);
2999LLVM_C_ABI void LLVMSetGlobalConstant(LLVMValueRef GlobalVar,
3000 LLVMBool IsConstant);
3001LLVM_C_ABI LLVMThreadLocalMode LLVMGetThreadLocalMode(LLVMValueRef GlobalVar);
3002LLVM_C_ABI void LLVMSetThreadLocalMode(LLVMValueRef GlobalVar,
3003 LLVMThreadLocalMode Mode);
3004LLVM_C_ABI LLVMBool LLVMIsExternallyInitialized(LLVMValueRef GlobalVar);
3005LLVM_C_ABI void LLVMSetExternallyInitialized(LLVMValueRef GlobalVar,
3006 LLVMBool IsExtInit);
3007
3008/**
3009 * @}
3010 */
3011
3012/**
3013 * @defgroup LLVMCoreValueConstantGlobalAlias Global Aliases
3014 *
3015 * This group contains function that operate on global alias values.
3016 *
3017 * @see llvm::GlobalAlias
3018 *
3019 * @{
3020 */
3021
3022/**
3023 * Add a GlobalAlias with the given value type, address space and aliasee.
3024 *
3025 * @see llvm::GlobalAlias::create()
3026 */
3027LLVM_C_ABI LLVMValueRef LLVMAddAlias2(LLVMModuleRef M, LLVMTypeRef ValueTy,
3028 unsigned AddrSpace, LLVMValueRef Aliasee,
3029 const char *Name);
3030
3031/**
3032 * Obtain a GlobalAlias value from a Module by its name.
3033 *
3034 * The returned value corresponds to a llvm::GlobalAlias value.
3035 *
3036 * @see llvm::Module::getNamedAlias()
3037 */
3038LLVM_C_ABI LLVMValueRef LLVMGetNamedGlobalAlias(LLVMModuleRef M,
3039 const char *Name,
3040 size_t NameLen);
3041
3042/**
3043 * Obtain an iterator to the first GlobalAlias in a Module.
3044 *
3045 * @see llvm::Module::alias_begin()
3046 */
3047LLVM_C_ABI LLVMValueRef LLVMGetFirstGlobalAlias(LLVMModuleRef M);
3048
3049/**
3050 * Obtain an iterator to the last GlobalAlias in a Module.
3051 *
3052 * @see llvm::Module::alias_end()
3053 */
3054LLVM_C_ABI LLVMValueRef LLVMGetLastGlobalAlias(LLVMModuleRef M);
3055
3056/**
3057 * Advance a GlobalAlias iterator to the next GlobalAlias.
3058 *
3059 * Returns NULL if the iterator was already at the end and there are no more
3060 * global aliases.
3061 */
3062LLVM_C_ABI LLVMValueRef LLVMGetNextGlobalAlias(LLVMValueRef GA);
3063
3064/**
3065 * Decrement a GlobalAlias iterator to the previous GlobalAlias.
3066 *
3067 * Returns NULL if the iterator was already at the beginning and there are
3068 * no previous global aliases.
3069 */
3070LLVM_C_ABI LLVMValueRef LLVMGetPreviousGlobalAlias(LLVMValueRef GA);
3071
3072/**
3073 * Retrieve the target value of an alias.
3074 */
3075LLVM_C_ABI LLVMValueRef LLVMAliasGetAliasee(LLVMValueRef Alias);
3076
3077/**
3078 * Set the target value of an alias.
3079 */
3080LLVM_C_ABI void LLVMAliasSetAliasee(LLVMValueRef Alias, LLVMValueRef Aliasee);
3081
3082/**
3083 * @}
3084 */
3085
3086/**
3087 * @defgroup LLVMCCoreValueFunction Function values
3088 *
3089 * Functions in this group operate on LLVMValueRef instances that
3090 * correspond to llvm::Function instances.
3091 *
3092 * @see llvm::Function
3093 *
3094 * @{
3095 */
3096
3097/**
3098 * Remove a function from its containing module and deletes it.
3099 *
3100 * @see llvm::Function::eraseFromParent()
3101 */
3102LLVM_C_ABI void LLVMDeleteFunction(LLVMValueRef Fn);
3103
3104/**
3105 * Check whether the given function has a personality function.
3106 *
3107 * @see llvm::Function::hasPersonalityFn()
3108 */
3109LLVM_C_ABI LLVMBool LLVMHasPersonalityFn(LLVMValueRef Fn);
3110
3111/**
3112 * Obtain the personality function attached to the function.
3113 *
3114 * @see llvm::Function::getPersonalityFn()
3115 */
3116LLVM_C_ABI LLVMValueRef LLVMGetPersonalityFn(LLVMValueRef Fn);
3117
3118/**
3119 * Set the personality function attached to the function.
3120 *
3121 * @see llvm::Function::setPersonalityFn()
3122 */
3123LLVM_C_ABI void LLVMSetPersonalityFn(LLVMValueRef Fn,
3124 LLVMValueRef PersonalityFn);
3125
3126/**
3127 * Obtain the intrinsic ID number which matches the given function name.
3128 *
3129 * @see llvm::Intrinsic::lookupIntrinsicID()
3130 */
3131LLVM_C_ABI unsigned LLVMLookupIntrinsicID(const char *Name, size_t NameLen);
3132
3133/**
3134 * Obtain the ID number from a function instance.
3135 *
3136 * @see llvm::Function::getIntrinsicID()
3137 */
3138LLVM_C_ABI unsigned LLVMGetIntrinsicID(LLVMValueRef Fn);
3139
3140/**
3141 * Get or insert the declaration of an intrinsic. For overloaded intrinsics,
3142 * parameter types must be provided to uniquely identify an overload.
3143 *
3144 * @see llvm::Intrinsic::getOrInsertDeclaration()
3145 */
3146LLVM_C_ABI LLVMValueRef LLVMGetIntrinsicDeclaration(LLVMModuleRef Mod,
3147 unsigned ID,
3148 LLVMTypeRef *ParamTypes,
3149 size_t ParamCount);
3150
3151/**
3152 * Retrieves the type of an intrinsic. For overloaded intrinsics, parameter
3153 * types must be provided to uniquely identify an overload.
3154 *
3155 * @see llvm::Intrinsic::getType()
3156 */
3157LLVM_C_ABI LLVMTypeRef LLVMIntrinsicGetType(LLVMContextRef Ctx, unsigned ID,
3158 LLVMTypeRef *ParamTypes,
3159 size_t ParamCount);
3160
3161/**
3162 * Retrieves the name of an intrinsic.
3163 *
3164 * @see llvm::Intrinsic::getName()
3165 */
3166LLVM_C_ABI const char *LLVMIntrinsicGetName(unsigned ID, size_t *NameLength);
3167
3168/** Deprecated: Use LLVMIntrinsicCopyOverloadedName2 instead. */
3169LLVM_C_ABI char *LLVMIntrinsicCopyOverloadedName(unsigned ID,
3170 LLVMTypeRef *ParamTypes,
3171 size_t ParamCount,
3172 size_t *NameLength);
3173
3174/**
3175 * Copies the name of an overloaded intrinsic identified by a given list of
3176 * parameter types.
3177 *
3178 * Unlike LLVMIntrinsicGetName, the caller is responsible for freeing the
3179 * returned string.
3180 *
3181 * This version also supports unnamed types.
3182 *
3183 * @see llvm::Intrinsic::getName()
3184 */
3185LLVM_C_ABI char *LLVMIntrinsicCopyOverloadedName2(LLVMModuleRef Mod,
3186 unsigned ID,
3187 LLVMTypeRef *ParamTypes,
3188 size_t ParamCount,
3189 size_t *NameLength);
3190
3191/**
3192 * Obtain if the intrinsic identified by the given ID is overloaded.
3193 *
3194 * @see llvm::Intrinsic::isOverloaded()
3195 */
3196LLVM_C_ABI LLVMBool LLVMIntrinsicIsOverloaded(unsigned ID);
3197
3198/**
3199 * Obtain the calling function of a function.
3200 *
3201 * The returned value corresponds to the LLVMCallConv enumeration.
3202 *
3203 * @see llvm::Function::getCallingConv()
3204 */
3205LLVM_C_ABI unsigned LLVMGetFunctionCallConv(LLVMValueRef Fn);
3206
3207/**
3208 * Set the calling convention of a function.
3209 *
3210 * @see llvm::Function::setCallingConv()
3211 *
3212 * @param Fn Function to operate on
3213 * @param CC LLVMCallConv to set calling convention to
3214 */
3215LLVM_C_ABI void LLVMSetFunctionCallConv(LLVMValueRef Fn, unsigned CC);
3216
3217/**
3218 * Obtain the name of the garbage collector to use during code
3219 * generation.
3220 *
3221 * @see llvm::Function::getGC()
3222 */
3223LLVM_C_ABI const char *LLVMGetGC(LLVMValueRef Fn);
3224
3225/**
3226 * Define the garbage collector to use during code generation.
3227 *
3228 * @see llvm::Function::setGC()
3229 */
3230LLVM_C_ABI void LLVMSetGC(LLVMValueRef Fn, const char *Name);
3231
3232/**
3233 * Gets the prefix data associated with a function. Only valid on functions, and
3234 * only if LLVMHasPrefixData returns true.
3235 * See https://llvm.org/docs/LangRef.html#prefix-data
3236 */
3237LLVM_C_ABI LLVMValueRef LLVMGetPrefixData(LLVMValueRef Fn);
3238
3239/**
3240 * Check if a given function has prefix data. Only valid on functions.
3241 * See https://llvm.org/docs/LangRef.html#prefix-data
3242 */
3243LLVM_C_ABI LLVMBool LLVMHasPrefixData(LLVMValueRef Fn);
3244
3245/**
3246 * Sets the prefix data for the function. Only valid on functions.
3247 * See https://llvm.org/docs/LangRef.html#prefix-data
3248 */
3249LLVM_C_ABI void LLVMSetPrefixData(LLVMValueRef Fn, LLVMValueRef prefixData);
3250
3251/**
3252 * Gets the prologue data associated with a function. Only valid on functions,
3253 * and only if LLVMHasPrologueData returns true.
3254 * See https://llvm.org/docs/LangRef.html#prologue-data
3255 */
3256LLVM_C_ABI LLVMValueRef LLVMGetPrologueData(LLVMValueRef Fn);
3257
3258/**
3259 * Check if a given function has prologue data. Only valid on functions.
3260 * See https://llvm.org/docs/LangRef.html#prologue-data
3261 */
3262LLVM_C_ABI LLVMBool LLVMHasPrologueData(LLVMValueRef Fn);
3263
3264/**
3265 * Sets the prologue data for the function. Only valid on functions.
3266 * See https://llvm.org/docs/LangRef.html#prologue-data
3267 */
3268LLVM_C_ABI void LLVMSetPrologueData(LLVMValueRef Fn, LLVMValueRef prologueData);
3269
3270/**
3271 * Add an attribute to a function.
3272 *
3273 * @see llvm::Function::addAttribute()
3274 */
3275LLVM_C_ABI void LLVMAddAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx,
3276 LLVMAttributeRef A);
3277LLVM_C_ABI unsigned LLVMGetAttributeCountAtIndex(LLVMValueRef F,
3278 LLVMAttributeIndex Idx);
3279LLVM_C_ABI void LLVMGetAttributesAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx,
3280 LLVMAttributeRef *Attrs);
3281LLVM_C_ABI LLVMAttributeRef LLVMGetEnumAttributeAtIndex(LLVMValueRef F,
3282 LLVMAttributeIndex Idx,
3283 unsigned KindID);
3284LLVM_C_ABI LLVMAttributeRef LLVMGetStringAttributeAtIndex(
3285 LLVMValueRef F, LLVMAttributeIndex Idx, const char *K, unsigned KLen);
3286LLVM_C_ABI void LLVMRemoveEnumAttributeAtIndex(LLVMValueRef F,
3287 LLVMAttributeIndex Idx,
3288 unsigned KindID);
3289LLVM_C_ABI void LLVMRemoveStringAttributeAtIndex(LLVMValueRef F,
3290 LLVMAttributeIndex Idx,
3291 const char *K, unsigned KLen);
3292
3293/**
3294 * Add a target-dependent attribute to a function
3295 * @see llvm::AttrBuilder::addAttribute()
3296 */
3297LLVM_C_ABI void LLVMAddTargetDependentFunctionAttr(LLVMValueRef Fn,
3298 const char *A,
3299 const char *V);
3300
3301/**
3302 * @defgroup LLVMCCoreValueFunctionParameters Function Parameters
3303 *
3304 * Functions in this group relate to arguments/parameters on functions.
3305 *
3306 * Functions in this group expect LLVMValueRef instances that correspond
3307 * to llvm::Function instances.
3308 *
3309 * @{
3310 */
3311
3312/**
3313 * Obtain the number of parameters in a function.
3314 *
3315 * @see llvm::Function::arg_size()
3316 */
3317LLVM_C_ABI unsigned LLVMCountParams(LLVMValueRef Fn);
3318
3319/**
3320 * Obtain the parameters in a function.
3321 *
3322 * The takes a pointer to a pre-allocated array of LLVMValueRef that is
3323 * at least LLVMCountParams() long. This array will be filled with
3324 * LLVMValueRef instances which correspond to the parameters the
3325 * function receives. Each LLVMValueRef corresponds to a llvm::Argument
3326 * instance.
3327 *
3328 * @see llvm::Function::arg_begin()
3329 */
3330LLVM_C_ABI void LLVMGetParams(LLVMValueRef Fn, LLVMValueRef *Params);
3331
3332/**
3333 * Obtain the parameter at the specified index.
3334 *
3335 * Parameters are indexed from 0.
3336 *
3337 * @see llvm::Function::arg_begin()
3338 */
3339LLVM_C_ABI LLVMValueRef LLVMGetParam(LLVMValueRef Fn, unsigned Index);
3340
3341/**
3342 * Obtain the function to which this argument belongs.
3343 *
3344 * Unlike other functions in this group, this one takes an LLVMValueRef
3345 * that corresponds to a llvm::Attribute.
3346 *
3347 * The returned LLVMValueRef is the llvm::Function to which this
3348 * argument belongs.
3349 */
3350LLVM_C_ABI LLVMValueRef LLVMGetParamParent(LLVMValueRef Inst);
3351
3352/**
3353 * Obtain the first parameter to a function.
3354 *
3355 * @see llvm::Function::arg_begin()
3356 */
3357LLVM_C_ABI LLVMValueRef LLVMGetFirstParam(LLVMValueRef Fn);
3358
3359/**
3360 * Obtain the last parameter to a function.
3361 *
3362 * @see llvm::Function::arg_end()
3363 */
3364LLVM_C_ABI LLVMValueRef LLVMGetLastParam(LLVMValueRef Fn);
3365
3366/**
3367 * Obtain the next parameter to a function.
3368 *
3369 * This takes an LLVMValueRef obtained from LLVMGetFirstParam() (which is
3370 * actually a wrapped iterator) and obtains the next parameter from the
3371 * underlying iterator.
3372 */
3373LLVM_C_ABI LLVMValueRef LLVMGetNextParam(LLVMValueRef Arg);
3374
3375/**
3376 * Obtain the previous parameter to a function.
3377 *
3378 * This is the opposite of LLVMGetNextParam().
3379 */
3380LLVM_C_ABI LLVMValueRef LLVMGetPreviousParam(LLVMValueRef Arg);
3381
3382/**
3383 * Set the alignment for a function parameter.
3384 *
3385 * @see llvm::Argument::addAttr()
3386 * @see llvm::AttrBuilder::addAlignmentAttr()
3387 */
3388LLVM_C_ABI void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned Align);
3389
3390/**
3391 * @}
3392 */
3393
3394/**
3395 * @defgroup LLVMCCoreValueGlobalIFunc IFuncs
3396 *
3397 * Functions in this group relate to indirect functions.
3398 *
3399 * Functions in this group expect LLVMValueRef instances that correspond
3400 * to llvm::GlobalIFunc instances.
3401 *
3402 * @{
3403 */
3404
3405/**
3406 * Add a global indirect function to a module under a specified name.
3407 *
3408 * @see llvm::GlobalIFunc::create()
3409 */
3410LLVM_C_ABI LLVMValueRef LLVMAddGlobalIFunc(LLVMModuleRef M, const char *Name,
3411 size_t NameLen, LLVMTypeRef Ty,
3412 unsigned AddrSpace,
3413 LLVMValueRef Resolver);
3414
3415/**
3416 * Obtain a GlobalIFunc value from a Module by its name.
3417 *
3418 * The returned value corresponds to a llvm::GlobalIFunc value.
3419 *
3420 * @see llvm::Module::getNamedIFunc()
3421 */
3422LLVM_C_ABI LLVMValueRef LLVMGetNamedGlobalIFunc(LLVMModuleRef M,
3423 const char *Name,
3424 size_t NameLen);
3425
3426/**
3427 * Obtain an iterator to the first GlobalIFunc in a Module.
3428 *
3429 * @see llvm::Module::ifunc_begin()
3430 */
3431LLVM_C_ABI LLVMValueRef LLVMGetFirstGlobalIFunc(LLVMModuleRef M);
3432
3433/**
3434 * Obtain an iterator to the last GlobalIFunc in a Module.
3435 *
3436 * @see llvm::Module::ifunc_end()
3437 */
3438LLVM_C_ABI LLVMValueRef LLVMGetLastGlobalIFunc(LLVMModuleRef M);
3439
3440/**
3441 * Advance a GlobalIFunc iterator to the next GlobalIFunc.
3442 *
3443 * Returns NULL if the iterator was already at the end and there are no more
3444 * global aliases.
3445 */
3446LLVM_C_ABI LLVMValueRef LLVMGetNextGlobalIFunc(LLVMValueRef IFunc);
3447
3448/**
3449 * Decrement a GlobalIFunc iterator to the previous GlobalIFunc.
3450 *
3451 * Returns NULL if the iterator was already at the beginning and there are
3452 * no previous global aliases.
3453 */
3454LLVM_C_ABI LLVMValueRef LLVMGetPreviousGlobalIFunc(LLVMValueRef IFunc);
3455
3456/**
3457 * Retrieves the resolver function associated with this indirect function, or
3458 * NULL if it doesn't not exist.
3459 *
3460 * @see llvm::GlobalIFunc::getResolver()
3461 */
3462LLVM_C_ABI LLVMValueRef LLVMGetGlobalIFuncResolver(LLVMValueRef IFunc);
3463
3464/**
3465 * Sets the resolver function associated with this indirect function.
3466 *
3467 * @see llvm::GlobalIFunc::setResolver()
3468 */
3469LLVM_C_ABI void LLVMSetGlobalIFuncResolver(LLVMValueRef IFunc,
3470 LLVMValueRef Resolver);
3471
3472/**
3473 * Remove a global indirect function from its parent module and delete it.
3474 *
3475 * @see llvm::GlobalIFunc::eraseFromParent()
3476 */
3477LLVM_C_ABI void LLVMEraseGlobalIFunc(LLVMValueRef IFunc);
3478
3479/**
3480 * Remove a global indirect function from its parent module.
3481 *
3482 * This unlinks the global indirect function from its containing module but
3483 * keeps it alive.
3484 *
3485 * @see llvm::GlobalIFunc::removeFromParent()
3486 */
3487LLVM_C_ABI void LLVMRemoveGlobalIFunc(LLVMValueRef IFunc);
3488
3489/**
3490 * @}
3491 */
3492
3493/**
3494 * @}
3495 */
3496
3497/**
3498 * @}
3499 */
3500
3501/**
3502 * @}
3503 */
3504
3505/**
3506 * @defgroup LLVMCCoreValueMetadata Metadata
3507 *
3508 * @{
3509 */
3510
3511/**
3512 * Create an MDString value from a given string value.
3513 *
3514 * The MDString value does not take ownership of the given string, it remains
3515 * the responsibility of the caller to free it.
3516 *
3517 * @see llvm::MDString::get()
3518 */
3519LLVM_C_ABI LLVMMetadataRef LLVMMDStringInContext2(LLVMContextRef C,
3520 const char *Str, size_t SLen);
3521
3522/**
3523 * Create an MDNode value with the given array of operands.
3524 *
3525 * @see llvm::MDNode::get()
3526 */
3527LLVM_C_ABI LLVMMetadataRef LLVMMDNodeInContext2(LLVMContextRef C,
3528 LLVMMetadataRef *MDs,
3529 size_t Count);
3530
3531/**
3532 * Obtain a Metadata as a Value.
3533 */
3534LLVM_C_ABI LLVMValueRef LLVMMetadataAsValue(LLVMContextRef C,
3535 LLVMMetadataRef MD);
3536
3537/**
3538 * Obtain a Value as a Metadata.
3539 */
3540LLVM_C_ABI LLVMMetadataRef LLVMValueAsMetadata(LLVMValueRef Val);
3541
3542/**
3543 * Obtain the underlying string from a MDString value.
3544 *
3545 * @param V Instance to obtain string from.
3546 * @param Length Memory address which will hold length of returned string.
3547 * @return String data in MDString.
3548 */
3549LLVM_C_ABI const char *LLVMGetMDString(LLVMValueRef V, unsigned *Length);
3550
3551/**
3552 * Obtain the number of operands from an MDNode value.
3553 *
3554 * @param V MDNode to get number of operands from.
3555 * @return Number of operands of the MDNode.
3556 */
3557LLVM_C_ABI unsigned LLVMGetMDNodeNumOperands(LLVMValueRef V);
3558
3559/**
3560 * Obtain the given MDNode's operands.
3561 *
3562 * The passed LLVMValueRef pointer should point to enough memory to hold all of
3563 * the operands of the given MDNode (see LLVMGetMDNodeNumOperands) as
3564 * LLVMValueRefs. This memory will be populated with the LLVMValueRefs of the
3565 * MDNode's operands.
3566 *
3567 * @param V MDNode to get the operands from.
3568 * @param Dest Destination array for operands.
3569 */
3570LLVM_C_ABI void LLVMGetMDNodeOperands(LLVMValueRef V, LLVMValueRef *Dest);
3571
3572/**
3573 * Replace an operand at a specific index in a llvm::MDNode value.
3574 *
3575 * @see llvm::MDNode::replaceOperandWith()
3576 */
3577LLVM_C_ABI void LLVMReplaceMDNodeOperandWith(LLVMValueRef V, unsigned Index,
3578 LLVMMetadataRef Replacement);
3579
3580/** Deprecated: Use LLVMMDStringInContext2 instead. */
3581LLVM_C_ABI LLVMValueRef LLVMMDStringInContext(LLVMContextRef C, const char *Str,
3582 unsigned SLen);
3583/** Deprecated: Use LLVMMDStringInContext2 instead. */
3584LLVM_C_ABI LLVM_ATTRIBUTE_C_DEPRECATED(
3585 LLVMValueRef LLVMMDString(const char *Str, unsigned SLen),
3586 "Use of the global context is deprecated, use LLVMMDStringInContext2 "
3587 "instead");
3588/** Deprecated: Use LLVMMDNodeInContext2 instead. */
3589LLVM_C_ABI LLVMValueRef LLVMMDNodeInContext(LLVMContextRef C,
3590 LLVMValueRef *Vals, unsigned Count);
3591/** Deprecated: Use LLVMMDNodeInContext2 instead. */
3592LLVM_C_ABI LLVM_ATTRIBUTE_C_DEPRECATED(
3593 LLVMValueRef LLVMMDNode(LLVMValueRef *Vals, unsigned Count),
3594 "Use of the global context is deprecated, use LLVMMDNodeInContext2 "
3595 "instead");
3596
3597/**
3598 * @}
3599 */
3600
3601/**
3602 * @defgroup LLVMCCoreOperandBundle Operand Bundles
3603 *
3604 * Functions in this group operate on LLVMOperandBundleRef instances that
3605 * correspond to llvm::OperandBundleDef instances.
3606 *
3607 * @see llvm::OperandBundleDef
3608 *
3609 * @{
3610 */
3611
3612/**
3613 * Create a new operand bundle.
3614 *
3615 * Every invocation should be paired with LLVMDisposeOperandBundle() or memory
3616 * will be leaked.
3617 *
3618 * @param Tag Tag name of the operand bundle
3619 * @param TagLen Length of Tag
3620 * @param Args Memory address of an array of bundle operands
3621 * @param NumArgs Length of Args
3622 */
3623LLVM_C_ABI LLVMOperandBundleRef LLVMCreateOperandBundle(const char *Tag,
3624 size_t TagLen,
3625 LLVMValueRef *Args,
3626 unsigned NumArgs);
3627
3628/**
3629 * Destroy an operand bundle.
3630 *
3631 * This must be called for every created operand bundle or memory will be
3632 * leaked.
3633 */
3634LLVM_C_ABI void LLVMDisposeOperandBundle(LLVMOperandBundleRef Bundle);
3635
3636/**
3637 * Obtain the tag of an operand bundle as a string.
3638 *
3639 * @param Bundle Operand bundle to obtain tag of.
3640 * @param Len Out parameter which holds the length of the returned string.
3641 * @return The tag name of Bundle.
3642 * @see OperandBundleDef::getTag()
3643 */
3644LLVM_C_ABI const char *LLVMGetOperandBundleTag(LLVMOperandBundleRef Bundle,
3645 size_t *Len);
3646
3647/**
3648 * Obtain the number of operands for an operand bundle.
3649 *
3650 * @param Bundle Operand bundle to obtain operand count of.
3651 * @return The number of operands.
3652 * @see OperandBundleDef::input_size()
3653 */
3654LLVM_C_ABI unsigned LLVMGetNumOperandBundleArgs(LLVMOperandBundleRef Bundle);
3655
3656/**
3657 * Obtain the operand for an operand bundle at the given index.
3658 *
3659 * @param Bundle Operand bundle to obtain operand of.
3660 * @param Index An operand index, must be less than
3661 * LLVMGetNumOperandBundleArgs().
3662 * @return The operand.
3663 */
3664LLVM_C_ABI LLVMValueRef
3665LLVMGetOperandBundleArgAtIndex(LLVMOperandBundleRef Bundle, unsigned Index);
3666
3667/**
3668 * @}
3669 */
3670
3671/**
3672 * @defgroup LLVMCCoreValueBasicBlock Basic Block
3673 *
3674 * A basic block represents a single entry single exit section of code.
3675 * Basic blocks contain a list of instructions which form the body of
3676 * the block.
3677 *
3678 * Basic blocks belong to functions. They have the type of label.
3679 *
3680 * Basic blocks are themselves values. However, the C API models them as
3681 * LLVMBasicBlockRef.
3682 *
3683 * @see llvm::BasicBlock
3684 *
3685 * @{
3686 */
3687
3688/**
3689 * Convert a basic block instance to a value type.
3690 */
3691LLVM_C_ABI LLVMValueRef LLVMBasicBlockAsValue(LLVMBasicBlockRef BB);
3692
3693/**
3694 * Determine whether an LLVMValueRef is itself a basic block.
3695 */
3696LLVM_C_ABI LLVMBool LLVMValueIsBasicBlock(LLVMValueRef Val);
3697
3698/**
3699 * Convert an LLVMValueRef to an LLVMBasicBlockRef instance.
3700 */
3701LLVM_C_ABI LLVMBasicBlockRef LLVMValueAsBasicBlock(LLVMValueRef Val);
3702
3703/**
3704 * Obtain the string name of a basic block.
3705 */
3706LLVM_C_ABI const char *LLVMGetBasicBlockName(LLVMBasicBlockRef BB);
3707
3708/**
3709 * Obtain the function to which a basic block belongs.
3710 *
3711 * @see llvm::BasicBlock::getParent()
3712 */
3713LLVM_C_ABI LLVMValueRef LLVMGetBasicBlockParent(LLVMBasicBlockRef BB);
3714
3715/**
3716 * Obtain the terminator instruction for a basic block.
3717 *
3718 * If the basic block does not have a terminator (it is not well-formed
3719 * if it doesn't), then NULL is returned.
3720 *
3721 * The returned LLVMValueRef corresponds to an llvm::Instruction.
3722 *
3723 * @see llvm::BasicBlock::getTerminator()
3724 */
3725LLVM_C_ABI LLVMValueRef LLVMGetBasicBlockTerminator(LLVMBasicBlockRef BB);
3726
3727/**
3728 * Obtain the number of basic blocks in a function.
3729 *
3730 * @param Fn Function value to operate on.
3731 */
3732LLVM_C_ABI unsigned LLVMCountBasicBlocks(LLVMValueRef Fn);
3733
3734/**
3735 * Obtain all of the basic blocks in a function.
3736 *
3737 * This operates on a function value. The BasicBlocks parameter is a
3738 * pointer to a pre-allocated array of LLVMBasicBlockRef of at least
3739 * LLVMCountBasicBlocks() in length. This array is populated with
3740 * LLVMBasicBlockRef instances.
3741 */
3742LLVM_C_ABI void LLVMGetBasicBlocks(LLVMValueRef Fn,
3743 LLVMBasicBlockRef *BasicBlocks);
3744
3745/**
3746 * Obtain the first basic block in a function.
3747 *
3748 * The returned basic block can be used as an iterator. You will likely
3749 * eventually call into LLVMGetNextBasicBlock() with it.
3750 *
3751 * @see llvm::Function::begin()
3752 */
3753LLVM_C_ABI LLVMBasicBlockRef LLVMGetFirstBasicBlock(LLVMValueRef Fn);
3754
3755/**
3756 * Obtain the last basic block in a function.
3757 *
3758 * @see llvm::Function::end()
3759 */
3760LLVM_C_ABI LLVMBasicBlockRef LLVMGetLastBasicBlock(LLVMValueRef Fn);
3761
3762/**
3763 * Advance a basic block iterator.
3764 */
3765LLVM_C_ABI LLVMBasicBlockRef LLVMGetNextBasicBlock(LLVMBasicBlockRef BB);
3766
3767/**
3768 * Go backwards in a basic block iterator.
3769 */
3770LLVM_C_ABI LLVMBasicBlockRef LLVMGetPreviousBasicBlock(LLVMBasicBlockRef BB);
3771
3772/**
3773 * Obtain the basic block that corresponds to the entry point of a
3774 * function.
3775 *
3776 * @see llvm::Function::getEntryBlock()
3777 */
3778LLVM_C_ABI LLVMBasicBlockRef LLVMGetEntryBasicBlock(LLVMValueRef Fn);
3779
3780/**
3781 * Insert the given basic block after the insertion point of the given builder.
3782 *
3783 * The insertion point must be valid.
3784 *
3785 * @see llvm::Function::BasicBlockListType::insertAfter()
3786 */
3787LLVM_C_ABI void
3788LLVMInsertExistingBasicBlockAfterInsertBlock(LLVMBuilderRef Builder,
3789 LLVMBasicBlockRef BB);
3790
3791/**
3792 * Append the given basic block to the basic block list of the given function.
3793 *
3794 * @see llvm::Function::BasicBlockListType::push_back()
3795 */
3796LLVM_C_ABI void LLVMAppendExistingBasicBlock(LLVMValueRef Fn,
3797 LLVMBasicBlockRef BB);
3798
3799/**
3800 * Create a new basic block without inserting it into a function.
3801 *
3802 * @see llvm::BasicBlock::Create()
3803 */
3804LLVM_C_ABI LLVMBasicBlockRef LLVMCreateBasicBlockInContext(LLVMContextRef C,
3805 const char *Name);
3806
3807/**
3808 * Append a basic block to the end of a function.
3809 *
3810 * @see llvm::BasicBlock::Create()
3811 */
3812LLVM_C_ABI LLVMBasicBlockRef LLVMAppendBasicBlockInContext(LLVMContextRef C,
3813 LLVMValueRef Fn,
3814 const char *Name);
3815
3816/**
3817 * Append a basic block to the end of a function using the global
3818 * context.
3819 *
3820 * @see llvm::BasicBlock::Create()
3821 */
3822LLVM_C_ABI LLVM_ATTRIBUTE_C_DEPRECATED(
3823 LLVMBasicBlockRef LLVMAppendBasicBlock(LLVMValueRef Fn, const char *Name),
3824 "Use of the global context is deprecated, use "
3825 "LLVMAppendBasicBlockInContext instead");
3826
3827/**
3828 * Insert a basic block in a function before another basic block.
3829 *
3830 * The function to add to is determined by the function of the
3831 * passed basic block.
3832 *
3833 * @see llvm::BasicBlock::Create()
3834 */
3835LLVM_C_ABI LLVMBasicBlockRef LLVMInsertBasicBlockInContext(LLVMContextRef C,
3836 LLVMBasicBlockRef BB,
3837 const char *Name);
3838
3839/**
3840 * Insert a basic block in a function using the global context.
3841 *
3842 * @see llvm::BasicBlock::Create()
3843 */
3844LLVM_C_ABI LLVM_ATTRIBUTE_C_DEPRECATED(
3845 LLVMBasicBlockRef LLVMInsertBasicBlock(LLVMBasicBlockRef InsertBeforeBB,
3846 const char *Name),
3847 "Use of the global context is deprecated, use "
3848 "LLVMInsertBasicBlockInContext instead");
3849
3850/**
3851 * Remove a basic block from a function and delete it.
3852 *
3853 * This deletes the basic block from its containing function and deletes
3854 * the basic block itself.
3855 *
3856 * @see llvm::BasicBlock::eraseFromParent()
3857 */
3858LLVM_C_ABI void LLVMDeleteBasicBlock(LLVMBasicBlockRef BB);
3859
3860/**
3861 * Remove a basic block from a function.
3862 *
3863 * This deletes the basic block from its containing function but keep
3864 * the basic block alive.
3865 *
3866 * @see llvm::BasicBlock::removeFromParent()
3867 */
3868LLVM_C_ABI void LLVMRemoveBasicBlockFromParent(LLVMBasicBlockRef BB);
3869
3870/**
3871 * Move a basic block to before another one.
3872 *
3873 * @see llvm::BasicBlock::moveBefore()
3874 */
3875LLVM_C_ABI void LLVMMoveBasicBlockBefore(LLVMBasicBlockRef BB,
3876 LLVMBasicBlockRef MovePos);
3877
3878/**
3879 * Move a basic block to after another one.
3880 *
3881 * @see llvm::BasicBlock::moveAfter()
3882 */
3883LLVM_C_ABI void LLVMMoveBasicBlockAfter(LLVMBasicBlockRef BB,
3884 LLVMBasicBlockRef MovePos);
3885
3886/**
3887 * Obtain the first instruction in a basic block.
3888 *
3889 * The returned LLVMValueRef corresponds to a llvm::Instruction
3890 * instance.
3891 */
3892LLVM_C_ABI LLVMValueRef LLVMGetFirstInstruction(LLVMBasicBlockRef BB);
3893
3894/**
3895 * Obtain the last instruction in a basic block.
3896 *
3897 * The returned LLVMValueRef corresponds to an LLVM:Instruction.
3898 */
3899LLVM_C_ABI LLVMValueRef LLVMGetLastInstruction(LLVMBasicBlockRef BB);
3900
3901/**
3902 * @}
3903 */
3904
3905/**
3906 * @defgroup LLVMCCoreValueInstruction Instructions
3907 *
3908 * Functions in this group relate to the inspection and manipulation of
3909 * individual instructions.
3910 *
3911 * In the C++ API, an instruction is modeled by llvm::Instruction. This
3912 * class has a large number of descendents. llvm::Instruction is a
3913 * llvm::Value and in the C API, instructions are modeled by
3914 * LLVMValueRef.
3915 *
3916 * This group also contains sub-groups which operate on specific
3917 * llvm::Instruction types, e.g. llvm::CallInst.
3918 *
3919 * @{
3920 */
3921
3922/**
3923 * Determine whether an instruction has any metadata attached.
3924 */
3925LLVM_C_ABI int LLVMHasMetadata(LLVMValueRef Val);
3926
3927/**
3928 * Return metadata associated with an instruction value.
3929 */
3930LLVM_C_ABI LLVMValueRef LLVMGetMetadata(LLVMValueRef Val, unsigned KindID);
3931
3932/**
3933 * Set metadata associated with an instruction value.
3934 */
3935LLVM_C_ABI void LLVMSetMetadata(LLVMValueRef Val, unsigned KindID,
3936 LLVMValueRef Node);
3937
3938/**
3939 * Returns the metadata associated with an instruction value, but filters out
3940 * all the debug locations.
3941 *
3942 * @see llvm::Instruction::getAllMetadataOtherThanDebugLoc()
3943 */
3944LLVM_C_ABI LLVMValueMetadataEntry *
3945LLVMInstructionGetAllMetadataOtherThanDebugLoc(LLVMValueRef Instr,
3946 size_t *NumEntries);
3947
3948/**
3949 * Obtain the basic block to which an instruction belongs.
3950 *
3951 * @see llvm::Instruction::getParent()
3952 */
3953LLVM_C_ABI LLVMBasicBlockRef LLVMGetInstructionParent(LLVMValueRef Inst);
3954
3955/**
3956 * Obtain the instruction that occurs after the one specified.
3957 *
3958 * The next instruction will be from the same basic block.
3959 *
3960 * If this is the last instruction in a basic block, NULL will be
3961 * returned.
3962 */
3963LLVM_C_ABI LLVMValueRef LLVMGetNextInstruction(LLVMValueRef Inst);
3964
3965/**
3966 * Obtain the instruction that occurred before this one.
3967 *
3968 * If the instruction is the first instruction in a basic block, NULL
3969 * will be returned.
3970 */
3971LLVM_C_ABI LLVMValueRef LLVMGetPreviousInstruction(LLVMValueRef Inst);
3972
3973/**
3974 * Remove an instruction.
3975 *
3976 * The instruction specified is removed from its containing building
3977 * block but is kept alive.
3978 *
3979 * @see llvm::Instruction::removeFromParent()
3980 */
3981LLVM_C_ABI void LLVMInstructionRemoveFromParent(LLVMValueRef Inst);
3982
3983/**
3984 * Remove and delete an instruction.
3985 *
3986 * The instruction specified is removed from its containing building
3987 * block and then deleted.
3988 *
3989 * @see llvm::Instruction::eraseFromParent()
3990 */
3991LLVM_C_ABI void LLVMInstructionEraseFromParent(LLVMValueRef Inst);
3992
3993/**
3994 * Delete an instruction.
3995 *
3996 * The instruction specified is deleted. It must have previously been
3997 * removed from its containing building block.
3998 *
3999 * @see llvm::Value::deleteValue()
4000 */
4001LLVM_C_ABI void LLVMDeleteInstruction(LLVMValueRef Inst);
4002
4003/**
4004 * Obtain the code opcode for an individual instruction.
4005 *
4006 * @see llvm::Instruction::getOpCode()
4007 */
4008LLVM_C_ABI LLVMOpcode LLVMGetInstructionOpcode(LLVMValueRef Inst);
4009
4010/**
4011 * Obtain the predicate of an instruction.
4012 *
4013 * This is only valid for instructions that correspond to llvm::ICmpInst.
4014 *
4015 * @see llvm::ICmpInst::getPredicate()
4016 */
4017LLVM_C_ABI LLVMIntPredicate LLVMGetICmpPredicate(LLVMValueRef Inst);
4018
4019/**
4020 * Get whether or not an icmp instruction has the samesign flag.
4021 *
4022 * This is only valid for instructions that correspond to llvm::ICmpInst.
4023 *
4024 * @see llvm::ICmpInst::hasSameSign()
4025 */
4026LLVM_C_ABI LLVMBool LLVMGetICmpSameSign(LLVMValueRef Inst);
4027
4028/**
4029 * Set the samesign flag on an icmp instruction.
4030 *
4031 * This is only valid for instructions that correspond to llvm::ICmpInst.
4032 *
4033 * @see llvm::ICmpInst::setSameSign()
4034 */
4035LLVM_C_ABI void LLVMSetICmpSameSign(LLVMValueRef Inst, LLVMBool SameSign);
4036
4037/**
4038 * Obtain the float predicate of an instruction.
4039 *
4040 * This is only valid for instructions that correspond to llvm::FCmpInst.
4041 *
4042 * @see llvm::FCmpInst::getPredicate()
4043 */
4044LLVM_C_ABI LLVMRealPredicate LLVMGetFCmpPredicate(LLVMValueRef Inst);
4045
4046/**
4047 * Create a copy of 'this' instruction that is identical in all ways
4048 * except the following:
4049 * * The instruction has no parent
4050 * * The instruction has no name
4051 *
4052 * @see llvm::Instruction::clone()
4053 */
4054LLVM_C_ABI LLVMValueRef LLVMInstructionClone(LLVMValueRef Inst);
4055
4056/**
4057 * Determine whether an instruction is a terminator. This routine is named to
4058 * be compatible with historical functions that did this by querying the
4059 * underlying C++ type.
4060 *
4061 * @see llvm::Instruction::isTerminator()
4062 */
4063LLVM_C_ABI LLVMValueRef LLVMIsATerminatorInst(LLVMValueRef Inst);
4064
4065/**
4066 * Obtain the first debug record attached to an instruction.
4067 *
4068 * Use LLVMGetNextDbgRecord() and LLVMGetPreviousDbgRecord() to traverse the
4069 * sequence of DbgRecords.
4070 *
4071 * Return the first DbgRecord attached to Inst or NULL if there are none.
4072 *
4073 * @see llvm::Instruction::getDbgRecordRange()
4074 */
4075LLVM_C_ABI LLVMDbgRecordRef LLVMGetFirstDbgRecord(LLVMValueRef Inst);
4076
4077/**
4078 * Obtain the last debug record attached to an instruction.
4079 *
4080 * Return the last DbgRecord attached to Inst or NULL if there are none.
4081 *
4082 * @see llvm::Instruction::getDbgRecordRange()
4083 */
4084LLVM_C_ABI LLVMDbgRecordRef LLVMGetLastDbgRecord(LLVMValueRef Inst);
4085
4086/**
4087 * Obtain the next DbgRecord in the sequence or NULL if there are no more.
4088 *
4089 * @see llvm::Instruction::getDbgRecordRange()
4090 */
4091LLVM_C_ABI LLVMDbgRecordRef LLVMGetNextDbgRecord(LLVMDbgRecordRef DbgRecord);
4092
4093/**
4094 * Obtain the previous DbgRecord in the sequence or NULL if there are no more.
4095 *
4096 * @see llvm::Instruction::getDbgRecordRange()
4097 */
4098LLVM_C_ABI LLVMDbgRecordRef
4099LLVMGetPreviousDbgRecord(LLVMDbgRecordRef DbgRecord);
4100
4101/**
4102 * Get the debug location attached to the debug record.
4103 *
4104 * @see llvm::DbgRecord::getDebugLoc()
4105 */
4106LLVM_C_ABI LLVMMetadataRef LLVMDbgRecordGetDebugLoc(LLVMDbgRecordRef Rec);
4107
4108LLVM_C_ABI LLVMDbgRecordKind LLVMDbgRecordGetKind(LLVMDbgRecordRef Rec);
4109
4110/**
4111 * Get the value of the DbgVariableRecord.
4112 *
4113 * @see llvm::DbgVariableRecord::getValue()
4114 */
4115LLVM_C_ABI LLVMValueRef LLVMDbgVariableRecordGetValue(LLVMDbgRecordRef Rec,
4116 unsigned OpIdx);
4117
4118/**
4119 * Get the debug info variable of the DbgVariableRecord.
4120 *
4121 * @see llvm::DbgVariableRecord::getVariable()
4122 */
4123LLVM_C_ABI LLVMMetadataRef
4124LLVMDbgVariableRecordGetVariable(LLVMDbgRecordRef Rec);
4125
4126/**
4127 * Get the debug info expression of the DbgVariableRecord.
4128 *
4129 * @see llvm::DbgVariableRecord::getExpression()
4130 */
4131LLVM_C_ABI LLVMMetadataRef
4132LLVMDbgVariableRecordGetExpression(LLVMDbgRecordRef Rec);
4133
4134/**
4135 * @defgroup LLVMCCoreValueInstructionCall Call Sites and Invocations
4136 *
4137 * Functions in this group apply to instructions that refer to call
4138 * sites and invocations. These correspond to C++ types in the
4139 * llvm::CallInst class tree.
4140 *
4141 * @{
4142 */
4143
4144/**
4145 * Obtain the argument count for a call instruction.
4146 *
4147 * This expects an LLVMValueRef that corresponds to a llvm::CallInst,
4148 * llvm::InvokeInst, or llvm:FuncletPadInst.
4149 *
4150 * @see llvm::CallInst::getNumArgOperands()
4151 * @see llvm::InvokeInst::getNumArgOperands()
4152 * @see llvm::FuncletPadInst::getNumArgOperands()
4153 */
4154LLVM_C_ABI unsigned LLVMGetNumArgOperands(LLVMValueRef Instr);
4155
4156/**
4157 * Set the calling convention for a call instruction.
4158 *
4159 * This expects an LLVMValueRef that corresponds to a llvm::CallInst or
4160 * llvm::InvokeInst.
4161 *
4162 * @see llvm::CallInst::setCallingConv()
4163 * @see llvm::InvokeInst::setCallingConv()
4164 */
4165LLVM_C_ABI void LLVMSetInstructionCallConv(LLVMValueRef Instr, unsigned CC);
4166
4167/**
4168 * Obtain the calling convention for a call instruction.
4169 *
4170 * This is the opposite of LLVMSetInstructionCallConv(). Reads its
4171 * usage.
4172 *
4173 * @see LLVMSetInstructionCallConv()
4174 */
4175LLVM_C_ABI unsigned LLVMGetInstructionCallConv(LLVMValueRef Instr);
4176
4177LLVM_C_ABI void LLVMSetInstrParamAlignment(LLVMValueRef Instr,
4178 LLVMAttributeIndex Idx,
4179 unsigned Align);
4180
4181LLVM_C_ABI void LLVMAddCallSiteAttribute(LLVMValueRef C, LLVMAttributeIndex Idx,
4182 LLVMAttributeRef A);
4183LLVM_C_ABI unsigned LLVMGetCallSiteAttributeCount(LLVMValueRef C,
4184 LLVMAttributeIndex Idx);
4185LLVM_C_ABI void LLVMGetCallSiteAttributes(LLVMValueRef C,
4186 LLVMAttributeIndex Idx,
4187 LLVMAttributeRef *Attrs);
4188LLVM_C_ABI LLVMAttributeRef LLVMGetCallSiteEnumAttribute(LLVMValueRef C,
4189 LLVMAttributeIndex Idx,
4190 unsigned KindID);
4191LLVM_C_ABI LLVMAttributeRef LLVMGetCallSiteStringAttribute(
4192 LLVMValueRef C, LLVMAttributeIndex Idx, const char *K, unsigned KLen);
4193LLVM_C_ABI void LLVMRemoveCallSiteEnumAttribute(LLVMValueRef C,
4194 LLVMAttributeIndex Idx,
4195 unsigned KindID);
4196LLVM_C_ABI void LLVMRemoveCallSiteStringAttribute(LLVMValueRef C,
4197 LLVMAttributeIndex Idx,
4198 const char *K, unsigned KLen);
4199
4200/**
4201 * Obtain the function type called by this instruction.
4202 *
4203 * @see llvm::CallBase::getFunctionType()
4204 */
4205LLVM_C_ABI LLVMTypeRef LLVMGetCalledFunctionType(LLVMValueRef C);
4206
4207/**
4208 * Obtain the pointer to the function invoked by this instruction.
4209 *
4210 * This expects an LLVMValueRef that corresponds to a llvm::CallInst or
4211 * llvm::InvokeInst.
4212 *
4213 * @see llvm::CallInst::getCalledOperand()
4214 * @see llvm::InvokeInst::getCalledOperand()
4215 */
4216LLVM_C_ABI LLVMValueRef LLVMGetCalledValue(LLVMValueRef Instr);
4217
4218/**
4219 * Obtain the number of operand bundles attached to this instruction.
4220 *
4221 * This only works on llvm::CallInst and llvm::InvokeInst instructions.
4222 *
4223 * @see llvm::CallBase::getNumOperandBundles()
4224 */
4225LLVM_C_ABI unsigned LLVMGetNumOperandBundles(LLVMValueRef C);
4226
4227/**
4228 * Obtain the operand bundle attached to this instruction at the given index.
4229 * Use LLVMDisposeOperandBundle to free the operand bundle.
4230 *
4231 * This only works on llvm::CallInst and llvm::InvokeInst instructions.
4232 */
4233LLVM_C_ABI LLVMOperandBundleRef LLVMGetOperandBundleAtIndex(LLVMValueRef C,
4234 unsigned Index);
4235
4236/**
4237 * Obtain whether a call instruction is a tail call.
4238 *
4239 * This only works on llvm::CallInst instructions.
4240 *
4241 * @see llvm::CallInst::isTailCall()
4242 */
4243LLVM_C_ABI LLVMBool LLVMIsTailCall(LLVMValueRef CallInst);
4244
4245/**
4246 * Set whether a call instruction is a tail call.
4247 *
4248 * This only works on llvm::CallInst instructions.
4249 *
4250 * @see llvm::CallInst::setTailCall()
4251 */
4252LLVM_C_ABI void LLVMSetTailCall(LLVMValueRef CallInst, LLVMBool IsTailCall);
4253
4254/**
4255 * Obtain a tail call kind of the call instruction.
4256 *
4257 * @see llvm::CallInst::setTailCallKind()
4258 */
4259LLVM_C_ABI LLVMTailCallKind LLVMGetTailCallKind(LLVMValueRef CallInst);
4260
4261/**
4262 * Set the call kind of the call instruction.
4263 *
4264 * @see llvm::CallInst::getTailCallKind()
4265 */
4266LLVM_C_ABI void LLVMSetTailCallKind(LLVMValueRef CallInst,
4267 LLVMTailCallKind kind);
4268
4269/**
4270 * Return the normal destination basic block.
4271 *
4272 * This only works on llvm::InvokeInst instructions.
4273 *
4274 * @see llvm::InvokeInst::getNormalDest()
4275 */
4276LLVM_C_ABI LLVMBasicBlockRef LLVMGetNormalDest(LLVMValueRef InvokeInst);
4277
4278/**
4279 * Return the unwind destination basic block.
4280 *
4281 * Works on llvm::InvokeInst, llvm::CleanupReturnInst, and
4282 * llvm::CatchSwitchInst instructions.
4283 *
4284 * @see llvm::InvokeInst::getUnwindDest()
4285 * @see llvm::CleanupReturnInst::getUnwindDest()
4286 * @see llvm::CatchSwitchInst::getUnwindDest()
4287 */
4288LLVM_C_ABI LLVMBasicBlockRef LLVMGetUnwindDest(LLVMValueRef InvokeInst);
4289
4290/**
4291 * Set the normal destination basic block.
4292 *
4293 * This only works on llvm::InvokeInst instructions.
4294 *
4295 * @see llvm::InvokeInst::setNormalDest()
4296 */
4297LLVM_C_ABI void LLVMSetNormalDest(LLVMValueRef InvokeInst, LLVMBasicBlockRef B);
4298
4299/**
4300 * Set the unwind destination basic block.
4301 *
4302 * Works on llvm::InvokeInst, llvm::CleanupReturnInst, and
4303 * llvm::CatchSwitchInst instructions.
4304 *
4305 * @see llvm::InvokeInst::setUnwindDest()
4306 * @see llvm::CleanupReturnInst::setUnwindDest()
4307 * @see llvm::CatchSwitchInst::setUnwindDest()
4308 */
4309LLVM_C_ABI void LLVMSetUnwindDest(LLVMValueRef InvokeInst, LLVMBasicBlockRef B);
4310
4311/**
4312 * Get the default destination of a CallBr instruction.
4313 *
4314 * @see llvm::CallBrInst::getDefaultDest()
4315 */
4316LLVM_C_ABI LLVMBasicBlockRef LLVMGetCallBrDefaultDest(LLVMValueRef CallBr);
4317
4318/**
4319 * Get the number of indirect destinations of a CallBr instruction.
4320 *
4321 * @see llvm::CallBrInst::getNumIndirectDests()
4322
4323 */
4324LLVM_C_ABI unsigned LLVMGetCallBrNumIndirectDests(LLVMValueRef CallBr);
4325
4326/**
4327 * Get the indirect destination of a CallBr instruction at the given index.
4328 *
4329 * @see llvm::CallBrInst::getIndirectDest()
4330 */
4331LLVM_C_ABI LLVMBasicBlockRef LLVMGetCallBrIndirectDest(LLVMValueRef CallBr,
4332 unsigned Idx);
4333
4334/**
4335 * @}
4336 */
4337
4338/**
4339 * @defgroup LLVMCCoreValueInstructionTerminator Terminators
4340 *
4341 * Functions in this group only apply to instructions for which
4342 * LLVMIsATerminatorInst returns true.
4343 *
4344 * @{
4345 */
4346
4347/**
4348 * Return the number of successors that this terminator has.
4349 *
4350 * @see llvm::Instruction::getNumSuccessors
4351 */
4352LLVM_C_ABI unsigned LLVMGetNumSuccessors(LLVMValueRef Term);
4353
4354/**
4355 * Return the specified successor.
4356 *
4357 * @see llvm::Instruction::getSuccessor
4358 */
4359LLVM_C_ABI LLVMBasicBlockRef LLVMGetSuccessor(LLVMValueRef Term, unsigned i);
4360
4361/**
4362 * Update the specified successor to point at the provided block.
4363 *
4364 * @see llvm::Instruction::setSuccessor
4365 */
4366LLVM_C_ABI void LLVMSetSuccessor(LLVMValueRef Term, unsigned i,
4367 LLVMBasicBlockRef block);
4368
4369/**
4370 * Return if an instruction is a conditional branch.
4371 *
4372 * Deprecated: Use LLVMIsACondBrInst instead.
4373 */
4374LLVM_C_ABI LLVMBool LLVMIsConditional(LLVMValueRef Branch);
4375
4376/**
4377 * Return the condition of a branch instruction.
4378 *
4379 * This only works on llvm::CondBrInst instructions.
4380 *
4381 * @see llvm::CondBrInst::getCondition
4382 */
4383LLVM_C_ABI LLVMValueRef LLVMGetCondition(LLVMValueRef Branch);
4384
4385/**
4386 * Set the condition of a branch instruction.
4387 *
4388 * This only works on llvm::CondBrInst instructions.
4389 *
4390 * @see llvm::CondBrInst::setCondition
4391 */
4392LLVM_C_ABI void LLVMSetCondition(LLVMValueRef Branch, LLVMValueRef Cond);
4393
4394/**
4395 * Obtain the default destination basic block of a switch instruction.
4396 *
4397 * This only works on llvm::SwitchInst instructions.
4398 *
4399 * @see llvm::SwitchInst::getDefaultDest()
4400 */
4401LLVM_C_ABI LLVMBasicBlockRef LLVMGetSwitchDefaultDest(LLVMValueRef SwitchInstr);
4402
4403/**
4404 * Obtain the case value for a successor of a switch instruction. i corresponds
4405 * to the successor index. The first successor is the default destination, so i
4406 * must be greater than zero.
4407 *
4408 * This only works on llvm::SwitchInst instructions.
4409 *
4410 * @see llvm::SwitchInst::CaseHandle::getCaseValue()
4411 */
4412LLVM_C_ABI LLVMValueRef LLVMGetSwitchCaseValue(LLVMValueRef SwitchInstr,
4413 unsigned i);
4414
4415/**
4416 * Set the case value for a successor of a switch instruction. i corresponds to
4417 * the successor index. The first successor is the default destination, so i
4418 * must be greater than zero.
4419 *
4420 * This only works on llvm::SwitchInst instructions.
4421 *
4422 * @see llvm::SwitchInst::CaseHandle::setValue()
4423 */
4424LLVM_C_ABI void LLVMSetSwitchCaseValue(LLVMValueRef SwitchInstr, unsigned i,
4425 LLVMValueRef CaseValue);
4426
4427/**
4428 * @}
4429 */
4430
4431/**
4432 * @defgroup LLVMCCoreValueInstructionAlloca Allocas
4433 *
4434 * Functions in this group only apply to instructions that map to
4435 * llvm::AllocaInst instances.
4436 *
4437 * @{
4438 */
4439
4440/**
4441 * Obtain the type that is being allocated by the alloca instruction.
4442 */
4443LLVM_C_ABI LLVMTypeRef LLVMGetAllocatedType(LLVMValueRef Alloca);
4444
4445/**
4446 * @}
4447 */
4448
4449/**
4450 * @defgroup LLVMCCoreValueInstructionGetElementPointer GEPs
4451 *
4452 * Functions in this group only apply to instructions that map to
4453 * llvm::GetElementPtrInst instances.
4454 *
4455 * @{
4456 */
4457
4458/**
4459 * Check whether the given GEP operator is inbounds.
4460 */
4461LLVM_C_ABI LLVMBool LLVMIsInBounds(LLVMValueRef GEP);
4462
4463/**
4464 * Set the given GEP instruction to be inbounds or not.
4465 */
4466LLVM_C_ABI void LLVMSetIsInBounds(LLVMValueRef GEP, LLVMBool InBounds);
4467
4468/**
4469 * Get the source element type of the given GEP operator.
4470 */
4471LLVM_C_ABI LLVMTypeRef LLVMGetGEPSourceElementType(LLVMValueRef GEP);
4472
4473/**
4474 * Get the no-wrap related flags for the given GEP instruction.
4475 *
4476 * @see llvm::GetElementPtrInst::getNoWrapFlags
4477 */
4478LLVM_C_ABI LLVMGEPNoWrapFlags LLVMGEPGetNoWrapFlags(LLVMValueRef GEP);
4479
4480/**
4481 * Set the no-wrap related flags for the given GEP instruction.
4482 *
4483 * @see llvm::GetElementPtrInst::setNoWrapFlags
4484 */
4485LLVM_C_ABI void LLVMGEPSetNoWrapFlags(LLVMValueRef GEP,
4486 LLVMGEPNoWrapFlags NoWrapFlags);
4487
4488/**
4489 * @}
4490 */
4491
4492/**
4493 * @defgroup LLVMCCoreValueInstructionPHINode PHI Nodes
4494 *
4495 * Functions in this group only apply to instructions that map to
4496 * llvm::PHINode instances.
4497 *
4498 * @{
4499 */
4500
4501/**
4502 * Add an incoming value to the end of a PHI list.
4503 */
4504LLVM_C_ABI void LLVMAddIncoming(LLVMValueRef PhiNode,
4505 LLVMValueRef *IncomingValues,
4506 LLVMBasicBlockRef *IncomingBlocks,
4507 unsigned Count);
4508
4509/**
4510 * Obtain the number of incoming basic blocks to a PHI node.
4511 */
4512LLVM_C_ABI unsigned LLVMCountIncoming(LLVMValueRef PhiNode);
4513
4514/**
4515 * Obtain an incoming value to a PHI node as an LLVMValueRef.
4516 */
4517LLVM_C_ABI LLVMValueRef LLVMGetIncomingValue(LLVMValueRef PhiNode,
4518 unsigned Index);
4519
4520/**
4521 * Obtain an incoming value to a PHI node as an LLVMBasicBlockRef.
4522 */
4523LLVM_C_ABI LLVMBasicBlockRef LLVMGetIncomingBlock(LLVMValueRef PhiNode,
4524 unsigned Index);
4525
4526/**
4527 * @}
4528 */
4529
4530/**
4531 * @defgroup LLVMCCoreValueInstructionExtractValue ExtractValue
4532 * @defgroup LLVMCCoreValueInstructionInsertValue InsertValue
4533 *
4534 * Functions in this group only apply to instructions that map to
4535 * llvm::ExtractValue and llvm::InsertValue instances.
4536 *
4537 * @{
4538 */
4539
4540/**
4541 * Obtain the number of indices.
4542 * NB: This also works on GEP operators.
4543 */
4544LLVM_C_ABI unsigned LLVMGetNumIndices(LLVMValueRef Inst);
4545
4546/**
4547 * Obtain the indices as an array.
4548 */
4549LLVM_C_ABI const unsigned *LLVMGetIndices(LLVMValueRef Inst);
4550
4551/**
4552 * @}
4553 */
4554
4555/**
4556 * @}
4557 */
4558
4559/**
4560 * @}
4561 */
4562
4563/**
4564 * @defgroup LLVMCCoreInstructionBuilder Instruction Builders
4565 *
4566 * An instruction builder represents a point within a basic block and is
4567 * the exclusive means of building instructions using the C interface.
4568 *
4569 * @{
4570 */
4571
4572LLVM_C_ABI LLVMBuilderRef LLVMCreateBuilderInContext(LLVMContextRef C);
4573LLVM_C_ABI
4574LLVM_ATTRIBUTE_C_DEPRECATED(LLVMBuilderRef LLVMCreateBuilder(void),
4575 "Use of the global context is deprecated, use "
4576 "LLVMCreateBuilderInContext instead");
4577/**
4578 * Set the builder position before Instr but after any attached debug records,
4579 * or if Instr is null set the position to the end of Block.
4580 */
4581LLVM_C_ABI void LLVMPositionBuilder(LLVMBuilderRef Builder,
4582 LLVMBasicBlockRef Block,
4583 LLVMValueRef Instr);
4584/**
4585 * Set the builder position before Instr and any attached debug records,
4586 * or if Instr is null set the position to the end of Block.
4587 */
4588LLVM_C_ABI void LLVMPositionBuilderBeforeDbgRecords(LLVMBuilderRef Builder,
4589 LLVMBasicBlockRef Block,
4590 LLVMValueRef Inst);
4591/**
4592 * Set the builder position before Instr but after any attached debug records.
4593 */
4594LLVM_C_ABI void LLVMPositionBuilderBefore(LLVMBuilderRef Builder,
4595 LLVMValueRef Instr);
4596/**
4597 * Set the builder position before Instr and any attached debug records.
4598 */
4599LLVM_C_ABI void
4600LLVMPositionBuilderBeforeInstrAndDbgRecords(LLVMBuilderRef Builder,
4601 LLVMValueRef Instr);
4602LLVM_C_ABI void LLVMPositionBuilderAtEnd(LLVMBuilderRef Builder,
4603 LLVMBasicBlockRef Block);
4604LLVM_C_ABI LLVMBasicBlockRef LLVMGetInsertBlock(LLVMBuilderRef Builder);
4605LLVM_C_ABI void LLVMClearInsertionPosition(LLVMBuilderRef Builder);
4606LLVM_C_ABI void LLVMInsertIntoBuilder(LLVMBuilderRef Builder,
4607 LLVMValueRef Instr);
4608LLVM_C_ABI void LLVMInsertIntoBuilderWithName(LLVMBuilderRef Builder,
4609 LLVMValueRef Instr,
4610 const char *Name);
4611LLVM_C_ABI void LLVMDisposeBuilder(LLVMBuilderRef Builder);
4612
4613/* Metadata */
4614
4615/**
4616 * Get location information used by debugging information.
4617 *
4618 * @see llvm::IRBuilder::getCurrentDebugLocation()
4619 */
4620LLVM_C_ABI LLVMMetadataRef LLVMGetCurrentDebugLocation2(LLVMBuilderRef Builder);
4621
4622/**
4623 * Set location information used by debugging information.
4624 *
4625 * To clear the location metadata of the given instruction, pass NULL to \p Loc.
4626 *
4627 * @see llvm::IRBuilder::SetCurrentDebugLocation()
4628 */
4629LLVM_C_ABI void LLVMSetCurrentDebugLocation2(LLVMBuilderRef Builder,
4630 LLVMMetadataRef Loc);
4631
4632/**
4633 * Attempts to set the debug location for the given instruction using the
4634 * current debug location for the given builder. If the builder has no current
4635 * debug location, this function is a no-op.
4636 *
4637 * @deprecated LLVMSetInstDebugLocation is deprecated in favor of the more general
4638 * LLVMAddMetadataToInst.
4639 *
4640 * @see llvm::IRBuilder::SetInstDebugLocation()
4641 */
4642LLVM_C_ABI void LLVMSetInstDebugLocation(LLVMBuilderRef Builder,
4643 LLVMValueRef Inst);
4644
4645/**
4646 * Adds the metadata registered with the given builder to the given instruction.
4647 *
4648 * @see llvm::IRBuilder::AddMetadataToInst()
4649 */
4650LLVM_C_ABI void LLVMAddMetadataToInst(LLVMBuilderRef Builder,
4651 LLVMValueRef Inst);
4652
4653/**
4654 * Get the dafult floating-point math metadata for a given builder.
4655 *
4656 * @see llvm::IRBuilder::getDefaultFPMathTag()
4657 */
4658LLVM_C_ABI LLVMMetadataRef
4659LLVMBuilderGetDefaultFPMathTag(LLVMBuilderRef Builder);
4660
4661/**
4662 * Set the default floating-point math metadata for the given builder.
4663 *
4664 * To clear the metadata, pass NULL to \p FPMathTag.
4665 *
4666 * @see llvm::IRBuilder::setDefaultFPMathTag()
4667 */
4668LLVM_C_ABI void LLVMBuilderSetDefaultFPMathTag(LLVMBuilderRef Builder,
4669 LLVMMetadataRef FPMathTag);
4670
4671/**
4672 * Obtain the context to which this builder is associated.
4673 *
4674 * @see llvm::IRBuilder::getContext()
4675 */
4676LLVM_C_ABI LLVMContextRef LLVMGetBuilderContext(LLVMBuilderRef Builder);
4677
4678/**
4679 * Deprecated: Passing the NULL location will crash.
4680 * Use LLVMGetCurrentDebugLocation2 instead.
4681 */
4682LLVM_C_ABI void LLVMSetCurrentDebugLocation(LLVMBuilderRef Builder,
4683 LLVMValueRef L);
4684/**
4685 * Deprecated: Returning the NULL location will crash.
4686 * Use LLVMGetCurrentDebugLocation2 instead.
4687 */
4688LLVM_C_ABI LLVMValueRef LLVMGetCurrentDebugLocation(LLVMBuilderRef Builder);
4689
4690/* Terminators */
4691LLVM_C_ABI LLVMValueRef LLVMBuildRetVoid(LLVMBuilderRef);
4692LLVM_C_ABI LLVMValueRef LLVMBuildRet(LLVMBuilderRef, LLVMValueRef V);
4693LLVM_C_ABI LLVMValueRef LLVMBuildAggregateRet(LLVMBuilderRef,
4694 LLVMValueRef *RetVals,
4695 unsigned N);
4696LLVM_C_ABI LLVMValueRef LLVMBuildBr(LLVMBuilderRef, LLVMBasicBlockRef Dest);
4697LLVM_C_ABI LLVMValueRef LLVMBuildCondBr(LLVMBuilderRef, LLVMValueRef If,
4698 LLVMBasicBlockRef Then,
4699 LLVMBasicBlockRef Else);
4700LLVM_C_ABI LLVMValueRef LLVMBuildSwitch(LLVMBuilderRef, LLVMValueRef V,
4701 LLVMBasicBlockRef Else,
4702 unsigned NumCases);
4703LLVM_C_ABI LLVMValueRef LLVMBuildIndirectBr(LLVMBuilderRef B, LLVMValueRef Addr,
4704 unsigned NumDests);
4705LLVM_C_ABI LLVMValueRef LLVMBuildCallBr(
4706 LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Fn,
4707 LLVMBasicBlockRef DefaultDest, LLVMBasicBlockRef *IndirectDests,
4708 unsigned NumIndirectDests, LLVMValueRef *Args, unsigned NumArgs,
4709 LLVMOperandBundleRef *Bundles, unsigned NumBundles, const char *Name);
4710LLVM_C_ABI LLVMValueRef LLVMBuildInvoke2(LLVMBuilderRef, LLVMTypeRef Ty,
4711 LLVMValueRef Fn, LLVMValueRef *Args,
4712 unsigned NumArgs,
4713 LLVMBasicBlockRef Then,
4714 LLVMBasicBlockRef Catch,
4715 const char *Name);
4716LLVM_C_ABI LLVMValueRef LLVMBuildInvokeWithOperandBundles(
4717 LLVMBuilderRef, LLVMTypeRef Ty, LLVMValueRef Fn, LLVMValueRef *Args,
4718 unsigned NumArgs, LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch,
4719 LLVMOperandBundleRef *Bundles, unsigned NumBundles, const char *Name);
4720LLVM_C_ABI LLVMValueRef LLVMBuildUnreachable(LLVMBuilderRef);
4721
4722/* Exception Handling */
4723LLVM_C_ABI LLVMValueRef LLVMBuildResume(LLVMBuilderRef B, LLVMValueRef Exn);
4724LLVM_C_ABI LLVMValueRef LLVMBuildLandingPad(LLVMBuilderRef B, LLVMTypeRef Ty,
4725 LLVMValueRef PersFn,
4726 unsigned NumClauses,
4727 const char *Name);
4728LLVM_C_ABI LLVMValueRef LLVMBuildCleanupRet(LLVMBuilderRef B,
4729 LLVMValueRef CatchPad,
4730 LLVMBasicBlockRef BB);
4731LLVM_C_ABI LLVMValueRef LLVMBuildCatchRet(LLVMBuilderRef B,
4732 LLVMValueRef CatchPad,
4733 LLVMBasicBlockRef BB);
4734LLVM_C_ABI LLVMValueRef LLVMBuildCatchPad(LLVMBuilderRef B,
4735 LLVMValueRef ParentPad,
4736 LLVMValueRef *Args, unsigned NumArgs,
4737 const char *Name);
4738LLVM_C_ABI LLVMValueRef LLVMBuildCleanupPad(LLVMBuilderRef B,
4739 LLVMValueRef ParentPad,
4740 LLVMValueRef *Args,
4741 unsigned NumArgs, const char *Name);
4742LLVM_C_ABI LLVMValueRef LLVMBuildCatchSwitch(LLVMBuilderRef B,
4743 LLVMValueRef ParentPad,
4744 LLVMBasicBlockRef UnwindBB,
4745 unsigned NumHandlers,
4746 const char *Name);
4747
4748/* Add a case to the switch instruction */
4749LLVM_C_ABI void LLVMAddCase(LLVMValueRef Switch, LLVMValueRef OnVal,
4750 LLVMBasicBlockRef Dest);
4751
4752/* Add a destination to the indirectbr instruction */
4753LLVM_C_ABI void LLVMAddDestination(LLVMValueRef IndirectBr,
4754 LLVMBasicBlockRef Dest);
4755
4756/* Get the number of clauses on the landingpad instruction */
4757LLVM_C_ABI unsigned LLVMGetNumClauses(LLVMValueRef LandingPad);
4758
4759/* Get the value of the clause at index Idx on the landingpad instruction */
4760LLVM_C_ABI LLVMValueRef LLVMGetClause(LLVMValueRef LandingPad, unsigned Idx);
4761
4762/* Add a catch or filter clause to the landingpad instruction */
4763LLVM_C_ABI void LLVMAddClause(LLVMValueRef LandingPad, LLVMValueRef ClauseVal);
4764
4765/* Get the 'cleanup' flag in the landingpad instruction */
4766LLVM_C_ABI LLVMBool LLVMIsCleanup(LLVMValueRef LandingPad);
4767
4768/* Set the 'cleanup' flag in the landingpad instruction */
4769LLVM_C_ABI void LLVMSetCleanup(LLVMValueRef LandingPad, LLVMBool Val);
4770
4771/* Add a destination to the catchswitch instruction */
4772LLVM_C_ABI void LLVMAddHandler(LLVMValueRef CatchSwitch,
4773 LLVMBasicBlockRef Dest);
4774
4775/* Get the number of handlers on the catchswitch instruction */
4776LLVM_C_ABI unsigned LLVMGetNumHandlers(LLVMValueRef CatchSwitch);
4777
4778/**
4779 * Obtain the basic blocks acting as handlers for a catchswitch instruction.
4780 *
4781 * The Handlers parameter should point to a pre-allocated array of
4782 * LLVMBasicBlockRefs at least LLVMGetNumHandlers() large. On return, the
4783 * first LLVMGetNumHandlers() entries in the array will be populated
4784 * with LLVMBasicBlockRef instances.
4785 *
4786 * @param CatchSwitch The catchswitch instruction to operate on.
4787 * @param Handlers Memory address of an array to be filled with basic blocks.
4788 */
4789LLVM_C_ABI void LLVMGetHandlers(LLVMValueRef CatchSwitch,
4790 LLVMBasicBlockRef *Handlers);
4791
4792/* Funclets */
4793
4794/* Get the number of funcletpad arguments. */
4795LLVM_C_ABI LLVMValueRef LLVMGetArgOperand(LLVMValueRef Funclet, unsigned i);
4796
4797/* Set a funcletpad argument at the given index. */
4798LLVM_C_ABI void LLVMSetArgOperand(LLVMValueRef Funclet, unsigned i,
4799 LLVMValueRef value);
4800
4801/**
4802 * Get the parent catchswitch instruction of a catchpad instruction.
4803 *
4804 * This only works on llvm::CatchPadInst instructions.
4805 *
4806 * @see llvm::CatchPadInst::getCatchSwitch()
4807 */
4808LLVM_C_ABI LLVMValueRef LLVMGetParentCatchSwitch(LLVMValueRef CatchPad);
4809
4810/**
4811 * Set the parent catchswitch instruction of a catchpad instruction.
4812 *
4813 * This only works on llvm::CatchPadInst instructions.
4814 *
4815 * @see llvm::CatchPadInst::setCatchSwitch()
4816 */
4817LLVM_C_ABI void LLVMSetParentCatchSwitch(LLVMValueRef CatchPad,
4818 LLVMValueRef CatchSwitch);
4819
4820/* Arithmetic */
4821LLVM_C_ABI LLVMValueRef LLVMBuildAdd(LLVMBuilderRef, LLVMValueRef LHS,
4822 LLVMValueRef RHS, const char *Name);
4823LLVM_C_ABI LLVMValueRef LLVMBuildNSWAdd(LLVMBuilderRef, LLVMValueRef LHS,
4824 LLVMValueRef RHS, const char *Name);
4825LLVM_C_ABI LLVMValueRef LLVMBuildNUWAdd(LLVMBuilderRef, LLVMValueRef LHS,
4826 LLVMValueRef RHS, const char *Name);
4827LLVM_C_ABI LLVMValueRef LLVMBuildFAdd(LLVMBuilderRef, LLVMValueRef LHS,
4828 LLVMValueRef RHS, const char *Name);
4829LLVM_C_ABI LLVMValueRef LLVMBuildSub(LLVMBuilderRef, LLVMValueRef LHS,
4830 LLVMValueRef RHS, const char *Name);
4831LLVM_C_ABI LLVMValueRef LLVMBuildNSWSub(LLVMBuilderRef, LLVMValueRef LHS,
4832 LLVMValueRef RHS, const char *Name);
4833LLVM_C_ABI LLVMValueRef LLVMBuildNUWSub(LLVMBuilderRef, LLVMValueRef LHS,
4834 LLVMValueRef RHS, const char *Name);
4835LLVM_C_ABI LLVMValueRef LLVMBuildFSub(LLVMBuilderRef, LLVMValueRef LHS,
4836 LLVMValueRef RHS, const char *Name);
4837LLVM_C_ABI LLVMValueRef LLVMBuildMul(LLVMBuilderRef, LLVMValueRef LHS,
4838 LLVMValueRef RHS, const char *Name);
4839LLVM_C_ABI LLVMValueRef LLVMBuildNSWMul(LLVMBuilderRef, LLVMValueRef LHS,
4840 LLVMValueRef RHS, const char *Name);
4841LLVM_C_ABI LLVMValueRef LLVMBuildNUWMul(LLVMBuilderRef, LLVMValueRef LHS,
4842 LLVMValueRef RHS, const char *Name);
4843LLVM_C_ABI LLVMValueRef LLVMBuildFMul(LLVMBuilderRef, LLVMValueRef LHS,
4844 LLVMValueRef RHS, const char *Name);
4845LLVM_C_ABI LLVMValueRef LLVMBuildUDiv(LLVMBuilderRef, LLVMValueRef LHS,
4846 LLVMValueRef RHS, const char *Name);
4847LLVM_C_ABI LLVMValueRef LLVMBuildExactUDiv(LLVMBuilderRef, LLVMValueRef LHS,
4848 LLVMValueRef RHS, const char *Name);
4849LLVM_C_ABI LLVMValueRef LLVMBuildSDiv(LLVMBuilderRef, LLVMValueRef LHS,
4850 LLVMValueRef RHS, const char *Name);
4851LLVM_C_ABI LLVMValueRef LLVMBuildExactSDiv(LLVMBuilderRef, LLVMValueRef LHS,
4852 LLVMValueRef RHS, const char *Name);
4853LLVM_C_ABI LLVMValueRef LLVMBuildFDiv(LLVMBuilderRef, LLVMValueRef LHS,
4854 LLVMValueRef RHS, const char *Name);
4855LLVM_C_ABI LLVMValueRef LLVMBuildURem(LLVMBuilderRef, LLVMValueRef LHS,
4856 LLVMValueRef RHS, const char *Name);
4857LLVM_C_ABI LLVMValueRef LLVMBuildSRem(LLVMBuilderRef, LLVMValueRef LHS,
4858 LLVMValueRef RHS, const char *Name);
4859LLVM_C_ABI LLVMValueRef LLVMBuildFRem(LLVMBuilderRef, LLVMValueRef LHS,
4860 LLVMValueRef RHS, const char *Name);
4861LLVM_C_ABI LLVMValueRef LLVMBuildShl(LLVMBuilderRef, LLVMValueRef LHS,
4862 LLVMValueRef RHS, const char *Name);
4863LLVM_C_ABI LLVMValueRef LLVMBuildLShr(LLVMBuilderRef, LLVMValueRef LHS,
4864 LLVMValueRef RHS, const char *Name);
4865LLVM_C_ABI LLVMValueRef LLVMBuildAShr(LLVMBuilderRef, LLVMValueRef LHS,
4866 LLVMValueRef RHS, const char *Name);
4867LLVM_C_ABI LLVMValueRef LLVMBuildAnd(LLVMBuilderRef, LLVMValueRef LHS,
4868 LLVMValueRef RHS, const char *Name);
4869LLVM_C_ABI LLVMValueRef LLVMBuildOr(LLVMBuilderRef, LLVMValueRef LHS,
4870 LLVMValueRef RHS, const char *Name);
4871LLVM_C_ABI LLVMValueRef LLVMBuildXor(LLVMBuilderRef, LLVMValueRef LHS,
4872 LLVMValueRef RHS, const char *Name);
4873LLVM_C_ABI LLVMValueRef LLVMBuildBinOp(LLVMBuilderRef B, LLVMOpcode Op,
4874 LLVMValueRef LHS, LLVMValueRef RHS,
4875 const char *Name);
4876LLVM_C_ABI LLVMValueRef LLVMBuildNeg(LLVMBuilderRef, LLVMValueRef V,
4877 const char *Name);
4878LLVM_C_ABI LLVMValueRef LLVMBuildNSWNeg(LLVMBuilderRef B, LLVMValueRef V,
4879 const char *Name);
4880LLVM_C_ABI LLVM_ATTRIBUTE_C_DEPRECATED(
4881 LLVMValueRef LLVMBuildNUWNeg(LLVMBuilderRef B, LLVMValueRef V,
4882 const char *Name),
4883 "Use LLVMBuildNeg + LLVMSetNUW instead.");
4884LLVM_C_ABI LLVMValueRef LLVMBuildFNeg(LLVMBuilderRef, LLVMValueRef V,
4885 const char *Name);
4886LLVM_C_ABI LLVMValueRef LLVMBuildNot(LLVMBuilderRef, LLVMValueRef V,
4887 const char *Name);
4888
4889LLVM_C_ABI LLVMBool LLVMGetNUW(LLVMValueRef ArithInst);
4890LLVM_C_ABI void LLVMSetNUW(LLVMValueRef ArithInst, LLVMBool HasNUW);
4891LLVM_C_ABI LLVMBool LLVMGetNSW(LLVMValueRef ArithInst);
4892LLVM_C_ABI void LLVMSetNSW(LLVMValueRef ArithInst, LLVMBool HasNSW);
4893LLVM_C_ABI LLVMBool LLVMGetExact(LLVMValueRef DivOrShrInst);
4894LLVM_C_ABI void LLVMSetExact(LLVMValueRef DivOrShrInst, LLVMBool IsExact);
4895
4896/**
4897 * Gets if the instruction has the non-negative flag set.
4898 * Only valid for zext instructions.
4899 */
4900LLVM_C_ABI LLVMBool LLVMGetNNeg(LLVMValueRef NonNegInst);
4901/**
4902 * Sets the non-negative flag for the instruction.
4903 * Only valid for zext instructions.
4904 */
4905LLVM_C_ABI void LLVMSetNNeg(LLVMValueRef NonNegInst, LLVMBool IsNonNeg);
4906
4907/**
4908 * Get the flags for which fast-math-style optimizations are allowed for this
4909 * value.
4910 *
4911 * Only valid on floating point instructions.
4912 * @see LLVMCanValueUseFastMathFlags
4913 */
4914LLVM_C_ABI LLVMFastMathFlags LLVMGetFastMathFlags(LLVMValueRef FPMathInst);
4915
4916/**
4917 * Sets the flags for which fast-math-style optimizations are allowed for this
4918 * value.
4919 *
4920 * Only valid on floating point instructions.
4921 * @see LLVMCanValueUseFastMathFlags
4922 */
4923LLVM_C_ABI void LLVMSetFastMathFlags(LLVMValueRef FPMathInst,
4924 LLVMFastMathFlags FMF);
4925
4926/**
4927 * Check if a given value can potentially have fast math flags.
4928 *
4929 * Will return true for floating point arithmetic instructions, and for select,
4930 * phi, and call instructions whose type is a floating point type, or a vector
4931 * or array thereof. See https://llvm.org/docs/LangRef.html#fast-math-flags
4932 */
4933LLVM_C_ABI LLVMBool LLVMCanValueUseFastMathFlags(LLVMValueRef Inst);
4934
4935/**
4936 * Gets whether the instruction has the disjoint flag set.
4937 * Only valid for or instructions.
4938 */
4939LLVM_C_ABI LLVMBool LLVMGetIsDisjoint(LLVMValueRef Inst);
4940/**
4941 * Sets the disjoint flag for the instruction.
4942 * Only valid for or instructions.
4943 */
4944LLVM_C_ABI void LLVMSetIsDisjoint(LLVMValueRef Inst, LLVMBool IsDisjoint);
4945
4946/* Memory */
4947LLVM_C_ABI LLVMValueRef LLVMBuildMalloc(LLVMBuilderRef, LLVMTypeRef Ty,
4948 const char *Name);
4949LLVM_C_ABI LLVMValueRef LLVMBuildArrayMalloc(LLVMBuilderRef, LLVMTypeRef Ty,
4950 LLVMValueRef Val,
4951 const char *Name);
4952
4953/**
4954 * Creates and inserts a memset to the specified pointer and the
4955 * specified value.
4956 *
4957 * @see llvm::IRRBuilder::CreateMemSet()
4958 */
4959LLVM_C_ABI LLVMValueRef LLVMBuildMemSet(LLVMBuilderRef B, LLVMValueRef Ptr,
4960 LLVMValueRef Val, LLVMValueRef Len,
4961 unsigned Align);
4962/**
4963 * Creates and inserts a memcpy between the specified pointers.
4964 *
4965 * @see llvm::IRRBuilder::CreateMemCpy()
4966 */
4967LLVM_C_ABI LLVMValueRef LLVMBuildMemCpy(LLVMBuilderRef B, LLVMValueRef Dst,
4968 unsigned DstAlign, LLVMValueRef Src,
4969 unsigned SrcAlign, LLVMValueRef Size);
4970/**
4971 * Creates and inserts a memmove between the specified pointers.
4972 *
4973 * @see llvm::IRRBuilder::CreateMemMove()
4974 */
4975LLVM_C_ABI LLVMValueRef LLVMBuildMemMove(LLVMBuilderRef B, LLVMValueRef Dst,
4976 unsigned DstAlign, LLVMValueRef Src,
4977 unsigned SrcAlign, LLVMValueRef Size);
4978
4979LLVM_C_ABI LLVMValueRef LLVMBuildAlloca(LLVMBuilderRef, LLVMTypeRef Ty,
4980 const char *Name);
4981LLVM_C_ABI LLVMValueRef LLVMBuildArrayAlloca(LLVMBuilderRef, LLVMTypeRef Ty,
4982 LLVMValueRef Val,
4983 const char *Name);
4984LLVM_C_ABI LLVMValueRef LLVMBuildFree(LLVMBuilderRef, LLVMValueRef PointerVal);
4985LLVM_C_ABI LLVMValueRef LLVMBuildLoad2(LLVMBuilderRef, LLVMTypeRef Ty,
4986 LLVMValueRef PointerVal,
4987 const char *Name);
4988LLVM_C_ABI LLVMValueRef LLVMBuildStore(LLVMBuilderRef, LLVMValueRef Val,
4989 LLVMValueRef Ptr);
4990LLVM_C_ABI LLVMValueRef LLVMBuildGEP2(LLVMBuilderRef B, LLVMTypeRef Ty,
4991 LLVMValueRef Pointer,
4992 LLVMValueRef *Indices,
4993 unsigned NumIndices, const char *Name);
4994LLVM_C_ABI LLVMValueRef LLVMBuildInBoundsGEP2(LLVMBuilderRef B, LLVMTypeRef Ty,
4995 LLVMValueRef Pointer,
4996 LLVMValueRef *Indices,
4997 unsigned NumIndices,
4998 const char *Name);
4999/**
5000 * Creates a GetElementPtr instruction. Similar to LLVMBuildGEP2, but allows
5001 * specifying the no-wrap flags.
5002 *
5003 * @see llvm::IRBuilder::CreateGEP()
5004 */
5005LLVM_C_ABI LLVMValueRef LLVMBuildGEPWithNoWrapFlags(
5006 LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Pointer,
5007 LLVMValueRef *Indices, unsigned NumIndices, const char *Name,
5008 LLVMGEPNoWrapFlags NoWrapFlags);
5009LLVM_C_ABI LLVMValueRef LLVMBuildStructGEP2(LLVMBuilderRef B, LLVMTypeRef Ty,
5010 LLVMValueRef Pointer, unsigned Idx,
5011 const char *Name);
5012LLVM_C_ABI LLVMValueRef LLVMBuildGlobalString(LLVMBuilderRef B, const char *Str,
5013 const char *Name);
5014/**
5015 * Deprecated: Use LLVMBuildGlobalString instead, which has identical behavior.
5016 */
5017LLVM_C_ABI LLVMValueRef LLVMBuildGlobalStringPtr(LLVMBuilderRef B,
5018 const char *Str,
5019 const char *Name);
5020LLVM_C_ABI LLVMBool LLVMGetVolatile(LLVMValueRef Inst);
5021LLVM_C_ABI void LLVMSetVolatile(LLVMValueRef MemoryAccessInst,
5022 LLVMBool IsVolatile);
5023LLVM_C_ABI LLVMBool LLVMGetWeak(LLVMValueRef CmpXchgInst);
5024LLVM_C_ABI void LLVMSetWeak(LLVMValueRef CmpXchgInst, LLVMBool IsWeak);
5025LLVM_C_ABI LLVMAtomicOrdering LLVMGetOrdering(LLVMValueRef MemoryAccessInst);
5026LLVM_C_ABI void LLVMSetOrdering(LLVMValueRef MemoryAccessInst,
5027 LLVMAtomicOrdering Ordering);
5028LLVM_C_ABI LLVMAtomicRMWBinOp LLVMGetAtomicRMWBinOp(LLVMValueRef AtomicRMWInst);
5029LLVM_C_ABI void LLVMSetAtomicRMWBinOp(LLVMValueRef AtomicRMWInst,
5030 LLVMAtomicRMWBinOp BinOp);
5031
5032/* Casts */
5033LLVM_C_ABI LLVMValueRef LLVMBuildTrunc(LLVMBuilderRef, LLVMValueRef Val,
5034 LLVMTypeRef DestTy, const char *Name);
5035LLVM_C_ABI LLVMValueRef LLVMBuildZExt(LLVMBuilderRef, LLVMValueRef Val,
5036 LLVMTypeRef DestTy, const char *Name);
5037LLVM_C_ABI LLVMValueRef LLVMBuildSExt(LLVMBuilderRef, LLVMValueRef Val,
5038 LLVMTypeRef DestTy, const char *Name);
5039LLVM_C_ABI LLVMValueRef LLVMBuildFPToUI(LLVMBuilderRef, LLVMValueRef Val,
5040 LLVMTypeRef DestTy, const char *Name);
5041LLVM_C_ABI LLVMValueRef LLVMBuildFPToSI(LLVMBuilderRef, LLVMValueRef Val,
5042 LLVMTypeRef DestTy, const char *Name);
5043LLVM_C_ABI LLVMValueRef LLVMBuildUIToFP(LLVMBuilderRef, LLVMValueRef Val,
5044 LLVMTypeRef DestTy, const char *Name);
5045LLVM_C_ABI LLVMValueRef LLVMBuildSIToFP(LLVMBuilderRef, LLVMValueRef Val,
5046 LLVMTypeRef DestTy, const char *Name);
5047LLVM_C_ABI LLVMValueRef LLVMBuildFPTrunc(LLVMBuilderRef, LLVMValueRef Val,
5048 LLVMTypeRef DestTy, const char *Name);
5049LLVM_C_ABI LLVMValueRef LLVMBuildFPExt(LLVMBuilderRef, LLVMValueRef Val,
5050 LLVMTypeRef DestTy, const char *Name);
5051LLVM_C_ABI LLVMValueRef LLVMBuildPtrToInt(LLVMBuilderRef, LLVMValueRef Val,
5052 LLVMTypeRef DestTy, const char *Name);
5053LLVM_C_ABI LLVMValueRef LLVMBuildIntToPtr(LLVMBuilderRef, LLVMValueRef Val,
5054 LLVMTypeRef DestTy, const char *Name);
5055LLVM_C_ABI LLVMValueRef LLVMBuildBitCast(LLVMBuilderRef, LLVMValueRef Val,
5056 LLVMTypeRef DestTy, const char *Name);
5057LLVM_C_ABI LLVMValueRef LLVMBuildAddrSpaceCast(LLVMBuilderRef, LLVMValueRef Val,
5058 LLVMTypeRef DestTy,
5059 const char *Name);
5060LLVM_C_ABI LLVMValueRef LLVMBuildZExtOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
5061 LLVMTypeRef DestTy,
5062 const char *Name);
5063LLVM_C_ABI LLVMValueRef LLVMBuildSExtOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
5064 LLVMTypeRef DestTy,
5065 const char *Name);
5066LLVM_C_ABI LLVMValueRef LLVMBuildTruncOrBitCast(LLVMBuilderRef,
5067 LLVMValueRef Val,
5068 LLVMTypeRef DestTy,
5069 const char *Name);
5070LLVM_C_ABI LLVMValueRef LLVMBuildCast(LLVMBuilderRef B, LLVMOpcode Op,
5071 LLVMValueRef Val, LLVMTypeRef DestTy,
5072 const char *Name);
5073LLVM_C_ABI LLVMValueRef LLVMBuildPointerCast(LLVMBuilderRef, LLVMValueRef Val,
5074 LLVMTypeRef DestTy,
5075 const char *Name);
5076LLVM_C_ABI LLVMValueRef LLVMBuildIntCast2(LLVMBuilderRef, LLVMValueRef Val,
5077 LLVMTypeRef DestTy, LLVMBool IsSigned,
5078 const char *Name);
5079LLVM_C_ABI LLVMValueRef LLVMBuildFPCast(LLVMBuilderRef, LLVMValueRef Val,
5080 LLVMTypeRef DestTy, const char *Name);
5081
5082/** Deprecated: This cast is always signed. Use LLVMBuildIntCast2 instead. */
5083LLVM_C_ABI LLVMValueRef LLVMBuildIntCast(LLVMBuilderRef,
5084 LLVMValueRef Val, /*Signed cast!*/
5085 LLVMTypeRef DestTy, const char *Name);
5086
5087LLVM_C_ABI LLVMOpcode LLVMGetCastOpcode(LLVMValueRef Src, LLVMBool SrcIsSigned,
5088 LLVMTypeRef DestTy,
5089 LLVMBool DestIsSigned);
5090
5091/* Comparisons */
5092LLVM_C_ABI LLVMValueRef LLVMBuildICmp(LLVMBuilderRef, LLVMIntPredicate Op,
5093 LLVMValueRef LHS, LLVMValueRef RHS,
5094 const char *Name);
5095LLVM_C_ABI LLVMValueRef LLVMBuildFCmp(LLVMBuilderRef, LLVMRealPredicate Op,
5096 LLVMValueRef LHS, LLVMValueRef RHS,
5097 const char *Name);
5098
5099/* Miscellaneous instructions */
5100LLVM_C_ABI LLVMValueRef LLVMBuildPhi(LLVMBuilderRef, LLVMTypeRef Ty,
5101 const char *Name);
5102LLVM_C_ABI LLVMValueRef LLVMBuildCall2(LLVMBuilderRef, LLVMTypeRef,
5103 LLVMValueRef Fn, LLVMValueRef *Args,
5104 unsigned NumArgs, const char *Name);
5105LLVM_C_ABI LLVMValueRef LLVMBuildCallWithOperandBundles(
5106 LLVMBuilderRef, LLVMTypeRef, LLVMValueRef Fn, LLVMValueRef *Args,
5107 unsigned NumArgs, LLVMOperandBundleRef *Bundles, unsigned NumBundles,
5108 const char *Name);
5109LLVM_C_ABI LLVMValueRef LLVMBuildSelect(LLVMBuilderRef, LLVMValueRef If,
5110 LLVMValueRef Then, LLVMValueRef Else,
5111 const char *Name);
5112LLVM_C_ABI LLVMValueRef LLVMBuildVAArg(LLVMBuilderRef, LLVMValueRef List,
5113 LLVMTypeRef Ty, const char *Name);
5114LLVM_C_ABI LLVMValueRef LLVMBuildExtractElement(LLVMBuilderRef,
5115 LLVMValueRef VecVal,
5116 LLVMValueRef Index,
5117 const char *Name);
5118LLVM_C_ABI LLVMValueRef LLVMBuildInsertElement(LLVMBuilderRef,
5119 LLVMValueRef VecVal,
5120 LLVMValueRef EltVal,
5121 LLVMValueRef Index,
5122 const char *Name);
5123LLVM_C_ABI LLVMValueRef LLVMBuildShuffleVector(LLVMBuilderRef, LLVMValueRef V1,
5124 LLVMValueRef V2,
5125 LLVMValueRef Mask,
5126 const char *Name);
5127LLVM_C_ABI LLVMValueRef LLVMBuildExtractValue(LLVMBuilderRef,
5128 LLVMValueRef AggVal,
5129 unsigned Index, const char *Name);
5130LLVM_C_ABI LLVMValueRef LLVMBuildInsertValue(LLVMBuilderRef,
5131 LLVMValueRef AggVal,
5132 LLVMValueRef EltVal,
5133 unsigned Index, const char *Name);
5134LLVM_C_ABI LLVMValueRef LLVMBuildFreeze(LLVMBuilderRef, LLVMValueRef Val,
5135 const char *Name);
5136
5137LLVM_C_ABI LLVMValueRef LLVMBuildIsNull(LLVMBuilderRef, LLVMValueRef Val,
5138 const char *Name);
5139LLVM_C_ABI LLVMValueRef LLVMBuildIsNotNull(LLVMBuilderRef, LLVMValueRef Val,
5140 const char *Name);
5141LLVM_C_ABI LLVMValueRef LLVMBuildPtrDiff2(LLVMBuilderRef, LLVMTypeRef ElemTy,
5142 LLVMValueRef LHS, LLVMValueRef RHS,
5143 const char *Name);
5144LLVM_C_ABI LLVMValueRef LLVMBuildFence(LLVMBuilderRef B,
5145 LLVMAtomicOrdering ordering,
5146 LLVMBool singleThread, const char *Name);
5147LLVM_C_ABI LLVMValueRef LLVMBuildFenceSyncScope(LLVMBuilderRef B,
5148 LLVMAtomicOrdering ordering,
5149 unsigned SSID,
5150 const char *Name);
5151LLVM_C_ABI LLVMValueRef LLVMBuildAtomicRMW(LLVMBuilderRef B,
5152 LLVMAtomicRMWBinOp op,
5153 LLVMValueRef PTR, LLVMValueRef Val,
5154 LLVMAtomicOrdering ordering,
5155 LLVMBool singleThread);
5156LLVM_C_ABI LLVMValueRef LLVMBuildAtomicRMWSyncScope(
5157 LLVMBuilderRef B, LLVMAtomicRMWBinOp op, LLVMValueRef PTR, LLVMValueRef Val,
5158 LLVMAtomicOrdering ordering, unsigned SSID);
5159LLVM_C_ABI LLVMValueRef LLVMBuildAtomicCmpXchg(
5160 LLVMBuilderRef B, LLVMValueRef Ptr, LLVMValueRef Cmp, LLVMValueRef New,
5161 LLVMAtomicOrdering SuccessOrdering, LLVMAtomicOrdering FailureOrdering,
5162 LLVMBool SingleThread);
5163LLVM_C_ABI LLVMValueRef LLVMBuildAtomicCmpXchgSyncScope(
5164 LLVMBuilderRef B, LLVMValueRef Ptr, LLVMValueRef Cmp, LLVMValueRef New,
5165 LLVMAtomicOrdering SuccessOrdering, LLVMAtomicOrdering FailureOrdering,
5166 unsigned SSID);
5167
5168/**
5169 * Get the number of elements in the mask of a ShuffleVector instruction.
5170 */
5171LLVM_C_ABI unsigned LLVMGetNumMaskElements(LLVMValueRef ShuffleVectorInst);
5172
5173/**
5174 * \returns a constant that specifies that the result of a \c ShuffleVectorInst
5175 * is undefined.
5176 */
5177LLVM_C_ABI int LLVMGetUndefMaskElem(void);
5178
5179/**
5180 * Get the mask value at position Elt in the mask of a ShuffleVector
5181 * instruction.
5182 *
5183 * \Returns the result of \c LLVMGetUndefMaskElem() if the mask value is
5184 * poison at that position.
5185 */
5186LLVM_C_ABI int LLVMGetMaskValue(LLVMValueRef ShuffleVectorInst, unsigned Elt);
5187
5188LLVM_C_ABI LLVMBool LLVMIsAtomicSingleThread(LLVMValueRef AtomicInst);
5189LLVM_C_ABI void LLVMSetAtomicSingleThread(LLVMValueRef AtomicInst,
5190 LLVMBool SingleThread);
5191
5192/**
5193 * Returns whether an instruction is an atomic instruction, e.g., atomicrmw,
5194 * cmpxchg, fence, or loads and stores with atomic ordering.
5195 */
5196LLVM_C_ABI LLVMBool LLVMIsAtomic(LLVMValueRef Inst);
5197
5198/**
5199 * Returns the synchronization scope ID of an atomic instruction.
5200 */
5201LLVM_C_ABI unsigned LLVMGetAtomicSyncScopeID(LLVMValueRef AtomicInst);
5202
5203/**
5204 * Sets the synchronization scope ID of an atomic instruction.
5205 */
5206LLVM_C_ABI void LLVMSetAtomicSyncScopeID(LLVMValueRef AtomicInst,
5207 unsigned SSID);
5208
5209LLVM_C_ABI LLVMAtomicOrdering
5210LLVMGetCmpXchgSuccessOrdering(LLVMValueRef CmpXchgInst);
5211LLVM_C_ABI void LLVMSetCmpXchgSuccessOrdering(LLVMValueRef CmpXchgInst,
5212 LLVMAtomicOrdering Ordering);
5213LLVM_C_ABI LLVMAtomicOrdering
5214LLVMGetCmpXchgFailureOrdering(LLVMValueRef CmpXchgInst);
5215LLVM_C_ABI void LLVMSetCmpXchgFailureOrdering(LLVMValueRef CmpXchgInst,
5216 LLVMAtomicOrdering Ordering);
5217
5218/**
5219 * @}
5220 */
5221
5222/**
5223 * @defgroup LLVMCCoreModuleProvider Module Providers
5224 *
5225 * @{
5226 */
5227
5228/**
5229 * Changes the type of M so it can be passed to FunctionPassManagers and the
5230 * JIT. They take ModuleProviders for historical reasons.
5231 */
5232LLVM_C_ABI LLVMModuleProviderRef
5233LLVMCreateModuleProviderForExistingModule(LLVMModuleRef M);
5234
5235/**
5236 * Destroys the module M.
5237 */
5238LLVM_C_ABI void LLVMDisposeModuleProvider(LLVMModuleProviderRef M);
5239
5240/**
5241 * @}
5242 */
5243
5244/**
5245 * @defgroup LLVMCCoreMemoryBuffers Memory Buffers
5246 *
5247 * @{
5248 */
5249
5250LLVM_C_ABI LLVMBool LLVMCreateMemoryBufferWithContentsOfFile(
5251 const char *Path, LLVMMemoryBufferRef *OutMemBuf, char **OutMessage);
5252LLVM_C_ABI LLVMBool LLVMCreateMemoryBufferWithSTDIN(
5253 LLVMMemoryBufferRef *OutMemBuf, char **OutMessage);
5254LLVM_C_ABI LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRange(
5255 const char *InputData, size_t InputDataLength, const char *BufferName,
5256 LLVMBool RequiresNullTerminator);
5257LLVM_C_ABI LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRangeCopy(
5258 const char *InputData, size_t InputDataLength, const char *BufferName);
5259LLVM_C_ABI const char *LLVMGetBufferStart(LLVMMemoryBufferRef MemBuf);
5260LLVM_C_ABI size_t LLVMGetBufferSize(LLVMMemoryBufferRef MemBuf);
5261LLVM_C_ABI void LLVMDisposeMemoryBuffer(LLVMMemoryBufferRef MemBuf);
5262
5263/**
5264 * @}
5265 */
5266
5267/**
5268 * @defgroup LLVMCCorePassManagers Pass Managers
5269 * @ingroup LLVMCCore
5270 *
5271 * @{
5272 */
5273
5274/** Constructs a new whole-module pass pipeline. This type of pipeline is
5275 suitable for link-time optimization and whole-module transformations.
5276 @see llvm::PassManager::PassManager */
5277LLVM_C_ABI LLVMPassManagerRef LLVMCreatePassManager(void);
5278
5279/** Constructs a new function-by-function pass pipeline over the module
5280 provider. It does not take ownership of the module provider. This type of
5281 pipeline is suitable for code generation and JIT compilation tasks.
5282 @see llvm::FunctionPassManager::FunctionPassManager */
5283LLVM_C_ABI LLVMPassManagerRef
5284LLVMCreateFunctionPassManagerForModule(LLVMModuleRef M);
5285
5286/** Deprecated: Use LLVMCreateFunctionPassManagerForModule instead. */
5287LLVM_C_ABI LLVMPassManagerRef
5288LLVMCreateFunctionPassManager(LLVMModuleProviderRef MP);
5289
5290/** Initializes, executes on the provided module, and finalizes all of the
5291 passes scheduled in the pass manager. Returns 1 if any of the passes
5292 modified the module, 0 otherwise.
5293 @see llvm::PassManager::run(Module&) */
5294LLVM_C_ABI LLVMBool LLVMRunPassManager(LLVMPassManagerRef PM, LLVMModuleRef M);
5295
5296/** Initializes all of the function passes scheduled in the function pass
5297 manager. Returns 1 if any of the passes modified the module, 0 otherwise.
5298 @see llvm::FunctionPassManager::doInitialization */
5299LLVM_C_ABI LLVMBool LLVMInitializeFunctionPassManager(LLVMPassManagerRef FPM);
5300
5301/** Executes all of the function passes scheduled in the function pass manager
5302 on the provided function. Returns 1 if any of the passes modified the
5303 function, false otherwise.
5304 @see llvm::FunctionPassManager::run(Function&) */
5305LLVM_C_ABI LLVMBool LLVMRunFunctionPassManager(LLVMPassManagerRef FPM,
5306 LLVMValueRef F);
5307
5308/** Finalizes all of the function passes scheduled in the function pass
5309 manager. Returns 1 if any of the passes modified the module, 0 otherwise.
5310 @see llvm::FunctionPassManager::doFinalization */
5311LLVM_C_ABI LLVMBool LLVMFinalizeFunctionPassManager(LLVMPassManagerRef FPM);
5312
5313/** Frees the memory of a pass pipeline. For function pipelines, does not free
5314 the module provider.
5315 @see llvm::PassManagerBase::~PassManagerBase. */
5316LLVM_C_ABI void LLVMDisposePassManager(LLVMPassManagerRef PM);
5317
5318/**
5319 * @}
5320 */
5321
5322/**
5323 * @defgroup LLVMCCoreThreading Threading
5324 *
5325 * Handle the structures needed to make LLVM safe for multithreading.
5326 *
5327 * @{
5328 */
5329
5330/** Deprecated: Multi-threading can only be enabled/disabled with the compile
5331 time define LLVM_ENABLE_THREADS. This function always returns
5332 LLVMIsMultithreaded(). */
5333LLVM_C_ABI LLVMBool LLVMStartMultithreaded(void);
5334
5335/** Deprecated: Multi-threading can only be enabled/disabled with the compile
5336 time define LLVM_ENABLE_THREADS. */
5337LLVM_C_ABI void LLVMStopMultithreaded(void);
5338
5339/** Check whether LLVM is executing in thread-safe mode or not.
5340 @see llvm::llvm_is_multithreaded */
5341LLVM_C_ABI LLVMBool LLVMIsMultithreaded(void);
5342
5343/**
5344 * @}
5345 */
5346
5347/**
5348 * @}
5349 */
5350
5351/**
5352 * @}
5353 */
5354
5355LLVM_C_EXTERN_C_END
5356
5357#endif /* LLVM_C_CORE_H */
5358