blob: 558da67f593bd83752214dc771294fdb3f020502 [file] [log] [blame]
Gordon Henriksen76a03742007-09-18 03:18:57 +00001/*===-- llvm-c/Core.h - Core Library C Interface ------------------*- C -*-===*\
2|* *|
3|* The LLVM Compiler Infrastructure *|
4|* *|
Chris Lattnere9cc7422007-12-29 19:59:42 +00005|* This file is distributed under the University of Illinois Open Source *|
6|* License. See LICENSE.TXT for details. *|
Gordon Henriksen76a03742007-09-18 03:18:57 +00007|* *|
8|*===----------------------------------------------------------------------===*|
9|* *|
10|* This header declares the C interface to libLLVMCore.a, which implements *|
11|* the LLVM intermediate representation. *|
12|* *|
Gordon Henriksen76a03742007-09-18 03:18:57 +000013\*===----------------------------------------------------------------------===*/
14
15#ifndef LLVM_C_CORE_H
16#define LLVM_C_CORE_H
17
Eric Christophera6b96002015-12-18 01:46:52 +000018#include "llvm-c/ErrorHandling.h"
19#include "llvm-c/Types.h"
Erick Tryzelaardd991352009-08-16 23:36:46 +000020
Evan Cheng2e254d02013-04-04 17:40:53 +000021#ifdef __cplusplus
Gordon Henriksen76a03742007-09-18 03:18:57 +000022extern "C" {
23#endif
24
Gregory Szorc34c863a2012-03-21 03:54:29 +000025/**
26 * @defgroup LLVMC LLVM-C: C interface to LLVM
27 *
28 * This module exposes parts of the LLVM library as a C API.
29 *
30 * @{
31 */
32
33/**
34 * @defgroup LLVMCTransforms Transforms
35 */
36
37/**
38 * @defgroup LLVMCCore Core
39 *
40 * This modules provide an interface to libLLVMCore, which implements
41 * the LLVM intermediate representation as well as other related types
42 * and utilities.
43 *
Gregory Szorc34c863a2012-03-21 03:54:29 +000044 * Many exotic languages can interoperate with C code but have a harder time
45 * with C++ due to name mangling. So in addition to C, this interface enables
46 * tools written in such languages.
47 *
Gregory Szorc34c863a2012-03-21 03:54:29 +000048 * @{
49 */
50
51/**
52 * @defgroup LLVMCCoreTypes Types and Enumerations
53 *
54 * @{
55 */
Gordon Henriksen76a03742007-09-18 03:18:57 +000056
Gordon Henriksen76a03742007-09-18 03:18:57 +000057typedef enum {
Bill Wendlingda52cec2010-02-15 20:53:17 +000058 /* Terminator Instructions */
Chris Lattner40cf28d2009-10-12 04:01:02 +000059 LLVMRet = 1,
60 LLVMBr = 2,
61 LLVMSwitch = 3,
Bill Wendling07d6d762010-02-15 20:50:51 +000062 LLVMIndirectBr = 4,
63 LLVMInvoke = 5,
Bill Wendling46ffaa92011-08-02 06:20:17 +000064 /* removed 6 due to API changes */
Bill Wendling2641d132011-07-27 21:00:28 +000065 LLVMUnreachable = 7,
Bill Wendling07d6d762010-02-15 20:50:51 +000066
Bill Wendlingda52cec2010-02-15 20:53:17 +000067 /* Standard Binary Operators */
Bill Wendling2641d132011-07-27 21:00:28 +000068 LLVMAdd = 8,
69 LLVMFAdd = 9,
70 LLVMSub = 10,
71 LLVMFSub = 11,
72 LLVMMul = 12,
73 LLVMFMul = 13,
74 LLVMUDiv = 14,
75 LLVMSDiv = 15,
76 LLVMFDiv = 16,
77 LLVMURem = 17,
78 LLVMSRem = 18,
79 LLVMFRem = 19,
Bill Wendling07d6d762010-02-15 20:50:51 +000080
Bill Wendlingda52cec2010-02-15 20:53:17 +000081 /* Logical Operators */
Bill Wendling2641d132011-07-27 21:00:28 +000082 LLVMShl = 20,
83 LLVMLShr = 21,
84 LLVMAShr = 22,
85 LLVMAnd = 23,
86 LLVMOr = 24,
87 LLVMXor = 25,
Bill Wendling07d6d762010-02-15 20:50:51 +000088
Bill Wendlingda52cec2010-02-15 20:53:17 +000089 /* Memory Operators */
Bill Wendling2641d132011-07-27 21:00:28 +000090 LLVMAlloca = 26,
91 LLVMLoad = 27,
92 LLVMStore = 28,
93 LLVMGetElementPtr = 29,
Bill Wendling07d6d762010-02-15 20:50:51 +000094
Bill Wendlingda52cec2010-02-15 20:53:17 +000095 /* Cast Operators */
Bill Wendling2641d132011-07-27 21:00:28 +000096 LLVMTrunc = 30,
97 LLVMZExt = 31,
98 LLVMSExt = 32,
99 LLVMFPToUI = 33,
100 LLVMFPToSI = 34,
101 LLVMUIToFP = 35,
102 LLVMSIToFP = 36,
103 LLVMFPTrunc = 37,
104 LLVMFPExt = 38,
105 LLVMPtrToInt = 39,
106 LLVMIntToPtr = 40,
107 LLVMBitCast = 41,
Matt Arsenaultb03bd4d2013-11-15 01:34:59 +0000108 LLVMAddrSpaceCast = 60,
Bill Wendling07d6d762010-02-15 20:50:51 +0000109
Bill Wendlingda52cec2010-02-15 20:53:17 +0000110 /* Other Operators */
Bill Wendling2641d132011-07-27 21:00:28 +0000111 LLVMICmp = 42,
112 LLVMFCmp = 43,
113 LLVMPHI = 44,
114 LLVMCall = 45,
115 LLVMSelect = 46,
Torok Edwin05dc9d62011-10-06 12:39:34 +0000116 LLVMUserOp1 = 47,
117 LLVMUserOp2 = 48,
Bill Wendling2641d132011-07-27 21:00:28 +0000118 LLVMVAArg = 49,
119 LLVMExtractElement = 50,
120 LLVMInsertElement = 51,
121 LLVMShuffleVector = 52,
122 LLVMExtractValue = 53,
123 LLVMInsertValue = 54,
Eli Friedman4fc946c2011-07-27 18:59:19 +0000124
125 /* Atomic operators */
Bill Wendling2641d132011-07-27 21:00:28 +0000126 LLVMFence = 55,
Eli Friedmanc9a551e2011-07-28 21:48:00 +0000127 LLVMAtomicCmpXchg = 56,
Bill Wendlingf891bf82011-07-31 06:30:59 +0000128 LLVMAtomicRMW = 57,
129
130 /* Exception Handling Operators */
Bill Wendlingfae14752011-08-12 20:24:12 +0000131 LLVMResume = 58,
David Majnemer654e1302015-07-31 17:58:14 +0000132 LLVMLandingPad = 59,
133 LLVMCleanupRet = 61,
134 LLVMCatchRet = 62,
Joseph Tremoulet9ce71f72015-09-03 09:09:43 +0000135 LLVMCatchPad = 63,
David Majnemerbbfc7212015-12-14 18:34:23 +0000136 LLVMCleanupPad = 64,
137 LLVMCatchSwitch = 65
Chris Lattner40cf28d2009-10-12 04:01:02 +0000138} LLVMOpcode;
139
140typedef enum {
Gordon Henriksen4a4d7352007-12-30 17:46:33 +0000141 LLVMVoidTypeKind, /**< type with no size */
Dan Gohman518cda42011-12-17 00:04:22 +0000142 LLVMHalfTypeKind, /**< 16 bit floating point type */
Gordon Henriksen4a4d7352007-12-30 17:46:33 +0000143 LLVMFloatTypeKind, /**< 32 bit floating point type */
144 LLVMDoubleTypeKind, /**< 64 bit floating point type */
145 LLVMX86_FP80TypeKind, /**< 80 bit floating point type (X87) */
146 LLVMFP128TypeKind, /**< 128 bit floating point type (112-bit mantissa)*/
147 LLVMPPC_FP128TypeKind, /**< 128 bit floating point type (two 64-bits) */
148 LLVMLabelTypeKind, /**< Labels */
149 LLVMIntegerTypeKind, /**< Arbitrary bit width integers */
150 LLVMFunctionTypeKind, /**< Functions */
151 LLVMStructTypeKind, /**< Structures */
152 LLVMArrayTypeKind, /**< Arrays */
153 LLVMPointerTypeKind, /**< Pointers */
Chris Lattnerdac44ec2009-07-15 22:00:31 +0000154 LLVMVectorTypeKind, /**< SIMD 'packed' format, or other vector type */
Dale Johannesenbaa5d042010-09-10 20:55:01 +0000155 LLVMMetadataTypeKind, /**< Metadata */
David Majnemerb611e3f2015-08-14 05:09:07 +0000156 LLVMX86_MMXTypeKind, /**< X86 MMX */
157 LLVMTokenTypeKind /**< Tokens */
Gordon Henriksen76a03742007-09-18 03:18:57 +0000158} LLVMTypeKind;
159
160typedef enum {
Gordon Henriksen4a4d7352007-12-30 17:46:33 +0000161 LLVMExternalLinkage, /**< Externally visible function */
Chris Lattner2dba0f02009-04-13 06:25:37 +0000162 LLVMAvailableExternallyLinkage,
Duncan Sands12da8ce2009-03-07 15:45:40 +0000163 LLVMLinkOnceAnyLinkage, /**< Keep one copy of function when linking (inline)*/
164 LLVMLinkOnceODRLinkage, /**< Same, but only replaced by something
165 equivalent. */
Rafael Espindola716e7402013-11-01 17:09:14 +0000166 LLVMLinkOnceODRAutoHideLinkage, /**< Obsolete */
Duncan Sands12da8ce2009-03-07 15:45:40 +0000167 LLVMWeakAnyLinkage, /**< Keep one copy of function when linking (weak) */
168 LLVMWeakODRLinkage, /**< Same, but only replaced by something
169 equivalent. */
Gordon Henriksen4a4d7352007-12-30 17:46:33 +0000170 LLVMAppendingLinkage, /**< Special purpose, only applies to global arrays */
171 LLVMInternalLinkage, /**< Rename collisions when linking (static
172 functions) */
Duncan Sands12da8ce2009-03-07 15:45:40 +0000173 LLVMPrivateLinkage, /**< Like Internal, but omit from symbol table */
Nico Rieck7157bb72014-01-14 15:22:47 +0000174 LLVMDLLImportLinkage, /**< Obsolete */
175 LLVMDLLExportLinkage, /**< Obsolete */
Duncan Sandse2881052009-03-11 08:08:06 +0000176 LLVMExternalWeakLinkage,/**< ExternalWeak linkage description */
Jeffrey Yasskin091217b2010-01-27 20:34:15 +0000177 LLVMGhostLinkage, /**< Obsolete */
Bill Wendling002b1672009-07-20 18:22:52 +0000178 LLVMCommonLinkage, /**< Tentative definitions */
Bill Wendling03bcd6e2010-07-01 21:55:59 +0000179 LLVMLinkerPrivateLinkage, /**< Like Private, but linker removes. */
Bill Wendling34bc34e2012-08-17 18:33:14 +0000180 LLVMLinkerPrivateWeakLinkage /**< Like LinkerPrivate, but is weak. */
Gordon Henriksen76a03742007-09-18 03:18:57 +0000181} LLVMLinkage;
182
183typedef enum {
Gordon Henriksen4a4d7352007-12-30 17:46:33 +0000184 LLVMDefaultVisibility, /**< The GV is visible */
185 LLVMHiddenVisibility, /**< The GV is hidden */
186 LLVMProtectedVisibility /**< The GV is protected */
Gordon Henriksen76a03742007-09-18 03:18:57 +0000187} LLVMVisibility;
188
Gordon Henriksenc23b66c2007-09-26 20:56:12 +0000189typedef enum {
Robert Widmann4bb481b2018-03-14 06:45:51 +0000190 LLVMNoUnnamedAddr, /**< Address of the GV is significant. */
191 LLVMLocalUnnamedAddr, /**< Address of the GV is locally insignificant. */
192 LLVMGlobalUnnamedAddr /**< Address of the GV is globally insignificant. */
193} LLVMUnnamedAddr;
194
195typedef enum {
Reid Kleckner2fae26f2014-03-05 02:34:23 +0000196 LLVMDefaultStorageClass = 0,
197 LLVMDLLImportStorageClass = 1, /**< Function to be imported from DLL. */
198 LLVMDLLExportStorageClass = 2 /**< Function to be accessible from DLL. */
199} LLVMDLLStorageClass;
200
201typedef enum {
Robert Widmann1e989de2018-04-06 04:02:39 +0000202 LLVMCCallConv = 0,
203 LLVMFastCallConv = 8,
204 LLVMColdCallConv = 9,
205 LLVMGHCCallConv = 10,
206 LLVMHiPECallConv = 11,
207 LLVMWebKitJSCallConv = 12,
208 LLVMAnyRegCallConv = 13,
209 LLVMPreserveMostCallConv = 14,
210 LLVMPreserveAllCallConv = 15,
211 LLVMSwiftCallConv = 16,
212 LLVMCXXFASTTLSCallConv = 17,
213 LLVMX86StdcallCallConv = 64,
214 LLVMX86FastcallCallConv = 65,
215 LLVMARMAPCSCallConv = 66,
216 LLVMARMAAPCSCallConv = 67,
217 LLVMARMAAPCSVFPCallConv = 68,
218 LLVMMSP430INTRCallConv = 69,
219 LLVMX86ThisCallCallConv = 70,
220 LLVMPTXKernelCallConv = 71,
221 LLVMPTXDeviceCallConv = 72,
222 LLVMSPIRFUNCCallConv = 75,
223 LLVMSPIRKERNELCallConv = 76,
224 LLVMIntelOCLBICallConv = 77,
225 LLVMX8664SysVCallConv = 78,
226 LLVMWin64CallConv = 79,
227 LLVMX86VectorCallCallConv = 80,
228 LLVMHHVMCallConv = 81,
229 LLVMHHVMCCallConv = 82,
230 LLVMX86INTRCallConv = 83,
231 LLVMAVRINTRCallConv = 84,
232 LLVMAVRSIGNALCallConv = 85,
233 LLVMAVRBUILTINCallConv = 86,
234 LLVMAMDGPUVSCallConv = 87,
235 LLVMAMDGPUGSCallConv = 88,
236 LLVMAMDGPUPSCallConv = 89,
237 LLVMAMDGPUCSCallConv = 90,
238 LLVMAMDGPUKERNELCallConv = 91,
239 LLVMX86RegCallCallConv = 92,
240 LLVMAMDGPUHSCallConv = 93,
241 LLVMMSP430BUILTINCallConv = 94,
242 LLVMAMDGPULSCallConv = 95,
243 LLVMAMDGPUESCallConv = 96
Gordon Henriksenc23b66c2007-09-26 20:56:12 +0000244} LLVMCallConv;
245
246typedef enum {
Peter Zotov3e4561c2016-04-06 22:21:29 +0000247 LLVMArgumentValueKind,
248 LLVMBasicBlockValueKind,
249 LLVMMemoryUseValueKind,
250 LLVMMemoryDefValueKind,
251 LLVMMemoryPhiValueKind,
252
253 LLVMFunctionValueKind,
254 LLVMGlobalAliasValueKind,
Dmitry Polukhina1feff72016-04-07 12:32:19 +0000255 LLVMGlobalIFuncValueKind,
Peter Zotov3e4561c2016-04-06 22:21:29 +0000256 LLVMGlobalVariableValueKind,
257 LLVMBlockAddressValueKind,
258 LLVMConstantExprValueKind,
259 LLVMConstantArrayValueKind,
260 LLVMConstantStructValueKind,
261 LLVMConstantVectorValueKind,
262
263 LLVMUndefValueValueKind,
264 LLVMConstantAggregateZeroValueKind,
265 LLVMConstantDataArrayValueKind,
266 LLVMConstantDataVectorValueKind,
267 LLVMConstantIntValueKind,
268 LLVMConstantFPValueKind,
269 LLVMConstantPointerNullValueKind,
270 LLVMConstantTokenNoneValueKind,
271
272 LLVMMetadataAsValueValueKind,
273 LLVMInlineAsmValueKind,
274
275 LLVMInstructionValueKind,
276} LLVMValueKind;
277
278typedef enum {
Gordon Henriksen4a4d7352007-12-30 17:46:33 +0000279 LLVMIntEQ = 32, /**< equal */
280 LLVMIntNE, /**< not equal */
281 LLVMIntUGT, /**< unsigned greater than */
282 LLVMIntUGE, /**< unsigned greater or equal */
283 LLVMIntULT, /**< unsigned less than */
284 LLVMIntULE, /**< unsigned less or equal */
285 LLVMIntSGT, /**< signed greater than */
286 LLVMIntSGE, /**< signed greater or equal */
287 LLVMIntSLT, /**< signed less than */
288 LLVMIntSLE /**< signed less or equal */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +0000289} LLVMIntPredicate;
290
291typedef enum {
Gordon Henriksen4a4d7352007-12-30 17:46:33 +0000292 LLVMRealPredicateFalse, /**< Always false (always folded) */
293 LLVMRealOEQ, /**< True if ordered and equal */
294 LLVMRealOGT, /**< True if ordered and greater than */
295 LLVMRealOGE, /**< True if ordered and greater than or equal */
296 LLVMRealOLT, /**< True if ordered and less than */
297 LLVMRealOLE, /**< True if ordered and less than or equal */
298 LLVMRealONE, /**< True if ordered and operands are unequal */
299 LLVMRealORD, /**< True if ordered (no nans) */
300 LLVMRealUNO, /**< True if unordered: isnan(X) | isnan(Y) */
301 LLVMRealUEQ, /**< True if unordered or equal */
302 LLVMRealUGT, /**< True if unordered or greater than */
303 LLVMRealUGE, /**< True if unordered, greater than, or equal */
304 LLVMRealULT, /**< True if unordered or less than */
305 LLVMRealULE, /**< True if unordered, less than, or equal */
306 LLVMRealUNE, /**< True if unordered or not equal */
307 LLVMRealPredicateTrue /**< Always true (always folded) */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +0000308} LLVMRealPredicate;
309
Bill Wendlingfae14752011-08-12 20:24:12 +0000310typedef enum {
311 LLVMLandingPadCatch, /**< A catch clause */
312 LLVMLandingPadFilter /**< A filter clause */
313} LLVMLandingPadClauseTy;
314
Hans Wennborg5ff71202013-04-16 08:58:59 +0000315typedef enum {
316 LLVMNotThreadLocal = 0,
317 LLVMGeneralDynamicTLSModel,
318 LLVMLocalDynamicTLSModel,
319 LLVMInitialExecTLSModel,
320 LLVMLocalExecTLSModel
321} LLVMThreadLocalMode;
322
Carlo Kokda0ac722013-04-23 13:45:37 +0000323typedef enum {
Carlo Kok8c6719b2013-04-23 13:21:19 +0000324 LLVMAtomicOrderingNotAtomic = 0, /**< A load or store which is not atomic */
325 LLVMAtomicOrderingUnordered = 1, /**< Lowest level of atomicity, guarantees
326 somewhat sane results, lock free. */
NAKAMURA Takumia3a81352013-10-23 17:56:29 +0000327 LLVMAtomicOrderingMonotonic = 2, /**< guarantees that if you take all the
328 operations affecting a specific address,
Carlo Kok8c6719b2013-04-23 13:21:19 +0000329 a consistent ordering exists */
NAKAMURA Takumia3a81352013-10-23 17:56:29 +0000330 LLVMAtomicOrderingAcquire = 4, /**< Acquire provides a barrier of the sort
331 necessary to acquire a lock to access other
Carlo Kok8c6719b2013-04-23 13:21:19 +0000332 memory with normal loads and stores. */
NAKAMURA Takumia3a81352013-10-23 17:56:29 +0000333 LLVMAtomicOrderingRelease = 5, /**< Release is similar to Acquire, but with
334 a barrier of the sort necessary to release
Carlo Kok8c6719b2013-04-23 13:21:19 +0000335 a lock. */
NAKAMURA Takumia3a81352013-10-23 17:56:29 +0000336 LLVMAtomicOrderingAcquireRelease = 6, /**< provides both an Acquire and a
337 Release barrier (for fences and
Carlo Kok8c6719b2013-04-23 13:21:19 +0000338 operations which both read and write
339 memory). */
NAKAMURA Takumia3a81352013-10-23 17:56:29 +0000340 LLVMAtomicOrderingSequentiallyConsistent = 7 /**< provides Acquire semantics
341 for loads and Release
342 semantics for stores.
343 Additionally, it guarantees
344 that a total ordering exists
345 between all
346 SequentiallyConsistent
Carlo Kok8c6719b2013-04-23 13:21:19 +0000347 operations. */
Carlo Kokda0ac722013-04-23 13:45:37 +0000348} LLVMAtomicOrdering;
Carlo Kok8c6719b2013-04-23 13:21:19 +0000349
Carlo Kokda0ac722013-04-23 13:45:37 +0000350typedef enum {
Carlo Kok8c6719b2013-04-23 13:21:19 +0000351 LLVMAtomicRMWBinOpXchg, /**< Set the new value and return the one old */
352 LLVMAtomicRMWBinOpAdd, /**< Add a value and return the old one */
353 LLVMAtomicRMWBinOpSub, /**< Subtract a value and return the old one */
354 LLVMAtomicRMWBinOpAnd, /**< And a value and return the old one */
355 LLVMAtomicRMWBinOpNand, /**< Not-And a value and return the old one */
356 LLVMAtomicRMWBinOpOr, /**< OR a value and return the old one */
357 LLVMAtomicRMWBinOpXor, /**< Xor a value and return the old one */
358 LLVMAtomicRMWBinOpMax, /**< Sets the value if it's greater than the
NAKAMURA Takumia3a81352013-10-23 17:56:29 +0000359 original using a signed comparison and return
Carlo Kok8c6719b2013-04-23 13:21:19 +0000360 the old one */
361 LLVMAtomicRMWBinOpMin, /**< Sets the value if it's Smaller than the
NAKAMURA Takumia3a81352013-10-23 17:56:29 +0000362 original using a signed comparison and return
Carlo Kok8c6719b2013-04-23 13:21:19 +0000363 the old one */
364 LLVMAtomicRMWBinOpUMax, /**< Sets the value if it's greater than the
NAKAMURA Takumia3a81352013-10-23 17:56:29 +0000365 original using an unsigned comparison and return
Carlo Kok8c6719b2013-04-23 13:21:19 +0000366 the old one */
367 LLVMAtomicRMWBinOpUMin /**< Sets the value if it's greater than the
NAKAMURA Takumia3a81352013-10-23 17:56:29 +0000368 original using an unsigned comparison and return
Carlo Kok8c6719b2013-04-23 13:21:19 +0000369 the old one */
Carlo Kokda0ac722013-04-23 13:45:37 +0000370} LLVMAtomicRMWBinOp;
Carlo Kok8c6719b2013-04-23 13:21:19 +0000371
Tom Stellard1580dc72014-04-16 17:45:04 +0000372typedef enum {
373 LLVMDSError,
374 LLVMDSWarning,
375 LLVMDSRemark,
376 LLVMDSNote
377} LLVMDiagnosticSeverity;
378
Robert Widmannf108d572018-04-06 02:31:29 +0000379typedef enum {
380 LLVMInlineAsmDialectATT,
381 LLVMInlineAsmDialectIntel
382} LLVMInlineAsmDialect;
383
Robert Widmannbce367702018-05-14 08:09:00 +0000384typedef enum {
385 /**
386 * Emits an error if two values disagree, otherwise the resulting value is
387 * that of the operands.
388 *
389 * @see Module::ModFlagBehavior::Error
390 */
391 LLVMModuleFlagBehaviorError,
392 /**
393 * Emits a warning if two values disagree. The result value will be the
394 * operand for the flag from the first module being linked.
395 *
396 * @see Module::ModFlagBehavior::Warning
397 */
398 LLVMModuleFlagBehaviorWarning,
399 /**
400 * Adds a requirement that another module flag be present and have a
401 * specified value after linking is performed. The value must be a metadata
402 * pair, where the first element of the pair is the ID of the module flag
403 * to be restricted, and the second element of the pair is the value the
404 * module flag should be restricted to. This behavior can be used to
405 * restrict the allowable results (via triggering of an error) of linking
406 * IDs with the **Override** behavior.
407 *
408 * @see Module::ModFlagBehavior::Require
409 */
410 LLVMModuleFlagBehaviorRequire,
411 /**
412 * Uses the specified value, regardless of the behavior or value of the
413 * other module. If both modules specify **Override**, but the values
414 * differ, an error will be emitted.
415 *
416 * @see Module::ModFlagBehavior::Override
417 */
418 LLVMModuleFlagBehaviorOverride,
419 /**
420 * Appends the two values, which are required to be metadata nodes.
421 *
422 * @see Module::ModFlagBehavior::Append
423 */
424 LLVMModuleFlagBehaviorAppend,
425 /**
426 * Appends the two values, which are required to be metadata
427 * nodes. However, duplicate entries in the second list are dropped
428 * during the append operation.
429 *
430 * @see Module::ModFlagBehavior::AppendUnique
431 */
432 LLVMModuleFlagBehaviorAppendUnique,
433} LLVMModuleFlagBehavior;
434
Gregory Szorc34c863a2012-03-21 03:54:29 +0000435/**
Amaury Sechet5db224e2016-06-12 06:17:24 +0000436 * Attribute index are either LLVMAttributeReturnIndex,
437 * LLVMAttributeFunctionIndex or a parameter number from 1 to N.
438 */
439enum {
440 LLVMAttributeReturnIndex = 0U,
441 // ISO C restricts enumerator values to range of 'int'
442 // (4294967295 is too large)
443 // LLVMAttributeFunctionIndex = ~0U,
444 LLVMAttributeFunctionIndex = -1,
445};
446
447typedef unsigned LLVMAttributeIndex;
448
449/**
Gregory Szorc34c863a2012-03-21 03:54:29 +0000450 * @}
451 */
452
Nick Lewycky0db26542011-05-15 07:20:34 +0000453void LLVMInitializeCore(LLVMPassRegistryRef R);
454
Duncan Sands1cba0a82013-02-17 16:35:51 +0000455/** Deallocate and destroy all ManagedStatic variables.
456 @see llvm::llvm_shutdown
457 @see ManagedStatic */
Benjamin Kramer325ec892013-10-23 16:57:34 +0000458void LLVMShutdown(void);
Duncan Sands1cba0a82013-02-17 16:35:51 +0000459
Gordon Henriksen34eb6d82007-12-19 22:30:40 +0000460/*===-- Error handling ----------------------------------------------------===*/
461
Filip Pizlo3fdbaff2013-05-22 02:46:43 +0000462char *LLVMCreateMessage(const char *Message);
Gordon Henriksen34eb6d82007-12-19 22:30:40 +0000463void LLVMDisposeMessage(char *Message);
464
Filip Pizlo9f50ccd2013-11-03 00:29:47 +0000465/**
Gregory Szorc34c863a2012-03-21 03:54:29 +0000466 * @defgroup LLVMCCoreContext Contexts
467 *
468 * Contexts are execution states for the core LLVM IR system.
469 *
470 * Most types are tied to a context instance. Multiple contexts can
471 * exist simultaneously. A single context is not thread safe. However,
472 * different contexts can execute on different threads simultaneously.
473 *
474 * @{
475 */
Gordon Henriksen76a03742007-09-18 03:18:57 +0000476
Tom Stellard1580dc72014-04-16 17:45:04 +0000477typedef void (*LLVMDiagnosticHandler)(LLVMDiagnosticInfoRef, void *);
Juergen Ributzka34390c72014-05-16 02:33:15 +0000478typedef void (*LLVMYieldCallback)(LLVMContextRef, void *);
Tom Stellard1580dc72014-04-16 17:45:04 +0000479
Gregory Szorc34c863a2012-03-21 03:54:29 +0000480/**
481 * Create a new context.
482 *
483 * Every call to this function should be paired with a call to
484 * LLVMContextDispose() or the context will leak memory.
485 */
Erick Tryzelaarf34cb0c2009-08-30 23:38:06 +0000486LLVMContextRef LLVMContextCreate(void);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000487
488/**
489 * Obtain the global context instance.
490 */
Erick Tryzelaarf34cb0c2009-08-30 23:38:06 +0000491LLVMContextRef LLVMGetGlobalContext(void);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000492
493/**
Tom Stellard1580dc72014-04-16 17:45:04 +0000494 * Set the diagnostic handler for this context.
495 */
496void LLVMContextSetDiagnosticHandler(LLVMContextRef C,
497 LLVMDiagnosticHandler Handler,
498 void *DiagnosticContext);
499
500/**
Jeroen Ketemaad659c32016-04-08 09:19:02 +0000501 * Get the diagnostic handler of this context.
502 */
503LLVMDiagnosticHandler LLVMContextGetDiagnosticHandler(LLVMContextRef C);
504
505/**
506 * Get the diagnostic context of this context.
507 */
508void *LLVMContextGetDiagnosticContext(LLVMContextRef C);
509
510/**
Juergen Ributzka34390c72014-05-16 02:33:15 +0000511 * Set the yield callback function for this context.
512 *
513 * @see LLVMContext::setYieldCallback()
514 */
515void LLVMContextSetYieldCallback(LLVMContextRef C, LLVMYieldCallback Callback,
516 void *OpaqueHandle);
517
518/**
Gregory Szorc34c863a2012-03-21 03:54:29 +0000519 * Destroy a context instance.
520 *
521 * This should be called for every call to LLVMContextCreate() or memory
522 * will be leaked.
523 */
Owen Anderson6773d382009-07-01 16:58:40 +0000524void LLVMContextDispose(LLVMContextRef C);
525
Tom Stellard1580dc72014-04-16 17:45:04 +0000526/**
527 * Return a string representation of the DiagnosticInfo. Use
528 * LLVMDisposeMessage to free the string.
529 *
530 * @see DiagnosticInfo::print()
531 */
532char *LLVMGetDiagInfoDescription(LLVMDiagnosticInfoRef DI);
533
534/**
535 * Return an enum LLVMDiagnosticSeverity.
536 *
537 * @see DiagnosticInfo::getSeverity()
538 */
539LLVMDiagnosticSeverity LLVMGetDiagInfoSeverity(LLVMDiagnosticInfoRef DI);
540
Amaury Sechet56f056c2016-04-04 22:00:25 +0000541unsigned LLVMGetMDKindIDInContext(LLVMContextRef C, const char *Name,
Erick Tryzelaard8531fa2010-02-28 09:45:59 +0000542 unsigned SLen);
Amaury Sechet56f056c2016-04-04 22:00:25 +0000543unsigned LLVMGetMDKindID(const char *Name, unsigned SLen);
Erick Tryzelaard8531fa2010-02-28 09:45:59 +0000544
Gregory Szorc34c863a2012-03-21 03:54:29 +0000545/**
Amaury Sechet5db224e2016-06-12 06:17:24 +0000546 * Return an unique id given the name of a enum attribute,
Amaury Sechet60b31452016-04-20 01:02:12 +0000547 * or 0 if no attribute by that name exists.
548 *
549 * See http://llvm.org/docs/LangRef.html#parameter-attributes
550 * and http://llvm.org/docs/LangRef.html#function-attributes
551 * for the list of available attributes.
552 *
553 * NB: Attribute names and/or id are subject to change without
554 * going through the C API deprecation cycle.
555 */
Amaury Sechet5db224e2016-06-12 06:17:24 +0000556unsigned LLVMGetEnumAttributeKindForName(const char *Name, size_t SLen);
Amaury Sechet48b06652016-06-12 07:56:21 +0000557unsigned LLVMGetLastEnumAttributeKind(void);
Amaury Sechet5db224e2016-06-12 06:17:24 +0000558
559/**
560 * Create an enum attribute.
561 */
562LLVMAttributeRef LLVMCreateEnumAttribute(LLVMContextRef C, unsigned KindID,
563 uint64_t Val);
564
565/**
566 * Get the unique id corresponding to the enum attribute
567 * passed as argument.
568 */
569unsigned LLVMGetEnumAttributeKind(LLVMAttributeRef A);
570
571/**
572 * Get the enum attribute's value. 0 is returned if none exists.
573 */
574uint64_t LLVMGetEnumAttributeValue(LLVMAttributeRef A);
575
576/**
577 * Create a string attribute.
578 */
579LLVMAttributeRef LLVMCreateStringAttribute(LLVMContextRef C,
580 const char *K, unsigned KLength,
581 const char *V, unsigned VLength);
582
583/**
584 * Get the string attribute's kind.
585 */
586const char *LLVMGetStringAttributeKind(LLVMAttributeRef A, unsigned *Length);
587
588/**
589 * Get the string attribute's value.
590 */
591const char *LLVMGetStringAttributeValue(LLVMAttributeRef A, unsigned *Length);
592
593/**
594 * Check for the different types of attributes.
595 */
596LLVMBool LLVMIsEnumAttribute(LLVMAttributeRef A);
597LLVMBool LLVMIsStringAttribute(LLVMAttributeRef A);
Amaury Sechet60b31452016-04-20 01:02:12 +0000598
599/**
Gregory Szorc34c863a2012-03-21 03:54:29 +0000600 * @}
601 */
602
Gregory Szorc52d26602012-03-21 07:28:27 +0000603/**
604 * @defgroup LLVMCCoreModule Modules
Gregory Szorc34c863a2012-03-21 03:54:29 +0000605 *
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +0000606 * Modules represent the top-level structure in an LLVM program. An LLVM
Gregory Szorc34c863a2012-03-21 03:54:29 +0000607 * module is effectively a translation unit or a collection of
608 * translation units merged together.
609 *
610 * @{
611 */
612
Gregory Szorc34c863a2012-03-21 03:54:29 +0000613/**
614 * Create a new, empty module in the global context.
615 *
616 * This is equivalent to calling LLVMModuleCreateWithNameInContext with
617 * LLVMGetGlobalContext() as the context parameter.
618 *
619 * Every invocation should be paired with LLVMDisposeModule() or memory
620 * will be leaked.
621 */
Gordon Henriksen76a03742007-09-18 03:18:57 +0000622LLVMModuleRef LLVMModuleCreateWithName(const char *ModuleID);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000623
624/**
625 * Create a new, empty module in a specific context.
626 *
627 * Every invocation should be paired with LLVMDisposeModule() or memory
628 * will be leaked.
629 */
Owen Anderson31d44e42009-07-02 07:17:57 +0000630LLVMModuleRef LLVMModuleCreateWithNameInContext(const char *ModuleID,
631 LLVMContextRef C);
Tom Stellard0a4e9a32014-10-01 17:14:57 +0000632/**
633 * Return an exact copy of the specified module.
634 */
635LLVMModuleRef LLVMCloneModule(LLVMModuleRef M);
Gordon Henriksena49d4352008-03-07 19:13:06 +0000636
Gregory Szorc34c863a2012-03-21 03:54:29 +0000637/**
638 * Destroy a module instance.
639 *
640 * This must be called for every created module or memory will be
641 * leaked.
642 */
Gordon Henriksen76a03742007-09-18 03:18:57 +0000643void LLVMDisposeModule(LLVMModuleRef M);
644
Gregory Szorc34c863a2012-03-21 03:54:29 +0000645/**
Peter Zotov0a2fa0a2016-04-05 13:56:59 +0000646 * Obtain the identifier of a module.
647 *
648 * @param M Module to obtain identifier of
649 * @param Len Out parameter which holds the length of the returned string.
650 * @return The identifier of M.
651 * @see Module::getModuleIdentifier()
652 */
653const char *LLVMGetModuleIdentifier(LLVMModuleRef M, size_t *Len);
654
655/**
656 * Set the identifier of a module to a string Ident with length Len.
657 *
658 * @param M The module to set identifier
659 * @param Ident The string to set M's identifier to
660 * @param Len Length of Ident
661 * @see Module::setModuleIdentifier()
662 */
663void LLVMSetModuleIdentifier(LLVMModuleRef M, const char *Ident, size_t Len);
664
665/**
Robert Widmann490a5802018-01-30 21:34:29 +0000666 * Obtain the module's original source file name.
667 *
668 * @param M Module to obtain the name of
669 * @param Len Out parameter which holds the length of the returned string
670 * @return The original source file name of M
671 * @see Module::getSourceFileName()
672 */
673const char *LLVMGetSourceFileName(LLVMModuleRef M, size_t *Len);
674
675/**
676 * Set the original source file name of a module to a string Name with length
677 * Len.
678 *
679 * @param M The module to set the source file name of
680 * @param Name The string to set M's source file name to
681 * @param Len Length of Name
682 * @see Module::setSourceFileName()
683 */
684void LLVMSetSourceFileName(LLVMModuleRef M, const char *Name, size_t Len);
685
686/**
Gregory Szorc34c863a2012-03-21 03:54:29 +0000687 * Obtain the data layout for a module.
688 *
Amaury Sechetf3549c42016-02-16 00:23:52 +0000689 * @see Module::getDataLayoutStr()
690 *
691 * LLVMGetDataLayout is DEPRECATED, as the name is not only incorrect,
692 * but match the name of another method on the module. Prefer the use
693 * of LLVMGetDataLayoutStr, which is not ambiguous.
Gregory Szorc34c863a2012-03-21 03:54:29 +0000694 */
Amaury Sechetf3549c42016-02-16 00:23:52 +0000695const char *LLVMGetDataLayoutStr(LLVMModuleRef M);
Gordon Henriksen05568bb2007-12-27 20:13:47 +0000696const char *LLVMGetDataLayout(LLVMModuleRef M);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000697
698/**
699 * Set the data layout for a module.
700 *
701 * @see Module::setDataLayout()
702 */
Amaury Sechet6ada31c2016-02-15 23:40:06 +0000703void LLVMSetDataLayout(LLVMModuleRef M, const char *DataLayoutStr);
Gordon Henriksen05568bb2007-12-27 20:13:47 +0000704
Gregory Szorc34c863a2012-03-21 03:54:29 +0000705/**
706 * Obtain the target triple for a module.
707 *
708 * @see Module::getTargetTriple()
709 */
Gordon Henriksen05568bb2007-12-27 20:13:47 +0000710const char *LLVMGetTarget(LLVMModuleRef M);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000711
712/**
713 * Set the target triple for a module.
714 *
715 * @see Module::setTargetTriple()
716 */
Gordon Henriksen05568bb2007-12-27 20:13:47 +0000717void LLVMSetTarget(LLVMModuleRef M, const char *Triple);
718
Gregory Szorc34c863a2012-03-21 03:54:29 +0000719/**
Robert Widmannbce367702018-05-14 08:09:00 +0000720 * Returns the module flags as an array of flag-key-value triples. The caller
721 * is responsible for freeing this array by calling
722 * \c LLVMDisposeModuleFlagsMetadata.
723 *
724 * @see Module::getModuleFlagsMetadata()
725 */
726LLVMModuleFlagEntry *LLVMCopyModuleFlagsMetadata(LLVMModuleRef M, size_t *Len);
727
728/**
729 * Destroys module flags metadata entries.
730 */
731void LLVMDisposeModuleFlagsMetadata(LLVMModuleFlagEntry *Entries);
732
733/**
734 * Returns the flag behavior for a module flag entry at a specific index.
735 *
736 * @see Module::ModuleFlagEntry::Behavior
737 */
738LLVMModuleFlagBehavior
739LLVMModuleFlagEntriesGetFlagBehavior(LLVMModuleFlagEntry *Entries,
740 unsigned Index);
741
742/**
743 * Returns the key for a module flag entry at a specific index.
744 *
745 * @see Module::ModuleFlagEntry::Key
746 */
747const char *LLVMModuleFlagEntriesGetKey(LLVMModuleFlagEntry *Entries,
748 unsigned Index, size_t *Len);
749
750/**
751 * Returns the metadata for a module flag entry at a specific index.
752 *
753 * @see Module::ModuleFlagEntry::Val
754 */
755LLVMMetadataRef LLVMModuleFlagEntriesGetMetadata(LLVMModuleFlagEntry *Entries,
756 unsigned Index);
757
758/**
759 * Add a module-level flag to the module-level flags metadata if it doesn't
760 * already exist.
761 *
762 * @see Module::getModuleFlag()
763 */
764LLVMMetadataRef LLVMGetModuleFlag(LLVMModuleRef M,
765 const char *Key, size_t KeyLen);
766
767/**
768 * Add a module-level flag to the module-level flags metadata if it doesn't
769 * already exist.
770 *
771 * @see Module::addModuleFlag()
772 */
773void LLVMAddModuleFlag(LLVMModuleRef M, LLVMModuleFlagBehavior Behavior,
774 const char *Key, size_t KeyLen,
775 LLVMMetadataRef Val);
776
777/**
Gregory Szorc34c863a2012-03-21 03:54:29 +0000778 * Dump a representation of a module to stderr.
779 *
780 * @see Module::dump()
781 */
Gordon Henriksen6c6075e2008-03-14 23:58:56 +0000782void LLVMDumpModule(LLVMModuleRef M);
783
Gregory Szorc34c863a2012-03-21 03:54:29 +0000784/**
Hans Wennborgb7ef2fe2012-05-09 16:54:17 +0000785 * Print a representation of a module to a file. The ErrorMessage needs to be
786 * disposed with LLVMDisposeMessage. Returns 0 on success, 1 otherwise.
787 *
788 * @see Module::print()
789 */
790LLVMBool LLVMPrintModuleToFile(LLVMModuleRef M, const char *Filename,
791 char **ErrorMessage);
792
793/**
Anders Waldenborg84355db2013-10-16 18:00:54 +0000794 * Return a string representation of the module. Use
795 * LLVMDisposeMessage to free the string.
796 *
797 * @see Module::print()
798 */
799char *LLVMPrintModuleToString(LLVMModuleRef M);
800
801/**
Robert Widmannf108d572018-04-06 02:31:29 +0000802 * Get inline assembly for a module.
803 *
804 * @see Module::getModuleInlineAsm()
805 */
806const char *LLVMGetModuleInlineAsm(LLVMModuleRef M, size_t *Len);
807
808/**
Gregory Szorc34c863a2012-03-21 03:54:29 +0000809 * Set inline assembly for a module.
810 *
811 * @see Module::setModuleInlineAsm()
812 */
Robert Widmannf108d572018-04-06 02:31:29 +0000813void LLVMSetModuleInlineAsm2(LLVMModuleRef M, const char *Asm, size_t Len);
814
815/**
816 * Append inline assembly to a module.
817 *
818 * @see Module::appendModuleInlineAsm()
819 */
820void LLVMAppendModuleInlineAsm(LLVMModuleRef M, const char *Asm, size_t Len);
821
822/**
823 * Create the specified uniqued inline asm string.
824 *
825 * @see InlineAsm::get()
826 */
827LLVMValueRef LLVMGetInlineAsm(LLVMTypeRef Ty,
828 char *AsmString, size_t AsmStringSize,
829 char *Constraints, size_t ConstraintsSize,
830 LLVMBool HasSideEffects, LLVMBool IsAlignStack,
831 LLVMInlineAsmDialect Dialect);
Gordon Henriksen76a03742007-09-18 03:18:57 +0000832
Gregory Szorc34c863a2012-03-21 03:54:29 +0000833/**
834 * Obtain the context to which this module is associated.
835 *
836 * @see Module::getContext()
837 */
Chris Lattnera7e04b02010-11-28 20:03:44 +0000838LLVMContextRef LLVMGetModuleContext(LLVMModuleRef M);
839
Gregory Szorc34c863a2012-03-21 03:54:29 +0000840/**
841 * Obtain a Type from a module by its registered name.
842 */
843LLVMTypeRef LLVMGetTypeByName(LLVMModuleRef M, const char *Name);
Gordon Henriksen76a03742007-09-18 03:18:57 +0000844
Gregory Szorc34c863a2012-03-21 03:54:29 +0000845/**
Robert Widmann0a35b762018-08-30 17:09:43 +0000846 * Obtain an iterator to the first NamedMDNode in a Module.
847 *
848 * @see llvm::Module::named_metadata_begin()
849 */
850LLVMNamedMDNodeRef LLVMGetFirstNamedMetadata(LLVMModuleRef M);
851
852/**
853 * Obtain an iterator to the last NamedMDNode in a Module.
854 *
855 * @see llvm::Module::named_metadata_end()
856 */
857LLVMNamedMDNodeRef LLVMGetLastNamedMetadata(LLVMModuleRef M);
858
859/**
860 * Advance a NamedMDNode iterator to the next NamedMDNode.
861 *
862 * Returns NULL if the iterator was already at the end and there are no more
863 * named metadata nodes.
864 */
865LLVMNamedMDNodeRef LLVMGetNextNamedMetadata(LLVMNamedMDNodeRef NamedMDNode);
866
867/**
868 * Decrement a NamedMDNode iterator to the previous NamedMDNode.
869 *
870 * Returns NULL if the iterator was already at the beginning and there are
871 * no previous named metadata nodes.
872 */
873LLVMNamedMDNodeRef LLVMGetPreviousNamedMetadata(LLVMNamedMDNodeRef NamedMDNode);
874
875/**
876 * Retrieve a NamedMDNode with the given name, returning NULL if no such
877 * node exists.
878 *
879 * @see llvm::Module::getNamedMetadata()
880 */
881LLVMNamedMDNodeRef LLVMGetNamedMetadata(LLVMModuleRef M,
882 const char *Name, size_t NameLen);
883
884/**
885 * Retrieve a NamedMDNode with the given name, creating a new node if no such
886 * node exists.
887 *
888 * @see llvm::Module::getOrInsertNamedMetadata()
889 */
890LLVMNamedMDNodeRef LLVMGetOrInsertNamedMetadata(LLVMModuleRef M,
891 const char *Name,
892 size_t NameLen);
893
894/**
895 * Retrieve the name of a NamedMDNode.
896 *
897 * @see llvm::NamedMDNode::getName()
898 */
899const char *LLVMGetNamedMetadataName(LLVMNamedMDNodeRef NamedMD,
900 size_t *NameLen);
901
902/**
Gregory Szorc34c863a2012-03-21 03:54:29 +0000903 * Obtain the number of operands for named metadata in a module.
904 *
905 * @see llvm::Module::getNamedMetadata()
906 */
Amaury Sechetb130f432016-04-23 00:12:45 +0000907unsigned LLVMGetNamedMetadataNumOperands(LLVMModuleRef M, const char *Name);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000908
909/**
910 * Obtain the named metadata operands for a module.
911 *
912 * The passed LLVMValueRef pointer should refer to an array of
913 * LLVMValueRef at least LLVMGetNamedMetadataNumOperands long. This
914 * array will be populated with the LLVMValueRef instances. Each
915 * instance corresponds to a llvm::MDNode.
916 *
917 * @see llvm::Module::getNamedMetadata()
918 * @see llvm::MDNode::getOperand()
919 */
Amaury Sechetb130f432016-04-23 00:12:45 +0000920void LLVMGetNamedMetadataOperands(LLVMModuleRef M, const char *Name,
921 LLVMValueRef *Dest);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000922
923/**
924 * Add an operand to named metadata.
925 *
926 * @see llvm::Module::getNamedMetadata()
927 * @see llvm::MDNode::addOperand()
928 */
Amaury Sechetb130f432016-04-23 00:12:45 +0000929void LLVMAddNamedMetadataOperand(LLVMModuleRef M, const char *Name,
Gregory Szorc34c863a2012-03-21 03:54:29 +0000930 LLVMValueRef Val);
931
Gregory Szorc52d26602012-03-21 07:28:27 +0000932/**
933 * Add a function to a module under a specified name.
934 *
935 * @see llvm::Function::Create()
936 */
937LLVMValueRef LLVMAddFunction(LLVMModuleRef M, const char *Name,
938 LLVMTypeRef FunctionTy);
939
940/**
941 * Obtain a Function value from a Module by its name.
942 *
943 * The returned value corresponds to a llvm::Function value.
944 *
945 * @see llvm::Module::getFunction()
946 */
947LLVMValueRef LLVMGetNamedFunction(LLVMModuleRef M, const char *Name);
948
949/**
950 * Obtain an iterator to the first Function in a Module.
951 *
952 * @see llvm::Module::begin()
953 */
954LLVMValueRef LLVMGetFirstFunction(LLVMModuleRef M);
955
956/**
957 * Obtain an iterator to the last Function in a Module.
958 *
959 * @see llvm::Module::end()
960 */
961LLVMValueRef LLVMGetLastFunction(LLVMModuleRef M);
962
963/**
964 * Advance a Function iterator to the next Function.
965 *
966 * Returns NULL if the iterator was already at the end and there are no more
967 * functions.
968 */
969LLVMValueRef LLVMGetNextFunction(LLVMValueRef Fn);
970
971/**
972 * Decrement a Function iterator to the previous Function.
973 *
974 * Returns NULL if the iterator was already at the beginning and there are
975 * no previous functions.
976 */
977LLVMValueRef LLVMGetPreviousFunction(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000978
Robert Widmannf108d572018-04-06 02:31:29 +0000979/** Deprecated: Use LLVMSetModuleInlineAsm2 instead. */
980void LLVMSetModuleInlineAsm(LLVMModuleRef M, const char *Asm);
981
Gregory Szorc34c863a2012-03-21 03:54:29 +0000982/**
983 * @}
984 */
985
986/**
987 * @defgroup LLVMCCoreType Types
988 *
989 * Types represent the type of a value.
990 *
991 * Types are associated with a context instance. The context internally
992 * deduplicates types so there is only 1 instance of a specific type
993 * alive at a time. In other words, a unique type is shared among all
994 * consumers within a context.
995 *
996 * A Type in the C API corresponds to llvm::Type.
997 *
998 * Types have the following hierarchy:
999 *
Gordon Henriksen76a03742007-09-18 03:18:57 +00001000 * types:
1001 * integer type
1002 * real type
1003 * function type
1004 * sequence types:
1005 * array type
1006 * pointer type
1007 * vector type
1008 * void type
1009 * label type
1010 * opaque type
Gregory Szorc34c863a2012-03-21 03:54:29 +00001011 *
1012 * @{
Gordon Henriksen76a03742007-09-18 03:18:57 +00001013 */
1014
Gregory Szorc34c863a2012-03-21 03:54:29 +00001015/**
1016 * Obtain the enumerated type of a Type instance.
1017 *
1018 * @see llvm::Type:getTypeID()
1019 */
Gordon Henriksen76a03742007-09-18 03:18:57 +00001020LLVMTypeKind LLVMGetTypeKind(LLVMTypeRef Ty);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001021
1022/**
1023 * Whether the type has a known size.
1024 *
1025 * Things that don't have a size are abstract types, labels, and void.a
1026 *
1027 * @see llvm::Type::isSized()
1028 */
Torok Edwin1cd9ade2011-10-06 12:13:28 +00001029LLVMBool LLVMTypeIsSized(LLVMTypeRef Ty);
Gordon Henriksena49d4352008-03-07 19:13:06 +00001030
Gregory Szorc34c863a2012-03-21 03:54:29 +00001031/**
1032 * Obtain the context to which this type instance is associated.
1033 *
1034 * @see llvm::Type::getContext()
1035 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +00001036LLVMContextRef LLVMGetTypeContext(LLVMTypeRef Ty);
1037
Gregory Szorc34c863a2012-03-21 03:54:29 +00001038/**
Anders Waldenborgb822cff2013-10-16 21:30:25 +00001039 * Dump a representation of a type to stderr.
1040 *
1041 * @see llvm::Type::dump()
1042 */
1043void LLVMDumpType(LLVMTypeRef Val);
1044
1045/**
Anders Waldenborg47b3bd32013-10-22 06:58:34 +00001046 * Return a string representation of the type. Use
1047 * LLVMDisposeMessage to free the string.
1048 *
1049 * @see llvm::Type::print()
1050 */
1051char *LLVMPrintTypeToString(LLVMTypeRef Val);
1052
1053/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00001054 * @defgroup LLVMCCoreTypeInt Integer Types
1055 *
1056 * Functions in this section operate on integer types.
1057 *
1058 * @{
1059 */
1060
1061/**
1062 * Obtain an integer type from a context with specified bit width.
1063 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +00001064LLVMTypeRef LLVMInt1TypeInContext(LLVMContextRef C);
1065LLVMTypeRef LLVMInt8TypeInContext(LLVMContextRef C);
1066LLVMTypeRef LLVMInt16TypeInContext(LLVMContextRef C);
1067LLVMTypeRef LLVMInt32TypeInContext(LLVMContextRef C);
1068LLVMTypeRef LLVMInt64TypeInContext(LLVMContextRef C);
Eugene Zelenkoffec81c2015-11-04 22:32:32 +00001069LLVMTypeRef LLVMInt128TypeInContext(LLVMContextRef C);
Erick Tryzelaar262332f2009-08-14 00:01:31 +00001070LLVMTypeRef LLVMIntTypeInContext(LLVMContextRef C, unsigned NumBits);
1071
Gregory Szorc34c863a2012-03-21 03:54:29 +00001072/**
1073 * Obtain an integer type from the global context with a specified bit
1074 * width.
1075 */
Gordon Henriksena735a9c2008-05-04 12:55:34 +00001076LLVMTypeRef LLVMInt1Type(void);
1077LLVMTypeRef LLVMInt8Type(void);
1078LLVMTypeRef LLVMInt16Type(void);
1079LLVMTypeRef LLVMInt32Type(void);
1080LLVMTypeRef LLVMInt64Type(void);
Eugene Zelenkoffec81c2015-11-04 22:32:32 +00001081LLVMTypeRef LLVMInt128Type(void);
Gordon Henriksened7beaa2007-10-06 16:05:20 +00001082LLVMTypeRef LLVMIntType(unsigned NumBits);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00001083unsigned LLVMGetIntTypeWidth(LLVMTypeRef IntegerTy);
Gordon Henriksen76a03742007-09-18 03:18:57 +00001084
Gregory Szorc34c863a2012-03-21 03:54:29 +00001085/**
1086 * @}
1087 */
1088
1089/**
1090 * @defgroup LLVMCCoreTypeFloat Floating Point Types
1091 *
1092 * @{
1093 */
1094
1095/**
1096 * Obtain a 16-bit floating point type from a context.
1097 */
Dan Gohman518cda42011-12-17 00:04:22 +00001098LLVMTypeRef LLVMHalfTypeInContext(LLVMContextRef C);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001099
1100/**
1101 * Obtain a 32-bit floating point type from a context.
1102 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +00001103LLVMTypeRef LLVMFloatTypeInContext(LLVMContextRef C);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001104
1105/**
1106 * Obtain a 64-bit floating point type from a context.
1107 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +00001108LLVMTypeRef LLVMDoubleTypeInContext(LLVMContextRef C);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001109
1110/**
1111 * Obtain a 80-bit floating point type (X87) from a context.
1112 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +00001113LLVMTypeRef LLVMX86FP80TypeInContext(LLVMContextRef C);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001114
1115/**
1116 * Obtain a 128-bit floating point type (112-bit mantissa) from a
1117 * context.
1118 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +00001119LLVMTypeRef LLVMFP128TypeInContext(LLVMContextRef C);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001120
1121/**
1122 * Obtain a 128-bit floating point type (two 64-bits) from a context.
1123 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +00001124LLVMTypeRef LLVMPPCFP128TypeInContext(LLVMContextRef C);
1125
Gregory Szorc34c863a2012-03-21 03:54:29 +00001126/**
1127 * Obtain a floating point type from the global context.
1128 *
1129 * These map to the functions in this group of the same name.
1130 */
Dan Gohman518cda42011-12-17 00:04:22 +00001131LLVMTypeRef LLVMHalfType(void);
Gordon Henriksena735a9c2008-05-04 12:55:34 +00001132LLVMTypeRef LLVMFloatType(void);
1133LLVMTypeRef LLVMDoubleType(void);
1134LLVMTypeRef LLVMX86FP80Type(void);
1135LLVMTypeRef LLVMFP128Type(void);
1136LLVMTypeRef LLVMPPCFP128Type(void);
Gordon Henriksen76a03742007-09-18 03:18:57 +00001137
Gregory Szorc34c863a2012-03-21 03:54:29 +00001138/**
1139 * @}
1140 */
1141
1142/**
1143 * @defgroup LLVMCCoreTypeFunction Function Types
1144 *
1145 * @{
1146 */
1147
1148/**
1149 * Obtain a function type consisting of a specified signature.
1150 *
1151 * The function is defined as a tuple of a return Type, a list of
1152 * parameter types, and whether the function is variadic.
1153 */
Gordon Henriksened7beaa2007-10-06 16:05:20 +00001154LLVMTypeRef LLVMFunctionType(LLVMTypeRef ReturnType,
1155 LLVMTypeRef *ParamTypes, unsigned ParamCount,
Chris Lattner25963c62010-01-09 22:27:07 +00001156 LLVMBool IsVarArg);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001157
1158/**
1159 * Returns whether a function type is variadic.
1160 */
Chris Lattner25963c62010-01-09 22:27:07 +00001161LLVMBool LLVMIsFunctionVarArg(LLVMTypeRef FunctionTy);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001162
1163/**
1164 * Obtain the Type this function Type returns.
1165 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00001166LLVMTypeRef LLVMGetReturnType(LLVMTypeRef FunctionTy);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001167
1168/**
1169 * Obtain the number of parameters this function accepts.
1170 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00001171unsigned LLVMCountParamTypes(LLVMTypeRef FunctionTy);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001172
1173/**
1174 * Obtain the types of a function's parameters.
1175 *
1176 * The Dest parameter should point to a pre-allocated array of
1177 * LLVMTypeRef at least LLVMCountParamTypes() large. On return, the
1178 * first LLVMCountParamTypes() entries in the array will be populated
1179 * with LLVMTypeRef instances.
1180 *
1181 * @param FunctionTy The function type to operate on.
1182 * @param Dest Memory address of an array to be filled with result.
1183 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00001184void LLVMGetParamTypes(LLVMTypeRef FunctionTy, LLVMTypeRef *Dest);
Gordon Henriksen76a03742007-09-18 03:18:57 +00001185
Gregory Szorc34c863a2012-03-21 03:54:29 +00001186/**
1187 * @}
1188 */
1189
1190/**
1191 * @defgroup LLVMCCoreTypeStruct Structure Types
1192 *
1193 * These functions relate to LLVMTypeRef instances.
1194 *
1195 * @see llvm::StructType
1196 *
1197 * @{
1198 */
1199
1200/**
1201 * Create a new structure type in a context.
1202 *
1203 * A structure is specified by a list of inner elements/types and
1204 * whether these can be packed together.
1205 *
1206 * @see llvm::StructType::create()
1207 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +00001208LLVMTypeRef LLVMStructTypeInContext(LLVMContextRef C, LLVMTypeRef *ElementTypes,
Chris Lattner25963c62010-01-09 22:27:07 +00001209 unsigned ElementCount, LLVMBool Packed);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001210
1211/**
1212 * Create a new structure type in the global context.
1213 *
1214 * @see llvm::StructType::create()
1215 */
Gordon Henriksened7beaa2007-10-06 16:05:20 +00001216LLVMTypeRef LLVMStructType(LLVMTypeRef *ElementTypes, unsigned ElementCount,
Chris Lattner25963c62010-01-09 22:27:07 +00001217 LLVMBool Packed);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001218
1219/**
1220 * Create an empty structure in a context having a specified name.
1221 *
1222 * @see llvm::StructType::create()
1223 */
Chris Lattnere71ccde2011-07-14 05:53:17 +00001224LLVMTypeRef LLVMStructCreateNamed(LLVMContextRef C, const char *Name);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001225
1226/**
1227 * Obtain the name of a structure.
1228 *
1229 * @see llvm::StructType::getName()
1230 */
Torok Edwin0d5f6ae2011-10-06 12:12:50 +00001231const char *LLVMGetStructName(LLVMTypeRef Ty);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001232
1233/**
1234 * Set the contents of a structure type.
1235 *
1236 * @see llvm::StructType::setBody()
1237 */
Chris Lattnere71ccde2011-07-14 05:53:17 +00001238void LLVMStructSetBody(LLVMTypeRef StructTy, LLVMTypeRef *ElementTypes,
1239 unsigned ElementCount, LLVMBool Packed);
1240
Gregory Szorc34c863a2012-03-21 03:54:29 +00001241/**
1242 * Get the number of elements defined inside the structure.
1243 *
1244 * @see llvm::StructType::getNumElements()
1245 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00001246unsigned LLVMCountStructElementTypes(LLVMTypeRef StructTy);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001247
1248/**
1249 * Get the elements within a structure.
1250 *
1251 * The function is passed the address of a pre-allocated array of
1252 * LLVMTypeRef at least LLVMCountStructElementTypes() long. After
1253 * invocation, this array will be populated with the structure's
1254 * elements. The objects in the destination array will have a lifetime
1255 * of the structure type itself, which is the lifetime of the context it
1256 * is contained in.
1257 */
Gordon Henriksen76a03742007-09-18 03:18:57 +00001258void LLVMGetStructElementTypes(LLVMTypeRef StructTy, LLVMTypeRef *Dest);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001259
1260/**
Peter Zotovc164a3f2015-06-04 09:09:53 +00001261 * Get the type of the element at a given index in the structure.
1262 *
1263 * @see llvm::StructType::getTypeAtIndex()
1264 */
1265LLVMTypeRef LLVMStructGetTypeAtIndex(LLVMTypeRef StructTy, unsigned i);
1266
1267/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00001268 * Determine whether a structure is packed.
1269 *
1270 * @see llvm::StructType::isPacked()
1271 */
Chris Lattner25963c62010-01-09 22:27:07 +00001272LLVMBool LLVMIsPackedStruct(LLVMTypeRef StructTy);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001273
1274/**
1275 * Determine whether a structure is opaque.
1276 *
1277 * @see llvm::StructType::isOpaque()
1278 */
Chris Lattner17cf05b2011-07-14 16:20:28 +00001279LLVMBool LLVMIsOpaqueStruct(LLVMTypeRef StructTy);
1280
Gregory Szorc34c863a2012-03-21 03:54:29 +00001281/**
whitequarkb4861072018-09-18 01:47:37 +00001282 * Determine whether a structure is literal.
1283 *
1284 * @see llvm::StructType::isLiteral()
1285 */
1286LLVMBool LLVMIsLiteralStruct(LLVMTypeRef StructTy);
1287
1288/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00001289 * @}
1290 */
Gordon Henriksen76a03742007-09-18 03:18:57 +00001291
Gregory Szorc34c863a2012-03-21 03:54:29 +00001292/**
1293 * @defgroup LLVMCCoreTypeSequential Sequential Types
1294 *
1295 * Sequential types represents "arrays" of types. This is a super class
1296 * for array, vector, and pointer types.
1297 *
1298 * @{
1299 */
1300
1301/**
1302 * Obtain the type of elements within a sequential type.
1303 *
1304 * This works on array, vector, and pointer types.
1305 *
1306 * @see llvm::SequentialType::getElementType()
1307 */
1308LLVMTypeRef LLVMGetElementType(LLVMTypeRef Ty);
1309
1310/**
whitequarkf6059fd2017-06-05 11:49:52 +00001311 * Returns type's subtypes
1312 *
1313 * @see llvm::Type::subtypes()
1314 */
1315void LLVMGetSubtypes(LLVMTypeRef Tp, LLVMTypeRef *Arr);
1316
1317/**
1318 * Return the number of types in the derived type.
1319 *
1320 * @see llvm::Type::getNumContainedTypes()
1321 */
1322unsigned LLVMGetNumContainedTypes(LLVMTypeRef Tp);
1323
1324/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00001325 * Create a fixed size array type that refers to a specific type.
1326 *
1327 * The created type will exist in the context that its element type
1328 * exists in.
1329 *
1330 * @see llvm::ArrayType::get()
1331 */
Gordon Henriksened7beaa2007-10-06 16:05:20 +00001332LLVMTypeRef LLVMArrayType(LLVMTypeRef ElementType, unsigned ElementCount);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001333
1334/**
1335 * Obtain the length of an array type.
1336 *
1337 * This only works on types that represent arrays.
1338 *
1339 * @see llvm::ArrayType::getNumElements()
1340 */
1341unsigned LLVMGetArrayLength(LLVMTypeRef ArrayTy);
1342
1343/**
1344 * Create a pointer type that points to a defined type.
1345 *
1346 * The created type will exist in the context that its pointee type
1347 * exists in.
1348 *
1349 * @see llvm::PointerType::get()
1350 */
Gordon Henriksen5a3fe032007-12-17 16:08:32 +00001351LLVMTypeRef LLVMPointerType(LLVMTypeRef ElementType, unsigned AddressSpace);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001352
1353/**
1354 * Obtain the address space of a pointer type.
1355 *
1356 * This only works on types that represent pointers.
1357 *
1358 * @see llvm::PointerType::getAddressSpace()
1359 */
1360unsigned LLVMGetPointerAddressSpace(LLVMTypeRef PointerTy);
1361
1362/**
1363 * Create a vector type that contains a defined type and has a specific
1364 * number of elements.
1365 *
1366 * The created type will exist in the context thats its element type
1367 * exists in.
1368 *
1369 * @see llvm::VectorType::get()
1370 */
Gordon Henriksened7beaa2007-10-06 16:05:20 +00001371LLVMTypeRef LLVMVectorType(LLVMTypeRef ElementType, unsigned ElementCount);
Gordon Henriksen76a03742007-09-18 03:18:57 +00001372
Gregory Szorc34c863a2012-03-21 03:54:29 +00001373/**
1374 * Obtain the number of elements in a vector type.
1375 *
1376 * This only works on types that represent vectors.
1377 *
1378 * @see llvm::VectorType::getNumElements()
1379 */
Gordon Henriksen76a03742007-09-18 03:18:57 +00001380unsigned LLVMGetVectorSize(LLVMTypeRef VectorTy);
1381
Gregory Szorc34c863a2012-03-21 03:54:29 +00001382/**
1383 * @}
1384 */
1385
1386/**
1387 * @defgroup LLVMCCoreTypeOther Other Types
1388 *
1389 * @{
1390 */
1391
1392/**
1393 * Create a void type in a context.
1394 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +00001395LLVMTypeRef LLVMVoidTypeInContext(LLVMContextRef C);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001396
1397/**
1398 * Create a label type in a context.
1399 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +00001400LLVMTypeRef LLVMLabelTypeInContext(LLVMContextRef C);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001401
1402/**
1403 * Create a X86 MMX type in a context.
1404 */
Dale Johannesen95b67af2010-09-10 21:58:02 +00001405LLVMTypeRef LLVMX86MMXTypeInContext(LLVMContextRef C);
Erick Tryzelaar262332f2009-08-14 00:01:31 +00001406
Gregory Szorc34c863a2012-03-21 03:54:29 +00001407/**
whitequark131f98f2017-10-27 11:51:40 +00001408 * Create a token type in a context.
1409 */
1410LLVMTypeRef LLVMTokenTypeInContext(LLVMContextRef C);
1411
1412/**
1413 * Create a metadata type in a context.
1414 */
1415LLVMTypeRef LLVMMetadataTypeInContext(LLVMContextRef C);
1416
1417/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00001418 * These are similar to the above functions except they operate on the
1419 * global context.
1420 */
Gordon Henriksena735a9c2008-05-04 12:55:34 +00001421LLVMTypeRef LLVMVoidType(void);
1422LLVMTypeRef LLVMLabelType(void);
Dale Johannesen95b67af2010-09-10 21:58:02 +00001423LLVMTypeRef LLVMX86MMXType(void);
Gordon Henriksen76a03742007-09-18 03:18:57 +00001424
Gregory Szorc34c863a2012-03-21 03:54:29 +00001425/**
1426 * @}
1427 */
Gordon Henriksen76a03742007-09-18 03:18:57 +00001428
Gregory Szorc34c863a2012-03-21 03:54:29 +00001429/**
1430 * @}
1431 */
1432
1433/**
1434 * @defgroup LLVMCCoreValues Values
1435 *
1436 * The bulk of LLVM's object model consists of values, which comprise a very
Gordon Henriksen76a03742007-09-18 03:18:57 +00001437 * rich type hierarchy.
Gregory Szorc34c863a2012-03-21 03:54:29 +00001438 *
1439 * LLVMValueRef essentially represents llvm::Value. There is a rich
1440 * hierarchy of classes within this type. Depending on the instance
Eli Benderskyc52863c2012-08-10 18:30:44 +00001441 * obtained, not all APIs are available.
Gregory Szorc34c863a2012-03-21 03:54:29 +00001442 *
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00001443 * Callers can determine the type of an LLVMValueRef by calling the
Gregory Szorc34c863a2012-03-21 03:54:29 +00001444 * LLVMIsA* family of functions (e.g. LLVMIsAArgument()). These
1445 * functions are defined by a macro, so it isn't obvious which are
1446 * available by looking at the Doxygen source code. Instead, look at the
1447 * source definition of LLVM_FOR_EACH_VALUE_SUBCLASS and note the list
1448 * of value names given. These value names also correspond to classes in
1449 * the llvm::Value hierarchy.
1450 *
1451 * @{
Gordon Henriksen76a03742007-09-18 03:18:57 +00001452 */
1453
Gordon Henriksen29e38942008-12-19 18:39:45 +00001454#define LLVM_FOR_EACH_VALUE_SUBCLASS(macro) \
1455 macro(Argument) \
1456 macro(BasicBlock) \
1457 macro(InlineAsm) \
1458 macro(User) \
1459 macro(Constant) \
Torok Edwind09b7572011-10-14 20:37:56 +00001460 macro(BlockAddress) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001461 macro(ConstantAggregateZero) \
1462 macro(ConstantArray) \
Peter Zotovae0344b2013-11-05 12:55:37 +00001463 macro(ConstantDataSequential) \
1464 macro(ConstantDataArray) \
1465 macro(ConstantDataVector) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001466 macro(ConstantExpr) \
1467 macro(ConstantFP) \
1468 macro(ConstantInt) \
1469 macro(ConstantPointerNull) \
1470 macro(ConstantStruct) \
David Majnemerf0f224d2015-11-11 21:57:16 +00001471 macro(ConstantTokenNone) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001472 macro(ConstantVector) \
1473 macro(GlobalValue) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001474 macro(GlobalAlias) \
whitequarkd299b2c2018-09-18 00:01:12 +00001475 macro(GlobalIFunc) \
Rafael Espindola99e05cf2014-05-13 18:45:48 +00001476 macro(GlobalObject) \
1477 macro(Function) \
1478 macro(GlobalVariable) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001479 macro(UndefValue) \
1480 macro(Instruction) \
1481 macro(BinaryOperator) \
1482 macro(CallInst) \
1483 macro(IntrinsicInst) \
1484 macro(DbgInfoIntrinsic) \
Hsiangkai Wangef72e482018-08-06 03:59:47 +00001485 macro(DbgVariableIntrinsic) \
1486 macro(DbgDeclareInst) \
1487 macro(DbgLabelInst) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001488 macro(MemIntrinsic) \
1489 macro(MemCpyInst) \
1490 macro(MemMoveInst) \
1491 macro(MemSetInst) \
1492 macro(CmpInst) \
Torok Edwind09b7572011-10-14 20:37:56 +00001493 macro(FCmpInst) \
1494 macro(ICmpInst) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001495 macro(ExtractElementInst) \
1496 macro(GetElementPtrInst) \
1497 macro(InsertElementInst) \
1498 macro(InsertValueInst) \
Bill Wendlingfae14752011-08-12 20:24:12 +00001499 macro(LandingPadInst) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001500 macro(PHINode) \
1501 macro(SelectInst) \
1502 macro(ShuffleVectorInst) \
1503 macro(StoreInst) \
1504 macro(TerminatorInst) \
1505 macro(BranchInst) \
Torok Edwind09b7572011-10-14 20:37:56 +00001506 macro(IndirectBrInst) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001507 macro(InvokeInst) \
1508 macro(ReturnInst) \
1509 macro(SwitchInst) \
1510 macro(UnreachableInst) \
Bill Wendlingf891bf82011-07-31 06:30:59 +00001511 macro(ResumeInst) \
David Majnemer654e1302015-07-31 17:58:14 +00001512 macro(CleanupReturnInst) \
1513 macro(CatchReturnInst) \
David Majnemer8a1c45d2015-12-12 05:38:55 +00001514 macro(FuncletPadInst) \
1515 macro(CatchPadInst) \
1516 macro(CleanupPadInst) \
Duncan Sands5e37e992013-05-06 08:55:45 +00001517 macro(UnaryInstruction) \
1518 macro(AllocaInst) \
1519 macro(CastInst) \
Matt Arsenaultb03bd4d2013-11-15 01:34:59 +00001520 macro(AddrSpaceCastInst) \
Duncan Sands5e37e992013-05-06 08:55:45 +00001521 macro(BitCastInst) \
1522 macro(FPExtInst) \
1523 macro(FPToSIInst) \
1524 macro(FPToUIInst) \
1525 macro(FPTruncInst) \
1526 macro(IntToPtrInst) \
1527 macro(PtrToIntInst) \
1528 macro(SExtInst) \
1529 macro(SIToFPInst) \
1530 macro(TruncInst) \
1531 macro(UIToFPInst) \
1532 macro(ZExtInst) \
1533 macro(ExtractValueInst) \
1534 macro(LoadInst) \
1535 macro(VAArgInst)
Gordon Henriksen29e38942008-12-19 18:39:45 +00001536
Gregory Szorc34c863a2012-03-21 03:54:29 +00001537/**
1538 * @defgroup LLVMCCoreValueGeneral General APIs
1539 *
1540 * Functions in this section work on all LLVMValueRef instances,
1541 * regardless of their sub-type. They correspond to functions available
1542 * on llvm::Value.
1543 *
1544 * @{
1545 */
Gordon Henriksen76a03742007-09-18 03:18:57 +00001546
Gregory Szorc34c863a2012-03-21 03:54:29 +00001547/**
1548 * Obtain the type of a value.
1549 *
1550 * @see llvm::Value::getType()
1551 */
1552LLVMTypeRef LLVMTypeOf(LLVMValueRef Val);
1553
1554/**
Peter Zotov3e4561c2016-04-06 22:21:29 +00001555 * Obtain the enumerated type of a Value instance.
1556 *
1557 * @see llvm::Value::getValueID()
1558 */
1559LLVMValueKind LLVMGetValueKind(LLVMValueRef Val);
1560
1561/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00001562 * Obtain the string name of a value.
1563 *
1564 * @see llvm::Value::getName()
1565 */
Robert Widmann025c78f2018-05-19 15:08:36 +00001566const char *LLVMGetValueName2(LLVMValueRef Val, size_t *Length);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001567
1568/**
1569 * Set the string name of a value.
1570 *
1571 * @see llvm::Value::setName()
1572 */
Robert Widmann025c78f2018-05-19 15:08:36 +00001573void LLVMSetValueName2(LLVMValueRef Val, const char *Name, size_t NameLen);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001574
1575/**
1576 * Dump a representation of a value to stderr.
1577 *
1578 * @see llvm::Value::dump()
1579 */
1580void LLVMDumpValue(LLVMValueRef Val);
1581
1582/**
Peter Zotovcd93b372013-11-06 09:21:01 +00001583 * Return a string representation of the value. Use
1584 * LLVMDisposeMessage to free the string.
1585 *
1586 * @see llvm::Value::print()
1587 */
1588char *LLVMPrintValueToString(LLVMValueRef Val);
1589
1590/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00001591 * Replace all uses of a value with another one.
1592 *
1593 * @see llvm::Value::replaceAllUsesWith()
1594 */
1595void LLVMReplaceAllUsesWith(LLVMValueRef OldVal, LLVMValueRef NewVal);
1596
1597/**
Amaury Sechet1c395072016-01-18 01:06:52 +00001598 * Determine whether the specified value instance is constant.
Gregory Szorc34c863a2012-03-21 03:54:29 +00001599 */
1600LLVMBool LLVMIsConstant(LLVMValueRef Val);
1601
1602/**
1603 * Determine whether a value instance is undefined.
1604 */
1605LLVMBool LLVMIsUndef(LLVMValueRef Val);
1606
1607/**
1608 * Convert value instances between types.
1609 *
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00001610 * Internally, an LLVMValueRef is "pinned" to a specific type. This
Gregory Szorc34c863a2012-03-21 03:54:29 +00001611 * series of functions allows you to cast an instance to a specific
1612 * type.
1613 *
1614 * If the cast is not valid for the specified type, NULL is returned.
1615 *
1616 * @see llvm::dyn_cast_or_null<>
1617 */
Gordon Henriksen29e38942008-12-19 18:39:45 +00001618#define LLVM_DECLARE_VALUE_CAST(name) \
1619 LLVMValueRef LLVMIsA##name(LLVMValueRef Val);
1620LLVM_FOR_EACH_VALUE_SUBCLASS(LLVM_DECLARE_VALUE_CAST)
1621
Duncan P. N. Exon Smith5bf8fef2014-12-09 18:38:53 +00001622LLVMValueRef LLVMIsAMDNode(LLVMValueRef Val);
1623LLVMValueRef LLVMIsAMDString(LLVMValueRef Val);
1624
Robert Widmann025c78f2018-05-19 15:08:36 +00001625/** Deprecated: Use LLVMGetValueName2 instead. */
1626const char *LLVMGetValueName(LLVMValueRef Val);
1627/** Deprecated: Use LLVMSetValueName2 instead. */
1628void LLVMSetValueName(LLVMValueRef Val, const char *Name);
1629
Gregory Szorc34c863a2012-03-21 03:54:29 +00001630/**
1631 * @}
1632 */
1633
1634/**
1635 * @defgroup LLVMCCoreValueUses Usage
1636 *
1637 * This module defines functions that allow you to inspect the uses of a
1638 * LLVMValueRef.
1639 *
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00001640 * It is possible to obtain an LLVMUseRef for any LLVMValueRef instance.
Gregory Szorc34c863a2012-03-21 03:54:29 +00001641 * Each LLVMUseRef (which corresponds to a llvm::Use instance) holds a
1642 * llvm::User and llvm::Value.
1643 *
1644 * @{
1645 */
1646
1647/**
1648 * Obtain the first use of a value.
1649 *
1650 * Uses are obtained in an iterator fashion. First, call this function
1651 * to obtain a reference to the first use. Then, call LLVMGetNextUse()
Eli Benderskyc52863c2012-08-10 18:30:44 +00001652 * on that instance and all subsequently obtained instances until
Gregory Szorc34c863a2012-03-21 03:54:29 +00001653 * LLVMGetNextUse() returns NULL.
1654 *
1655 * @see llvm::Value::use_begin()
1656 */
Erick Tryzelaar9f9857e2010-03-02 20:32:28 +00001657LLVMUseRef LLVMGetFirstUse(LLVMValueRef Val);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001658
1659/**
1660 * Obtain the next use of a value.
1661 *
1662 * This effectively advances the iterator. It returns NULL if you are on
1663 * the final use and no more are available.
1664 */
Erick Tryzelaar9f9857e2010-03-02 20:32:28 +00001665LLVMUseRef LLVMGetNextUse(LLVMUseRef U);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001666
1667/**
1668 * Obtain the user value for a user.
1669 *
1670 * The returned value corresponds to a llvm::User type.
1671 *
1672 * @see llvm::Use::getUser()
1673 */
Erick Tryzelaar9f9857e2010-03-02 20:32:28 +00001674LLVMValueRef LLVMGetUser(LLVMUseRef U);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001675
1676/**
1677 * Obtain the value this use corresponds to.
1678 *
1679 * @see llvm::Use::get().
1680 */
Erick Tryzelaar9f9857e2010-03-02 20:32:28 +00001681LLVMValueRef LLVMGetUsedValue(LLVMUseRef U);
Chris Lattner40cf28d2009-10-12 04:01:02 +00001682
Gregory Szorc34c863a2012-03-21 03:54:29 +00001683/**
1684 * @}
1685 */
1686
1687/**
Gregory Szorc52d26602012-03-21 07:28:27 +00001688 * @defgroup LLVMCCoreValueUser User value
Gregory Szorc34c863a2012-03-21 03:54:29 +00001689 *
1690 * Function in this group pertain to LLVMValueRef instances that descent
1691 * from llvm::User. This includes constants, instructions, and
1692 * operators.
1693 *
1694 * @{
1695 */
1696
1697/**
1698 * Obtain an operand at a specific index in a llvm::User value.
1699 *
1700 * @see llvm::User::getOperand()
1701 */
Chris Lattner40cf28d2009-10-12 04:01:02 +00001702LLVMValueRef LLVMGetOperand(LLVMValueRef Val, unsigned Index);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001703
1704/**
Peter Zotovb19f78f2014-08-12 02:55:40 +00001705 * Obtain the use of an operand at a specific index in a llvm::User value.
1706 *
1707 * @see llvm::User::getOperandUse()
1708 */
1709LLVMUseRef LLVMGetOperandUse(LLVMValueRef Val, unsigned Index);
1710
1711/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00001712 * Set an operand at a specific index in a llvm::User value.
1713 *
1714 * @see llvm::User::setOperand()
1715 */
Erick Tryzelaarb4d48702010-08-20 14:51:22 +00001716void LLVMSetOperand(LLVMValueRef User, unsigned Index, LLVMValueRef Val);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001717
1718/**
1719 * Obtain the number of operands in a llvm::User value.
1720 *
1721 * @see llvm::User::getNumOperands()
1722 */
Erick Tryzelaarb4d48702010-08-20 14:51:22 +00001723int LLVMGetNumOperands(LLVMValueRef Val);
Chris Lattner40cf28d2009-10-12 04:01:02 +00001724
Gregory Szorc34c863a2012-03-21 03:54:29 +00001725/**
1726 * @}
1727 */
1728
1729/**
Gregory Szorc52d26602012-03-21 07:28:27 +00001730 * @defgroup LLVMCCoreValueConstant Constants
Gregory Szorc34c863a2012-03-21 03:54:29 +00001731 *
1732 * This section contains APIs for interacting with LLVMValueRef that
1733 * correspond to llvm::Constant instances.
1734 *
1735 * These functions will work for any LLVMValueRef in the llvm::Constant
1736 * class hierarchy.
1737 *
1738 * @{
1739 */
1740
1741/**
1742 * Obtain a constant value referring to the null instance of a type.
1743 *
1744 * @see llvm::Constant::getNullValue()
1745 */
Gordon Henriksen1046c732007-10-06 15:11:06 +00001746LLVMValueRef LLVMConstNull(LLVMTypeRef Ty); /* all zeroes */
Gregory Szorc34c863a2012-03-21 03:54:29 +00001747
1748/**
1749 * Obtain a constant value referring to the instance of a type
1750 * consisting of all ones.
1751 *
1752 * This is only valid for integer types.
1753 *
1754 * @see llvm::Constant::getAllOnesValue()
1755 */
1756LLVMValueRef LLVMConstAllOnes(LLVMTypeRef Ty);
1757
1758/**
1759 * Obtain a constant value referring to an undefined value of a type.
1760 *
1761 * @see llvm::UndefValue::get()
1762 */
Gordon Henriksen76a03742007-09-18 03:18:57 +00001763LLVMValueRef LLVMGetUndef(LLVMTypeRef Ty);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001764
1765/**
1766 * Determine whether a value instance is null.
1767 *
1768 * @see llvm::Constant::isNullValue()
1769 */
Chris Lattner25963c62010-01-09 22:27:07 +00001770LLVMBool LLVMIsNull(LLVMValueRef Val);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001771
1772/**
1773 * Obtain a constant that is a constant pointer pointing to NULL for a
1774 * specified type.
1775 */
Chris Lattner7f318242009-07-06 17:29:59 +00001776LLVMValueRef LLVMConstPointerNull(LLVMTypeRef Ty);
Gordon Henriksen76a03742007-09-18 03:18:57 +00001777
Gregory Szorc34c863a2012-03-21 03:54:29 +00001778/**
1779 * @defgroup LLVMCCoreValueConstantScalar Scalar constants
1780 *
1781 * Functions in this group model LLVMValueRef instances that correspond
1782 * to constants referring to scalar types.
1783 *
1784 * For integer types, the LLVMTypeRef parameter should correspond to a
1785 * llvm::IntegerType instance and the returned LLVMValueRef will
1786 * correspond to a llvm::ConstantInt.
1787 *
1788 * For floating point types, the LLVMTypeRef returned corresponds to a
1789 * llvm::ConstantFP.
1790 *
1791 * @{
1792 */
Erick Tryzelaard8531fa2010-02-28 09:45:59 +00001793
Gregory Szorc34c863a2012-03-21 03:54:29 +00001794/**
1795 * Obtain a constant value for an integer type.
1796 *
1797 * The returned value corresponds to a llvm::ConstantInt.
1798 *
1799 * @see llvm::ConstantInt::get()
1800 *
1801 * @param IntTy Integer type to obtain value of.
1802 * @param N The value the returned instance should refer to.
1803 * @param SignExtend Whether to sign extend the produced value.
1804 */
Gordon Henriksen1046c732007-10-06 15:11:06 +00001805LLVMValueRef LLVMConstInt(LLVMTypeRef IntTy, unsigned long long N,
Chris Lattner25963c62010-01-09 22:27:07 +00001806 LLVMBool SignExtend);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001807
1808/**
1809 * Obtain a constant value for an integer of arbitrary precision.
1810 *
1811 * @see llvm::ConstantInt::get()
1812 */
Chris Lattner4329e072010-11-23 02:47:22 +00001813LLVMValueRef LLVMConstIntOfArbitraryPrecision(LLVMTypeRef IntTy,
1814 unsigned NumWords,
1815 const uint64_t Words[]);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001816
1817/**
1818 * Obtain a constant value for an integer parsed from a string.
1819 *
1820 * A similar API, LLVMConstIntOfStringAndSize is also available. If the
1821 * string's length is available, it is preferred to call that function
1822 * instead.
1823 *
1824 * @see llvm::ConstantInt::get()
1825 */
Erick Tryzelaardd991352009-08-16 23:36:46 +00001826LLVMValueRef LLVMConstIntOfString(LLVMTypeRef IntTy, const char *Text,
1827 uint8_t Radix);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001828
1829/**
1830 * Obtain a constant value for an integer parsed from a string with
1831 * specified length.
1832 *
1833 * @see llvm::ConstantInt::get()
1834 */
Erick Tryzelaardd991352009-08-16 23:36:46 +00001835LLVMValueRef LLVMConstIntOfStringAndSize(LLVMTypeRef IntTy, const char *Text,
1836 unsigned SLen, uint8_t Radix);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001837
1838/**
1839 * Obtain a constant value referring to a double floating point value.
1840 */
Gordon Henriksen1046c732007-10-06 15:11:06 +00001841LLVMValueRef LLVMConstReal(LLVMTypeRef RealTy, double N);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001842
1843/**
1844 * Obtain a constant for a floating point value parsed from a string.
1845 *
1846 * A similar API, LLVMConstRealOfStringAndSize is also available. It
1847 * should be used if the input string's length is known.
1848 */
Gordon Henriksen931e1212008-02-02 01:07:50 +00001849LLVMValueRef LLVMConstRealOfString(LLVMTypeRef RealTy, const char *Text);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001850
1851/**
1852 * Obtain a constant for a floating point value parsed from a string.
1853 */
Erick Tryzelaardd991352009-08-16 23:36:46 +00001854LLVMValueRef LLVMConstRealOfStringAndSize(LLVMTypeRef RealTy, const char *Text,
1855 unsigned SLen);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001856
1857/**
1858 * Obtain the zero extended value for an integer constant value.
1859 *
1860 * @see llvm::ConstantInt::getZExtValue()
1861 */
Chris Lattner40cf28d2009-10-12 04:01:02 +00001862unsigned long long LLVMConstIntGetZExtValue(LLVMValueRef ConstantVal);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001863
1864/**
1865 * Obtain the sign extended value for an integer constant value.
1866 *
1867 * @see llvm::ConstantInt::getSExtValue()
1868 */
Chris Lattner40cf28d2009-10-12 04:01:02 +00001869long long LLVMConstIntGetSExtValue(LLVMValueRef ConstantVal);
Erick Tryzelaardd991352009-08-16 23:36:46 +00001870
Gregory Szorc34c863a2012-03-21 03:54:29 +00001871/**
Peter Zotov1d98e6d2014-10-28 19:46:44 +00001872 * Obtain the double value for an floating point constant value.
1873 * losesInfo indicates if some precision was lost in the conversion.
1874 *
1875 * @see llvm::ConstantFP::getDoubleValue
1876 */
1877double LLVMConstRealGetDouble(LLVMValueRef ConstantVal, LLVMBool *losesInfo);
1878
1879/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00001880 * @}
1881 */
1882
1883/**
Gregory Szorc52d26602012-03-21 07:28:27 +00001884 * @defgroup LLVMCCoreValueConstantComposite Composite Constants
1885 *
1886 * Functions in this group operate on composite constants.
Gregory Szorc34c863a2012-03-21 03:54:29 +00001887 *
1888 * @{
1889 */
1890
1891/**
Gregory Szorc52d26602012-03-21 07:28:27 +00001892 * Create a ConstantDataSequential and initialize it with a string.
Gregory Szorc34c863a2012-03-21 03:54:29 +00001893 *
Gregory Szorc52d26602012-03-21 07:28:27 +00001894 * @see llvm::ConstantDataArray::getString()
Gregory Szorc34c863a2012-03-21 03:54:29 +00001895 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +00001896LLVMValueRef LLVMConstStringInContext(LLVMContextRef C, const char *Str,
Chris Lattner25963c62010-01-09 22:27:07 +00001897 unsigned Length, LLVMBool DontNullTerminate);
Gregory Szorc52d26602012-03-21 07:28:27 +00001898
1899/**
1900 * Create a ConstantDataSequential with string content in the global context.
1901 *
1902 * This is the same as LLVMConstStringInContext except it operates on the
1903 * global context.
1904 *
1905 * @see LLVMConstStringInContext()
1906 * @see llvm::ConstantDataArray::getString()
1907 */
1908LLVMValueRef LLVMConstString(const char *Str, unsigned Length,
1909 LLVMBool DontNullTerminate);
1910
1911/**
Peter Zotovf9aa8822014-08-03 23:54:16 +00001912 * Returns true if the specified constant is an array of i8.
1913 *
1914 * @see ConstantDataSequential::getAsString()
1915 */
1916LLVMBool LLVMIsConstantString(LLVMValueRef c);
1917
1918/**
1919 * Get the given constant data sequential as a string.
1920 *
1921 * @see ConstantDataSequential::getAsString()
1922 */
Amaury Sechet7c2883c2016-04-03 21:06:04 +00001923const char *LLVMGetAsString(LLVMValueRef c, size_t *Length);
Peter Zotovf9aa8822014-08-03 23:54:16 +00001924
1925/**
Gregory Szorc52d26602012-03-21 07:28:27 +00001926 * Create an anonymous ConstantStruct with the specified values.
1927 *
1928 * @see llvm::ConstantStruct::getAnon()
1929 */
1930LLVMValueRef LLVMConstStructInContext(LLVMContextRef C,
Erick Tryzelaar262332f2009-08-14 00:01:31 +00001931 LLVMValueRef *ConstantVals,
Chris Lattner25963c62010-01-09 22:27:07 +00001932 unsigned Count, LLVMBool Packed);
Erick Tryzelaar262332f2009-08-14 00:01:31 +00001933
Gregory Szorc52d26602012-03-21 07:28:27 +00001934/**
1935 * Create a ConstantStruct in the global Context.
1936 *
1937 * This is the same as LLVMConstStructInContext except it operates on the
1938 * global Context.
1939 *
1940 * @see LLVMConstStructInContext()
1941 */
Gordon Henriksen1046c732007-10-06 15:11:06 +00001942LLVMValueRef LLVMConstStruct(LLVMValueRef *ConstantVals, unsigned Count,
Chris Lattner25963c62010-01-09 22:27:07 +00001943 LLVMBool Packed);
Gregory Szorc52d26602012-03-21 07:28:27 +00001944
1945/**
1946 * Create a ConstantArray from values.
1947 *
1948 * @see llvm::ConstantArray::get()
1949 */
1950LLVMValueRef LLVMConstArray(LLVMTypeRef ElementTy,
1951 LLVMValueRef *ConstantVals, unsigned Length);
1952
1953/**
1954 * Create a non-anonymous ConstantStruct from values.
1955 *
1956 * @see llvm::ConstantStruct::get()
1957 */
Rafael Espindola784ad242011-07-14 19:09:08 +00001958LLVMValueRef LLVMConstNamedStruct(LLVMTypeRef StructTy,
1959 LLVMValueRef *ConstantVals,
1960 unsigned Count);
Gregory Szorc52d26602012-03-21 07:28:27 +00001961
1962/**
Peter Zotovf9aa8822014-08-03 23:54:16 +00001963 * Get an element at specified index as a constant.
1964 *
1965 * @see ConstantDataSequential::getElementAsConstant()
1966 */
Amaury Sechet006ce632016-03-13 00:54:40 +00001967LLVMValueRef LLVMGetElementAsConstant(LLVMValueRef C, unsigned idx);
Peter Zotovf9aa8822014-08-03 23:54:16 +00001968
1969/**
Gregory Szorc52d26602012-03-21 07:28:27 +00001970 * Create a ConstantVector from values.
1971 *
1972 * @see llvm::ConstantVector::get()
1973 */
Gordon Henriksen1046c732007-10-06 15:11:06 +00001974LLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals, unsigned Size);
Gordon Henriksen76a03742007-09-18 03:18:57 +00001975
Gregory Szorc52d26602012-03-21 07:28:27 +00001976/**
1977 * @}
1978 */
1979
1980/**
1981 * @defgroup LLVMCCoreValueConstantExpressions Constant Expressions
1982 *
1983 * Functions in this group correspond to APIs on llvm::ConstantExpr.
1984 *
1985 * @see llvm::ConstantExpr.
1986 *
1987 * @{
1988 */
Chris Lattner40cf28d2009-10-12 04:01:02 +00001989LLVMOpcode LLVMGetConstOpcode(LLVMValueRef ConstantVal);
Erick Tryzelaarfd529d72009-08-19 08:36:49 +00001990LLVMValueRef LLVMAlignOf(LLVMTypeRef Ty);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001991LLVMValueRef LLVMSizeOf(LLVMTypeRef Ty);
1992LLVMValueRef LLVMConstNeg(LLVMValueRef ConstantVal);
Erick Tryzelaar4c340c72010-02-28 05:51:43 +00001993LLVMValueRef LLVMConstNSWNeg(LLVMValueRef ConstantVal);
1994LLVMValueRef LLVMConstNUWNeg(LLVMValueRef ConstantVal);
Erick Tryzelaar4cc690c2009-08-16 02:20:12 +00001995LLVMValueRef LLVMConstFNeg(LLVMValueRef ConstantVal);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001996LLVMValueRef LLVMConstNot(LLVMValueRef ConstantVal);
1997LLVMValueRef LLVMConstAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Dan Gohmane4ca02d2009-09-03 23:34:49 +00001998LLVMValueRef LLVMConstNSWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Erick Tryzelaar4c340c72010-02-28 05:51:43 +00001999LLVMValueRef LLVMConstNUWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Erick Tryzelaar4cc690c2009-08-16 02:20:12 +00002000LLVMValueRef LLVMConstFAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00002001LLVMValueRef LLVMConstSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Erick Tryzelaar4c340c72010-02-28 05:51:43 +00002002LLVMValueRef LLVMConstNSWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2003LLVMValueRef LLVMConstNUWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Erick Tryzelaar4cc690c2009-08-16 02:20:12 +00002004LLVMValueRef LLVMConstFSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00002005LLVMValueRef LLVMConstMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Erick Tryzelaar4c340c72010-02-28 05:51:43 +00002006LLVMValueRef LLVMConstNSWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2007LLVMValueRef LLVMConstNUWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Erick Tryzelaar4cc690c2009-08-16 02:20:12 +00002008LLVMValueRef LLVMConstFMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00002009LLVMValueRef LLVMConstUDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Manuel Jacob49fafb12016-10-04 23:32:42 +00002010LLVMValueRef LLVMConstExactUDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00002011LLVMValueRef LLVMConstSDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Dan Gohmane4ca02d2009-09-03 23:34:49 +00002012LLVMValueRef LLVMConstExactSDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00002013LLVMValueRef LLVMConstFDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2014LLVMValueRef LLVMConstURem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2015LLVMValueRef LLVMConstSRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2016LLVMValueRef LLVMConstFRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2017LLVMValueRef LLVMConstAnd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2018LLVMValueRef LLVMConstOr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2019LLVMValueRef LLVMConstXor(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2020LLVMValueRef LLVMConstICmp(LLVMIntPredicate Predicate,
2021 LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2022LLVMValueRef LLVMConstFCmp(LLVMRealPredicate Predicate,
2023 LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2024LLVMValueRef LLVMConstShl(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2025LLVMValueRef LLVMConstLShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2026LLVMValueRef LLVMConstAShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2027LLVMValueRef LLVMConstGEP(LLVMValueRef ConstantVal,
2028 LLVMValueRef *ConstantIndices, unsigned NumIndices);
Dan Gohmane4ca02d2009-09-03 23:34:49 +00002029LLVMValueRef LLVMConstInBoundsGEP(LLVMValueRef ConstantVal,
2030 LLVMValueRef *ConstantIndices,
2031 unsigned NumIndices);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00002032LLVMValueRef LLVMConstTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
2033LLVMValueRef LLVMConstSExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
2034LLVMValueRef LLVMConstZExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
2035LLVMValueRef LLVMConstFPTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
2036LLVMValueRef LLVMConstFPExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
2037LLVMValueRef LLVMConstUIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
2038LLVMValueRef LLVMConstSIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
2039LLVMValueRef LLVMConstFPToUI(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
2040LLVMValueRef LLVMConstFPToSI(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
2041LLVMValueRef LLVMConstPtrToInt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
2042LLVMValueRef LLVMConstIntToPtr(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
2043LLVMValueRef LLVMConstBitCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
Matt Arsenaultb03bd4d2013-11-15 01:34:59 +00002044LLVMValueRef LLVMConstAddrSpaceCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
Erick Tryzelaar4cc690c2009-08-16 02:20:12 +00002045LLVMValueRef LLVMConstZExtOrBitCast(LLVMValueRef ConstantVal,
2046 LLVMTypeRef ToType);
2047LLVMValueRef LLVMConstSExtOrBitCast(LLVMValueRef ConstantVal,
2048 LLVMTypeRef ToType);
2049LLVMValueRef LLVMConstTruncOrBitCast(LLVMValueRef ConstantVal,
2050 LLVMTypeRef ToType);
2051LLVMValueRef LLVMConstPointerCast(LLVMValueRef ConstantVal,
2052 LLVMTypeRef ToType);
2053LLVMValueRef LLVMConstIntCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType,
Chris Lattner25963c62010-01-09 22:27:07 +00002054 LLVMBool isSigned);
Erick Tryzelaar4cc690c2009-08-16 02:20:12 +00002055LLVMValueRef LLVMConstFPCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00002056LLVMValueRef LLVMConstSelect(LLVMValueRef ConstantCondition,
2057 LLVMValueRef ConstantIfTrue,
2058 LLVMValueRef ConstantIfFalse);
2059LLVMValueRef LLVMConstExtractElement(LLVMValueRef VectorConstant,
2060 LLVMValueRef IndexConstant);
2061LLVMValueRef LLVMConstInsertElement(LLVMValueRef VectorConstant,
2062 LLVMValueRef ElementValueConstant,
2063 LLVMValueRef IndexConstant);
2064LLVMValueRef LLVMConstShuffleVector(LLVMValueRef VectorAConstant,
2065 LLVMValueRef VectorBConstant,
2066 LLVMValueRef MaskConstant);
Dan Gohmand5104a52008-11-03 22:55:43 +00002067LLVMValueRef LLVMConstExtractValue(LLVMValueRef AggConstant, unsigned *IdxList,
2068 unsigned NumIdx);
2069LLVMValueRef LLVMConstInsertValue(LLVMValueRef AggConstant,
2070 LLVMValueRef ElementValueConstant,
2071 unsigned *IdxList, unsigned NumIdx);
Robert Widmannf108d572018-04-06 02:31:29 +00002072LLVMValueRef LLVMBlockAddress(LLVMValueRef F, LLVMBasicBlockRef BB);
2073
2074/** Deprecated: Use LLVMGetInlineAsm instead. */
Chris Lattner25963c62010-01-09 22:27:07 +00002075LLVMValueRef LLVMConstInlineAsm(LLVMTypeRef Ty,
Chris Lattner3d1f5522008-12-17 21:39:50 +00002076 const char *AsmString, const char *Constraints,
Chris Lattner25963c62010-01-09 22:27:07 +00002077 LLVMBool HasSideEffects, LLVMBool IsAlignStack);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00002078
Gregory Szorc52d26602012-03-21 07:28:27 +00002079/**
2080 * @}
2081 */
2082
2083/**
2084 * @defgroup LLVMCCoreValueConstantGlobals Global Values
2085 *
2086 * This group contains functions that operate on global values. Functions in
2087 * this group relate to functions in the llvm::GlobalValue class tree.
2088 *
2089 * @see llvm::GlobalValue
2090 *
2091 * @{
2092 */
2093
Gordon Henriksen265f7802008-03-19 01:11:35 +00002094LLVMModuleRef LLVMGetGlobalParent(LLVMValueRef Global);
Chris Lattner25963c62010-01-09 22:27:07 +00002095LLVMBool LLVMIsDeclaration(LLVMValueRef Global);
Gordon Henriksen76a03742007-09-18 03:18:57 +00002096LLVMLinkage LLVMGetLinkage(LLVMValueRef Global);
2097void LLVMSetLinkage(LLVMValueRef Global, LLVMLinkage Linkage);
2098const char *LLVMGetSection(LLVMValueRef Global);
2099void LLVMSetSection(LLVMValueRef Global, const char *Section);
2100LLVMVisibility LLVMGetVisibility(LLVMValueRef Global);
2101void LLVMSetVisibility(LLVMValueRef Global, LLVMVisibility Viz);
Reid Kleckner2fae26f2014-03-05 02:34:23 +00002102LLVMDLLStorageClass LLVMGetDLLStorageClass(LLVMValueRef Global);
2103void LLVMSetDLLStorageClass(LLVMValueRef Global, LLVMDLLStorageClass Class);
Robert Widmann4bb481b2018-03-14 06:45:51 +00002104LLVMUnnamedAddr LLVMGetUnnamedAddress(LLVMValueRef Global);
2105void LLVMSetUnnamedAddress(LLVMValueRef Global, LLVMUnnamedAddr UnnamedAddr);
2106
2107/** Deprecated: Use LLVMGetUnnamedAddress instead. */
Tim Northoverad96d012014-03-10 19:24:35 +00002108LLVMBool LLVMHasUnnamedAddr(LLVMValueRef Global);
Robert Widmann4bb481b2018-03-14 06:45:51 +00002109/** Deprecated: Use LLVMSetUnnamedAddress instead. */
Tim Northoverad96d012014-03-10 19:24:35 +00002110void LLVMSetUnnamedAddr(LLVMValueRef Global, LLVMBool HasUnnamedAddr);
Anders Waldenborg213a63f2013-10-29 09:02:02 +00002111
2112/**
2113 * @defgroup LLVMCCoreValueWithAlignment Values with alignment
2114 *
2115 * Functions in this group only apply to values with alignment, i.e.
2116 * global variables, load and store instructions.
2117 */
2118
2119/**
2120 * Obtain the preferred alignment of the value.
Peter Zotov9f584e62014-03-05 05:05:34 +00002121 * @see llvm::AllocaInst::getAlignment()
Anders Waldenborg213a63f2013-10-29 09:02:02 +00002122 * @see llvm::LoadInst::getAlignment()
2123 * @see llvm::StoreInst::getAlignment()
2124 * @see llvm::GlobalValue::getAlignment()
2125 */
2126unsigned LLVMGetAlignment(LLVMValueRef V);
2127
2128/**
2129 * Set the preferred alignment of the value.
Peter Zotov9f584e62014-03-05 05:05:34 +00002130 * @see llvm::AllocaInst::setAlignment()
Anders Waldenborg213a63f2013-10-29 09:02:02 +00002131 * @see llvm::LoadInst::setAlignment()
2132 * @see llvm::StoreInst::setAlignment()
2133 * @see llvm::GlobalValue::setAlignment()
2134 */
2135void LLVMSetAlignment(LLVMValueRef V, unsigned Bytes);
2136
2137/**
Amaury Sechet83550102016-02-14 08:58:49 +00002138 * @}
2139 */
Gordon Henriksen76a03742007-09-18 03:18:57 +00002140
Gregory Szorc52d26602012-03-21 07:28:27 +00002141/**
2142 * @defgroup LLVMCoreValueConstantGlobalVariable Global Variables
2143 *
2144 * This group contains functions that operate on global variable values.
2145 *
2146 * @see llvm::GlobalVariable
2147 *
2148 * @{
2149 */
Gordon Henriksen76a03742007-09-18 03:18:57 +00002150LLVMValueRef LLVMAddGlobal(LLVMModuleRef M, LLVMTypeRef Ty, const char *Name);
Erick Tryzelaar06894b32010-02-28 09:46:13 +00002151LLVMValueRef LLVMAddGlobalInAddressSpace(LLVMModuleRef M, LLVMTypeRef Ty,
2152 const char *Name,
2153 unsigned AddressSpace);
Gordon Henriksen783f7bb2007-10-08 03:45:09 +00002154LLVMValueRef LLVMGetNamedGlobal(LLVMModuleRef M, const char *Name);
Gordon Henriksen07a45f42008-03-23 22:21:29 +00002155LLVMValueRef LLVMGetFirstGlobal(LLVMModuleRef M);
2156LLVMValueRef LLVMGetLastGlobal(LLVMModuleRef M);
2157LLVMValueRef LLVMGetNextGlobal(LLVMValueRef GlobalVar);
2158LLVMValueRef LLVMGetPreviousGlobal(LLVMValueRef GlobalVar);
Gordon Henriksen76a03742007-09-18 03:18:57 +00002159void LLVMDeleteGlobal(LLVMValueRef GlobalVar);
Gordon Henriksen76a03742007-09-18 03:18:57 +00002160LLVMValueRef LLVMGetInitializer(LLVMValueRef GlobalVar);
2161void LLVMSetInitializer(LLVMValueRef GlobalVar, LLVMValueRef ConstantVal);
Chris Lattner25963c62010-01-09 22:27:07 +00002162LLVMBool LLVMIsThreadLocal(LLVMValueRef GlobalVar);
2163void LLVMSetThreadLocal(LLVMValueRef GlobalVar, LLVMBool IsThreadLocal);
2164LLVMBool LLVMIsGlobalConstant(LLVMValueRef GlobalVar);
2165void LLVMSetGlobalConstant(LLVMValueRef GlobalVar, LLVMBool IsConstant);
Hans Wennborg5ff71202013-04-16 08:58:59 +00002166LLVMThreadLocalMode LLVMGetThreadLocalMode(LLVMValueRef GlobalVar);
2167void LLVMSetThreadLocalMode(LLVMValueRef GlobalVar, LLVMThreadLocalMode Mode);
2168LLVMBool LLVMIsExternallyInitialized(LLVMValueRef GlobalVar);
2169void LLVMSetExternallyInitialized(LLVMValueRef GlobalVar, LLVMBool IsExtInit);
Gordon Henriksen76a03742007-09-18 03:18:57 +00002170
Gregory Szorc52d26602012-03-21 07:28:27 +00002171/**
2172 * @}
2173 */
2174
2175/**
2176 * @defgroup LLVMCoreValueConstantGlobalAlias Global Aliases
2177 *
2178 * This group contains function that operate on global alias values.
2179 *
2180 * @see llvm::GlobalAlias
2181 *
2182 * @{
2183 */
Chris Lattner3d1f5522008-12-17 21:39:50 +00002184LLVMValueRef LLVMAddAlias(LLVMModuleRef M, LLVMTypeRef Ty, LLVMValueRef Aliasee,
2185 const char *Name);
2186
Gregory Szorc34c863a2012-03-21 03:54:29 +00002187/**
Robert Widmann360d6e32018-05-20 23:49:08 +00002188 * Obtain a GlobalAlias value from a Module by its name.
2189 *
2190 * The returned value corresponds to a llvm::GlobalAlias value.
2191 *
2192 * @see llvm::Module::getNamedAlias()
2193 */
2194LLVMValueRef LLVMGetNamedGlobalAlias(LLVMModuleRef M,
2195 const char *Name, size_t NameLen);
2196
2197/**
2198 * Obtain an iterator to the first GlobalAlias in a Module.
2199 *
2200 * @see llvm::Module::alias_begin()
2201 */
2202LLVMValueRef LLVMGetFirstGlobalAlias(LLVMModuleRef M);
2203
2204/**
2205 * Obtain an iterator to the last GlobalAlias in a Module.
2206 *
2207 * @see llvm::Module::alias_end()
2208 */
2209LLVMValueRef LLVMGetLastGlobalAlias(LLVMModuleRef M);
2210
2211/**
2212 * Advance a GlobalAlias iterator to the next GlobalAlias.
2213 *
2214 * Returns NULL if the iterator was already at the end and there are no more
2215 * global aliases.
2216 */
2217LLVMValueRef LLVMGetNextGlobalAlias(LLVMValueRef GA);
2218
2219/**
2220 * Decrement a GlobalAlias iterator to the previous GlobalAlias.
2221 *
2222 * Returns NULL if the iterator was already at the beginning and there are
2223 * no previous global aliases.
2224 */
2225LLVMValueRef LLVMGetPreviousGlobalAlias(LLVMValueRef GA);
2226
2227/**
2228 * Retrieve the target value of an alias.
2229 */
2230LLVMValueRef LLVMAliasGetAliasee(LLVMValueRef Alias);
2231
2232/**
2233 * Set the target value of an alias.
2234 */
2235void LLVMAliasSetAliasee(LLVMValueRef Alias, LLVMValueRef Aliasee);
2236
2237/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002238 * @}
2239 */
2240
2241/**
2242 * @defgroup LLVMCCoreValueFunction Function values
2243 *
2244 * Functions in this group operate on LLVMValueRef instances that
2245 * correspond to llvm::Function instances.
2246 *
2247 * @see llvm::Function
2248 *
2249 * @{
2250 */
2251
2252/**
2253 * Remove a function from its containing module and deletes it.
2254 *
2255 * @see llvm::Function::eraseFromParent()
2256 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002257void LLVMDeleteFunction(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002258
2259/**
Amaury Sechete39e8532016-02-18 20:38:32 +00002260 * Check whether the given function has a personality function.
2261 *
2262 * @see llvm::Function::hasPersonalityFn()
2263 */
2264LLVMBool LLVMHasPersonalityFn(LLVMValueRef Fn);
2265
2266/**
Andrew Wilkins3bdfc1c2015-07-14 01:23:06 +00002267 * Obtain the personality function attached to the function.
2268 *
2269 * @see llvm::Function::getPersonalityFn()
2270 */
2271LLVMValueRef LLVMGetPersonalityFn(LLVMValueRef Fn);
2272
2273/**
2274 * Set the personality function attached to the function.
2275 *
2276 * @see llvm::Function::setPersonalityFn()
2277 */
2278void LLVMSetPersonalityFn(LLVMValueRef Fn, LLVMValueRef PersonalityFn);
2279
2280/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002281 * Obtain the ID number from a function instance.
2282 *
2283 * @see llvm::Function::getIntrinsicID()
2284 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002285unsigned LLVMGetIntrinsicID(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002286
2287/**
2288 * Obtain the calling function of a function.
2289 *
2290 * The returned value corresponds to the LLVMCallConv enumeration.
2291 *
2292 * @see llvm::Function::getCallingConv()
2293 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002294unsigned LLVMGetFunctionCallConv(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002295
2296/**
2297 * Set the calling convention of a function.
2298 *
2299 * @see llvm::Function::setCallingConv()
2300 *
2301 * @param Fn Function to operate on
2302 * @param CC LLVMCallConv to set calling convention to
2303 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002304void LLVMSetFunctionCallConv(LLVMValueRef Fn, unsigned CC);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002305
2306/**
2307 * Obtain the name of the garbage collector to use during code
2308 * generation.
2309 *
2310 * @see llvm::Function::getGC()
2311 */
Gordon Henriksend930f912008-08-17 18:44:35 +00002312const char *LLVMGetGC(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002313
2314/**
2315 * Define the garbage collector to use during code generation.
2316 *
2317 * @see llvm::Function::setGC()
2318 */
Gordon Henriksend930f912008-08-17 18:44:35 +00002319void LLVMSetGC(LLVMValueRef Fn, const char *Name);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002320
2321/**
2322 * Add an attribute to a function.
2323 *
2324 * @see llvm::Function::addAttribute()
2325 */
Amaury Sechet5db224e2016-06-12 06:17:24 +00002326void LLVMAddAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx,
2327 LLVMAttributeRef A);
Amaury Sechet17b67cd2016-07-21 04:25:06 +00002328unsigned LLVMGetAttributeCountAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx);
2329void LLVMGetAttributesAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx,
2330 LLVMAttributeRef *Attrs);
Amaury Sechet5db224e2016-06-12 06:17:24 +00002331LLVMAttributeRef LLVMGetEnumAttributeAtIndex(LLVMValueRef F,
2332 LLVMAttributeIndex Idx,
2333 unsigned KindID);
Amaury Sechet6100adf2016-06-15 17:50:39 +00002334LLVMAttributeRef LLVMGetStringAttributeAtIndex(LLVMValueRef F,
2335 LLVMAttributeIndex Idx,
2336 const char *K, unsigned KLen);
Amaury Sechet5db224e2016-06-12 06:17:24 +00002337void LLVMRemoveEnumAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx,
2338 unsigned KindID);
Amaury Sechet6100adf2016-06-15 17:50:39 +00002339void LLVMRemoveStringAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx,
2340 const char *K, unsigned KLen);
Amaury Sechet5db224e2016-06-12 06:17:24 +00002341
Gregory Szorc34c863a2012-03-21 03:54:29 +00002342/**
Nick Lewyckyc3890d22015-07-29 22:32:47 +00002343 * Add a target-dependent attribute to a function
Tom Stellarde8f35e12013-04-16 23:12:43 +00002344 * @see llvm::AttrBuilder::addAttribute()
2345 */
2346void LLVMAddTargetDependentFunctionAttr(LLVMValueRef Fn, const char *A,
2347 const char *V);
2348
2349/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002350 * @defgroup LLVMCCoreValueFunctionParameters Function Parameters
2351 *
2352 * Functions in this group relate to arguments/parameters on functions.
2353 *
2354 * Functions in this group expect LLVMValueRef instances that correspond
2355 * to llvm::Function instances.
2356 *
2357 * @{
2358 */
2359
2360/**
2361 * Obtain the number of parameters in a function.
2362 *
2363 * @see llvm::Function::arg_size()
2364 */
Gordon Henriksen265f7802008-03-19 01:11:35 +00002365unsigned LLVMCountParams(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002366
2367/**
2368 * Obtain the parameters in a function.
2369 *
2370 * The takes a pointer to a pre-allocated array of LLVMValueRef that is
2371 * at least LLVMCountParams() long. This array will be filled with
2372 * LLVMValueRef instances which correspond to the parameters the
2373 * function receives. Each LLVMValueRef corresponds to a llvm::Argument
2374 * instance.
2375 *
2376 * @see llvm::Function::arg_begin()
2377 */
Gordon Henriksen265f7802008-03-19 01:11:35 +00002378void LLVMGetParams(LLVMValueRef Fn, LLVMValueRef *Params);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002379
2380/**
2381 * Obtain the parameter at the specified index.
2382 *
2383 * Parameters are indexed from 0.
2384 *
2385 * @see llvm::Function::arg_begin()
2386 */
Gordon Henriksen265f7802008-03-19 01:11:35 +00002387LLVMValueRef LLVMGetParam(LLVMValueRef Fn, unsigned Index);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002388
2389/**
2390 * Obtain the function to which this argument belongs.
2391 *
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00002392 * Unlike other functions in this group, this one takes an LLVMValueRef
Gregory Szorc34c863a2012-03-21 03:54:29 +00002393 * that corresponds to a llvm::Attribute.
2394 *
2395 * The returned LLVMValueRef is the llvm::Function to which this
2396 * argument belongs.
2397 */
Gordon Henriksen265f7802008-03-19 01:11:35 +00002398LLVMValueRef LLVMGetParamParent(LLVMValueRef Inst);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002399
2400/**
2401 * Obtain the first parameter to a function.
2402 *
2403 * @see llvm::Function::arg_begin()
2404 */
Gordon Henriksen07a45f42008-03-23 22:21:29 +00002405LLVMValueRef LLVMGetFirstParam(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002406
2407/**
2408 * Obtain the last parameter to a function.
2409 *
2410 * @see llvm::Function::arg_end()
2411 */
Gordon Henriksen07a45f42008-03-23 22:21:29 +00002412LLVMValueRef LLVMGetLastParam(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002413
2414/**
2415 * Obtain the next parameter to a function.
2416 *
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00002417 * This takes an LLVMValueRef obtained from LLVMGetFirstParam() (which is
Gregory Szorc34c863a2012-03-21 03:54:29 +00002418 * actually a wrapped iterator) and obtains the next parameter from the
2419 * underlying iterator.
2420 */
Gordon Henriksen07a45f42008-03-23 22:21:29 +00002421LLVMValueRef LLVMGetNextParam(LLVMValueRef Arg);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002422
2423/**
2424 * Obtain the previous parameter to a function.
2425 *
2426 * This is the opposite of LLVMGetNextParam().
2427 */
Gordon Henriksen07a45f42008-03-23 22:21:29 +00002428LLVMValueRef LLVMGetPreviousParam(LLVMValueRef Arg);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002429
2430/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002431 * Set the alignment for a function parameter.
2432 *
2433 * @see llvm::Argument::addAttr()
Bill Wendling50d27842012-10-15 20:35:56 +00002434 * @see llvm::AttrBuilder::addAlignmentAttr()
Gregory Szorc34c863a2012-03-21 03:54:29 +00002435 */
Amaury Sechet81243a72016-05-01 01:42:34 +00002436void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned Align);
Gordon Henriksen265f7802008-03-19 01:11:35 +00002437
Gregory Szorc34c863a2012-03-21 03:54:29 +00002438/**
2439 * @}
2440 */
2441
2442/**
2443 * @}
2444 */
2445
2446/**
Gregory Szorc52d26602012-03-21 07:28:27 +00002447 * @}
2448 */
2449
2450/**
2451 * @}
2452 */
2453
2454/**
2455 * @defgroup LLVMCCoreValueMetadata Metadata
2456 *
2457 * @{
2458 */
2459
2460/**
2461 * Obtain a MDString value from a context.
2462 *
2463 * The returned instance corresponds to the llvm::MDString class.
2464 *
2465 * The instance is specified by string data of a specified length. The
2466 * string content is copied, so the backing memory can be freed after
2467 * this function returns.
2468 */
2469LLVMValueRef LLVMMDStringInContext(LLVMContextRef C, const char *Str,
2470 unsigned SLen);
2471
2472/**
2473 * Obtain a MDString value from the global context.
2474 */
2475LLVMValueRef LLVMMDString(const char *Str, unsigned SLen);
2476
2477/**
2478 * Obtain a MDNode value from a context.
2479 *
2480 * The returned value corresponds to the llvm::MDNode class.
2481 */
2482LLVMValueRef LLVMMDNodeInContext(LLVMContextRef C, LLVMValueRef *Vals,
2483 unsigned Count);
2484
2485/**
2486 * Obtain a MDNode value from the global context.
2487 */
2488LLVMValueRef LLVMMDNode(LLVMValueRef *Vals, unsigned Count);
2489
2490/**
Amaury Sechetf8429752017-04-17 11:52:54 +00002491 * Obtain a Metadata as a Value.
2492 */
2493LLVMValueRef LLVMMetadataAsValue(LLVMContextRef C, LLVMMetadataRef MD);
2494
2495/**
2496 * Obtain a Value as a Metadata.
2497 */
2498LLVMMetadataRef LLVMValueAsMetadata(LLVMValueRef Val);
2499
2500/**
Gregory Szorc52d26602012-03-21 07:28:27 +00002501 * Obtain the underlying string from a MDString value.
2502 *
2503 * @param V Instance to obtain string from.
NAKAMURA Takumie4a77052016-04-04 11:54:48 +00002504 * @param Length Memory address which will hold length of returned string.
Gregory Szorc52d26602012-03-21 07:28:27 +00002505 * @return String data in MDString.
2506 */
Amaury Sechet7c2883c2016-04-03 21:06:04 +00002507const char *LLVMGetMDString(LLVMValueRef V, unsigned *Length);
Gregory Szorc52d26602012-03-21 07:28:27 +00002508
2509/**
Duncan Sands12ccbe72012-09-19 20:29:39 +00002510 * Obtain the number of operands from an MDNode value.
2511 *
2512 * @param V MDNode to get number of operands from.
2513 * @return Number of operands of the MDNode.
2514 */
2515unsigned LLVMGetMDNodeNumOperands(LLVMValueRef V);
2516
2517/**
2518 * Obtain the given MDNode's operands.
2519 *
2520 * The passed LLVMValueRef pointer should point to enough memory to hold all of
2521 * the operands of the given MDNode (see LLVMGetMDNodeNumOperands) as
2522 * LLVMValueRefs. This memory will be populated with the LLVMValueRefs of the
2523 * MDNode's operands.
2524 *
2525 * @param V MDNode to get the operands from.
2526 * @param Dest Destination array for operands.
2527 */
2528void LLVMGetMDNodeOperands(LLVMValueRef V, LLVMValueRef *Dest);
2529
2530/**
Gregory Szorc52d26602012-03-21 07:28:27 +00002531 * @}
2532 */
2533
2534/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002535 * @defgroup LLVMCCoreValueBasicBlock Basic Block
2536 *
2537 * A basic block represents a single entry single exit section of code.
2538 * Basic blocks contain a list of instructions which form the body of
2539 * the block.
2540 *
2541 * Basic blocks belong to functions. They have the type of label.
2542 *
2543 * Basic blocks are themselves values. However, the C API models them as
2544 * LLVMBasicBlockRef.
2545 *
2546 * @see llvm::BasicBlock
2547 *
2548 * @{
2549 */
2550
2551/**
2552 * Convert a basic block instance to a value type.
2553 */
Gordon Henriksen07a45f42008-03-23 22:21:29 +00002554LLVMValueRef LLVMBasicBlockAsValue(LLVMBasicBlockRef BB);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002555
2556/**
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00002557 * Determine whether an LLVMValueRef is itself a basic block.
Gregory Szorc34c863a2012-03-21 03:54:29 +00002558 */
Chris Lattner25963c62010-01-09 22:27:07 +00002559LLVMBool LLVMValueIsBasicBlock(LLVMValueRef Val);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002560
2561/**
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00002562 * Convert an LLVMValueRef to an LLVMBasicBlockRef instance.
Gregory Szorc34c863a2012-03-21 03:54:29 +00002563 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002564LLVMBasicBlockRef LLVMValueAsBasicBlock(LLVMValueRef Val);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002565
2566/**
Amaury Secheta82042e2016-02-09 22:36:41 +00002567 * Obtain the string name of a basic block.
2568 */
2569const char *LLVMGetBasicBlockName(LLVMBasicBlockRef BB);
2570
2571/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002572 * Obtain the function to which a basic block belongs.
2573 *
2574 * @see llvm::BasicBlock::getParent()
2575 */
Gordon Henriksen07a45f42008-03-23 22:21:29 +00002576LLVMValueRef LLVMGetBasicBlockParent(LLVMBasicBlockRef BB);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002577
2578/**
2579 * Obtain the terminator instruction for a basic block.
2580 *
2581 * If the basic block does not have a terminator (it is not well-formed
2582 * if it doesn't), then NULL is returned.
2583 *
2584 * The returned LLVMValueRef corresponds to a llvm::TerminatorInst.
2585 *
2586 * @see llvm::BasicBlock::getTerminator()
2587 */
Nate Begeman43c322b2011-08-23 20:27:46 +00002588LLVMValueRef LLVMGetBasicBlockTerminator(LLVMBasicBlockRef BB);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002589
2590/**
2591 * Obtain the number of basic blocks in a function.
2592 *
2593 * @param Fn Function value to operate on.
2594 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002595unsigned LLVMCountBasicBlocks(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002596
2597/**
2598 * Obtain all of the basic blocks in a function.
2599 *
2600 * This operates on a function value. The BasicBlocks parameter is a
2601 * pointer to a pre-allocated array of LLVMBasicBlockRef of at least
2602 * LLVMCountBasicBlocks() in length. This array is populated with
2603 * LLVMBasicBlockRef instances.
2604 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002605void LLVMGetBasicBlocks(LLVMValueRef Fn, LLVMBasicBlockRef *BasicBlocks);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002606
2607/**
2608 * Obtain the first basic block in a function.
2609 *
2610 * The returned basic block can be used as an iterator. You will likely
2611 * eventually call into LLVMGetNextBasicBlock() with it.
2612 *
2613 * @see llvm::Function::begin()
2614 */
Gordon Henriksen054817c2008-03-19 03:47:18 +00002615LLVMBasicBlockRef LLVMGetFirstBasicBlock(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002616
2617/**
2618 * Obtain the last basic block in a function.
2619 *
2620 * @see llvm::Function::end()
2621 */
Gordon Henriksen054817c2008-03-19 03:47:18 +00002622LLVMBasicBlockRef LLVMGetLastBasicBlock(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002623
2624/**
2625 * Advance a basic block iterator.
2626 */
Gordon Henriksen054817c2008-03-19 03:47:18 +00002627LLVMBasicBlockRef LLVMGetNextBasicBlock(LLVMBasicBlockRef BB);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002628
2629/**
2630 * Go backwards in a basic block iterator.
2631 */
Gordon Henriksen054817c2008-03-19 03:47:18 +00002632LLVMBasicBlockRef LLVMGetPreviousBasicBlock(LLVMBasicBlockRef BB);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002633
2634/**
2635 * Obtain the basic block that corresponds to the entry point of a
2636 * function.
2637 *
2638 * @see llvm::Function::getEntryBlock()
2639 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002640LLVMBasicBlockRef LLVMGetEntryBasicBlock(LLVMValueRef Fn);
Erick Tryzelaar262332f2009-08-14 00:01:31 +00002641
Gregory Szorc34c863a2012-03-21 03:54:29 +00002642/**
2643 * Append a basic block to the end of a function.
2644 *
2645 * @see llvm::BasicBlock::Create()
2646 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +00002647LLVMBasicBlockRef LLVMAppendBasicBlockInContext(LLVMContextRef C,
2648 LLVMValueRef Fn,
2649 const char *Name);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002650
2651/**
2652 * Append a basic block to the end of a function using the global
2653 * context.
2654 *
2655 * @see llvm::BasicBlock::Create()
2656 */
2657LLVMBasicBlockRef LLVMAppendBasicBlock(LLVMValueRef Fn, const char *Name);
2658
2659/**
2660 * Insert a basic block in a function before another basic block.
2661 *
2662 * The function to add to is determined by the function of the
2663 * passed basic block.
2664 *
2665 * @see llvm::BasicBlock::Create()
2666 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +00002667LLVMBasicBlockRef LLVMInsertBasicBlockInContext(LLVMContextRef C,
2668 LLVMBasicBlockRef BB,
2669 const char *Name);
2670
Gregory Szorc34c863a2012-03-21 03:54:29 +00002671/**
2672 * Insert a basic block in a function using the global context.
2673 *
2674 * @see llvm::BasicBlock::Create()
2675 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002676LLVMBasicBlockRef LLVMInsertBasicBlock(LLVMBasicBlockRef InsertBeforeBB,
2677 const char *Name);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002678
2679/**
2680 * Remove a basic block from a function and delete it.
2681 *
2682 * This deletes the basic block from its containing function and deletes
2683 * the basic block itself.
2684 *
2685 * @see llvm::BasicBlock::eraseFromParent()
2686 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002687void LLVMDeleteBasicBlock(LLVMBasicBlockRef BB);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002688
2689/**
2690 * Remove a basic block from a function.
2691 *
2692 * This deletes the basic block from its containing function but keep
2693 * the basic block alive.
2694 *
2695 * @see llvm::BasicBlock::removeFromParent()
2696 */
Nate Begeman43c322b2011-08-23 20:27:46 +00002697void LLVMRemoveBasicBlockFromParent(LLVMBasicBlockRef BB);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002698
Gregory Szorc34c863a2012-03-21 03:54:29 +00002699/**
2700 * Move a basic block to before another one.
2701 *
2702 * @see llvm::BasicBlock::moveBefore()
2703 */
Duncan Sandsb1d61aa2010-07-19 15:31:07 +00002704void LLVMMoveBasicBlockBefore(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002705
2706/**
2707 * Move a basic block to after another one.
2708 *
2709 * @see llvm::BasicBlock::moveAfter()
2710 */
Duncan Sandsb1d61aa2010-07-19 15:31:07 +00002711void LLVMMoveBasicBlockAfter(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos);
2712
Gregory Szorc34c863a2012-03-21 03:54:29 +00002713/**
2714 * Obtain the first instruction in a basic block.
2715 *
2716 * The returned LLVMValueRef corresponds to a llvm::Instruction
2717 * instance.
2718 */
Gordon Henriksen054817c2008-03-19 03:47:18 +00002719LLVMValueRef LLVMGetFirstInstruction(LLVMBasicBlockRef BB);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002720
2721/**
2722 * Obtain the last instruction in a basic block.
2723 *
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00002724 * The returned LLVMValueRef corresponds to an LLVM:Instruction.
Gregory Szorc34c863a2012-03-21 03:54:29 +00002725 */
Gordon Henriksen054817c2008-03-19 03:47:18 +00002726LLVMValueRef LLVMGetLastInstruction(LLVMBasicBlockRef BB);
Nate Begeman43c322b2011-08-23 20:27:46 +00002727
Gregory Szorc34c863a2012-03-21 03:54:29 +00002728/**
2729 * @}
2730 */
2731
2732/**
2733 * @defgroup LLVMCCoreValueInstruction Instructions
2734 *
2735 * Functions in this group relate to the inspection and manipulation of
2736 * individual instructions.
2737 *
2738 * In the C++ API, an instruction is modeled by llvm::Instruction. This
2739 * class has a large number of descendents. llvm::Instruction is a
2740 * llvm::Value and in the C API, instructions are modeled by
2741 * LLVMValueRef.
2742 *
2743 * This group also contains sub-groups which operate on specific
2744 * llvm::Instruction types, e.g. llvm::CallInst.
2745 *
2746 * @{
2747 */
2748
2749/**
2750 * Determine whether an instruction has any metadata attached.
2751 */
2752int LLVMHasMetadata(LLVMValueRef Val);
2753
2754/**
2755 * Return metadata associated with an instruction value.
2756 */
2757LLVMValueRef LLVMGetMetadata(LLVMValueRef Val, unsigned KindID);
2758
2759/**
2760 * Set metadata associated with an instruction value.
2761 */
2762void LLVMSetMetadata(LLVMValueRef Val, unsigned KindID, LLVMValueRef Node);
2763
2764/**
2765 * Obtain the basic block to which an instruction belongs.
2766 *
2767 * @see llvm::Instruction::getParent()
2768 */
Nate Begeman43c322b2011-08-23 20:27:46 +00002769LLVMBasicBlockRef LLVMGetInstructionParent(LLVMValueRef Inst);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002770
2771/**
2772 * Obtain the instruction that occurs after the one specified.
2773 *
2774 * The next instruction will be from the same basic block.
2775 *
2776 * If this is the last instruction in a basic block, NULL will be
2777 * returned.
2778 */
Gordon Henriksen054817c2008-03-19 03:47:18 +00002779LLVMValueRef LLVMGetNextInstruction(LLVMValueRef Inst);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002780
2781/**
Benjamin Kramerbde91762012-06-02 10:20:22 +00002782 * Obtain the instruction that occurred before this one.
Gregory Szorc34c863a2012-03-21 03:54:29 +00002783 *
2784 * If the instruction is the first instruction in a basic block, NULL
2785 * will be returned.
2786 */
Gordon Henriksen054817c2008-03-19 03:47:18 +00002787LLVMValueRef LLVMGetPreviousInstruction(LLVMValueRef Inst);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002788
2789/**
2790 * Remove and delete an instruction.
2791 *
2792 * The instruction specified is removed from its containing building
Amaury Sechet2f432082016-02-11 21:37:54 +00002793 * block but is kept alive.
2794 *
2795 * @see llvm::Instruction::removeFromParent()
2796 */
2797void LLVMInstructionRemoveFromParent(LLVMValueRef Inst);
2798
2799/**
2800 * Remove and delete an instruction.
2801 *
2802 * The instruction specified is removed from its containing building
Gregory Szorc34c863a2012-03-21 03:54:29 +00002803 * block and then deleted.
2804 *
2805 * @see llvm::Instruction::eraseFromParent()
2806 */
Devang Pateldbebc6f2011-10-03 20:59:18 +00002807void LLVMInstructionEraseFromParent(LLVMValueRef Inst);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002808
2809/**
2810 * Obtain the code opcode for an individual instruction.
2811 *
2812 * @see llvm::Instruction::getOpCode()
2813 */
Eric Christophera6b96002015-12-18 01:46:52 +00002814LLVMOpcode LLVMGetInstructionOpcode(LLVMValueRef Inst);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002815
2816/**
2817 * Obtain the predicate of an instruction.
2818 *
2819 * This is only valid for instructions that correspond to llvm::ICmpInst
2820 * or llvm::ConstantExpr whose opcode is llvm::Instruction::ICmp.
2821 *
2822 * @see llvm::ICmpInst::getPredicate()
2823 */
Torok Edwin60c40de2011-10-06 12:13:20 +00002824LLVMIntPredicate LLVMGetICmpPredicate(LLVMValueRef Inst);
Gordon Henriksen265f7802008-03-19 01:11:35 +00002825
Gregory Szorc34c863a2012-03-21 03:54:29 +00002826/**
Peter Zotov1d98e6d2014-10-28 19:46:44 +00002827 * Obtain the float predicate of an instruction.
2828 *
2829 * This is only valid for instructions that correspond to llvm::FCmpInst
2830 * or llvm::ConstantExpr whose opcode is llvm::Instruction::FCmp.
2831 *
2832 * @see llvm::FCmpInst::getPredicate()
2833 */
2834LLVMRealPredicate LLVMGetFCmpPredicate(LLVMValueRef Inst);
2835
2836/**
Peter Zotovaff492c2014-10-17 01:02:34 +00002837 * Create a copy of 'this' instruction that is identical in all ways
2838 * except the following:
2839 * * The instruction has no parent
2840 * * The instruction has no name
2841 *
2842 * @see llvm::Instruction::clone()
2843 */
2844LLVMValueRef LLVMInstructionClone(LLVMValueRef Inst);
2845
2846/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002847 * @defgroup LLVMCCoreValueInstructionCall Call Sites and Invocations
2848 *
2849 * Functions in this group apply to instructions that refer to call
2850 * sites and invocations. These correspond to C++ types in the
2851 * llvm::CallInst class tree.
2852 *
2853 * @{
2854 */
2855
2856/**
Amaury Sechet5c7b3af2016-02-10 00:09:37 +00002857 * Obtain the argument count for a call instruction.
2858 *
Robert Widmann478fce92018-03-30 17:49:53 +00002859 * This expects an LLVMValueRef that corresponds to a llvm::CallInst,
2860 * llvm::InvokeInst, or llvm:FuncletPadInst.
Amaury Sechet5c7b3af2016-02-10 00:09:37 +00002861 *
2862 * @see llvm::CallInst::getNumArgOperands()
2863 * @see llvm::InvokeInst::getNumArgOperands()
Robert Widmann478fce92018-03-30 17:49:53 +00002864 * @see llvm::FuncletPadInst::getNumArgOperands()
Amaury Sechet5c7b3af2016-02-10 00:09:37 +00002865 */
2866unsigned LLVMGetNumArgOperands(LLVMValueRef Instr);
2867
2868/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002869 * Set the calling convention for a call instruction.
2870 *
2871 * This expects an LLVMValueRef that corresponds to a llvm::CallInst or
2872 * llvm::InvokeInst.
2873 *
2874 * @see llvm::CallInst::setCallingConv()
2875 * @see llvm::InvokeInst::setCallingConv()
2876 */
Gordon Henriksen1158c532007-12-29 20:45:00 +00002877void LLVMSetInstructionCallConv(LLVMValueRef Instr, unsigned CC);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002878
2879/**
2880 * Obtain the calling convention for a call instruction.
2881 *
2882 * This is the opposite of LLVMSetInstructionCallConv(). Reads its
2883 * usage.
2884 *
2885 * @see LLVMSetInstructionCallConv()
2886 */
Gordon Henriksen1158c532007-12-29 20:45:00 +00002887unsigned LLVMGetInstructionCallConv(LLVMValueRef Instr);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002888
Gregory Szorc34c863a2012-03-21 03:54:29 +00002889void LLVMSetInstrParamAlignment(LLVMValueRef Instr, unsigned index,
Amaury Sechet81243a72016-05-01 01:42:34 +00002890 unsigned Align);
Gordon Henriksen1158c532007-12-29 20:45:00 +00002891
Amaury Secheta65a2372016-06-15 05:14:29 +00002892void LLVMAddCallSiteAttribute(LLVMValueRef C, LLVMAttributeIndex Idx,
2893 LLVMAttributeRef A);
Amaury Sechet17b67cd2016-07-21 04:25:06 +00002894unsigned LLVMGetCallSiteAttributeCount(LLVMValueRef C, LLVMAttributeIndex Idx);
2895void LLVMGetCallSiteAttributes(LLVMValueRef C, LLVMAttributeIndex Idx,
2896 LLVMAttributeRef *Attrs);
Amaury Secheta65a2372016-06-15 05:14:29 +00002897LLVMAttributeRef LLVMGetCallSiteEnumAttribute(LLVMValueRef C,
2898 LLVMAttributeIndex Idx,
2899 unsigned KindID);
Amaury Sechet6100adf2016-06-15 17:50:39 +00002900LLVMAttributeRef LLVMGetCallSiteStringAttribute(LLVMValueRef C,
2901 LLVMAttributeIndex Idx,
2902 const char *K, unsigned KLen);
Amaury Secheta65a2372016-06-15 05:14:29 +00002903void LLVMRemoveCallSiteEnumAttribute(LLVMValueRef C, LLVMAttributeIndex Idx,
2904 unsigned KindID);
Amaury Sechet6100adf2016-06-15 17:50:39 +00002905void LLVMRemoveCallSiteStringAttribute(LLVMValueRef C, LLVMAttributeIndex Idx,
2906 const char *K, unsigned KLen);
Amaury Secheta65a2372016-06-15 05:14:29 +00002907
Gregory Szorc34c863a2012-03-21 03:54:29 +00002908/**
Amaury Sechet5c7b3af2016-02-10 00:09:37 +00002909 * Obtain the pointer to the function invoked by this instruction.
2910 *
2911 * This expects an LLVMValueRef that corresponds to a llvm::CallInst or
2912 * llvm::InvokeInst.
2913 *
2914 * @see llvm::CallInst::getCalledValue()
2915 * @see llvm::InvokeInst::getCalledValue()
2916 */
2917LLVMValueRef LLVMGetCalledValue(LLVMValueRef Instr);
2918
2919/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002920 * Obtain whether a call instruction is a tail call.
2921 *
2922 * This only works on llvm::CallInst instructions.
2923 *
2924 * @see llvm::CallInst::isTailCall()
2925 */
Chris Lattner25963c62010-01-09 22:27:07 +00002926LLVMBool LLVMIsTailCall(LLVMValueRef CallInst);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002927
2928/**
2929 * Set whether a call instruction is a tail call.
2930 *
2931 * This only works on llvm::CallInst instructions.
2932 *
2933 * @see llvm::CallInst::setTailCall()
2934 */
Chris Lattner25963c62010-01-09 22:27:07 +00002935void LLVMSetTailCall(LLVMValueRef CallInst, LLVMBool IsTailCall);
Gordon Henrikseneeb65372008-08-30 16:34:54 +00002936
Gregory Szorc34c863a2012-03-21 03:54:29 +00002937/**
Amaury Sechete39e8532016-02-18 20:38:32 +00002938 * Return the normal destination basic block.
2939 *
2940 * This only works on llvm::InvokeInst instructions.
2941 *
2942 * @see llvm::InvokeInst::getNormalDest()
2943 */
2944LLVMBasicBlockRef LLVMGetNormalDest(LLVMValueRef InvokeInst);
2945
2946/**
2947 * Return the unwind destination basic block.
2948 *
Robert Widmann478fce92018-03-30 17:49:53 +00002949 * Works on llvm::InvokeInst, llvm::CleanupReturnInst, and
2950 * llvm::CatchSwitchInst instructions.
Amaury Sechete39e8532016-02-18 20:38:32 +00002951 *
2952 * @see llvm::InvokeInst::getUnwindDest()
Robert Widmann478fce92018-03-30 17:49:53 +00002953 * @see llvm::CleanupReturnInst::getUnwindDest()
2954 * @see llvm::CatchSwitchInst::getUnwindDest()
Amaury Sechete39e8532016-02-18 20:38:32 +00002955 */
2956LLVMBasicBlockRef LLVMGetUnwindDest(LLVMValueRef InvokeInst);
2957
2958/**
2959 * Set the normal destination basic block.
2960 *
2961 * This only works on llvm::InvokeInst instructions.
2962 *
2963 * @see llvm::InvokeInst::setNormalDest()
2964 */
2965void LLVMSetNormalDest(LLVMValueRef InvokeInst, LLVMBasicBlockRef B);
2966
2967/**
2968 * Set the unwind destination basic block.
2969 *
Robert Widmann478fce92018-03-30 17:49:53 +00002970 * Works on llvm::InvokeInst, llvm::CleanupReturnInst, and
2971 * llvm::CatchSwitchInst instructions.
Amaury Sechete39e8532016-02-18 20:38:32 +00002972 *
2973 * @see llvm::InvokeInst::setUnwindDest()
Robert Widmann478fce92018-03-30 17:49:53 +00002974 * @see llvm::CleanupReturnInst::setUnwindDest()
2975 * @see llvm::CatchSwitchInst::setUnwindDest()
Amaury Sechete39e8532016-02-18 20:38:32 +00002976 */
2977void LLVMSetUnwindDest(LLVMValueRef InvokeInst, LLVMBasicBlockRef B);
2978
2979/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002980 * @}
2981 */
2982
2983/**
Peter Zotov2481c752014-10-28 19:46:56 +00002984 * @defgroup LLVMCCoreValueInstructionTerminator Terminators
2985 *
2986 * Functions in this group only apply to instructions that map to
2987 * llvm::TerminatorInst instances.
2988 *
2989 * @{
2990 */
2991
2992/**
2993 * Return the number of successors that this terminator has.
2994 *
2995 * @see llvm::TerminatorInst::getNumSuccessors
2996 */
2997unsigned LLVMGetNumSuccessors(LLVMValueRef Term);
2998
2999/**
3000 * Return the specified successor.
3001 *
3002 * @see llvm::TerminatorInst::getSuccessor
3003 */
3004LLVMBasicBlockRef LLVMGetSuccessor(LLVMValueRef Term, unsigned i);
3005
3006/**
3007 * Update the specified successor to point at the provided block.
3008 *
3009 * @see llvm::TerminatorInst::setSuccessor
3010 */
3011void LLVMSetSuccessor(LLVMValueRef Term, unsigned i, LLVMBasicBlockRef block);
3012
3013/**
3014 * Return if a branch is conditional.
3015 *
3016 * This only works on llvm::BranchInst instructions.
3017 *
3018 * @see llvm::BranchInst::isConditional
3019 */
3020LLVMBool LLVMIsConditional(LLVMValueRef Branch);
3021
3022/**
3023 * Return the condition of a branch instruction.
3024 *
3025 * This only works on llvm::BranchInst instructions.
3026 *
3027 * @see llvm::BranchInst::getCondition
3028 */
3029LLVMValueRef LLVMGetCondition(LLVMValueRef Branch);
3030
3031/**
3032 * Set the condition of a branch instruction.
3033 *
3034 * This only works on llvm::BranchInst instructions.
3035 *
3036 * @see llvm::BranchInst::setCondition
3037 */
3038void LLVMSetCondition(LLVMValueRef Branch, LLVMValueRef Cond);
3039
3040/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00003041 * Obtain the default destination basic block of a switch instruction.
3042 *
3043 * This only works on llvm::SwitchInst instructions.
3044 *
3045 * @see llvm::SwitchInst::getDefaultDest()
3046 */
Nate Begeman43c322b2011-08-23 20:27:46 +00003047LLVMBasicBlockRef LLVMGetSwitchDefaultDest(LLVMValueRef SwitchInstr);
3048
Gregory Szorc34c863a2012-03-21 03:54:29 +00003049/**
Peter Zotov2481c752014-10-28 19:46:56 +00003050 * @}
3051 */
3052
3053/**
Amaury Sechet1dcf5772016-02-09 22:50:53 +00003054 * @defgroup LLVMCCoreValueInstructionAlloca Allocas
3055 *
3056 * Functions in this group only apply to instructions that map to
3057 * llvm::AllocaInst instances.
3058 *
3059 * @{
3060 */
3061
3062/**
3063 * Obtain the type that is being allocated by the alloca instruction.
3064 */
3065LLVMTypeRef LLVMGetAllocatedType(LLVMValueRef Alloca);
3066
3067/**
3068 * @}
3069 */
3070
3071/**
Amaury Sechet053ac452016-02-17 22:51:03 +00003072 * @defgroup LLVMCCoreValueInstructionGetElementPointer GEPs
3073 *
3074 * Functions in this group only apply to instructions that map to
3075 * llvm::GetElementPtrInst instances.
3076 *
3077 * @{
3078 */
3079
3080/**
3081 * Check whether the given GEP instruction is inbounds.
3082 */
3083LLVMBool LLVMIsInBounds(LLVMValueRef GEP);
3084
3085/**
3086 * Set the given GEP instruction to be inbounds or not.
3087 */
Amaury Sechet8a367d42016-05-01 02:23:14 +00003088void LLVMSetIsInBounds(LLVMValueRef GEP, LLVMBool InBounds);
Amaury Sechet053ac452016-02-17 22:51:03 +00003089
3090/**
3091 * @}
3092 */
3093
3094/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00003095 * @defgroup LLVMCCoreValueInstructionPHINode PHI Nodes
3096 *
3097 * Functions in this group only apply to instructions that map to
3098 * llvm::PHINode instances.
3099 *
3100 * @{
3101 */
3102
3103/**
3104 * Add an incoming value to the end of a PHI list.
3105 */
Gordon Henriksen44dd8fb2007-10-08 18:14:39 +00003106void LLVMAddIncoming(LLVMValueRef PhiNode, LLVMValueRef *IncomingValues,
3107 LLVMBasicBlockRef *IncomingBlocks, unsigned Count);
Gregory Szorc34c863a2012-03-21 03:54:29 +00003108
3109/**
3110 * Obtain the number of incoming basic blocks to a PHI node.
3111 */
Gordon Henriksen44dd8fb2007-10-08 18:14:39 +00003112unsigned LLVMCountIncoming(LLVMValueRef PhiNode);
Gregory Szorc34c863a2012-03-21 03:54:29 +00003113
3114/**
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00003115 * Obtain an incoming value to a PHI node as an LLVMValueRef.
Gregory Szorc34c863a2012-03-21 03:54:29 +00003116 */
Gordon Henriksen44dd8fb2007-10-08 18:14:39 +00003117LLVMValueRef LLVMGetIncomingValue(LLVMValueRef PhiNode, unsigned Index);
Gregory Szorc34c863a2012-03-21 03:54:29 +00003118
3119/**
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00003120 * Obtain an incoming value to a PHI node as an LLVMBasicBlockRef.
Gregory Szorc34c863a2012-03-21 03:54:29 +00003121 */
Gordon Henriksen44dd8fb2007-10-08 18:14:39 +00003122LLVMBasicBlockRef LLVMGetIncomingBlock(LLVMValueRef PhiNode, unsigned Index);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00003123
Gregory Szorc34c863a2012-03-21 03:54:29 +00003124/**
3125 * @}
3126 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00003127
Gregory Szorc34c863a2012-03-21 03:54:29 +00003128/**
Amaury Sechetaad93532016-02-10 00:38:50 +00003129 * @defgroup LLVMCCoreValueInstructionExtractValue ExtractValue
3130 * @defgroup LLVMCCoreValueInstructionInsertValue InsertValue
3131 *
3132 * Functions in this group only apply to instructions that map to
3133 * llvm::ExtractValue and llvm::InsertValue instances.
3134 *
3135 * @{
3136 */
3137
3138/**
3139 * Obtain the number of indices.
Amaury Sechet053ac452016-02-17 22:51:03 +00003140 * NB: This also works on GEP.
Amaury Sechetaad93532016-02-10 00:38:50 +00003141 */
3142unsigned LLVMGetNumIndices(LLVMValueRef Inst);
3143
3144/**
3145 * Obtain the indices as an array.
3146 */
3147const unsigned *LLVMGetIndices(LLVMValueRef Inst);
3148
3149/**
3150 * @}
3151 */
3152
3153/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00003154 * @}
3155 */
3156
3157/**
3158 * @}
3159 */
3160
3161/**
3162 * @defgroup LLVMCCoreInstructionBuilder Instruction Builders
3163 *
3164 * An instruction builder represents a point within a basic block and is
3165 * the exclusive means of building instructions using the C interface.
3166 *
3167 * @{
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00003168 */
3169
Erick Tryzelaar262332f2009-08-14 00:01:31 +00003170LLVMBuilderRef LLVMCreateBuilderInContext(LLVMContextRef C);
Gordon Henriksena735a9c2008-05-04 12:55:34 +00003171LLVMBuilderRef LLVMCreateBuilder(void);
Gordon Henriksen054817c2008-03-19 03:47:18 +00003172void LLVMPositionBuilder(LLVMBuilderRef Builder, LLVMBasicBlockRef Block,
3173 LLVMValueRef Instr);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00003174void LLVMPositionBuilderBefore(LLVMBuilderRef Builder, LLVMValueRef Instr);
3175void LLVMPositionBuilderAtEnd(LLVMBuilderRef Builder, LLVMBasicBlockRef Block);
Gordon Henriksen265f7802008-03-19 01:11:35 +00003176LLVMBasicBlockRef LLVMGetInsertBlock(LLVMBuilderRef Builder);
Chris Lattner3d1f5522008-12-17 21:39:50 +00003177void LLVMClearInsertionPosition(LLVMBuilderRef Builder);
3178void LLVMInsertIntoBuilder(LLVMBuilderRef Builder, LLVMValueRef Instr);
Erick Tryzelaar9813bea2009-08-16 02:20:57 +00003179void LLVMInsertIntoBuilderWithName(LLVMBuilderRef Builder, LLVMValueRef Instr,
3180 const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00003181void LLVMDisposeBuilder(LLVMBuilderRef Builder);
3182
Erick Tryzelaard8531fa2010-02-28 09:45:59 +00003183/* Metadata */
3184void LLVMSetCurrentDebugLocation(LLVMBuilderRef Builder, LLVMValueRef L);
3185LLVMValueRef LLVMGetCurrentDebugLocation(LLVMBuilderRef Builder);
3186void LLVMSetInstDebugLocation(LLVMBuilderRef Builder, LLVMValueRef Inst);
3187
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00003188/* Terminators */
3189LLVMValueRef LLVMBuildRetVoid(LLVMBuilderRef);
3190LLVMValueRef LLVMBuildRet(LLVMBuilderRef, LLVMValueRef V);
Erick Tryzelaarfd529d72009-08-19 08:36:49 +00003191LLVMValueRef LLVMBuildAggregateRet(LLVMBuilderRef, LLVMValueRef *RetVals,
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00003192 unsigned N);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00003193LLVMValueRef LLVMBuildBr(LLVMBuilderRef, LLVMBasicBlockRef Dest);
3194LLVMValueRef LLVMBuildCondBr(LLVMBuilderRef, LLVMValueRef If,
3195 LLVMBasicBlockRef Then, LLVMBasicBlockRef Else);
3196LLVMValueRef LLVMBuildSwitch(LLVMBuilderRef, LLVMValueRef V,
3197 LLVMBasicBlockRef Else, unsigned NumCases);
Erick Tryzelaar0fb26ef2010-02-28 09:46:06 +00003198LLVMValueRef LLVMBuildIndirectBr(LLVMBuilderRef B, LLVMValueRef Addr,
3199 unsigned NumDests);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00003200LLVMValueRef LLVMBuildInvoke(LLVMBuilderRef, LLVMValueRef Fn,
3201 LLVMValueRef *Args, unsigned NumArgs,
3202 LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch,
3203 const char *Name);
Robert Widmann478fce92018-03-30 17:49:53 +00003204LLVMValueRef LLVMBuildUnreachable(LLVMBuilderRef);
3205
3206/* Exception Handling */
3207LLVMValueRef LLVMBuildResume(LLVMBuilderRef B, LLVMValueRef Exn);
Benjamin Kramer5a6568832011-08-19 01:36:54 +00003208LLVMValueRef LLVMBuildLandingPad(LLVMBuilderRef B, LLVMTypeRef Ty,
Reid Kleckneref9828f2015-07-16 01:16:39 +00003209 LLVMValueRef PersFn, unsigned NumClauses,
3210 const char *Name);
Robert Widmann478fce92018-03-30 17:49:53 +00003211LLVMValueRef LLVMBuildCleanupRet(LLVMBuilderRef B, LLVMValueRef CatchPad,
3212 LLVMBasicBlockRef BB);
3213LLVMValueRef LLVMBuildCatchRet(LLVMBuilderRef B, LLVMValueRef CatchPad,
3214 LLVMBasicBlockRef BB);
3215LLVMValueRef LLVMBuildCatchPad(LLVMBuilderRef B, LLVMValueRef ParentPad,
3216 LLVMValueRef *Args, unsigned NumArgs,
3217 const char *Name);
3218LLVMValueRef LLVMBuildCleanupPad(LLVMBuilderRef B, LLVMValueRef ParentPad,
3219 LLVMValueRef *Args, unsigned NumArgs,
3220 const char *Name);
3221LLVMValueRef LLVMBuildCatchSwitch(LLVMBuilderRef B, LLVMValueRef ParentPad,
3222 LLVMBasicBlockRef UnwindBB,
3223 unsigned NumHandlers, const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00003224
Gordon Henriksen097102c2008-01-01 05:50:53 +00003225/* Add a case to the switch instruction */
3226void LLVMAddCase(LLVMValueRef Switch, LLVMValueRef OnVal,
3227 LLVMBasicBlockRef Dest);
3228
Erick Tryzelaar0fb26ef2010-02-28 09:46:06 +00003229/* Add a destination to the indirectbr instruction */
3230void LLVMAddDestination(LLVMValueRef IndirectBr, LLVMBasicBlockRef Dest);
3231
Amaury Sechete39e8532016-02-18 20:38:32 +00003232/* Get the number of clauses on the landingpad instruction */
3233unsigned LLVMGetNumClauses(LLVMValueRef LandingPad);
3234
3235/* Get the value of the clause at idnex Idx on the landingpad instruction */
3236LLVMValueRef LLVMGetClause(LLVMValueRef LandingPad, unsigned Idx);
3237
Bill Wendlingfae14752011-08-12 20:24:12 +00003238/* Add a catch or filter clause to the landingpad instruction */
3239void LLVMAddClause(LLVMValueRef LandingPad, LLVMValueRef ClauseVal);
3240
Amaury Sechete39e8532016-02-18 20:38:32 +00003241/* Get the 'cleanup' flag in the landingpad instruction */
3242LLVMBool LLVMIsCleanup(LLVMValueRef LandingPad);
3243
Bill Wendlingfae14752011-08-12 20:24:12 +00003244/* Set the 'cleanup' flag in the landingpad instruction */
3245void LLVMSetCleanup(LLVMValueRef LandingPad, LLVMBool Val);
3246
Robert Widmann478fce92018-03-30 17:49:53 +00003247/* Add a destination to the catchswitch instruction */
3248void LLVMAddHandler(LLVMValueRef CatchSwitch, LLVMBasicBlockRef Dest);
3249
3250/* Get the number of handlers on the catchswitch instruction */
3251unsigned LLVMGetNumHandlers(LLVMValueRef CatchSwitch);
3252
3253/**
3254 * Obtain the basic blocks acting as handlers for a catchswitch instruction.
3255 *
3256 * The Handlers parameter should point to a pre-allocated array of
3257 * LLVMBasicBlockRefs at least LLVMGetNumHandlers() large. On return, the
3258 * first LLVMGetNumHandlers() entries in the array will be populated
3259 * with LLVMBasicBlockRef instances.
3260 *
3261 * @param CatchSwitch The catchswitch instruction to operate on.
3262 * @param Handlers Memory address of an array to be filled with basic blocks.
3263 */
3264void LLVMGetHandlers(LLVMValueRef CatchSwitch, LLVMBasicBlockRef *Handlers);
3265
3266/* Funclets */
3267
3268/* Get the number of funcletpad arguments. */
3269LLVMValueRef LLVMGetArgOperand(LLVMValueRef Funclet, unsigned i);
3270
3271/* Set a funcletpad argument at the given index. */
3272void LLVMSetArgOperand(LLVMValueRef Funclet, unsigned i, LLVMValueRef value);
3273
3274/**
3275 * Get the parent catchswitch instruction of a catchpad instruction.
3276 *
3277 * This only works on llvm::CatchPadInst instructions.
3278 *
3279 * @see llvm::CatchPadInst::getCatchSwitch()
3280 */
3281LLVMValueRef LLVMGetParentCatchSwitch(LLVMValueRef CatchPad);
3282
3283/**
3284 * Set the parent catchswitch instruction of a catchpad instruction.
3285 *
3286 * This only works on llvm::CatchPadInst instructions.
3287 *
3288 * @see llvm::CatchPadInst::setCatchSwitch()
3289 */
3290void LLVMSetParentCatchSwitch(LLVMValueRef CatchPad, LLVMValueRef CatchSwitch);
3291
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00003292/* Arithmetic */
3293LLVMValueRef LLVMBuildAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3294 const char *Name);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00003295LLVMValueRef LLVMBuildNSWAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3296 const char *Name);
Erick Tryzelaar4c340c72010-02-28 05:51:43 +00003297LLVMValueRef LLVMBuildNUWAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3298 const char *Name);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00003299LLVMValueRef LLVMBuildFAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3300 const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00003301LLVMValueRef LLVMBuildSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3302 const char *Name);
Erick Tryzelaar4c340c72010-02-28 05:51:43 +00003303LLVMValueRef LLVMBuildNSWSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3304 const char *Name);
3305LLVMValueRef LLVMBuildNUWSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3306 const char *Name);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00003307LLVMValueRef LLVMBuildFSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3308 const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00003309LLVMValueRef LLVMBuildMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3310 const char *Name);
Erick Tryzelaar4c340c72010-02-28 05:51:43 +00003311LLVMValueRef LLVMBuildNSWMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3312 const char *Name);
3313LLVMValueRef LLVMBuildNUWMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3314 const char *Name);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00003315LLVMValueRef LLVMBuildFMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3316 const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00003317LLVMValueRef LLVMBuildUDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3318 const char *Name);
Manuel Jacob49fafb12016-10-04 23:32:42 +00003319LLVMValueRef LLVMBuildExactUDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3320 const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00003321LLVMValueRef LLVMBuildSDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3322 const char *Name);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00003323LLVMValueRef LLVMBuildExactSDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3324 const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00003325LLVMValueRef LLVMBuildFDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3326 const char *Name);
3327LLVMValueRef LLVMBuildURem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3328 const char *Name);
3329LLVMValueRef LLVMBuildSRem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3330 const char *Name);
3331LLVMValueRef LLVMBuildFRem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3332 const char *Name);
3333LLVMValueRef LLVMBuildShl(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3334 const char *Name);
3335LLVMValueRef LLVMBuildLShr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3336 const char *Name);
3337LLVMValueRef LLVMBuildAShr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3338 const char *Name);
3339LLVMValueRef LLVMBuildAnd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3340 const char *Name);
3341LLVMValueRef LLVMBuildOr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3342 const char *Name);
3343LLVMValueRef LLVMBuildXor(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3344 const char *Name);
Erick Tryzelaar31831792010-02-28 05:51:27 +00003345LLVMValueRef LLVMBuildBinOp(LLVMBuilderRef B, LLVMOpcode Op,
3346 LLVMValueRef LHS, LLVMValueRef RHS,
3347 const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00003348LLVMValueRef LLVMBuildNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name);
Erick Tryzelaar4c340c72010-02-28 05:51:43 +00003349LLVMValueRef LLVMBuildNSWNeg(LLVMBuilderRef B, LLVMValueRef V,
3350 const char *Name);
3351LLVMValueRef LLVMBuildNUWNeg(LLVMBuilderRef B, LLVMValueRef V,
3352 const char *Name);
Dan Gohmanf919bd62009-09-28 21:51:41 +00003353LLVMValueRef LLVMBuildFNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00003354LLVMValueRef LLVMBuildNot(LLVMBuilderRef, LLVMValueRef V, const char *Name);
3355
3356/* Memory */
3357LLVMValueRef LLVMBuildMalloc(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
3358LLVMValueRef LLVMBuildArrayMalloc(LLVMBuilderRef, LLVMTypeRef Ty,
3359 LLVMValueRef Val, const char *Name);
3360LLVMValueRef LLVMBuildAlloca(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
3361LLVMValueRef LLVMBuildArrayAlloca(LLVMBuilderRef, LLVMTypeRef Ty,
3362 LLVMValueRef Val, const char *Name);
3363LLVMValueRef LLVMBuildFree(LLVMBuilderRef, LLVMValueRef PointerVal);
3364LLVMValueRef LLVMBuildLoad(LLVMBuilderRef, LLVMValueRef PointerVal,
3365 const char *Name);
3366LLVMValueRef LLVMBuildStore(LLVMBuilderRef, LLVMValueRef Val, LLVMValueRef Ptr);
3367LLVMValueRef LLVMBuildGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
3368 LLVMValueRef *Indices, unsigned NumIndices,
3369 const char *Name);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00003370LLVMValueRef LLVMBuildInBoundsGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
3371 LLVMValueRef *Indices, unsigned NumIndices,
3372 const char *Name);
3373LLVMValueRef LLVMBuildStructGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
3374 unsigned Idx, const char *Name);
3375LLVMValueRef LLVMBuildGlobalString(LLVMBuilderRef B, const char *Str,
3376 const char *Name);
3377LLVMValueRef LLVMBuildGlobalStringPtr(LLVMBuilderRef B, const char *Str,
3378 const char *Name);
Chris Lattner2cc6f9d2012-03-22 03:54:15 +00003379LLVMBool LLVMGetVolatile(LLVMValueRef MemoryAccessInst);
3380void LLVMSetVolatile(LLVMValueRef MemoryAccessInst, LLVMBool IsVolatile);
Andrew Wilkinsb7362ce2015-08-02 12:16:57 +00003381LLVMAtomicOrdering LLVMGetOrdering(LLVMValueRef MemoryAccessInst);
3382void LLVMSetOrdering(LLVMValueRef MemoryAccessInst, LLVMAtomicOrdering Ordering);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00003383
3384/* Casts */
3385LLVMValueRef LLVMBuildTrunc(LLVMBuilderRef, LLVMValueRef Val,
3386 LLVMTypeRef DestTy, const char *Name);
3387LLVMValueRef LLVMBuildZExt(LLVMBuilderRef, LLVMValueRef Val,
3388 LLVMTypeRef DestTy, const char *Name);
3389LLVMValueRef LLVMBuildSExt(LLVMBuilderRef, LLVMValueRef Val,
3390 LLVMTypeRef DestTy, const char *Name);
3391LLVMValueRef LLVMBuildFPToUI(LLVMBuilderRef, LLVMValueRef Val,
3392 LLVMTypeRef DestTy, const char *Name);
3393LLVMValueRef LLVMBuildFPToSI(LLVMBuilderRef, LLVMValueRef Val,
3394 LLVMTypeRef DestTy, const char *Name);
3395LLVMValueRef LLVMBuildUIToFP(LLVMBuilderRef, LLVMValueRef Val,
3396 LLVMTypeRef DestTy, const char *Name);
3397LLVMValueRef LLVMBuildSIToFP(LLVMBuilderRef, LLVMValueRef Val,
3398 LLVMTypeRef DestTy, const char *Name);
3399LLVMValueRef LLVMBuildFPTrunc(LLVMBuilderRef, LLVMValueRef Val,
3400 LLVMTypeRef DestTy, const char *Name);
3401LLVMValueRef LLVMBuildFPExt(LLVMBuilderRef, LLVMValueRef Val,
3402 LLVMTypeRef DestTy, const char *Name);
3403LLVMValueRef LLVMBuildPtrToInt(LLVMBuilderRef, LLVMValueRef Val,
3404 LLVMTypeRef DestTy, const char *Name);
3405LLVMValueRef LLVMBuildIntToPtr(LLVMBuilderRef, LLVMValueRef Val,
3406 LLVMTypeRef DestTy, const char *Name);
3407LLVMValueRef LLVMBuildBitCast(LLVMBuilderRef, LLVMValueRef Val,
3408 LLVMTypeRef DestTy, const char *Name);
Matt Arsenaultb03bd4d2013-11-15 01:34:59 +00003409LLVMValueRef LLVMBuildAddrSpaceCast(LLVMBuilderRef, LLVMValueRef Val,
3410 LLVMTypeRef DestTy, const char *Name);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00003411LLVMValueRef LLVMBuildZExtOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
3412 LLVMTypeRef DestTy, const char *Name);
3413LLVMValueRef LLVMBuildSExtOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
3414 LLVMTypeRef DestTy, const char *Name);
3415LLVMValueRef LLVMBuildTruncOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
3416 LLVMTypeRef DestTy, const char *Name);
Erick Tryzelaar31831792010-02-28 05:51:27 +00003417LLVMValueRef LLVMBuildCast(LLVMBuilderRef B, LLVMOpcode Op, LLVMValueRef Val,
3418 LLVMTypeRef DestTy, const char *Name);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00003419LLVMValueRef LLVMBuildPointerCast(LLVMBuilderRef, LLVMValueRef Val,
3420 LLVMTypeRef DestTy, const char *Name);
Duncan Sands9d786d72009-11-23 10:49:03 +00003421LLVMValueRef LLVMBuildIntCast(LLVMBuilderRef, LLVMValueRef Val, /*Signed cast!*/
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00003422 LLVMTypeRef DestTy, const char *Name);
3423LLVMValueRef LLVMBuildFPCast(LLVMBuilderRef, LLVMValueRef Val,
3424 LLVMTypeRef DestTy, const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00003425
3426/* Comparisons */
3427LLVMValueRef LLVMBuildICmp(LLVMBuilderRef, LLVMIntPredicate Op,
3428 LLVMValueRef LHS, LLVMValueRef RHS,
3429 const char *Name);
3430LLVMValueRef LLVMBuildFCmp(LLVMBuilderRef, LLVMRealPredicate Op,
3431 LLVMValueRef LHS, LLVMValueRef RHS,
3432 const char *Name);
3433
3434/* Miscellaneous instructions */
3435LLVMValueRef LLVMBuildPhi(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
3436LLVMValueRef LLVMBuildCall(LLVMBuilderRef, LLVMValueRef Fn,
3437 LLVMValueRef *Args, unsigned NumArgs,
3438 const char *Name);
3439LLVMValueRef LLVMBuildSelect(LLVMBuilderRef, LLVMValueRef If,
3440 LLVMValueRef Then, LLVMValueRef Else,
3441 const char *Name);
3442LLVMValueRef LLVMBuildVAArg(LLVMBuilderRef, LLVMValueRef List, LLVMTypeRef Ty,
3443 const char *Name);
3444LLVMValueRef LLVMBuildExtractElement(LLVMBuilderRef, LLVMValueRef VecVal,
3445 LLVMValueRef Index, const char *Name);
3446LLVMValueRef LLVMBuildInsertElement(LLVMBuilderRef, LLVMValueRef VecVal,
3447 LLVMValueRef EltVal, LLVMValueRef Index,
3448 const char *Name);
3449LLVMValueRef LLVMBuildShuffleVector(LLVMBuilderRef, LLVMValueRef V1,
3450 LLVMValueRef V2, LLVMValueRef Mask,
3451 const char *Name);
Dan Gohmand5104a52008-11-03 22:55:43 +00003452LLVMValueRef LLVMBuildExtractValue(LLVMBuilderRef, LLVMValueRef AggVal,
3453 unsigned Index, const char *Name);
3454LLVMValueRef LLVMBuildInsertValue(LLVMBuilderRef, LLVMValueRef AggVal,
3455 LLVMValueRef EltVal, unsigned Index,
3456 const char *Name);
Gordon Henriksen76a03742007-09-18 03:18:57 +00003457
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00003458LLVMValueRef LLVMBuildIsNull(LLVMBuilderRef, LLVMValueRef Val,
3459 const char *Name);
3460LLVMValueRef LLVMBuildIsNotNull(LLVMBuilderRef, LLVMValueRef Val,
3461 const char *Name);
3462LLVMValueRef LLVMBuildPtrDiff(LLVMBuilderRef, LLVMValueRef LHS,
3463 LLVMValueRef RHS, const char *Name);
Filip Pizlo0d3f7ec2013-11-20 00:07:49 +00003464LLVMValueRef LLVMBuildFence(LLVMBuilderRef B, LLVMAtomicOrdering ordering,
3465 LLVMBool singleThread, const char *Name);
3466LLVMValueRef LLVMBuildAtomicRMW(LLVMBuilderRef B, LLVMAtomicRMWBinOp op,
NAKAMURA Takumia3a81352013-10-23 17:56:29 +00003467 LLVMValueRef PTR, LLVMValueRef Val,
3468 LLVMAtomicOrdering ordering,
Carlo Kok8c6719b2013-04-23 13:21:19 +00003469 LLVMBool singleThread);
Mehdi Amini43165d92016-03-19 21:28:28 +00003470LLVMValueRef LLVMBuildAtomicCmpXchg(LLVMBuilderRef B, LLVMValueRef Ptr,
3471 LLVMValueRef Cmp, LLVMValueRef New,
3472 LLVMAtomicOrdering SuccessOrdering,
3473 LLVMAtomicOrdering FailureOrdering,
3474 LLVMBool SingleThread);
3475
3476LLVMBool LLVMIsAtomicSingleThread(LLVMValueRef AtomicInst);
3477void LLVMSetAtomicSingleThread(LLVMValueRef AtomicInst, LLVMBool SingleThread);
3478
3479LLVMAtomicOrdering LLVMGetCmpXchgSuccessOrdering(LLVMValueRef CmpXchgInst);
3480void LLVMSetCmpXchgSuccessOrdering(LLVMValueRef CmpXchgInst,
3481 LLVMAtomicOrdering Ordering);
3482LLVMAtomicOrdering LLVMGetCmpXchgFailureOrdering(LLVMValueRef CmpXchgInst);
3483void LLVMSetCmpXchgFailureOrdering(LLVMValueRef CmpXchgInst,
3484 LLVMAtomicOrdering Ordering);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00003485
Gregory Szorc34c863a2012-03-21 03:54:29 +00003486/**
3487 * @}
3488 */
Gordon Henriksen34eb6d82007-12-19 22:30:40 +00003489
Gregory Szorc34c863a2012-03-21 03:54:29 +00003490/**
3491 * @defgroup LLVMCCoreModuleProvider Module Providers
3492 *
3493 * @{
3494 */
Gordon Henriksen0a68fe22007-12-12 01:04:30 +00003495
Gregory Szorc34c863a2012-03-21 03:54:29 +00003496/**
3497 * Changes the type of M so it can be passed to FunctionPassManagers and the
Jeffrey Yasskin091217b2010-01-27 20:34:15 +00003498 * JIT. They take ModuleProviders for historical reasons.
Gordon Henriksen0a68fe22007-12-12 01:04:30 +00003499 */
3500LLVMModuleProviderRef
3501LLVMCreateModuleProviderForExistingModule(LLVMModuleRef M);
3502
Gregory Szorc34c863a2012-03-21 03:54:29 +00003503/**
3504 * Destroys the module M.
Gordon Henriksen0a68fe22007-12-12 01:04:30 +00003505 */
Jeffrey Yasskin091217b2010-01-27 20:34:15 +00003506void LLVMDisposeModuleProvider(LLVMModuleProviderRef M);
Gordon Henriksen0a68fe22007-12-12 01:04:30 +00003507
Gregory Szorc34c863a2012-03-21 03:54:29 +00003508/**
3509 * @}
3510 */
Gordon Henriksen34eb6d82007-12-19 22:30:40 +00003511
Gregory Szorc34c863a2012-03-21 03:54:29 +00003512/**
3513 * @defgroup LLVMCCoreMemoryBuffers Memory Buffers
3514 *
3515 * @{
3516 */
Gordon Henriksen34eb6d82007-12-19 22:30:40 +00003517
Chris Lattner25963c62010-01-09 22:27:07 +00003518LLVMBool LLVMCreateMemoryBufferWithContentsOfFile(const char *Path,
3519 LLVMMemoryBufferRef *OutMemBuf,
3520 char **OutMessage);
3521LLVMBool LLVMCreateMemoryBufferWithSTDIN(LLVMMemoryBufferRef *OutMemBuf,
3522 char **OutMessage);
Bill Wendling526276a2013-02-14 19:11:28 +00003523LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRange(const char *InputData,
3524 size_t InputDataLength,
3525 const char *BufferName,
Bill Wendlingc9baa962013-02-14 19:39:14 +00003526 LLVMBool RequiresNullTerminator);
Bill Wendling526276a2013-02-14 19:11:28 +00003527LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRangeCopy(const char *InputData,
3528 size_t InputDataLength,
3529 const char *BufferName);
Tom Stellard62c03202013-04-18 19:50:53 +00003530const char *LLVMGetBufferStart(LLVMMemoryBufferRef MemBuf);
Tom Stellardb7fb7242013-04-16 23:12:51 +00003531size_t LLVMGetBufferSize(LLVMMemoryBufferRef MemBuf);
Gordon Henriksen34eb6d82007-12-19 22:30:40 +00003532void LLVMDisposeMemoryBuffer(LLVMMemoryBufferRef MemBuf);
3533
Gregory Szorc34c863a2012-03-21 03:54:29 +00003534/**
3535 * @}
3536 */
3537
3538/**
3539 * @defgroup LLVMCCorePassRegistry Pass Registry
3540 *
3541 * @{
3542 */
Owen Anderson4698c5d2010-10-07 17:55:47 +00003543
3544/** Return the global pass registry, for use with initialization functions.
Gregory Szorc34c863a2012-03-21 03:54:29 +00003545 @see llvm::PassRegistry::getPassRegistry */
Owen Anderson4698c5d2010-10-07 17:55:47 +00003546LLVMPassRegistryRef LLVMGetGlobalPassRegistry(void);
Gordon Henriksen878114b2008-03-16 04:20:44 +00003547
Gregory Szorc34c863a2012-03-21 03:54:29 +00003548/**
3549 * @}
3550 */
3551
3552/**
3553 * @defgroup LLVMCCorePassManagers Pass Managers
3554 *
3555 * @{
3556 */
Gordon Henriksen878114b2008-03-16 04:20:44 +00003557
3558/** Constructs a new whole-module pass pipeline. This type of pipeline is
3559 suitable for link-time optimization and whole-module transformations.
Gregory Szorc34c863a2012-03-21 03:54:29 +00003560 @see llvm::PassManager::PassManager */
Gordon Henriksena735a9c2008-05-04 12:55:34 +00003561LLVMPassManagerRef LLVMCreatePassManager(void);
Gordon Henriksen878114b2008-03-16 04:20:44 +00003562
3563/** Constructs a new function-by-function pass pipeline over the module
3564 provider. It does not take ownership of the module provider. This type of
3565 pipeline is suitable for code generation and JIT compilation tasks.
Gregory Szorc34c863a2012-03-21 03:54:29 +00003566 @see llvm::FunctionPassManager::FunctionPassManager */
Erick Tryzelaarad0e0cb2010-03-02 23:58:54 +00003567LLVMPassManagerRef LLVMCreateFunctionPassManagerForModule(LLVMModuleRef M);
3568
3569/** Deprecated: Use LLVMCreateFunctionPassManagerForModule instead. */
Gordon Henriksen878114b2008-03-16 04:20:44 +00003570LLVMPassManagerRef LLVMCreateFunctionPassManager(LLVMModuleProviderRef MP);
3571
3572/** Initializes, executes on the provided module, and finalizes all of the
3573 passes scheduled in the pass manager. Returns 1 if any of the passes
Gregory Szorc34c863a2012-03-21 03:54:29 +00003574 modified the module, 0 otherwise.
3575 @see llvm::PassManager::run(Module&) */
Chris Lattner25963c62010-01-09 22:27:07 +00003576LLVMBool LLVMRunPassManager(LLVMPassManagerRef PM, LLVMModuleRef M);
Gordon Henriksen878114b2008-03-16 04:20:44 +00003577
3578/** Initializes all of the function passes scheduled in the function pass
3579 manager. Returns 1 if any of the passes modified the module, 0 otherwise.
Gregory Szorc34c863a2012-03-21 03:54:29 +00003580 @see llvm::FunctionPassManager::doInitialization */
Chris Lattner25963c62010-01-09 22:27:07 +00003581LLVMBool LLVMInitializeFunctionPassManager(LLVMPassManagerRef FPM);
Gordon Henriksen878114b2008-03-16 04:20:44 +00003582
3583/** Executes all of the function passes scheduled in the function pass manager
3584 on the provided function. Returns 1 if any of the passes modified the
3585 function, false otherwise.
Gregory Szorc34c863a2012-03-21 03:54:29 +00003586 @see llvm::FunctionPassManager::run(Function&) */
Chris Lattner25963c62010-01-09 22:27:07 +00003587LLVMBool LLVMRunFunctionPassManager(LLVMPassManagerRef FPM, LLVMValueRef F);
Gordon Henriksen878114b2008-03-16 04:20:44 +00003588
Hiroshi Inoue0909ca12018-01-26 08:15:29 +00003589/** Finalizes all of the function passes scheduled in the function pass
Gordon Henriksen878114b2008-03-16 04:20:44 +00003590 manager. Returns 1 if any of the passes modified the module, 0 otherwise.
Gregory Szorc34c863a2012-03-21 03:54:29 +00003591 @see llvm::FunctionPassManager::doFinalization */
Chris Lattner25963c62010-01-09 22:27:07 +00003592LLVMBool LLVMFinalizeFunctionPassManager(LLVMPassManagerRef FPM);
Gordon Henriksen878114b2008-03-16 04:20:44 +00003593
3594/** Frees the memory of a pass pipeline. For function pipelines, does not free
3595 the module provider.
Gregory Szorc34c863a2012-03-21 03:54:29 +00003596 @see llvm::PassManagerBase::~PassManagerBase. */
Gordon Henriksen878114b2008-03-16 04:20:44 +00003597void LLVMDisposePassManager(LLVMPassManagerRef PM);
3598
Gregory Szorc34c863a2012-03-21 03:54:29 +00003599/**
3600 * @}
3601 */
3602
3603/**
Duncan Sands1cba0a82013-02-17 16:35:51 +00003604 * @defgroup LLVMCCoreThreading Threading
3605 *
3606 * Handle the structures needed to make LLVM safe for multithreading.
3607 *
3608 * @{
3609 */
3610
Chandler Carruth39cd2162014-06-27 15:13:01 +00003611/** Deprecated: Multi-threading can only be enabled/disabled with the compile
3612 time define LLVM_ENABLE_THREADS. This function always returns
3613 LLVMIsMultithreaded(). */
Benjamin Kramer325ec892013-10-23 16:57:34 +00003614LLVMBool LLVMStartMultithreaded(void);
Duncan Sands1cba0a82013-02-17 16:35:51 +00003615
Chandler Carruth39cd2162014-06-27 15:13:01 +00003616/** Deprecated: Multi-threading can only be enabled/disabled with the compile
3617 time define LLVM_ENABLE_THREADS. */
Benjamin Kramer325ec892013-10-23 16:57:34 +00003618void LLVMStopMultithreaded(void);
Duncan Sands1cba0a82013-02-17 16:35:51 +00003619
3620/** Check whether LLVM is executing in thread-safe mode or not.
3621 @see llvm::llvm_is_multithreaded */
Benjamin Kramer325ec892013-10-23 16:57:34 +00003622LLVMBool LLVMIsMultithreaded(void);
Duncan Sands1cba0a82013-02-17 16:35:51 +00003623
3624/**
3625 * @}
3626 */
3627
3628/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00003629 * @}
3630 */
3631
3632/**
3633 * @}
3634 */
Gordon Henriksen878114b2008-03-16 04:20:44 +00003635
Gordon Henriksen76a03742007-09-18 03:18:57 +00003636#ifdef __cplusplus
3637}
Eugene Zelenkoffec81c2015-11-04 22:32:32 +00003638#endif
Gordon Henriksen7330acd2007-10-05 23:59:36 +00003639
Eugene Zelenkoffec81c2015-11-04 22:32:32 +00003640#endif /* LLVM_C_CORE_H */