blob: 8e70c872a29d51d6b3015dc2d99897098737bf3a [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 {
Devang Patel4c758ea2008-09-25 21:00:45 +000058 LLVMZExtAttribute = 1<<0,
59 LLVMSExtAttribute = 1<<1,
60 LLVMNoReturnAttribute = 1<<2,
61 LLVMInRegAttribute = 1<<3,
62 LLVMStructRetAttribute = 1<<4,
63 LLVMNoUnwindAttribute = 1<<5,
64 LLVMNoAliasAttribute = 1<<6,
65 LLVMByValAttribute = 1<<7,
66 LLVMNestAttribute = 1<<8,
67 LLVMReadNoneAttribute = 1<<9,
Anton Korobeynikovc8ce7b082009-07-17 18:07:26 +000068 LLVMReadOnlyAttribute = 1<<10,
Anton Korobeynikov9750be92009-07-17 18:57:16 +000069 LLVMNoInlineAttribute = 1<<11,
70 LLVMAlwaysInlineAttribute = 1<<12,
71 LLVMOptimizeForSizeAttribute = 1<<13,
72 LLVMStackProtectAttribute = 1<<14,
73 LLVMStackProtectReqAttribute = 1<<15,
Erick Tryzelaar8f69fea2010-03-03 23:51:25 +000074 LLVMAlignment = 31<<16,
Anton Korobeynikov9750be92009-07-17 18:57:16 +000075 LLVMNoCaptureAttribute = 1<<21,
76 LLVMNoRedZoneAttribute = 1<<22,
77 LLVMNoImplicitFloatAttribute = 1<<23,
Jakob Stoklund Olesen74bb06c2010-02-06 01:16:28 +000078 LLVMNakedAttribute = 1<<24,
Erick Tryzelaar8f69fea2010-03-03 23:51:25 +000079 LLVMInlineHintAttribute = 1<<25,
Torok Edwin1db48c02011-10-06 12:13:32 +000080 LLVMStackAlignment = 7<<26,
81 LLVMReturnsTwice = 1 << 29,
82 LLVMUWTable = 1 << 30,
Chandler Carruth44d69d92012-01-25 07:40:15 +000083 LLVMNonLazyBind = 1 << 31
84
Bill Wendlingd154e2832013-01-23 06:41:41 +000085 /* FIXME: These attributes are currently not included in the C API as
Nuno Lopesdef4229972012-09-02 14:19:21 +000086 a temporary measure until the API/ABI impact to the C API is understood
87 and the path forward agreed upon.
Peter Collingbourne58af6d12015-06-15 22:16:51 +000088 LLVMSanitizeAddressAttribute = 1ULL << 32,
89 LLVMStackProtectStrongAttribute = 1ULL<<35,
90 LLVMColdAttribute = 1ULL << 40,
91 LLVMOptimizeNoneAttribute = 1ULL << 42,
92 LLVMInAllocaAttribute = 1ULL << 43,
93 LLVMNonNullAttribute = 1ULL << 44,
94 LLVMJumpTableAttribute = 1ULL << 45,
95 LLVMConvergentAttribute = 1ULL << 46,
96 LLVMSafeStackAttribute = 1ULL << 47,
Manman Renf46262e2016-03-29 17:37:21 +000097 LLVMSwiftSelfAttribute = 1ULL << 48,
Manman Ren9bfd0d02016-04-01 21:41:15 +000098 LLVMSwiftErrorAttribute = 1ULL << 49,
Nuno Lopesdef4229972012-09-02 14:19:21 +000099 */
Devang Patel4c758ea2008-09-25 21:00:45 +0000100} LLVMAttribute;
Gordon Henriksen2d9cc212008-04-28 17:37:06 +0000101
102typedef enum {
Bill Wendlingda52cec2010-02-15 20:53:17 +0000103 /* Terminator Instructions */
Chris Lattner40cf28d2009-10-12 04:01:02 +0000104 LLVMRet = 1,
105 LLVMBr = 2,
106 LLVMSwitch = 3,
Bill Wendling07d6d762010-02-15 20:50:51 +0000107 LLVMIndirectBr = 4,
108 LLVMInvoke = 5,
Bill Wendling46ffaa92011-08-02 06:20:17 +0000109 /* removed 6 due to API changes */
Bill Wendling2641d132011-07-27 21:00:28 +0000110 LLVMUnreachable = 7,
Bill Wendling07d6d762010-02-15 20:50:51 +0000111
Bill Wendlingda52cec2010-02-15 20:53:17 +0000112 /* Standard Binary Operators */
Bill Wendling2641d132011-07-27 21:00:28 +0000113 LLVMAdd = 8,
114 LLVMFAdd = 9,
115 LLVMSub = 10,
116 LLVMFSub = 11,
117 LLVMMul = 12,
118 LLVMFMul = 13,
119 LLVMUDiv = 14,
120 LLVMSDiv = 15,
121 LLVMFDiv = 16,
122 LLVMURem = 17,
123 LLVMSRem = 18,
124 LLVMFRem = 19,
Bill Wendling07d6d762010-02-15 20:50:51 +0000125
Bill Wendlingda52cec2010-02-15 20:53:17 +0000126 /* Logical Operators */
Bill Wendling2641d132011-07-27 21:00:28 +0000127 LLVMShl = 20,
128 LLVMLShr = 21,
129 LLVMAShr = 22,
130 LLVMAnd = 23,
131 LLVMOr = 24,
132 LLVMXor = 25,
Bill Wendling07d6d762010-02-15 20:50:51 +0000133
Bill Wendlingda52cec2010-02-15 20:53:17 +0000134 /* Memory Operators */
Bill Wendling2641d132011-07-27 21:00:28 +0000135 LLVMAlloca = 26,
136 LLVMLoad = 27,
137 LLVMStore = 28,
138 LLVMGetElementPtr = 29,
Bill Wendling07d6d762010-02-15 20:50:51 +0000139
Bill Wendlingda52cec2010-02-15 20:53:17 +0000140 /* Cast Operators */
Bill Wendling2641d132011-07-27 21:00:28 +0000141 LLVMTrunc = 30,
142 LLVMZExt = 31,
143 LLVMSExt = 32,
144 LLVMFPToUI = 33,
145 LLVMFPToSI = 34,
146 LLVMUIToFP = 35,
147 LLVMSIToFP = 36,
148 LLVMFPTrunc = 37,
149 LLVMFPExt = 38,
150 LLVMPtrToInt = 39,
151 LLVMIntToPtr = 40,
152 LLVMBitCast = 41,
Matt Arsenaultb03bd4d2013-11-15 01:34:59 +0000153 LLVMAddrSpaceCast = 60,
Bill Wendling07d6d762010-02-15 20:50:51 +0000154
Bill Wendlingda52cec2010-02-15 20:53:17 +0000155 /* Other Operators */
Bill Wendling2641d132011-07-27 21:00:28 +0000156 LLVMICmp = 42,
157 LLVMFCmp = 43,
158 LLVMPHI = 44,
159 LLVMCall = 45,
160 LLVMSelect = 46,
Torok Edwin05dc9d62011-10-06 12:39:34 +0000161 LLVMUserOp1 = 47,
162 LLVMUserOp2 = 48,
Bill Wendling2641d132011-07-27 21:00:28 +0000163 LLVMVAArg = 49,
164 LLVMExtractElement = 50,
165 LLVMInsertElement = 51,
166 LLVMShuffleVector = 52,
167 LLVMExtractValue = 53,
168 LLVMInsertValue = 54,
Eli Friedman4fc946c2011-07-27 18:59:19 +0000169
170 /* Atomic operators */
Bill Wendling2641d132011-07-27 21:00:28 +0000171 LLVMFence = 55,
Eli Friedmanc9a551e2011-07-28 21:48:00 +0000172 LLVMAtomicCmpXchg = 56,
Bill Wendlingf891bf82011-07-31 06:30:59 +0000173 LLVMAtomicRMW = 57,
174
175 /* Exception Handling Operators */
Bill Wendlingfae14752011-08-12 20:24:12 +0000176 LLVMResume = 58,
David Majnemer654e1302015-07-31 17:58:14 +0000177 LLVMLandingPad = 59,
178 LLVMCleanupRet = 61,
179 LLVMCatchRet = 62,
Joseph Tremoulet9ce71f72015-09-03 09:09:43 +0000180 LLVMCatchPad = 63,
David Majnemerbbfc7212015-12-14 18:34:23 +0000181 LLVMCleanupPad = 64,
182 LLVMCatchSwitch = 65
Chris Lattner40cf28d2009-10-12 04:01:02 +0000183} LLVMOpcode;
184
185typedef enum {
Gordon Henriksen4a4d7352007-12-30 17:46:33 +0000186 LLVMVoidTypeKind, /**< type with no size */
Dan Gohman518cda42011-12-17 00:04:22 +0000187 LLVMHalfTypeKind, /**< 16 bit floating point type */
Gordon Henriksen4a4d7352007-12-30 17:46:33 +0000188 LLVMFloatTypeKind, /**< 32 bit floating point type */
189 LLVMDoubleTypeKind, /**< 64 bit floating point type */
190 LLVMX86_FP80TypeKind, /**< 80 bit floating point type (X87) */
191 LLVMFP128TypeKind, /**< 128 bit floating point type (112-bit mantissa)*/
192 LLVMPPC_FP128TypeKind, /**< 128 bit floating point type (two 64-bits) */
193 LLVMLabelTypeKind, /**< Labels */
194 LLVMIntegerTypeKind, /**< Arbitrary bit width integers */
195 LLVMFunctionTypeKind, /**< Functions */
196 LLVMStructTypeKind, /**< Structures */
197 LLVMArrayTypeKind, /**< Arrays */
198 LLVMPointerTypeKind, /**< Pointers */
Chris Lattnerdac44ec2009-07-15 22:00:31 +0000199 LLVMVectorTypeKind, /**< SIMD 'packed' format, or other vector type */
Dale Johannesenbaa5d042010-09-10 20:55:01 +0000200 LLVMMetadataTypeKind, /**< Metadata */
David Majnemerb611e3f2015-08-14 05:09:07 +0000201 LLVMX86_MMXTypeKind, /**< X86 MMX */
202 LLVMTokenTypeKind /**< Tokens */
Gordon Henriksen76a03742007-09-18 03:18:57 +0000203} LLVMTypeKind;
204
205typedef enum {
Gordon Henriksen4a4d7352007-12-30 17:46:33 +0000206 LLVMExternalLinkage, /**< Externally visible function */
Chris Lattner2dba0f02009-04-13 06:25:37 +0000207 LLVMAvailableExternallyLinkage,
Duncan Sands12da8ce2009-03-07 15:45:40 +0000208 LLVMLinkOnceAnyLinkage, /**< Keep one copy of function when linking (inline)*/
209 LLVMLinkOnceODRLinkage, /**< Same, but only replaced by something
210 equivalent. */
Rafael Espindola716e7402013-11-01 17:09:14 +0000211 LLVMLinkOnceODRAutoHideLinkage, /**< Obsolete */
Duncan Sands12da8ce2009-03-07 15:45:40 +0000212 LLVMWeakAnyLinkage, /**< Keep one copy of function when linking (weak) */
213 LLVMWeakODRLinkage, /**< Same, but only replaced by something
214 equivalent. */
Gordon Henriksen4a4d7352007-12-30 17:46:33 +0000215 LLVMAppendingLinkage, /**< Special purpose, only applies to global arrays */
216 LLVMInternalLinkage, /**< Rename collisions when linking (static
217 functions) */
Duncan Sands12da8ce2009-03-07 15:45:40 +0000218 LLVMPrivateLinkage, /**< Like Internal, but omit from symbol table */
Nico Rieck7157bb72014-01-14 15:22:47 +0000219 LLVMDLLImportLinkage, /**< Obsolete */
220 LLVMDLLExportLinkage, /**< Obsolete */
Duncan Sandse2881052009-03-11 08:08:06 +0000221 LLVMExternalWeakLinkage,/**< ExternalWeak linkage description */
Jeffrey Yasskin091217b2010-01-27 20:34:15 +0000222 LLVMGhostLinkage, /**< Obsolete */
Bill Wendling002b1672009-07-20 18:22:52 +0000223 LLVMCommonLinkage, /**< Tentative definitions */
Bill Wendling03bcd6e2010-07-01 21:55:59 +0000224 LLVMLinkerPrivateLinkage, /**< Like Private, but linker removes. */
Bill Wendling34bc34e2012-08-17 18:33:14 +0000225 LLVMLinkerPrivateWeakLinkage /**< Like LinkerPrivate, but is weak. */
Gordon Henriksen76a03742007-09-18 03:18:57 +0000226} LLVMLinkage;
227
228typedef enum {
Gordon Henriksen4a4d7352007-12-30 17:46:33 +0000229 LLVMDefaultVisibility, /**< The GV is visible */
230 LLVMHiddenVisibility, /**< The GV is hidden */
231 LLVMProtectedVisibility /**< The GV is protected */
Gordon Henriksen76a03742007-09-18 03:18:57 +0000232} LLVMVisibility;
233
Gordon Henriksenc23b66c2007-09-26 20:56:12 +0000234typedef enum {
Reid Kleckner2fae26f2014-03-05 02:34:23 +0000235 LLVMDefaultStorageClass = 0,
236 LLVMDLLImportStorageClass = 1, /**< Function to be imported from DLL. */
237 LLVMDLLExportStorageClass = 2 /**< Function to be accessible from DLL. */
238} LLVMDLLStorageClass;
239
240typedef enum {
Gordon Henriksenc23b66c2007-09-26 20:56:12 +0000241 LLVMCCallConv = 0,
242 LLVMFastCallConv = 8,
243 LLVMColdCallConv = 9,
Filip Pizlodfc9b582013-11-09 06:00:03 +0000244 LLVMWebKitJSCallConv = 12,
245 LLVMAnyRegCallConv = 13,
Gordon Henriksenc23b66c2007-09-26 20:56:12 +0000246 LLVMX86StdcallCallConv = 64,
247 LLVMX86FastcallCallConv = 65
248} LLVMCallConv;
249
250typedef enum {
Gordon Henriksen4a4d7352007-12-30 17:46:33 +0000251 LLVMIntEQ = 32, /**< equal */
252 LLVMIntNE, /**< not equal */
253 LLVMIntUGT, /**< unsigned greater than */
254 LLVMIntUGE, /**< unsigned greater or equal */
255 LLVMIntULT, /**< unsigned less than */
256 LLVMIntULE, /**< unsigned less or equal */
257 LLVMIntSGT, /**< signed greater than */
258 LLVMIntSGE, /**< signed greater or equal */
259 LLVMIntSLT, /**< signed less than */
260 LLVMIntSLE /**< signed less or equal */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +0000261} LLVMIntPredicate;
262
263typedef enum {
Gordon Henriksen4a4d7352007-12-30 17:46:33 +0000264 LLVMRealPredicateFalse, /**< Always false (always folded) */
265 LLVMRealOEQ, /**< True if ordered and equal */
266 LLVMRealOGT, /**< True if ordered and greater than */
267 LLVMRealOGE, /**< True if ordered and greater than or equal */
268 LLVMRealOLT, /**< True if ordered and less than */
269 LLVMRealOLE, /**< True if ordered and less than or equal */
270 LLVMRealONE, /**< True if ordered and operands are unequal */
271 LLVMRealORD, /**< True if ordered (no nans) */
272 LLVMRealUNO, /**< True if unordered: isnan(X) | isnan(Y) */
273 LLVMRealUEQ, /**< True if unordered or equal */
274 LLVMRealUGT, /**< True if unordered or greater than */
275 LLVMRealUGE, /**< True if unordered, greater than, or equal */
276 LLVMRealULT, /**< True if unordered or less than */
277 LLVMRealULE, /**< True if unordered, less than, or equal */
278 LLVMRealUNE, /**< True if unordered or not equal */
279 LLVMRealPredicateTrue /**< Always true (always folded) */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +0000280} LLVMRealPredicate;
281
Bill Wendlingfae14752011-08-12 20:24:12 +0000282typedef enum {
283 LLVMLandingPadCatch, /**< A catch clause */
284 LLVMLandingPadFilter /**< A filter clause */
285} LLVMLandingPadClauseTy;
286
Hans Wennborg5ff71202013-04-16 08:58:59 +0000287typedef enum {
288 LLVMNotThreadLocal = 0,
289 LLVMGeneralDynamicTLSModel,
290 LLVMLocalDynamicTLSModel,
291 LLVMInitialExecTLSModel,
292 LLVMLocalExecTLSModel
293} LLVMThreadLocalMode;
294
Carlo Kokda0ac722013-04-23 13:45:37 +0000295typedef enum {
Carlo Kok8c6719b2013-04-23 13:21:19 +0000296 LLVMAtomicOrderingNotAtomic = 0, /**< A load or store which is not atomic */
297 LLVMAtomicOrderingUnordered = 1, /**< Lowest level of atomicity, guarantees
298 somewhat sane results, lock free. */
NAKAMURA Takumia3a81352013-10-23 17:56:29 +0000299 LLVMAtomicOrderingMonotonic = 2, /**< guarantees that if you take all the
300 operations affecting a specific address,
Carlo Kok8c6719b2013-04-23 13:21:19 +0000301 a consistent ordering exists */
NAKAMURA Takumia3a81352013-10-23 17:56:29 +0000302 LLVMAtomicOrderingAcquire = 4, /**< Acquire provides a barrier of the sort
303 necessary to acquire a lock to access other
Carlo Kok8c6719b2013-04-23 13:21:19 +0000304 memory with normal loads and stores. */
NAKAMURA Takumia3a81352013-10-23 17:56:29 +0000305 LLVMAtomicOrderingRelease = 5, /**< Release is similar to Acquire, but with
306 a barrier of the sort necessary to release
Carlo Kok8c6719b2013-04-23 13:21:19 +0000307 a lock. */
NAKAMURA Takumia3a81352013-10-23 17:56:29 +0000308 LLVMAtomicOrderingAcquireRelease = 6, /**< provides both an Acquire and a
309 Release barrier (for fences and
Carlo Kok8c6719b2013-04-23 13:21:19 +0000310 operations which both read and write
311 memory). */
NAKAMURA Takumia3a81352013-10-23 17:56:29 +0000312 LLVMAtomicOrderingSequentiallyConsistent = 7 /**< provides Acquire semantics
313 for loads and Release
314 semantics for stores.
315 Additionally, it guarantees
316 that a total ordering exists
317 between all
318 SequentiallyConsistent
Carlo Kok8c6719b2013-04-23 13:21:19 +0000319 operations. */
Carlo Kokda0ac722013-04-23 13:45:37 +0000320} LLVMAtomicOrdering;
Carlo Kok8c6719b2013-04-23 13:21:19 +0000321
Carlo Kokda0ac722013-04-23 13:45:37 +0000322typedef enum {
Carlo Kok8c6719b2013-04-23 13:21:19 +0000323 LLVMAtomicRMWBinOpXchg, /**< Set the new value and return the one old */
324 LLVMAtomicRMWBinOpAdd, /**< Add a value and return the old one */
325 LLVMAtomicRMWBinOpSub, /**< Subtract a value and return the old one */
326 LLVMAtomicRMWBinOpAnd, /**< And a value and return the old one */
327 LLVMAtomicRMWBinOpNand, /**< Not-And a value and return the old one */
328 LLVMAtomicRMWBinOpOr, /**< OR a value and return the old one */
329 LLVMAtomicRMWBinOpXor, /**< Xor a value and return the old one */
330 LLVMAtomicRMWBinOpMax, /**< Sets the value if it's greater than the
NAKAMURA Takumia3a81352013-10-23 17:56:29 +0000331 original using a signed comparison and return
Carlo Kok8c6719b2013-04-23 13:21:19 +0000332 the old one */
333 LLVMAtomicRMWBinOpMin, /**< Sets the value if it's Smaller than the
NAKAMURA Takumia3a81352013-10-23 17:56:29 +0000334 original using a signed comparison and return
Carlo Kok8c6719b2013-04-23 13:21:19 +0000335 the old one */
336 LLVMAtomicRMWBinOpUMax, /**< Sets the value if it's greater than the
NAKAMURA Takumia3a81352013-10-23 17:56:29 +0000337 original using an unsigned comparison and return
Carlo Kok8c6719b2013-04-23 13:21:19 +0000338 the old one */
339 LLVMAtomicRMWBinOpUMin /**< Sets the value if it's greater than the
NAKAMURA Takumia3a81352013-10-23 17:56:29 +0000340 original using an unsigned comparison and return
Carlo Kok8c6719b2013-04-23 13:21:19 +0000341 the old one */
Carlo Kokda0ac722013-04-23 13:45:37 +0000342} LLVMAtomicRMWBinOp;
Carlo Kok8c6719b2013-04-23 13:21:19 +0000343
Tom Stellard1580dc72014-04-16 17:45:04 +0000344typedef enum {
345 LLVMDSError,
346 LLVMDSWarning,
347 LLVMDSRemark,
348 LLVMDSNote
349} LLVMDiagnosticSeverity;
350
Gregory Szorc34c863a2012-03-21 03:54:29 +0000351/**
352 * @}
353 */
354
Nick Lewycky0db26542011-05-15 07:20:34 +0000355void LLVMInitializeCore(LLVMPassRegistryRef R);
356
Duncan Sands1cba0a82013-02-17 16:35:51 +0000357/** Deallocate and destroy all ManagedStatic variables.
358 @see llvm::llvm_shutdown
359 @see ManagedStatic */
Benjamin Kramer325ec892013-10-23 16:57:34 +0000360void LLVMShutdown(void);
Duncan Sands1cba0a82013-02-17 16:35:51 +0000361
Gordon Henriksen34eb6d82007-12-19 22:30:40 +0000362/*===-- Error handling ----------------------------------------------------===*/
363
Filip Pizlo3fdbaff2013-05-22 02:46:43 +0000364char *LLVMCreateMessage(const char *Message);
Gordon Henriksen34eb6d82007-12-19 22:30:40 +0000365void LLVMDisposeMessage(char *Message);
366
Filip Pizlo9f50ccd2013-11-03 00:29:47 +0000367/**
Gregory Szorc34c863a2012-03-21 03:54:29 +0000368 * @defgroup LLVMCCoreContext Contexts
369 *
370 * Contexts are execution states for the core LLVM IR system.
371 *
372 * Most types are tied to a context instance. Multiple contexts can
373 * exist simultaneously. A single context is not thread safe. However,
374 * different contexts can execute on different threads simultaneously.
375 *
376 * @{
377 */
Gordon Henriksen76a03742007-09-18 03:18:57 +0000378
Tom Stellard1580dc72014-04-16 17:45:04 +0000379typedef void (*LLVMDiagnosticHandler)(LLVMDiagnosticInfoRef, void *);
Juergen Ributzka34390c72014-05-16 02:33:15 +0000380typedef void (*LLVMYieldCallback)(LLVMContextRef, void *);
Tom Stellard1580dc72014-04-16 17:45:04 +0000381
Gregory Szorc34c863a2012-03-21 03:54:29 +0000382/**
383 * Create a new context.
384 *
385 * Every call to this function should be paired with a call to
386 * LLVMContextDispose() or the context will leak memory.
387 */
Erick Tryzelaarf34cb0c2009-08-30 23:38:06 +0000388LLVMContextRef LLVMContextCreate(void);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000389
390/**
391 * Obtain the global context instance.
392 */
Erick Tryzelaarf34cb0c2009-08-30 23:38:06 +0000393LLVMContextRef LLVMGetGlobalContext(void);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000394
395/**
Tom Stellard1580dc72014-04-16 17:45:04 +0000396 * Set the diagnostic handler for this context.
397 */
398void LLVMContextSetDiagnosticHandler(LLVMContextRef C,
399 LLVMDiagnosticHandler Handler,
400 void *DiagnosticContext);
401
402/**
Juergen Ributzka34390c72014-05-16 02:33:15 +0000403 * Set the yield callback function for this context.
404 *
405 * @see LLVMContext::setYieldCallback()
406 */
407void LLVMContextSetYieldCallback(LLVMContextRef C, LLVMYieldCallback Callback,
408 void *OpaqueHandle);
409
410/**
Gregory Szorc34c863a2012-03-21 03:54:29 +0000411 * Destroy a context instance.
412 *
413 * This should be called for every call to LLVMContextCreate() or memory
414 * will be leaked.
415 */
Owen Anderson6773d382009-07-01 16:58:40 +0000416void LLVMContextDispose(LLVMContextRef C);
417
Tom Stellard1580dc72014-04-16 17:45:04 +0000418/**
419 * Return a string representation of the DiagnosticInfo. Use
420 * LLVMDisposeMessage to free the string.
421 *
422 * @see DiagnosticInfo::print()
423 */
424char *LLVMGetDiagInfoDescription(LLVMDiagnosticInfoRef DI);
425
426/**
427 * Return an enum LLVMDiagnosticSeverity.
428 *
429 * @see DiagnosticInfo::getSeverity()
430 */
431LLVMDiagnosticSeverity LLVMGetDiagInfoSeverity(LLVMDiagnosticInfoRef DI);
432
Amaury Sechet56f056c2016-04-04 22:00:25 +0000433unsigned LLVMGetMDKindIDInContext(LLVMContextRef C, const char *Name,
Erick Tryzelaard8531fa2010-02-28 09:45:59 +0000434 unsigned SLen);
Amaury Sechet56f056c2016-04-04 22:00:25 +0000435unsigned LLVMGetMDKindID(const char *Name, unsigned SLen);
Erick Tryzelaard8531fa2010-02-28 09:45:59 +0000436
Gregory Szorc34c863a2012-03-21 03:54:29 +0000437/**
438 * @}
439 */
440
Gregory Szorc52d26602012-03-21 07:28:27 +0000441/**
442 * @defgroup LLVMCCoreModule Modules
Gregory Szorc34c863a2012-03-21 03:54:29 +0000443 *
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +0000444 * Modules represent the top-level structure in an LLVM program. An LLVM
Gregory Szorc34c863a2012-03-21 03:54:29 +0000445 * module is effectively a translation unit or a collection of
446 * translation units merged together.
447 *
448 * @{
449 */
450
Gregory Szorc34c863a2012-03-21 03:54:29 +0000451/**
452 * Create a new, empty module in the global context.
453 *
454 * This is equivalent to calling LLVMModuleCreateWithNameInContext with
455 * LLVMGetGlobalContext() as the context parameter.
456 *
457 * Every invocation should be paired with LLVMDisposeModule() or memory
458 * will be leaked.
459 */
Gordon Henriksen76a03742007-09-18 03:18:57 +0000460LLVMModuleRef LLVMModuleCreateWithName(const char *ModuleID);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000461
462/**
463 * Create a new, empty module in a specific context.
464 *
465 * Every invocation should be paired with LLVMDisposeModule() or memory
466 * will be leaked.
467 */
Owen Anderson31d44e42009-07-02 07:17:57 +0000468LLVMModuleRef LLVMModuleCreateWithNameInContext(const char *ModuleID,
469 LLVMContextRef C);
Tom Stellard0a4e9a32014-10-01 17:14:57 +0000470/**
471 * Return an exact copy of the specified module.
472 */
473LLVMModuleRef LLVMCloneModule(LLVMModuleRef M);
Gordon Henriksena49d4352008-03-07 19:13:06 +0000474
Gregory Szorc34c863a2012-03-21 03:54:29 +0000475/**
476 * Destroy a module instance.
477 *
478 * This must be called for every created module or memory will be
479 * leaked.
480 */
Gordon Henriksen76a03742007-09-18 03:18:57 +0000481void LLVMDisposeModule(LLVMModuleRef M);
482
Gregory Szorc34c863a2012-03-21 03:54:29 +0000483/**
Peter Zotov0a2fa0a2016-04-05 13:56:59 +0000484 * Obtain the identifier of a module.
485 *
486 * @param M Module to obtain identifier of
487 * @param Len Out parameter which holds the length of the returned string.
488 * @return The identifier of M.
489 * @see Module::getModuleIdentifier()
490 */
491const char *LLVMGetModuleIdentifier(LLVMModuleRef M, size_t *Len);
492
493/**
494 * Set the identifier of a module to a string Ident with length Len.
495 *
496 * @param M The module to set identifier
497 * @param Ident The string to set M's identifier to
498 * @param Len Length of Ident
499 * @see Module::setModuleIdentifier()
500 */
501void LLVMSetModuleIdentifier(LLVMModuleRef M, const char *Ident, size_t Len);
502
503/**
Gregory Szorc34c863a2012-03-21 03:54:29 +0000504 * Obtain the data layout for a module.
505 *
Amaury Sechetf3549c42016-02-16 00:23:52 +0000506 * @see Module::getDataLayoutStr()
507 *
508 * LLVMGetDataLayout is DEPRECATED, as the name is not only incorrect,
509 * but match the name of another method on the module. Prefer the use
510 * of LLVMGetDataLayoutStr, which is not ambiguous.
Gregory Szorc34c863a2012-03-21 03:54:29 +0000511 */
Amaury Sechetf3549c42016-02-16 00:23:52 +0000512const char *LLVMGetDataLayoutStr(LLVMModuleRef M);
Gordon Henriksen05568bb2007-12-27 20:13:47 +0000513const char *LLVMGetDataLayout(LLVMModuleRef M);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000514
515/**
516 * Set the data layout for a module.
517 *
518 * @see Module::setDataLayout()
519 */
Amaury Sechet6ada31c2016-02-15 23:40:06 +0000520void LLVMSetDataLayout(LLVMModuleRef M, const char *DataLayoutStr);
Gordon Henriksen05568bb2007-12-27 20:13:47 +0000521
Gregory Szorc34c863a2012-03-21 03:54:29 +0000522/**
523 * Obtain the target triple for a module.
524 *
525 * @see Module::getTargetTriple()
526 */
Gordon Henriksen05568bb2007-12-27 20:13:47 +0000527const char *LLVMGetTarget(LLVMModuleRef M);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000528
529/**
530 * Set the target triple for a module.
531 *
532 * @see Module::setTargetTriple()
533 */
Gordon Henriksen05568bb2007-12-27 20:13:47 +0000534void LLVMSetTarget(LLVMModuleRef M, const char *Triple);
535
Gregory Szorc34c863a2012-03-21 03:54:29 +0000536/**
537 * Dump a representation of a module to stderr.
538 *
539 * @see Module::dump()
540 */
Gordon Henriksen6c6075e2008-03-14 23:58:56 +0000541void LLVMDumpModule(LLVMModuleRef M);
542
Gregory Szorc34c863a2012-03-21 03:54:29 +0000543/**
Hans Wennborgb7ef2fe2012-05-09 16:54:17 +0000544 * Print a representation of a module to a file. The ErrorMessage needs to be
545 * disposed with LLVMDisposeMessage. Returns 0 on success, 1 otherwise.
546 *
547 * @see Module::print()
548 */
549LLVMBool LLVMPrintModuleToFile(LLVMModuleRef M, const char *Filename,
550 char **ErrorMessage);
551
552/**
Anders Waldenborg84355db2013-10-16 18:00:54 +0000553 * Return a string representation of the module. Use
554 * LLVMDisposeMessage to free the string.
555 *
556 * @see Module::print()
557 */
558char *LLVMPrintModuleToString(LLVMModuleRef M);
559
560/**
Gregory Szorc34c863a2012-03-21 03:54:29 +0000561 * Set inline assembly for a module.
562 *
563 * @see Module::setModuleInlineAsm()
564 */
Chris Lattner26941452010-04-10 17:52:58 +0000565void LLVMSetModuleInlineAsm(LLVMModuleRef M, const char *Asm);
Gordon Henriksen76a03742007-09-18 03:18:57 +0000566
Gregory Szorc34c863a2012-03-21 03:54:29 +0000567/**
568 * Obtain the context to which this module is associated.
569 *
570 * @see Module::getContext()
571 */
Chris Lattnera7e04b02010-11-28 20:03:44 +0000572LLVMContextRef LLVMGetModuleContext(LLVMModuleRef M);
573
Gregory Szorc34c863a2012-03-21 03:54:29 +0000574/**
575 * Obtain a Type from a module by its registered name.
576 */
577LLVMTypeRef LLVMGetTypeByName(LLVMModuleRef M, const char *Name);
Gordon Henriksen76a03742007-09-18 03:18:57 +0000578
Gregory Szorc34c863a2012-03-21 03:54:29 +0000579/**
580 * Obtain the number of operands for named metadata in a module.
581 *
582 * @see llvm::Module::getNamedMetadata()
583 */
584unsigned LLVMGetNamedMetadataNumOperands(LLVMModuleRef M, const char* name);
585
586/**
587 * Obtain the named metadata operands for a module.
588 *
589 * The passed LLVMValueRef pointer should refer to an array of
590 * LLVMValueRef at least LLVMGetNamedMetadataNumOperands long. This
591 * array will be populated with the LLVMValueRef instances. Each
592 * instance corresponds to a llvm::MDNode.
593 *
594 * @see llvm::Module::getNamedMetadata()
595 * @see llvm::MDNode::getOperand()
596 */
597void LLVMGetNamedMetadataOperands(LLVMModuleRef M, const char* name, LLVMValueRef *Dest);
598
599/**
600 * Add an operand to named metadata.
601 *
602 * @see llvm::Module::getNamedMetadata()
603 * @see llvm::MDNode::addOperand()
604 */
605void LLVMAddNamedMetadataOperand(LLVMModuleRef M, const char* name,
606 LLVMValueRef Val);
607
Gregory Szorc52d26602012-03-21 07:28:27 +0000608/**
609 * Add a function to a module under a specified name.
610 *
611 * @see llvm::Function::Create()
612 */
613LLVMValueRef LLVMAddFunction(LLVMModuleRef M, const char *Name,
614 LLVMTypeRef FunctionTy);
615
616/**
617 * Obtain a Function value from a Module by its name.
618 *
619 * The returned value corresponds to a llvm::Function value.
620 *
621 * @see llvm::Module::getFunction()
622 */
623LLVMValueRef LLVMGetNamedFunction(LLVMModuleRef M, const char *Name);
624
625/**
626 * Obtain an iterator to the first Function in a Module.
627 *
628 * @see llvm::Module::begin()
629 */
630LLVMValueRef LLVMGetFirstFunction(LLVMModuleRef M);
631
632/**
633 * Obtain an iterator to the last Function in a Module.
634 *
635 * @see llvm::Module::end()
636 */
637LLVMValueRef LLVMGetLastFunction(LLVMModuleRef M);
638
639/**
640 * Advance a Function iterator to the next Function.
641 *
642 * Returns NULL if the iterator was already at the end and there are no more
643 * functions.
644 */
645LLVMValueRef LLVMGetNextFunction(LLVMValueRef Fn);
646
647/**
648 * Decrement a Function iterator to the previous Function.
649 *
650 * Returns NULL if the iterator was already at the beginning and there are
651 * no previous functions.
652 */
653LLVMValueRef LLVMGetPreviousFunction(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000654
655/**
656 * @}
657 */
658
659/**
660 * @defgroup LLVMCCoreType Types
661 *
662 * Types represent the type of a value.
663 *
664 * Types are associated with a context instance. The context internally
665 * deduplicates types so there is only 1 instance of a specific type
666 * alive at a time. In other words, a unique type is shared among all
667 * consumers within a context.
668 *
669 * A Type in the C API corresponds to llvm::Type.
670 *
671 * Types have the following hierarchy:
672 *
Gordon Henriksen76a03742007-09-18 03:18:57 +0000673 * types:
674 * integer type
675 * real type
676 * function type
677 * sequence types:
678 * array type
679 * pointer type
680 * vector type
681 * void type
682 * label type
683 * opaque type
Gregory Szorc34c863a2012-03-21 03:54:29 +0000684 *
685 * @{
Gordon Henriksen76a03742007-09-18 03:18:57 +0000686 */
687
Gregory Szorc34c863a2012-03-21 03:54:29 +0000688/**
689 * Obtain the enumerated type of a Type instance.
690 *
691 * @see llvm::Type:getTypeID()
692 */
Gordon Henriksen76a03742007-09-18 03:18:57 +0000693LLVMTypeKind LLVMGetTypeKind(LLVMTypeRef Ty);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000694
695/**
696 * Whether the type has a known size.
697 *
698 * Things that don't have a size are abstract types, labels, and void.a
699 *
700 * @see llvm::Type::isSized()
701 */
Torok Edwin1cd9ade2011-10-06 12:13:28 +0000702LLVMBool LLVMTypeIsSized(LLVMTypeRef Ty);
Gordon Henriksena49d4352008-03-07 19:13:06 +0000703
Gregory Szorc34c863a2012-03-21 03:54:29 +0000704/**
705 * Obtain the context to which this type instance is associated.
706 *
707 * @see llvm::Type::getContext()
708 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +0000709LLVMContextRef LLVMGetTypeContext(LLVMTypeRef Ty);
710
Gregory Szorc34c863a2012-03-21 03:54:29 +0000711/**
Anders Waldenborgb822cff2013-10-16 21:30:25 +0000712 * Dump a representation of a type to stderr.
713 *
714 * @see llvm::Type::dump()
715 */
716void LLVMDumpType(LLVMTypeRef Val);
717
718/**
Anders Waldenborg47b3bd32013-10-22 06:58:34 +0000719 * Return a string representation of the type. Use
720 * LLVMDisposeMessage to free the string.
721 *
722 * @see llvm::Type::print()
723 */
724char *LLVMPrintTypeToString(LLVMTypeRef Val);
725
726/**
Gregory Szorc34c863a2012-03-21 03:54:29 +0000727 * @defgroup LLVMCCoreTypeInt Integer Types
728 *
729 * Functions in this section operate on integer types.
730 *
731 * @{
732 */
733
734/**
735 * Obtain an integer type from a context with specified bit width.
736 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +0000737LLVMTypeRef LLVMInt1TypeInContext(LLVMContextRef C);
738LLVMTypeRef LLVMInt8TypeInContext(LLVMContextRef C);
739LLVMTypeRef LLVMInt16TypeInContext(LLVMContextRef C);
740LLVMTypeRef LLVMInt32TypeInContext(LLVMContextRef C);
741LLVMTypeRef LLVMInt64TypeInContext(LLVMContextRef C);
Eugene Zelenkoffec81c2015-11-04 22:32:32 +0000742LLVMTypeRef LLVMInt128TypeInContext(LLVMContextRef C);
Erick Tryzelaar262332f2009-08-14 00:01:31 +0000743LLVMTypeRef LLVMIntTypeInContext(LLVMContextRef C, unsigned NumBits);
744
Gregory Szorc34c863a2012-03-21 03:54:29 +0000745/**
746 * Obtain an integer type from the global context with a specified bit
747 * width.
748 */
Gordon Henriksena735a9c2008-05-04 12:55:34 +0000749LLVMTypeRef LLVMInt1Type(void);
750LLVMTypeRef LLVMInt8Type(void);
751LLVMTypeRef LLVMInt16Type(void);
752LLVMTypeRef LLVMInt32Type(void);
753LLVMTypeRef LLVMInt64Type(void);
Eugene Zelenkoffec81c2015-11-04 22:32:32 +0000754LLVMTypeRef LLVMInt128Type(void);
Gordon Henriksened7beaa2007-10-06 16:05:20 +0000755LLVMTypeRef LLVMIntType(unsigned NumBits);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +0000756unsigned LLVMGetIntTypeWidth(LLVMTypeRef IntegerTy);
Gordon Henriksen76a03742007-09-18 03:18:57 +0000757
Gregory Szorc34c863a2012-03-21 03:54:29 +0000758/**
759 * @}
760 */
761
762/**
763 * @defgroup LLVMCCoreTypeFloat Floating Point Types
764 *
765 * @{
766 */
767
768/**
769 * Obtain a 16-bit floating point type from a context.
770 */
Dan Gohman518cda42011-12-17 00:04:22 +0000771LLVMTypeRef LLVMHalfTypeInContext(LLVMContextRef C);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000772
773/**
774 * Obtain a 32-bit floating point type from a context.
775 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +0000776LLVMTypeRef LLVMFloatTypeInContext(LLVMContextRef C);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000777
778/**
779 * Obtain a 64-bit floating point type from a context.
780 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +0000781LLVMTypeRef LLVMDoubleTypeInContext(LLVMContextRef C);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000782
783/**
784 * Obtain a 80-bit floating point type (X87) from a context.
785 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +0000786LLVMTypeRef LLVMX86FP80TypeInContext(LLVMContextRef C);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000787
788/**
789 * Obtain a 128-bit floating point type (112-bit mantissa) from a
790 * context.
791 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +0000792LLVMTypeRef LLVMFP128TypeInContext(LLVMContextRef C);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000793
794/**
795 * Obtain a 128-bit floating point type (two 64-bits) from a context.
796 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +0000797LLVMTypeRef LLVMPPCFP128TypeInContext(LLVMContextRef C);
798
Gregory Szorc34c863a2012-03-21 03:54:29 +0000799/**
800 * Obtain a floating point type from the global context.
801 *
802 * These map to the functions in this group of the same name.
803 */
Dan Gohman518cda42011-12-17 00:04:22 +0000804LLVMTypeRef LLVMHalfType(void);
Gordon Henriksena735a9c2008-05-04 12:55:34 +0000805LLVMTypeRef LLVMFloatType(void);
806LLVMTypeRef LLVMDoubleType(void);
807LLVMTypeRef LLVMX86FP80Type(void);
808LLVMTypeRef LLVMFP128Type(void);
809LLVMTypeRef LLVMPPCFP128Type(void);
Gordon Henriksen76a03742007-09-18 03:18:57 +0000810
Gregory Szorc34c863a2012-03-21 03:54:29 +0000811/**
812 * @}
813 */
814
815/**
816 * @defgroup LLVMCCoreTypeFunction Function Types
817 *
818 * @{
819 */
820
821/**
822 * Obtain a function type consisting of a specified signature.
823 *
824 * The function is defined as a tuple of a return Type, a list of
825 * parameter types, and whether the function is variadic.
826 */
Gordon Henriksened7beaa2007-10-06 16:05:20 +0000827LLVMTypeRef LLVMFunctionType(LLVMTypeRef ReturnType,
828 LLVMTypeRef *ParamTypes, unsigned ParamCount,
Chris Lattner25963c62010-01-09 22:27:07 +0000829 LLVMBool IsVarArg);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000830
831/**
832 * Returns whether a function type is variadic.
833 */
Chris Lattner25963c62010-01-09 22:27:07 +0000834LLVMBool LLVMIsFunctionVarArg(LLVMTypeRef FunctionTy);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000835
836/**
837 * Obtain the Type this function Type returns.
838 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +0000839LLVMTypeRef LLVMGetReturnType(LLVMTypeRef FunctionTy);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000840
841/**
842 * Obtain the number of parameters this function accepts.
843 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +0000844unsigned LLVMCountParamTypes(LLVMTypeRef FunctionTy);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000845
846/**
847 * Obtain the types of a function's parameters.
848 *
849 * The Dest parameter should point to a pre-allocated array of
850 * LLVMTypeRef at least LLVMCountParamTypes() large. On return, the
851 * first LLVMCountParamTypes() entries in the array will be populated
852 * with LLVMTypeRef instances.
853 *
854 * @param FunctionTy The function type to operate on.
855 * @param Dest Memory address of an array to be filled with result.
856 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +0000857void LLVMGetParamTypes(LLVMTypeRef FunctionTy, LLVMTypeRef *Dest);
Gordon Henriksen76a03742007-09-18 03:18:57 +0000858
Gregory Szorc34c863a2012-03-21 03:54:29 +0000859/**
860 * @}
861 */
862
863/**
864 * @defgroup LLVMCCoreTypeStruct Structure Types
865 *
866 * These functions relate to LLVMTypeRef instances.
867 *
868 * @see llvm::StructType
869 *
870 * @{
871 */
872
873/**
874 * Create a new structure type in a context.
875 *
876 * A structure is specified by a list of inner elements/types and
877 * whether these can be packed together.
878 *
879 * @see llvm::StructType::create()
880 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +0000881LLVMTypeRef LLVMStructTypeInContext(LLVMContextRef C, LLVMTypeRef *ElementTypes,
Chris Lattner25963c62010-01-09 22:27:07 +0000882 unsigned ElementCount, LLVMBool Packed);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000883
884/**
885 * Create a new structure type in the global context.
886 *
887 * @see llvm::StructType::create()
888 */
Gordon Henriksened7beaa2007-10-06 16:05:20 +0000889LLVMTypeRef LLVMStructType(LLVMTypeRef *ElementTypes, unsigned ElementCount,
Chris Lattner25963c62010-01-09 22:27:07 +0000890 LLVMBool Packed);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000891
892/**
893 * Create an empty structure in a context having a specified name.
894 *
895 * @see llvm::StructType::create()
896 */
Chris Lattnere71ccde2011-07-14 05:53:17 +0000897LLVMTypeRef LLVMStructCreateNamed(LLVMContextRef C, const char *Name);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000898
899/**
900 * Obtain the name of a structure.
901 *
902 * @see llvm::StructType::getName()
903 */
Torok Edwin0d5f6ae2011-10-06 12:12:50 +0000904const char *LLVMGetStructName(LLVMTypeRef Ty);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000905
906/**
907 * Set the contents of a structure type.
908 *
909 * @see llvm::StructType::setBody()
910 */
Chris Lattnere71ccde2011-07-14 05:53:17 +0000911void LLVMStructSetBody(LLVMTypeRef StructTy, LLVMTypeRef *ElementTypes,
912 unsigned ElementCount, LLVMBool Packed);
913
Gregory Szorc34c863a2012-03-21 03:54:29 +0000914/**
915 * Get the number of elements defined inside the structure.
916 *
917 * @see llvm::StructType::getNumElements()
918 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +0000919unsigned LLVMCountStructElementTypes(LLVMTypeRef StructTy);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000920
921/**
922 * Get the elements within a structure.
923 *
924 * The function is passed the address of a pre-allocated array of
925 * LLVMTypeRef at least LLVMCountStructElementTypes() long. After
926 * invocation, this array will be populated with the structure's
927 * elements. The objects in the destination array will have a lifetime
928 * of the structure type itself, which is the lifetime of the context it
929 * is contained in.
930 */
Gordon Henriksen76a03742007-09-18 03:18:57 +0000931void LLVMGetStructElementTypes(LLVMTypeRef StructTy, LLVMTypeRef *Dest);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000932
933/**
Peter Zotovc164a3f2015-06-04 09:09:53 +0000934 * Get the type of the element at a given index in the structure.
935 *
936 * @see llvm::StructType::getTypeAtIndex()
937 */
938LLVMTypeRef LLVMStructGetTypeAtIndex(LLVMTypeRef StructTy, unsigned i);
939
940/**
Gregory Szorc34c863a2012-03-21 03:54:29 +0000941 * Determine whether a structure is packed.
942 *
943 * @see llvm::StructType::isPacked()
944 */
Chris Lattner25963c62010-01-09 22:27:07 +0000945LLVMBool LLVMIsPackedStruct(LLVMTypeRef StructTy);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000946
947/**
948 * Determine whether a structure is opaque.
949 *
950 * @see llvm::StructType::isOpaque()
951 */
Chris Lattner17cf05b2011-07-14 16:20:28 +0000952LLVMBool LLVMIsOpaqueStruct(LLVMTypeRef StructTy);
953
Gregory Szorc34c863a2012-03-21 03:54:29 +0000954/**
955 * @}
956 */
Gordon Henriksen76a03742007-09-18 03:18:57 +0000957
Gregory Szorc34c863a2012-03-21 03:54:29 +0000958/**
959 * @defgroup LLVMCCoreTypeSequential Sequential Types
960 *
961 * Sequential types represents "arrays" of types. This is a super class
962 * for array, vector, and pointer types.
963 *
964 * @{
965 */
966
967/**
968 * Obtain the type of elements within a sequential type.
969 *
970 * This works on array, vector, and pointer types.
971 *
972 * @see llvm::SequentialType::getElementType()
973 */
974LLVMTypeRef LLVMGetElementType(LLVMTypeRef Ty);
975
976/**
977 * Create a fixed size array type that refers to a specific type.
978 *
979 * The created type will exist in the context that its element type
980 * exists in.
981 *
982 * @see llvm::ArrayType::get()
983 */
Gordon Henriksened7beaa2007-10-06 16:05:20 +0000984LLVMTypeRef LLVMArrayType(LLVMTypeRef ElementType, unsigned ElementCount);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000985
986/**
987 * Obtain the length of an array type.
988 *
989 * This only works on types that represent arrays.
990 *
991 * @see llvm::ArrayType::getNumElements()
992 */
993unsigned LLVMGetArrayLength(LLVMTypeRef ArrayTy);
994
995/**
996 * Create a pointer type that points to a defined type.
997 *
998 * The created type will exist in the context that its pointee type
999 * exists in.
1000 *
1001 * @see llvm::PointerType::get()
1002 */
Gordon Henriksen5a3fe032007-12-17 16:08:32 +00001003LLVMTypeRef LLVMPointerType(LLVMTypeRef ElementType, unsigned AddressSpace);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001004
1005/**
1006 * Obtain the address space of a pointer type.
1007 *
1008 * This only works on types that represent pointers.
1009 *
1010 * @see llvm::PointerType::getAddressSpace()
1011 */
1012unsigned LLVMGetPointerAddressSpace(LLVMTypeRef PointerTy);
1013
1014/**
1015 * Create a vector type that contains a defined type and has a specific
1016 * number of elements.
1017 *
1018 * The created type will exist in the context thats its element type
1019 * exists in.
1020 *
1021 * @see llvm::VectorType::get()
1022 */
Gordon Henriksened7beaa2007-10-06 16:05:20 +00001023LLVMTypeRef LLVMVectorType(LLVMTypeRef ElementType, unsigned ElementCount);
Gordon Henriksen76a03742007-09-18 03:18:57 +00001024
Gregory Szorc34c863a2012-03-21 03:54:29 +00001025/**
1026 * Obtain the number of elements in a vector type.
1027 *
1028 * This only works on types that represent vectors.
1029 *
1030 * @see llvm::VectorType::getNumElements()
1031 */
Gordon Henriksen76a03742007-09-18 03:18:57 +00001032unsigned LLVMGetVectorSize(LLVMTypeRef VectorTy);
1033
Gregory Szorc34c863a2012-03-21 03:54:29 +00001034/**
1035 * @}
1036 */
1037
1038/**
1039 * @defgroup LLVMCCoreTypeOther Other Types
1040 *
1041 * @{
1042 */
1043
1044/**
1045 * Create a void type in a context.
1046 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +00001047LLVMTypeRef LLVMVoidTypeInContext(LLVMContextRef C);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001048
1049/**
1050 * Create a label type in a context.
1051 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +00001052LLVMTypeRef LLVMLabelTypeInContext(LLVMContextRef C);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001053
1054/**
1055 * Create a X86 MMX type in a context.
1056 */
Dale Johannesen95b67af2010-09-10 21:58:02 +00001057LLVMTypeRef LLVMX86MMXTypeInContext(LLVMContextRef C);
Erick Tryzelaar262332f2009-08-14 00:01:31 +00001058
Gregory Szorc34c863a2012-03-21 03:54:29 +00001059/**
1060 * These are similar to the above functions except they operate on the
1061 * global context.
1062 */
Gordon Henriksena735a9c2008-05-04 12:55:34 +00001063LLVMTypeRef LLVMVoidType(void);
1064LLVMTypeRef LLVMLabelType(void);
Dale Johannesen95b67af2010-09-10 21:58:02 +00001065LLVMTypeRef LLVMX86MMXType(void);
Gordon Henriksen76a03742007-09-18 03:18:57 +00001066
Gregory Szorc34c863a2012-03-21 03:54:29 +00001067/**
1068 * @}
1069 */
Gordon Henriksen76a03742007-09-18 03:18:57 +00001070
Gregory Szorc34c863a2012-03-21 03:54:29 +00001071/**
1072 * @}
1073 */
1074
1075/**
1076 * @defgroup LLVMCCoreValues Values
1077 *
1078 * The bulk of LLVM's object model consists of values, which comprise a very
Gordon Henriksen76a03742007-09-18 03:18:57 +00001079 * rich type hierarchy.
Gregory Szorc34c863a2012-03-21 03:54:29 +00001080 *
1081 * LLVMValueRef essentially represents llvm::Value. There is a rich
1082 * hierarchy of classes within this type. Depending on the instance
Eli Benderskyc52863c2012-08-10 18:30:44 +00001083 * obtained, not all APIs are available.
Gregory Szorc34c863a2012-03-21 03:54:29 +00001084 *
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00001085 * Callers can determine the type of an LLVMValueRef by calling the
Gregory Szorc34c863a2012-03-21 03:54:29 +00001086 * LLVMIsA* family of functions (e.g. LLVMIsAArgument()). These
1087 * functions are defined by a macro, so it isn't obvious which are
1088 * available by looking at the Doxygen source code. Instead, look at the
1089 * source definition of LLVM_FOR_EACH_VALUE_SUBCLASS and note the list
1090 * of value names given. These value names also correspond to classes in
1091 * the llvm::Value hierarchy.
1092 *
1093 * @{
Gordon Henriksen76a03742007-09-18 03:18:57 +00001094 */
1095
Gordon Henriksen29e38942008-12-19 18:39:45 +00001096#define LLVM_FOR_EACH_VALUE_SUBCLASS(macro) \
1097 macro(Argument) \
1098 macro(BasicBlock) \
1099 macro(InlineAsm) \
1100 macro(User) \
1101 macro(Constant) \
Torok Edwind09b7572011-10-14 20:37:56 +00001102 macro(BlockAddress) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001103 macro(ConstantAggregateZero) \
1104 macro(ConstantArray) \
Peter Zotovae0344b2013-11-05 12:55:37 +00001105 macro(ConstantDataSequential) \
1106 macro(ConstantDataArray) \
1107 macro(ConstantDataVector) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001108 macro(ConstantExpr) \
1109 macro(ConstantFP) \
1110 macro(ConstantInt) \
1111 macro(ConstantPointerNull) \
1112 macro(ConstantStruct) \
David Majnemerf0f224d2015-11-11 21:57:16 +00001113 macro(ConstantTokenNone) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001114 macro(ConstantVector) \
1115 macro(GlobalValue) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001116 macro(GlobalAlias) \
Rafael Espindola99e05cf2014-05-13 18:45:48 +00001117 macro(GlobalObject) \
1118 macro(Function) \
1119 macro(GlobalVariable) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001120 macro(UndefValue) \
1121 macro(Instruction) \
1122 macro(BinaryOperator) \
1123 macro(CallInst) \
1124 macro(IntrinsicInst) \
1125 macro(DbgInfoIntrinsic) \
1126 macro(DbgDeclareInst) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001127 macro(MemIntrinsic) \
1128 macro(MemCpyInst) \
1129 macro(MemMoveInst) \
1130 macro(MemSetInst) \
1131 macro(CmpInst) \
Torok Edwind09b7572011-10-14 20:37:56 +00001132 macro(FCmpInst) \
1133 macro(ICmpInst) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001134 macro(ExtractElementInst) \
1135 macro(GetElementPtrInst) \
1136 macro(InsertElementInst) \
1137 macro(InsertValueInst) \
Bill Wendlingfae14752011-08-12 20:24:12 +00001138 macro(LandingPadInst) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001139 macro(PHINode) \
1140 macro(SelectInst) \
1141 macro(ShuffleVectorInst) \
1142 macro(StoreInst) \
1143 macro(TerminatorInst) \
1144 macro(BranchInst) \
Torok Edwind09b7572011-10-14 20:37:56 +00001145 macro(IndirectBrInst) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001146 macro(InvokeInst) \
1147 macro(ReturnInst) \
1148 macro(SwitchInst) \
1149 macro(UnreachableInst) \
Bill Wendlingf891bf82011-07-31 06:30:59 +00001150 macro(ResumeInst) \
David Majnemer654e1302015-07-31 17:58:14 +00001151 macro(CleanupReturnInst) \
1152 macro(CatchReturnInst) \
David Majnemer8a1c45d2015-12-12 05:38:55 +00001153 macro(FuncletPadInst) \
1154 macro(CatchPadInst) \
1155 macro(CleanupPadInst) \
Duncan Sands5e37e992013-05-06 08:55:45 +00001156 macro(UnaryInstruction) \
1157 macro(AllocaInst) \
1158 macro(CastInst) \
Matt Arsenaultb03bd4d2013-11-15 01:34:59 +00001159 macro(AddrSpaceCastInst) \
Duncan Sands5e37e992013-05-06 08:55:45 +00001160 macro(BitCastInst) \
1161 macro(FPExtInst) \
1162 macro(FPToSIInst) \
1163 macro(FPToUIInst) \
1164 macro(FPTruncInst) \
1165 macro(IntToPtrInst) \
1166 macro(PtrToIntInst) \
1167 macro(SExtInst) \
1168 macro(SIToFPInst) \
1169 macro(TruncInst) \
1170 macro(UIToFPInst) \
1171 macro(ZExtInst) \
1172 macro(ExtractValueInst) \
1173 macro(LoadInst) \
1174 macro(VAArgInst)
Gordon Henriksen29e38942008-12-19 18:39:45 +00001175
Gregory Szorc34c863a2012-03-21 03:54:29 +00001176/**
1177 * @defgroup LLVMCCoreValueGeneral General APIs
1178 *
1179 * Functions in this section work on all LLVMValueRef instances,
1180 * regardless of their sub-type. They correspond to functions available
1181 * on llvm::Value.
1182 *
1183 * @{
1184 */
Gordon Henriksen76a03742007-09-18 03:18:57 +00001185
Gregory Szorc34c863a2012-03-21 03:54:29 +00001186/**
1187 * Obtain the type of a value.
1188 *
1189 * @see llvm::Value::getType()
1190 */
1191LLVMTypeRef LLVMTypeOf(LLVMValueRef Val);
1192
1193/**
1194 * Obtain the string name of a value.
1195 *
1196 * @see llvm::Value::getName()
1197 */
1198const char *LLVMGetValueName(LLVMValueRef Val);
1199
1200/**
1201 * Set the string name of a value.
1202 *
1203 * @see llvm::Value::setName()
1204 */
1205void LLVMSetValueName(LLVMValueRef Val, const char *Name);
1206
1207/**
1208 * Dump a representation of a value to stderr.
1209 *
1210 * @see llvm::Value::dump()
1211 */
1212void LLVMDumpValue(LLVMValueRef Val);
1213
1214/**
Peter Zotovcd93b372013-11-06 09:21:01 +00001215 * Return a string representation of the value. Use
1216 * LLVMDisposeMessage to free the string.
1217 *
1218 * @see llvm::Value::print()
1219 */
1220char *LLVMPrintValueToString(LLVMValueRef Val);
1221
1222/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00001223 * Replace all uses of a value with another one.
1224 *
1225 * @see llvm::Value::replaceAllUsesWith()
1226 */
1227void LLVMReplaceAllUsesWith(LLVMValueRef OldVal, LLVMValueRef NewVal);
1228
1229/**
Amaury Sechet1c395072016-01-18 01:06:52 +00001230 * Determine whether the specified value instance is constant.
Gregory Szorc34c863a2012-03-21 03:54:29 +00001231 */
1232LLVMBool LLVMIsConstant(LLVMValueRef Val);
1233
1234/**
1235 * Determine whether a value instance is undefined.
1236 */
1237LLVMBool LLVMIsUndef(LLVMValueRef Val);
1238
1239/**
1240 * Convert value instances between types.
1241 *
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00001242 * Internally, an LLVMValueRef is "pinned" to a specific type. This
Gregory Szorc34c863a2012-03-21 03:54:29 +00001243 * series of functions allows you to cast an instance to a specific
1244 * type.
1245 *
1246 * If the cast is not valid for the specified type, NULL is returned.
1247 *
1248 * @see llvm::dyn_cast_or_null<>
1249 */
Gordon Henriksen29e38942008-12-19 18:39:45 +00001250#define LLVM_DECLARE_VALUE_CAST(name) \
1251 LLVMValueRef LLVMIsA##name(LLVMValueRef Val);
1252LLVM_FOR_EACH_VALUE_SUBCLASS(LLVM_DECLARE_VALUE_CAST)
1253
Duncan P. N. Exon Smith5bf8fef2014-12-09 18:38:53 +00001254LLVMValueRef LLVMIsAMDNode(LLVMValueRef Val);
1255LLVMValueRef LLVMIsAMDString(LLVMValueRef Val);
1256
Gregory Szorc34c863a2012-03-21 03:54:29 +00001257/**
1258 * @}
1259 */
1260
1261/**
1262 * @defgroup LLVMCCoreValueUses Usage
1263 *
1264 * This module defines functions that allow you to inspect the uses of a
1265 * LLVMValueRef.
1266 *
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00001267 * It is possible to obtain an LLVMUseRef for any LLVMValueRef instance.
Gregory Szorc34c863a2012-03-21 03:54:29 +00001268 * Each LLVMUseRef (which corresponds to a llvm::Use instance) holds a
1269 * llvm::User and llvm::Value.
1270 *
1271 * @{
1272 */
1273
1274/**
1275 * Obtain the first use of a value.
1276 *
1277 * Uses are obtained in an iterator fashion. First, call this function
1278 * to obtain a reference to the first use. Then, call LLVMGetNextUse()
Eli Benderskyc52863c2012-08-10 18:30:44 +00001279 * on that instance and all subsequently obtained instances until
Gregory Szorc34c863a2012-03-21 03:54:29 +00001280 * LLVMGetNextUse() returns NULL.
1281 *
1282 * @see llvm::Value::use_begin()
1283 */
Erick Tryzelaar9f9857e2010-03-02 20:32:28 +00001284LLVMUseRef LLVMGetFirstUse(LLVMValueRef Val);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001285
1286/**
1287 * Obtain the next use of a value.
1288 *
1289 * This effectively advances the iterator. It returns NULL if you are on
1290 * the final use and no more are available.
1291 */
Erick Tryzelaar9f9857e2010-03-02 20:32:28 +00001292LLVMUseRef LLVMGetNextUse(LLVMUseRef U);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001293
1294/**
1295 * Obtain the user value for a user.
1296 *
1297 * The returned value corresponds to a llvm::User type.
1298 *
1299 * @see llvm::Use::getUser()
1300 */
Erick Tryzelaar9f9857e2010-03-02 20:32:28 +00001301LLVMValueRef LLVMGetUser(LLVMUseRef U);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001302
1303/**
1304 * Obtain the value this use corresponds to.
1305 *
1306 * @see llvm::Use::get().
1307 */
Erick Tryzelaar9f9857e2010-03-02 20:32:28 +00001308LLVMValueRef LLVMGetUsedValue(LLVMUseRef U);
Chris Lattner40cf28d2009-10-12 04:01:02 +00001309
Gregory Szorc34c863a2012-03-21 03:54:29 +00001310/**
1311 * @}
1312 */
1313
1314/**
Gregory Szorc52d26602012-03-21 07:28:27 +00001315 * @defgroup LLVMCCoreValueUser User value
Gregory Szorc34c863a2012-03-21 03:54:29 +00001316 *
1317 * Function in this group pertain to LLVMValueRef instances that descent
1318 * from llvm::User. This includes constants, instructions, and
1319 * operators.
1320 *
1321 * @{
1322 */
1323
1324/**
1325 * Obtain an operand at a specific index in a llvm::User value.
1326 *
1327 * @see llvm::User::getOperand()
1328 */
Chris Lattner40cf28d2009-10-12 04:01:02 +00001329LLVMValueRef LLVMGetOperand(LLVMValueRef Val, unsigned Index);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001330
1331/**
Peter Zotovb19f78f2014-08-12 02:55:40 +00001332 * Obtain the use of an operand at a specific index in a llvm::User value.
1333 *
1334 * @see llvm::User::getOperandUse()
1335 */
1336LLVMUseRef LLVMGetOperandUse(LLVMValueRef Val, unsigned Index);
1337
1338/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00001339 * Set an operand at a specific index in a llvm::User value.
1340 *
1341 * @see llvm::User::setOperand()
1342 */
Erick Tryzelaarb4d48702010-08-20 14:51:22 +00001343void LLVMSetOperand(LLVMValueRef User, unsigned Index, LLVMValueRef Val);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001344
1345/**
1346 * Obtain the number of operands in a llvm::User value.
1347 *
1348 * @see llvm::User::getNumOperands()
1349 */
Erick Tryzelaarb4d48702010-08-20 14:51:22 +00001350int LLVMGetNumOperands(LLVMValueRef Val);
Chris Lattner40cf28d2009-10-12 04:01:02 +00001351
Gregory Szorc34c863a2012-03-21 03:54:29 +00001352/**
1353 * @}
1354 */
1355
1356/**
Gregory Szorc52d26602012-03-21 07:28:27 +00001357 * @defgroup LLVMCCoreValueConstant Constants
Gregory Szorc34c863a2012-03-21 03:54:29 +00001358 *
1359 * This section contains APIs for interacting with LLVMValueRef that
1360 * correspond to llvm::Constant instances.
1361 *
1362 * These functions will work for any LLVMValueRef in the llvm::Constant
1363 * class hierarchy.
1364 *
1365 * @{
1366 */
1367
1368/**
1369 * Obtain a constant value referring to the null instance of a type.
1370 *
1371 * @see llvm::Constant::getNullValue()
1372 */
Gordon Henriksen1046c732007-10-06 15:11:06 +00001373LLVMValueRef LLVMConstNull(LLVMTypeRef Ty); /* all zeroes */
Gregory Szorc34c863a2012-03-21 03:54:29 +00001374
1375/**
1376 * Obtain a constant value referring to the instance of a type
1377 * consisting of all ones.
1378 *
1379 * This is only valid for integer types.
1380 *
1381 * @see llvm::Constant::getAllOnesValue()
1382 */
1383LLVMValueRef LLVMConstAllOnes(LLVMTypeRef Ty);
1384
1385/**
1386 * Obtain a constant value referring to an undefined value of a type.
1387 *
1388 * @see llvm::UndefValue::get()
1389 */
Gordon Henriksen76a03742007-09-18 03:18:57 +00001390LLVMValueRef LLVMGetUndef(LLVMTypeRef Ty);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001391
1392/**
1393 * Determine whether a value instance is null.
1394 *
1395 * @see llvm::Constant::isNullValue()
1396 */
Chris Lattner25963c62010-01-09 22:27:07 +00001397LLVMBool LLVMIsNull(LLVMValueRef Val);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001398
1399/**
1400 * Obtain a constant that is a constant pointer pointing to NULL for a
1401 * specified type.
1402 */
Chris Lattner7f318242009-07-06 17:29:59 +00001403LLVMValueRef LLVMConstPointerNull(LLVMTypeRef Ty);
Gordon Henriksen76a03742007-09-18 03:18:57 +00001404
Gregory Szorc34c863a2012-03-21 03:54:29 +00001405/**
1406 * @defgroup LLVMCCoreValueConstantScalar Scalar constants
1407 *
1408 * Functions in this group model LLVMValueRef instances that correspond
1409 * to constants referring to scalar types.
1410 *
1411 * For integer types, the LLVMTypeRef parameter should correspond to a
1412 * llvm::IntegerType instance and the returned LLVMValueRef will
1413 * correspond to a llvm::ConstantInt.
1414 *
1415 * For floating point types, the LLVMTypeRef returned corresponds to a
1416 * llvm::ConstantFP.
1417 *
1418 * @{
1419 */
Erick Tryzelaard8531fa2010-02-28 09:45:59 +00001420
Gregory Szorc34c863a2012-03-21 03:54:29 +00001421/**
1422 * Obtain a constant value for an integer type.
1423 *
1424 * The returned value corresponds to a llvm::ConstantInt.
1425 *
1426 * @see llvm::ConstantInt::get()
1427 *
1428 * @param IntTy Integer type to obtain value of.
1429 * @param N The value the returned instance should refer to.
1430 * @param SignExtend Whether to sign extend the produced value.
1431 */
Gordon Henriksen1046c732007-10-06 15:11:06 +00001432LLVMValueRef LLVMConstInt(LLVMTypeRef IntTy, unsigned long long N,
Chris Lattner25963c62010-01-09 22:27:07 +00001433 LLVMBool SignExtend);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001434
1435/**
1436 * Obtain a constant value for an integer of arbitrary precision.
1437 *
1438 * @see llvm::ConstantInt::get()
1439 */
Chris Lattner4329e072010-11-23 02:47:22 +00001440LLVMValueRef LLVMConstIntOfArbitraryPrecision(LLVMTypeRef IntTy,
1441 unsigned NumWords,
1442 const uint64_t Words[]);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001443
1444/**
1445 * Obtain a constant value for an integer parsed from a string.
1446 *
1447 * A similar API, LLVMConstIntOfStringAndSize is also available. If the
1448 * string's length is available, it is preferred to call that function
1449 * instead.
1450 *
1451 * @see llvm::ConstantInt::get()
1452 */
Erick Tryzelaardd991352009-08-16 23:36:46 +00001453LLVMValueRef LLVMConstIntOfString(LLVMTypeRef IntTy, const char *Text,
1454 uint8_t Radix);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001455
1456/**
1457 * Obtain a constant value for an integer parsed from a string with
1458 * specified length.
1459 *
1460 * @see llvm::ConstantInt::get()
1461 */
Erick Tryzelaardd991352009-08-16 23:36:46 +00001462LLVMValueRef LLVMConstIntOfStringAndSize(LLVMTypeRef IntTy, const char *Text,
1463 unsigned SLen, uint8_t Radix);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001464
1465/**
1466 * Obtain a constant value referring to a double floating point value.
1467 */
Gordon Henriksen1046c732007-10-06 15:11:06 +00001468LLVMValueRef LLVMConstReal(LLVMTypeRef RealTy, double N);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001469
1470/**
1471 * Obtain a constant for a floating point value parsed from a string.
1472 *
1473 * A similar API, LLVMConstRealOfStringAndSize is also available. It
1474 * should be used if the input string's length is known.
1475 */
Gordon Henriksen931e1212008-02-02 01:07:50 +00001476LLVMValueRef LLVMConstRealOfString(LLVMTypeRef RealTy, const char *Text);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001477
1478/**
1479 * Obtain a constant for a floating point value parsed from a string.
1480 */
Erick Tryzelaardd991352009-08-16 23:36:46 +00001481LLVMValueRef LLVMConstRealOfStringAndSize(LLVMTypeRef RealTy, const char *Text,
1482 unsigned SLen);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001483
1484/**
1485 * Obtain the zero extended value for an integer constant value.
1486 *
1487 * @see llvm::ConstantInt::getZExtValue()
1488 */
Chris Lattner40cf28d2009-10-12 04:01:02 +00001489unsigned long long LLVMConstIntGetZExtValue(LLVMValueRef ConstantVal);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001490
1491/**
1492 * Obtain the sign extended value for an integer constant value.
1493 *
1494 * @see llvm::ConstantInt::getSExtValue()
1495 */
Chris Lattner40cf28d2009-10-12 04:01:02 +00001496long long LLVMConstIntGetSExtValue(LLVMValueRef ConstantVal);
Erick Tryzelaardd991352009-08-16 23:36:46 +00001497
Gregory Szorc34c863a2012-03-21 03:54:29 +00001498/**
Peter Zotov1d98e6d2014-10-28 19:46:44 +00001499 * Obtain the double value for an floating point constant value.
1500 * losesInfo indicates if some precision was lost in the conversion.
1501 *
1502 * @see llvm::ConstantFP::getDoubleValue
1503 */
1504double LLVMConstRealGetDouble(LLVMValueRef ConstantVal, LLVMBool *losesInfo);
1505
1506/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00001507 * @}
1508 */
1509
1510/**
Gregory Szorc52d26602012-03-21 07:28:27 +00001511 * @defgroup LLVMCCoreValueConstantComposite Composite Constants
1512 *
1513 * Functions in this group operate on composite constants.
Gregory Szorc34c863a2012-03-21 03:54:29 +00001514 *
1515 * @{
1516 */
1517
1518/**
Gregory Szorc52d26602012-03-21 07:28:27 +00001519 * Create a ConstantDataSequential and initialize it with a string.
Gregory Szorc34c863a2012-03-21 03:54:29 +00001520 *
Gregory Szorc52d26602012-03-21 07:28:27 +00001521 * @see llvm::ConstantDataArray::getString()
Gregory Szorc34c863a2012-03-21 03:54:29 +00001522 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +00001523LLVMValueRef LLVMConstStringInContext(LLVMContextRef C, const char *Str,
Chris Lattner25963c62010-01-09 22:27:07 +00001524 unsigned Length, LLVMBool DontNullTerminate);
Gregory Szorc52d26602012-03-21 07:28:27 +00001525
1526/**
1527 * Create a ConstantDataSequential with string content in the global context.
1528 *
1529 * This is the same as LLVMConstStringInContext except it operates on the
1530 * global context.
1531 *
1532 * @see LLVMConstStringInContext()
1533 * @see llvm::ConstantDataArray::getString()
1534 */
1535LLVMValueRef LLVMConstString(const char *Str, unsigned Length,
1536 LLVMBool DontNullTerminate);
1537
1538/**
Peter Zotovf9aa8822014-08-03 23:54:16 +00001539 * Returns true if the specified constant is an array of i8.
1540 *
1541 * @see ConstantDataSequential::getAsString()
1542 */
1543LLVMBool LLVMIsConstantString(LLVMValueRef c);
1544
1545/**
1546 * Get the given constant data sequential as a string.
1547 *
1548 * @see ConstantDataSequential::getAsString()
1549 */
Amaury Sechet7c2883c2016-04-03 21:06:04 +00001550const char *LLVMGetAsString(LLVMValueRef c, size_t *Length);
Peter Zotovf9aa8822014-08-03 23:54:16 +00001551
1552/**
Gregory Szorc52d26602012-03-21 07:28:27 +00001553 * Create an anonymous ConstantStruct with the specified values.
1554 *
1555 * @see llvm::ConstantStruct::getAnon()
1556 */
1557LLVMValueRef LLVMConstStructInContext(LLVMContextRef C,
Erick Tryzelaar262332f2009-08-14 00:01:31 +00001558 LLVMValueRef *ConstantVals,
Chris Lattner25963c62010-01-09 22:27:07 +00001559 unsigned Count, LLVMBool Packed);
Erick Tryzelaar262332f2009-08-14 00:01:31 +00001560
Gregory Szorc52d26602012-03-21 07:28:27 +00001561/**
1562 * Create a ConstantStruct in the global Context.
1563 *
1564 * This is the same as LLVMConstStructInContext except it operates on the
1565 * global Context.
1566 *
1567 * @see LLVMConstStructInContext()
1568 */
Gordon Henriksen1046c732007-10-06 15:11:06 +00001569LLVMValueRef LLVMConstStruct(LLVMValueRef *ConstantVals, unsigned Count,
Chris Lattner25963c62010-01-09 22:27:07 +00001570 LLVMBool Packed);
Gregory Szorc52d26602012-03-21 07:28:27 +00001571
1572/**
1573 * Create a ConstantArray from values.
1574 *
1575 * @see llvm::ConstantArray::get()
1576 */
1577LLVMValueRef LLVMConstArray(LLVMTypeRef ElementTy,
1578 LLVMValueRef *ConstantVals, unsigned Length);
1579
1580/**
1581 * Create a non-anonymous ConstantStruct from values.
1582 *
1583 * @see llvm::ConstantStruct::get()
1584 */
Rafael Espindola784ad242011-07-14 19:09:08 +00001585LLVMValueRef LLVMConstNamedStruct(LLVMTypeRef StructTy,
1586 LLVMValueRef *ConstantVals,
1587 unsigned Count);
Gregory Szorc52d26602012-03-21 07:28:27 +00001588
1589/**
Peter Zotovf9aa8822014-08-03 23:54:16 +00001590 * Get an element at specified index as a constant.
1591 *
1592 * @see ConstantDataSequential::getElementAsConstant()
1593 */
Amaury Sechet006ce632016-03-13 00:54:40 +00001594LLVMValueRef LLVMGetElementAsConstant(LLVMValueRef C, unsigned idx);
Peter Zotovf9aa8822014-08-03 23:54:16 +00001595
1596/**
Gregory Szorc52d26602012-03-21 07:28:27 +00001597 * Create a ConstantVector from values.
1598 *
1599 * @see llvm::ConstantVector::get()
1600 */
Gordon Henriksen1046c732007-10-06 15:11:06 +00001601LLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals, unsigned Size);
Gordon Henriksen76a03742007-09-18 03:18:57 +00001602
Gregory Szorc52d26602012-03-21 07:28:27 +00001603/**
1604 * @}
1605 */
1606
1607/**
1608 * @defgroup LLVMCCoreValueConstantExpressions Constant Expressions
1609 *
1610 * Functions in this group correspond to APIs on llvm::ConstantExpr.
1611 *
1612 * @see llvm::ConstantExpr.
1613 *
1614 * @{
1615 */
Chris Lattner40cf28d2009-10-12 04:01:02 +00001616LLVMOpcode LLVMGetConstOpcode(LLVMValueRef ConstantVal);
Erick Tryzelaarfd529d72009-08-19 08:36:49 +00001617LLVMValueRef LLVMAlignOf(LLVMTypeRef Ty);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001618LLVMValueRef LLVMSizeOf(LLVMTypeRef Ty);
1619LLVMValueRef LLVMConstNeg(LLVMValueRef ConstantVal);
Erick Tryzelaar4c340c72010-02-28 05:51:43 +00001620LLVMValueRef LLVMConstNSWNeg(LLVMValueRef ConstantVal);
1621LLVMValueRef LLVMConstNUWNeg(LLVMValueRef ConstantVal);
Erick Tryzelaar4cc690c2009-08-16 02:20:12 +00001622LLVMValueRef LLVMConstFNeg(LLVMValueRef ConstantVal);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001623LLVMValueRef LLVMConstNot(LLVMValueRef ConstantVal);
1624LLVMValueRef LLVMConstAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Dan Gohmane4ca02d2009-09-03 23:34:49 +00001625LLVMValueRef LLVMConstNSWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Erick Tryzelaar4c340c72010-02-28 05:51:43 +00001626LLVMValueRef LLVMConstNUWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Erick Tryzelaar4cc690c2009-08-16 02:20:12 +00001627LLVMValueRef LLVMConstFAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001628LLVMValueRef LLVMConstSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Erick Tryzelaar4c340c72010-02-28 05:51:43 +00001629LLVMValueRef LLVMConstNSWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1630LLVMValueRef LLVMConstNUWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Erick Tryzelaar4cc690c2009-08-16 02:20:12 +00001631LLVMValueRef LLVMConstFSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001632LLVMValueRef LLVMConstMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Erick Tryzelaar4c340c72010-02-28 05:51:43 +00001633LLVMValueRef LLVMConstNSWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1634LLVMValueRef LLVMConstNUWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Erick Tryzelaar4cc690c2009-08-16 02:20:12 +00001635LLVMValueRef LLVMConstFMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001636LLVMValueRef LLVMConstUDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1637LLVMValueRef LLVMConstSDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Dan Gohmane4ca02d2009-09-03 23:34:49 +00001638LLVMValueRef LLVMConstExactSDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001639LLVMValueRef LLVMConstFDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1640LLVMValueRef LLVMConstURem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1641LLVMValueRef LLVMConstSRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1642LLVMValueRef LLVMConstFRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1643LLVMValueRef LLVMConstAnd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1644LLVMValueRef LLVMConstOr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1645LLVMValueRef LLVMConstXor(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1646LLVMValueRef LLVMConstICmp(LLVMIntPredicate Predicate,
1647 LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1648LLVMValueRef LLVMConstFCmp(LLVMRealPredicate Predicate,
1649 LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1650LLVMValueRef LLVMConstShl(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1651LLVMValueRef LLVMConstLShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1652LLVMValueRef LLVMConstAShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1653LLVMValueRef LLVMConstGEP(LLVMValueRef ConstantVal,
1654 LLVMValueRef *ConstantIndices, unsigned NumIndices);
Dan Gohmane4ca02d2009-09-03 23:34:49 +00001655LLVMValueRef LLVMConstInBoundsGEP(LLVMValueRef ConstantVal,
1656 LLVMValueRef *ConstantIndices,
1657 unsigned NumIndices);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001658LLVMValueRef LLVMConstTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1659LLVMValueRef LLVMConstSExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1660LLVMValueRef LLVMConstZExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1661LLVMValueRef LLVMConstFPTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1662LLVMValueRef LLVMConstFPExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1663LLVMValueRef LLVMConstUIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1664LLVMValueRef LLVMConstSIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1665LLVMValueRef LLVMConstFPToUI(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1666LLVMValueRef LLVMConstFPToSI(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1667LLVMValueRef LLVMConstPtrToInt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1668LLVMValueRef LLVMConstIntToPtr(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1669LLVMValueRef LLVMConstBitCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
Matt Arsenaultb03bd4d2013-11-15 01:34:59 +00001670LLVMValueRef LLVMConstAddrSpaceCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
Erick Tryzelaar4cc690c2009-08-16 02:20:12 +00001671LLVMValueRef LLVMConstZExtOrBitCast(LLVMValueRef ConstantVal,
1672 LLVMTypeRef ToType);
1673LLVMValueRef LLVMConstSExtOrBitCast(LLVMValueRef ConstantVal,
1674 LLVMTypeRef ToType);
1675LLVMValueRef LLVMConstTruncOrBitCast(LLVMValueRef ConstantVal,
1676 LLVMTypeRef ToType);
1677LLVMValueRef LLVMConstPointerCast(LLVMValueRef ConstantVal,
1678 LLVMTypeRef ToType);
1679LLVMValueRef LLVMConstIntCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType,
Chris Lattner25963c62010-01-09 22:27:07 +00001680 LLVMBool isSigned);
Erick Tryzelaar4cc690c2009-08-16 02:20:12 +00001681LLVMValueRef LLVMConstFPCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001682LLVMValueRef LLVMConstSelect(LLVMValueRef ConstantCondition,
1683 LLVMValueRef ConstantIfTrue,
1684 LLVMValueRef ConstantIfFalse);
1685LLVMValueRef LLVMConstExtractElement(LLVMValueRef VectorConstant,
1686 LLVMValueRef IndexConstant);
1687LLVMValueRef LLVMConstInsertElement(LLVMValueRef VectorConstant,
1688 LLVMValueRef ElementValueConstant,
1689 LLVMValueRef IndexConstant);
1690LLVMValueRef LLVMConstShuffleVector(LLVMValueRef VectorAConstant,
1691 LLVMValueRef VectorBConstant,
1692 LLVMValueRef MaskConstant);
Dan Gohmand5104a52008-11-03 22:55:43 +00001693LLVMValueRef LLVMConstExtractValue(LLVMValueRef AggConstant, unsigned *IdxList,
1694 unsigned NumIdx);
1695LLVMValueRef LLVMConstInsertValue(LLVMValueRef AggConstant,
1696 LLVMValueRef ElementValueConstant,
1697 unsigned *IdxList, unsigned NumIdx);
Chris Lattner25963c62010-01-09 22:27:07 +00001698LLVMValueRef LLVMConstInlineAsm(LLVMTypeRef Ty,
Chris Lattner3d1f5522008-12-17 21:39:50 +00001699 const char *AsmString, const char *Constraints,
Chris Lattner25963c62010-01-09 22:27:07 +00001700 LLVMBool HasSideEffects, LLVMBool IsAlignStack);
Erick Tryzelaar0fb26ef2010-02-28 09:46:06 +00001701LLVMValueRef LLVMBlockAddress(LLVMValueRef F, LLVMBasicBlockRef BB);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001702
Gregory Szorc52d26602012-03-21 07:28:27 +00001703/**
1704 * @}
1705 */
1706
1707/**
1708 * @defgroup LLVMCCoreValueConstantGlobals Global Values
1709 *
1710 * This group contains functions that operate on global values. Functions in
1711 * this group relate to functions in the llvm::GlobalValue class tree.
1712 *
1713 * @see llvm::GlobalValue
1714 *
1715 * @{
1716 */
1717
Gordon Henriksen265f7802008-03-19 01:11:35 +00001718LLVMModuleRef LLVMGetGlobalParent(LLVMValueRef Global);
Chris Lattner25963c62010-01-09 22:27:07 +00001719LLVMBool LLVMIsDeclaration(LLVMValueRef Global);
Gordon Henriksen76a03742007-09-18 03:18:57 +00001720LLVMLinkage LLVMGetLinkage(LLVMValueRef Global);
1721void LLVMSetLinkage(LLVMValueRef Global, LLVMLinkage Linkage);
1722const char *LLVMGetSection(LLVMValueRef Global);
1723void LLVMSetSection(LLVMValueRef Global, const char *Section);
1724LLVMVisibility LLVMGetVisibility(LLVMValueRef Global);
1725void LLVMSetVisibility(LLVMValueRef Global, LLVMVisibility Viz);
Reid Kleckner2fae26f2014-03-05 02:34:23 +00001726LLVMDLLStorageClass LLVMGetDLLStorageClass(LLVMValueRef Global);
1727void LLVMSetDLLStorageClass(LLVMValueRef Global, LLVMDLLStorageClass Class);
Tim Northoverad96d012014-03-10 19:24:35 +00001728LLVMBool LLVMHasUnnamedAddr(LLVMValueRef Global);
1729void LLVMSetUnnamedAddr(LLVMValueRef Global, LLVMBool HasUnnamedAddr);
Anders Waldenborg213a63f2013-10-29 09:02:02 +00001730
1731/**
1732 * @defgroup LLVMCCoreValueWithAlignment Values with alignment
1733 *
1734 * Functions in this group only apply to values with alignment, i.e.
1735 * global variables, load and store instructions.
1736 */
1737
1738/**
1739 * Obtain the preferred alignment of the value.
Peter Zotov9f584e62014-03-05 05:05:34 +00001740 * @see llvm::AllocaInst::getAlignment()
Anders Waldenborg213a63f2013-10-29 09:02:02 +00001741 * @see llvm::LoadInst::getAlignment()
1742 * @see llvm::StoreInst::getAlignment()
1743 * @see llvm::GlobalValue::getAlignment()
1744 */
1745unsigned LLVMGetAlignment(LLVMValueRef V);
1746
1747/**
1748 * Set the preferred alignment of the value.
Peter Zotov9f584e62014-03-05 05:05:34 +00001749 * @see llvm::AllocaInst::setAlignment()
Anders Waldenborg213a63f2013-10-29 09:02:02 +00001750 * @see llvm::LoadInst::setAlignment()
1751 * @see llvm::StoreInst::setAlignment()
1752 * @see llvm::GlobalValue::setAlignment()
1753 */
1754void LLVMSetAlignment(LLVMValueRef V, unsigned Bytes);
1755
1756/**
Amaury Sechet83550102016-02-14 08:58:49 +00001757 * @}
1758 */
Gordon Henriksen76a03742007-09-18 03:18:57 +00001759
Gregory Szorc52d26602012-03-21 07:28:27 +00001760/**
1761 * @defgroup LLVMCoreValueConstantGlobalVariable Global Variables
1762 *
1763 * This group contains functions that operate on global variable values.
1764 *
1765 * @see llvm::GlobalVariable
1766 *
1767 * @{
1768 */
Gordon Henriksen76a03742007-09-18 03:18:57 +00001769LLVMValueRef LLVMAddGlobal(LLVMModuleRef M, LLVMTypeRef Ty, const char *Name);
Erick Tryzelaar06894b32010-02-28 09:46:13 +00001770LLVMValueRef LLVMAddGlobalInAddressSpace(LLVMModuleRef M, LLVMTypeRef Ty,
1771 const char *Name,
1772 unsigned AddressSpace);
Gordon Henriksen783f7bb2007-10-08 03:45:09 +00001773LLVMValueRef LLVMGetNamedGlobal(LLVMModuleRef M, const char *Name);
Gordon Henriksen07a45f42008-03-23 22:21:29 +00001774LLVMValueRef LLVMGetFirstGlobal(LLVMModuleRef M);
1775LLVMValueRef LLVMGetLastGlobal(LLVMModuleRef M);
1776LLVMValueRef LLVMGetNextGlobal(LLVMValueRef GlobalVar);
1777LLVMValueRef LLVMGetPreviousGlobal(LLVMValueRef GlobalVar);
Gordon Henriksen76a03742007-09-18 03:18:57 +00001778void LLVMDeleteGlobal(LLVMValueRef GlobalVar);
Gordon Henriksen76a03742007-09-18 03:18:57 +00001779LLVMValueRef LLVMGetInitializer(LLVMValueRef GlobalVar);
1780void LLVMSetInitializer(LLVMValueRef GlobalVar, LLVMValueRef ConstantVal);
Chris Lattner25963c62010-01-09 22:27:07 +00001781LLVMBool LLVMIsThreadLocal(LLVMValueRef GlobalVar);
1782void LLVMSetThreadLocal(LLVMValueRef GlobalVar, LLVMBool IsThreadLocal);
1783LLVMBool LLVMIsGlobalConstant(LLVMValueRef GlobalVar);
1784void LLVMSetGlobalConstant(LLVMValueRef GlobalVar, LLVMBool IsConstant);
Hans Wennborg5ff71202013-04-16 08:58:59 +00001785LLVMThreadLocalMode LLVMGetThreadLocalMode(LLVMValueRef GlobalVar);
1786void LLVMSetThreadLocalMode(LLVMValueRef GlobalVar, LLVMThreadLocalMode Mode);
1787LLVMBool LLVMIsExternallyInitialized(LLVMValueRef GlobalVar);
1788void LLVMSetExternallyInitialized(LLVMValueRef GlobalVar, LLVMBool IsExtInit);
Gordon Henriksen76a03742007-09-18 03:18:57 +00001789
Gregory Szorc52d26602012-03-21 07:28:27 +00001790/**
1791 * @}
1792 */
1793
1794/**
1795 * @defgroup LLVMCoreValueConstantGlobalAlias Global Aliases
1796 *
1797 * This group contains function that operate on global alias values.
1798 *
1799 * @see llvm::GlobalAlias
1800 *
1801 * @{
1802 */
Chris Lattner3d1f5522008-12-17 21:39:50 +00001803LLVMValueRef LLVMAddAlias(LLVMModuleRef M, LLVMTypeRef Ty, LLVMValueRef Aliasee,
1804 const char *Name);
1805
Gregory Szorc34c863a2012-03-21 03:54:29 +00001806/**
1807 * @}
1808 */
1809
1810/**
1811 * @defgroup LLVMCCoreValueFunction Function values
1812 *
1813 * Functions in this group operate on LLVMValueRef instances that
1814 * correspond to llvm::Function instances.
1815 *
1816 * @see llvm::Function
1817 *
1818 * @{
1819 */
1820
1821/**
1822 * Remove a function from its containing module and deletes it.
1823 *
1824 * @see llvm::Function::eraseFromParent()
1825 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00001826void LLVMDeleteFunction(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001827
1828/**
Amaury Sechete39e8532016-02-18 20:38:32 +00001829 * Check whether the given function has a personality function.
1830 *
1831 * @see llvm::Function::hasPersonalityFn()
1832 */
1833LLVMBool LLVMHasPersonalityFn(LLVMValueRef Fn);
1834
1835/**
Andrew Wilkins3bdfc1c2015-07-14 01:23:06 +00001836 * Obtain the personality function attached to the function.
1837 *
1838 * @see llvm::Function::getPersonalityFn()
1839 */
1840LLVMValueRef LLVMGetPersonalityFn(LLVMValueRef Fn);
1841
1842/**
1843 * Set the personality function attached to the function.
1844 *
1845 * @see llvm::Function::setPersonalityFn()
1846 */
1847void LLVMSetPersonalityFn(LLVMValueRef Fn, LLVMValueRef PersonalityFn);
1848
1849/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00001850 * Obtain the ID number from a function instance.
1851 *
1852 * @see llvm::Function::getIntrinsicID()
1853 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00001854unsigned LLVMGetIntrinsicID(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001855
1856/**
1857 * Obtain the calling function of a function.
1858 *
1859 * The returned value corresponds to the LLVMCallConv enumeration.
1860 *
1861 * @see llvm::Function::getCallingConv()
1862 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00001863unsigned LLVMGetFunctionCallConv(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001864
1865/**
1866 * Set the calling convention of a function.
1867 *
1868 * @see llvm::Function::setCallingConv()
1869 *
1870 * @param Fn Function to operate on
1871 * @param CC LLVMCallConv to set calling convention to
1872 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00001873void LLVMSetFunctionCallConv(LLVMValueRef Fn, unsigned CC);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001874
1875/**
1876 * Obtain the name of the garbage collector to use during code
1877 * generation.
1878 *
1879 * @see llvm::Function::getGC()
1880 */
Gordon Henriksend930f912008-08-17 18:44:35 +00001881const char *LLVMGetGC(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001882
1883/**
1884 * Define the garbage collector to use during code generation.
1885 *
1886 * @see llvm::Function::setGC()
1887 */
Gordon Henriksend930f912008-08-17 18:44:35 +00001888void LLVMSetGC(LLVMValueRef Fn, const char *Name);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001889
1890/**
1891 * Add an attribute to a function.
1892 *
1893 * @see llvm::Function::addAttribute()
1894 */
Duncan Sands7374a012009-05-06 12:21:17 +00001895void LLVMAddFunctionAttr(LLVMValueRef Fn, LLVMAttribute PA);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001896
1897/**
Nick Lewyckyc3890d22015-07-29 22:32:47 +00001898 * Add a target-dependent attribute to a function
Tom Stellarde8f35e12013-04-16 23:12:43 +00001899 * @see llvm::AttrBuilder::addAttribute()
1900 */
1901void LLVMAddTargetDependentFunctionAttr(LLVMValueRef Fn, const char *A,
1902 const char *V);
1903
1904/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00001905 * Obtain an attribute from a function.
1906 *
1907 * @see llvm::Function::getAttributes()
1908 */
Chris Lattner40cf28d2009-10-12 04:01:02 +00001909LLVMAttribute LLVMGetFunctionAttr(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001910
1911/**
1912 * Remove an attribute from a function.
1913 */
Duncan Sands7374a012009-05-06 12:21:17 +00001914void LLVMRemoveFunctionAttr(LLVMValueRef Fn, LLVMAttribute PA);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00001915
Gregory Szorc34c863a2012-03-21 03:54:29 +00001916/**
1917 * @defgroup LLVMCCoreValueFunctionParameters Function Parameters
1918 *
1919 * Functions in this group relate to arguments/parameters on functions.
1920 *
1921 * Functions in this group expect LLVMValueRef instances that correspond
1922 * to llvm::Function instances.
1923 *
1924 * @{
1925 */
1926
1927/**
1928 * Obtain the number of parameters in a function.
1929 *
1930 * @see llvm::Function::arg_size()
1931 */
Gordon Henriksen265f7802008-03-19 01:11:35 +00001932unsigned LLVMCountParams(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001933
1934/**
1935 * Obtain the parameters in a function.
1936 *
1937 * The takes a pointer to a pre-allocated array of LLVMValueRef that is
1938 * at least LLVMCountParams() long. This array will be filled with
1939 * LLVMValueRef instances which correspond to the parameters the
1940 * function receives. Each LLVMValueRef corresponds to a llvm::Argument
1941 * instance.
1942 *
1943 * @see llvm::Function::arg_begin()
1944 */
Gordon Henriksen265f7802008-03-19 01:11:35 +00001945void LLVMGetParams(LLVMValueRef Fn, LLVMValueRef *Params);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001946
1947/**
1948 * Obtain the parameter at the specified index.
1949 *
1950 * Parameters are indexed from 0.
1951 *
1952 * @see llvm::Function::arg_begin()
1953 */
Gordon Henriksen265f7802008-03-19 01:11:35 +00001954LLVMValueRef LLVMGetParam(LLVMValueRef Fn, unsigned Index);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001955
1956/**
1957 * Obtain the function to which this argument belongs.
1958 *
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00001959 * Unlike other functions in this group, this one takes an LLVMValueRef
Gregory Szorc34c863a2012-03-21 03:54:29 +00001960 * that corresponds to a llvm::Attribute.
1961 *
1962 * The returned LLVMValueRef is the llvm::Function to which this
1963 * argument belongs.
1964 */
Gordon Henriksen265f7802008-03-19 01:11:35 +00001965LLVMValueRef LLVMGetParamParent(LLVMValueRef Inst);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001966
1967/**
1968 * Obtain the first parameter to a function.
1969 *
1970 * @see llvm::Function::arg_begin()
1971 */
Gordon Henriksen07a45f42008-03-23 22:21:29 +00001972LLVMValueRef LLVMGetFirstParam(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001973
1974/**
1975 * Obtain the last parameter to a function.
1976 *
1977 * @see llvm::Function::arg_end()
1978 */
Gordon Henriksen07a45f42008-03-23 22:21:29 +00001979LLVMValueRef LLVMGetLastParam(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001980
1981/**
1982 * Obtain the next parameter to a function.
1983 *
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00001984 * This takes an LLVMValueRef obtained from LLVMGetFirstParam() (which is
Gregory Szorc34c863a2012-03-21 03:54:29 +00001985 * actually a wrapped iterator) and obtains the next parameter from the
1986 * underlying iterator.
1987 */
Gordon Henriksen07a45f42008-03-23 22:21:29 +00001988LLVMValueRef LLVMGetNextParam(LLVMValueRef Arg);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001989
1990/**
1991 * Obtain the previous parameter to a function.
1992 *
1993 * This is the opposite of LLVMGetNextParam().
1994 */
Gordon Henriksen07a45f42008-03-23 22:21:29 +00001995LLVMValueRef LLVMGetPreviousParam(LLVMValueRef Arg);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001996
1997/**
1998 * Add an attribute to a function argument.
1999 *
2000 * @see llvm::Argument::addAttr()
2001 */
Devang Patel4c758ea2008-09-25 21:00:45 +00002002void LLVMAddAttribute(LLVMValueRef Arg, LLVMAttribute PA);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002003
2004/**
2005 * Remove an attribute from a function argument.
2006 *
2007 * @see llvm::Argument::removeAttr()
2008 */
Devang Patel4c758ea2008-09-25 21:00:45 +00002009void LLVMRemoveAttribute(LLVMValueRef Arg, LLVMAttribute PA);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002010
2011/**
2012 * Get an attribute from a function argument.
2013 */
Chris Lattner40cf28d2009-10-12 04:01:02 +00002014LLVMAttribute LLVMGetAttribute(LLVMValueRef Arg);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002015
2016/**
2017 * Set the alignment for a function parameter.
2018 *
2019 * @see llvm::Argument::addAttr()
Bill Wendling50d27842012-10-15 20:35:56 +00002020 * @see llvm::AttrBuilder::addAlignmentAttr()
Gregory Szorc34c863a2012-03-21 03:54:29 +00002021 */
Gordon Henriksen2d9cc212008-04-28 17:37:06 +00002022void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned align);
Gordon Henriksen265f7802008-03-19 01:11:35 +00002023
Gregory Szorc34c863a2012-03-21 03:54:29 +00002024/**
2025 * @}
2026 */
2027
2028/**
2029 * @}
2030 */
2031
2032/**
Gregory Szorc52d26602012-03-21 07:28:27 +00002033 * @}
2034 */
2035
2036/**
2037 * @}
2038 */
2039
2040/**
2041 * @defgroup LLVMCCoreValueMetadata Metadata
2042 *
2043 * @{
2044 */
2045
2046/**
2047 * Obtain a MDString value from a context.
2048 *
2049 * The returned instance corresponds to the llvm::MDString class.
2050 *
2051 * The instance is specified by string data of a specified length. The
2052 * string content is copied, so the backing memory can be freed after
2053 * this function returns.
2054 */
2055LLVMValueRef LLVMMDStringInContext(LLVMContextRef C, const char *Str,
2056 unsigned SLen);
2057
2058/**
2059 * Obtain a MDString value from the global context.
2060 */
2061LLVMValueRef LLVMMDString(const char *Str, unsigned SLen);
2062
2063/**
2064 * Obtain a MDNode value from a context.
2065 *
2066 * The returned value corresponds to the llvm::MDNode class.
2067 */
2068LLVMValueRef LLVMMDNodeInContext(LLVMContextRef C, LLVMValueRef *Vals,
2069 unsigned Count);
2070
2071/**
2072 * Obtain a MDNode value from the global context.
2073 */
2074LLVMValueRef LLVMMDNode(LLVMValueRef *Vals, unsigned Count);
2075
2076/**
2077 * Obtain the underlying string from a MDString value.
2078 *
2079 * @param V Instance to obtain string from.
NAKAMURA Takumie4a77052016-04-04 11:54:48 +00002080 * @param Length Memory address which will hold length of returned string.
Gregory Szorc52d26602012-03-21 07:28:27 +00002081 * @return String data in MDString.
2082 */
Amaury Sechet7c2883c2016-04-03 21:06:04 +00002083const char *LLVMGetMDString(LLVMValueRef V, unsigned *Length);
Gregory Szorc52d26602012-03-21 07:28:27 +00002084
2085/**
Duncan Sands12ccbe72012-09-19 20:29:39 +00002086 * Obtain the number of operands from an MDNode value.
2087 *
2088 * @param V MDNode to get number of operands from.
2089 * @return Number of operands of the MDNode.
2090 */
2091unsigned LLVMGetMDNodeNumOperands(LLVMValueRef V);
2092
2093/**
2094 * Obtain the given MDNode's operands.
2095 *
2096 * The passed LLVMValueRef pointer should point to enough memory to hold all of
2097 * the operands of the given MDNode (see LLVMGetMDNodeNumOperands) as
2098 * LLVMValueRefs. This memory will be populated with the LLVMValueRefs of the
2099 * MDNode's operands.
2100 *
2101 * @param V MDNode to get the operands from.
2102 * @param Dest Destination array for operands.
2103 */
2104void LLVMGetMDNodeOperands(LLVMValueRef V, LLVMValueRef *Dest);
2105
2106/**
Gregory Szorc52d26602012-03-21 07:28:27 +00002107 * @}
2108 */
2109
2110/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002111 * @defgroup LLVMCCoreValueBasicBlock Basic Block
2112 *
2113 * A basic block represents a single entry single exit section of code.
2114 * Basic blocks contain a list of instructions which form the body of
2115 * the block.
2116 *
2117 * Basic blocks belong to functions. They have the type of label.
2118 *
2119 * Basic blocks are themselves values. However, the C API models them as
2120 * LLVMBasicBlockRef.
2121 *
2122 * @see llvm::BasicBlock
2123 *
2124 * @{
2125 */
2126
2127/**
2128 * Convert a basic block instance to a value type.
2129 */
Gordon Henriksen07a45f42008-03-23 22:21:29 +00002130LLVMValueRef LLVMBasicBlockAsValue(LLVMBasicBlockRef BB);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002131
2132/**
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00002133 * Determine whether an LLVMValueRef is itself a basic block.
Gregory Szorc34c863a2012-03-21 03:54:29 +00002134 */
Chris Lattner25963c62010-01-09 22:27:07 +00002135LLVMBool LLVMValueIsBasicBlock(LLVMValueRef Val);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002136
2137/**
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00002138 * Convert an LLVMValueRef to an LLVMBasicBlockRef instance.
Gregory Szorc34c863a2012-03-21 03:54:29 +00002139 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002140LLVMBasicBlockRef LLVMValueAsBasicBlock(LLVMValueRef Val);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002141
2142/**
Amaury Secheta82042e2016-02-09 22:36:41 +00002143 * Obtain the string name of a basic block.
2144 */
2145const char *LLVMGetBasicBlockName(LLVMBasicBlockRef BB);
2146
2147/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002148 * Obtain the function to which a basic block belongs.
2149 *
2150 * @see llvm::BasicBlock::getParent()
2151 */
Gordon Henriksen07a45f42008-03-23 22:21:29 +00002152LLVMValueRef LLVMGetBasicBlockParent(LLVMBasicBlockRef BB);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002153
2154/**
2155 * Obtain the terminator instruction for a basic block.
2156 *
2157 * If the basic block does not have a terminator (it is not well-formed
2158 * if it doesn't), then NULL is returned.
2159 *
2160 * The returned LLVMValueRef corresponds to a llvm::TerminatorInst.
2161 *
2162 * @see llvm::BasicBlock::getTerminator()
2163 */
Nate Begeman43c322b2011-08-23 20:27:46 +00002164LLVMValueRef LLVMGetBasicBlockTerminator(LLVMBasicBlockRef BB);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002165
2166/**
2167 * Obtain the number of basic blocks in a function.
2168 *
2169 * @param Fn Function value to operate on.
2170 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002171unsigned LLVMCountBasicBlocks(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002172
2173/**
2174 * Obtain all of the basic blocks in a function.
2175 *
2176 * This operates on a function value. The BasicBlocks parameter is a
2177 * pointer to a pre-allocated array of LLVMBasicBlockRef of at least
2178 * LLVMCountBasicBlocks() in length. This array is populated with
2179 * LLVMBasicBlockRef instances.
2180 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002181void LLVMGetBasicBlocks(LLVMValueRef Fn, LLVMBasicBlockRef *BasicBlocks);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002182
2183/**
2184 * Obtain the first basic block in a function.
2185 *
2186 * The returned basic block can be used as an iterator. You will likely
2187 * eventually call into LLVMGetNextBasicBlock() with it.
2188 *
2189 * @see llvm::Function::begin()
2190 */
Gordon Henriksen054817c2008-03-19 03:47:18 +00002191LLVMBasicBlockRef LLVMGetFirstBasicBlock(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002192
2193/**
2194 * Obtain the last basic block in a function.
2195 *
2196 * @see llvm::Function::end()
2197 */
Gordon Henriksen054817c2008-03-19 03:47:18 +00002198LLVMBasicBlockRef LLVMGetLastBasicBlock(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002199
2200/**
2201 * Advance a basic block iterator.
2202 */
Gordon Henriksen054817c2008-03-19 03:47:18 +00002203LLVMBasicBlockRef LLVMGetNextBasicBlock(LLVMBasicBlockRef BB);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002204
2205/**
2206 * Go backwards in a basic block iterator.
2207 */
Gordon Henriksen054817c2008-03-19 03:47:18 +00002208LLVMBasicBlockRef LLVMGetPreviousBasicBlock(LLVMBasicBlockRef BB);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002209
2210/**
2211 * Obtain the basic block that corresponds to the entry point of a
2212 * function.
2213 *
2214 * @see llvm::Function::getEntryBlock()
2215 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002216LLVMBasicBlockRef LLVMGetEntryBasicBlock(LLVMValueRef Fn);
Erick Tryzelaar262332f2009-08-14 00:01:31 +00002217
Gregory Szorc34c863a2012-03-21 03:54:29 +00002218/**
2219 * Append a basic block to the end of a function.
2220 *
2221 * @see llvm::BasicBlock::Create()
2222 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +00002223LLVMBasicBlockRef LLVMAppendBasicBlockInContext(LLVMContextRef C,
2224 LLVMValueRef Fn,
2225 const char *Name);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002226
2227/**
2228 * Append a basic block to the end of a function using the global
2229 * context.
2230 *
2231 * @see llvm::BasicBlock::Create()
2232 */
2233LLVMBasicBlockRef LLVMAppendBasicBlock(LLVMValueRef Fn, const char *Name);
2234
2235/**
2236 * Insert a basic block in a function before another basic block.
2237 *
2238 * The function to add to is determined by the function of the
2239 * passed basic block.
2240 *
2241 * @see llvm::BasicBlock::Create()
2242 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +00002243LLVMBasicBlockRef LLVMInsertBasicBlockInContext(LLVMContextRef C,
2244 LLVMBasicBlockRef BB,
2245 const char *Name);
2246
Gregory Szorc34c863a2012-03-21 03:54:29 +00002247/**
2248 * Insert a basic block in a function using the global context.
2249 *
2250 * @see llvm::BasicBlock::Create()
2251 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002252LLVMBasicBlockRef LLVMInsertBasicBlock(LLVMBasicBlockRef InsertBeforeBB,
2253 const char *Name);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002254
2255/**
2256 * Remove a basic block from a function and delete it.
2257 *
2258 * This deletes the basic block from its containing function and deletes
2259 * the basic block itself.
2260 *
2261 * @see llvm::BasicBlock::eraseFromParent()
2262 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002263void LLVMDeleteBasicBlock(LLVMBasicBlockRef BB);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002264
2265/**
2266 * Remove a basic block from a function.
2267 *
2268 * This deletes the basic block from its containing function but keep
2269 * the basic block alive.
2270 *
2271 * @see llvm::BasicBlock::removeFromParent()
2272 */
Nate Begeman43c322b2011-08-23 20:27:46 +00002273void LLVMRemoveBasicBlockFromParent(LLVMBasicBlockRef BB);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002274
Gregory Szorc34c863a2012-03-21 03:54:29 +00002275/**
2276 * Move a basic block to before another one.
2277 *
2278 * @see llvm::BasicBlock::moveBefore()
2279 */
Duncan Sandsb1d61aa2010-07-19 15:31:07 +00002280void LLVMMoveBasicBlockBefore(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002281
2282/**
2283 * Move a basic block to after another one.
2284 *
2285 * @see llvm::BasicBlock::moveAfter()
2286 */
Duncan Sandsb1d61aa2010-07-19 15:31:07 +00002287void LLVMMoveBasicBlockAfter(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos);
2288
Gregory Szorc34c863a2012-03-21 03:54:29 +00002289/**
2290 * Obtain the first instruction in a basic block.
2291 *
2292 * The returned LLVMValueRef corresponds to a llvm::Instruction
2293 * instance.
2294 */
Gordon Henriksen054817c2008-03-19 03:47:18 +00002295LLVMValueRef LLVMGetFirstInstruction(LLVMBasicBlockRef BB);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002296
2297/**
2298 * Obtain the last instruction in a basic block.
2299 *
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00002300 * The returned LLVMValueRef corresponds to an LLVM:Instruction.
Gregory Szorc34c863a2012-03-21 03:54:29 +00002301 */
Gordon Henriksen054817c2008-03-19 03:47:18 +00002302LLVMValueRef LLVMGetLastInstruction(LLVMBasicBlockRef BB);
Nate Begeman43c322b2011-08-23 20:27:46 +00002303
Gregory Szorc34c863a2012-03-21 03:54:29 +00002304/**
2305 * @}
2306 */
2307
2308/**
2309 * @defgroup LLVMCCoreValueInstruction Instructions
2310 *
2311 * Functions in this group relate to the inspection and manipulation of
2312 * individual instructions.
2313 *
2314 * In the C++ API, an instruction is modeled by llvm::Instruction. This
2315 * class has a large number of descendents. llvm::Instruction is a
2316 * llvm::Value and in the C API, instructions are modeled by
2317 * LLVMValueRef.
2318 *
2319 * This group also contains sub-groups which operate on specific
2320 * llvm::Instruction types, e.g. llvm::CallInst.
2321 *
2322 * @{
2323 */
2324
2325/**
2326 * Determine whether an instruction has any metadata attached.
2327 */
2328int LLVMHasMetadata(LLVMValueRef Val);
2329
2330/**
2331 * Return metadata associated with an instruction value.
2332 */
2333LLVMValueRef LLVMGetMetadata(LLVMValueRef Val, unsigned KindID);
2334
2335/**
2336 * Set metadata associated with an instruction value.
2337 */
2338void LLVMSetMetadata(LLVMValueRef Val, unsigned KindID, LLVMValueRef Node);
2339
2340/**
2341 * Obtain the basic block to which an instruction belongs.
2342 *
2343 * @see llvm::Instruction::getParent()
2344 */
Nate Begeman43c322b2011-08-23 20:27:46 +00002345LLVMBasicBlockRef LLVMGetInstructionParent(LLVMValueRef Inst);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002346
2347/**
2348 * Obtain the instruction that occurs after the one specified.
2349 *
2350 * The next instruction will be from the same basic block.
2351 *
2352 * If this is the last instruction in a basic block, NULL will be
2353 * returned.
2354 */
Gordon Henriksen054817c2008-03-19 03:47:18 +00002355LLVMValueRef LLVMGetNextInstruction(LLVMValueRef Inst);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002356
2357/**
Benjamin Kramerbde91762012-06-02 10:20:22 +00002358 * Obtain the instruction that occurred before this one.
Gregory Szorc34c863a2012-03-21 03:54:29 +00002359 *
2360 * If the instruction is the first instruction in a basic block, NULL
2361 * will be returned.
2362 */
Gordon Henriksen054817c2008-03-19 03:47:18 +00002363LLVMValueRef LLVMGetPreviousInstruction(LLVMValueRef Inst);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002364
2365/**
2366 * Remove and delete an instruction.
2367 *
2368 * The instruction specified is removed from its containing building
Amaury Sechet2f432082016-02-11 21:37:54 +00002369 * block but is kept alive.
2370 *
2371 * @see llvm::Instruction::removeFromParent()
2372 */
2373void LLVMInstructionRemoveFromParent(LLVMValueRef Inst);
2374
2375/**
2376 * Remove and delete an instruction.
2377 *
2378 * The instruction specified is removed from its containing building
Gregory Szorc34c863a2012-03-21 03:54:29 +00002379 * block and then deleted.
2380 *
2381 * @see llvm::Instruction::eraseFromParent()
2382 */
Devang Pateldbebc6f2011-10-03 20:59:18 +00002383void LLVMInstructionEraseFromParent(LLVMValueRef Inst);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002384
2385/**
2386 * Obtain the code opcode for an individual instruction.
2387 *
2388 * @see llvm::Instruction::getOpCode()
2389 */
Eric Christophera6b96002015-12-18 01:46:52 +00002390LLVMOpcode LLVMGetInstructionOpcode(LLVMValueRef Inst);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002391
2392/**
2393 * Obtain the predicate of an instruction.
2394 *
2395 * This is only valid for instructions that correspond to llvm::ICmpInst
2396 * or llvm::ConstantExpr whose opcode is llvm::Instruction::ICmp.
2397 *
2398 * @see llvm::ICmpInst::getPredicate()
2399 */
Torok Edwin60c40de2011-10-06 12:13:20 +00002400LLVMIntPredicate LLVMGetICmpPredicate(LLVMValueRef Inst);
Gordon Henriksen265f7802008-03-19 01:11:35 +00002401
Gregory Szorc34c863a2012-03-21 03:54:29 +00002402/**
Peter Zotov1d98e6d2014-10-28 19:46:44 +00002403 * Obtain the float predicate of an instruction.
2404 *
2405 * This is only valid for instructions that correspond to llvm::FCmpInst
2406 * or llvm::ConstantExpr whose opcode is llvm::Instruction::FCmp.
2407 *
2408 * @see llvm::FCmpInst::getPredicate()
2409 */
2410LLVMRealPredicate LLVMGetFCmpPredicate(LLVMValueRef Inst);
2411
2412/**
Peter Zotovaff492c2014-10-17 01:02:34 +00002413 * Create a copy of 'this' instruction that is identical in all ways
2414 * except the following:
2415 * * The instruction has no parent
2416 * * The instruction has no name
2417 *
2418 * @see llvm::Instruction::clone()
2419 */
2420LLVMValueRef LLVMInstructionClone(LLVMValueRef Inst);
2421
2422/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002423 * @defgroup LLVMCCoreValueInstructionCall Call Sites and Invocations
2424 *
2425 * Functions in this group apply to instructions that refer to call
2426 * sites and invocations. These correspond to C++ types in the
2427 * llvm::CallInst class tree.
2428 *
2429 * @{
2430 */
2431
2432/**
Amaury Sechet5c7b3af2016-02-10 00:09:37 +00002433 * Obtain the argument count for a call instruction.
2434 *
2435 * This expects an LLVMValueRef that corresponds to a llvm::CallInst or
2436 * llvm::InvokeInst.
2437 *
2438 * @see llvm::CallInst::getNumArgOperands()
2439 * @see llvm::InvokeInst::getNumArgOperands()
2440 */
2441unsigned LLVMGetNumArgOperands(LLVMValueRef Instr);
2442
2443/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002444 * Set the calling convention for a call instruction.
2445 *
2446 * This expects an LLVMValueRef that corresponds to a llvm::CallInst or
2447 * llvm::InvokeInst.
2448 *
2449 * @see llvm::CallInst::setCallingConv()
2450 * @see llvm::InvokeInst::setCallingConv()
2451 */
Gordon Henriksen1158c532007-12-29 20:45:00 +00002452void LLVMSetInstructionCallConv(LLVMValueRef Instr, unsigned CC);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002453
2454/**
2455 * Obtain the calling convention for a call instruction.
2456 *
2457 * This is the opposite of LLVMSetInstructionCallConv(). Reads its
2458 * usage.
2459 *
2460 * @see LLVMSetInstructionCallConv()
2461 */
Gordon Henriksen1158c532007-12-29 20:45:00 +00002462unsigned LLVMGetInstructionCallConv(LLVMValueRef Instr);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002463
2464
Devang Patel4c758ea2008-09-25 21:00:45 +00002465void LLVMAddInstrAttribute(LLVMValueRef Instr, unsigned index, LLVMAttribute);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002466void LLVMRemoveInstrAttribute(LLVMValueRef Instr, unsigned index,
Devang Patel4c758ea2008-09-25 21:00:45 +00002467 LLVMAttribute);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002468void LLVMSetInstrParamAlignment(LLVMValueRef Instr, unsigned index,
Gordon Henriksen2d9cc212008-04-28 17:37:06 +00002469 unsigned align);
Gordon Henriksen1158c532007-12-29 20:45:00 +00002470
Gregory Szorc34c863a2012-03-21 03:54:29 +00002471/**
Amaury Sechet5c7b3af2016-02-10 00:09:37 +00002472 * Obtain the pointer to the function invoked by this instruction.
2473 *
2474 * This expects an LLVMValueRef that corresponds to a llvm::CallInst or
2475 * llvm::InvokeInst.
2476 *
2477 * @see llvm::CallInst::getCalledValue()
2478 * @see llvm::InvokeInst::getCalledValue()
2479 */
2480LLVMValueRef LLVMGetCalledValue(LLVMValueRef Instr);
2481
2482/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002483 * Obtain whether a call instruction is a tail call.
2484 *
2485 * This only works on llvm::CallInst instructions.
2486 *
2487 * @see llvm::CallInst::isTailCall()
2488 */
Chris Lattner25963c62010-01-09 22:27:07 +00002489LLVMBool LLVMIsTailCall(LLVMValueRef CallInst);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002490
2491/**
2492 * Set whether a call instruction is a tail call.
2493 *
2494 * This only works on llvm::CallInst instructions.
2495 *
2496 * @see llvm::CallInst::setTailCall()
2497 */
Chris Lattner25963c62010-01-09 22:27:07 +00002498void LLVMSetTailCall(LLVMValueRef CallInst, LLVMBool IsTailCall);
Gordon Henrikseneeb65372008-08-30 16:34:54 +00002499
Gregory Szorc34c863a2012-03-21 03:54:29 +00002500/**
Amaury Sechete39e8532016-02-18 20:38:32 +00002501 * Return the normal destination basic block.
2502 *
2503 * This only works on llvm::InvokeInst instructions.
2504 *
2505 * @see llvm::InvokeInst::getNormalDest()
2506 */
2507LLVMBasicBlockRef LLVMGetNormalDest(LLVMValueRef InvokeInst);
2508
2509/**
2510 * Return the unwind destination basic block.
2511 *
2512 * This only works on llvm::InvokeInst instructions.
2513 *
2514 * @see llvm::InvokeInst::getUnwindDest()
2515 */
2516LLVMBasicBlockRef LLVMGetUnwindDest(LLVMValueRef InvokeInst);
2517
2518/**
2519 * Set the normal destination basic block.
2520 *
2521 * This only works on llvm::InvokeInst instructions.
2522 *
2523 * @see llvm::InvokeInst::setNormalDest()
2524 */
2525void LLVMSetNormalDest(LLVMValueRef InvokeInst, LLVMBasicBlockRef B);
2526
2527/**
2528 * Set the unwind destination basic block.
2529 *
2530 * This only works on llvm::InvokeInst instructions.
2531 *
2532 * @see llvm::InvokeInst::setUnwindDest()
2533 */
2534void LLVMSetUnwindDest(LLVMValueRef InvokeInst, LLVMBasicBlockRef B);
2535
2536/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002537 * @}
2538 */
2539
2540/**
Peter Zotov2481c752014-10-28 19:46:56 +00002541 * @defgroup LLVMCCoreValueInstructionTerminator Terminators
2542 *
2543 * Functions in this group only apply to instructions that map to
2544 * llvm::TerminatorInst instances.
2545 *
2546 * @{
2547 */
2548
2549/**
2550 * Return the number of successors that this terminator has.
2551 *
2552 * @see llvm::TerminatorInst::getNumSuccessors
2553 */
2554unsigned LLVMGetNumSuccessors(LLVMValueRef Term);
2555
2556/**
2557 * Return the specified successor.
2558 *
2559 * @see llvm::TerminatorInst::getSuccessor
2560 */
2561LLVMBasicBlockRef LLVMGetSuccessor(LLVMValueRef Term, unsigned i);
2562
2563/**
2564 * Update the specified successor to point at the provided block.
2565 *
2566 * @see llvm::TerminatorInst::setSuccessor
2567 */
2568void LLVMSetSuccessor(LLVMValueRef Term, unsigned i, LLVMBasicBlockRef block);
2569
2570/**
2571 * Return if a branch is conditional.
2572 *
2573 * This only works on llvm::BranchInst instructions.
2574 *
2575 * @see llvm::BranchInst::isConditional
2576 */
2577LLVMBool LLVMIsConditional(LLVMValueRef Branch);
2578
2579/**
2580 * Return the condition of a branch instruction.
2581 *
2582 * This only works on llvm::BranchInst instructions.
2583 *
2584 * @see llvm::BranchInst::getCondition
2585 */
2586LLVMValueRef LLVMGetCondition(LLVMValueRef Branch);
2587
2588/**
2589 * Set the condition of a branch instruction.
2590 *
2591 * This only works on llvm::BranchInst instructions.
2592 *
2593 * @see llvm::BranchInst::setCondition
2594 */
2595void LLVMSetCondition(LLVMValueRef Branch, LLVMValueRef Cond);
2596
2597/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002598 * Obtain the default destination basic block of a switch instruction.
2599 *
2600 * This only works on llvm::SwitchInst instructions.
2601 *
2602 * @see llvm::SwitchInst::getDefaultDest()
2603 */
Nate Begeman43c322b2011-08-23 20:27:46 +00002604LLVMBasicBlockRef LLVMGetSwitchDefaultDest(LLVMValueRef SwitchInstr);
2605
Gregory Szorc34c863a2012-03-21 03:54:29 +00002606/**
Peter Zotov2481c752014-10-28 19:46:56 +00002607 * @}
2608 */
2609
2610/**
Amaury Sechet1dcf5772016-02-09 22:50:53 +00002611 * @defgroup LLVMCCoreValueInstructionAlloca Allocas
2612 *
2613 * Functions in this group only apply to instructions that map to
2614 * llvm::AllocaInst instances.
2615 *
2616 * @{
2617 */
2618
2619/**
2620 * Obtain the type that is being allocated by the alloca instruction.
2621 */
2622LLVMTypeRef LLVMGetAllocatedType(LLVMValueRef Alloca);
2623
2624/**
2625 * @}
2626 */
2627
2628/**
Amaury Sechet053ac452016-02-17 22:51:03 +00002629 * @defgroup LLVMCCoreValueInstructionGetElementPointer GEPs
2630 *
2631 * Functions in this group only apply to instructions that map to
2632 * llvm::GetElementPtrInst instances.
2633 *
2634 * @{
2635 */
2636
2637/**
2638 * Check whether the given GEP instruction is inbounds.
2639 */
2640LLVMBool LLVMIsInBounds(LLVMValueRef GEP);
2641
2642/**
2643 * Set the given GEP instruction to be inbounds or not.
2644 */
2645void LLVMSetIsInBounds(LLVMValueRef GEP, LLVMBool b);
2646
2647/**
2648 * @}
2649 */
2650
2651/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002652 * @defgroup LLVMCCoreValueInstructionPHINode PHI Nodes
2653 *
2654 * Functions in this group only apply to instructions that map to
2655 * llvm::PHINode instances.
2656 *
2657 * @{
2658 */
2659
2660/**
2661 * Add an incoming value to the end of a PHI list.
2662 */
Gordon Henriksen44dd8fb2007-10-08 18:14:39 +00002663void LLVMAddIncoming(LLVMValueRef PhiNode, LLVMValueRef *IncomingValues,
2664 LLVMBasicBlockRef *IncomingBlocks, unsigned Count);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002665
2666/**
2667 * Obtain the number of incoming basic blocks to a PHI node.
2668 */
Gordon Henriksen44dd8fb2007-10-08 18:14:39 +00002669unsigned LLVMCountIncoming(LLVMValueRef PhiNode);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002670
2671/**
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00002672 * Obtain an incoming value to a PHI node as an LLVMValueRef.
Gregory Szorc34c863a2012-03-21 03:54:29 +00002673 */
Gordon Henriksen44dd8fb2007-10-08 18:14:39 +00002674LLVMValueRef LLVMGetIncomingValue(LLVMValueRef PhiNode, unsigned Index);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002675
2676/**
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00002677 * Obtain an incoming value to a PHI node as an LLVMBasicBlockRef.
Gregory Szorc34c863a2012-03-21 03:54:29 +00002678 */
Gordon Henriksen44dd8fb2007-10-08 18:14:39 +00002679LLVMBasicBlockRef LLVMGetIncomingBlock(LLVMValueRef PhiNode, unsigned Index);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002680
Gregory Szorc34c863a2012-03-21 03:54:29 +00002681/**
2682 * @}
2683 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002684
Gregory Szorc34c863a2012-03-21 03:54:29 +00002685/**
Amaury Sechetaad93532016-02-10 00:38:50 +00002686 * @defgroup LLVMCCoreValueInstructionExtractValue ExtractValue
2687 * @defgroup LLVMCCoreValueInstructionInsertValue InsertValue
2688 *
2689 * Functions in this group only apply to instructions that map to
2690 * llvm::ExtractValue and llvm::InsertValue instances.
2691 *
2692 * @{
2693 */
2694
2695/**
2696 * Obtain the number of indices.
Amaury Sechet053ac452016-02-17 22:51:03 +00002697 * NB: This also works on GEP.
Amaury Sechetaad93532016-02-10 00:38:50 +00002698 */
2699unsigned LLVMGetNumIndices(LLVMValueRef Inst);
2700
2701/**
2702 * Obtain the indices as an array.
2703 */
2704const unsigned *LLVMGetIndices(LLVMValueRef Inst);
2705
2706/**
2707 * @}
2708 */
2709
2710/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002711 * @}
2712 */
2713
2714/**
2715 * @}
2716 */
2717
2718/**
2719 * @defgroup LLVMCCoreInstructionBuilder Instruction Builders
2720 *
2721 * An instruction builder represents a point within a basic block and is
2722 * the exclusive means of building instructions using the C interface.
2723 *
2724 * @{
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002725 */
2726
Erick Tryzelaar262332f2009-08-14 00:01:31 +00002727LLVMBuilderRef LLVMCreateBuilderInContext(LLVMContextRef C);
Gordon Henriksena735a9c2008-05-04 12:55:34 +00002728LLVMBuilderRef LLVMCreateBuilder(void);
Gordon Henriksen054817c2008-03-19 03:47:18 +00002729void LLVMPositionBuilder(LLVMBuilderRef Builder, LLVMBasicBlockRef Block,
2730 LLVMValueRef Instr);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002731void LLVMPositionBuilderBefore(LLVMBuilderRef Builder, LLVMValueRef Instr);
2732void LLVMPositionBuilderAtEnd(LLVMBuilderRef Builder, LLVMBasicBlockRef Block);
Gordon Henriksen265f7802008-03-19 01:11:35 +00002733LLVMBasicBlockRef LLVMGetInsertBlock(LLVMBuilderRef Builder);
Chris Lattner3d1f5522008-12-17 21:39:50 +00002734void LLVMClearInsertionPosition(LLVMBuilderRef Builder);
2735void LLVMInsertIntoBuilder(LLVMBuilderRef Builder, LLVMValueRef Instr);
Erick Tryzelaar9813bea2009-08-16 02:20:57 +00002736void LLVMInsertIntoBuilderWithName(LLVMBuilderRef Builder, LLVMValueRef Instr,
2737 const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002738void LLVMDisposeBuilder(LLVMBuilderRef Builder);
2739
Erick Tryzelaard8531fa2010-02-28 09:45:59 +00002740/* Metadata */
2741void LLVMSetCurrentDebugLocation(LLVMBuilderRef Builder, LLVMValueRef L);
2742LLVMValueRef LLVMGetCurrentDebugLocation(LLVMBuilderRef Builder);
2743void LLVMSetInstDebugLocation(LLVMBuilderRef Builder, LLVMValueRef Inst);
2744
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002745/* Terminators */
2746LLVMValueRef LLVMBuildRetVoid(LLVMBuilderRef);
2747LLVMValueRef LLVMBuildRet(LLVMBuilderRef, LLVMValueRef V);
Erick Tryzelaarfd529d72009-08-19 08:36:49 +00002748LLVMValueRef LLVMBuildAggregateRet(LLVMBuilderRef, LLVMValueRef *RetVals,
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002749 unsigned N);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002750LLVMValueRef LLVMBuildBr(LLVMBuilderRef, LLVMBasicBlockRef Dest);
2751LLVMValueRef LLVMBuildCondBr(LLVMBuilderRef, LLVMValueRef If,
2752 LLVMBasicBlockRef Then, LLVMBasicBlockRef Else);
2753LLVMValueRef LLVMBuildSwitch(LLVMBuilderRef, LLVMValueRef V,
2754 LLVMBasicBlockRef Else, unsigned NumCases);
Erick Tryzelaar0fb26ef2010-02-28 09:46:06 +00002755LLVMValueRef LLVMBuildIndirectBr(LLVMBuilderRef B, LLVMValueRef Addr,
2756 unsigned NumDests);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002757LLVMValueRef LLVMBuildInvoke(LLVMBuilderRef, LLVMValueRef Fn,
2758 LLVMValueRef *Args, unsigned NumArgs,
2759 LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch,
2760 const char *Name);
Benjamin Kramer5a6568832011-08-19 01:36:54 +00002761LLVMValueRef LLVMBuildLandingPad(LLVMBuilderRef B, LLVMTypeRef Ty,
Reid Kleckneref9828f2015-07-16 01:16:39 +00002762 LLVMValueRef PersFn, unsigned NumClauses,
2763 const char *Name);
Bill Wendlingf891bf82011-07-31 06:30:59 +00002764LLVMValueRef LLVMBuildResume(LLVMBuilderRef B, LLVMValueRef Exn);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002765LLVMValueRef LLVMBuildUnreachable(LLVMBuilderRef);
2766
Gordon Henriksen097102c2008-01-01 05:50:53 +00002767/* Add a case to the switch instruction */
2768void LLVMAddCase(LLVMValueRef Switch, LLVMValueRef OnVal,
2769 LLVMBasicBlockRef Dest);
2770
Erick Tryzelaar0fb26ef2010-02-28 09:46:06 +00002771/* Add a destination to the indirectbr instruction */
2772void LLVMAddDestination(LLVMValueRef IndirectBr, LLVMBasicBlockRef Dest);
2773
Amaury Sechete39e8532016-02-18 20:38:32 +00002774/* Get the number of clauses on the landingpad instruction */
2775unsigned LLVMGetNumClauses(LLVMValueRef LandingPad);
2776
2777/* Get the value of the clause at idnex Idx on the landingpad instruction */
2778LLVMValueRef LLVMGetClause(LLVMValueRef LandingPad, unsigned Idx);
2779
Bill Wendlingfae14752011-08-12 20:24:12 +00002780/* Add a catch or filter clause to the landingpad instruction */
2781void LLVMAddClause(LLVMValueRef LandingPad, LLVMValueRef ClauseVal);
2782
Amaury Sechete39e8532016-02-18 20:38:32 +00002783/* Get the 'cleanup' flag in the landingpad instruction */
2784LLVMBool LLVMIsCleanup(LLVMValueRef LandingPad);
2785
Bill Wendlingfae14752011-08-12 20:24:12 +00002786/* Set the 'cleanup' flag in the landingpad instruction */
2787void LLVMSetCleanup(LLVMValueRef LandingPad, LLVMBool Val);
2788
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002789/* Arithmetic */
2790LLVMValueRef LLVMBuildAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2791 const char *Name);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002792LLVMValueRef LLVMBuildNSWAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2793 const char *Name);
Erick Tryzelaar4c340c72010-02-28 05:51:43 +00002794LLVMValueRef LLVMBuildNUWAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2795 const char *Name);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002796LLVMValueRef LLVMBuildFAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2797 const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002798LLVMValueRef LLVMBuildSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2799 const char *Name);
Erick Tryzelaar4c340c72010-02-28 05:51:43 +00002800LLVMValueRef LLVMBuildNSWSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2801 const char *Name);
2802LLVMValueRef LLVMBuildNUWSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2803 const char *Name);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002804LLVMValueRef LLVMBuildFSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2805 const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002806LLVMValueRef LLVMBuildMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2807 const char *Name);
Erick Tryzelaar4c340c72010-02-28 05:51:43 +00002808LLVMValueRef LLVMBuildNSWMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2809 const char *Name);
2810LLVMValueRef LLVMBuildNUWMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2811 const char *Name);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002812LLVMValueRef LLVMBuildFMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2813 const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002814LLVMValueRef LLVMBuildUDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2815 const char *Name);
2816LLVMValueRef LLVMBuildSDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2817 const char *Name);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002818LLVMValueRef LLVMBuildExactSDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2819 const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002820LLVMValueRef LLVMBuildFDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2821 const char *Name);
2822LLVMValueRef LLVMBuildURem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2823 const char *Name);
2824LLVMValueRef LLVMBuildSRem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2825 const char *Name);
2826LLVMValueRef LLVMBuildFRem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2827 const char *Name);
2828LLVMValueRef LLVMBuildShl(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2829 const char *Name);
2830LLVMValueRef LLVMBuildLShr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2831 const char *Name);
2832LLVMValueRef LLVMBuildAShr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2833 const char *Name);
2834LLVMValueRef LLVMBuildAnd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2835 const char *Name);
2836LLVMValueRef LLVMBuildOr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2837 const char *Name);
2838LLVMValueRef LLVMBuildXor(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2839 const char *Name);
Erick Tryzelaar31831792010-02-28 05:51:27 +00002840LLVMValueRef LLVMBuildBinOp(LLVMBuilderRef B, LLVMOpcode Op,
2841 LLVMValueRef LHS, LLVMValueRef RHS,
2842 const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002843LLVMValueRef LLVMBuildNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name);
Erick Tryzelaar4c340c72010-02-28 05:51:43 +00002844LLVMValueRef LLVMBuildNSWNeg(LLVMBuilderRef B, LLVMValueRef V,
2845 const char *Name);
2846LLVMValueRef LLVMBuildNUWNeg(LLVMBuilderRef B, LLVMValueRef V,
2847 const char *Name);
Dan Gohmanf919bd62009-09-28 21:51:41 +00002848LLVMValueRef LLVMBuildFNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002849LLVMValueRef LLVMBuildNot(LLVMBuilderRef, LLVMValueRef V, const char *Name);
2850
2851/* Memory */
2852LLVMValueRef LLVMBuildMalloc(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
2853LLVMValueRef LLVMBuildArrayMalloc(LLVMBuilderRef, LLVMTypeRef Ty,
2854 LLVMValueRef Val, const char *Name);
2855LLVMValueRef LLVMBuildAlloca(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
2856LLVMValueRef LLVMBuildArrayAlloca(LLVMBuilderRef, LLVMTypeRef Ty,
2857 LLVMValueRef Val, const char *Name);
2858LLVMValueRef LLVMBuildFree(LLVMBuilderRef, LLVMValueRef PointerVal);
2859LLVMValueRef LLVMBuildLoad(LLVMBuilderRef, LLVMValueRef PointerVal,
2860 const char *Name);
2861LLVMValueRef LLVMBuildStore(LLVMBuilderRef, LLVMValueRef Val, LLVMValueRef Ptr);
2862LLVMValueRef LLVMBuildGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
2863 LLVMValueRef *Indices, unsigned NumIndices,
2864 const char *Name);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002865LLVMValueRef LLVMBuildInBoundsGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
2866 LLVMValueRef *Indices, unsigned NumIndices,
2867 const char *Name);
2868LLVMValueRef LLVMBuildStructGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
2869 unsigned Idx, const char *Name);
2870LLVMValueRef LLVMBuildGlobalString(LLVMBuilderRef B, const char *Str,
2871 const char *Name);
2872LLVMValueRef LLVMBuildGlobalStringPtr(LLVMBuilderRef B, const char *Str,
2873 const char *Name);
Chris Lattner2cc6f9d2012-03-22 03:54:15 +00002874LLVMBool LLVMGetVolatile(LLVMValueRef MemoryAccessInst);
2875void LLVMSetVolatile(LLVMValueRef MemoryAccessInst, LLVMBool IsVolatile);
Andrew Wilkinsb7362ce2015-08-02 12:16:57 +00002876LLVMAtomicOrdering LLVMGetOrdering(LLVMValueRef MemoryAccessInst);
2877void LLVMSetOrdering(LLVMValueRef MemoryAccessInst, LLVMAtomicOrdering Ordering);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002878
2879/* Casts */
2880LLVMValueRef LLVMBuildTrunc(LLVMBuilderRef, LLVMValueRef Val,
2881 LLVMTypeRef DestTy, const char *Name);
2882LLVMValueRef LLVMBuildZExt(LLVMBuilderRef, LLVMValueRef Val,
2883 LLVMTypeRef DestTy, const char *Name);
2884LLVMValueRef LLVMBuildSExt(LLVMBuilderRef, LLVMValueRef Val,
2885 LLVMTypeRef DestTy, const char *Name);
2886LLVMValueRef LLVMBuildFPToUI(LLVMBuilderRef, LLVMValueRef Val,
2887 LLVMTypeRef DestTy, const char *Name);
2888LLVMValueRef LLVMBuildFPToSI(LLVMBuilderRef, LLVMValueRef Val,
2889 LLVMTypeRef DestTy, const char *Name);
2890LLVMValueRef LLVMBuildUIToFP(LLVMBuilderRef, LLVMValueRef Val,
2891 LLVMTypeRef DestTy, const char *Name);
2892LLVMValueRef LLVMBuildSIToFP(LLVMBuilderRef, LLVMValueRef Val,
2893 LLVMTypeRef DestTy, const char *Name);
2894LLVMValueRef LLVMBuildFPTrunc(LLVMBuilderRef, LLVMValueRef Val,
2895 LLVMTypeRef DestTy, const char *Name);
2896LLVMValueRef LLVMBuildFPExt(LLVMBuilderRef, LLVMValueRef Val,
2897 LLVMTypeRef DestTy, const char *Name);
2898LLVMValueRef LLVMBuildPtrToInt(LLVMBuilderRef, LLVMValueRef Val,
2899 LLVMTypeRef DestTy, const char *Name);
2900LLVMValueRef LLVMBuildIntToPtr(LLVMBuilderRef, LLVMValueRef Val,
2901 LLVMTypeRef DestTy, const char *Name);
2902LLVMValueRef LLVMBuildBitCast(LLVMBuilderRef, LLVMValueRef Val,
2903 LLVMTypeRef DestTy, const char *Name);
Matt Arsenaultb03bd4d2013-11-15 01:34:59 +00002904LLVMValueRef LLVMBuildAddrSpaceCast(LLVMBuilderRef, LLVMValueRef Val,
2905 LLVMTypeRef DestTy, const char *Name);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002906LLVMValueRef LLVMBuildZExtOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
2907 LLVMTypeRef DestTy, const char *Name);
2908LLVMValueRef LLVMBuildSExtOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
2909 LLVMTypeRef DestTy, const char *Name);
2910LLVMValueRef LLVMBuildTruncOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
2911 LLVMTypeRef DestTy, const char *Name);
Erick Tryzelaar31831792010-02-28 05:51:27 +00002912LLVMValueRef LLVMBuildCast(LLVMBuilderRef B, LLVMOpcode Op, LLVMValueRef Val,
2913 LLVMTypeRef DestTy, const char *Name);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002914LLVMValueRef LLVMBuildPointerCast(LLVMBuilderRef, LLVMValueRef Val,
2915 LLVMTypeRef DestTy, const char *Name);
Duncan Sands9d786d72009-11-23 10:49:03 +00002916LLVMValueRef LLVMBuildIntCast(LLVMBuilderRef, LLVMValueRef Val, /*Signed cast!*/
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002917 LLVMTypeRef DestTy, const char *Name);
2918LLVMValueRef LLVMBuildFPCast(LLVMBuilderRef, LLVMValueRef Val,
2919 LLVMTypeRef DestTy, const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002920
2921/* Comparisons */
2922LLVMValueRef LLVMBuildICmp(LLVMBuilderRef, LLVMIntPredicate Op,
2923 LLVMValueRef LHS, LLVMValueRef RHS,
2924 const char *Name);
2925LLVMValueRef LLVMBuildFCmp(LLVMBuilderRef, LLVMRealPredicate Op,
2926 LLVMValueRef LHS, LLVMValueRef RHS,
2927 const char *Name);
2928
2929/* Miscellaneous instructions */
2930LLVMValueRef LLVMBuildPhi(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
2931LLVMValueRef LLVMBuildCall(LLVMBuilderRef, LLVMValueRef Fn,
2932 LLVMValueRef *Args, unsigned NumArgs,
2933 const char *Name);
2934LLVMValueRef LLVMBuildSelect(LLVMBuilderRef, LLVMValueRef If,
2935 LLVMValueRef Then, LLVMValueRef Else,
2936 const char *Name);
2937LLVMValueRef LLVMBuildVAArg(LLVMBuilderRef, LLVMValueRef List, LLVMTypeRef Ty,
2938 const char *Name);
2939LLVMValueRef LLVMBuildExtractElement(LLVMBuilderRef, LLVMValueRef VecVal,
2940 LLVMValueRef Index, const char *Name);
2941LLVMValueRef LLVMBuildInsertElement(LLVMBuilderRef, LLVMValueRef VecVal,
2942 LLVMValueRef EltVal, LLVMValueRef Index,
2943 const char *Name);
2944LLVMValueRef LLVMBuildShuffleVector(LLVMBuilderRef, LLVMValueRef V1,
2945 LLVMValueRef V2, LLVMValueRef Mask,
2946 const char *Name);
Dan Gohmand5104a52008-11-03 22:55:43 +00002947LLVMValueRef LLVMBuildExtractValue(LLVMBuilderRef, LLVMValueRef AggVal,
2948 unsigned Index, const char *Name);
2949LLVMValueRef LLVMBuildInsertValue(LLVMBuilderRef, LLVMValueRef AggVal,
2950 LLVMValueRef EltVal, unsigned Index,
2951 const char *Name);
Gordon Henriksen76a03742007-09-18 03:18:57 +00002952
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002953LLVMValueRef LLVMBuildIsNull(LLVMBuilderRef, LLVMValueRef Val,
2954 const char *Name);
2955LLVMValueRef LLVMBuildIsNotNull(LLVMBuilderRef, LLVMValueRef Val,
2956 const char *Name);
2957LLVMValueRef LLVMBuildPtrDiff(LLVMBuilderRef, LLVMValueRef LHS,
2958 LLVMValueRef RHS, const char *Name);
Filip Pizlo0d3f7ec2013-11-20 00:07:49 +00002959LLVMValueRef LLVMBuildFence(LLVMBuilderRef B, LLVMAtomicOrdering ordering,
2960 LLVMBool singleThread, const char *Name);
2961LLVMValueRef LLVMBuildAtomicRMW(LLVMBuilderRef B, LLVMAtomicRMWBinOp op,
NAKAMURA Takumia3a81352013-10-23 17:56:29 +00002962 LLVMValueRef PTR, LLVMValueRef Val,
2963 LLVMAtomicOrdering ordering,
Carlo Kok8c6719b2013-04-23 13:21:19 +00002964 LLVMBool singleThread);
Mehdi Amini43165d92016-03-19 21:28:28 +00002965LLVMValueRef LLVMBuildAtomicCmpXchg(LLVMBuilderRef B, LLVMValueRef Ptr,
2966 LLVMValueRef Cmp, LLVMValueRef New,
2967 LLVMAtomicOrdering SuccessOrdering,
2968 LLVMAtomicOrdering FailureOrdering,
2969 LLVMBool SingleThread);
2970
2971LLVMBool LLVMIsAtomicSingleThread(LLVMValueRef AtomicInst);
2972void LLVMSetAtomicSingleThread(LLVMValueRef AtomicInst, LLVMBool SingleThread);
2973
2974LLVMAtomicOrdering LLVMGetCmpXchgSuccessOrdering(LLVMValueRef CmpXchgInst);
2975void LLVMSetCmpXchgSuccessOrdering(LLVMValueRef CmpXchgInst,
2976 LLVMAtomicOrdering Ordering);
2977LLVMAtomicOrdering LLVMGetCmpXchgFailureOrdering(LLVMValueRef CmpXchgInst);
2978void LLVMSetCmpXchgFailureOrdering(LLVMValueRef CmpXchgInst,
2979 LLVMAtomicOrdering Ordering);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002980
Gregory Szorc34c863a2012-03-21 03:54:29 +00002981/**
2982 * @}
2983 */
Gordon Henriksen34eb6d82007-12-19 22:30:40 +00002984
Gregory Szorc34c863a2012-03-21 03:54:29 +00002985/**
2986 * @defgroup LLVMCCoreModuleProvider Module Providers
2987 *
2988 * @{
2989 */
Gordon Henriksen0a68fe22007-12-12 01:04:30 +00002990
Gregory Szorc34c863a2012-03-21 03:54:29 +00002991/**
2992 * Changes the type of M so it can be passed to FunctionPassManagers and the
Jeffrey Yasskin091217b2010-01-27 20:34:15 +00002993 * JIT. They take ModuleProviders for historical reasons.
Gordon Henriksen0a68fe22007-12-12 01:04:30 +00002994 */
2995LLVMModuleProviderRef
2996LLVMCreateModuleProviderForExistingModule(LLVMModuleRef M);
2997
Gregory Szorc34c863a2012-03-21 03:54:29 +00002998/**
2999 * Destroys the module M.
Gordon Henriksen0a68fe22007-12-12 01:04:30 +00003000 */
Jeffrey Yasskin091217b2010-01-27 20:34:15 +00003001void LLVMDisposeModuleProvider(LLVMModuleProviderRef M);
Gordon Henriksen0a68fe22007-12-12 01:04:30 +00003002
Gregory Szorc34c863a2012-03-21 03:54:29 +00003003/**
3004 * @}
3005 */
Gordon Henriksen34eb6d82007-12-19 22:30:40 +00003006
Gregory Szorc34c863a2012-03-21 03:54:29 +00003007/**
3008 * @defgroup LLVMCCoreMemoryBuffers Memory Buffers
3009 *
3010 * @{
3011 */
Gordon Henriksen34eb6d82007-12-19 22:30:40 +00003012
Chris Lattner25963c62010-01-09 22:27:07 +00003013LLVMBool LLVMCreateMemoryBufferWithContentsOfFile(const char *Path,
3014 LLVMMemoryBufferRef *OutMemBuf,
3015 char **OutMessage);
3016LLVMBool LLVMCreateMemoryBufferWithSTDIN(LLVMMemoryBufferRef *OutMemBuf,
3017 char **OutMessage);
Bill Wendling526276a2013-02-14 19:11:28 +00003018LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRange(const char *InputData,
3019 size_t InputDataLength,
3020 const char *BufferName,
Bill Wendlingc9baa962013-02-14 19:39:14 +00003021 LLVMBool RequiresNullTerminator);
Bill Wendling526276a2013-02-14 19:11:28 +00003022LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRangeCopy(const char *InputData,
3023 size_t InputDataLength,
3024 const char *BufferName);
Tom Stellard62c03202013-04-18 19:50:53 +00003025const char *LLVMGetBufferStart(LLVMMemoryBufferRef MemBuf);
Tom Stellardb7fb7242013-04-16 23:12:51 +00003026size_t LLVMGetBufferSize(LLVMMemoryBufferRef MemBuf);
Gordon Henriksen34eb6d82007-12-19 22:30:40 +00003027void LLVMDisposeMemoryBuffer(LLVMMemoryBufferRef MemBuf);
3028
Gregory Szorc34c863a2012-03-21 03:54:29 +00003029/**
3030 * @}
3031 */
3032
3033/**
3034 * @defgroup LLVMCCorePassRegistry Pass Registry
3035 *
3036 * @{
3037 */
Owen Anderson4698c5d2010-10-07 17:55:47 +00003038
3039/** Return the global pass registry, for use with initialization functions.
Gregory Szorc34c863a2012-03-21 03:54:29 +00003040 @see llvm::PassRegistry::getPassRegistry */
Owen Anderson4698c5d2010-10-07 17:55:47 +00003041LLVMPassRegistryRef LLVMGetGlobalPassRegistry(void);
Gordon Henriksen878114b2008-03-16 04:20:44 +00003042
Gregory Szorc34c863a2012-03-21 03:54:29 +00003043/**
3044 * @}
3045 */
3046
3047/**
3048 * @defgroup LLVMCCorePassManagers Pass Managers
3049 *
3050 * @{
3051 */
Gordon Henriksen878114b2008-03-16 04:20:44 +00003052
3053/** Constructs a new whole-module pass pipeline. This type of pipeline is
3054 suitable for link-time optimization and whole-module transformations.
Gregory Szorc34c863a2012-03-21 03:54:29 +00003055 @see llvm::PassManager::PassManager */
Gordon Henriksena735a9c2008-05-04 12:55:34 +00003056LLVMPassManagerRef LLVMCreatePassManager(void);
Gordon Henriksen878114b2008-03-16 04:20:44 +00003057
3058/** Constructs a new function-by-function pass pipeline over the module
3059 provider. It does not take ownership of the module provider. This type of
3060 pipeline is suitable for code generation and JIT compilation tasks.
Gregory Szorc34c863a2012-03-21 03:54:29 +00003061 @see llvm::FunctionPassManager::FunctionPassManager */
Erick Tryzelaarad0e0cb2010-03-02 23:58:54 +00003062LLVMPassManagerRef LLVMCreateFunctionPassManagerForModule(LLVMModuleRef M);
3063
3064/** Deprecated: Use LLVMCreateFunctionPassManagerForModule instead. */
Gordon Henriksen878114b2008-03-16 04:20:44 +00003065LLVMPassManagerRef LLVMCreateFunctionPassManager(LLVMModuleProviderRef MP);
3066
3067/** Initializes, executes on the provided module, and finalizes all of the
3068 passes scheduled in the pass manager. Returns 1 if any of the passes
Gregory Szorc34c863a2012-03-21 03:54:29 +00003069 modified the module, 0 otherwise.
3070 @see llvm::PassManager::run(Module&) */
Chris Lattner25963c62010-01-09 22:27:07 +00003071LLVMBool LLVMRunPassManager(LLVMPassManagerRef PM, LLVMModuleRef M);
Gordon Henriksen878114b2008-03-16 04:20:44 +00003072
3073/** Initializes all of the function passes scheduled in the function pass
3074 manager. Returns 1 if any of the passes modified the module, 0 otherwise.
Gregory Szorc34c863a2012-03-21 03:54:29 +00003075 @see llvm::FunctionPassManager::doInitialization */
Chris Lattner25963c62010-01-09 22:27:07 +00003076LLVMBool LLVMInitializeFunctionPassManager(LLVMPassManagerRef FPM);
Gordon Henriksen878114b2008-03-16 04:20:44 +00003077
3078/** Executes all of the function passes scheduled in the function pass manager
3079 on the provided function. Returns 1 if any of the passes modified the
3080 function, false otherwise.
Gregory Szorc34c863a2012-03-21 03:54:29 +00003081 @see llvm::FunctionPassManager::run(Function&) */
Chris Lattner25963c62010-01-09 22:27:07 +00003082LLVMBool LLVMRunFunctionPassManager(LLVMPassManagerRef FPM, LLVMValueRef F);
Gordon Henriksen878114b2008-03-16 04:20:44 +00003083
3084/** Finalizes all of the function passes scheduled in in the function pass
3085 manager. Returns 1 if any of the passes modified the module, 0 otherwise.
Gregory Szorc34c863a2012-03-21 03:54:29 +00003086 @see llvm::FunctionPassManager::doFinalization */
Chris Lattner25963c62010-01-09 22:27:07 +00003087LLVMBool LLVMFinalizeFunctionPassManager(LLVMPassManagerRef FPM);
Gordon Henriksen878114b2008-03-16 04:20:44 +00003088
3089/** Frees the memory of a pass pipeline. For function pipelines, does not free
3090 the module provider.
Gregory Szorc34c863a2012-03-21 03:54:29 +00003091 @see llvm::PassManagerBase::~PassManagerBase. */
Gordon Henriksen878114b2008-03-16 04:20:44 +00003092void LLVMDisposePassManager(LLVMPassManagerRef PM);
3093
Gregory Szorc34c863a2012-03-21 03:54:29 +00003094/**
3095 * @}
3096 */
3097
3098/**
Duncan Sands1cba0a82013-02-17 16:35:51 +00003099 * @defgroup LLVMCCoreThreading Threading
3100 *
3101 * Handle the structures needed to make LLVM safe for multithreading.
3102 *
3103 * @{
3104 */
3105
Chandler Carruth39cd2162014-06-27 15:13:01 +00003106/** Deprecated: Multi-threading can only be enabled/disabled with the compile
3107 time define LLVM_ENABLE_THREADS. This function always returns
3108 LLVMIsMultithreaded(). */
Benjamin Kramer325ec892013-10-23 16:57:34 +00003109LLVMBool LLVMStartMultithreaded(void);
Duncan Sands1cba0a82013-02-17 16:35:51 +00003110
Chandler Carruth39cd2162014-06-27 15:13:01 +00003111/** Deprecated: Multi-threading can only be enabled/disabled with the compile
3112 time define LLVM_ENABLE_THREADS. */
Benjamin Kramer325ec892013-10-23 16:57:34 +00003113void LLVMStopMultithreaded(void);
Duncan Sands1cba0a82013-02-17 16:35:51 +00003114
3115/** Check whether LLVM is executing in thread-safe mode or not.
3116 @see llvm::llvm_is_multithreaded */
Benjamin Kramer325ec892013-10-23 16:57:34 +00003117LLVMBool LLVMIsMultithreaded(void);
Duncan Sands1cba0a82013-02-17 16:35:51 +00003118
3119/**
3120 * @}
3121 */
3122
3123/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00003124 * @}
3125 */
3126
3127/**
3128 * @}
3129 */
Gordon Henriksen878114b2008-03-16 04:20:44 +00003130
Gordon Henriksen76a03742007-09-18 03:18:57 +00003131#ifdef __cplusplus
3132}
Eugene Zelenkoffec81c2015-11-04 22:32:32 +00003133#endif
Gordon Henriksen7330acd2007-10-05 23:59:36 +00003134
Eugene Zelenkoffec81c2015-11-04 22:32:32 +00003135#endif /* LLVM_C_CORE_H */