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