blob: 6792219f87306183c9f24f0fb1e33f6bd2d3eaba [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/**
846 * Obtain the number of operands for named metadata in a module.
847 *
848 * @see llvm::Module::getNamedMetadata()
849 */
Amaury Sechetb130f432016-04-23 00:12:45 +0000850unsigned LLVMGetNamedMetadataNumOperands(LLVMModuleRef M, const char *Name);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000851
852/**
853 * Obtain the named metadata operands for a module.
854 *
855 * The passed LLVMValueRef pointer should refer to an array of
856 * LLVMValueRef at least LLVMGetNamedMetadataNumOperands long. This
857 * array will be populated with the LLVMValueRef instances. Each
858 * instance corresponds to a llvm::MDNode.
859 *
860 * @see llvm::Module::getNamedMetadata()
861 * @see llvm::MDNode::getOperand()
862 */
Amaury Sechetb130f432016-04-23 00:12:45 +0000863void LLVMGetNamedMetadataOperands(LLVMModuleRef M, const char *Name,
864 LLVMValueRef *Dest);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000865
866/**
867 * Add an operand to named metadata.
868 *
869 * @see llvm::Module::getNamedMetadata()
870 * @see llvm::MDNode::addOperand()
871 */
Amaury Sechetb130f432016-04-23 00:12:45 +0000872void LLVMAddNamedMetadataOperand(LLVMModuleRef M, const char *Name,
Gregory Szorc34c863a2012-03-21 03:54:29 +0000873 LLVMValueRef Val);
874
Gregory Szorc52d26602012-03-21 07:28:27 +0000875/**
876 * Add a function to a module under a specified name.
877 *
878 * @see llvm::Function::Create()
879 */
880LLVMValueRef LLVMAddFunction(LLVMModuleRef M, const char *Name,
881 LLVMTypeRef FunctionTy);
882
883/**
884 * Obtain a Function value from a Module by its name.
885 *
886 * The returned value corresponds to a llvm::Function value.
887 *
888 * @see llvm::Module::getFunction()
889 */
890LLVMValueRef LLVMGetNamedFunction(LLVMModuleRef M, const char *Name);
891
892/**
893 * Obtain an iterator to the first Function in a Module.
894 *
895 * @see llvm::Module::begin()
896 */
897LLVMValueRef LLVMGetFirstFunction(LLVMModuleRef M);
898
899/**
900 * Obtain an iterator to the last Function in a Module.
901 *
902 * @see llvm::Module::end()
903 */
904LLVMValueRef LLVMGetLastFunction(LLVMModuleRef M);
905
906/**
907 * Advance a Function iterator to the next Function.
908 *
909 * Returns NULL if the iterator was already at the end and there are no more
910 * functions.
911 */
912LLVMValueRef LLVMGetNextFunction(LLVMValueRef Fn);
913
914/**
915 * Decrement a Function iterator to the previous Function.
916 *
917 * Returns NULL if the iterator was already at the beginning and there are
918 * no previous functions.
919 */
920LLVMValueRef LLVMGetPreviousFunction(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000921
Robert Widmannf108d572018-04-06 02:31:29 +0000922/** Deprecated: Use LLVMSetModuleInlineAsm2 instead. */
923void LLVMSetModuleInlineAsm(LLVMModuleRef M, const char *Asm);
924
Gregory Szorc34c863a2012-03-21 03:54:29 +0000925/**
926 * @}
927 */
928
929/**
930 * @defgroup LLVMCCoreType Types
931 *
932 * Types represent the type of a value.
933 *
934 * Types are associated with a context instance. The context internally
935 * deduplicates types so there is only 1 instance of a specific type
936 * alive at a time. In other words, a unique type is shared among all
937 * consumers within a context.
938 *
939 * A Type in the C API corresponds to llvm::Type.
940 *
941 * Types have the following hierarchy:
942 *
Gordon Henriksen76a03742007-09-18 03:18:57 +0000943 * types:
944 * integer type
945 * real type
946 * function type
947 * sequence types:
948 * array type
949 * pointer type
950 * vector type
951 * void type
952 * label type
953 * opaque type
Gregory Szorc34c863a2012-03-21 03:54:29 +0000954 *
955 * @{
Gordon Henriksen76a03742007-09-18 03:18:57 +0000956 */
957
Gregory Szorc34c863a2012-03-21 03:54:29 +0000958/**
959 * Obtain the enumerated type of a Type instance.
960 *
961 * @see llvm::Type:getTypeID()
962 */
Gordon Henriksen76a03742007-09-18 03:18:57 +0000963LLVMTypeKind LLVMGetTypeKind(LLVMTypeRef Ty);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000964
965/**
966 * Whether the type has a known size.
967 *
968 * Things that don't have a size are abstract types, labels, and void.a
969 *
970 * @see llvm::Type::isSized()
971 */
Torok Edwin1cd9ade2011-10-06 12:13:28 +0000972LLVMBool LLVMTypeIsSized(LLVMTypeRef Ty);
Gordon Henriksena49d4352008-03-07 19:13:06 +0000973
Gregory Szorc34c863a2012-03-21 03:54:29 +0000974/**
975 * Obtain the context to which this type instance is associated.
976 *
977 * @see llvm::Type::getContext()
978 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +0000979LLVMContextRef LLVMGetTypeContext(LLVMTypeRef Ty);
980
Gregory Szorc34c863a2012-03-21 03:54:29 +0000981/**
Anders Waldenborgb822cff2013-10-16 21:30:25 +0000982 * Dump a representation of a type to stderr.
983 *
984 * @see llvm::Type::dump()
985 */
986void LLVMDumpType(LLVMTypeRef Val);
987
988/**
Anders Waldenborg47b3bd32013-10-22 06:58:34 +0000989 * Return a string representation of the type. Use
990 * LLVMDisposeMessage to free the string.
991 *
992 * @see llvm::Type::print()
993 */
994char *LLVMPrintTypeToString(LLVMTypeRef Val);
995
996/**
Gregory Szorc34c863a2012-03-21 03:54:29 +0000997 * @defgroup LLVMCCoreTypeInt Integer Types
998 *
999 * Functions in this section operate on integer types.
1000 *
1001 * @{
1002 */
1003
1004/**
1005 * Obtain an integer type from a context with specified bit width.
1006 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +00001007LLVMTypeRef LLVMInt1TypeInContext(LLVMContextRef C);
1008LLVMTypeRef LLVMInt8TypeInContext(LLVMContextRef C);
1009LLVMTypeRef LLVMInt16TypeInContext(LLVMContextRef C);
1010LLVMTypeRef LLVMInt32TypeInContext(LLVMContextRef C);
1011LLVMTypeRef LLVMInt64TypeInContext(LLVMContextRef C);
Eugene Zelenkoffec81c2015-11-04 22:32:32 +00001012LLVMTypeRef LLVMInt128TypeInContext(LLVMContextRef C);
Erick Tryzelaar262332f2009-08-14 00:01:31 +00001013LLVMTypeRef LLVMIntTypeInContext(LLVMContextRef C, unsigned NumBits);
1014
Gregory Szorc34c863a2012-03-21 03:54:29 +00001015/**
1016 * Obtain an integer type from the global context with a specified bit
1017 * width.
1018 */
Gordon Henriksena735a9c2008-05-04 12:55:34 +00001019LLVMTypeRef LLVMInt1Type(void);
1020LLVMTypeRef LLVMInt8Type(void);
1021LLVMTypeRef LLVMInt16Type(void);
1022LLVMTypeRef LLVMInt32Type(void);
1023LLVMTypeRef LLVMInt64Type(void);
Eugene Zelenkoffec81c2015-11-04 22:32:32 +00001024LLVMTypeRef LLVMInt128Type(void);
Gordon Henriksened7beaa2007-10-06 16:05:20 +00001025LLVMTypeRef LLVMIntType(unsigned NumBits);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00001026unsigned LLVMGetIntTypeWidth(LLVMTypeRef IntegerTy);
Gordon Henriksen76a03742007-09-18 03:18:57 +00001027
Gregory Szorc34c863a2012-03-21 03:54:29 +00001028/**
1029 * @}
1030 */
1031
1032/**
1033 * @defgroup LLVMCCoreTypeFloat Floating Point Types
1034 *
1035 * @{
1036 */
1037
1038/**
1039 * Obtain a 16-bit floating point type from a context.
1040 */
Dan Gohman518cda42011-12-17 00:04:22 +00001041LLVMTypeRef LLVMHalfTypeInContext(LLVMContextRef C);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001042
1043/**
1044 * Obtain a 32-bit floating point type from a context.
1045 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +00001046LLVMTypeRef LLVMFloatTypeInContext(LLVMContextRef C);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001047
1048/**
1049 * Obtain a 64-bit floating point type from a context.
1050 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +00001051LLVMTypeRef LLVMDoubleTypeInContext(LLVMContextRef C);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001052
1053/**
1054 * Obtain a 80-bit floating point type (X87) from a context.
1055 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +00001056LLVMTypeRef LLVMX86FP80TypeInContext(LLVMContextRef C);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001057
1058/**
1059 * Obtain a 128-bit floating point type (112-bit mantissa) from a
1060 * context.
1061 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +00001062LLVMTypeRef LLVMFP128TypeInContext(LLVMContextRef C);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001063
1064/**
1065 * Obtain a 128-bit floating point type (two 64-bits) from a context.
1066 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +00001067LLVMTypeRef LLVMPPCFP128TypeInContext(LLVMContextRef C);
1068
Gregory Szorc34c863a2012-03-21 03:54:29 +00001069/**
1070 * Obtain a floating point type from the global context.
1071 *
1072 * These map to the functions in this group of the same name.
1073 */
Dan Gohman518cda42011-12-17 00:04:22 +00001074LLVMTypeRef LLVMHalfType(void);
Gordon Henriksena735a9c2008-05-04 12:55:34 +00001075LLVMTypeRef LLVMFloatType(void);
1076LLVMTypeRef LLVMDoubleType(void);
1077LLVMTypeRef LLVMX86FP80Type(void);
1078LLVMTypeRef LLVMFP128Type(void);
1079LLVMTypeRef LLVMPPCFP128Type(void);
Gordon Henriksen76a03742007-09-18 03:18:57 +00001080
Gregory Szorc34c863a2012-03-21 03:54:29 +00001081/**
1082 * @}
1083 */
1084
1085/**
1086 * @defgroup LLVMCCoreTypeFunction Function Types
1087 *
1088 * @{
1089 */
1090
1091/**
1092 * Obtain a function type consisting of a specified signature.
1093 *
1094 * The function is defined as a tuple of a return Type, a list of
1095 * parameter types, and whether the function is variadic.
1096 */
Gordon Henriksened7beaa2007-10-06 16:05:20 +00001097LLVMTypeRef LLVMFunctionType(LLVMTypeRef ReturnType,
1098 LLVMTypeRef *ParamTypes, unsigned ParamCount,
Chris Lattner25963c62010-01-09 22:27:07 +00001099 LLVMBool IsVarArg);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001100
1101/**
1102 * Returns whether a function type is variadic.
1103 */
Chris Lattner25963c62010-01-09 22:27:07 +00001104LLVMBool LLVMIsFunctionVarArg(LLVMTypeRef FunctionTy);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001105
1106/**
1107 * Obtain the Type this function Type returns.
1108 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00001109LLVMTypeRef LLVMGetReturnType(LLVMTypeRef FunctionTy);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001110
1111/**
1112 * Obtain the number of parameters this function accepts.
1113 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00001114unsigned LLVMCountParamTypes(LLVMTypeRef FunctionTy);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001115
1116/**
1117 * Obtain the types of a function's parameters.
1118 *
1119 * The Dest parameter should point to a pre-allocated array of
1120 * LLVMTypeRef at least LLVMCountParamTypes() large. On return, the
1121 * first LLVMCountParamTypes() entries in the array will be populated
1122 * with LLVMTypeRef instances.
1123 *
1124 * @param FunctionTy The function type to operate on.
1125 * @param Dest Memory address of an array to be filled with result.
1126 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00001127void LLVMGetParamTypes(LLVMTypeRef FunctionTy, LLVMTypeRef *Dest);
Gordon Henriksen76a03742007-09-18 03:18:57 +00001128
Gregory Szorc34c863a2012-03-21 03:54:29 +00001129/**
1130 * @}
1131 */
1132
1133/**
1134 * @defgroup LLVMCCoreTypeStruct Structure Types
1135 *
1136 * These functions relate to LLVMTypeRef instances.
1137 *
1138 * @see llvm::StructType
1139 *
1140 * @{
1141 */
1142
1143/**
1144 * Create a new structure type in a context.
1145 *
1146 * A structure is specified by a list of inner elements/types and
1147 * whether these can be packed together.
1148 *
1149 * @see llvm::StructType::create()
1150 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +00001151LLVMTypeRef LLVMStructTypeInContext(LLVMContextRef C, LLVMTypeRef *ElementTypes,
Chris Lattner25963c62010-01-09 22:27:07 +00001152 unsigned ElementCount, LLVMBool Packed);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001153
1154/**
1155 * Create a new structure type in the global context.
1156 *
1157 * @see llvm::StructType::create()
1158 */
Gordon Henriksened7beaa2007-10-06 16:05:20 +00001159LLVMTypeRef LLVMStructType(LLVMTypeRef *ElementTypes, unsigned ElementCount,
Chris Lattner25963c62010-01-09 22:27:07 +00001160 LLVMBool Packed);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001161
1162/**
1163 * Create an empty structure in a context having a specified name.
1164 *
1165 * @see llvm::StructType::create()
1166 */
Chris Lattnere71ccde2011-07-14 05:53:17 +00001167LLVMTypeRef LLVMStructCreateNamed(LLVMContextRef C, const char *Name);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001168
1169/**
1170 * Obtain the name of a structure.
1171 *
1172 * @see llvm::StructType::getName()
1173 */
Torok Edwin0d5f6ae2011-10-06 12:12:50 +00001174const char *LLVMGetStructName(LLVMTypeRef Ty);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001175
1176/**
1177 * Set the contents of a structure type.
1178 *
1179 * @see llvm::StructType::setBody()
1180 */
Chris Lattnere71ccde2011-07-14 05:53:17 +00001181void LLVMStructSetBody(LLVMTypeRef StructTy, LLVMTypeRef *ElementTypes,
1182 unsigned ElementCount, LLVMBool Packed);
1183
Gregory Szorc34c863a2012-03-21 03:54:29 +00001184/**
1185 * Get the number of elements defined inside the structure.
1186 *
1187 * @see llvm::StructType::getNumElements()
1188 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00001189unsigned LLVMCountStructElementTypes(LLVMTypeRef StructTy);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001190
1191/**
1192 * Get the elements within a structure.
1193 *
1194 * The function is passed the address of a pre-allocated array of
1195 * LLVMTypeRef at least LLVMCountStructElementTypes() long. After
1196 * invocation, this array will be populated with the structure's
1197 * elements. The objects in the destination array will have a lifetime
1198 * of the structure type itself, which is the lifetime of the context it
1199 * is contained in.
1200 */
Gordon Henriksen76a03742007-09-18 03:18:57 +00001201void LLVMGetStructElementTypes(LLVMTypeRef StructTy, LLVMTypeRef *Dest);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001202
1203/**
Peter Zotovc164a3f2015-06-04 09:09:53 +00001204 * Get the type of the element at a given index in the structure.
1205 *
1206 * @see llvm::StructType::getTypeAtIndex()
1207 */
1208LLVMTypeRef LLVMStructGetTypeAtIndex(LLVMTypeRef StructTy, unsigned i);
1209
1210/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00001211 * Determine whether a structure is packed.
1212 *
1213 * @see llvm::StructType::isPacked()
1214 */
Chris Lattner25963c62010-01-09 22:27:07 +00001215LLVMBool LLVMIsPackedStruct(LLVMTypeRef StructTy);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001216
1217/**
1218 * Determine whether a structure is opaque.
1219 *
1220 * @see llvm::StructType::isOpaque()
1221 */
Chris Lattner17cf05b2011-07-14 16:20:28 +00001222LLVMBool LLVMIsOpaqueStruct(LLVMTypeRef StructTy);
1223
Gregory Szorc34c863a2012-03-21 03:54:29 +00001224/**
1225 * @}
1226 */
Gordon Henriksen76a03742007-09-18 03:18:57 +00001227
Gregory Szorc34c863a2012-03-21 03:54:29 +00001228/**
1229 * @defgroup LLVMCCoreTypeSequential Sequential Types
1230 *
1231 * Sequential types represents "arrays" of types. This is a super class
1232 * for array, vector, and pointer types.
1233 *
1234 * @{
1235 */
1236
1237/**
1238 * Obtain the type of elements within a sequential type.
1239 *
1240 * This works on array, vector, and pointer types.
1241 *
1242 * @see llvm::SequentialType::getElementType()
1243 */
1244LLVMTypeRef LLVMGetElementType(LLVMTypeRef Ty);
1245
1246/**
whitequarkf6059fd2017-06-05 11:49:52 +00001247 * Returns type's subtypes
1248 *
1249 * @see llvm::Type::subtypes()
1250 */
1251void LLVMGetSubtypes(LLVMTypeRef Tp, LLVMTypeRef *Arr);
1252
1253/**
1254 * Return the number of types in the derived type.
1255 *
1256 * @see llvm::Type::getNumContainedTypes()
1257 */
1258unsigned LLVMGetNumContainedTypes(LLVMTypeRef Tp);
1259
1260/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00001261 * Create a fixed size array type that refers to a specific type.
1262 *
1263 * The created type will exist in the context that its element type
1264 * exists in.
1265 *
1266 * @see llvm::ArrayType::get()
1267 */
Gordon Henriksened7beaa2007-10-06 16:05:20 +00001268LLVMTypeRef LLVMArrayType(LLVMTypeRef ElementType, unsigned ElementCount);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001269
1270/**
1271 * Obtain the length of an array type.
1272 *
1273 * This only works on types that represent arrays.
1274 *
1275 * @see llvm::ArrayType::getNumElements()
1276 */
1277unsigned LLVMGetArrayLength(LLVMTypeRef ArrayTy);
1278
1279/**
1280 * Create a pointer type that points to a defined type.
1281 *
1282 * The created type will exist in the context that its pointee type
1283 * exists in.
1284 *
1285 * @see llvm::PointerType::get()
1286 */
Gordon Henriksen5a3fe032007-12-17 16:08:32 +00001287LLVMTypeRef LLVMPointerType(LLVMTypeRef ElementType, unsigned AddressSpace);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001288
1289/**
1290 * Obtain the address space of a pointer type.
1291 *
1292 * This only works on types that represent pointers.
1293 *
1294 * @see llvm::PointerType::getAddressSpace()
1295 */
1296unsigned LLVMGetPointerAddressSpace(LLVMTypeRef PointerTy);
1297
1298/**
1299 * Create a vector type that contains a defined type and has a specific
1300 * number of elements.
1301 *
1302 * The created type will exist in the context thats its element type
1303 * exists in.
1304 *
1305 * @see llvm::VectorType::get()
1306 */
Gordon Henriksened7beaa2007-10-06 16:05:20 +00001307LLVMTypeRef LLVMVectorType(LLVMTypeRef ElementType, unsigned ElementCount);
Gordon Henriksen76a03742007-09-18 03:18:57 +00001308
Gregory Szorc34c863a2012-03-21 03:54:29 +00001309/**
1310 * Obtain the number of elements in a vector type.
1311 *
1312 * This only works on types that represent vectors.
1313 *
1314 * @see llvm::VectorType::getNumElements()
1315 */
Gordon Henriksen76a03742007-09-18 03:18:57 +00001316unsigned LLVMGetVectorSize(LLVMTypeRef VectorTy);
1317
Gregory Szorc34c863a2012-03-21 03:54:29 +00001318/**
1319 * @}
1320 */
1321
1322/**
1323 * @defgroup LLVMCCoreTypeOther Other Types
1324 *
1325 * @{
1326 */
1327
1328/**
1329 * Create a void type in a context.
1330 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +00001331LLVMTypeRef LLVMVoidTypeInContext(LLVMContextRef C);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001332
1333/**
1334 * Create a label type in a context.
1335 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +00001336LLVMTypeRef LLVMLabelTypeInContext(LLVMContextRef C);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001337
1338/**
1339 * Create a X86 MMX type in a context.
1340 */
Dale Johannesen95b67af2010-09-10 21:58:02 +00001341LLVMTypeRef LLVMX86MMXTypeInContext(LLVMContextRef C);
Erick Tryzelaar262332f2009-08-14 00:01:31 +00001342
Gregory Szorc34c863a2012-03-21 03:54:29 +00001343/**
whitequark131f98f2017-10-27 11:51:40 +00001344 * Create a token type in a context.
1345 */
1346LLVMTypeRef LLVMTokenTypeInContext(LLVMContextRef C);
1347
1348/**
1349 * Create a metadata type in a context.
1350 */
1351LLVMTypeRef LLVMMetadataTypeInContext(LLVMContextRef C);
1352
1353/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00001354 * These are similar to the above functions except they operate on the
1355 * global context.
1356 */
Gordon Henriksena735a9c2008-05-04 12:55:34 +00001357LLVMTypeRef LLVMVoidType(void);
1358LLVMTypeRef LLVMLabelType(void);
Dale Johannesen95b67af2010-09-10 21:58:02 +00001359LLVMTypeRef LLVMX86MMXType(void);
Gordon Henriksen76a03742007-09-18 03:18:57 +00001360
Gregory Szorc34c863a2012-03-21 03:54:29 +00001361/**
1362 * @}
1363 */
Gordon Henriksen76a03742007-09-18 03:18:57 +00001364
Gregory Szorc34c863a2012-03-21 03:54:29 +00001365/**
1366 * @}
1367 */
1368
1369/**
1370 * @defgroup LLVMCCoreValues Values
1371 *
1372 * The bulk of LLVM's object model consists of values, which comprise a very
Gordon Henriksen76a03742007-09-18 03:18:57 +00001373 * rich type hierarchy.
Gregory Szorc34c863a2012-03-21 03:54:29 +00001374 *
1375 * LLVMValueRef essentially represents llvm::Value. There is a rich
1376 * hierarchy of classes within this type. Depending on the instance
Eli Benderskyc52863c2012-08-10 18:30:44 +00001377 * obtained, not all APIs are available.
Gregory Szorc34c863a2012-03-21 03:54:29 +00001378 *
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00001379 * Callers can determine the type of an LLVMValueRef by calling the
Gregory Szorc34c863a2012-03-21 03:54:29 +00001380 * LLVMIsA* family of functions (e.g. LLVMIsAArgument()). These
1381 * functions are defined by a macro, so it isn't obvious which are
1382 * available by looking at the Doxygen source code. Instead, look at the
1383 * source definition of LLVM_FOR_EACH_VALUE_SUBCLASS and note the list
1384 * of value names given. These value names also correspond to classes in
1385 * the llvm::Value hierarchy.
1386 *
1387 * @{
Gordon Henriksen76a03742007-09-18 03:18:57 +00001388 */
1389
Gordon Henriksen29e38942008-12-19 18:39:45 +00001390#define LLVM_FOR_EACH_VALUE_SUBCLASS(macro) \
1391 macro(Argument) \
1392 macro(BasicBlock) \
1393 macro(InlineAsm) \
1394 macro(User) \
1395 macro(Constant) \
Torok Edwind09b7572011-10-14 20:37:56 +00001396 macro(BlockAddress) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001397 macro(ConstantAggregateZero) \
1398 macro(ConstantArray) \
Peter Zotovae0344b2013-11-05 12:55:37 +00001399 macro(ConstantDataSequential) \
1400 macro(ConstantDataArray) \
1401 macro(ConstantDataVector) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001402 macro(ConstantExpr) \
1403 macro(ConstantFP) \
1404 macro(ConstantInt) \
1405 macro(ConstantPointerNull) \
1406 macro(ConstantStruct) \
David Majnemerf0f224d2015-11-11 21:57:16 +00001407 macro(ConstantTokenNone) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001408 macro(ConstantVector) \
1409 macro(GlobalValue) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001410 macro(GlobalAlias) \
Rafael Espindola99e05cf2014-05-13 18:45:48 +00001411 macro(GlobalObject) \
1412 macro(Function) \
1413 macro(GlobalVariable) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001414 macro(UndefValue) \
1415 macro(Instruction) \
1416 macro(BinaryOperator) \
1417 macro(CallInst) \
1418 macro(IntrinsicInst) \
1419 macro(DbgInfoIntrinsic) \
1420 macro(DbgDeclareInst) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001421 macro(MemIntrinsic) \
1422 macro(MemCpyInst) \
1423 macro(MemMoveInst) \
1424 macro(MemSetInst) \
1425 macro(CmpInst) \
Torok Edwind09b7572011-10-14 20:37:56 +00001426 macro(FCmpInst) \
1427 macro(ICmpInst) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001428 macro(ExtractElementInst) \
1429 macro(GetElementPtrInst) \
1430 macro(InsertElementInst) \
1431 macro(InsertValueInst) \
Bill Wendlingfae14752011-08-12 20:24:12 +00001432 macro(LandingPadInst) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001433 macro(PHINode) \
1434 macro(SelectInst) \
1435 macro(ShuffleVectorInst) \
1436 macro(StoreInst) \
1437 macro(TerminatorInst) \
1438 macro(BranchInst) \
Torok Edwind09b7572011-10-14 20:37:56 +00001439 macro(IndirectBrInst) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001440 macro(InvokeInst) \
1441 macro(ReturnInst) \
1442 macro(SwitchInst) \
1443 macro(UnreachableInst) \
Bill Wendlingf891bf82011-07-31 06:30:59 +00001444 macro(ResumeInst) \
David Majnemer654e1302015-07-31 17:58:14 +00001445 macro(CleanupReturnInst) \
1446 macro(CatchReturnInst) \
David Majnemer8a1c45d2015-12-12 05:38:55 +00001447 macro(FuncletPadInst) \
1448 macro(CatchPadInst) \
1449 macro(CleanupPadInst) \
Duncan Sands5e37e992013-05-06 08:55:45 +00001450 macro(UnaryInstruction) \
1451 macro(AllocaInst) \
1452 macro(CastInst) \
Matt Arsenaultb03bd4d2013-11-15 01:34:59 +00001453 macro(AddrSpaceCastInst) \
Duncan Sands5e37e992013-05-06 08:55:45 +00001454 macro(BitCastInst) \
1455 macro(FPExtInst) \
1456 macro(FPToSIInst) \
1457 macro(FPToUIInst) \
1458 macro(FPTruncInst) \
1459 macro(IntToPtrInst) \
1460 macro(PtrToIntInst) \
1461 macro(SExtInst) \
1462 macro(SIToFPInst) \
1463 macro(TruncInst) \
1464 macro(UIToFPInst) \
1465 macro(ZExtInst) \
1466 macro(ExtractValueInst) \
1467 macro(LoadInst) \
1468 macro(VAArgInst)
Gordon Henriksen29e38942008-12-19 18:39:45 +00001469
Gregory Szorc34c863a2012-03-21 03:54:29 +00001470/**
1471 * @defgroup LLVMCCoreValueGeneral General APIs
1472 *
1473 * Functions in this section work on all LLVMValueRef instances,
1474 * regardless of their sub-type. They correspond to functions available
1475 * on llvm::Value.
1476 *
1477 * @{
1478 */
Gordon Henriksen76a03742007-09-18 03:18:57 +00001479
Gregory Szorc34c863a2012-03-21 03:54:29 +00001480/**
1481 * Obtain the type of a value.
1482 *
1483 * @see llvm::Value::getType()
1484 */
1485LLVMTypeRef LLVMTypeOf(LLVMValueRef Val);
1486
1487/**
Peter Zotov3e4561c2016-04-06 22:21:29 +00001488 * Obtain the enumerated type of a Value instance.
1489 *
1490 * @see llvm::Value::getValueID()
1491 */
1492LLVMValueKind LLVMGetValueKind(LLVMValueRef Val);
1493
1494/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00001495 * Obtain the string name of a value.
1496 *
1497 * @see llvm::Value::getName()
1498 */
Robert Widmann025c78f2018-05-19 15:08:36 +00001499const char *LLVMGetValueName2(LLVMValueRef Val, size_t *Length);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001500
1501/**
1502 * Set the string name of a value.
1503 *
1504 * @see llvm::Value::setName()
1505 */
Robert Widmann025c78f2018-05-19 15:08:36 +00001506void LLVMSetValueName2(LLVMValueRef Val, const char *Name, size_t NameLen);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001507
1508/**
1509 * Dump a representation of a value to stderr.
1510 *
1511 * @see llvm::Value::dump()
1512 */
1513void LLVMDumpValue(LLVMValueRef Val);
1514
1515/**
Peter Zotovcd93b372013-11-06 09:21:01 +00001516 * Return a string representation of the value. Use
1517 * LLVMDisposeMessage to free the string.
1518 *
1519 * @see llvm::Value::print()
1520 */
1521char *LLVMPrintValueToString(LLVMValueRef Val);
1522
1523/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00001524 * Replace all uses of a value with another one.
1525 *
1526 * @see llvm::Value::replaceAllUsesWith()
1527 */
1528void LLVMReplaceAllUsesWith(LLVMValueRef OldVal, LLVMValueRef NewVal);
1529
1530/**
Amaury Sechet1c395072016-01-18 01:06:52 +00001531 * Determine whether the specified value instance is constant.
Gregory Szorc34c863a2012-03-21 03:54:29 +00001532 */
1533LLVMBool LLVMIsConstant(LLVMValueRef Val);
1534
1535/**
1536 * Determine whether a value instance is undefined.
1537 */
1538LLVMBool LLVMIsUndef(LLVMValueRef Val);
1539
1540/**
1541 * Convert value instances between types.
1542 *
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00001543 * Internally, an LLVMValueRef is "pinned" to a specific type. This
Gregory Szorc34c863a2012-03-21 03:54:29 +00001544 * series of functions allows you to cast an instance to a specific
1545 * type.
1546 *
1547 * If the cast is not valid for the specified type, NULL is returned.
1548 *
1549 * @see llvm::dyn_cast_or_null<>
1550 */
Gordon Henriksen29e38942008-12-19 18:39:45 +00001551#define LLVM_DECLARE_VALUE_CAST(name) \
1552 LLVMValueRef LLVMIsA##name(LLVMValueRef Val);
1553LLVM_FOR_EACH_VALUE_SUBCLASS(LLVM_DECLARE_VALUE_CAST)
1554
Duncan P. N. Exon Smith5bf8fef2014-12-09 18:38:53 +00001555LLVMValueRef LLVMIsAMDNode(LLVMValueRef Val);
1556LLVMValueRef LLVMIsAMDString(LLVMValueRef Val);
1557
Robert Widmann025c78f2018-05-19 15:08:36 +00001558/** Deprecated: Use LLVMGetValueName2 instead. */
1559const char *LLVMGetValueName(LLVMValueRef Val);
1560/** Deprecated: Use LLVMSetValueName2 instead. */
1561void LLVMSetValueName(LLVMValueRef Val, const char *Name);
1562
Gregory Szorc34c863a2012-03-21 03:54:29 +00001563/**
1564 * @}
1565 */
1566
1567/**
1568 * @defgroup LLVMCCoreValueUses Usage
1569 *
1570 * This module defines functions that allow you to inspect the uses of a
1571 * LLVMValueRef.
1572 *
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00001573 * It is possible to obtain an LLVMUseRef for any LLVMValueRef instance.
Gregory Szorc34c863a2012-03-21 03:54:29 +00001574 * Each LLVMUseRef (which corresponds to a llvm::Use instance) holds a
1575 * llvm::User and llvm::Value.
1576 *
1577 * @{
1578 */
1579
1580/**
1581 * Obtain the first use of a value.
1582 *
1583 * Uses are obtained in an iterator fashion. First, call this function
1584 * to obtain a reference to the first use. Then, call LLVMGetNextUse()
Eli Benderskyc52863c2012-08-10 18:30:44 +00001585 * on that instance and all subsequently obtained instances until
Gregory Szorc34c863a2012-03-21 03:54:29 +00001586 * LLVMGetNextUse() returns NULL.
1587 *
1588 * @see llvm::Value::use_begin()
1589 */
Erick Tryzelaar9f9857e2010-03-02 20:32:28 +00001590LLVMUseRef LLVMGetFirstUse(LLVMValueRef Val);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001591
1592/**
1593 * Obtain the next use of a value.
1594 *
1595 * This effectively advances the iterator. It returns NULL if you are on
1596 * the final use and no more are available.
1597 */
Erick Tryzelaar9f9857e2010-03-02 20:32:28 +00001598LLVMUseRef LLVMGetNextUse(LLVMUseRef U);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001599
1600/**
1601 * Obtain the user value for a user.
1602 *
1603 * The returned value corresponds to a llvm::User type.
1604 *
1605 * @see llvm::Use::getUser()
1606 */
Erick Tryzelaar9f9857e2010-03-02 20:32:28 +00001607LLVMValueRef LLVMGetUser(LLVMUseRef U);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001608
1609/**
1610 * Obtain the value this use corresponds to.
1611 *
1612 * @see llvm::Use::get().
1613 */
Erick Tryzelaar9f9857e2010-03-02 20:32:28 +00001614LLVMValueRef LLVMGetUsedValue(LLVMUseRef U);
Chris Lattner40cf28d2009-10-12 04:01:02 +00001615
Gregory Szorc34c863a2012-03-21 03:54:29 +00001616/**
1617 * @}
1618 */
1619
1620/**
Gregory Szorc52d26602012-03-21 07:28:27 +00001621 * @defgroup LLVMCCoreValueUser User value
Gregory Szorc34c863a2012-03-21 03:54:29 +00001622 *
1623 * Function in this group pertain to LLVMValueRef instances that descent
1624 * from llvm::User. This includes constants, instructions, and
1625 * operators.
1626 *
1627 * @{
1628 */
1629
1630/**
1631 * Obtain an operand at a specific index in a llvm::User value.
1632 *
1633 * @see llvm::User::getOperand()
1634 */
Chris Lattner40cf28d2009-10-12 04:01:02 +00001635LLVMValueRef LLVMGetOperand(LLVMValueRef Val, unsigned Index);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001636
1637/**
Peter Zotovb19f78f2014-08-12 02:55:40 +00001638 * Obtain the use of an operand at a specific index in a llvm::User value.
1639 *
1640 * @see llvm::User::getOperandUse()
1641 */
1642LLVMUseRef LLVMGetOperandUse(LLVMValueRef Val, unsigned Index);
1643
1644/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00001645 * Set an operand at a specific index in a llvm::User value.
1646 *
1647 * @see llvm::User::setOperand()
1648 */
Erick Tryzelaarb4d48702010-08-20 14:51:22 +00001649void LLVMSetOperand(LLVMValueRef User, unsigned Index, LLVMValueRef Val);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001650
1651/**
1652 * Obtain the number of operands in a llvm::User value.
1653 *
1654 * @see llvm::User::getNumOperands()
1655 */
Erick Tryzelaarb4d48702010-08-20 14:51:22 +00001656int LLVMGetNumOperands(LLVMValueRef Val);
Chris Lattner40cf28d2009-10-12 04:01:02 +00001657
Gregory Szorc34c863a2012-03-21 03:54:29 +00001658/**
1659 * @}
1660 */
1661
1662/**
Gregory Szorc52d26602012-03-21 07:28:27 +00001663 * @defgroup LLVMCCoreValueConstant Constants
Gregory Szorc34c863a2012-03-21 03:54:29 +00001664 *
1665 * This section contains APIs for interacting with LLVMValueRef that
1666 * correspond to llvm::Constant instances.
1667 *
1668 * These functions will work for any LLVMValueRef in the llvm::Constant
1669 * class hierarchy.
1670 *
1671 * @{
1672 */
1673
1674/**
1675 * Obtain a constant value referring to the null instance of a type.
1676 *
1677 * @see llvm::Constant::getNullValue()
1678 */
Gordon Henriksen1046c732007-10-06 15:11:06 +00001679LLVMValueRef LLVMConstNull(LLVMTypeRef Ty); /* all zeroes */
Gregory Szorc34c863a2012-03-21 03:54:29 +00001680
1681/**
1682 * Obtain a constant value referring to the instance of a type
1683 * consisting of all ones.
1684 *
1685 * This is only valid for integer types.
1686 *
1687 * @see llvm::Constant::getAllOnesValue()
1688 */
1689LLVMValueRef LLVMConstAllOnes(LLVMTypeRef Ty);
1690
1691/**
1692 * Obtain a constant value referring to an undefined value of a type.
1693 *
1694 * @see llvm::UndefValue::get()
1695 */
Gordon Henriksen76a03742007-09-18 03:18:57 +00001696LLVMValueRef LLVMGetUndef(LLVMTypeRef Ty);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001697
1698/**
1699 * Determine whether a value instance is null.
1700 *
1701 * @see llvm::Constant::isNullValue()
1702 */
Chris Lattner25963c62010-01-09 22:27:07 +00001703LLVMBool LLVMIsNull(LLVMValueRef Val);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001704
1705/**
1706 * Obtain a constant that is a constant pointer pointing to NULL for a
1707 * specified type.
1708 */
Chris Lattner7f318242009-07-06 17:29:59 +00001709LLVMValueRef LLVMConstPointerNull(LLVMTypeRef Ty);
Gordon Henriksen76a03742007-09-18 03:18:57 +00001710
Gregory Szorc34c863a2012-03-21 03:54:29 +00001711/**
1712 * @defgroup LLVMCCoreValueConstantScalar Scalar constants
1713 *
1714 * Functions in this group model LLVMValueRef instances that correspond
1715 * to constants referring to scalar types.
1716 *
1717 * For integer types, the LLVMTypeRef parameter should correspond to a
1718 * llvm::IntegerType instance and the returned LLVMValueRef will
1719 * correspond to a llvm::ConstantInt.
1720 *
1721 * For floating point types, the LLVMTypeRef returned corresponds to a
1722 * llvm::ConstantFP.
1723 *
1724 * @{
1725 */
Erick Tryzelaard8531fa2010-02-28 09:45:59 +00001726
Gregory Szorc34c863a2012-03-21 03:54:29 +00001727/**
1728 * Obtain a constant value for an integer type.
1729 *
1730 * The returned value corresponds to a llvm::ConstantInt.
1731 *
1732 * @see llvm::ConstantInt::get()
1733 *
1734 * @param IntTy Integer type to obtain value of.
1735 * @param N The value the returned instance should refer to.
1736 * @param SignExtend Whether to sign extend the produced value.
1737 */
Gordon Henriksen1046c732007-10-06 15:11:06 +00001738LLVMValueRef LLVMConstInt(LLVMTypeRef IntTy, unsigned long long N,
Chris Lattner25963c62010-01-09 22:27:07 +00001739 LLVMBool SignExtend);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001740
1741/**
1742 * Obtain a constant value for an integer of arbitrary precision.
1743 *
1744 * @see llvm::ConstantInt::get()
1745 */
Chris Lattner4329e072010-11-23 02:47:22 +00001746LLVMValueRef LLVMConstIntOfArbitraryPrecision(LLVMTypeRef IntTy,
1747 unsigned NumWords,
1748 const uint64_t Words[]);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001749
1750/**
1751 * Obtain a constant value for an integer parsed from a string.
1752 *
1753 * A similar API, LLVMConstIntOfStringAndSize is also available. If the
1754 * string's length is available, it is preferred to call that function
1755 * instead.
1756 *
1757 * @see llvm::ConstantInt::get()
1758 */
Erick Tryzelaardd991352009-08-16 23:36:46 +00001759LLVMValueRef LLVMConstIntOfString(LLVMTypeRef IntTy, const char *Text,
1760 uint8_t Radix);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001761
1762/**
1763 * Obtain a constant value for an integer parsed from a string with
1764 * specified length.
1765 *
1766 * @see llvm::ConstantInt::get()
1767 */
Erick Tryzelaardd991352009-08-16 23:36:46 +00001768LLVMValueRef LLVMConstIntOfStringAndSize(LLVMTypeRef IntTy, const char *Text,
1769 unsigned SLen, uint8_t Radix);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001770
1771/**
1772 * Obtain a constant value referring to a double floating point value.
1773 */
Gordon Henriksen1046c732007-10-06 15:11:06 +00001774LLVMValueRef LLVMConstReal(LLVMTypeRef RealTy, double N);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001775
1776/**
1777 * Obtain a constant for a floating point value parsed from a string.
1778 *
1779 * A similar API, LLVMConstRealOfStringAndSize is also available. It
1780 * should be used if the input string's length is known.
1781 */
Gordon Henriksen931e1212008-02-02 01:07:50 +00001782LLVMValueRef LLVMConstRealOfString(LLVMTypeRef RealTy, const char *Text);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001783
1784/**
1785 * Obtain a constant for a floating point value parsed from a string.
1786 */
Erick Tryzelaardd991352009-08-16 23:36:46 +00001787LLVMValueRef LLVMConstRealOfStringAndSize(LLVMTypeRef RealTy, const char *Text,
1788 unsigned SLen);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001789
1790/**
1791 * Obtain the zero extended value for an integer constant value.
1792 *
1793 * @see llvm::ConstantInt::getZExtValue()
1794 */
Chris Lattner40cf28d2009-10-12 04:01:02 +00001795unsigned long long LLVMConstIntGetZExtValue(LLVMValueRef ConstantVal);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001796
1797/**
1798 * Obtain the sign extended value for an integer constant value.
1799 *
1800 * @see llvm::ConstantInt::getSExtValue()
1801 */
Chris Lattner40cf28d2009-10-12 04:01:02 +00001802long long LLVMConstIntGetSExtValue(LLVMValueRef ConstantVal);
Erick Tryzelaardd991352009-08-16 23:36:46 +00001803
Gregory Szorc34c863a2012-03-21 03:54:29 +00001804/**
Peter Zotov1d98e6d2014-10-28 19:46:44 +00001805 * Obtain the double value for an floating point constant value.
1806 * losesInfo indicates if some precision was lost in the conversion.
1807 *
1808 * @see llvm::ConstantFP::getDoubleValue
1809 */
1810double LLVMConstRealGetDouble(LLVMValueRef ConstantVal, LLVMBool *losesInfo);
1811
1812/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00001813 * @}
1814 */
1815
1816/**
Gregory Szorc52d26602012-03-21 07:28:27 +00001817 * @defgroup LLVMCCoreValueConstantComposite Composite Constants
1818 *
1819 * Functions in this group operate on composite constants.
Gregory Szorc34c863a2012-03-21 03:54:29 +00001820 *
1821 * @{
1822 */
1823
1824/**
Gregory Szorc52d26602012-03-21 07:28:27 +00001825 * Create a ConstantDataSequential and initialize it with a string.
Gregory Szorc34c863a2012-03-21 03:54:29 +00001826 *
Gregory Szorc52d26602012-03-21 07:28:27 +00001827 * @see llvm::ConstantDataArray::getString()
Gregory Szorc34c863a2012-03-21 03:54:29 +00001828 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +00001829LLVMValueRef LLVMConstStringInContext(LLVMContextRef C, const char *Str,
Chris Lattner25963c62010-01-09 22:27:07 +00001830 unsigned Length, LLVMBool DontNullTerminate);
Gregory Szorc52d26602012-03-21 07:28:27 +00001831
1832/**
1833 * Create a ConstantDataSequential with string content in the global context.
1834 *
1835 * This is the same as LLVMConstStringInContext except it operates on the
1836 * global context.
1837 *
1838 * @see LLVMConstStringInContext()
1839 * @see llvm::ConstantDataArray::getString()
1840 */
1841LLVMValueRef LLVMConstString(const char *Str, unsigned Length,
1842 LLVMBool DontNullTerminate);
1843
1844/**
Peter Zotovf9aa8822014-08-03 23:54:16 +00001845 * Returns true if the specified constant is an array of i8.
1846 *
1847 * @see ConstantDataSequential::getAsString()
1848 */
1849LLVMBool LLVMIsConstantString(LLVMValueRef c);
1850
1851/**
1852 * Get the given constant data sequential as a string.
1853 *
1854 * @see ConstantDataSequential::getAsString()
1855 */
Amaury Sechet7c2883c2016-04-03 21:06:04 +00001856const char *LLVMGetAsString(LLVMValueRef c, size_t *Length);
Peter Zotovf9aa8822014-08-03 23:54:16 +00001857
1858/**
Gregory Szorc52d26602012-03-21 07:28:27 +00001859 * Create an anonymous ConstantStruct with the specified values.
1860 *
1861 * @see llvm::ConstantStruct::getAnon()
1862 */
1863LLVMValueRef LLVMConstStructInContext(LLVMContextRef C,
Erick Tryzelaar262332f2009-08-14 00:01:31 +00001864 LLVMValueRef *ConstantVals,
Chris Lattner25963c62010-01-09 22:27:07 +00001865 unsigned Count, LLVMBool Packed);
Erick Tryzelaar262332f2009-08-14 00:01:31 +00001866
Gregory Szorc52d26602012-03-21 07:28:27 +00001867/**
1868 * Create a ConstantStruct in the global Context.
1869 *
1870 * This is the same as LLVMConstStructInContext except it operates on the
1871 * global Context.
1872 *
1873 * @see LLVMConstStructInContext()
1874 */
Gordon Henriksen1046c732007-10-06 15:11:06 +00001875LLVMValueRef LLVMConstStruct(LLVMValueRef *ConstantVals, unsigned Count,
Chris Lattner25963c62010-01-09 22:27:07 +00001876 LLVMBool Packed);
Gregory Szorc52d26602012-03-21 07:28:27 +00001877
1878/**
1879 * Create a ConstantArray from values.
1880 *
1881 * @see llvm::ConstantArray::get()
1882 */
1883LLVMValueRef LLVMConstArray(LLVMTypeRef ElementTy,
1884 LLVMValueRef *ConstantVals, unsigned Length);
1885
1886/**
1887 * Create a non-anonymous ConstantStruct from values.
1888 *
1889 * @see llvm::ConstantStruct::get()
1890 */
Rafael Espindola784ad242011-07-14 19:09:08 +00001891LLVMValueRef LLVMConstNamedStruct(LLVMTypeRef StructTy,
1892 LLVMValueRef *ConstantVals,
1893 unsigned Count);
Gregory Szorc52d26602012-03-21 07:28:27 +00001894
1895/**
Peter Zotovf9aa8822014-08-03 23:54:16 +00001896 * Get an element at specified index as a constant.
1897 *
1898 * @see ConstantDataSequential::getElementAsConstant()
1899 */
Amaury Sechet006ce632016-03-13 00:54:40 +00001900LLVMValueRef LLVMGetElementAsConstant(LLVMValueRef C, unsigned idx);
Peter Zotovf9aa8822014-08-03 23:54:16 +00001901
1902/**
Gregory Szorc52d26602012-03-21 07:28:27 +00001903 * Create a ConstantVector from values.
1904 *
1905 * @see llvm::ConstantVector::get()
1906 */
Gordon Henriksen1046c732007-10-06 15:11:06 +00001907LLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals, unsigned Size);
Gordon Henriksen76a03742007-09-18 03:18:57 +00001908
Gregory Szorc52d26602012-03-21 07:28:27 +00001909/**
1910 * @}
1911 */
1912
1913/**
1914 * @defgroup LLVMCCoreValueConstantExpressions Constant Expressions
1915 *
1916 * Functions in this group correspond to APIs on llvm::ConstantExpr.
1917 *
1918 * @see llvm::ConstantExpr.
1919 *
1920 * @{
1921 */
Chris Lattner40cf28d2009-10-12 04:01:02 +00001922LLVMOpcode LLVMGetConstOpcode(LLVMValueRef ConstantVal);
Erick Tryzelaarfd529d72009-08-19 08:36:49 +00001923LLVMValueRef LLVMAlignOf(LLVMTypeRef Ty);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001924LLVMValueRef LLVMSizeOf(LLVMTypeRef Ty);
1925LLVMValueRef LLVMConstNeg(LLVMValueRef ConstantVal);
Erick Tryzelaar4c340c72010-02-28 05:51:43 +00001926LLVMValueRef LLVMConstNSWNeg(LLVMValueRef ConstantVal);
1927LLVMValueRef LLVMConstNUWNeg(LLVMValueRef ConstantVal);
Erick Tryzelaar4cc690c2009-08-16 02:20:12 +00001928LLVMValueRef LLVMConstFNeg(LLVMValueRef ConstantVal);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001929LLVMValueRef LLVMConstNot(LLVMValueRef ConstantVal);
1930LLVMValueRef LLVMConstAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Dan Gohmane4ca02d2009-09-03 23:34:49 +00001931LLVMValueRef LLVMConstNSWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Erick Tryzelaar4c340c72010-02-28 05:51:43 +00001932LLVMValueRef LLVMConstNUWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Erick Tryzelaar4cc690c2009-08-16 02:20:12 +00001933LLVMValueRef LLVMConstFAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001934LLVMValueRef LLVMConstSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Erick Tryzelaar4c340c72010-02-28 05:51:43 +00001935LLVMValueRef LLVMConstNSWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1936LLVMValueRef LLVMConstNUWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Erick Tryzelaar4cc690c2009-08-16 02:20:12 +00001937LLVMValueRef LLVMConstFSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001938LLVMValueRef LLVMConstMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Erick Tryzelaar4c340c72010-02-28 05:51:43 +00001939LLVMValueRef LLVMConstNSWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1940LLVMValueRef LLVMConstNUWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Erick Tryzelaar4cc690c2009-08-16 02:20:12 +00001941LLVMValueRef LLVMConstFMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001942LLVMValueRef LLVMConstUDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Manuel Jacob49fafb12016-10-04 23:32:42 +00001943LLVMValueRef LLVMConstExactUDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001944LLVMValueRef LLVMConstSDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Dan Gohmane4ca02d2009-09-03 23:34:49 +00001945LLVMValueRef LLVMConstExactSDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001946LLVMValueRef LLVMConstFDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1947LLVMValueRef LLVMConstURem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1948LLVMValueRef LLVMConstSRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1949LLVMValueRef LLVMConstFRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1950LLVMValueRef LLVMConstAnd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1951LLVMValueRef LLVMConstOr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1952LLVMValueRef LLVMConstXor(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1953LLVMValueRef LLVMConstICmp(LLVMIntPredicate Predicate,
1954 LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1955LLVMValueRef LLVMConstFCmp(LLVMRealPredicate Predicate,
1956 LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1957LLVMValueRef LLVMConstShl(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1958LLVMValueRef LLVMConstLShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1959LLVMValueRef LLVMConstAShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1960LLVMValueRef LLVMConstGEP(LLVMValueRef ConstantVal,
1961 LLVMValueRef *ConstantIndices, unsigned NumIndices);
Dan Gohmane4ca02d2009-09-03 23:34:49 +00001962LLVMValueRef LLVMConstInBoundsGEP(LLVMValueRef ConstantVal,
1963 LLVMValueRef *ConstantIndices,
1964 unsigned NumIndices);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001965LLVMValueRef LLVMConstTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1966LLVMValueRef LLVMConstSExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1967LLVMValueRef LLVMConstZExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1968LLVMValueRef LLVMConstFPTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1969LLVMValueRef LLVMConstFPExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1970LLVMValueRef LLVMConstUIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1971LLVMValueRef LLVMConstSIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1972LLVMValueRef LLVMConstFPToUI(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1973LLVMValueRef LLVMConstFPToSI(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1974LLVMValueRef LLVMConstPtrToInt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1975LLVMValueRef LLVMConstIntToPtr(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1976LLVMValueRef LLVMConstBitCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
Matt Arsenaultb03bd4d2013-11-15 01:34:59 +00001977LLVMValueRef LLVMConstAddrSpaceCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
Erick Tryzelaar4cc690c2009-08-16 02:20:12 +00001978LLVMValueRef LLVMConstZExtOrBitCast(LLVMValueRef ConstantVal,
1979 LLVMTypeRef ToType);
1980LLVMValueRef LLVMConstSExtOrBitCast(LLVMValueRef ConstantVal,
1981 LLVMTypeRef ToType);
1982LLVMValueRef LLVMConstTruncOrBitCast(LLVMValueRef ConstantVal,
1983 LLVMTypeRef ToType);
1984LLVMValueRef LLVMConstPointerCast(LLVMValueRef ConstantVal,
1985 LLVMTypeRef ToType);
1986LLVMValueRef LLVMConstIntCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType,
Chris Lattner25963c62010-01-09 22:27:07 +00001987 LLVMBool isSigned);
Erick Tryzelaar4cc690c2009-08-16 02:20:12 +00001988LLVMValueRef LLVMConstFPCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001989LLVMValueRef LLVMConstSelect(LLVMValueRef ConstantCondition,
1990 LLVMValueRef ConstantIfTrue,
1991 LLVMValueRef ConstantIfFalse);
1992LLVMValueRef LLVMConstExtractElement(LLVMValueRef VectorConstant,
1993 LLVMValueRef IndexConstant);
1994LLVMValueRef LLVMConstInsertElement(LLVMValueRef VectorConstant,
1995 LLVMValueRef ElementValueConstant,
1996 LLVMValueRef IndexConstant);
1997LLVMValueRef LLVMConstShuffleVector(LLVMValueRef VectorAConstant,
1998 LLVMValueRef VectorBConstant,
1999 LLVMValueRef MaskConstant);
Dan Gohmand5104a52008-11-03 22:55:43 +00002000LLVMValueRef LLVMConstExtractValue(LLVMValueRef AggConstant, unsigned *IdxList,
2001 unsigned NumIdx);
2002LLVMValueRef LLVMConstInsertValue(LLVMValueRef AggConstant,
2003 LLVMValueRef ElementValueConstant,
2004 unsigned *IdxList, unsigned NumIdx);
Robert Widmannf108d572018-04-06 02:31:29 +00002005LLVMValueRef LLVMBlockAddress(LLVMValueRef F, LLVMBasicBlockRef BB);
2006
2007/** Deprecated: Use LLVMGetInlineAsm instead. */
Chris Lattner25963c62010-01-09 22:27:07 +00002008LLVMValueRef LLVMConstInlineAsm(LLVMTypeRef Ty,
Chris Lattner3d1f5522008-12-17 21:39:50 +00002009 const char *AsmString, const char *Constraints,
Chris Lattner25963c62010-01-09 22:27:07 +00002010 LLVMBool HasSideEffects, LLVMBool IsAlignStack);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00002011
Gregory Szorc52d26602012-03-21 07:28:27 +00002012/**
2013 * @}
2014 */
2015
2016/**
2017 * @defgroup LLVMCCoreValueConstantGlobals Global Values
2018 *
2019 * This group contains functions that operate on global values. Functions in
2020 * this group relate to functions in the llvm::GlobalValue class tree.
2021 *
2022 * @see llvm::GlobalValue
2023 *
2024 * @{
2025 */
2026
Gordon Henriksen265f7802008-03-19 01:11:35 +00002027LLVMModuleRef LLVMGetGlobalParent(LLVMValueRef Global);
Chris Lattner25963c62010-01-09 22:27:07 +00002028LLVMBool LLVMIsDeclaration(LLVMValueRef Global);
Gordon Henriksen76a03742007-09-18 03:18:57 +00002029LLVMLinkage LLVMGetLinkage(LLVMValueRef Global);
2030void LLVMSetLinkage(LLVMValueRef Global, LLVMLinkage Linkage);
2031const char *LLVMGetSection(LLVMValueRef Global);
2032void LLVMSetSection(LLVMValueRef Global, const char *Section);
2033LLVMVisibility LLVMGetVisibility(LLVMValueRef Global);
2034void LLVMSetVisibility(LLVMValueRef Global, LLVMVisibility Viz);
Reid Kleckner2fae26f2014-03-05 02:34:23 +00002035LLVMDLLStorageClass LLVMGetDLLStorageClass(LLVMValueRef Global);
2036void LLVMSetDLLStorageClass(LLVMValueRef Global, LLVMDLLStorageClass Class);
Robert Widmann4bb481b2018-03-14 06:45:51 +00002037LLVMUnnamedAddr LLVMGetUnnamedAddress(LLVMValueRef Global);
2038void LLVMSetUnnamedAddress(LLVMValueRef Global, LLVMUnnamedAddr UnnamedAddr);
2039
2040/** Deprecated: Use LLVMGetUnnamedAddress instead. */
Tim Northoverad96d012014-03-10 19:24:35 +00002041LLVMBool LLVMHasUnnamedAddr(LLVMValueRef Global);
Robert Widmann4bb481b2018-03-14 06:45:51 +00002042/** Deprecated: Use LLVMSetUnnamedAddress instead. */
Tim Northoverad96d012014-03-10 19:24:35 +00002043void LLVMSetUnnamedAddr(LLVMValueRef Global, LLVMBool HasUnnamedAddr);
Anders Waldenborg213a63f2013-10-29 09:02:02 +00002044
2045/**
2046 * @defgroup LLVMCCoreValueWithAlignment Values with alignment
2047 *
2048 * Functions in this group only apply to values with alignment, i.e.
2049 * global variables, load and store instructions.
2050 */
2051
2052/**
2053 * Obtain the preferred alignment of the value.
Peter Zotov9f584e62014-03-05 05:05:34 +00002054 * @see llvm::AllocaInst::getAlignment()
Anders Waldenborg213a63f2013-10-29 09:02:02 +00002055 * @see llvm::LoadInst::getAlignment()
2056 * @see llvm::StoreInst::getAlignment()
2057 * @see llvm::GlobalValue::getAlignment()
2058 */
2059unsigned LLVMGetAlignment(LLVMValueRef V);
2060
2061/**
2062 * Set the preferred alignment of the value.
Peter Zotov9f584e62014-03-05 05:05:34 +00002063 * @see llvm::AllocaInst::setAlignment()
Anders Waldenborg213a63f2013-10-29 09:02:02 +00002064 * @see llvm::LoadInst::setAlignment()
2065 * @see llvm::StoreInst::setAlignment()
2066 * @see llvm::GlobalValue::setAlignment()
2067 */
2068void LLVMSetAlignment(LLVMValueRef V, unsigned Bytes);
2069
2070/**
Amaury Sechet83550102016-02-14 08:58:49 +00002071 * @}
2072 */
Gordon Henriksen76a03742007-09-18 03:18:57 +00002073
Gregory Szorc52d26602012-03-21 07:28:27 +00002074/**
2075 * @defgroup LLVMCoreValueConstantGlobalVariable Global Variables
2076 *
2077 * This group contains functions that operate on global variable values.
2078 *
2079 * @see llvm::GlobalVariable
2080 *
2081 * @{
2082 */
Gordon Henriksen76a03742007-09-18 03:18:57 +00002083LLVMValueRef LLVMAddGlobal(LLVMModuleRef M, LLVMTypeRef Ty, const char *Name);
Erick Tryzelaar06894b32010-02-28 09:46:13 +00002084LLVMValueRef LLVMAddGlobalInAddressSpace(LLVMModuleRef M, LLVMTypeRef Ty,
2085 const char *Name,
2086 unsigned AddressSpace);
Gordon Henriksen783f7bb2007-10-08 03:45:09 +00002087LLVMValueRef LLVMGetNamedGlobal(LLVMModuleRef M, const char *Name);
Gordon Henriksen07a45f42008-03-23 22:21:29 +00002088LLVMValueRef LLVMGetFirstGlobal(LLVMModuleRef M);
2089LLVMValueRef LLVMGetLastGlobal(LLVMModuleRef M);
2090LLVMValueRef LLVMGetNextGlobal(LLVMValueRef GlobalVar);
2091LLVMValueRef LLVMGetPreviousGlobal(LLVMValueRef GlobalVar);
Gordon Henriksen76a03742007-09-18 03:18:57 +00002092void LLVMDeleteGlobal(LLVMValueRef GlobalVar);
Gordon Henriksen76a03742007-09-18 03:18:57 +00002093LLVMValueRef LLVMGetInitializer(LLVMValueRef GlobalVar);
2094void LLVMSetInitializer(LLVMValueRef GlobalVar, LLVMValueRef ConstantVal);
Chris Lattner25963c62010-01-09 22:27:07 +00002095LLVMBool LLVMIsThreadLocal(LLVMValueRef GlobalVar);
2096void LLVMSetThreadLocal(LLVMValueRef GlobalVar, LLVMBool IsThreadLocal);
2097LLVMBool LLVMIsGlobalConstant(LLVMValueRef GlobalVar);
2098void LLVMSetGlobalConstant(LLVMValueRef GlobalVar, LLVMBool IsConstant);
Hans Wennborg5ff71202013-04-16 08:58:59 +00002099LLVMThreadLocalMode LLVMGetThreadLocalMode(LLVMValueRef GlobalVar);
2100void LLVMSetThreadLocalMode(LLVMValueRef GlobalVar, LLVMThreadLocalMode Mode);
2101LLVMBool LLVMIsExternallyInitialized(LLVMValueRef GlobalVar);
2102void LLVMSetExternallyInitialized(LLVMValueRef GlobalVar, LLVMBool IsExtInit);
Gordon Henriksen76a03742007-09-18 03:18:57 +00002103
Gregory Szorc52d26602012-03-21 07:28:27 +00002104/**
2105 * @}
2106 */
2107
2108/**
2109 * @defgroup LLVMCoreValueConstantGlobalAlias Global Aliases
2110 *
2111 * This group contains function that operate on global alias values.
2112 *
2113 * @see llvm::GlobalAlias
2114 *
2115 * @{
2116 */
Chris Lattner3d1f5522008-12-17 21:39:50 +00002117LLVMValueRef LLVMAddAlias(LLVMModuleRef M, LLVMTypeRef Ty, LLVMValueRef Aliasee,
2118 const char *Name);
2119
Gregory Szorc34c863a2012-03-21 03:54:29 +00002120/**
Robert Widmann360d6e32018-05-20 23:49:08 +00002121 * Obtain a GlobalAlias value from a Module by its name.
2122 *
2123 * The returned value corresponds to a llvm::GlobalAlias value.
2124 *
2125 * @see llvm::Module::getNamedAlias()
2126 */
2127LLVMValueRef LLVMGetNamedGlobalAlias(LLVMModuleRef M,
2128 const char *Name, size_t NameLen);
2129
2130/**
2131 * Obtain an iterator to the first GlobalAlias in a Module.
2132 *
2133 * @see llvm::Module::alias_begin()
2134 */
2135LLVMValueRef LLVMGetFirstGlobalAlias(LLVMModuleRef M);
2136
2137/**
2138 * Obtain an iterator to the last GlobalAlias in a Module.
2139 *
2140 * @see llvm::Module::alias_end()
2141 */
2142LLVMValueRef LLVMGetLastGlobalAlias(LLVMModuleRef M);
2143
2144/**
2145 * Advance a GlobalAlias iterator to the next GlobalAlias.
2146 *
2147 * Returns NULL if the iterator was already at the end and there are no more
2148 * global aliases.
2149 */
2150LLVMValueRef LLVMGetNextGlobalAlias(LLVMValueRef GA);
2151
2152/**
2153 * Decrement a GlobalAlias iterator to the previous GlobalAlias.
2154 *
2155 * Returns NULL if the iterator was already at the beginning and there are
2156 * no previous global aliases.
2157 */
2158LLVMValueRef LLVMGetPreviousGlobalAlias(LLVMValueRef GA);
2159
2160/**
2161 * Retrieve the target value of an alias.
2162 */
2163LLVMValueRef LLVMAliasGetAliasee(LLVMValueRef Alias);
2164
2165/**
2166 * Set the target value of an alias.
2167 */
2168void LLVMAliasSetAliasee(LLVMValueRef Alias, LLVMValueRef Aliasee);
2169
2170/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002171 * @}
2172 */
2173
2174/**
2175 * @defgroup LLVMCCoreValueFunction Function values
2176 *
2177 * Functions in this group operate on LLVMValueRef instances that
2178 * correspond to llvm::Function instances.
2179 *
2180 * @see llvm::Function
2181 *
2182 * @{
2183 */
2184
2185/**
2186 * Remove a function from its containing module and deletes it.
2187 *
2188 * @see llvm::Function::eraseFromParent()
2189 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002190void LLVMDeleteFunction(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002191
2192/**
Amaury Sechete39e8532016-02-18 20:38:32 +00002193 * Check whether the given function has a personality function.
2194 *
2195 * @see llvm::Function::hasPersonalityFn()
2196 */
2197LLVMBool LLVMHasPersonalityFn(LLVMValueRef Fn);
2198
2199/**
Andrew Wilkins3bdfc1c2015-07-14 01:23:06 +00002200 * Obtain the personality function attached to the function.
2201 *
2202 * @see llvm::Function::getPersonalityFn()
2203 */
2204LLVMValueRef LLVMGetPersonalityFn(LLVMValueRef Fn);
2205
2206/**
2207 * Set the personality function attached to the function.
2208 *
2209 * @see llvm::Function::setPersonalityFn()
2210 */
2211void LLVMSetPersonalityFn(LLVMValueRef Fn, LLVMValueRef PersonalityFn);
2212
2213/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002214 * Obtain the ID number from a function instance.
2215 *
2216 * @see llvm::Function::getIntrinsicID()
2217 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002218unsigned LLVMGetIntrinsicID(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002219
2220/**
2221 * Obtain the calling function of a function.
2222 *
2223 * The returned value corresponds to the LLVMCallConv enumeration.
2224 *
2225 * @see llvm::Function::getCallingConv()
2226 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002227unsigned LLVMGetFunctionCallConv(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002228
2229/**
2230 * Set the calling convention of a function.
2231 *
2232 * @see llvm::Function::setCallingConv()
2233 *
2234 * @param Fn Function to operate on
2235 * @param CC LLVMCallConv to set calling convention to
2236 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002237void LLVMSetFunctionCallConv(LLVMValueRef Fn, unsigned CC);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002238
2239/**
2240 * Obtain the name of the garbage collector to use during code
2241 * generation.
2242 *
2243 * @see llvm::Function::getGC()
2244 */
Gordon Henriksend930f912008-08-17 18:44:35 +00002245const char *LLVMGetGC(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002246
2247/**
2248 * Define the garbage collector to use during code generation.
2249 *
2250 * @see llvm::Function::setGC()
2251 */
Gordon Henriksend930f912008-08-17 18:44:35 +00002252void LLVMSetGC(LLVMValueRef Fn, const char *Name);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002253
2254/**
2255 * Add an attribute to a function.
2256 *
2257 * @see llvm::Function::addAttribute()
2258 */
Amaury Sechet5db224e2016-06-12 06:17:24 +00002259void LLVMAddAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx,
2260 LLVMAttributeRef A);
Amaury Sechet17b67cd2016-07-21 04:25:06 +00002261unsigned LLVMGetAttributeCountAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx);
2262void LLVMGetAttributesAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx,
2263 LLVMAttributeRef *Attrs);
Amaury Sechet5db224e2016-06-12 06:17:24 +00002264LLVMAttributeRef LLVMGetEnumAttributeAtIndex(LLVMValueRef F,
2265 LLVMAttributeIndex Idx,
2266 unsigned KindID);
Amaury Sechet6100adf2016-06-15 17:50:39 +00002267LLVMAttributeRef LLVMGetStringAttributeAtIndex(LLVMValueRef F,
2268 LLVMAttributeIndex Idx,
2269 const char *K, unsigned KLen);
Amaury Sechet5db224e2016-06-12 06:17:24 +00002270void LLVMRemoveEnumAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx,
2271 unsigned KindID);
Amaury Sechet6100adf2016-06-15 17:50:39 +00002272void LLVMRemoveStringAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx,
2273 const char *K, unsigned KLen);
Amaury Sechet5db224e2016-06-12 06:17:24 +00002274
Gregory Szorc34c863a2012-03-21 03:54:29 +00002275/**
Nick Lewyckyc3890d22015-07-29 22:32:47 +00002276 * Add a target-dependent attribute to a function
Tom Stellarde8f35e12013-04-16 23:12:43 +00002277 * @see llvm::AttrBuilder::addAttribute()
2278 */
2279void LLVMAddTargetDependentFunctionAttr(LLVMValueRef Fn, const char *A,
2280 const char *V);
2281
2282/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002283 * @defgroup LLVMCCoreValueFunctionParameters Function Parameters
2284 *
2285 * Functions in this group relate to arguments/parameters on functions.
2286 *
2287 * Functions in this group expect LLVMValueRef instances that correspond
2288 * to llvm::Function instances.
2289 *
2290 * @{
2291 */
2292
2293/**
2294 * Obtain the number of parameters in a function.
2295 *
2296 * @see llvm::Function::arg_size()
2297 */
Gordon Henriksen265f7802008-03-19 01:11:35 +00002298unsigned LLVMCountParams(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002299
2300/**
2301 * Obtain the parameters in a function.
2302 *
2303 * The takes a pointer to a pre-allocated array of LLVMValueRef that is
2304 * at least LLVMCountParams() long. This array will be filled with
2305 * LLVMValueRef instances which correspond to the parameters the
2306 * function receives. Each LLVMValueRef corresponds to a llvm::Argument
2307 * instance.
2308 *
2309 * @see llvm::Function::arg_begin()
2310 */
Gordon Henriksen265f7802008-03-19 01:11:35 +00002311void LLVMGetParams(LLVMValueRef Fn, LLVMValueRef *Params);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002312
2313/**
2314 * Obtain the parameter at the specified index.
2315 *
2316 * Parameters are indexed from 0.
2317 *
2318 * @see llvm::Function::arg_begin()
2319 */
Gordon Henriksen265f7802008-03-19 01:11:35 +00002320LLVMValueRef LLVMGetParam(LLVMValueRef Fn, unsigned Index);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002321
2322/**
2323 * Obtain the function to which this argument belongs.
2324 *
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00002325 * Unlike other functions in this group, this one takes an LLVMValueRef
Gregory Szorc34c863a2012-03-21 03:54:29 +00002326 * that corresponds to a llvm::Attribute.
2327 *
2328 * The returned LLVMValueRef is the llvm::Function to which this
2329 * argument belongs.
2330 */
Gordon Henriksen265f7802008-03-19 01:11:35 +00002331LLVMValueRef LLVMGetParamParent(LLVMValueRef Inst);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002332
2333/**
2334 * Obtain the first parameter to a function.
2335 *
2336 * @see llvm::Function::arg_begin()
2337 */
Gordon Henriksen07a45f42008-03-23 22:21:29 +00002338LLVMValueRef LLVMGetFirstParam(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002339
2340/**
2341 * Obtain the last parameter to a function.
2342 *
2343 * @see llvm::Function::arg_end()
2344 */
Gordon Henriksen07a45f42008-03-23 22:21:29 +00002345LLVMValueRef LLVMGetLastParam(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002346
2347/**
2348 * Obtain the next parameter to a function.
2349 *
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00002350 * This takes an LLVMValueRef obtained from LLVMGetFirstParam() (which is
Gregory Szorc34c863a2012-03-21 03:54:29 +00002351 * actually a wrapped iterator) and obtains the next parameter from the
2352 * underlying iterator.
2353 */
Gordon Henriksen07a45f42008-03-23 22:21:29 +00002354LLVMValueRef LLVMGetNextParam(LLVMValueRef Arg);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002355
2356/**
2357 * Obtain the previous parameter to a function.
2358 *
2359 * This is the opposite of LLVMGetNextParam().
2360 */
Gordon Henriksen07a45f42008-03-23 22:21:29 +00002361LLVMValueRef LLVMGetPreviousParam(LLVMValueRef Arg);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002362
2363/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002364 * Set the alignment for a function parameter.
2365 *
2366 * @see llvm::Argument::addAttr()
Bill Wendling50d27842012-10-15 20:35:56 +00002367 * @see llvm::AttrBuilder::addAlignmentAttr()
Gregory Szorc34c863a2012-03-21 03:54:29 +00002368 */
Amaury Sechet81243a72016-05-01 01:42:34 +00002369void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned Align);
Gordon Henriksen265f7802008-03-19 01:11:35 +00002370
Gregory Szorc34c863a2012-03-21 03:54:29 +00002371/**
2372 * @}
2373 */
2374
2375/**
2376 * @}
2377 */
2378
2379/**
Gregory Szorc52d26602012-03-21 07:28:27 +00002380 * @}
2381 */
2382
2383/**
2384 * @}
2385 */
2386
2387/**
2388 * @defgroup LLVMCCoreValueMetadata Metadata
2389 *
2390 * @{
2391 */
2392
2393/**
2394 * Obtain a MDString value from a context.
2395 *
2396 * The returned instance corresponds to the llvm::MDString class.
2397 *
2398 * The instance is specified by string data of a specified length. The
2399 * string content is copied, so the backing memory can be freed after
2400 * this function returns.
2401 */
2402LLVMValueRef LLVMMDStringInContext(LLVMContextRef C, const char *Str,
2403 unsigned SLen);
2404
2405/**
2406 * Obtain a MDString value from the global context.
2407 */
2408LLVMValueRef LLVMMDString(const char *Str, unsigned SLen);
2409
2410/**
2411 * Obtain a MDNode value from a context.
2412 *
2413 * The returned value corresponds to the llvm::MDNode class.
2414 */
2415LLVMValueRef LLVMMDNodeInContext(LLVMContextRef C, LLVMValueRef *Vals,
2416 unsigned Count);
2417
2418/**
2419 * Obtain a MDNode value from the global context.
2420 */
2421LLVMValueRef LLVMMDNode(LLVMValueRef *Vals, unsigned Count);
2422
2423/**
Amaury Sechetf8429752017-04-17 11:52:54 +00002424 * Obtain a Metadata as a Value.
2425 */
2426LLVMValueRef LLVMMetadataAsValue(LLVMContextRef C, LLVMMetadataRef MD);
2427
2428/**
2429 * Obtain a Value as a Metadata.
2430 */
2431LLVMMetadataRef LLVMValueAsMetadata(LLVMValueRef Val);
2432
2433/**
Gregory Szorc52d26602012-03-21 07:28:27 +00002434 * Obtain the underlying string from a MDString value.
2435 *
2436 * @param V Instance to obtain string from.
NAKAMURA Takumie4a77052016-04-04 11:54:48 +00002437 * @param Length Memory address which will hold length of returned string.
Gregory Szorc52d26602012-03-21 07:28:27 +00002438 * @return String data in MDString.
2439 */
Amaury Sechet7c2883c2016-04-03 21:06:04 +00002440const char *LLVMGetMDString(LLVMValueRef V, unsigned *Length);
Gregory Szorc52d26602012-03-21 07:28:27 +00002441
2442/**
Duncan Sands12ccbe72012-09-19 20:29:39 +00002443 * Obtain the number of operands from an MDNode value.
2444 *
2445 * @param V MDNode to get number of operands from.
2446 * @return Number of operands of the MDNode.
2447 */
2448unsigned LLVMGetMDNodeNumOperands(LLVMValueRef V);
2449
2450/**
2451 * Obtain the given MDNode's operands.
2452 *
2453 * The passed LLVMValueRef pointer should point to enough memory to hold all of
2454 * the operands of the given MDNode (see LLVMGetMDNodeNumOperands) as
2455 * LLVMValueRefs. This memory will be populated with the LLVMValueRefs of the
2456 * MDNode's operands.
2457 *
2458 * @param V MDNode to get the operands from.
2459 * @param Dest Destination array for operands.
2460 */
2461void LLVMGetMDNodeOperands(LLVMValueRef V, LLVMValueRef *Dest);
2462
2463/**
Gregory Szorc52d26602012-03-21 07:28:27 +00002464 * @}
2465 */
2466
2467/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002468 * @defgroup LLVMCCoreValueBasicBlock Basic Block
2469 *
2470 * A basic block represents a single entry single exit section of code.
2471 * Basic blocks contain a list of instructions which form the body of
2472 * the block.
2473 *
2474 * Basic blocks belong to functions. They have the type of label.
2475 *
2476 * Basic blocks are themselves values. However, the C API models them as
2477 * LLVMBasicBlockRef.
2478 *
2479 * @see llvm::BasicBlock
2480 *
2481 * @{
2482 */
2483
2484/**
2485 * Convert a basic block instance to a value type.
2486 */
Gordon Henriksen07a45f42008-03-23 22:21:29 +00002487LLVMValueRef LLVMBasicBlockAsValue(LLVMBasicBlockRef BB);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002488
2489/**
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00002490 * Determine whether an LLVMValueRef is itself a basic block.
Gregory Szorc34c863a2012-03-21 03:54:29 +00002491 */
Chris Lattner25963c62010-01-09 22:27:07 +00002492LLVMBool LLVMValueIsBasicBlock(LLVMValueRef Val);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002493
2494/**
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00002495 * Convert an LLVMValueRef to an LLVMBasicBlockRef instance.
Gregory Szorc34c863a2012-03-21 03:54:29 +00002496 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002497LLVMBasicBlockRef LLVMValueAsBasicBlock(LLVMValueRef Val);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002498
2499/**
Amaury Secheta82042e2016-02-09 22:36:41 +00002500 * Obtain the string name of a basic block.
2501 */
2502const char *LLVMGetBasicBlockName(LLVMBasicBlockRef BB);
2503
2504/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002505 * Obtain the function to which a basic block belongs.
2506 *
2507 * @see llvm::BasicBlock::getParent()
2508 */
Gordon Henriksen07a45f42008-03-23 22:21:29 +00002509LLVMValueRef LLVMGetBasicBlockParent(LLVMBasicBlockRef BB);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002510
2511/**
2512 * Obtain the terminator instruction for a basic block.
2513 *
2514 * If the basic block does not have a terminator (it is not well-formed
2515 * if it doesn't), then NULL is returned.
2516 *
2517 * The returned LLVMValueRef corresponds to a llvm::TerminatorInst.
2518 *
2519 * @see llvm::BasicBlock::getTerminator()
2520 */
Nate Begeman43c322b2011-08-23 20:27:46 +00002521LLVMValueRef LLVMGetBasicBlockTerminator(LLVMBasicBlockRef BB);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002522
2523/**
2524 * Obtain the number of basic blocks in a function.
2525 *
2526 * @param Fn Function value to operate on.
2527 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002528unsigned LLVMCountBasicBlocks(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002529
2530/**
2531 * Obtain all of the basic blocks in a function.
2532 *
2533 * This operates on a function value. The BasicBlocks parameter is a
2534 * pointer to a pre-allocated array of LLVMBasicBlockRef of at least
2535 * LLVMCountBasicBlocks() in length. This array is populated with
2536 * LLVMBasicBlockRef instances.
2537 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002538void LLVMGetBasicBlocks(LLVMValueRef Fn, LLVMBasicBlockRef *BasicBlocks);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002539
2540/**
2541 * Obtain the first basic block in a function.
2542 *
2543 * The returned basic block can be used as an iterator. You will likely
2544 * eventually call into LLVMGetNextBasicBlock() with it.
2545 *
2546 * @see llvm::Function::begin()
2547 */
Gordon Henriksen054817c2008-03-19 03:47:18 +00002548LLVMBasicBlockRef LLVMGetFirstBasicBlock(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002549
2550/**
2551 * Obtain the last basic block in a function.
2552 *
2553 * @see llvm::Function::end()
2554 */
Gordon Henriksen054817c2008-03-19 03:47:18 +00002555LLVMBasicBlockRef LLVMGetLastBasicBlock(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002556
2557/**
2558 * Advance a basic block iterator.
2559 */
Gordon Henriksen054817c2008-03-19 03:47:18 +00002560LLVMBasicBlockRef LLVMGetNextBasicBlock(LLVMBasicBlockRef BB);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002561
2562/**
2563 * Go backwards in a basic block iterator.
2564 */
Gordon Henriksen054817c2008-03-19 03:47:18 +00002565LLVMBasicBlockRef LLVMGetPreviousBasicBlock(LLVMBasicBlockRef BB);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002566
2567/**
2568 * Obtain the basic block that corresponds to the entry point of a
2569 * function.
2570 *
2571 * @see llvm::Function::getEntryBlock()
2572 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002573LLVMBasicBlockRef LLVMGetEntryBasicBlock(LLVMValueRef Fn);
Erick Tryzelaar262332f2009-08-14 00:01:31 +00002574
Gregory Szorc34c863a2012-03-21 03:54:29 +00002575/**
2576 * Append a basic block to the end of a function.
2577 *
2578 * @see llvm::BasicBlock::Create()
2579 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +00002580LLVMBasicBlockRef LLVMAppendBasicBlockInContext(LLVMContextRef C,
2581 LLVMValueRef Fn,
2582 const char *Name);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002583
2584/**
2585 * Append a basic block to the end of a function using the global
2586 * context.
2587 *
2588 * @see llvm::BasicBlock::Create()
2589 */
2590LLVMBasicBlockRef LLVMAppendBasicBlock(LLVMValueRef Fn, const char *Name);
2591
2592/**
2593 * Insert a basic block in a function before another basic block.
2594 *
2595 * The function to add to is determined by the function of the
2596 * passed basic block.
2597 *
2598 * @see llvm::BasicBlock::Create()
2599 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +00002600LLVMBasicBlockRef LLVMInsertBasicBlockInContext(LLVMContextRef C,
2601 LLVMBasicBlockRef BB,
2602 const char *Name);
2603
Gregory Szorc34c863a2012-03-21 03:54:29 +00002604/**
2605 * Insert a basic block in a function using the global context.
2606 *
2607 * @see llvm::BasicBlock::Create()
2608 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002609LLVMBasicBlockRef LLVMInsertBasicBlock(LLVMBasicBlockRef InsertBeforeBB,
2610 const char *Name);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002611
2612/**
2613 * Remove a basic block from a function and delete it.
2614 *
2615 * This deletes the basic block from its containing function and deletes
2616 * the basic block itself.
2617 *
2618 * @see llvm::BasicBlock::eraseFromParent()
2619 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002620void LLVMDeleteBasicBlock(LLVMBasicBlockRef BB);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002621
2622/**
2623 * Remove a basic block from a function.
2624 *
2625 * This deletes the basic block from its containing function but keep
2626 * the basic block alive.
2627 *
2628 * @see llvm::BasicBlock::removeFromParent()
2629 */
Nate Begeman43c322b2011-08-23 20:27:46 +00002630void LLVMRemoveBasicBlockFromParent(LLVMBasicBlockRef BB);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002631
Gregory Szorc34c863a2012-03-21 03:54:29 +00002632/**
2633 * Move a basic block to before another one.
2634 *
2635 * @see llvm::BasicBlock::moveBefore()
2636 */
Duncan Sandsb1d61aa2010-07-19 15:31:07 +00002637void LLVMMoveBasicBlockBefore(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002638
2639/**
2640 * Move a basic block to after another one.
2641 *
2642 * @see llvm::BasicBlock::moveAfter()
2643 */
Duncan Sandsb1d61aa2010-07-19 15:31:07 +00002644void LLVMMoveBasicBlockAfter(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos);
2645
Gregory Szorc34c863a2012-03-21 03:54:29 +00002646/**
2647 * Obtain the first instruction in a basic block.
2648 *
2649 * The returned LLVMValueRef corresponds to a llvm::Instruction
2650 * instance.
2651 */
Gordon Henriksen054817c2008-03-19 03:47:18 +00002652LLVMValueRef LLVMGetFirstInstruction(LLVMBasicBlockRef BB);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002653
2654/**
2655 * Obtain the last instruction in a basic block.
2656 *
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00002657 * The returned LLVMValueRef corresponds to an LLVM:Instruction.
Gregory Szorc34c863a2012-03-21 03:54:29 +00002658 */
Gordon Henriksen054817c2008-03-19 03:47:18 +00002659LLVMValueRef LLVMGetLastInstruction(LLVMBasicBlockRef BB);
Nate Begeman43c322b2011-08-23 20:27:46 +00002660
Gregory Szorc34c863a2012-03-21 03:54:29 +00002661/**
2662 * @}
2663 */
2664
2665/**
2666 * @defgroup LLVMCCoreValueInstruction Instructions
2667 *
2668 * Functions in this group relate to the inspection and manipulation of
2669 * individual instructions.
2670 *
2671 * In the C++ API, an instruction is modeled by llvm::Instruction. This
2672 * class has a large number of descendents. llvm::Instruction is a
2673 * llvm::Value and in the C API, instructions are modeled by
2674 * LLVMValueRef.
2675 *
2676 * This group also contains sub-groups which operate on specific
2677 * llvm::Instruction types, e.g. llvm::CallInst.
2678 *
2679 * @{
2680 */
2681
2682/**
2683 * Determine whether an instruction has any metadata attached.
2684 */
2685int LLVMHasMetadata(LLVMValueRef Val);
2686
2687/**
2688 * Return metadata associated with an instruction value.
2689 */
2690LLVMValueRef LLVMGetMetadata(LLVMValueRef Val, unsigned KindID);
2691
2692/**
2693 * Set metadata associated with an instruction value.
2694 */
2695void LLVMSetMetadata(LLVMValueRef Val, unsigned KindID, LLVMValueRef Node);
2696
2697/**
2698 * Obtain the basic block to which an instruction belongs.
2699 *
2700 * @see llvm::Instruction::getParent()
2701 */
Nate Begeman43c322b2011-08-23 20:27:46 +00002702LLVMBasicBlockRef LLVMGetInstructionParent(LLVMValueRef Inst);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002703
2704/**
2705 * Obtain the instruction that occurs after the one specified.
2706 *
2707 * The next instruction will be from the same basic block.
2708 *
2709 * If this is the last instruction in a basic block, NULL will be
2710 * returned.
2711 */
Gordon Henriksen054817c2008-03-19 03:47:18 +00002712LLVMValueRef LLVMGetNextInstruction(LLVMValueRef Inst);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002713
2714/**
Benjamin Kramerbde91762012-06-02 10:20:22 +00002715 * Obtain the instruction that occurred before this one.
Gregory Szorc34c863a2012-03-21 03:54:29 +00002716 *
2717 * If the instruction is the first instruction in a basic block, NULL
2718 * will be returned.
2719 */
Gordon Henriksen054817c2008-03-19 03:47:18 +00002720LLVMValueRef LLVMGetPreviousInstruction(LLVMValueRef Inst);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002721
2722/**
2723 * Remove and delete an instruction.
2724 *
2725 * The instruction specified is removed from its containing building
Amaury Sechet2f432082016-02-11 21:37:54 +00002726 * block but is kept alive.
2727 *
2728 * @see llvm::Instruction::removeFromParent()
2729 */
2730void LLVMInstructionRemoveFromParent(LLVMValueRef Inst);
2731
2732/**
2733 * Remove and delete an instruction.
2734 *
2735 * The instruction specified is removed from its containing building
Gregory Szorc34c863a2012-03-21 03:54:29 +00002736 * block and then deleted.
2737 *
2738 * @see llvm::Instruction::eraseFromParent()
2739 */
Devang Pateldbebc6f2011-10-03 20:59:18 +00002740void LLVMInstructionEraseFromParent(LLVMValueRef Inst);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002741
2742/**
2743 * Obtain the code opcode for an individual instruction.
2744 *
2745 * @see llvm::Instruction::getOpCode()
2746 */
Eric Christophera6b96002015-12-18 01:46:52 +00002747LLVMOpcode LLVMGetInstructionOpcode(LLVMValueRef Inst);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002748
2749/**
2750 * Obtain the predicate of an instruction.
2751 *
2752 * This is only valid for instructions that correspond to llvm::ICmpInst
2753 * or llvm::ConstantExpr whose opcode is llvm::Instruction::ICmp.
2754 *
2755 * @see llvm::ICmpInst::getPredicate()
2756 */
Torok Edwin60c40de2011-10-06 12:13:20 +00002757LLVMIntPredicate LLVMGetICmpPredicate(LLVMValueRef Inst);
Gordon Henriksen265f7802008-03-19 01:11:35 +00002758
Gregory Szorc34c863a2012-03-21 03:54:29 +00002759/**
Peter Zotov1d98e6d2014-10-28 19:46:44 +00002760 * Obtain the float predicate of an instruction.
2761 *
2762 * This is only valid for instructions that correspond to llvm::FCmpInst
2763 * or llvm::ConstantExpr whose opcode is llvm::Instruction::FCmp.
2764 *
2765 * @see llvm::FCmpInst::getPredicate()
2766 */
2767LLVMRealPredicate LLVMGetFCmpPredicate(LLVMValueRef Inst);
2768
2769/**
Peter Zotovaff492c2014-10-17 01:02:34 +00002770 * Create a copy of 'this' instruction that is identical in all ways
2771 * except the following:
2772 * * The instruction has no parent
2773 * * The instruction has no name
2774 *
2775 * @see llvm::Instruction::clone()
2776 */
2777LLVMValueRef LLVMInstructionClone(LLVMValueRef Inst);
2778
2779/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002780 * @defgroup LLVMCCoreValueInstructionCall Call Sites and Invocations
2781 *
2782 * Functions in this group apply to instructions that refer to call
2783 * sites and invocations. These correspond to C++ types in the
2784 * llvm::CallInst class tree.
2785 *
2786 * @{
2787 */
2788
2789/**
Amaury Sechet5c7b3af2016-02-10 00:09:37 +00002790 * Obtain the argument count for a call instruction.
2791 *
Robert Widmann478fce92018-03-30 17:49:53 +00002792 * This expects an LLVMValueRef that corresponds to a llvm::CallInst,
2793 * llvm::InvokeInst, or llvm:FuncletPadInst.
Amaury Sechet5c7b3af2016-02-10 00:09:37 +00002794 *
2795 * @see llvm::CallInst::getNumArgOperands()
2796 * @see llvm::InvokeInst::getNumArgOperands()
Robert Widmann478fce92018-03-30 17:49:53 +00002797 * @see llvm::FuncletPadInst::getNumArgOperands()
Amaury Sechet5c7b3af2016-02-10 00:09:37 +00002798 */
2799unsigned LLVMGetNumArgOperands(LLVMValueRef Instr);
2800
2801/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002802 * Set the calling convention for a call instruction.
2803 *
2804 * This expects an LLVMValueRef that corresponds to a llvm::CallInst or
2805 * llvm::InvokeInst.
2806 *
2807 * @see llvm::CallInst::setCallingConv()
2808 * @see llvm::InvokeInst::setCallingConv()
2809 */
Gordon Henriksen1158c532007-12-29 20:45:00 +00002810void LLVMSetInstructionCallConv(LLVMValueRef Instr, unsigned CC);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002811
2812/**
2813 * Obtain the calling convention for a call instruction.
2814 *
2815 * This is the opposite of LLVMSetInstructionCallConv(). Reads its
2816 * usage.
2817 *
2818 * @see LLVMSetInstructionCallConv()
2819 */
Gordon Henriksen1158c532007-12-29 20:45:00 +00002820unsigned LLVMGetInstructionCallConv(LLVMValueRef Instr);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002821
Gregory Szorc34c863a2012-03-21 03:54:29 +00002822void LLVMSetInstrParamAlignment(LLVMValueRef Instr, unsigned index,
Amaury Sechet81243a72016-05-01 01:42:34 +00002823 unsigned Align);
Gordon Henriksen1158c532007-12-29 20:45:00 +00002824
Amaury Secheta65a2372016-06-15 05:14:29 +00002825void LLVMAddCallSiteAttribute(LLVMValueRef C, LLVMAttributeIndex Idx,
2826 LLVMAttributeRef A);
Amaury Sechet17b67cd2016-07-21 04:25:06 +00002827unsigned LLVMGetCallSiteAttributeCount(LLVMValueRef C, LLVMAttributeIndex Idx);
2828void LLVMGetCallSiteAttributes(LLVMValueRef C, LLVMAttributeIndex Idx,
2829 LLVMAttributeRef *Attrs);
Amaury Secheta65a2372016-06-15 05:14:29 +00002830LLVMAttributeRef LLVMGetCallSiteEnumAttribute(LLVMValueRef C,
2831 LLVMAttributeIndex Idx,
2832 unsigned KindID);
Amaury Sechet6100adf2016-06-15 17:50:39 +00002833LLVMAttributeRef LLVMGetCallSiteStringAttribute(LLVMValueRef C,
2834 LLVMAttributeIndex Idx,
2835 const char *K, unsigned KLen);
Amaury Secheta65a2372016-06-15 05:14:29 +00002836void LLVMRemoveCallSiteEnumAttribute(LLVMValueRef C, LLVMAttributeIndex Idx,
2837 unsigned KindID);
Amaury Sechet6100adf2016-06-15 17:50:39 +00002838void LLVMRemoveCallSiteStringAttribute(LLVMValueRef C, LLVMAttributeIndex Idx,
2839 const char *K, unsigned KLen);
Amaury Secheta65a2372016-06-15 05:14:29 +00002840
Gregory Szorc34c863a2012-03-21 03:54:29 +00002841/**
Amaury Sechet5c7b3af2016-02-10 00:09:37 +00002842 * Obtain the pointer to the function invoked by this instruction.
2843 *
2844 * This expects an LLVMValueRef that corresponds to a llvm::CallInst or
2845 * llvm::InvokeInst.
2846 *
2847 * @see llvm::CallInst::getCalledValue()
2848 * @see llvm::InvokeInst::getCalledValue()
2849 */
2850LLVMValueRef LLVMGetCalledValue(LLVMValueRef Instr);
2851
2852/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002853 * Obtain whether a call instruction is a tail call.
2854 *
2855 * This only works on llvm::CallInst instructions.
2856 *
2857 * @see llvm::CallInst::isTailCall()
2858 */
Chris Lattner25963c62010-01-09 22:27:07 +00002859LLVMBool LLVMIsTailCall(LLVMValueRef CallInst);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002860
2861/**
2862 * Set whether a call instruction is a tail call.
2863 *
2864 * This only works on llvm::CallInst instructions.
2865 *
2866 * @see llvm::CallInst::setTailCall()
2867 */
Chris Lattner25963c62010-01-09 22:27:07 +00002868void LLVMSetTailCall(LLVMValueRef CallInst, LLVMBool IsTailCall);
Gordon Henrikseneeb65372008-08-30 16:34:54 +00002869
Gregory Szorc34c863a2012-03-21 03:54:29 +00002870/**
Amaury Sechete39e8532016-02-18 20:38:32 +00002871 * Return the normal destination basic block.
2872 *
2873 * This only works on llvm::InvokeInst instructions.
2874 *
2875 * @see llvm::InvokeInst::getNormalDest()
2876 */
2877LLVMBasicBlockRef LLVMGetNormalDest(LLVMValueRef InvokeInst);
2878
2879/**
2880 * Return the unwind destination basic block.
2881 *
Robert Widmann478fce92018-03-30 17:49:53 +00002882 * Works on llvm::InvokeInst, llvm::CleanupReturnInst, and
2883 * llvm::CatchSwitchInst instructions.
Amaury Sechete39e8532016-02-18 20:38:32 +00002884 *
2885 * @see llvm::InvokeInst::getUnwindDest()
Robert Widmann478fce92018-03-30 17:49:53 +00002886 * @see llvm::CleanupReturnInst::getUnwindDest()
2887 * @see llvm::CatchSwitchInst::getUnwindDest()
Amaury Sechete39e8532016-02-18 20:38:32 +00002888 */
2889LLVMBasicBlockRef LLVMGetUnwindDest(LLVMValueRef InvokeInst);
2890
2891/**
2892 * Set the normal destination basic block.
2893 *
2894 * This only works on llvm::InvokeInst instructions.
2895 *
2896 * @see llvm::InvokeInst::setNormalDest()
2897 */
2898void LLVMSetNormalDest(LLVMValueRef InvokeInst, LLVMBasicBlockRef B);
2899
2900/**
2901 * Set the unwind destination basic block.
2902 *
Robert Widmann478fce92018-03-30 17:49:53 +00002903 * Works on llvm::InvokeInst, llvm::CleanupReturnInst, and
2904 * llvm::CatchSwitchInst instructions.
Amaury Sechete39e8532016-02-18 20:38:32 +00002905 *
2906 * @see llvm::InvokeInst::setUnwindDest()
Robert Widmann478fce92018-03-30 17:49:53 +00002907 * @see llvm::CleanupReturnInst::setUnwindDest()
2908 * @see llvm::CatchSwitchInst::setUnwindDest()
Amaury Sechete39e8532016-02-18 20:38:32 +00002909 */
2910void LLVMSetUnwindDest(LLVMValueRef InvokeInst, LLVMBasicBlockRef B);
2911
2912/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002913 * @}
2914 */
2915
2916/**
Peter Zotov2481c752014-10-28 19:46:56 +00002917 * @defgroup LLVMCCoreValueInstructionTerminator Terminators
2918 *
2919 * Functions in this group only apply to instructions that map to
2920 * llvm::TerminatorInst instances.
2921 *
2922 * @{
2923 */
2924
2925/**
2926 * Return the number of successors that this terminator has.
2927 *
2928 * @see llvm::TerminatorInst::getNumSuccessors
2929 */
2930unsigned LLVMGetNumSuccessors(LLVMValueRef Term);
2931
2932/**
2933 * Return the specified successor.
2934 *
2935 * @see llvm::TerminatorInst::getSuccessor
2936 */
2937LLVMBasicBlockRef LLVMGetSuccessor(LLVMValueRef Term, unsigned i);
2938
2939/**
2940 * Update the specified successor to point at the provided block.
2941 *
2942 * @see llvm::TerminatorInst::setSuccessor
2943 */
2944void LLVMSetSuccessor(LLVMValueRef Term, unsigned i, LLVMBasicBlockRef block);
2945
2946/**
2947 * Return if a branch is conditional.
2948 *
2949 * This only works on llvm::BranchInst instructions.
2950 *
2951 * @see llvm::BranchInst::isConditional
2952 */
2953LLVMBool LLVMIsConditional(LLVMValueRef Branch);
2954
2955/**
2956 * Return the condition of a branch instruction.
2957 *
2958 * This only works on llvm::BranchInst instructions.
2959 *
2960 * @see llvm::BranchInst::getCondition
2961 */
2962LLVMValueRef LLVMGetCondition(LLVMValueRef Branch);
2963
2964/**
2965 * Set the condition of a branch instruction.
2966 *
2967 * This only works on llvm::BranchInst instructions.
2968 *
2969 * @see llvm::BranchInst::setCondition
2970 */
2971void LLVMSetCondition(LLVMValueRef Branch, LLVMValueRef Cond);
2972
2973/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002974 * Obtain the default destination basic block of a switch instruction.
2975 *
2976 * This only works on llvm::SwitchInst instructions.
2977 *
2978 * @see llvm::SwitchInst::getDefaultDest()
2979 */
Nate Begeman43c322b2011-08-23 20:27:46 +00002980LLVMBasicBlockRef LLVMGetSwitchDefaultDest(LLVMValueRef SwitchInstr);
2981
Gregory Szorc34c863a2012-03-21 03:54:29 +00002982/**
Peter Zotov2481c752014-10-28 19:46:56 +00002983 * @}
2984 */
2985
2986/**
Amaury Sechet1dcf5772016-02-09 22:50:53 +00002987 * @defgroup LLVMCCoreValueInstructionAlloca Allocas
2988 *
2989 * Functions in this group only apply to instructions that map to
2990 * llvm::AllocaInst instances.
2991 *
2992 * @{
2993 */
2994
2995/**
2996 * Obtain the type that is being allocated by the alloca instruction.
2997 */
2998LLVMTypeRef LLVMGetAllocatedType(LLVMValueRef Alloca);
2999
3000/**
3001 * @}
3002 */
3003
3004/**
Amaury Sechet053ac452016-02-17 22:51:03 +00003005 * @defgroup LLVMCCoreValueInstructionGetElementPointer GEPs
3006 *
3007 * Functions in this group only apply to instructions that map to
3008 * llvm::GetElementPtrInst instances.
3009 *
3010 * @{
3011 */
3012
3013/**
3014 * Check whether the given GEP instruction is inbounds.
3015 */
3016LLVMBool LLVMIsInBounds(LLVMValueRef GEP);
3017
3018/**
3019 * Set the given GEP instruction to be inbounds or not.
3020 */
Amaury Sechet8a367d42016-05-01 02:23:14 +00003021void LLVMSetIsInBounds(LLVMValueRef GEP, LLVMBool InBounds);
Amaury Sechet053ac452016-02-17 22:51:03 +00003022
3023/**
3024 * @}
3025 */
3026
3027/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00003028 * @defgroup LLVMCCoreValueInstructionPHINode PHI Nodes
3029 *
3030 * Functions in this group only apply to instructions that map to
3031 * llvm::PHINode instances.
3032 *
3033 * @{
3034 */
3035
3036/**
3037 * Add an incoming value to the end of a PHI list.
3038 */
Gordon Henriksen44dd8fb2007-10-08 18:14:39 +00003039void LLVMAddIncoming(LLVMValueRef PhiNode, LLVMValueRef *IncomingValues,
3040 LLVMBasicBlockRef *IncomingBlocks, unsigned Count);
Gregory Szorc34c863a2012-03-21 03:54:29 +00003041
3042/**
3043 * Obtain the number of incoming basic blocks to a PHI node.
3044 */
Gordon Henriksen44dd8fb2007-10-08 18:14:39 +00003045unsigned LLVMCountIncoming(LLVMValueRef PhiNode);
Gregory Szorc34c863a2012-03-21 03:54:29 +00003046
3047/**
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00003048 * Obtain an incoming value to a PHI node as an LLVMValueRef.
Gregory Szorc34c863a2012-03-21 03:54:29 +00003049 */
Gordon Henriksen44dd8fb2007-10-08 18:14:39 +00003050LLVMValueRef LLVMGetIncomingValue(LLVMValueRef PhiNode, unsigned Index);
Gregory Szorc34c863a2012-03-21 03:54:29 +00003051
3052/**
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00003053 * Obtain an incoming value to a PHI node as an LLVMBasicBlockRef.
Gregory Szorc34c863a2012-03-21 03:54:29 +00003054 */
Gordon Henriksen44dd8fb2007-10-08 18:14:39 +00003055LLVMBasicBlockRef LLVMGetIncomingBlock(LLVMValueRef PhiNode, unsigned Index);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00003056
Gregory Szorc34c863a2012-03-21 03:54:29 +00003057/**
3058 * @}
3059 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00003060
Gregory Szorc34c863a2012-03-21 03:54:29 +00003061/**
Amaury Sechetaad93532016-02-10 00:38:50 +00003062 * @defgroup LLVMCCoreValueInstructionExtractValue ExtractValue
3063 * @defgroup LLVMCCoreValueInstructionInsertValue InsertValue
3064 *
3065 * Functions in this group only apply to instructions that map to
3066 * llvm::ExtractValue and llvm::InsertValue instances.
3067 *
3068 * @{
3069 */
3070
3071/**
3072 * Obtain the number of indices.
Amaury Sechet053ac452016-02-17 22:51:03 +00003073 * NB: This also works on GEP.
Amaury Sechetaad93532016-02-10 00:38:50 +00003074 */
3075unsigned LLVMGetNumIndices(LLVMValueRef Inst);
3076
3077/**
3078 * Obtain the indices as an array.
3079 */
3080const unsigned *LLVMGetIndices(LLVMValueRef Inst);
3081
3082/**
3083 * @}
3084 */
3085
3086/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00003087 * @}
3088 */
3089
3090/**
3091 * @}
3092 */
3093
3094/**
3095 * @defgroup LLVMCCoreInstructionBuilder Instruction Builders
3096 *
3097 * An instruction builder represents a point within a basic block and is
3098 * the exclusive means of building instructions using the C interface.
3099 *
3100 * @{
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00003101 */
3102
Erick Tryzelaar262332f2009-08-14 00:01:31 +00003103LLVMBuilderRef LLVMCreateBuilderInContext(LLVMContextRef C);
Gordon Henriksena735a9c2008-05-04 12:55:34 +00003104LLVMBuilderRef LLVMCreateBuilder(void);
Gordon Henriksen054817c2008-03-19 03:47:18 +00003105void LLVMPositionBuilder(LLVMBuilderRef Builder, LLVMBasicBlockRef Block,
3106 LLVMValueRef Instr);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00003107void LLVMPositionBuilderBefore(LLVMBuilderRef Builder, LLVMValueRef Instr);
3108void LLVMPositionBuilderAtEnd(LLVMBuilderRef Builder, LLVMBasicBlockRef Block);
Gordon Henriksen265f7802008-03-19 01:11:35 +00003109LLVMBasicBlockRef LLVMGetInsertBlock(LLVMBuilderRef Builder);
Chris Lattner3d1f5522008-12-17 21:39:50 +00003110void LLVMClearInsertionPosition(LLVMBuilderRef Builder);
3111void LLVMInsertIntoBuilder(LLVMBuilderRef Builder, LLVMValueRef Instr);
Erick Tryzelaar9813bea2009-08-16 02:20:57 +00003112void LLVMInsertIntoBuilderWithName(LLVMBuilderRef Builder, LLVMValueRef Instr,
3113 const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00003114void LLVMDisposeBuilder(LLVMBuilderRef Builder);
3115
Erick Tryzelaard8531fa2010-02-28 09:45:59 +00003116/* Metadata */
3117void LLVMSetCurrentDebugLocation(LLVMBuilderRef Builder, LLVMValueRef L);
3118LLVMValueRef LLVMGetCurrentDebugLocation(LLVMBuilderRef Builder);
3119void LLVMSetInstDebugLocation(LLVMBuilderRef Builder, LLVMValueRef Inst);
3120
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00003121/* Terminators */
3122LLVMValueRef LLVMBuildRetVoid(LLVMBuilderRef);
3123LLVMValueRef LLVMBuildRet(LLVMBuilderRef, LLVMValueRef V);
Erick Tryzelaarfd529d72009-08-19 08:36:49 +00003124LLVMValueRef LLVMBuildAggregateRet(LLVMBuilderRef, LLVMValueRef *RetVals,
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00003125 unsigned N);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00003126LLVMValueRef LLVMBuildBr(LLVMBuilderRef, LLVMBasicBlockRef Dest);
3127LLVMValueRef LLVMBuildCondBr(LLVMBuilderRef, LLVMValueRef If,
3128 LLVMBasicBlockRef Then, LLVMBasicBlockRef Else);
3129LLVMValueRef LLVMBuildSwitch(LLVMBuilderRef, LLVMValueRef V,
3130 LLVMBasicBlockRef Else, unsigned NumCases);
Erick Tryzelaar0fb26ef2010-02-28 09:46:06 +00003131LLVMValueRef LLVMBuildIndirectBr(LLVMBuilderRef B, LLVMValueRef Addr,
3132 unsigned NumDests);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00003133LLVMValueRef LLVMBuildInvoke(LLVMBuilderRef, LLVMValueRef Fn,
3134 LLVMValueRef *Args, unsigned NumArgs,
3135 LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch,
3136 const char *Name);
Robert Widmann478fce92018-03-30 17:49:53 +00003137LLVMValueRef LLVMBuildUnreachable(LLVMBuilderRef);
3138
3139/* Exception Handling */
3140LLVMValueRef LLVMBuildResume(LLVMBuilderRef B, LLVMValueRef Exn);
Benjamin Kramer5a6568832011-08-19 01:36:54 +00003141LLVMValueRef LLVMBuildLandingPad(LLVMBuilderRef B, LLVMTypeRef Ty,
Reid Kleckneref9828f2015-07-16 01:16:39 +00003142 LLVMValueRef PersFn, unsigned NumClauses,
3143 const char *Name);
Robert Widmann478fce92018-03-30 17:49:53 +00003144LLVMValueRef LLVMBuildCleanupRet(LLVMBuilderRef B, LLVMValueRef CatchPad,
3145 LLVMBasicBlockRef BB);
3146LLVMValueRef LLVMBuildCatchRet(LLVMBuilderRef B, LLVMValueRef CatchPad,
3147 LLVMBasicBlockRef BB);
3148LLVMValueRef LLVMBuildCatchPad(LLVMBuilderRef B, LLVMValueRef ParentPad,
3149 LLVMValueRef *Args, unsigned NumArgs,
3150 const char *Name);
3151LLVMValueRef LLVMBuildCleanupPad(LLVMBuilderRef B, LLVMValueRef ParentPad,
3152 LLVMValueRef *Args, unsigned NumArgs,
3153 const char *Name);
3154LLVMValueRef LLVMBuildCatchSwitch(LLVMBuilderRef B, LLVMValueRef ParentPad,
3155 LLVMBasicBlockRef UnwindBB,
3156 unsigned NumHandlers, const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00003157
Gordon Henriksen097102c2008-01-01 05:50:53 +00003158/* Add a case to the switch instruction */
3159void LLVMAddCase(LLVMValueRef Switch, LLVMValueRef OnVal,
3160 LLVMBasicBlockRef Dest);
3161
Erick Tryzelaar0fb26ef2010-02-28 09:46:06 +00003162/* Add a destination to the indirectbr instruction */
3163void LLVMAddDestination(LLVMValueRef IndirectBr, LLVMBasicBlockRef Dest);
3164
Amaury Sechete39e8532016-02-18 20:38:32 +00003165/* Get the number of clauses on the landingpad instruction */
3166unsigned LLVMGetNumClauses(LLVMValueRef LandingPad);
3167
3168/* Get the value of the clause at idnex Idx on the landingpad instruction */
3169LLVMValueRef LLVMGetClause(LLVMValueRef LandingPad, unsigned Idx);
3170
Bill Wendlingfae14752011-08-12 20:24:12 +00003171/* Add a catch or filter clause to the landingpad instruction */
3172void LLVMAddClause(LLVMValueRef LandingPad, LLVMValueRef ClauseVal);
3173
Amaury Sechete39e8532016-02-18 20:38:32 +00003174/* Get the 'cleanup' flag in the landingpad instruction */
3175LLVMBool LLVMIsCleanup(LLVMValueRef LandingPad);
3176
Bill Wendlingfae14752011-08-12 20:24:12 +00003177/* Set the 'cleanup' flag in the landingpad instruction */
3178void LLVMSetCleanup(LLVMValueRef LandingPad, LLVMBool Val);
3179
Robert Widmann478fce92018-03-30 17:49:53 +00003180/* Add a destination to the catchswitch instruction */
3181void LLVMAddHandler(LLVMValueRef CatchSwitch, LLVMBasicBlockRef Dest);
3182
3183/* Get the number of handlers on the catchswitch instruction */
3184unsigned LLVMGetNumHandlers(LLVMValueRef CatchSwitch);
3185
3186/**
3187 * Obtain the basic blocks acting as handlers for a catchswitch instruction.
3188 *
3189 * The Handlers parameter should point to a pre-allocated array of
3190 * LLVMBasicBlockRefs at least LLVMGetNumHandlers() large. On return, the
3191 * first LLVMGetNumHandlers() entries in the array will be populated
3192 * with LLVMBasicBlockRef instances.
3193 *
3194 * @param CatchSwitch The catchswitch instruction to operate on.
3195 * @param Handlers Memory address of an array to be filled with basic blocks.
3196 */
3197void LLVMGetHandlers(LLVMValueRef CatchSwitch, LLVMBasicBlockRef *Handlers);
3198
3199/* Funclets */
3200
3201/* Get the number of funcletpad arguments. */
3202LLVMValueRef LLVMGetArgOperand(LLVMValueRef Funclet, unsigned i);
3203
3204/* Set a funcletpad argument at the given index. */
3205void LLVMSetArgOperand(LLVMValueRef Funclet, unsigned i, LLVMValueRef value);
3206
3207/**
3208 * Get the parent catchswitch instruction of a catchpad instruction.
3209 *
3210 * This only works on llvm::CatchPadInst instructions.
3211 *
3212 * @see llvm::CatchPadInst::getCatchSwitch()
3213 */
3214LLVMValueRef LLVMGetParentCatchSwitch(LLVMValueRef CatchPad);
3215
3216/**
3217 * Set the parent catchswitch instruction of a catchpad instruction.
3218 *
3219 * This only works on llvm::CatchPadInst instructions.
3220 *
3221 * @see llvm::CatchPadInst::setCatchSwitch()
3222 */
3223void LLVMSetParentCatchSwitch(LLVMValueRef CatchPad, LLVMValueRef CatchSwitch);
3224
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00003225/* Arithmetic */
3226LLVMValueRef LLVMBuildAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3227 const char *Name);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00003228LLVMValueRef LLVMBuildNSWAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3229 const char *Name);
Erick Tryzelaar4c340c72010-02-28 05:51:43 +00003230LLVMValueRef LLVMBuildNUWAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3231 const char *Name);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00003232LLVMValueRef LLVMBuildFAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3233 const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00003234LLVMValueRef LLVMBuildSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3235 const char *Name);
Erick Tryzelaar4c340c72010-02-28 05:51:43 +00003236LLVMValueRef LLVMBuildNSWSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3237 const char *Name);
3238LLVMValueRef LLVMBuildNUWSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3239 const char *Name);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00003240LLVMValueRef LLVMBuildFSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3241 const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00003242LLVMValueRef LLVMBuildMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3243 const char *Name);
Erick Tryzelaar4c340c72010-02-28 05:51:43 +00003244LLVMValueRef LLVMBuildNSWMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3245 const char *Name);
3246LLVMValueRef LLVMBuildNUWMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3247 const char *Name);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00003248LLVMValueRef LLVMBuildFMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3249 const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00003250LLVMValueRef LLVMBuildUDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3251 const char *Name);
Manuel Jacob49fafb12016-10-04 23:32:42 +00003252LLVMValueRef LLVMBuildExactUDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3253 const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00003254LLVMValueRef LLVMBuildSDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3255 const char *Name);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00003256LLVMValueRef LLVMBuildExactSDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3257 const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00003258LLVMValueRef LLVMBuildFDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3259 const char *Name);
3260LLVMValueRef LLVMBuildURem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3261 const char *Name);
3262LLVMValueRef LLVMBuildSRem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3263 const char *Name);
3264LLVMValueRef LLVMBuildFRem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3265 const char *Name);
3266LLVMValueRef LLVMBuildShl(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3267 const char *Name);
3268LLVMValueRef LLVMBuildLShr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3269 const char *Name);
3270LLVMValueRef LLVMBuildAShr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3271 const char *Name);
3272LLVMValueRef LLVMBuildAnd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3273 const char *Name);
3274LLVMValueRef LLVMBuildOr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3275 const char *Name);
3276LLVMValueRef LLVMBuildXor(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3277 const char *Name);
Erick Tryzelaar31831792010-02-28 05:51:27 +00003278LLVMValueRef LLVMBuildBinOp(LLVMBuilderRef B, LLVMOpcode Op,
3279 LLVMValueRef LHS, LLVMValueRef RHS,
3280 const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00003281LLVMValueRef LLVMBuildNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name);
Erick Tryzelaar4c340c72010-02-28 05:51:43 +00003282LLVMValueRef LLVMBuildNSWNeg(LLVMBuilderRef B, LLVMValueRef V,
3283 const char *Name);
3284LLVMValueRef LLVMBuildNUWNeg(LLVMBuilderRef B, LLVMValueRef V,
3285 const char *Name);
Dan Gohmanf919bd62009-09-28 21:51:41 +00003286LLVMValueRef LLVMBuildFNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00003287LLVMValueRef LLVMBuildNot(LLVMBuilderRef, LLVMValueRef V, const char *Name);
3288
3289/* Memory */
3290LLVMValueRef LLVMBuildMalloc(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
3291LLVMValueRef LLVMBuildArrayMalloc(LLVMBuilderRef, LLVMTypeRef Ty,
3292 LLVMValueRef Val, const char *Name);
3293LLVMValueRef LLVMBuildAlloca(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
3294LLVMValueRef LLVMBuildArrayAlloca(LLVMBuilderRef, LLVMTypeRef Ty,
3295 LLVMValueRef Val, const char *Name);
3296LLVMValueRef LLVMBuildFree(LLVMBuilderRef, LLVMValueRef PointerVal);
3297LLVMValueRef LLVMBuildLoad(LLVMBuilderRef, LLVMValueRef PointerVal,
3298 const char *Name);
3299LLVMValueRef LLVMBuildStore(LLVMBuilderRef, LLVMValueRef Val, LLVMValueRef Ptr);
3300LLVMValueRef LLVMBuildGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
3301 LLVMValueRef *Indices, unsigned NumIndices,
3302 const char *Name);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00003303LLVMValueRef LLVMBuildInBoundsGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
3304 LLVMValueRef *Indices, unsigned NumIndices,
3305 const char *Name);
3306LLVMValueRef LLVMBuildStructGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
3307 unsigned Idx, const char *Name);
3308LLVMValueRef LLVMBuildGlobalString(LLVMBuilderRef B, const char *Str,
3309 const char *Name);
3310LLVMValueRef LLVMBuildGlobalStringPtr(LLVMBuilderRef B, const char *Str,
3311 const char *Name);
Chris Lattner2cc6f9d2012-03-22 03:54:15 +00003312LLVMBool LLVMGetVolatile(LLVMValueRef MemoryAccessInst);
3313void LLVMSetVolatile(LLVMValueRef MemoryAccessInst, LLVMBool IsVolatile);
Andrew Wilkinsb7362ce2015-08-02 12:16:57 +00003314LLVMAtomicOrdering LLVMGetOrdering(LLVMValueRef MemoryAccessInst);
3315void LLVMSetOrdering(LLVMValueRef MemoryAccessInst, LLVMAtomicOrdering Ordering);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00003316
3317/* Casts */
3318LLVMValueRef LLVMBuildTrunc(LLVMBuilderRef, LLVMValueRef Val,
3319 LLVMTypeRef DestTy, const char *Name);
3320LLVMValueRef LLVMBuildZExt(LLVMBuilderRef, LLVMValueRef Val,
3321 LLVMTypeRef DestTy, const char *Name);
3322LLVMValueRef LLVMBuildSExt(LLVMBuilderRef, LLVMValueRef Val,
3323 LLVMTypeRef DestTy, const char *Name);
3324LLVMValueRef LLVMBuildFPToUI(LLVMBuilderRef, LLVMValueRef Val,
3325 LLVMTypeRef DestTy, const char *Name);
3326LLVMValueRef LLVMBuildFPToSI(LLVMBuilderRef, LLVMValueRef Val,
3327 LLVMTypeRef DestTy, const char *Name);
3328LLVMValueRef LLVMBuildUIToFP(LLVMBuilderRef, LLVMValueRef Val,
3329 LLVMTypeRef DestTy, const char *Name);
3330LLVMValueRef LLVMBuildSIToFP(LLVMBuilderRef, LLVMValueRef Val,
3331 LLVMTypeRef DestTy, const char *Name);
3332LLVMValueRef LLVMBuildFPTrunc(LLVMBuilderRef, LLVMValueRef Val,
3333 LLVMTypeRef DestTy, const char *Name);
3334LLVMValueRef LLVMBuildFPExt(LLVMBuilderRef, LLVMValueRef Val,
3335 LLVMTypeRef DestTy, const char *Name);
3336LLVMValueRef LLVMBuildPtrToInt(LLVMBuilderRef, LLVMValueRef Val,
3337 LLVMTypeRef DestTy, const char *Name);
3338LLVMValueRef LLVMBuildIntToPtr(LLVMBuilderRef, LLVMValueRef Val,
3339 LLVMTypeRef DestTy, const char *Name);
3340LLVMValueRef LLVMBuildBitCast(LLVMBuilderRef, LLVMValueRef Val,
3341 LLVMTypeRef DestTy, const char *Name);
Matt Arsenaultb03bd4d2013-11-15 01:34:59 +00003342LLVMValueRef LLVMBuildAddrSpaceCast(LLVMBuilderRef, LLVMValueRef Val,
3343 LLVMTypeRef DestTy, const char *Name);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00003344LLVMValueRef LLVMBuildZExtOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
3345 LLVMTypeRef DestTy, const char *Name);
3346LLVMValueRef LLVMBuildSExtOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
3347 LLVMTypeRef DestTy, const char *Name);
3348LLVMValueRef LLVMBuildTruncOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
3349 LLVMTypeRef DestTy, const char *Name);
Erick Tryzelaar31831792010-02-28 05:51:27 +00003350LLVMValueRef LLVMBuildCast(LLVMBuilderRef B, LLVMOpcode Op, LLVMValueRef Val,
3351 LLVMTypeRef DestTy, const char *Name);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00003352LLVMValueRef LLVMBuildPointerCast(LLVMBuilderRef, LLVMValueRef Val,
3353 LLVMTypeRef DestTy, const char *Name);
Duncan Sands9d786d72009-11-23 10:49:03 +00003354LLVMValueRef LLVMBuildIntCast(LLVMBuilderRef, LLVMValueRef Val, /*Signed cast!*/
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00003355 LLVMTypeRef DestTy, const char *Name);
3356LLVMValueRef LLVMBuildFPCast(LLVMBuilderRef, LLVMValueRef Val,
3357 LLVMTypeRef DestTy, const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00003358
3359/* Comparisons */
3360LLVMValueRef LLVMBuildICmp(LLVMBuilderRef, LLVMIntPredicate Op,
3361 LLVMValueRef LHS, LLVMValueRef RHS,
3362 const char *Name);
3363LLVMValueRef LLVMBuildFCmp(LLVMBuilderRef, LLVMRealPredicate Op,
3364 LLVMValueRef LHS, LLVMValueRef RHS,
3365 const char *Name);
3366
3367/* Miscellaneous instructions */
3368LLVMValueRef LLVMBuildPhi(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
3369LLVMValueRef LLVMBuildCall(LLVMBuilderRef, LLVMValueRef Fn,
3370 LLVMValueRef *Args, unsigned NumArgs,
3371 const char *Name);
3372LLVMValueRef LLVMBuildSelect(LLVMBuilderRef, LLVMValueRef If,
3373 LLVMValueRef Then, LLVMValueRef Else,
3374 const char *Name);
3375LLVMValueRef LLVMBuildVAArg(LLVMBuilderRef, LLVMValueRef List, LLVMTypeRef Ty,
3376 const char *Name);
3377LLVMValueRef LLVMBuildExtractElement(LLVMBuilderRef, LLVMValueRef VecVal,
3378 LLVMValueRef Index, const char *Name);
3379LLVMValueRef LLVMBuildInsertElement(LLVMBuilderRef, LLVMValueRef VecVal,
3380 LLVMValueRef EltVal, LLVMValueRef Index,
3381 const char *Name);
3382LLVMValueRef LLVMBuildShuffleVector(LLVMBuilderRef, LLVMValueRef V1,
3383 LLVMValueRef V2, LLVMValueRef Mask,
3384 const char *Name);
Dan Gohmand5104a52008-11-03 22:55:43 +00003385LLVMValueRef LLVMBuildExtractValue(LLVMBuilderRef, LLVMValueRef AggVal,
3386 unsigned Index, const char *Name);
3387LLVMValueRef LLVMBuildInsertValue(LLVMBuilderRef, LLVMValueRef AggVal,
3388 LLVMValueRef EltVal, unsigned Index,
3389 const char *Name);
Gordon Henriksen76a03742007-09-18 03:18:57 +00003390
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00003391LLVMValueRef LLVMBuildIsNull(LLVMBuilderRef, LLVMValueRef Val,
3392 const char *Name);
3393LLVMValueRef LLVMBuildIsNotNull(LLVMBuilderRef, LLVMValueRef Val,
3394 const char *Name);
3395LLVMValueRef LLVMBuildPtrDiff(LLVMBuilderRef, LLVMValueRef LHS,
3396 LLVMValueRef RHS, const char *Name);
Filip Pizlo0d3f7ec2013-11-20 00:07:49 +00003397LLVMValueRef LLVMBuildFence(LLVMBuilderRef B, LLVMAtomicOrdering ordering,
3398 LLVMBool singleThread, const char *Name);
3399LLVMValueRef LLVMBuildAtomicRMW(LLVMBuilderRef B, LLVMAtomicRMWBinOp op,
NAKAMURA Takumia3a81352013-10-23 17:56:29 +00003400 LLVMValueRef PTR, LLVMValueRef Val,
3401 LLVMAtomicOrdering ordering,
Carlo Kok8c6719b2013-04-23 13:21:19 +00003402 LLVMBool singleThread);
Mehdi Amini43165d92016-03-19 21:28:28 +00003403LLVMValueRef LLVMBuildAtomicCmpXchg(LLVMBuilderRef B, LLVMValueRef Ptr,
3404 LLVMValueRef Cmp, LLVMValueRef New,
3405 LLVMAtomicOrdering SuccessOrdering,
3406 LLVMAtomicOrdering FailureOrdering,
3407 LLVMBool SingleThread);
3408
3409LLVMBool LLVMIsAtomicSingleThread(LLVMValueRef AtomicInst);
3410void LLVMSetAtomicSingleThread(LLVMValueRef AtomicInst, LLVMBool SingleThread);
3411
3412LLVMAtomicOrdering LLVMGetCmpXchgSuccessOrdering(LLVMValueRef CmpXchgInst);
3413void LLVMSetCmpXchgSuccessOrdering(LLVMValueRef CmpXchgInst,
3414 LLVMAtomicOrdering Ordering);
3415LLVMAtomicOrdering LLVMGetCmpXchgFailureOrdering(LLVMValueRef CmpXchgInst);
3416void LLVMSetCmpXchgFailureOrdering(LLVMValueRef CmpXchgInst,
3417 LLVMAtomicOrdering Ordering);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00003418
Gregory Szorc34c863a2012-03-21 03:54:29 +00003419/**
3420 * @}
3421 */
Gordon Henriksen34eb6d82007-12-19 22:30:40 +00003422
Gregory Szorc34c863a2012-03-21 03:54:29 +00003423/**
3424 * @defgroup LLVMCCoreModuleProvider Module Providers
3425 *
3426 * @{
3427 */
Gordon Henriksen0a68fe22007-12-12 01:04:30 +00003428
Gregory Szorc34c863a2012-03-21 03:54:29 +00003429/**
3430 * Changes the type of M so it can be passed to FunctionPassManagers and the
Jeffrey Yasskin091217b2010-01-27 20:34:15 +00003431 * JIT. They take ModuleProviders for historical reasons.
Gordon Henriksen0a68fe22007-12-12 01:04:30 +00003432 */
3433LLVMModuleProviderRef
3434LLVMCreateModuleProviderForExistingModule(LLVMModuleRef M);
3435
Gregory Szorc34c863a2012-03-21 03:54:29 +00003436/**
3437 * Destroys the module M.
Gordon Henriksen0a68fe22007-12-12 01:04:30 +00003438 */
Jeffrey Yasskin091217b2010-01-27 20:34:15 +00003439void LLVMDisposeModuleProvider(LLVMModuleProviderRef M);
Gordon Henriksen0a68fe22007-12-12 01:04:30 +00003440
Gregory Szorc34c863a2012-03-21 03:54:29 +00003441/**
3442 * @}
3443 */
Gordon Henriksen34eb6d82007-12-19 22:30:40 +00003444
Gregory Szorc34c863a2012-03-21 03:54:29 +00003445/**
3446 * @defgroup LLVMCCoreMemoryBuffers Memory Buffers
3447 *
3448 * @{
3449 */
Gordon Henriksen34eb6d82007-12-19 22:30:40 +00003450
Chris Lattner25963c62010-01-09 22:27:07 +00003451LLVMBool LLVMCreateMemoryBufferWithContentsOfFile(const char *Path,
3452 LLVMMemoryBufferRef *OutMemBuf,
3453 char **OutMessage);
3454LLVMBool LLVMCreateMemoryBufferWithSTDIN(LLVMMemoryBufferRef *OutMemBuf,
3455 char **OutMessage);
Bill Wendling526276a2013-02-14 19:11:28 +00003456LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRange(const char *InputData,
3457 size_t InputDataLength,
3458 const char *BufferName,
Bill Wendlingc9baa962013-02-14 19:39:14 +00003459 LLVMBool RequiresNullTerminator);
Bill Wendling526276a2013-02-14 19:11:28 +00003460LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRangeCopy(const char *InputData,
3461 size_t InputDataLength,
3462 const char *BufferName);
Tom Stellard62c03202013-04-18 19:50:53 +00003463const char *LLVMGetBufferStart(LLVMMemoryBufferRef MemBuf);
Tom Stellardb7fb7242013-04-16 23:12:51 +00003464size_t LLVMGetBufferSize(LLVMMemoryBufferRef MemBuf);
Gordon Henriksen34eb6d82007-12-19 22:30:40 +00003465void LLVMDisposeMemoryBuffer(LLVMMemoryBufferRef MemBuf);
3466
Gregory Szorc34c863a2012-03-21 03:54:29 +00003467/**
3468 * @}
3469 */
3470
3471/**
3472 * @defgroup LLVMCCorePassRegistry Pass Registry
3473 *
3474 * @{
3475 */
Owen Anderson4698c5d2010-10-07 17:55:47 +00003476
3477/** Return the global pass registry, for use with initialization functions.
Gregory Szorc34c863a2012-03-21 03:54:29 +00003478 @see llvm::PassRegistry::getPassRegistry */
Owen Anderson4698c5d2010-10-07 17:55:47 +00003479LLVMPassRegistryRef LLVMGetGlobalPassRegistry(void);
Gordon Henriksen878114b2008-03-16 04:20:44 +00003480
Gregory Szorc34c863a2012-03-21 03:54:29 +00003481/**
3482 * @}
3483 */
3484
3485/**
3486 * @defgroup LLVMCCorePassManagers Pass Managers
3487 *
3488 * @{
3489 */
Gordon Henriksen878114b2008-03-16 04:20:44 +00003490
3491/** Constructs a new whole-module pass pipeline. This type of pipeline is
3492 suitable for link-time optimization and whole-module transformations.
Gregory Szorc34c863a2012-03-21 03:54:29 +00003493 @see llvm::PassManager::PassManager */
Gordon Henriksena735a9c2008-05-04 12:55:34 +00003494LLVMPassManagerRef LLVMCreatePassManager(void);
Gordon Henriksen878114b2008-03-16 04:20:44 +00003495
3496/** Constructs a new function-by-function pass pipeline over the module
3497 provider. It does not take ownership of the module provider. This type of
3498 pipeline is suitable for code generation and JIT compilation tasks.
Gregory Szorc34c863a2012-03-21 03:54:29 +00003499 @see llvm::FunctionPassManager::FunctionPassManager */
Erick Tryzelaarad0e0cb2010-03-02 23:58:54 +00003500LLVMPassManagerRef LLVMCreateFunctionPassManagerForModule(LLVMModuleRef M);
3501
3502/** Deprecated: Use LLVMCreateFunctionPassManagerForModule instead. */
Gordon Henriksen878114b2008-03-16 04:20:44 +00003503LLVMPassManagerRef LLVMCreateFunctionPassManager(LLVMModuleProviderRef MP);
3504
3505/** Initializes, executes on the provided module, and finalizes all of the
3506 passes scheduled in the pass manager. Returns 1 if any of the passes
Gregory Szorc34c863a2012-03-21 03:54:29 +00003507 modified the module, 0 otherwise.
3508 @see llvm::PassManager::run(Module&) */
Chris Lattner25963c62010-01-09 22:27:07 +00003509LLVMBool LLVMRunPassManager(LLVMPassManagerRef PM, LLVMModuleRef M);
Gordon Henriksen878114b2008-03-16 04:20:44 +00003510
3511/** Initializes all of the function passes scheduled in the function pass
3512 manager. Returns 1 if any of the passes modified the module, 0 otherwise.
Gregory Szorc34c863a2012-03-21 03:54:29 +00003513 @see llvm::FunctionPassManager::doInitialization */
Chris Lattner25963c62010-01-09 22:27:07 +00003514LLVMBool LLVMInitializeFunctionPassManager(LLVMPassManagerRef FPM);
Gordon Henriksen878114b2008-03-16 04:20:44 +00003515
3516/** Executes all of the function passes scheduled in the function pass manager
3517 on the provided function. Returns 1 if any of the passes modified the
3518 function, false otherwise.
Gregory Szorc34c863a2012-03-21 03:54:29 +00003519 @see llvm::FunctionPassManager::run(Function&) */
Chris Lattner25963c62010-01-09 22:27:07 +00003520LLVMBool LLVMRunFunctionPassManager(LLVMPassManagerRef FPM, LLVMValueRef F);
Gordon Henriksen878114b2008-03-16 04:20:44 +00003521
Hiroshi Inoue0909ca12018-01-26 08:15:29 +00003522/** Finalizes all of the function passes scheduled in the function pass
Gordon Henriksen878114b2008-03-16 04:20:44 +00003523 manager. Returns 1 if any of the passes modified the module, 0 otherwise.
Gregory Szorc34c863a2012-03-21 03:54:29 +00003524 @see llvm::FunctionPassManager::doFinalization */
Chris Lattner25963c62010-01-09 22:27:07 +00003525LLVMBool LLVMFinalizeFunctionPassManager(LLVMPassManagerRef FPM);
Gordon Henriksen878114b2008-03-16 04:20:44 +00003526
3527/** Frees the memory of a pass pipeline. For function pipelines, does not free
3528 the module provider.
Gregory Szorc34c863a2012-03-21 03:54:29 +00003529 @see llvm::PassManagerBase::~PassManagerBase. */
Gordon Henriksen878114b2008-03-16 04:20:44 +00003530void LLVMDisposePassManager(LLVMPassManagerRef PM);
3531
Gregory Szorc34c863a2012-03-21 03:54:29 +00003532/**
3533 * @}
3534 */
3535
3536/**
Duncan Sands1cba0a82013-02-17 16:35:51 +00003537 * @defgroup LLVMCCoreThreading Threading
3538 *
3539 * Handle the structures needed to make LLVM safe for multithreading.
3540 *
3541 * @{
3542 */
3543
Chandler Carruth39cd2162014-06-27 15:13:01 +00003544/** Deprecated: Multi-threading can only be enabled/disabled with the compile
3545 time define LLVM_ENABLE_THREADS. This function always returns
3546 LLVMIsMultithreaded(). */
Benjamin Kramer325ec892013-10-23 16:57:34 +00003547LLVMBool LLVMStartMultithreaded(void);
Duncan Sands1cba0a82013-02-17 16:35:51 +00003548
Chandler Carruth39cd2162014-06-27 15:13:01 +00003549/** Deprecated: Multi-threading can only be enabled/disabled with the compile
3550 time define LLVM_ENABLE_THREADS. */
Benjamin Kramer325ec892013-10-23 16:57:34 +00003551void LLVMStopMultithreaded(void);
Duncan Sands1cba0a82013-02-17 16:35:51 +00003552
3553/** Check whether LLVM is executing in thread-safe mode or not.
3554 @see llvm::llvm_is_multithreaded */
Benjamin Kramer325ec892013-10-23 16:57:34 +00003555LLVMBool LLVMIsMultithreaded(void);
Duncan Sands1cba0a82013-02-17 16:35:51 +00003556
3557/**
3558 * @}
3559 */
3560
3561/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00003562 * @}
3563 */
3564
3565/**
3566 * @}
3567 */
Gordon Henriksen878114b2008-03-16 04:20:44 +00003568
Gordon Henriksen76a03742007-09-18 03:18:57 +00003569#ifdef __cplusplus
3570}
Eugene Zelenkoffec81c2015-11-04 22:32:32 +00003571#endif
Gordon Henriksen7330acd2007-10-05 23:59:36 +00003572
Eugene Zelenkoffec81c2015-11-04 22:32:32 +00003573#endif /* LLVM_C_CORE_H */