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