blob: a339ce9c31e6f4e179a6fd28085e1afd4c2b08c9 [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 {
Peter Zotov3e4561c2016-04-06 22:21:29 +0000251 LLVMArgumentValueKind,
252 LLVMBasicBlockValueKind,
253 LLVMMemoryUseValueKind,
254 LLVMMemoryDefValueKind,
255 LLVMMemoryPhiValueKind,
256
257 LLVMFunctionValueKind,
258 LLVMGlobalAliasValueKind,
Dmitry Polukhina1feff72016-04-07 12:32:19 +0000259 LLVMGlobalIFuncValueKind,
Peter Zotov3e4561c2016-04-06 22:21:29 +0000260 LLVMGlobalVariableValueKind,
261 LLVMBlockAddressValueKind,
262 LLVMConstantExprValueKind,
263 LLVMConstantArrayValueKind,
264 LLVMConstantStructValueKind,
265 LLVMConstantVectorValueKind,
266
267 LLVMUndefValueValueKind,
268 LLVMConstantAggregateZeroValueKind,
269 LLVMConstantDataArrayValueKind,
270 LLVMConstantDataVectorValueKind,
271 LLVMConstantIntValueKind,
272 LLVMConstantFPValueKind,
273 LLVMConstantPointerNullValueKind,
274 LLVMConstantTokenNoneValueKind,
275
276 LLVMMetadataAsValueValueKind,
277 LLVMInlineAsmValueKind,
278
279 LLVMInstructionValueKind,
280} LLVMValueKind;
281
282typedef enum {
Gordon Henriksen4a4d7352007-12-30 17:46:33 +0000283 LLVMIntEQ = 32, /**< equal */
284 LLVMIntNE, /**< not equal */
285 LLVMIntUGT, /**< unsigned greater than */
286 LLVMIntUGE, /**< unsigned greater or equal */
287 LLVMIntULT, /**< unsigned less than */
288 LLVMIntULE, /**< unsigned less or equal */
289 LLVMIntSGT, /**< signed greater than */
290 LLVMIntSGE, /**< signed greater or equal */
291 LLVMIntSLT, /**< signed less than */
292 LLVMIntSLE /**< signed less or equal */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +0000293} LLVMIntPredicate;
294
295typedef enum {
Gordon Henriksen4a4d7352007-12-30 17:46:33 +0000296 LLVMRealPredicateFalse, /**< Always false (always folded) */
297 LLVMRealOEQ, /**< True if ordered and equal */
298 LLVMRealOGT, /**< True if ordered and greater than */
299 LLVMRealOGE, /**< True if ordered and greater than or equal */
300 LLVMRealOLT, /**< True if ordered and less than */
301 LLVMRealOLE, /**< True if ordered and less than or equal */
302 LLVMRealONE, /**< True if ordered and operands are unequal */
303 LLVMRealORD, /**< True if ordered (no nans) */
304 LLVMRealUNO, /**< True if unordered: isnan(X) | isnan(Y) */
305 LLVMRealUEQ, /**< True if unordered or equal */
306 LLVMRealUGT, /**< True if unordered or greater than */
307 LLVMRealUGE, /**< True if unordered, greater than, or equal */
308 LLVMRealULT, /**< True if unordered or less than */
309 LLVMRealULE, /**< True if unordered, less than, or equal */
310 LLVMRealUNE, /**< True if unordered or not equal */
311 LLVMRealPredicateTrue /**< Always true (always folded) */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +0000312} LLVMRealPredicate;
313
Bill Wendlingfae14752011-08-12 20:24:12 +0000314typedef enum {
315 LLVMLandingPadCatch, /**< A catch clause */
316 LLVMLandingPadFilter /**< A filter clause */
317} LLVMLandingPadClauseTy;
318
Hans Wennborg5ff71202013-04-16 08:58:59 +0000319typedef enum {
320 LLVMNotThreadLocal = 0,
321 LLVMGeneralDynamicTLSModel,
322 LLVMLocalDynamicTLSModel,
323 LLVMInitialExecTLSModel,
324 LLVMLocalExecTLSModel
325} LLVMThreadLocalMode;
326
Carlo Kokda0ac722013-04-23 13:45:37 +0000327typedef enum {
Carlo Kok8c6719b2013-04-23 13:21:19 +0000328 LLVMAtomicOrderingNotAtomic = 0, /**< A load or store which is not atomic */
329 LLVMAtomicOrderingUnordered = 1, /**< Lowest level of atomicity, guarantees
330 somewhat sane results, lock free. */
NAKAMURA Takumia3a81352013-10-23 17:56:29 +0000331 LLVMAtomicOrderingMonotonic = 2, /**< guarantees that if you take all the
332 operations affecting a specific address,
Carlo Kok8c6719b2013-04-23 13:21:19 +0000333 a consistent ordering exists */
NAKAMURA Takumia3a81352013-10-23 17:56:29 +0000334 LLVMAtomicOrderingAcquire = 4, /**< Acquire provides a barrier of the sort
335 necessary to acquire a lock to access other
Carlo Kok8c6719b2013-04-23 13:21:19 +0000336 memory with normal loads and stores. */
NAKAMURA Takumia3a81352013-10-23 17:56:29 +0000337 LLVMAtomicOrderingRelease = 5, /**< Release is similar to Acquire, but with
338 a barrier of the sort necessary to release
Carlo Kok8c6719b2013-04-23 13:21:19 +0000339 a lock. */
NAKAMURA Takumia3a81352013-10-23 17:56:29 +0000340 LLVMAtomicOrderingAcquireRelease = 6, /**< provides both an Acquire and a
341 Release barrier (for fences and
Carlo Kok8c6719b2013-04-23 13:21:19 +0000342 operations which both read and write
343 memory). */
NAKAMURA Takumia3a81352013-10-23 17:56:29 +0000344 LLVMAtomicOrderingSequentiallyConsistent = 7 /**< provides Acquire semantics
345 for loads and Release
346 semantics for stores.
347 Additionally, it guarantees
348 that a total ordering exists
349 between all
350 SequentiallyConsistent
Carlo Kok8c6719b2013-04-23 13:21:19 +0000351 operations. */
Carlo Kokda0ac722013-04-23 13:45:37 +0000352} LLVMAtomicOrdering;
Carlo Kok8c6719b2013-04-23 13:21:19 +0000353
Carlo Kokda0ac722013-04-23 13:45:37 +0000354typedef enum {
Carlo Kok8c6719b2013-04-23 13:21:19 +0000355 LLVMAtomicRMWBinOpXchg, /**< Set the new value and return the one old */
356 LLVMAtomicRMWBinOpAdd, /**< Add a value and return the old one */
357 LLVMAtomicRMWBinOpSub, /**< Subtract a value and return the old one */
358 LLVMAtomicRMWBinOpAnd, /**< And a value and return the old one */
359 LLVMAtomicRMWBinOpNand, /**< Not-And a value and return the old one */
360 LLVMAtomicRMWBinOpOr, /**< OR a value and return the old one */
361 LLVMAtomicRMWBinOpXor, /**< Xor a value and return the old one */
362 LLVMAtomicRMWBinOpMax, /**< Sets the value if it's greater than the
NAKAMURA Takumia3a81352013-10-23 17:56:29 +0000363 original using a signed comparison and return
Carlo Kok8c6719b2013-04-23 13:21:19 +0000364 the old one */
365 LLVMAtomicRMWBinOpMin, /**< Sets the value if it's Smaller than the
NAKAMURA Takumia3a81352013-10-23 17:56:29 +0000366 original using a signed comparison and return
Carlo Kok8c6719b2013-04-23 13:21:19 +0000367 the old one */
368 LLVMAtomicRMWBinOpUMax, /**< Sets the value if it's greater than the
NAKAMURA Takumia3a81352013-10-23 17:56:29 +0000369 original using an unsigned comparison and return
Carlo Kok8c6719b2013-04-23 13:21:19 +0000370 the old one */
371 LLVMAtomicRMWBinOpUMin /**< Sets the value if it's greater than the
NAKAMURA Takumia3a81352013-10-23 17:56:29 +0000372 original using an unsigned comparison and return
Carlo Kok8c6719b2013-04-23 13:21:19 +0000373 the old one */
Carlo Kokda0ac722013-04-23 13:45:37 +0000374} LLVMAtomicRMWBinOp;
Carlo Kok8c6719b2013-04-23 13:21:19 +0000375
Tom Stellard1580dc72014-04-16 17:45:04 +0000376typedef enum {
377 LLVMDSError,
378 LLVMDSWarning,
379 LLVMDSRemark,
380 LLVMDSNote
381} LLVMDiagnosticSeverity;
382
Gregory Szorc34c863a2012-03-21 03:54:29 +0000383/**
384 * @}
385 */
386
Nick Lewycky0db26542011-05-15 07:20:34 +0000387void LLVMInitializeCore(LLVMPassRegistryRef R);
388
Duncan Sands1cba0a82013-02-17 16:35:51 +0000389/** Deallocate and destroy all ManagedStatic variables.
390 @see llvm::llvm_shutdown
391 @see ManagedStatic */
Benjamin Kramer325ec892013-10-23 16:57:34 +0000392void LLVMShutdown(void);
Duncan Sands1cba0a82013-02-17 16:35:51 +0000393
Gordon Henriksen34eb6d82007-12-19 22:30:40 +0000394/*===-- Error handling ----------------------------------------------------===*/
395
Filip Pizlo3fdbaff2013-05-22 02:46:43 +0000396char *LLVMCreateMessage(const char *Message);
Gordon Henriksen34eb6d82007-12-19 22:30:40 +0000397void LLVMDisposeMessage(char *Message);
398
Filip Pizlo9f50ccd2013-11-03 00:29:47 +0000399/**
Gregory Szorc34c863a2012-03-21 03:54:29 +0000400 * @defgroup LLVMCCoreContext Contexts
401 *
402 * Contexts are execution states for the core LLVM IR system.
403 *
404 * Most types are tied to a context instance. Multiple contexts can
405 * exist simultaneously. A single context is not thread safe. However,
406 * different contexts can execute on different threads simultaneously.
407 *
408 * @{
409 */
Gordon Henriksen76a03742007-09-18 03:18:57 +0000410
Tom Stellard1580dc72014-04-16 17:45:04 +0000411typedef void (*LLVMDiagnosticHandler)(LLVMDiagnosticInfoRef, void *);
Juergen Ributzka34390c72014-05-16 02:33:15 +0000412typedef void (*LLVMYieldCallback)(LLVMContextRef, void *);
Tom Stellard1580dc72014-04-16 17:45:04 +0000413
Gregory Szorc34c863a2012-03-21 03:54:29 +0000414/**
415 * Create a new context.
416 *
417 * Every call to this function should be paired with a call to
418 * LLVMContextDispose() or the context will leak memory.
419 */
Erick Tryzelaarf34cb0c2009-08-30 23:38:06 +0000420LLVMContextRef LLVMContextCreate(void);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000421
422/**
423 * Obtain the global context instance.
424 */
Erick Tryzelaarf34cb0c2009-08-30 23:38:06 +0000425LLVMContextRef LLVMGetGlobalContext(void);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000426
427/**
Tom Stellard1580dc72014-04-16 17:45:04 +0000428 * Set the diagnostic handler for this context.
429 */
430void LLVMContextSetDiagnosticHandler(LLVMContextRef C,
431 LLVMDiagnosticHandler Handler,
432 void *DiagnosticContext);
433
434/**
Juergen Ributzka34390c72014-05-16 02:33:15 +0000435 * Set the yield callback function for this context.
436 *
437 * @see LLVMContext::setYieldCallback()
438 */
439void LLVMContextSetYieldCallback(LLVMContextRef C, LLVMYieldCallback Callback,
440 void *OpaqueHandle);
441
442/**
Gregory Szorc34c863a2012-03-21 03:54:29 +0000443 * Destroy a context instance.
444 *
445 * This should be called for every call to LLVMContextCreate() or memory
446 * will be leaked.
447 */
Owen Anderson6773d382009-07-01 16:58:40 +0000448void LLVMContextDispose(LLVMContextRef C);
449
Tom Stellard1580dc72014-04-16 17:45:04 +0000450/**
451 * Return a string representation of the DiagnosticInfo. Use
452 * LLVMDisposeMessage to free the string.
453 *
454 * @see DiagnosticInfo::print()
455 */
456char *LLVMGetDiagInfoDescription(LLVMDiagnosticInfoRef DI);
457
458/**
459 * Return an enum LLVMDiagnosticSeverity.
460 *
461 * @see DiagnosticInfo::getSeverity()
462 */
463LLVMDiagnosticSeverity LLVMGetDiagInfoSeverity(LLVMDiagnosticInfoRef DI);
464
Amaury Sechet56f056c2016-04-04 22:00:25 +0000465unsigned LLVMGetMDKindIDInContext(LLVMContextRef C, const char *Name,
Erick Tryzelaard8531fa2010-02-28 09:45:59 +0000466 unsigned SLen);
Amaury Sechet56f056c2016-04-04 22:00:25 +0000467unsigned LLVMGetMDKindID(const char *Name, unsigned SLen);
Erick Tryzelaard8531fa2010-02-28 09:45:59 +0000468
Gregory Szorc34c863a2012-03-21 03:54:29 +0000469/**
470 * @}
471 */
472
Gregory Szorc52d26602012-03-21 07:28:27 +0000473/**
474 * @defgroup LLVMCCoreModule Modules
Gregory Szorc34c863a2012-03-21 03:54:29 +0000475 *
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +0000476 * Modules represent the top-level structure in an LLVM program. An LLVM
Gregory Szorc34c863a2012-03-21 03:54:29 +0000477 * module is effectively a translation unit or a collection of
478 * translation units merged together.
479 *
480 * @{
481 */
482
Gregory Szorc34c863a2012-03-21 03:54:29 +0000483/**
484 * Create a new, empty module in the global context.
485 *
486 * This is equivalent to calling LLVMModuleCreateWithNameInContext with
487 * LLVMGetGlobalContext() as the context parameter.
488 *
489 * Every invocation should be paired with LLVMDisposeModule() or memory
490 * will be leaked.
491 */
Gordon Henriksen76a03742007-09-18 03:18:57 +0000492LLVMModuleRef LLVMModuleCreateWithName(const char *ModuleID);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000493
494/**
495 * Create a new, empty module in a specific context.
496 *
497 * Every invocation should be paired with LLVMDisposeModule() or memory
498 * will be leaked.
499 */
Owen Anderson31d44e42009-07-02 07:17:57 +0000500LLVMModuleRef LLVMModuleCreateWithNameInContext(const char *ModuleID,
501 LLVMContextRef C);
Tom Stellard0a4e9a32014-10-01 17:14:57 +0000502/**
503 * Return an exact copy of the specified module.
504 */
505LLVMModuleRef LLVMCloneModule(LLVMModuleRef M);
Gordon Henriksena49d4352008-03-07 19:13:06 +0000506
Gregory Szorc34c863a2012-03-21 03:54:29 +0000507/**
508 * Destroy a module instance.
509 *
510 * This must be called for every created module or memory will be
511 * leaked.
512 */
Gordon Henriksen76a03742007-09-18 03:18:57 +0000513void LLVMDisposeModule(LLVMModuleRef M);
514
Gregory Szorc34c863a2012-03-21 03:54:29 +0000515/**
Peter Zotov0a2fa0a2016-04-05 13:56:59 +0000516 * Obtain the identifier of a module.
517 *
518 * @param M Module to obtain identifier of
519 * @param Len Out parameter which holds the length of the returned string.
520 * @return The identifier of M.
521 * @see Module::getModuleIdentifier()
522 */
523const char *LLVMGetModuleIdentifier(LLVMModuleRef M, size_t *Len);
524
525/**
526 * Set the identifier of a module to a string Ident with length Len.
527 *
528 * @param M The module to set identifier
529 * @param Ident The string to set M's identifier to
530 * @param Len Length of Ident
531 * @see Module::setModuleIdentifier()
532 */
533void LLVMSetModuleIdentifier(LLVMModuleRef M, const char *Ident, size_t Len);
534
535/**
Gregory Szorc34c863a2012-03-21 03:54:29 +0000536 * Obtain the data layout for a module.
537 *
Amaury Sechetf3549c42016-02-16 00:23:52 +0000538 * @see Module::getDataLayoutStr()
539 *
540 * LLVMGetDataLayout is DEPRECATED, as the name is not only incorrect,
541 * but match the name of another method on the module. Prefer the use
542 * of LLVMGetDataLayoutStr, which is not ambiguous.
Gregory Szorc34c863a2012-03-21 03:54:29 +0000543 */
Amaury Sechetf3549c42016-02-16 00:23:52 +0000544const char *LLVMGetDataLayoutStr(LLVMModuleRef M);
Gordon Henriksen05568bb2007-12-27 20:13:47 +0000545const char *LLVMGetDataLayout(LLVMModuleRef M);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000546
547/**
548 * Set the data layout for a module.
549 *
550 * @see Module::setDataLayout()
551 */
Amaury Sechet6ada31c2016-02-15 23:40:06 +0000552void LLVMSetDataLayout(LLVMModuleRef M, const char *DataLayoutStr);
Gordon Henriksen05568bb2007-12-27 20:13:47 +0000553
Gregory Szorc34c863a2012-03-21 03:54:29 +0000554/**
555 * Obtain the target triple for a module.
556 *
557 * @see Module::getTargetTriple()
558 */
Gordon Henriksen05568bb2007-12-27 20:13:47 +0000559const char *LLVMGetTarget(LLVMModuleRef M);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000560
561/**
562 * Set the target triple for a module.
563 *
564 * @see Module::setTargetTriple()
565 */
Gordon Henriksen05568bb2007-12-27 20:13:47 +0000566void LLVMSetTarget(LLVMModuleRef M, const char *Triple);
567
Gregory Szorc34c863a2012-03-21 03:54:29 +0000568/**
569 * Dump a representation of a module to stderr.
570 *
571 * @see Module::dump()
572 */
Gordon Henriksen6c6075e2008-03-14 23:58:56 +0000573void LLVMDumpModule(LLVMModuleRef M);
574
Gregory Szorc34c863a2012-03-21 03:54:29 +0000575/**
Hans Wennborgb7ef2fe2012-05-09 16:54:17 +0000576 * Print a representation of a module to a file. The ErrorMessage needs to be
577 * disposed with LLVMDisposeMessage. Returns 0 on success, 1 otherwise.
578 *
579 * @see Module::print()
580 */
581LLVMBool LLVMPrintModuleToFile(LLVMModuleRef M, const char *Filename,
582 char **ErrorMessage);
583
584/**
Anders Waldenborg84355db2013-10-16 18:00:54 +0000585 * Return a string representation of the module. Use
586 * LLVMDisposeMessage to free the string.
587 *
588 * @see Module::print()
589 */
590char *LLVMPrintModuleToString(LLVMModuleRef M);
591
592/**
Gregory Szorc34c863a2012-03-21 03:54:29 +0000593 * Set inline assembly for a module.
594 *
595 * @see Module::setModuleInlineAsm()
596 */
Chris Lattner26941452010-04-10 17:52:58 +0000597void LLVMSetModuleInlineAsm(LLVMModuleRef M, const char *Asm);
Gordon Henriksen76a03742007-09-18 03:18:57 +0000598
Gregory Szorc34c863a2012-03-21 03:54:29 +0000599/**
600 * Obtain the context to which this module is associated.
601 *
602 * @see Module::getContext()
603 */
Chris Lattnera7e04b02010-11-28 20:03:44 +0000604LLVMContextRef LLVMGetModuleContext(LLVMModuleRef M);
605
Gregory Szorc34c863a2012-03-21 03:54:29 +0000606/**
607 * Obtain a Type from a module by its registered name.
608 */
609LLVMTypeRef LLVMGetTypeByName(LLVMModuleRef M, const char *Name);
Gordon Henriksen76a03742007-09-18 03:18:57 +0000610
Gregory Szorc34c863a2012-03-21 03:54:29 +0000611/**
612 * Obtain the number of operands for named metadata in a module.
613 *
614 * @see llvm::Module::getNamedMetadata()
615 */
616unsigned LLVMGetNamedMetadataNumOperands(LLVMModuleRef M, const char* name);
617
618/**
619 * Obtain the named metadata operands for a module.
620 *
621 * The passed LLVMValueRef pointer should refer to an array of
622 * LLVMValueRef at least LLVMGetNamedMetadataNumOperands long. This
623 * array will be populated with the LLVMValueRef instances. Each
624 * instance corresponds to a llvm::MDNode.
625 *
626 * @see llvm::Module::getNamedMetadata()
627 * @see llvm::MDNode::getOperand()
628 */
629void LLVMGetNamedMetadataOperands(LLVMModuleRef M, const char* name, LLVMValueRef *Dest);
630
631/**
632 * Add an operand to named metadata.
633 *
634 * @see llvm::Module::getNamedMetadata()
635 * @see llvm::MDNode::addOperand()
636 */
637void LLVMAddNamedMetadataOperand(LLVMModuleRef M, const char* name,
638 LLVMValueRef Val);
639
Gregory Szorc52d26602012-03-21 07:28:27 +0000640/**
641 * Add a function to a module under a specified name.
642 *
643 * @see llvm::Function::Create()
644 */
645LLVMValueRef LLVMAddFunction(LLVMModuleRef M, const char *Name,
646 LLVMTypeRef FunctionTy);
647
648/**
649 * Obtain a Function value from a Module by its name.
650 *
651 * The returned value corresponds to a llvm::Function value.
652 *
653 * @see llvm::Module::getFunction()
654 */
655LLVMValueRef LLVMGetNamedFunction(LLVMModuleRef M, const char *Name);
656
657/**
658 * Obtain an iterator to the first Function in a Module.
659 *
660 * @see llvm::Module::begin()
661 */
662LLVMValueRef LLVMGetFirstFunction(LLVMModuleRef M);
663
664/**
665 * Obtain an iterator to the last Function in a Module.
666 *
667 * @see llvm::Module::end()
668 */
669LLVMValueRef LLVMGetLastFunction(LLVMModuleRef M);
670
671/**
672 * Advance a Function iterator to the next Function.
673 *
674 * Returns NULL if the iterator was already at the end and there are no more
675 * functions.
676 */
677LLVMValueRef LLVMGetNextFunction(LLVMValueRef Fn);
678
679/**
680 * Decrement a Function iterator to the previous Function.
681 *
682 * Returns NULL if the iterator was already at the beginning and there are
683 * no previous functions.
684 */
685LLVMValueRef LLVMGetPreviousFunction(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000686
687/**
688 * @}
689 */
690
691/**
692 * @defgroup LLVMCCoreType Types
693 *
694 * Types represent the type of a value.
695 *
696 * Types are associated with a context instance. The context internally
697 * deduplicates types so there is only 1 instance of a specific type
698 * alive at a time. In other words, a unique type is shared among all
699 * consumers within a context.
700 *
701 * A Type in the C API corresponds to llvm::Type.
702 *
703 * Types have the following hierarchy:
704 *
Gordon Henriksen76a03742007-09-18 03:18:57 +0000705 * types:
706 * integer type
707 * real type
708 * function type
709 * sequence types:
710 * array type
711 * pointer type
712 * vector type
713 * void type
714 * label type
715 * opaque type
Gregory Szorc34c863a2012-03-21 03:54:29 +0000716 *
717 * @{
Gordon Henriksen76a03742007-09-18 03:18:57 +0000718 */
719
Gregory Szorc34c863a2012-03-21 03:54:29 +0000720/**
721 * Obtain the enumerated type of a Type instance.
722 *
723 * @see llvm::Type:getTypeID()
724 */
Gordon Henriksen76a03742007-09-18 03:18:57 +0000725LLVMTypeKind LLVMGetTypeKind(LLVMTypeRef Ty);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000726
727/**
728 * Whether the type has a known size.
729 *
730 * Things that don't have a size are abstract types, labels, and void.a
731 *
732 * @see llvm::Type::isSized()
733 */
Torok Edwin1cd9ade2011-10-06 12:13:28 +0000734LLVMBool LLVMTypeIsSized(LLVMTypeRef Ty);
Gordon Henriksena49d4352008-03-07 19:13:06 +0000735
Gregory Szorc34c863a2012-03-21 03:54:29 +0000736/**
737 * Obtain the context to which this type instance is associated.
738 *
739 * @see llvm::Type::getContext()
740 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +0000741LLVMContextRef LLVMGetTypeContext(LLVMTypeRef Ty);
742
Gregory Szorc34c863a2012-03-21 03:54:29 +0000743/**
Anders Waldenborgb822cff2013-10-16 21:30:25 +0000744 * Dump a representation of a type to stderr.
745 *
746 * @see llvm::Type::dump()
747 */
748void LLVMDumpType(LLVMTypeRef Val);
749
750/**
Anders Waldenborg47b3bd32013-10-22 06:58:34 +0000751 * Return a string representation of the type. Use
752 * LLVMDisposeMessage to free the string.
753 *
754 * @see llvm::Type::print()
755 */
756char *LLVMPrintTypeToString(LLVMTypeRef Val);
757
758/**
Gregory Szorc34c863a2012-03-21 03:54:29 +0000759 * @defgroup LLVMCCoreTypeInt Integer Types
760 *
761 * Functions in this section operate on integer types.
762 *
763 * @{
764 */
765
766/**
767 * Obtain an integer type from a context with specified bit width.
768 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +0000769LLVMTypeRef LLVMInt1TypeInContext(LLVMContextRef C);
770LLVMTypeRef LLVMInt8TypeInContext(LLVMContextRef C);
771LLVMTypeRef LLVMInt16TypeInContext(LLVMContextRef C);
772LLVMTypeRef LLVMInt32TypeInContext(LLVMContextRef C);
773LLVMTypeRef LLVMInt64TypeInContext(LLVMContextRef C);
Eugene Zelenkoffec81c2015-11-04 22:32:32 +0000774LLVMTypeRef LLVMInt128TypeInContext(LLVMContextRef C);
Erick Tryzelaar262332f2009-08-14 00:01:31 +0000775LLVMTypeRef LLVMIntTypeInContext(LLVMContextRef C, unsigned NumBits);
776
Gregory Szorc34c863a2012-03-21 03:54:29 +0000777/**
778 * Obtain an integer type from the global context with a specified bit
779 * width.
780 */
Gordon Henriksena735a9c2008-05-04 12:55:34 +0000781LLVMTypeRef LLVMInt1Type(void);
782LLVMTypeRef LLVMInt8Type(void);
783LLVMTypeRef LLVMInt16Type(void);
784LLVMTypeRef LLVMInt32Type(void);
785LLVMTypeRef LLVMInt64Type(void);
Eugene Zelenkoffec81c2015-11-04 22:32:32 +0000786LLVMTypeRef LLVMInt128Type(void);
Gordon Henriksened7beaa2007-10-06 16:05:20 +0000787LLVMTypeRef LLVMIntType(unsigned NumBits);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +0000788unsigned LLVMGetIntTypeWidth(LLVMTypeRef IntegerTy);
Gordon Henriksen76a03742007-09-18 03:18:57 +0000789
Gregory Szorc34c863a2012-03-21 03:54:29 +0000790/**
791 * @}
792 */
793
794/**
795 * @defgroup LLVMCCoreTypeFloat Floating Point Types
796 *
797 * @{
798 */
799
800/**
801 * Obtain a 16-bit floating point type from a context.
802 */
Dan Gohman518cda42011-12-17 00:04:22 +0000803LLVMTypeRef LLVMHalfTypeInContext(LLVMContextRef C);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000804
805/**
806 * Obtain a 32-bit floating point type from a context.
807 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +0000808LLVMTypeRef LLVMFloatTypeInContext(LLVMContextRef C);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000809
810/**
811 * Obtain a 64-bit floating point type from a context.
812 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +0000813LLVMTypeRef LLVMDoubleTypeInContext(LLVMContextRef C);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000814
815/**
816 * Obtain a 80-bit floating point type (X87) from a context.
817 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +0000818LLVMTypeRef LLVMX86FP80TypeInContext(LLVMContextRef C);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000819
820/**
821 * Obtain a 128-bit floating point type (112-bit mantissa) from a
822 * context.
823 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +0000824LLVMTypeRef LLVMFP128TypeInContext(LLVMContextRef C);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000825
826/**
827 * Obtain a 128-bit floating point type (two 64-bits) from a context.
828 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +0000829LLVMTypeRef LLVMPPCFP128TypeInContext(LLVMContextRef C);
830
Gregory Szorc34c863a2012-03-21 03:54:29 +0000831/**
832 * Obtain a floating point type from the global context.
833 *
834 * These map to the functions in this group of the same name.
835 */
Dan Gohman518cda42011-12-17 00:04:22 +0000836LLVMTypeRef LLVMHalfType(void);
Gordon Henriksena735a9c2008-05-04 12:55:34 +0000837LLVMTypeRef LLVMFloatType(void);
838LLVMTypeRef LLVMDoubleType(void);
839LLVMTypeRef LLVMX86FP80Type(void);
840LLVMTypeRef LLVMFP128Type(void);
841LLVMTypeRef LLVMPPCFP128Type(void);
Gordon Henriksen76a03742007-09-18 03:18:57 +0000842
Gregory Szorc34c863a2012-03-21 03:54:29 +0000843/**
844 * @}
845 */
846
847/**
848 * @defgroup LLVMCCoreTypeFunction Function Types
849 *
850 * @{
851 */
852
853/**
854 * Obtain a function type consisting of a specified signature.
855 *
856 * The function is defined as a tuple of a return Type, a list of
857 * parameter types, and whether the function is variadic.
858 */
Gordon Henriksened7beaa2007-10-06 16:05:20 +0000859LLVMTypeRef LLVMFunctionType(LLVMTypeRef ReturnType,
860 LLVMTypeRef *ParamTypes, unsigned ParamCount,
Chris Lattner25963c62010-01-09 22:27:07 +0000861 LLVMBool IsVarArg);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000862
863/**
864 * Returns whether a function type is variadic.
865 */
Chris Lattner25963c62010-01-09 22:27:07 +0000866LLVMBool LLVMIsFunctionVarArg(LLVMTypeRef FunctionTy);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000867
868/**
869 * Obtain the Type this function Type returns.
870 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +0000871LLVMTypeRef LLVMGetReturnType(LLVMTypeRef FunctionTy);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000872
873/**
874 * Obtain the number of parameters this function accepts.
875 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +0000876unsigned LLVMCountParamTypes(LLVMTypeRef FunctionTy);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000877
878/**
879 * Obtain the types of a function's parameters.
880 *
881 * The Dest parameter should point to a pre-allocated array of
882 * LLVMTypeRef at least LLVMCountParamTypes() large. On return, the
883 * first LLVMCountParamTypes() entries in the array will be populated
884 * with LLVMTypeRef instances.
885 *
886 * @param FunctionTy The function type to operate on.
887 * @param Dest Memory address of an array to be filled with result.
888 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +0000889void LLVMGetParamTypes(LLVMTypeRef FunctionTy, LLVMTypeRef *Dest);
Gordon Henriksen76a03742007-09-18 03:18:57 +0000890
Gregory Szorc34c863a2012-03-21 03:54:29 +0000891/**
892 * @}
893 */
894
895/**
896 * @defgroup LLVMCCoreTypeStruct Structure Types
897 *
898 * These functions relate to LLVMTypeRef instances.
899 *
900 * @see llvm::StructType
901 *
902 * @{
903 */
904
905/**
906 * Create a new structure type in a context.
907 *
908 * A structure is specified by a list of inner elements/types and
909 * whether these can be packed together.
910 *
911 * @see llvm::StructType::create()
912 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +0000913LLVMTypeRef LLVMStructTypeInContext(LLVMContextRef C, LLVMTypeRef *ElementTypes,
Chris Lattner25963c62010-01-09 22:27:07 +0000914 unsigned ElementCount, LLVMBool Packed);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000915
916/**
917 * Create a new structure type in the global context.
918 *
919 * @see llvm::StructType::create()
920 */
Gordon Henriksened7beaa2007-10-06 16:05:20 +0000921LLVMTypeRef LLVMStructType(LLVMTypeRef *ElementTypes, unsigned ElementCount,
Chris Lattner25963c62010-01-09 22:27:07 +0000922 LLVMBool Packed);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000923
924/**
925 * Create an empty structure in a context having a specified name.
926 *
927 * @see llvm::StructType::create()
928 */
Chris Lattnere71ccde2011-07-14 05:53:17 +0000929LLVMTypeRef LLVMStructCreateNamed(LLVMContextRef C, const char *Name);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000930
931/**
932 * Obtain the name of a structure.
933 *
934 * @see llvm::StructType::getName()
935 */
Torok Edwin0d5f6ae2011-10-06 12:12:50 +0000936const char *LLVMGetStructName(LLVMTypeRef Ty);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000937
938/**
939 * Set the contents of a structure type.
940 *
941 * @see llvm::StructType::setBody()
942 */
Chris Lattnere71ccde2011-07-14 05:53:17 +0000943void LLVMStructSetBody(LLVMTypeRef StructTy, LLVMTypeRef *ElementTypes,
944 unsigned ElementCount, LLVMBool Packed);
945
Gregory Szorc34c863a2012-03-21 03:54:29 +0000946/**
947 * Get the number of elements defined inside the structure.
948 *
949 * @see llvm::StructType::getNumElements()
950 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +0000951unsigned LLVMCountStructElementTypes(LLVMTypeRef StructTy);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000952
953/**
954 * Get the elements within a structure.
955 *
956 * The function is passed the address of a pre-allocated array of
957 * LLVMTypeRef at least LLVMCountStructElementTypes() long. After
958 * invocation, this array will be populated with the structure's
959 * elements. The objects in the destination array will have a lifetime
960 * of the structure type itself, which is the lifetime of the context it
961 * is contained in.
962 */
Gordon Henriksen76a03742007-09-18 03:18:57 +0000963void LLVMGetStructElementTypes(LLVMTypeRef StructTy, LLVMTypeRef *Dest);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000964
965/**
Peter Zotovc164a3f2015-06-04 09:09:53 +0000966 * Get the type of the element at a given index in the structure.
967 *
968 * @see llvm::StructType::getTypeAtIndex()
969 */
970LLVMTypeRef LLVMStructGetTypeAtIndex(LLVMTypeRef StructTy, unsigned i);
971
972/**
Gregory Szorc34c863a2012-03-21 03:54:29 +0000973 * Determine whether a structure is packed.
974 *
975 * @see llvm::StructType::isPacked()
976 */
Chris Lattner25963c62010-01-09 22:27:07 +0000977LLVMBool LLVMIsPackedStruct(LLVMTypeRef StructTy);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000978
979/**
980 * Determine whether a structure is opaque.
981 *
982 * @see llvm::StructType::isOpaque()
983 */
Chris Lattner17cf05b2011-07-14 16:20:28 +0000984LLVMBool LLVMIsOpaqueStruct(LLVMTypeRef StructTy);
985
Gregory Szorc34c863a2012-03-21 03:54:29 +0000986/**
987 * @}
988 */
Gordon Henriksen76a03742007-09-18 03:18:57 +0000989
Gregory Szorc34c863a2012-03-21 03:54:29 +0000990/**
991 * @defgroup LLVMCCoreTypeSequential Sequential Types
992 *
993 * Sequential types represents "arrays" of types. This is a super class
994 * for array, vector, and pointer types.
995 *
996 * @{
997 */
998
999/**
1000 * Obtain the type of elements within a sequential type.
1001 *
1002 * This works on array, vector, and pointer types.
1003 *
1004 * @see llvm::SequentialType::getElementType()
1005 */
1006LLVMTypeRef LLVMGetElementType(LLVMTypeRef Ty);
1007
1008/**
1009 * Create a fixed size array type that refers to a specific type.
1010 *
1011 * The created type will exist in the context that its element type
1012 * exists in.
1013 *
1014 * @see llvm::ArrayType::get()
1015 */
Gordon Henriksened7beaa2007-10-06 16:05:20 +00001016LLVMTypeRef LLVMArrayType(LLVMTypeRef ElementType, unsigned ElementCount);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001017
1018/**
1019 * Obtain the length of an array type.
1020 *
1021 * This only works on types that represent arrays.
1022 *
1023 * @see llvm::ArrayType::getNumElements()
1024 */
1025unsigned LLVMGetArrayLength(LLVMTypeRef ArrayTy);
1026
1027/**
1028 * Create a pointer type that points to a defined type.
1029 *
1030 * The created type will exist in the context that its pointee type
1031 * exists in.
1032 *
1033 * @see llvm::PointerType::get()
1034 */
Gordon Henriksen5a3fe032007-12-17 16:08:32 +00001035LLVMTypeRef LLVMPointerType(LLVMTypeRef ElementType, unsigned AddressSpace);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001036
1037/**
1038 * Obtain the address space of a pointer type.
1039 *
1040 * This only works on types that represent pointers.
1041 *
1042 * @see llvm::PointerType::getAddressSpace()
1043 */
1044unsigned LLVMGetPointerAddressSpace(LLVMTypeRef PointerTy);
1045
1046/**
1047 * Create a vector type that contains a defined type and has a specific
1048 * number of elements.
1049 *
1050 * The created type will exist in the context thats its element type
1051 * exists in.
1052 *
1053 * @see llvm::VectorType::get()
1054 */
Gordon Henriksened7beaa2007-10-06 16:05:20 +00001055LLVMTypeRef LLVMVectorType(LLVMTypeRef ElementType, unsigned ElementCount);
Gordon Henriksen76a03742007-09-18 03:18:57 +00001056
Gregory Szorc34c863a2012-03-21 03:54:29 +00001057/**
1058 * Obtain the number of elements in a vector type.
1059 *
1060 * This only works on types that represent vectors.
1061 *
1062 * @see llvm::VectorType::getNumElements()
1063 */
Gordon Henriksen76a03742007-09-18 03:18:57 +00001064unsigned LLVMGetVectorSize(LLVMTypeRef VectorTy);
1065
Gregory Szorc34c863a2012-03-21 03:54:29 +00001066/**
1067 * @}
1068 */
1069
1070/**
1071 * @defgroup LLVMCCoreTypeOther Other Types
1072 *
1073 * @{
1074 */
1075
1076/**
1077 * Create a void type in a context.
1078 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +00001079LLVMTypeRef LLVMVoidTypeInContext(LLVMContextRef C);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001080
1081/**
1082 * Create a label type in a context.
1083 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +00001084LLVMTypeRef LLVMLabelTypeInContext(LLVMContextRef C);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001085
1086/**
1087 * Create a X86 MMX type in a context.
1088 */
Dale Johannesen95b67af2010-09-10 21:58:02 +00001089LLVMTypeRef LLVMX86MMXTypeInContext(LLVMContextRef C);
Erick Tryzelaar262332f2009-08-14 00:01:31 +00001090
Gregory Szorc34c863a2012-03-21 03:54:29 +00001091/**
1092 * These are similar to the above functions except they operate on the
1093 * global context.
1094 */
Gordon Henriksena735a9c2008-05-04 12:55:34 +00001095LLVMTypeRef LLVMVoidType(void);
1096LLVMTypeRef LLVMLabelType(void);
Dale Johannesen95b67af2010-09-10 21:58:02 +00001097LLVMTypeRef LLVMX86MMXType(void);
Gordon Henriksen76a03742007-09-18 03:18:57 +00001098
Gregory Szorc34c863a2012-03-21 03:54:29 +00001099/**
1100 * @}
1101 */
Gordon Henriksen76a03742007-09-18 03:18:57 +00001102
Gregory Szorc34c863a2012-03-21 03:54:29 +00001103/**
1104 * @}
1105 */
1106
1107/**
1108 * @defgroup LLVMCCoreValues Values
1109 *
1110 * The bulk of LLVM's object model consists of values, which comprise a very
Gordon Henriksen76a03742007-09-18 03:18:57 +00001111 * rich type hierarchy.
Gregory Szorc34c863a2012-03-21 03:54:29 +00001112 *
1113 * LLVMValueRef essentially represents llvm::Value. There is a rich
1114 * hierarchy of classes within this type. Depending on the instance
Eli Benderskyc52863c2012-08-10 18:30:44 +00001115 * obtained, not all APIs are available.
Gregory Szorc34c863a2012-03-21 03:54:29 +00001116 *
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00001117 * Callers can determine the type of an LLVMValueRef by calling the
Gregory Szorc34c863a2012-03-21 03:54:29 +00001118 * LLVMIsA* family of functions (e.g. LLVMIsAArgument()). These
1119 * functions are defined by a macro, so it isn't obvious which are
1120 * available by looking at the Doxygen source code. Instead, look at the
1121 * source definition of LLVM_FOR_EACH_VALUE_SUBCLASS and note the list
1122 * of value names given. These value names also correspond to classes in
1123 * the llvm::Value hierarchy.
1124 *
1125 * @{
Gordon Henriksen76a03742007-09-18 03:18:57 +00001126 */
1127
Gordon Henriksen29e38942008-12-19 18:39:45 +00001128#define LLVM_FOR_EACH_VALUE_SUBCLASS(macro) \
1129 macro(Argument) \
1130 macro(BasicBlock) \
1131 macro(InlineAsm) \
1132 macro(User) \
1133 macro(Constant) \
Torok Edwind09b7572011-10-14 20:37:56 +00001134 macro(BlockAddress) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001135 macro(ConstantAggregateZero) \
1136 macro(ConstantArray) \
Peter Zotovae0344b2013-11-05 12:55:37 +00001137 macro(ConstantDataSequential) \
1138 macro(ConstantDataArray) \
1139 macro(ConstantDataVector) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001140 macro(ConstantExpr) \
1141 macro(ConstantFP) \
1142 macro(ConstantInt) \
1143 macro(ConstantPointerNull) \
1144 macro(ConstantStruct) \
David Majnemerf0f224d2015-11-11 21:57:16 +00001145 macro(ConstantTokenNone) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001146 macro(ConstantVector) \
1147 macro(GlobalValue) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001148 macro(GlobalAlias) \
Rafael Espindola99e05cf2014-05-13 18:45:48 +00001149 macro(GlobalObject) \
1150 macro(Function) \
1151 macro(GlobalVariable) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001152 macro(UndefValue) \
1153 macro(Instruction) \
1154 macro(BinaryOperator) \
1155 macro(CallInst) \
1156 macro(IntrinsicInst) \
1157 macro(DbgInfoIntrinsic) \
1158 macro(DbgDeclareInst) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001159 macro(MemIntrinsic) \
1160 macro(MemCpyInst) \
1161 macro(MemMoveInst) \
1162 macro(MemSetInst) \
1163 macro(CmpInst) \
Torok Edwind09b7572011-10-14 20:37:56 +00001164 macro(FCmpInst) \
1165 macro(ICmpInst) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001166 macro(ExtractElementInst) \
1167 macro(GetElementPtrInst) \
1168 macro(InsertElementInst) \
1169 macro(InsertValueInst) \
Bill Wendlingfae14752011-08-12 20:24:12 +00001170 macro(LandingPadInst) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001171 macro(PHINode) \
1172 macro(SelectInst) \
1173 macro(ShuffleVectorInst) \
1174 macro(StoreInst) \
1175 macro(TerminatorInst) \
1176 macro(BranchInst) \
Torok Edwind09b7572011-10-14 20:37:56 +00001177 macro(IndirectBrInst) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001178 macro(InvokeInst) \
1179 macro(ReturnInst) \
1180 macro(SwitchInst) \
1181 macro(UnreachableInst) \
Bill Wendlingf891bf82011-07-31 06:30:59 +00001182 macro(ResumeInst) \
David Majnemer654e1302015-07-31 17:58:14 +00001183 macro(CleanupReturnInst) \
1184 macro(CatchReturnInst) \
David Majnemer8a1c45d2015-12-12 05:38:55 +00001185 macro(FuncletPadInst) \
1186 macro(CatchPadInst) \
1187 macro(CleanupPadInst) \
Duncan Sands5e37e992013-05-06 08:55:45 +00001188 macro(UnaryInstruction) \
1189 macro(AllocaInst) \
1190 macro(CastInst) \
Matt Arsenaultb03bd4d2013-11-15 01:34:59 +00001191 macro(AddrSpaceCastInst) \
Duncan Sands5e37e992013-05-06 08:55:45 +00001192 macro(BitCastInst) \
1193 macro(FPExtInst) \
1194 macro(FPToSIInst) \
1195 macro(FPToUIInst) \
1196 macro(FPTruncInst) \
1197 macro(IntToPtrInst) \
1198 macro(PtrToIntInst) \
1199 macro(SExtInst) \
1200 macro(SIToFPInst) \
1201 macro(TruncInst) \
1202 macro(UIToFPInst) \
1203 macro(ZExtInst) \
1204 macro(ExtractValueInst) \
1205 macro(LoadInst) \
1206 macro(VAArgInst)
Gordon Henriksen29e38942008-12-19 18:39:45 +00001207
Gregory Szorc34c863a2012-03-21 03:54:29 +00001208/**
1209 * @defgroup LLVMCCoreValueGeneral General APIs
1210 *
1211 * Functions in this section work on all LLVMValueRef instances,
1212 * regardless of their sub-type. They correspond to functions available
1213 * on llvm::Value.
1214 *
1215 * @{
1216 */
Gordon Henriksen76a03742007-09-18 03:18:57 +00001217
Gregory Szorc34c863a2012-03-21 03:54:29 +00001218/**
1219 * Obtain the type of a value.
1220 *
1221 * @see llvm::Value::getType()
1222 */
1223LLVMTypeRef LLVMTypeOf(LLVMValueRef Val);
1224
1225/**
Peter Zotov3e4561c2016-04-06 22:21:29 +00001226 * Obtain the enumerated type of a Value instance.
1227 *
1228 * @see llvm::Value::getValueID()
1229 */
1230LLVMValueKind LLVMGetValueKind(LLVMValueRef Val);
1231
1232/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00001233 * Obtain the string name of a value.
1234 *
1235 * @see llvm::Value::getName()
1236 */
1237const char *LLVMGetValueName(LLVMValueRef Val);
1238
1239/**
1240 * Set the string name of a value.
1241 *
1242 * @see llvm::Value::setName()
1243 */
1244void LLVMSetValueName(LLVMValueRef Val, const char *Name);
1245
1246/**
1247 * Dump a representation of a value to stderr.
1248 *
1249 * @see llvm::Value::dump()
1250 */
1251void LLVMDumpValue(LLVMValueRef Val);
1252
1253/**
Peter Zotovcd93b372013-11-06 09:21:01 +00001254 * Return a string representation of the value. Use
1255 * LLVMDisposeMessage to free the string.
1256 *
1257 * @see llvm::Value::print()
1258 */
1259char *LLVMPrintValueToString(LLVMValueRef Val);
1260
1261/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00001262 * Replace all uses of a value with another one.
1263 *
1264 * @see llvm::Value::replaceAllUsesWith()
1265 */
1266void LLVMReplaceAllUsesWith(LLVMValueRef OldVal, LLVMValueRef NewVal);
1267
1268/**
Amaury Sechet1c395072016-01-18 01:06:52 +00001269 * Determine whether the specified value instance is constant.
Gregory Szorc34c863a2012-03-21 03:54:29 +00001270 */
1271LLVMBool LLVMIsConstant(LLVMValueRef Val);
1272
1273/**
1274 * Determine whether a value instance is undefined.
1275 */
1276LLVMBool LLVMIsUndef(LLVMValueRef Val);
1277
1278/**
1279 * Convert value instances between types.
1280 *
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00001281 * Internally, an LLVMValueRef is "pinned" to a specific type. This
Gregory Szorc34c863a2012-03-21 03:54:29 +00001282 * series of functions allows you to cast an instance to a specific
1283 * type.
1284 *
1285 * If the cast is not valid for the specified type, NULL is returned.
1286 *
1287 * @see llvm::dyn_cast_or_null<>
1288 */
Gordon Henriksen29e38942008-12-19 18:39:45 +00001289#define LLVM_DECLARE_VALUE_CAST(name) \
1290 LLVMValueRef LLVMIsA##name(LLVMValueRef Val);
1291LLVM_FOR_EACH_VALUE_SUBCLASS(LLVM_DECLARE_VALUE_CAST)
1292
Duncan P. N. Exon Smith5bf8fef2014-12-09 18:38:53 +00001293LLVMValueRef LLVMIsAMDNode(LLVMValueRef Val);
1294LLVMValueRef LLVMIsAMDString(LLVMValueRef Val);
1295
Gregory Szorc34c863a2012-03-21 03:54:29 +00001296/**
1297 * @}
1298 */
1299
1300/**
1301 * @defgroup LLVMCCoreValueUses Usage
1302 *
1303 * This module defines functions that allow you to inspect the uses of a
1304 * LLVMValueRef.
1305 *
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00001306 * It is possible to obtain an LLVMUseRef for any LLVMValueRef instance.
Gregory Szorc34c863a2012-03-21 03:54:29 +00001307 * Each LLVMUseRef (which corresponds to a llvm::Use instance) holds a
1308 * llvm::User and llvm::Value.
1309 *
1310 * @{
1311 */
1312
1313/**
1314 * Obtain the first use of a value.
1315 *
1316 * Uses are obtained in an iterator fashion. First, call this function
1317 * to obtain a reference to the first use. Then, call LLVMGetNextUse()
Eli Benderskyc52863c2012-08-10 18:30:44 +00001318 * on that instance and all subsequently obtained instances until
Gregory Szorc34c863a2012-03-21 03:54:29 +00001319 * LLVMGetNextUse() returns NULL.
1320 *
1321 * @see llvm::Value::use_begin()
1322 */
Erick Tryzelaar9f9857e2010-03-02 20:32:28 +00001323LLVMUseRef LLVMGetFirstUse(LLVMValueRef Val);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001324
1325/**
1326 * Obtain the next use of a value.
1327 *
1328 * This effectively advances the iterator. It returns NULL if you are on
1329 * the final use and no more are available.
1330 */
Erick Tryzelaar9f9857e2010-03-02 20:32:28 +00001331LLVMUseRef LLVMGetNextUse(LLVMUseRef U);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001332
1333/**
1334 * Obtain the user value for a user.
1335 *
1336 * The returned value corresponds to a llvm::User type.
1337 *
1338 * @see llvm::Use::getUser()
1339 */
Erick Tryzelaar9f9857e2010-03-02 20:32:28 +00001340LLVMValueRef LLVMGetUser(LLVMUseRef U);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001341
1342/**
1343 * Obtain the value this use corresponds to.
1344 *
1345 * @see llvm::Use::get().
1346 */
Erick Tryzelaar9f9857e2010-03-02 20:32:28 +00001347LLVMValueRef LLVMGetUsedValue(LLVMUseRef U);
Chris Lattner40cf28d2009-10-12 04:01:02 +00001348
Gregory Szorc34c863a2012-03-21 03:54:29 +00001349/**
1350 * @}
1351 */
1352
1353/**
Gregory Szorc52d26602012-03-21 07:28:27 +00001354 * @defgroup LLVMCCoreValueUser User value
Gregory Szorc34c863a2012-03-21 03:54:29 +00001355 *
1356 * Function in this group pertain to LLVMValueRef instances that descent
1357 * from llvm::User. This includes constants, instructions, and
1358 * operators.
1359 *
1360 * @{
1361 */
1362
1363/**
1364 * Obtain an operand at a specific index in a llvm::User value.
1365 *
1366 * @see llvm::User::getOperand()
1367 */
Chris Lattner40cf28d2009-10-12 04:01:02 +00001368LLVMValueRef LLVMGetOperand(LLVMValueRef Val, unsigned Index);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001369
1370/**
Peter Zotovb19f78f2014-08-12 02:55:40 +00001371 * Obtain the use of an operand at a specific index in a llvm::User value.
1372 *
1373 * @see llvm::User::getOperandUse()
1374 */
1375LLVMUseRef LLVMGetOperandUse(LLVMValueRef Val, unsigned Index);
1376
1377/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00001378 * Set an operand at a specific index in a llvm::User value.
1379 *
1380 * @see llvm::User::setOperand()
1381 */
Erick Tryzelaarb4d48702010-08-20 14:51:22 +00001382void LLVMSetOperand(LLVMValueRef User, unsigned Index, LLVMValueRef Val);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001383
1384/**
1385 * Obtain the number of operands in a llvm::User value.
1386 *
1387 * @see llvm::User::getNumOperands()
1388 */
Erick Tryzelaarb4d48702010-08-20 14:51:22 +00001389int LLVMGetNumOperands(LLVMValueRef Val);
Chris Lattner40cf28d2009-10-12 04:01:02 +00001390
Gregory Szorc34c863a2012-03-21 03:54:29 +00001391/**
1392 * @}
1393 */
1394
1395/**
Gregory Szorc52d26602012-03-21 07:28:27 +00001396 * @defgroup LLVMCCoreValueConstant Constants
Gregory Szorc34c863a2012-03-21 03:54:29 +00001397 *
1398 * This section contains APIs for interacting with LLVMValueRef that
1399 * correspond to llvm::Constant instances.
1400 *
1401 * These functions will work for any LLVMValueRef in the llvm::Constant
1402 * class hierarchy.
1403 *
1404 * @{
1405 */
1406
1407/**
1408 * Obtain a constant value referring to the null instance of a type.
1409 *
1410 * @see llvm::Constant::getNullValue()
1411 */
Gordon Henriksen1046c732007-10-06 15:11:06 +00001412LLVMValueRef LLVMConstNull(LLVMTypeRef Ty); /* all zeroes */
Gregory Szorc34c863a2012-03-21 03:54:29 +00001413
1414/**
1415 * Obtain a constant value referring to the instance of a type
1416 * consisting of all ones.
1417 *
1418 * This is only valid for integer types.
1419 *
1420 * @see llvm::Constant::getAllOnesValue()
1421 */
1422LLVMValueRef LLVMConstAllOnes(LLVMTypeRef Ty);
1423
1424/**
1425 * Obtain a constant value referring to an undefined value of a type.
1426 *
1427 * @see llvm::UndefValue::get()
1428 */
Gordon Henriksen76a03742007-09-18 03:18:57 +00001429LLVMValueRef LLVMGetUndef(LLVMTypeRef Ty);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001430
1431/**
1432 * Determine whether a value instance is null.
1433 *
1434 * @see llvm::Constant::isNullValue()
1435 */
Chris Lattner25963c62010-01-09 22:27:07 +00001436LLVMBool LLVMIsNull(LLVMValueRef Val);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001437
1438/**
1439 * Obtain a constant that is a constant pointer pointing to NULL for a
1440 * specified type.
1441 */
Chris Lattner7f318242009-07-06 17:29:59 +00001442LLVMValueRef LLVMConstPointerNull(LLVMTypeRef Ty);
Gordon Henriksen76a03742007-09-18 03:18:57 +00001443
Gregory Szorc34c863a2012-03-21 03:54:29 +00001444/**
1445 * @defgroup LLVMCCoreValueConstantScalar Scalar constants
1446 *
1447 * Functions in this group model LLVMValueRef instances that correspond
1448 * to constants referring to scalar types.
1449 *
1450 * For integer types, the LLVMTypeRef parameter should correspond to a
1451 * llvm::IntegerType instance and the returned LLVMValueRef will
1452 * correspond to a llvm::ConstantInt.
1453 *
1454 * For floating point types, the LLVMTypeRef returned corresponds to a
1455 * llvm::ConstantFP.
1456 *
1457 * @{
1458 */
Erick Tryzelaard8531fa2010-02-28 09:45:59 +00001459
Gregory Szorc34c863a2012-03-21 03:54:29 +00001460/**
1461 * Obtain a constant value for an integer type.
1462 *
1463 * The returned value corresponds to a llvm::ConstantInt.
1464 *
1465 * @see llvm::ConstantInt::get()
1466 *
1467 * @param IntTy Integer type to obtain value of.
1468 * @param N The value the returned instance should refer to.
1469 * @param SignExtend Whether to sign extend the produced value.
1470 */
Gordon Henriksen1046c732007-10-06 15:11:06 +00001471LLVMValueRef LLVMConstInt(LLVMTypeRef IntTy, unsigned long long N,
Chris Lattner25963c62010-01-09 22:27:07 +00001472 LLVMBool SignExtend);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001473
1474/**
1475 * Obtain a constant value for an integer of arbitrary precision.
1476 *
1477 * @see llvm::ConstantInt::get()
1478 */
Chris Lattner4329e072010-11-23 02:47:22 +00001479LLVMValueRef LLVMConstIntOfArbitraryPrecision(LLVMTypeRef IntTy,
1480 unsigned NumWords,
1481 const uint64_t Words[]);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001482
1483/**
1484 * Obtain a constant value for an integer parsed from a string.
1485 *
1486 * A similar API, LLVMConstIntOfStringAndSize is also available. If the
1487 * string's length is available, it is preferred to call that function
1488 * instead.
1489 *
1490 * @see llvm::ConstantInt::get()
1491 */
Erick Tryzelaardd991352009-08-16 23:36:46 +00001492LLVMValueRef LLVMConstIntOfString(LLVMTypeRef IntTy, const char *Text,
1493 uint8_t Radix);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001494
1495/**
1496 * Obtain a constant value for an integer parsed from a string with
1497 * specified length.
1498 *
1499 * @see llvm::ConstantInt::get()
1500 */
Erick Tryzelaardd991352009-08-16 23:36:46 +00001501LLVMValueRef LLVMConstIntOfStringAndSize(LLVMTypeRef IntTy, const char *Text,
1502 unsigned SLen, uint8_t Radix);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001503
1504/**
1505 * Obtain a constant value referring to a double floating point value.
1506 */
Gordon Henriksen1046c732007-10-06 15:11:06 +00001507LLVMValueRef LLVMConstReal(LLVMTypeRef RealTy, double N);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001508
1509/**
1510 * Obtain a constant for a floating point value parsed from a string.
1511 *
1512 * A similar API, LLVMConstRealOfStringAndSize is also available. It
1513 * should be used if the input string's length is known.
1514 */
Gordon Henriksen931e1212008-02-02 01:07:50 +00001515LLVMValueRef LLVMConstRealOfString(LLVMTypeRef RealTy, const char *Text);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001516
1517/**
1518 * Obtain a constant for a floating point value parsed from a string.
1519 */
Erick Tryzelaardd991352009-08-16 23:36:46 +00001520LLVMValueRef LLVMConstRealOfStringAndSize(LLVMTypeRef RealTy, const char *Text,
1521 unsigned SLen);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001522
1523/**
1524 * Obtain the zero extended value for an integer constant value.
1525 *
1526 * @see llvm::ConstantInt::getZExtValue()
1527 */
Chris Lattner40cf28d2009-10-12 04:01:02 +00001528unsigned long long LLVMConstIntGetZExtValue(LLVMValueRef ConstantVal);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001529
1530/**
1531 * Obtain the sign extended value for an integer constant value.
1532 *
1533 * @see llvm::ConstantInt::getSExtValue()
1534 */
Chris Lattner40cf28d2009-10-12 04:01:02 +00001535long long LLVMConstIntGetSExtValue(LLVMValueRef ConstantVal);
Erick Tryzelaardd991352009-08-16 23:36:46 +00001536
Gregory Szorc34c863a2012-03-21 03:54:29 +00001537/**
Peter Zotov1d98e6d2014-10-28 19:46:44 +00001538 * Obtain the double value for an floating point constant value.
1539 * losesInfo indicates if some precision was lost in the conversion.
1540 *
1541 * @see llvm::ConstantFP::getDoubleValue
1542 */
1543double LLVMConstRealGetDouble(LLVMValueRef ConstantVal, LLVMBool *losesInfo);
1544
1545/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00001546 * @}
1547 */
1548
1549/**
Gregory Szorc52d26602012-03-21 07:28:27 +00001550 * @defgroup LLVMCCoreValueConstantComposite Composite Constants
1551 *
1552 * Functions in this group operate on composite constants.
Gregory Szorc34c863a2012-03-21 03:54:29 +00001553 *
1554 * @{
1555 */
1556
1557/**
Gregory Szorc52d26602012-03-21 07:28:27 +00001558 * Create a ConstantDataSequential and initialize it with a string.
Gregory Szorc34c863a2012-03-21 03:54:29 +00001559 *
Gregory Szorc52d26602012-03-21 07:28:27 +00001560 * @see llvm::ConstantDataArray::getString()
Gregory Szorc34c863a2012-03-21 03:54:29 +00001561 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +00001562LLVMValueRef LLVMConstStringInContext(LLVMContextRef C, const char *Str,
Chris Lattner25963c62010-01-09 22:27:07 +00001563 unsigned Length, LLVMBool DontNullTerminate);
Gregory Szorc52d26602012-03-21 07:28:27 +00001564
1565/**
1566 * Create a ConstantDataSequential with string content in the global context.
1567 *
1568 * This is the same as LLVMConstStringInContext except it operates on the
1569 * global context.
1570 *
1571 * @see LLVMConstStringInContext()
1572 * @see llvm::ConstantDataArray::getString()
1573 */
1574LLVMValueRef LLVMConstString(const char *Str, unsigned Length,
1575 LLVMBool DontNullTerminate);
1576
1577/**
Peter Zotovf9aa8822014-08-03 23:54:16 +00001578 * Returns true if the specified constant is an array of i8.
1579 *
1580 * @see ConstantDataSequential::getAsString()
1581 */
1582LLVMBool LLVMIsConstantString(LLVMValueRef c);
1583
1584/**
1585 * Get the given constant data sequential as a string.
1586 *
1587 * @see ConstantDataSequential::getAsString()
1588 */
Amaury Sechet7c2883c2016-04-03 21:06:04 +00001589const char *LLVMGetAsString(LLVMValueRef c, size_t *Length);
Peter Zotovf9aa8822014-08-03 23:54:16 +00001590
1591/**
Gregory Szorc52d26602012-03-21 07:28:27 +00001592 * Create an anonymous ConstantStruct with the specified values.
1593 *
1594 * @see llvm::ConstantStruct::getAnon()
1595 */
1596LLVMValueRef LLVMConstStructInContext(LLVMContextRef C,
Erick Tryzelaar262332f2009-08-14 00:01:31 +00001597 LLVMValueRef *ConstantVals,
Chris Lattner25963c62010-01-09 22:27:07 +00001598 unsigned Count, LLVMBool Packed);
Erick Tryzelaar262332f2009-08-14 00:01:31 +00001599
Gregory Szorc52d26602012-03-21 07:28:27 +00001600/**
1601 * Create a ConstantStruct in the global Context.
1602 *
1603 * This is the same as LLVMConstStructInContext except it operates on the
1604 * global Context.
1605 *
1606 * @see LLVMConstStructInContext()
1607 */
Gordon Henriksen1046c732007-10-06 15:11:06 +00001608LLVMValueRef LLVMConstStruct(LLVMValueRef *ConstantVals, unsigned Count,
Chris Lattner25963c62010-01-09 22:27:07 +00001609 LLVMBool Packed);
Gregory Szorc52d26602012-03-21 07:28:27 +00001610
1611/**
1612 * Create a ConstantArray from values.
1613 *
1614 * @see llvm::ConstantArray::get()
1615 */
1616LLVMValueRef LLVMConstArray(LLVMTypeRef ElementTy,
1617 LLVMValueRef *ConstantVals, unsigned Length);
1618
1619/**
1620 * Create a non-anonymous ConstantStruct from values.
1621 *
1622 * @see llvm::ConstantStruct::get()
1623 */
Rafael Espindola784ad242011-07-14 19:09:08 +00001624LLVMValueRef LLVMConstNamedStruct(LLVMTypeRef StructTy,
1625 LLVMValueRef *ConstantVals,
1626 unsigned Count);
Gregory Szorc52d26602012-03-21 07:28:27 +00001627
1628/**
Peter Zotovf9aa8822014-08-03 23:54:16 +00001629 * Get an element at specified index as a constant.
1630 *
1631 * @see ConstantDataSequential::getElementAsConstant()
1632 */
Amaury Sechet006ce632016-03-13 00:54:40 +00001633LLVMValueRef LLVMGetElementAsConstant(LLVMValueRef C, unsigned idx);
Peter Zotovf9aa8822014-08-03 23:54:16 +00001634
1635/**
Gregory Szorc52d26602012-03-21 07:28:27 +00001636 * Create a ConstantVector from values.
1637 *
1638 * @see llvm::ConstantVector::get()
1639 */
Gordon Henriksen1046c732007-10-06 15:11:06 +00001640LLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals, unsigned Size);
Gordon Henriksen76a03742007-09-18 03:18:57 +00001641
Gregory Szorc52d26602012-03-21 07:28:27 +00001642/**
1643 * @}
1644 */
1645
1646/**
1647 * @defgroup LLVMCCoreValueConstantExpressions Constant Expressions
1648 *
1649 * Functions in this group correspond to APIs on llvm::ConstantExpr.
1650 *
1651 * @see llvm::ConstantExpr.
1652 *
1653 * @{
1654 */
Chris Lattner40cf28d2009-10-12 04:01:02 +00001655LLVMOpcode LLVMGetConstOpcode(LLVMValueRef ConstantVal);
Erick Tryzelaarfd529d72009-08-19 08:36:49 +00001656LLVMValueRef LLVMAlignOf(LLVMTypeRef Ty);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001657LLVMValueRef LLVMSizeOf(LLVMTypeRef Ty);
1658LLVMValueRef LLVMConstNeg(LLVMValueRef ConstantVal);
Erick Tryzelaar4c340c72010-02-28 05:51:43 +00001659LLVMValueRef LLVMConstNSWNeg(LLVMValueRef ConstantVal);
1660LLVMValueRef LLVMConstNUWNeg(LLVMValueRef ConstantVal);
Erick Tryzelaar4cc690c2009-08-16 02:20:12 +00001661LLVMValueRef LLVMConstFNeg(LLVMValueRef ConstantVal);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001662LLVMValueRef LLVMConstNot(LLVMValueRef ConstantVal);
1663LLVMValueRef LLVMConstAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Dan Gohmane4ca02d2009-09-03 23:34:49 +00001664LLVMValueRef LLVMConstNSWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Erick Tryzelaar4c340c72010-02-28 05:51:43 +00001665LLVMValueRef LLVMConstNUWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Erick Tryzelaar4cc690c2009-08-16 02:20:12 +00001666LLVMValueRef LLVMConstFAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001667LLVMValueRef LLVMConstSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Erick Tryzelaar4c340c72010-02-28 05:51:43 +00001668LLVMValueRef LLVMConstNSWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1669LLVMValueRef LLVMConstNUWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Erick Tryzelaar4cc690c2009-08-16 02:20:12 +00001670LLVMValueRef LLVMConstFSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001671LLVMValueRef LLVMConstMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Erick Tryzelaar4c340c72010-02-28 05:51:43 +00001672LLVMValueRef LLVMConstNSWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1673LLVMValueRef LLVMConstNUWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Erick Tryzelaar4cc690c2009-08-16 02:20:12 +00001674LLVMValueRef LLVMConstFMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001675LLVMValueRef LLVMConstUDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1676LLVMValueRef LLVMConstSDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Dan Gohmane4ca02d2009-09-03 23:34:49 +00001677LLVMValueRef LLVMConstExactSDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001678LLVMValueRef LLVMConstFDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1679LLVMValueRef LLVMConstURem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1680LLVMValueRef LLVMConstSRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1681LLVMValueRef LLVMConstFRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1682LLVMValueRef LLVMConstAnd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1683LLVMValueRef LLVMConstOr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1684LLVMValueRef LLVMConstXor(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1685LLVMValueRef LLVMConstICmp(LLVMIntPredicate Predicate,
1686 LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1687LLVMValueRef LLVMConstFCmp(LLVMRealPredicate Predicate,
1688 LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1689LLVMValueRef LLVMConstShl(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1690LLVMValueRef LLVMConstLShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1691LLVMValueRef LLVMConstAShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1692LLVMValueRef LLVMConstGEP(LLVMValueRef ConstantVal,
1693 LLVMValueRef *ConstantIndices, unsigned NumIndices);
Dan Gohmane4ca02d2009-09-03 23:34:49 +00001694LLVMValueRef LLVMConstInBoundsGEP(LLVMValueRef ConstantVal,
1695 LLVMValueRef *ConstantIndices,
1696 unsigned NumIndices);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001697LLVMValueRef LLVMConstTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1698LLVMValueRef LLVMConstSExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1699LLVMValueRef LLVMConstZExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1700LLVMValueRef LLVMConstFPTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1701LLVMValueRef LLVMConstFPExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1702LLVMValueRef LLVMConstUIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1703LLVMValueRef LLVMConstSIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1704LLVMValueRef LLVMConstFPToUI(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1705LLVMValueRef LLVMConstFPToSI(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1706LLVMValueRef LLVMConstPtrToInt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1707LLVMValueRef LLVMConstIntToPtr(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1708LLVMValueRef LLVMConstBitCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
Matt Arsenaultb03bd4d2013-11-15 01:34:59 +00001709LLVMValueRef LLVMConstAddrSpaceCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
Erick Tryzelaar4cc690c2009-08-16 02:20:12 +00001710LLVMValueRef LLVMConstZExtOrBitCast(LLVMValueRef ConstantVal,
1711 LLVMTypeRef ToType);
1712LLVMValueRef LLVMConstSExtOrBitCast(LLVMValueRef ConstantVal,
1713 LLVMTypeRef ToType);
1714LLVMValueRef LLVMConstTruncOrBitCast(LLVMValueRef ConstantVal,
1715 LLVMTypeRef ToType);
1716LLVMValueRef LLVMConstPointerCast(LLVMValueRef ConstantVal,
1717 LLVMTypeRef ToType);
1718LLVMValueRef LLVMConstIntCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType,
Chris Lattner25963c62010-01-09 22:27:07 +00001719 LLVMBool isSigned);
Erick Tryzelaar4cc690c2009-08-16 02:20:12 +00001720LLVMValueRef LLVMConstFPCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001721LLVMValueRef LLVMConstSelect(LLVMValueRef ConstantCondition,
1722 LLVMValueRef ConstantIfTrue,
1723 LLVMValueRef ConstantIfFalse);
1724LLVMValueRef LLVMConstExtractElement(LLVMValueRef VectorConstant,
1725 LLVMValueRef IndexConstant);
1726LLVMValueRef LLVMConstInsertElement(LLVMValueRef VectorConstant,
1727 LLVMValueRef ElementValueConstant,
1728 LLVMValueRef IndexConstant);
1729LLVMValueRef LLVMConstShuffleVector(LLVMValueRef VectorAConstant,
1730 LLVMValueRef VectorBConstant,
1731 LLVMValueRef MaskConstant);
Dan Gohmand5104a52008-11-03 22:55:43 +00001732LLVMValueRef LLVMConstExtractValue(LLVMValueRef AggConstant, unsigned *IdxList,
1733 unsigned NumIdx);
1734LLVMValueRef LLVMConstInsertValue(LLVMValueRef AggConstant,
1735 LLVMValueRef ElementValueConstant,
1736 unsigned *IdxList, unsigned NumIdx);
Chris Lattner25963c62010-01-09 22:27:07 +00001737LLVMValueRef LLVMConstInlineAsm(LLVMTypeRef Ty,
Chris Lattner3d1f5522008-12-17 21:39:50 +00001738 const char *AsmString, const char *Constraints,
Chris Lattner25963c62010-01-09 22:27:07 +00001739 LLVMBool HasSideEffects, LLVMBool IsAlignStack);
Erick Tryzelaar0fb26ef2010-02-28 09:46:06 +00001740LLVMValueRef LLVMBlockAddress(LLVMValueRef F, LLVMBasicBlockRef BB);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001741
Gregory Szorc52d26602012-03-21 07:28:27 +00001742/**
1743 * @}
1744 */
1745
1746/**
1747 * @defgroup LLVMCCoreValueConstantGlobals Global Values
1748 *
1749 * This group contains functions that operate on global values. Functions in
1750 * this group relate to functions in the llvm::GlobalValue class tree.
1751 *
1752 * @see llvm::GlobalValue
1753 *
1754 * @{
1755 */
1756
Gordon Henriksen265f7802008-03-19 01:11:35 +00001757LLVMModuleRef LLVMGetGlobalParent(LLVMValueRef Global);
Chris Lattner25963c62010-01-09 22:27:07 +00001758LLVMBool LLVMIsDeclaration(LLVMValueRef Global);
Gordon Henriksen76a03742007-09-18 03:18:57 +00001759LLVMLinkage LLVMGetLinkage(LLVMValueRef Global);
1760void LLVMSetLinkage(LLVMValueRef Global, LLVMLinkage Linkage);
1761const char *LLVMGetSection(LLVMValueRef Global);
1762void LLVMSetSection(LLVMValueRef Global, const char *Section);
1763LLVMVisibility LLVMGetVisibility(LLVMValueRef Global);
1764void LLVMSetVisibility(LLVMValueRef Global, LLVMVisibility Viz);
Reid Kleckner2fae26f2014-03-05 02:34:23 +00001765LLVMDLLStorageClass LLVMGetDLLStorageClass(LLVMValueRef Global);
1766void LLVMSetDLLStorageClass(LLVMValueRef Global, LLVMDLLStorageClass Class);
Tim Northoverad96d012014-03-10 19:24:35 +00001767LLVMBool LLVMHasUnnamedAddr(LLVMValueRef Global);
1768void LLVMSetUnnamedAddr(LLVMValueRef Global, LLVMBool HasUnnamedAddr);
Anders Waldenborg213a63f2013-10-29 09:02:02 +00001769
1770/**
1771 * @defgroup LLVMCCoreValueWithAlignment Values with alignment
1772 *
1773 * Functions in this group only apply to values with alignment, i.e.
1774 * global variables, load and store instructions.
1775 */
1776
1777/**
1778 * Obtain the preferred alignment of the value.
Peter Zotov9f584e62014-03-05 05:05:34 +00001779 * @see llvm::AllocaInst::getAlignment()
Anders Waldenborg213a63f2013-10-29 09:02:02 +00001780 * @see llvm::LoadInst::getAlignment()
1781 * @see llvm::StoreInst::getAlignment()
1782 * @see llvm::GlobalValue::getAlignment()
1783 */
1784unsigned LLVMGetAlignment(LLVMValueRef V);
1785
1786/**
1787 * Set the preferred alignment of the value.
Peter Zotov9f584e62014-03-05 05:05:34 +00001788 * @see llvm::AllocaInst::setAlignment()
Anders Waldenborg213a63f2013-10-29 09:02:02 +00001789 * @see llvm::LoadInst::setAlignment()
1790 * @see llvm::StoreInst::setAlignment()
1791 * @see llvm::GlobalValue::setAlignment()
1792 */
1793void LLVMSetAlignment(LLVMValueRef V, unsigned Bytes);
1794
1795/**
Amaury Sechet83550102016-02-14 08:58:49 +00001796 * @}
1797 */
Gordon Henriksen76a03742007-09-18 03:18:57 +00001798
Gregory Szorc52d26602012-03-21 07:28:27 +00001799/**
1800 * @defgroup LLVMCoreValueConstantGlobalVariable Global Variables
1801 *
1802 * This group contains functions that operate on global variable values.
1803 *
1804 * @see llvm::GlobalVariable
1805 *
1806 * @{
1807 */
Gordon Henriksen76a03742007-09-18 03:18:57 +00001808LLVMValueRef LLVMAddGlobal(LLVMModuleRef M, LLVMTypeRef Ty, const char *Name);
Erick Tryzelaar06894b32010-02-28 09:46:13 +00001809LLVMValueRef LLVMAddGlobalInAddressSpace(LLVMModuleRef M, LLVMTypeRef Ty,
1810 const char *Name,
1811 unsigned AddressSpace);
Gordon Henriksen783f7bb2007-10-08 03:45:09 +00001812LLVMValueRef LLVMGetNamedGlobal(LLVMModuleRef M, const char *Name);
Gordon Henriksen07a45f42008-03-23 22:21:29 +00001813LLVMValueRef LLVMGetFirstGlobal(LLVMModuleRef M);
1814LLVMValueRef LLVMGetLastGlobal(LLVMModuleRef M);
1815LLVMValueRef LLVMGetNextGlobal(LLVMValueRef GlobalVar);
1816LLVMValueRef LLVMGetPreviousGlobal(LLVMValueRef GlobalVar);
Gordon Henriksen76a03742007-09-18 03:18:57 +00001817void LLVMDeleteGlobal(LLVMValueRef GlobalVar);
Gordon Henriksen76a03742007-09-18 03:18:57 +00001818LLVMValueRef LLVMGetInitializer(LLVMValueRef GlobalVar);
1819void LLVMSetInitializer(LLVMValueRef GlobalVar, LLVMValueRef ConstantVal);
Chris Lattner25963c62010-01-09 22:27:07 +00001820LLVMBool LLVMIsThreadLocal(LLVMValueRef GlobalVar);
1821void LLVMSetThreadLocal(LLVMValueRef GlobalVar, LLVMBool IsThreadLocal);
1822LLVMBool LLVMIsGlobalConstant(LLVMValueRef GlobalVar);
1823void LLVMSetGlobalConstant(LLVMValueRef GlobalVar, LLVMBool IsConstant);
Hans Wennborg5ff71202013-04-16 08:58:59 +00001824LLVMThreadLocalMode LLVMGetThreadLocalMode(LLVMValueRef GlobalVar);
1825void LLVMSetThreadLocalMode(LLVMValueRef GlobalVar, LLVMThreadLocalMode Mode);
1826LLVMBool LLVMIsExternallyInitialized(LLVMValueRef GlobalVar);
1827void LLVMSetExternallyInitialized(LLVMValueRef GlobalVar, LLVMBool IsExtInit);
Gordon Henriksen76a03742007-09-18 03:18:57 +00001828
Gregory Szorc52d26602012-03-21 07:28:27 +00001829/**
1830 * @}
1831 */
1832
1833/**
1834 * @defgroup LLVMCoreValueConstantGlobalAlias Global Aliases
1835 *
1836 * This group contains function that operate on global alias values.
1837 *
1838 * @see llvm::GlobalAlias
1839 *
1840 * @{
1841 */
Chris Lattner3d1f5522008-12-17 21:39:50 +00001842LLVMValueRef LLVMAddAlias(LLVMModuleRef M, LLVMTypeRef Ty, LLVMValueRef Aliasee,
1843 const char *Name);
1844
Gregory Szorc34c863a2012-03-21 03:54:29 +00001845/**
1846 * @}
1847 */
1848
1849/**
1850 * @defgroup LLVMCCoreValueFunction Function values
1851 *
1852 * Functions in this group operate on LLVMValueRef instances that
1853 * correspond to llvm::Function instances.
1854 *
1855 * @see llvm::Function
1856 *
1857 * @{
1858 */
1859
1860/**
1861 * Remove a function from its containing module and deletes it.
1862 *
1863 * @see llvm::Function::eraseFromParent()
1864 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00001865void LLVMDeleteFunction(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001866
1867/**
Amaury Sechete39e8532016-02-18 20:38:32 +00001868 * Check whether the given function has a personality function.
1869 *
1870 * @see llvm::Function::hasPersonalityFn()
1871 */
1872LLVMBool LLVMHasPersonalityFn(LLVMValueRef Fn);
1873
1874/**
Andrew Wilkins3bdfc1c2015-07-14 01:23:06 +00001875 * Obtain the personality function attached to the function.
1876 *
1877 * @see llvm::Function::getPersonalityFn()
1878 */
1879LLVMValueRef LLVMGetPersonalityFn(LLVMValueRef Fn);
1880
1881/**
1882 * Set the personality function attached to the function.
1883 *
1884 * @see llvm::Function::setPersonalityFn()
1885 */
1886void LLVMSetPersonalityFn(LLVMValueRef Fn, LLVMValueRef PersonalityFn);
1887
1888/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00001889 * Obtain the ID number from a function instance.
1890 *
1891 * @see llvm::Function::getIntrinsicID()
1892 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00001893unsigned LLVMGetIntrinsicID(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001894
1895/**
1896 * Obtain the calling function of a function.
1897 *
1898 * The returned value corresponds to the LLVMCallConv enumeration.
1899 *
1900 * @see llvm::Function::getCallingConv()
1901 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00001902unsigned LLVMGetFunctionCallConv(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001903
1904/**
1905 * Set the calling convention of a function.
1906 *
1907 * @see llvm::Function::setCallingConv()
1908 *
1909 * @param Fn Function to operate on
1910 * @param CC LLVMCallConv to set calling convention to
1911 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00001912void LLVMSetFunctionCallConv(LLVMValueRef Fn, unsigned CC);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001913
1914/**
1915 * Obtain the name of the garbage collector to use during code
1916 * generation.
1917 *
1918 * @see llvm::Function::getGC()
1919 */
Gordon Henriksend930f912008-08-17 18:44:35 +00001920const char *LLVMGetGC(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001921
1922/**
1923 * Define the garbage collector to use during code generation.
1924 *
1925 * @see llvm::Function::setGC()
1926 */
Gordon Henriksend930f912008-08-17 18:44:35 +00001927void LLVMSetGC(LLVMValueRef Fn, const char *Name);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001928
1929/**
1930 * Add an attribute to a function.
1931 *
1932 * @see llvm::Function::addAttribute()
1933 */
Duncan Sands7374a012009-05-06 12:21:17 +00001934void LLVMAddFunctionAttr(LLVMValueRef Fn, LLVMAttribute PA);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001935
1936/**
Nick Lewyckyc3890d22015-07-29 22:32:47 +00001937 * Add a target-dependent attribute to a function
Tom Stellarde8f35e12013-04-16 23:12:43 +00001938 * @see llvm::AttrBuilder::addAttribute()
1939 */
1940void LLVMAddTargetDependentFunctionAttr(LLVMValueRef Fn, const char *A,
1941 const char *V);
1942
1943/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00001944 * Obtain an attribute from a function.
1945 *
1946 * @see llvm::Function::getAttributes()
1947 */
Chris Lattner40cf28d2009-10-12 04:01:02 +00001948LLVMAttribute LLVMGetFunctionAttr(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001949
1950/**
1951 * Remove an attribute from a function.
1952 */
Duncan Sands7374a012009-05-06 12:21:17 +00001953void LLVMRemoveFunctionAttr(LLVMValueRef Fn, LLVMAttribute PA);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00001954
Gregory Szorc34c863a2012-03-21 03:54:29 +00001955/**
1956 * @defgroup LLVMCCoreValueFunctionParameters Function Parameters
1957 *
1958 * Functions in this group relate to arguments/parameters on functions.
1959 *
1960 * Functions in this group expect LLVMValueRef instances that correspond
1961 * to llvm::Function instances.
1962 *
1963 * @{
1964 */
1965
1966/**
1967 * Obtain the number of parameters in a function.
1968 *
1969 * @see llvm::Function::arg_size()
1970 */
Gordon Henriksen265f7802008-03-19 01:11:35 +00001971unsigned LLVMCountParams(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001972
1973/**
1974 * Obtain the parameters in a function.
1975 *
1976 * The takes a pointer to a pre-allocated array of LLVMValueRef that is
1977 * at least LLVMCountParams() long. This array will be filled with
1978 * LLVMValueRef instances which correspond to the parameters the
1979 * function receives. Each LLVMValueRef corresponds to a llvm::Argument
1980 * instance.
1981 *
1982 * @see llvm::Function::arg_begin()
1983 */
Gordon Henriksen265f7802008-03-19 01:11:35 +00001984void LLVMGetParams(LLVMValueRef Fn, LLVMValueRef *Params);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001985
1986/**
1987 * Obtain the parameter at the specified index.
1988 *
1989 * Parameters are indexed from 0.
1990 *
1991 * @see llvm::Function::arg_begin()
1992 */
Gordon Henriksen265f7802008-03-19 01:11:35 +00001993LLVMValueRef LLVMGetParam(LLVMValueRef Fn, unsigned Index);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001994
1995/**
1996 * Obtain the function to which this argument belongs.
1997 *
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00001998 * Unlike other functions in this group, this one takes an LLVMValueRef
Gregory Szorc34c863a2012-03-21 03:54:29 +00001999 * that corresponds to a llvm::Attribute.
2000 *
2001 * The returned LLVMValueRef is the llvm::Function to which this
2002 * argument belongs.
2003 */
Gordon Henriksen265f7802008-03-19 01:11:35 +00002004LLVMValueRef LLVMGetParamParent(LLVMValueRef Inst);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002005
2006/**
2007 * Obtain the first parameter to a function.
2008 *
2009 * @see llvm::Function::arg_begin()
2010 */
Gordon Henriksen07a45f42008-03-23 22:21:29 +00002011LLVMValueRef LLVMGetFirstParam(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002012
2013/**
2014 * Obtain the last parameter to a function.
2015 *
2016 * @see llvm::Function::arg_end()
2017 */
Gordon Henriksen07a45f42008-03-23 22:21:29 +00002018LLVMValueRef LLVMGetLastParam(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002019
2020/**
2021 * Obtain the next parameter to a function.
2022 *
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00002023 * This takes an LLVMValueRef obtained from LLVMGetFirstParam() (which is
Gregory Szorc34c863a2012-03-21 03:54:29 +00002024 * actually a wrapped iterator) and obtains the next parameter from the
2025 * underlying iterator.
2026 */
Gordon Henriksen07a45f42008-03-23 22:21:29 +00002027LLVMValueRef LLVMGetNextParam(LLVMValueRef Arg);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002028
2029/**
2030 * Obtain the previous parameter to a function.
2031 *
2032 * This is the opposite of LLVMGetNextParam().
2033 */
Gordon Henriksen07a45f42008-03-23 22:21:29 +00002034LLVMValueRef LLVMGetPreviousParam(LLVMValueRef Arg);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002035
2036/**
2037 * Add an attribute to a function argument.
2038 *
2039 * @see llvm::Argument::addAttr()
2040 */
Devang Patel4c758ea2008-09-25 21:00:45 +00002041void LLVMAddAttribute(LLVMValueRef Arg, LLVMAttribute PA);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002042
2043/**
2044 * Remove an attribute from a function argument.
2045 *
2046 * @see llvm::Argument::removeAttr()
2047 */
Devang Patel4c758ea2008-09-25 21:00:45 +00002048void LLVMRemoveAttribute(LLVMValueRef Arg, LLVMAttribute PA);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002049
2050/**
2051 * Get an attribute from a function argument.
2052 */
Chris Lattner40cf28d2009-10-12 04:01:02 +00002053LLVMAttribute LLVMGetAttribute(LLVMValueRef Arg);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002054
2055/**
2056 * Set the alignment for a function parameter.
2057 *
2058 * @see llvm::Argument::addAttr()
Bill Wendling50d27842012-10-15 20:35:56 +00002059 * @see llvm::AttrBuilder::addAlignmentAttr()
Gregory Szorc34c863a2012-03-21 03:54:29 +00002060 */
Gordon Henriksen2d9cc212008-04-28 17:37:06 +00002061void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned align);
Gordon Henriksen265f7802008-03-19 01:11:35 +00002062
Gregory Szorc34c863a2012-03-21 03:54:29 +00002063/**
2064 * @}
2065 */
2066
2067/**
2068 * @}
2069 */
2070
2071/**
Gregory Szorc52d26602012-03-21 07:28:27 +00002072 * @}
2073 */
2074
2075/**
2076 * @}
2077 */
2078
2079/**
2080 * @defgroup LLVMCCoreValueMetadata Metadata
2081 *
2082 * @{
2083 */
2084
2085/**
2086 * Obtain a MDString value from a context.
2087 *
2088 * The returned instance corresponds to the llvm::MDString class.
2089 *
2090 * The instance is specified by string data of a specified length. The
2091 * string content is copied, so the backing memory can be freed after
2092 * this function returns.
2093 */
2094LLVMValueRef LLVMMDStringInContext(LLVMContextRef C, const char *Str,
2095 unsigned SLen);
2096
2097/**
2098 * Obtain a MDString value from the global context.
2099 */
2100LLVMValueRef LLVMMDString(const char *Str, unsigned SLen);
2101
2102/**
2103 * Obtain a MDNode value from a context.
2104 *
2105 * The returned value corresponds to the llvm::MDNode class.
2106 */
2107LLVMValueRef LLVMMDNodeInContext(LLVMContextRef C, LLVMValueRef *Vals,
2108 unsigned Count);
2109
2110/**
2111 * Obtain a MDNode value from the global context.
2112 */
2113LLVMValueRef LLVMMDNode(LLVMValueRef *Vals, unsigned Count);
2114
2115/**
2116 * Obtain the underlying string from a MDString value.
2117 *
2118 * @param V Instance to obtain string from.
NAKAMURA Takumie4a77052016-04-04 11:54:48 +00002119 * @param Length Memory address which will hold length of returned string.
Gregory Szorc52d26602012-03-21 07:28:27 +00002120 * @return String data in MDString.
2121 */
Amaury Sechet7c2883c2016-04-03 21:06:04 +00002122const char *LLVMGetMDString(LLVMValueRef V, unsigned *Length);
Gregory Szorc52d26602012-03-21 07:28:27 +00002123
2124/**
Duncan Sands12ccbe72012-09-19 20:29:39 +00002125 * Obtain the number of operands from an MDNode value.
2126 *
2127 * @param V MDNode to get number of operands from.
2128 * @return Number of operands of the MDNode.
2129 */
2130unsigned LLVMGetMDNodeNumOperands(LLVMValueRef V);
2131
2132/**
2133 * Obtain the given MDNode's operands.
2134 *
2135 * The passed LLVMValueRef pointer should point to enough memory to hold all of
2136 * the operands of the given MDNode (see LLVMGetMDNodeNumOperands) as
2137 * LLVMValueRefs. This memory will be populated with the LLVMValueRefs of the
2138 * MDNode's operands.
2139 *
2140 * @param V MDNode to get the operands from.
2141 * @param Dest Destination array for operands.
2142 */
2143void LLVMGetMDNodeOperands(LLVMValueRef V, LLVMValueRef *Dest);
2144
2145/**
Gregory Szorc52d26602012-03-21 07:28:27 +00002146 * @}
2147 */
2148
2149/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002150 * @defgroup LLVMCCoreValueBasicBlock Basic Block
2151 *
2152 * A basic block represents a single entry single exit section of code.
2153 * Basic blocks contain a list of instructions which form the body of
2154 * the block.
2155 *
2156 * Basic blocks belong to functions. They have the type of label.
2157 *
2158 * Basic blocks are themselves values. However, the C API models them as
2159 * LLVMBasicBlockRef.
2160 *
2161 * @see llvm::BasicBlock
2162 *
2163 * @{
2164 */
2165
2166/**
2167 * Convert a basic block instance to a value type.
2168 */
Gordon Henriksen07a45f42008-03-23 22:21:29 +00002169LLVMValueRef LLVMBasicBlockAsValue(LLVMBasicBlockRef BB);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002170
2171/**
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00002172 * Determine whether an LLVMValueRef is itself a basic block.
Gregory Szorc34c863a2012-03-21 03:54:29 +00002173 */
Chris Lattner25963c62010-01-09 22:27:07 +00002174LLVMBool LLVMValueIsBasicBlock(LLVMValueRef Val);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002175
2176/**
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00002177 * Convert an LLVMValueRef to an LLVMBasicBlockRef instance.
Gregory Szorc34c863a2012-03-21 03:54:29 +00002178 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002179LLVMBasicBlockRef LLVMValueAsBasicBlock(LLVMValueRef Val);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002180
2181/**
Amaury Secheta82042e2016-02-09 22:36:41 +00002182 * Obtain the string name of a basic block.
2183 */
2184const char *LLVMGetBasicBlockName(LLVMBasicBlockRef BB);
2185
2186/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002187 * Obtain the function to which a basic block belongs.
2188 *
2189 * @see llvm::BasicBlock::getParent()
2190 */
Gordon Henriksen07a45f42008-03-23 22:21:29 +00002191LLVMValueRef LLVMGetBasicBlockParent(LLVMBasicBlockRef BB);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002192
2193/**
2194 * Obtain the terminator instruction for a basic block.
2195 *
2196 * If the basic block does not have a terminator (it is not well-formed
2197 * if it doesn't), then NULL is returned.
2198 *
2199 * The returned LLVMValueRef corresponds to a llvm::TerminatorInst.
2200 *
2201 * @see llvm::BasicBlock::getTerminator()
2202 */
Nate Begeman43c322b2011-08-23 20:27:46 +00002203LLVMValueRef LLVMGetBasicBlockTerminator(LLVMBasicBlockRef BB);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002204
2205/**
2206 * Obtain the number of basic blocks in a function.
2207 *
2208 * @param Fn Function value to operate on.
2209 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002210unsigned LLVMCountBasicBlocks(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002211
2212/**
2213 * Obtain all of the basic blocks in a function.
2214 *
2215 * This operates on a function value. The BasicBlocks parameter is a
2216 * pointer to a pre-allocated array of LLVMBasicBlockRef of at least
2217 * LLVMCountBasicBlocks() in length. This array is populated with
2218 * LLVMBasicBlockRef instances.
2219 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002220void LLVMGetBasicBlocks(LLVMValueRef Fn, LLVMBasicBlockRef *BasicBlocks);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002221
2222/**
2223 * Obtain the first basic block in a function.
2224 *
2225 * The returned basic block can be used as an iterator. You will likely
2226 * eventually call into LLVMGetNextBasicBlock() with it.
2227 *
2228 * @see llvm::Function::begin()
2229 */
Gordon Henriksen054817c2008-03-19 03:47:18 +00002230LLVMBasicBlockRef LLVMGetFirstBasicBlock(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002231
2232/**
2233 * Obtain the last basic block in a function.
2234 *
2235 * @see llvm::Function::end()
2236 */
Gordon Henriksen054817c2008-03-19 03:47:18 +00002237LLVMBasicBlockRef LLVMGetLastBasicBlock(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002238
2239/**
2240 * Advance a basic block iterator.
2241 */
Gordon Henriksen054817c2008-03-19 03:47:18 +00002242LLVMBasicBlockRef LLVMGetNextBasicBlock(LLVMBasicBlockRef BB);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002243
2244/**
2245 * Go backwards in a basic block iterator.
2246 */
Gordon Henriksen054817c2008-03-19 03:47:18 +00002247LLVMBasicBlockRef LLVMGetPreviousBasicBlock(LLVMBasicBlockRef BB);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002248
2249/**
2250 * Obtain the basic block that corresponds to the entry point of a
2251 * function.
2252 *
2253 * @see llvm::Function::getEntryBlock()
2254 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002255LLVMBasicBlockRef LLVMGetEntryBasicBlock(LLVMValueRef Fn);
Erick Tryzelaar262332f2009-08-14 00:01:31 +00002256
Gregory Szorc34c863a2012-03-21 03:54:29 +00002257/**
2258 * Append a basic block to the end of a function.
2259 *
2260 * @see llvm::BasicBlock::Create()
2261 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +00002262LLVMBasicBlockRef LLVMAppendBasicBlockInContext(LLVMContextRef C,
2263 LLVMValueRef Fn,
2264 const char *Name);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002265
2266/**
2267 * Append a basic block to the end of a function using the global
2268 * context.
2269 *
2270 * @see llvm::BasicBlock::Create()
2271 */
2272LLVMBasicBlockRef LLVMAppendBasicBlock(LLVMValueRef Fn, const char *Name);
2273
2274/**
2275 * Insert a basic block in a function before another basic block.
2276 *
2277 * The function to add to is determined by the function of the
2278 * passed basic block.
2279 *
2280 * @see llvm::BasicBlock::Create()
2281 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +00002282LLVMBasicBlockRef LLVMInsertBasicBlockInContext(LLVMContextRef C,
2283 LLVMBasicBlockRef BB,
2284 const char *Name);
2285
Gregory Szorc34c863a2012-03-21 03:54:29 +00002286/**
2287 * Insert a basic block in a function using the global context.
2288 *
2289 * @see llvm::BasicBlock::Create()
2290 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002291LLVMBasicBlockRef LLVMInsertBasicBlock(LLVMBasicBlockRef InsertBeforeBB,
2292 const char *Name);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002293
2294/**
2295 * Remove a basic block from a function and delete it.
2296 *
2297 * This deletes the basic block from its containing function and deletes
2298 * the basic block itself.
2299 *
2300 * @see llvm::BasicBlock::eraseFromParent()
2301 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002302void LLVMDeleteBasicBlock(LLVMBasicBlockRef BB);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002303
2304/**
2305 * Remove a basic block from a function.
2306 *
2307 * This deletes the basic block from its containing function but keep
2308 * the basic block alive.
2309 *
2310 * @see llvm::BasicBlock::removeFromParent()
2311 */
Nate Begeman43c322b2011-08-23 20:27:46 +00002312void LLVMRemoveBasicBlockFromParent(LLVMBasicBlockRef BB);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002313
Gregory Szorc34c863a2012-03-21 03:54:29 +00002314/**
2315 * Move a basic block to before another one.
2316 *
2317 * @see llvm::BasicBlock::moveBefore()
2318 */
Duncan Sandsb1d61aa2010-07-19 15:31:07 +00002319void LLVMMoveBasicBlockBefore(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002320
2321/**
2322 * Move a basic block to after another one.
2323 *
2324 * @see llvm::BasicBlock::moveAfter()
2325 */
Duncan Sandsb1d61aa2010-07-19 15:31:07 +00002326void LLVMMoveBasicBlockAfter(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos);
2327
Gregory Szorc34c863a2012-03-21 03:54:29 +00002328/**
2329 * Obtain the first instruction in a basic block.
2330 *
2331 * The returned LLVMValueRef corresponds to a llvm::Instruction
2332 * instance.
2333 */
Gordon Henriksen054817c2008-03-19 03:47:18 +00002334LLVMValueRef LLVMGetFirstInstruction(LLVMBasicBlockRef BB);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002335
2336/**
2337 * Obtain the last instruction in a basic block.
2338 *
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00002339 * The returned LLVMValueRef corresponds to an LLVM:Instruction.
Gregory Szorc34c863a2012-03-21 03:54:29 +00002340 */
Gordon Henriksen054817c2008-03-19 03:47:18 +00002341LLVMValueRef LLVMGetLastInstruction(LLVMBasicBlockRef BB);
Nate Begeman43c322b2011-08-23 20:27:46 +00002342
Gregory Szorc34c863a2012-03-21 03:54:29 +00002343/**
2344 * @}
2345 */
2346
2347/**
2348 * @defgroup LLVMCCoreValueInstruction Instructions
2349 *
2350 * Functions in this group relate to the inspection and manipulation of
2351 * individual instructions.
2352 *
2353 * In the C++ API, an instruction is modeled by llvm::Instruction. This
2354 * class has a large number of descendents. llvm::Instruction is a
2355 * llvm::Value and in the C API, instructions are modeled by
2356 * LLVMValueRef.
2357 *
2358 * This group also contains sub-groups which operate on specific
2359 * llvm::Instruction types, e.g. llvm::CallInst.
2360 *
2361 * @{
2362 */
2363
2364/**
2365 * Determine whether an instruction has any metadata attached.
2366 */
2367int LLVMHasMetadata(LLVMValueRef Val);
2368
2369/**
2370 * Return metadata associated with an instruction value.
2371 */
2372LLVMValueRef LLVMGetMetadata(LLVMValueRef Val, unsigned KindID);
2373
2374/**
2375 * Set metadata associated with an instruction value.
2376 */
2377void LLVMSetMetadata(LLVMValueRef Val, unsigned KindID, LLVMValueRef Node);
2378
2379/**
2380 * Obtain the basic block to which an instruction belongs.
2381 *
2382 * @see llvm::Instruction::getParent()
2383 */
Nate Begeman43c322b2011-08-23 20:27:46 +00002384LLVMBasicBlockRef LLVMGetInstructionParent(LLVMValueRef Inst);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002385
2386/**
2387 * Obtain the instruction that occurs after the one specified.
2388 *
2389 * The next instruction will be from the same basic block.
2390 *
2391 * If this is the last instruction in a basic block, NULL will be
2392 * returned.
2393 */
Gordon Henriksen054817c2008-03-19 03:47:18 +00002394LLVMValueRef LLVMGetNextInstruction(LLVMValueRef Inst);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002395
2396/**
Benjamin Kramerbde91762012-06-02 10:20:22 +00002397 * Obtain the instruction that occurred before this one.
Gregory Szorc34c863a2012-03-21 03:54:29 +00002398 *
2399 * If the instruction is the first instruction in a basic block, NULL
2400 * will be returned.
2401 */
Gordon Henriksen054817c2008-03-19 03:47:18 +00002402LLVMValueRef LLVMGetPreviousInstruction(LLVMValueRef Inst);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002403
2404/**
2405 * Remove and delete an instruction.
2406 *
2407 * The instruction specified is removed from its containing building
Amaury Sechet2f432082016-02-11 21:37:54 +00002408 * block but is kept alive.
2409 *
2410 * @see llvm::Instruction::removeFromParent()
2411 */
2412void LLVMInstructionRemoveFromParent(LLVMValueRef Inst);
2413
2414/**
2415 * Remove and delete an instruction.
2416 *
2417 * The instruction specified is removed from its containing building
Gregory Szorc34c863a2012-03-21 03:54:29 +00002418 * block and then deleted.
2419 *
2420 * @see llvm::Instruction::eraseFromParent()
2421 */
Devang Pateldbebc6f2011-10-03 20:59:18 +00002422void LLVMInstructionEraseFromParent(LLVMValueRef Inst);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002423
2424/**
2425 * Obtain the code opcode for an individual instruction.
2426 *
2427 * @see llvm::Instruction::getOpCode()
2428 */
Eric Christophera6b96002015-12-18 01:46:52 +00002429LLVMOpcode LLVMGetInstructionOpcode(LLVMValueRef Inst);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002430
2431/**
2432 * Obtain the predicate of an instruction.
2433 *
2434 * This is only valid for instructions that correspond to llvm::ICmpInst
2435 * or llvm::ConstantExpr whose opcode is llvm::Instruction::ICmp.
2436 *
2437 * @see llvm::ICmpInst::getPredicate()
2438 */
Torok Edwin60c40de2011-10-06 12:13:20 +00002439LLVMIntPredicate LLVMGetICmpPredicate(LLVMValueRef Inst);
Gordon Henriksen265f7802008-03-19 01:11:35 +00002440
Gregory Szorc34c863a2012-03-21 03:54:29 +00002441/**
Peter Zotov1d98e6d2014-10-28 19:46:44 +00002442 * Obtain the float predicate of an instruction.
2443 *
2444 * This is only valid for instructions that correspond to llvm::FCmpInst
2445 * or llvm::ConstantExpr whose opcode is llvm::Instruction::FCmp.
2446 *
2447 * @see llvm::FCmpInst::getPredicate()
2448 */
2449LLVMRealPredicate LLVMGetFCmpPredicate(LLVMValueRef Inst);
2450
2451/**
Peter Zotovaff492c2014-10-17 01:02:34 +00002452 * Create a copy of 'this' instruction that is identical in all ways
2453 * except the following:
2454 * * The instruction has no parent
2455 * * The instruction has no name
2456 *
2457 * @see llvm::Instruction::clone()
2458 */
2459LLVMValueRef LLVMInstructionClone(LLVMValueRef Inst);
2460
2461/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002462 * @defgroup LLVMCCoreValueInstructionCall Call Sites and Invocations
2463 *
2464 * Functions in this group apply to instructions that refer to call
2465 * sites and invocations. These correspond to C++ types in the
2466 * llvm::CallInst class tree.
2467 *
2468 * @{
2469 */
2470
2471/**
Amaury Sechet5c7b3af2016-02-10 00:09:37 +00002472 * Obtain the argument count for a call instruction.
2473 *
2474 * This expects an LLVMValueRef that corresponds to a llvm::CallInst or
2475 * llvm::InvokeInst.
2476 *
2477 * @see llvm::CallInst::getNumArgOperands()
2478 * @see llvm::InvokeInst::getNumArgOperands()
2479 */
2480unsigned LLVMGetNumArgOperands(LLVMValueRef Instr);
2481
2482/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002483 * Set the calling convention for a call instruction.
2484 *
2485 * This expects an LLVMValueRef that corresponds to a llvm::CallInst or
2486 * llvm::InvokeInst.
2487 *
2488 * @see llvm::CallInst::setCallingConv()
2489 * @see llvm::InvokeInst::setCallingConv()
2490 */
Gordon Henriksen1158c532007-12-29 20:45:00 +00002491void LLVMSetInstructionCallConv(LLVMValueRef Instr, unsigned CC);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002492
2493/**
2494 * Obtain the calling convention for a call instruction.
2495 *
2496 * This is the opposite of LLVMSetInstructionCallConv(). Reads its
2497 * usage.
2498 *
2499 * @see LLVMSetInstructionCallConv()
2500 */
Gordon Henriksen1158c532007-12-29 20:45:00 +00002501unsigned LLVMGetInstructionCallConv(LLVMValueRef Instr);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002502
2503
Devang Patel4c758ea2008-09-25 21:00:45 +00002504void LLVMAddInstrAttribute(LLVMValueRef Instr, unsigned index, LLVMAttribute);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002505void LLVMRemoveInstrAttribute(LLVMValueRef Instr, unsigned index,
Devang Patel4c758ea2008-09-25 21:00:45 +00002506 LLVMAttribute);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002507void LLVMSetInstrParamAlignment(LLVMValueRef Instr, unsigned index,
Gordon Henriksen2d9cc212008-04-28 17:37:06 +00002508 unsigned align);
Gordon Henriksen1158c532007-12-29 20:45:00 +00002509
Gregory Szorc34c863a2012-03-21 03:54:29 +00002510/**
Amaury Sechet5c7b3af2016-02-10 00:09:37 +00002511 * Obtain the pointer to the function invoked by this instruction.
2512 *
2513 * This expects an LLVMValueRef that corresponds to a llvm::CallInst or
2514 * llvm::InvokeInst.
2515 *
2516 * @see llvm::CallInst::getCalledValue()
2517 * @see llvm::InvokeInst::getCalledValue()
2518 */
2519LLVMValueRef LLVMGetCalledValue(LLVMValueRef Instr);
2520
2521/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002522 * Obtain whether a call instruction is a tail call.
2523 *
2524 * This only works on llvm::CallInst instructions.
2525 *
2526 * @see llvm::CallInst::isTailCall()
2527 */
Chris Lattner25963c62010-01-09 22:27:07 +00002528LLVMBool LLVMIsTailCall(LLVMValueRef CallInst);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002529
2530/**
2531 * Set whether a call instruction is a tail call.
2532 *
2533 * This only works on llvm::CallInst instructions.
2534 *
2535 * @see llvm::CallInst::setTailCall()
2536 */
Chris Lattner25963c62010-01-09 22:27:07 +00002537void LLVMSetTailCall(LLVMValueRef CallInst, LLVMBool IsTailCall);
Gordon Henrikseneeb65372008-08-30 16:34:54 +00002538
Gregory Szorc34c863a2012-03-21 03:54:29 +00002539/**
Amaury Sechete39e8532016-02-18 20:38:32 +00002540 * Return the normal destination basic block.
2541 *
2542 * This only works on llvm::InvokeInst instructions.
2543 *
2544 * @see llvm::InvokeInst::getNormalDest()
2545 */
2546LLVMBasicBlockRef LLVMGetNormalDest(LLVMValueRef InvokeInst);
2547
2548/**
2549 * Return the unwind destination basic block.
2550 *
2551 * This only works on llvm::InvokeInst instructions.
2552 *
2553 * @see llvm::InvokeInst::getUnwindDest()
2554 */
2555LLVMBasicBlockRef LLVMGetUnwindDest(LLVMValueRef InvokeInst);
2556
2557/**
2558 * Set the normal destination basic block.
2559 *
2560 * This only works on llvm::InvokeInst instructions.
2561 *
2562 * @see llvm::InvokeInst::setNormalDest()
2563 */
2564void LLVMSetNormalDest(LLVMValueRef InvokeInst, LLVMBasicBlockRef B);
2565
2566/**
2567 * Set the unwind destination basic block.
2568 *
2569 * This only works on llvm::InvokeInst instructions.
2570 *
2571 * @see llvm::InvokeInst::setUnwindDest()
2572 */
2573void LLVMSetUnwindDest(LLVMValueRef InvokeInst, LLVMBasicBlockRef B);
2574
2575/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002576 * @}
2577 */
2578
2579/**
Peter Zotov2481c752014-10-28 19:46:56 +00002580 * @defgroup LLVMCCoreValueInstructionTerminator Terminators
2581 *
2582 * Functions in this group only apply to instructions that map to
2583 * llvm::TerminatorInst instances.
2584 *
2585 * @{
2586 */
2587
2588/**
2589 * Return the number of successors that this terminator has.
2590 *
2591 * @see llvm::TerminatorInst::getNumSuccessors
2592 */
2593unsigned LLVMGetNumSuccessors(LLVMValueRef Term);
2594
2595/**
2596 * Return the specified successor.
2597 *
2598 * @see llvm::TerminatorInst::getSuccessor
2599 */
2600LLVMBasicBlockRef LLVMGetSuccessor(LLVMValueRef Term, unsigned i);
2601
2602/**
2603 * Update the specified successor to point at the provided block.
2604 *
2605 * @see llvm::TerminatorInst::setSuccessor
2606 */
2607void LLVMSetSuccessor(LLVMValueRef Term, unsigned i, LLVMBasicBlockRef block);
2608
2609/**
2610 * Return if a branch is conditional.
2611 *
2612 * This only works on llvm::BranchInst instructions.
2613 *
2614 * @see llvm::BranchInst::isConditional
2615 */
2616LLVMBool LLVMIsConditional(LLVMValueRef Branch);
2617
2618/**
2619 * Return the condition of a branch instruction.
2620 *
2621 * This only works on llvm::BranchInst instructions.
2622 *
2623 * @see llvm::BranchInst::getCondition
2624 */
2625LLVMValueRef LLVMGetCondition(LLVMValueRef Branch);
2626
2627/**
2628 * Set the condition of a branch instruction.
2629 *
2630 * This only works on llvm::BranchInst instructions.
2631 *
2632 * @see llvm::BranchInst::setCondition
2633 */
2634void LLVMSetCondition(LLVMValueRef Branch, LLVMValueRef Cond);
2635
2636/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002637 * Obtain the default destination basic block of a switch instruction.
2638 *
2639 * This only works on llvm::SwitchInst instructions.
2640 *
2641 * @see llvm::SwitchInst::getDefaultDest()
2642 */
Nate Begeman43c322b2011-08-23 20:27:46 +00002643LLVMBasicBlockRef LLVMGetSwitchDefaultDest(LLVMValueRef SwitchInstr);
2644
Gregory Szorc34c863a2012-03-21 03:54:29 +00002645/**
Peter Zotov2481c752014-10-28 19:46:56 +00002646 * @}
2647 */
2648
2649/**
Amaury Sechet1dcf5772016-02-09 22:50:53 +00002650 * @defgroup LLVMCCoreValueInstructionAlloca Allocas
2651 *
2652 * Functions in this group only apply to instructions that map to
2653 * llvm::AllocaInst instances.
2654 *
2655 * @{
2656 */
2657
2658/**
2659 * Obtain the type that is being allocated by the alloca instruction.
2660 */
2661LLVMTypeRef LLVMGetAllocatedType(LLVMValueRef Alloca);
2662
2663/**
2664 * @}
2665 */
2666
2667/**
Amaury Sechet053ac452016-02-17 22:51:03 +00002668 * @defgroup LLVMCCoreValueInstructionGetElementPointer GEPs
2669 *
2670 * Functions in this group only apply to instructions that map to
2671 * llvm::GetElementPtrInst instances.
2672 *
2673 * @{
2674 */
2675
2676/**
2677 * Check whether the given GEP instruction is inbounds.
2678 */
2679LLVMBool LLVMIsInBounds(LLVMValueRef GEP);
2680
2681/**
2682 * Set the given GEP instruction to be inbounds or not.
2683 */
2684void LLVMSetIsInBounds(LLVMValueRef GEP, LLVMBool b);
2685
2686/**
2687 * @}
2688 */
2689
2690/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002691 * @defgroup LLVMCCoreValueInstructionPHINode PHI Nodes
2692 *
2693 * Functions in this group only apply to instructions that map to
2694 * llvm::PHINode instances.
2695 *
2696 * @{
2697 */
2698
2699/**
2700 * Add an incoming value to the end of a PHI list.
2701 */
Gordon Henriksen44dd8fb2007-10-08 18:14:39 +00002702void LLVMAddIncoming(LLVMValueRef PhiNode, LLVMValueRef *IncomingValues,
2703 LLVMBasicBlockRef *IncomingBlocks, unsigned Count);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002704
2705/**
2706 * Obtain the number of incoming basic blocks to a PHI node.
2707 */
Gordon Henriksen44dd8fb2007-10-08 18:14:39 +00002708unsigned LLVMCountIncoming(LLVMValueRef PhiNode);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002709
2710/**
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00002711 * Obtain an incoming value to a PHI node as an LLVMValueRef.
Gregory Szorc34c863a2012-03-21 03:54:29 +00002712 */
Gordon Henriksen44dd8fb2007-10-08 18:14:39 +00002713LLVMValueRef LLVMGetIncomingValue(LLVMValueRef PhiNode, unsigned Index);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002714
2715/**
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00002716 * Obtain an incoming value to a PHI node as an LLVMBasicBlockRef.
Gregory Szorc34c863a2012-03-21 03:54:29 +00002717 */
Gordon Henriksen44dd8fb2007-10-08 18:14:39 +00002718LLVMBasicBlockRef LLVMGetIncomingBlock(LLVMValueRef PhiNode, unsigned Index);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002719
Gregory Szorc34c863a2012-03-21 03:54:29 +00002720/**
2721 * @}
2722 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002723
Gregory Szorc34c863a2012-03-21 03:54:29 +00002724/**
Amaury Sechetaad93532016-02-10 00:38:50 +00002725 * @defgroup LLVMCCoreValueInstructionExtractValue ExtractValue
2726 * @defgroup LLVMCCoreValueInstructionInsertValue InsertValue
2727 *
2728 * Functions in this group only apply to instructions that map to
2729 * llvm::ExtractValue and llvm::InsertValue instances.
2730 *
2731 * @{
2732 */
2733
2734/**
2735 * Obtain the number of indices.
Amaury Sechet053ac452016-02-17 22:51:03 +00002736 * NB: This also works on GEP.
Amaury Sechetaad93532016-02-10 00:38:50 +00002737 */
2738unsigned LLVMGetNumIndices(LLVMValueRef Inst);
2739
2740/**
2741 * Obtain the indices as an array.
2742 */
2743const unsigned *LLVMGetIndices(LLVMValueRef Inst);
2744
2745/**
2746 * @}
2747 */
2748
2749/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002750 * @}
2751 */
2752
2753/**
2754 * @}
2755 */
2756
2757/**
2758 * @defgroup LLVMCCoreInstructionBuilder Instruction Builders
2759 *
2760 * An instruction builder represents a point within a basic block and is
2761 * the exclusive means of building instructions using the C interface.
2762 *
2763 * @{
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002764 */
2765
Erick Tryzelaar262332f2009-08-14 00:01:31 +00002766LLVMBuilderRef LLVMCreateBuilderInContext(LLVMContextRef C);
Gordon Henriksena735a9c2008-05-04 12:55:34 +00002767LLVMBuilderRef LLVMCreateBuilder(void);
Gordon Henriksen054817c2008-03-19 03:47:18 +00002768void LLVMPositionBuilder(LLVMBuilderRef Builder, LLVMBasicBlockRef Block,
2769 LLVMValueRef Instr);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002770void LLVMPositionBuilderBefore(LLVMBuilderRef Builder, LLVMValueRef Instr);
2771void LLVMPositionBuilderAtEnd(LLVMBuilderRef Builder, LLVMBasicBlockRef Block);
Gordon Henriksen265f7802008-03-19 01:11:35 +00002772LLVMBasicBlockRef LLVMGetInsertBlock(LLVMBuilderRef Builder);
Chris Lattner3d1f5522008-12-17 21:39:50 +00002773void LLVMClearInsertionPosition(LLVMBuilderRef Builder);
2774void LLVMInsertIntoBuilder(LLVMBuilderRef Builder, LLVMValueRef Instr);
Erick Tryzelaar9813bea2009-08-16 02:20:57 +00002775void LLVMInsertIntoBuilderWithName(LLVMBuilderRef Builder, LLVMValueRef Instr,
2776 const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002777void LLVMDisposeBuilder(LLVMBuilderRef Builder);
2778
Erick Tryzelaard8531fa2010-02-28 09:45:59 +00002779/* Metadata */
2780void LLVMSetCurrentDebugLocation(LLVMBuilderRef Builder, LLVMValueRef L);
2781LLVMValueRef LLVMGetCurrentDebugLocation(LLVMBuilderRef Builder);
2782void LLVMSetInstDebugLocation(LLVMBuilderRef Builder, LLVMValueRef Inst);
2783
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002784/* Terminators */
2785LLVMValueRef LLVMBuildRetVoid(LLVMBuilderRef);
2786LLVMValueRef LLVMBuildRet(LLVMBuilderRef, LLVMValueRef V);
Erick Tryzelaarfd529d72009-08-19 08:36:49 +00002787LLVMValueRef LLVMBuildAggregateRet(LLVMBuilderRef, LLVMValueRef *RetVals,
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002788 unsigned N);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002789LLVMValueRef LLVMBuildBr(LLVMBuilderRef, LLVMBasicBlockRef Dest);
2790LLVMValueRef LLVMBuildCondBr(LLVMBuilderRef, LLVMValueRef If,
2791 LLVMBasicBlockRef Then, LLVMBasicBlockRef Else);
2792LLVMValueRef LLVMBuildSwitch(LLVMBuilderRef, LLVMValueRef V,
2793 LLVMBasicBlockRef Else, unsigned NumCases);
Erick Tryzelaar0fb26ef2010-02-28 09:46:06 +00002794LLVMValueRef LLVMBuildIndirectBr(LLVMBuilderRef B, LLVMValueRef Addr,
2795 unsigned NumDests);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002796LLVMValueRef LLVMBuildInvoke(LLVMBuilderRef, LLVMValueRef Fn,
2797 LLVMValueRef *Args, unsigned NumArgs,
2798 LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch,
2799 const char *Name);
Benjamin Kramer5a6568832011-08-19 01:36:54 +00002800LLVMValueRef LLVMBuildLandingPad(LLVMBuilderRef B, LLVMTypeRef Ty,
Reid Kleckneref9828f2015-07-16 01:16:39 +00002801 LLVMValueRef PersFn, unsigned NumClauses,
2802 const char *Name);
Bill Wendlingf891bf82011-07-31 06:30:59 +00002803LLVMValueRef LLVMBuildResume(LLVMBuilderRef B, LLVMValueRef Exn);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002804LLVMValueRef LLVMBuildUnreachable(LLVMBuilderRef);
2805
Gordon Henriksen097102c2008-01-01 05:50:53 +00002806/* Add a case to the switch instruction */
2807void LLVMAddCase(LLVMValueRef Switch, LLVMValueRef OnVal,
2808 LLVMBasicBlockRef Dest);
2809
Erick Tryzelaar0fb26ef2010-02-28 09:46:06 +00002810/* Add a destination to the indirectbr instruction */
2811void LLVMAddDestination(LLVMValueRef IndirectBr, LLVMBasicBlockRef Dest);
2812
Amaury Sechete39e8532016-02-18 20:38:32 +00002813/* Get the number of clauses on the landingpad instruction */
2814unsigned LLVMGetNumClauses(LLVMValueRef LandingPad);
2815
2816/* Get the value of the clause at idnex Idx on the landingpad instruction */
2817LLVMValueRef LLVMGetClause(LLVMValueRef LandingPad, unsigned Idx);
2818
Bill Wendlingfae14752011-08-12 20:24:12 +00002819/* Add a catch or filter clause to the landingpad instruction */
2820void LLVMAddClause(LLVMValueRef LandingPad, LLVMValueRef ClauseVal);
2821
Amaury Sechete39e8532016-02-18 20:38:32 +00002822/* Get the 'cleanup' flag in the landingpad instruction */
2823LLVMBool LLVMIsCleanup(LLVMValueRef LandingPad);
2824
Bill Wendlingfae14752011-08-12 20:24:12 +00002825/* Set the 'cleanup' flag in the landingpad instruction */
2826void LLVMSetCleanup(LLVMValueRef LandingPad, LLVMBool Val);
2827
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002828/* Arithmetic */
2829LLVMValueRef LLVMBuildAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2830 const char *Name);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002831LLVMValueRef LLVMBuildNSWAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2832 const char *Name);
Erick Tryzelaar4c340c72010-02-28 05:51:43 +00002833LLVMValueRef LLVMBuildNUWAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2834 const char *Name);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002835LLVMValueRef LLVMBuildFAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2836 const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002837LLVMValueRef LLVMBuildSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2838 const char *Name);
Erick Tryzelaar4c340c72010-02-28 05:51:43 +00002839LLVMValueRef LLVMBuildNSWSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2840 const char *Name);
2841LLVMValueRef LLVMBuildNUWSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2842 const char *Name);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002843LLVMValueRef LLVMBuildFSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2844 const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002845LLVMValueRef LLVMBuildMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2846 const char *Name);
Erick Tryzelaar4c340c72010-02-28 05:51:43 +00002847LLVMValueRef LLVMBuildNSWMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2848 const char *Name);
2849LLVMValueRef LLVMBuildNUWMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2850 const char *Name);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002851LLVMValueRef LLVMBuildFMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2852 const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002853LLVMValueRef LLVMBuildUDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2854 const char *Name);
2855LLVMValueRef LLVMBuildSDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2856 const char *Name);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002857LLVMValueRef LLVMBuildExactSDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2858 const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002859LLVMValueRef LLVMBuildFDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2860 const char *Name);
2861LLVMValueRef LLVMBuildURem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2862 const char *Name);
2863LLVMValueRef LLVMBuildSRem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2864 const char *Name);
2865LLVMValueRef LLVMBuildFRem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2866 const char *Name);
2867LLVMValueRef LLVMBuildShl(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2868 const char *Name);
2869LLVMValueRef LLVMBuildLShr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2870 const char *Name);
2871LLVMValueRef LLVMBuildAShr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2872 const char *Name);
2873LLVMValueRef LLVMBuildAnd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2874 const char *Name);
2875LLVMValueRef LLVMBuildOr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2876 const char *Name);
2877LLVMValueRef LLVMBuildXor(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2878 const char *Name);
Erick Tryzelaar31831792010-02-28 05:51:27 +00002879LLVMValueRef LLVMBuildBinOp(LLVMBuilderRef B, LLVMOpcode Op,
2880 LLVMValueRef LHS, LLVMValueRef RHS,
2881 const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002882LLVMValueRef LLVMBuildNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name);
Erick Tryzelaar4c340c72010-02-28 05:51:43 +00002883LLVMValueRef LLVMBuildNSWNeg(LLVMBuilderRef B, LLVMValueRef V,
2884 const char *Name);
2885LLVMValueRef LLVMBuildNUWNeg(LLVMBuilderRef B, LLVMValueRef V,
2886 const char *Name);
Dan Gohmanf919bd62009-09-28 21:51:41 +00002887LLVMValueRef LLVMBuildFNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002888LLVMValueRef LLVMBuildNot(LLVMBuilderRef, LLVMValueRef V, const char *Name);
2889
2890/* Memory */
2891LLVMValueRef LLVMBuildMalloc(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
2892LLVMValueRef LLVMBuildArrayMalloc(LLVMBuilderRef, LLVMTypeRef Ty,
2893 LLVMValueRef Val, const char *Name);
2894LLVMValueRef LLVMBuildAlloca(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
2895LLVMValueRef LLVMBuildArrayAlloca(LLVMBuilderRef, LLVMTypeRef Ty,
2896 LLVMValueRef Val, const char *Name);
2897LLVMValueRef LLVMBuildFree(LLVMBuilderRef, LLVMValueRef PointerVal);
2898LLVMValueRef LLVMBuildLoad(LLVMBuilderRef, LLVMValueRef PointerVal,
2899 const char *Name);
2900LLVMValueRef LLVMBuildStore(LLVMBuilderRef, LLVMValueRef Val, LLVMValueRef Ptr);
2901LLVMValueRef LLVMBuildGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
2902 LLVMValueRef *Indices, unsigned NumIndices,
2903 const char *Name);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002904LLVMValueRef LLVMBuildInBoundsGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
2905 LLVMValueRef *Indices, unsigned NumIndices,
2906 const char *Name);
2907LLVMValueRef LLVMBuildStructGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
2908 unsigned Idx, const char *Name);
2909LLVMValueRef LLVMBuildGlobalString(LLVMBuilderRef B, const char *Str,
2910 const char *Name);
2911LLVMValueRef LLVMBuildGlobalStringPtr(LLVMBuilderRef B, const char *Str,
2912 const char *Name);
Chris Lattner2cc6f9d2012-03-22 03:54:15 +00002913LLVMBool LLVMGetVolatile(LLVMValueRef MemoryAccessInst);
2914void LLVMSetVolatile(LLVMValueRef MemoryAccessInst, LLVMBool IsVolatile);
Andrew Wilkinsb7362ce2015-08-02 12:16:57 +00002915LLVMAtomicOrdering LLVMGetOrdering(LLVMValueRef MemoryAccessInst);
2916void LLVMSetOrdering(LLVMValueRef MemoryAccessInst, LLVMAtomicOrdering Ordering);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002917
2918/* Casts */
2919LLVMValueRef LLVMBuildTrunc(LLVMBuilderRef, LLVMValueRef Val,
2920 LLVMTypeRef DestTy, const char *Name);
2921LLVMValueRef LLVMBuildZExt(LLVMBuilderRef, LLVMValueRef Val,
2922 LLVMTypeRef DestTy, const char *Name);
2923LLVMValueRef LLVMBuildSExt(LLVMBuilderRef, LLVMValueRef Val,
2924 LLVMTypeRef DestTy, const char *Name);
2925LLVMValueRef LLVMBuildFPToUI(LLVMBuilderRef, LLVMValueRef Val,
2926 LLVMTypeRef DestTy, const char *Name);
2927LLVMValueRef LLVMBuildFPToSI(LLVMBuilderRef, LLVMValueRef Val,
2928 LLVMTypeRef DestTy, const char *Name);
2929LLVMValueRef LLVMBuildUIToFP(LLVMBuilderRef, LLVMValueRef Val,
2930 LLVMTypeRef DestTy, const char *Name);
2931LLVMValueRef LLVMBuildSIToFP(LLVMBuilderRef, LLVMValueRef Val,
2932 LLVMTypeRef DestTy, const char *Name);
2933LLVMValueRef LLVMBuildFPTrunc(LLVMBuilderRef, LLVMValueRef Val,
2934 LLVMTypeRef DestTy, const char *Name);
2935LLVMValueRef LLVMBuildFPExt(LLVMBuilderRef, LLVMValueRef Val,
2936 LLVMTypeRef DestTy, const char *Name);
2937LLVMValueRef LLVMBuildPtrToInt(LLVMBuilderRef, LLVMValueRef Val,
2938 LLVMTypeRef DestTy, const char *Name);
2939LLVMValueRef LLVMBuildIntToPtr(LLVMBuilderRef, LLVMValueRef Val,
2940 LLVMTypeRef DestTy, const char *Name);
2941LLVMValueRef LLVMBuildBitCast(LLVMBuilderRef, LLVMValueRef Val,
2942 LLVMTypeRef DestTy, const char *Name);
Matt Arsenaultb03bd4d2013-11-15 01:34:59 +00002943LLVMValueRef LLVMBuildAddrSpaceCast(LLVMBuilderRef, LLVMValueRef Val,
2944 LLVMTypeRef DestTy, const char *Name);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002945LLVMValueRef LLVMBuildZExtOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
2946 LLVMTypeRef DestTy, const char *Name);
2947LLVMValueRef LLVMBuildSExtOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
2948 LLVMTypeRef DestTy, const char *Name);
2949LLVMValueRef LLVMBuildTruncOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
2950 LLVMTypeRef DestTy, const char *Name);
Erick Tryzelaar31831792010-02-28 05:51:27 +00002951LLVMValueRef LLVMBuildCast(LLVMBuilderRef B, LLVMOpcode Op, LLVMValueRef Val,
2952 LLVMTypeRef DestTy, const char *Name);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002953LLVMValueRef LLVMBuildPointerCast(LLVMBuilderRef, LLVMValueRef Val,
2954 LLVMTypeRef DestTy, const char *Name);
Duncan Sands9d786d72009-11-23 10:49:03 +00002955LLVMValueRef LLVMBuildIntCast(LLVMBuilderRef, LLVMValueRef Val, /*Signed cast!*/
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002956 LLVMTypeRef DestTy, const char *Name);
2957LLVMValueRef LLVMBuildFPCast(LLVMBuilderRef, LLVMValueRef Val,
2958 LLVMTypeRef DestTy, const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002959
2960/* Comparisons */
2961LLVMValueRef LLVMBuildICmp(LLVMBuilderRef, LLVMIntPredicate Op,
2962 LLVMValueRef LHS, LLVMValueRef RHS,
2963 const char *Name);
2964LLVMValueRef LLVMBuildFCmp(LLVMBuilderRef, LLVMRealPredicate Op,
2965 LLVMValueRef LHS, LLVMValueRef RHS,
2966 const char *Name);
2967
2968/* Miscellaneous instructions */
2969LLVMValueRef LLVMBuildPhi(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
2970LLVMValueRef LLVMBuildCall(LLVMBuilderRef, LLVMValueRef Fn,
2971 LLVMValueRef *Args, unsigned NumArgs,
2972 const char *Name);
2973LLVMValueRef LLVMBuildSelect(LLVMBuilderRef, LLVMValueRef If,
2974 LLVMValueRef Then, LLVMValueRef Else,
2975 const char *Name);
2976LLVMValueRef LLVMBuildVAArg(LLVMBuilderRef, LLVMValueRef List, LLVMTypeRef Ty,
2977 const char *Name);
2978LLVMValueRef LLVMBuildExtractElement(LLVMBuilderRef, LLVMValueRef VecVal,
2979 LLVMValueRef Index, const char *Name);
2980LLVMValueRef LLVMBuildInsertElement(LLVMBuilderRef, LLVMValueRef VecVal,
2981 LLVMValueRef EltVal, LLVMValueRef Index,
2982 const char *Name);
2983LLVMValueRef LLVMBuildShuffleVector(LLVMBuilderRef, LLVMValueRef V1,
2984 LLVMValueRef V2, LLVMValueRef Mask,
2985 const char *Name);
Dan Gohmand5104a52008-11-03 22:55:43 +00002986LLVMValueRef LLVMBuildExtractValue(LLVMBuilderRef, LLVMValueRef AggVal,
2987 unsigned Index, const char *Name);
2988LLVMValueRef LLVMBuildInsertValue(LLVMBuilderRef, LLVMValueRef AggVal,
2989 LLVMValueRef EltVal, unsigned Index,
2990 const char *Name);
Gordon Henriksen76a03742007-09-18 03:18:57 +00002991
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002992LLVMValueRef LLVMBuildIsNull(LLVMBuilderRef, LLVMValueRef Val,
2993 const char *Name);
2994LLVMValueRef LLVMBuildIsNotNull(LLVMBuilderRef, LLVMValueRef Val,
2995 const char *Name);
2996LLVMValueRef LLVMBuildPtrDiff(LLVMBuilderRef, LLVMValueRef LHS,
2997 LLVMValueRef RHS, const char *Name);
Filip Pizlo0d3f7ec2013-11-20 00:07:49 +00002998LLVMValueRef LLVMBuildFence(LLVMBuilderRef B, LLVMAtomicOrdering ordering,
2999 LLVMBool singleThread, const char *Name);
3000LLVMValueRef LLVMBuildAtomicRMW(LLVMBuilderRef B, LLVMAtomicRMWBinOp op,
NAKAMURA Takumia3a81352013-10-23 17:56:29 +00003001 LLVMValueRef PTR, LLVMValueRef Val,
3002 LLVMAtomicOrdering ordering,
Carlo Kok8c6719b2013-04-23 13:21:19 +00003003 LLVMBool singleThread);
Mehdi Amini43165d92016-03-19 21:28:28 +00003004LLVMValueRef LLVMBuildAtomicCmpXchg(LLVMBuilderRef B, LLVMValueRef Ptr,
3005 LLVMValueRef Cmp, LLVMValueRef New,
3006 LLVMAtomicOrdering SuccessOrdering,
3007 LLVMAtomicOrdering FailureOrdering,
3008 LLVMBool SingleThread);
3009
3010LLVMBool LLVMIsAtomicSingleThread(LLVMValueRef AtomicInst);
3011void LLVMSetAtomicSingleThread(LLVMValueRef AtomicInst, LLVMBool SingleThread);
3012
3013LLVMAtomicOrdering LLVMGetCmpXchgSuccessOrdering(LLVMValueRef CmpXchgInst);
3014void LLVMSetCmpXchgSuccessOrdering(LLVMValueRef CmpXchgInst,
3015 LLVMAtomicOrdering Ordering);
3016LLVMAtomicOrdering LLVMGetCmpXchgFailureOrdering(LLVMValueRef CmpXchgInst);
3017void LLVMSetCmpXchgFailureOrdering(LLVMValueRef CmpXchgInst,
3018 LLVMAtomicOrdering Ordering);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00003019
Gregory Szorc34c863a2012-03-21 03:54:29 +00003020/**
3021 * @}
3022 */
Gordon Henriksen34eb6d82007-12-19 22:30:40 +00003023
Gregory Szorc34c863a2012-03-21 03:54:29 +00003024/**
3025 * @defgroup LLVMCCoreModuleProvider Module Providers
3026 *
3027 * @{
3028 */
Gordon Henriksen0a68fe22007-12-12 01:04:30 +00003029
Gregory Szorc34c863a2012-03-21 03:54:29 +00003030/**
3031 * Changes the type of M so it can be passed to FunctionPassManagers and the
Jeffrey Yasskin091217b2010-01-27 20:34:15 +00003032 * JIT. They take ModuleProviders for historical reasons.
Gordon Henriksen0a68fe22007-12-12 01:04:30 +00003033 */
3034LLVMModuleProviderRef
3035LLVMCreateModuleProviderForExistingModule(LLVMModuleRef M);
3036
Gregory Szorc34c863a2012-03-21 03:54:29 +00003037/**
3038 * Destroys the module M.
Gordon Henriksen0a68fe22007-12-12 01:04:30 +00003039 */
Jeffrey Yasskin091217b2010-01-27 20:34:15 +00003040void LLVMDisposeModuleProvider(LLVMModuleProviderRef M);
Gordon Henriksen0a68fe22007-12-12 01:04:30 +00003041
Gregory Szorc34c863a2012-03-21 03:54:29 +00003042/**
3043 * @}
3044 */
Gordon Henriksen34eb6d82007-12-19 22:30:40 +00003045
Gregory Szorc34c863a2012-03-21 03:54:29 +00003046/**
3047 * @defgroup LLVMCCoreMemoryBuffers Memory Buffers
3048 *
3049 * @{
3050 */
Gordon Henriksen34eb6d82007-12-19 22:30:40 +00003051
Chris Lattner25963c62010-01-09 22:27:07 +00003052LLVMBool LLVMCreateMemoryBufferWithContentsOfFile(const char *Path,
3053 LLVMMemoryBufferRef *OutMemBuf,
3054 char **OutMessage);
3055LLVMBool LLVMCreateMemoryBufferWithSTDIN(LLVMMemoryBufferRef *OutMemBuf,
3056 char **OutMessage);
Bill Wendling526276a2013-02-14 19:11:28 +00003057LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRange(const char *InputData,
3058 size_t InputDataLength,
3059 const char *BufferName,
Bill Wendlingc9baa962013-02-14 19:39:14 +00003060 LLVMBool RequiresNullTerminator);
Bill Wendling526276a2013-02-14 19:11:28 +00003061LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRangeCopy(const char *InputData,
3062 size_t InputDataLength,
3063 const char *BufferName);
Tom Stellard62c03202013-04-18 19:50:53 +00003064const char *LLVMGetBufferStart(LLVMMemoryBufferRef MemBuf);
Tom Stellardb7fb7242013-04-16 23:12:51 +00003065size_t LLVMGetBufferSize(LLVMMemoryBufferRef MemBuf);
Gordon Henriksen34eb6d82007-12-19 22:30:40 +00003066void LLVMDisposeMemoryBuffer(LLVMMemoryBufferRef MemBuf);
3067
Gregory Szorc34c863a2012-03-21 03:54:29 +00003068/**
3069 * @}
3070 */
3071
3072/**
3073 * @defgroup LLVMCCorePassRegistry Pass Registry
3074 *
3075 * @{
3076 */
Owen Anderson4698c5d2010-10-07 17:55:47 +00003077
3078/** Return the global pass registry, for use with initialization functions.
Gregory Szorc34c863a2012-03-21 03:54:29 +00003079 @see llvm::PassRegistry::getPassRegistry */
Owen Anderson4698c5d2010-10-07 17:55:47 +00003080LLVMPassRegistryRef LLVMGetGlobalPassRegistry(void);
Gordon Henriksen878114b2008-03-16 04:20:44 +00003081
Gregory Szorc34c863a2012-03-21 03:54:29 +00003082/**
3083 * @}
3084 */
3085
3086/**
3087 * @defgroup LLVMCCorePassManagers Pass Managers
3088 *
3089 * @{
3090 */
Gordon Henriksen878114b2008-03-16 04:20:44 +00003091
3092/** Constructs a new whole-module pass pipeline. This type of pipeline is
3093 suitable for link-time optimization and whole-module transformations.
Gregory Szorc34c863a2012-03-21 03:54:29 +00003094 @see llvm::PassManager::PassManager */
Gordon Henriksena735a9c2008-05-04 12:55:34 +00003095LLVMPassManagerRef LLVMCreatePassManager(void);
Gordon Henriksen878114b2008-03-16 04:20:44 +00003096
3097/** Constructs a new function-by-function pass pipeline over the module
3098 provider. It does not take ownership of the module provider. This type of
3099 pipeline is suitable for code generation and JIT compilation tasks.
Gregory Szorc34c863a2012-03-21 03:54:29 +00003100 @see llvm::FunctionPassManager::FunctionPassManager */
Erick Tryzelaarad0e0cb2010-03-02 23:58:54 +00003101LLVMPassManagerRef LLVMCreateFunctionPassManagerForModule(LLVMModuleRef M);
3102
3103/** Deprecated: Use LLVMCreateFunctionPassManagerForModule instead. */
Gordon Henriksen878114b2008-03-16 04:20:44 +00003104LLVMPassManagerRef LLVMCreateFunctionPassManager(LLVMModuleProviderRef MP);
3105
3106/** Initializes, executes on the provided module, and finalizes all of the
3107 passes scheduled in the pass manager. Returns 1 if any of the passes
Gregory Szorc34c863a2012-03-21 03:54:29 +00003108 modified the module, 0 otherwise.
3109 @see llvm::PassManager::run(Module&) */
Chris Lattner25963c62010-01-09 22:27:07 +00003110LLVMBool LLVMRunPassManager(LLVMPassManagerRef PM, LLVMModuleRef M);
Gordon Henriksen878114b2008-03-16 04:20:44 +00003111
3112/** Initializes all of the function passes scheduled in the function pass
3113 manager. Returns 1 if any of the passes modified the module, 0 otherwise.
Gregory Szorc34c863a2012-03-21 03:54:29 +00003114 @see llvm::FunctionPassManager::doInitialization */
Chris Lattner25963c62010-01-09 22:27:07 +00003115LLVMBool LLVMInitializeFunctionPassManager(LLVMPassManagerRef FPM);
Gordon Henriksen878114b2008-03-16 04:20:44 +00003116
3117/** Executes all of the function passes scheduled in the function pass manager
3118 on the provided function. Returns 1 if any of the passes modified the
3119 function, false otherwise.
Gregory Szorc34c863a2012-03-21 03:54:29 +00003120 @see llvm::FunctionPassManager::run(Function&) */
Chris Lattner25963c62010-01-09 22:27:07 +00003121LLVMBool LLVMRunFunctionPassManager(LLVMPassManagerRef FPM, LLVMValueRef F);
Gordon Henriksen878114b2008-03-16 04:20:44 +00003122
3123/** Finalizes all of the function passes scheduled in in the function pass
3124 manager. Returns 1 if any of the passes modified the module, 0 otherwise.
Gregory Szorc34c863a2012-03-21 03:54:29 +00003125 @see llvm::FunctionPassManager::doFinalization */
Chris Lattner25963c62010-01-09 22:27:07 +00003126LLVMBool LLVMFinalizeFunctionPassManager(LLVMPassManagerRef FPM);
Gordon Henriksen878114b2008-03-16 04:20:44 +00003127
3128/** Frees the memory of a pass pipeline. For function pipelines, does not free
3129 the module provider.
Gregory Szorc34c863a2012-03-21 03:54:29 +00003130 @see llvm::PassManagerBase::~PassManagerBase. */
Gordon Henriksen878114b2008-03-16 04:20:44 +00003131void LLVMDisposePassManager(LLVMPassManagerRef PM);
3132
Gregory Szorc34c863a2012-03-21 03:54:29 +00003133/**
3134 * @}
3135 */
3136
3137/**
Duncan Sands1cba0a82013-02-17 16:35:51 +00003138 * @defgroup LLVMCCoreThreading Threading
3139 *
3140 * Handle the structures needed to make LLVM safe for multithreading.
3141 *
3142 * @{
3143 */
3144
Chandler Carruth39cd2162014-06-27 15:13:01 +00003145/** Deprecated: Multi-threading can only be enabled/disabled with the compile
3146 time define LLVM_ENABLE_THREADS. This function always returns
3147 LLVMIsMultithreaded(). */
Benjamin Kramer325ec892013-10-23 16:57:34 +00003148LLVMBool LLVMStartMultithreaded(void);
Duncan Sands1cba0a82013-02-17 16:35:51 +00003149
Chandler Carruth39cd2162014-06-27 15:13:01 +00003150/** Deprecated: Multi-threading can only be enabled/disabled with the compile
3151 time define LLVM_ENABLE_THREADS. */
Benjamin Kramer325ec892013-10-23 16:57:34 +00003152void LLVMStopMultithreaded(void);
Duncan Sands1cba0a82013-02-17 16:35:51 +00003153
3154/** Check whether LLVM is executing in thread-safe mode or not.
3155 @see llvm::llvm_is_multithreaded */
Benjamin Kramer325ec892013-10-23 16:57:34 +00003156LLVMBool LLVMIsMultithreaded(void);
Duncan Sands1cba0a82013-02-17 16:35:51 +00003157
3158/**
3159 * @}
3160 */
3161
3162/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00003163 * @}
3164 */
3165
3166/**
3167 * @}
3168 */
Gordon Henriksen878114b2008-03-16 04:20:44 +00003169
Gordon Henriksen76a03742007-09-18 03:18:57 +00003170#ifdef __cplusplus
3171}
Eugene Zelenkoffec81c2015-11-04 22:32:32 +00003172#endif
Gordon Henriksen7330acd2007-10-05 23:59:36 +00003173
Eugene Zelenkoffec81c2015-11-04 22:32:32 +00003174#endif /* LLVM_C_CORE_H */