blob: e84726b2d0cedfc23303eb24a26d7eef2d529647 [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,
259 LLVMGlobalVariableValueKind,
260 LLVMBlockAddressValueKind,
261 LLVMConstantExprValueKind,
262 LLVMConstantArrayValueKind,
263 LLVMConstantStructValueKind,
264 LLVMConstantVectorValueKind,
265
266 LLVMUndefValueValueKind,
267 LLVMConstantAggregateZeroValueKind,
268 LLVMConstantDataArrayValueKind,
269 LLVMConstantDataVectorValueKind,
270 LLVMConstantIntValueKind,
271 LLVMConstantFPValueKind,
272 LLVMConstantPointerNullValueKind,
273 LLVMConstantTokenNoneValueKind,
274
275 LLVMMetadataAsValueValueKind,
276 LLVMInlineAsmValueKind,
277
278 LLVMInstructionValueKind,
279} LLVMValueKind;
280
281typedef enum {
Gordon Henriksen4a4d7352007-12-30 17:46:33 +0000282 LLVMIntEQ = 32, /**< equal */
283 LLVMIntNE, /**< not equal */
284 LLVMIntUGT, /**< unsigned greater than */
285 LLVMIntUGE, /**< unsigned greater or equal */
286 LLVMIntULT, /**< unsigned less than */
287 LLVMIntULE, /**< unsigned less or equal */
288 LLVMIntSGT, /**< signed greater than */
289 LLVMIntSGE, /**< signed greater or equal */
290 LLVMIntSLT, /**< signed less than */
291 LLVMIntSLE /**< signed less or equal */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +0000292} LLVMIntPredicate;
293
294typedef enum {
Gordon Henriksen4a4d7352007-12-30 17:46:33 +0000295 LLVMRealPredicateFalse, /**< Always false (always folded) */
296 LLVMRealOEQ, /**< True if ordered and equal */
297 LLVMRealOGT, /**< True if ordered and greater than */
298 LLVMRealOGE, /**< True if ordered and greater than or equal */
299 LLVMRealOLT, /**< True if ordered and less than */
300 LLVMRealOLE, /**< True if ordered and less than or equal */
301 LLVMRealONE, /**< True if ordered and operands are unequal */
302 LLVMRealORD, /**< True if ordered (no nans) */
303 LLVMRealUNO, /**< True if unordered: isnan(X) | isnan(Y) */
304 LLVMRealUEQ, /**< True if unordered or equal */
305 LLVMRealUGT, /**< True if unordered or greater than */
306 LLVMRealUGE, /**< True if unordered, greater than, or equal */
307 LLVMRealULT, /**< True if unordered or less than */
308 LLVMRealULE, /**< True if unordered, less than, or equal */
309 LLVMRealUNE, /**< True if unordered or not equal */
310 LLVMRealPredicateTrue /**< Always true (always folded) */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +0000311} LLVMRealPredicate;
312
Bill Wendlingfae14752011-08-12 20:24:12 +0000313typedef enum {
314 LLVMLandingPadCatch, /**< A catch clause */
315 LLVMLandingPadFilter /**< A filter clause */
316} LLVMLandingPadClauseTy;
317
Hans Wennborg5ff71202013-04-16 08:58:59 +0000318typedef enum {
319 LLVMNotThreadLocal = 0,
320 LLVMGeneralDynamicTLSModel,
321 LLVMLocalDynamicTLSModel,
322 LLVMInitialExecTLSModel,
323 LLVMLocalExecTLSModel
324} LLVMThreadLocalMode;
325
Carlo Kokda0ac722013-04-23 13:45:37 +0000326typedef enum {
Carlo Kok8c6719b2013-04-23 13:21:19 +0000327 LLVMAtomicOrderingNotAtomic = 0, /**< A load or store which is not atomic */
328 LLVMAtomicOrderingUnordered = 1, /**< Lowest level of atomicity, guarantees
329 somewhat sane results, lock free. */
NAKAMURA Takumia3a81352013-10-23 17:56:29 +0000330 LLVMAtomicOrderingMonotonic = 2, /**< guarantees that if you take all the
331 operations affecting a specific address,
Carlo Kok8c6719b2013-04-23 13:21:19 +0000332 a consistent ordering exists */
NAKAMURA Takumia3a81352013-10-23 17:56:29 +0000333 LLVMAtomicOrderingAcquire = 4, /**< Acquire provides a barrier of the sort
334 necessary to acquire a lock to access other
Carlo Kok8c6719b2013-04-23 13:21:19 +0000335 memory with normal loads and stores. */
NAKAMURA Takumia3a81352013-10-23 17:56:29 +0000336 LLVMAtomicOrderingRelease = 5, /**< Release is similar to Acquire, but with
337 a barrier of the sort necessary to release
Carlo Kok8c6719b2013-04-23 13:21:19 +0000338 a lock. */
NAKAMURA Takumia3a81352013-10-23 17:56:29 +0000339 LLVMAtomicOrderingAcquireRelease = 6, /**< provides both an Acquire and a
340 Release barrier (for fences and
Carlo Kok8c6719b2013-04-23 13:21:19 +0000341 operations which both read and write
342 memory). */
NAKAMURA Takumia3a81352013-10-23 17:56:29 +0000343 LLVMAtomicOrderingSequentiallyConsistent = 7 /**< provides Acquire semantics
344 for loads and Release
345 semantics for stores.
346 Additionally, it guarantees
347 that a total ordering exists
348 between all
349 SequentiallyConsistent
Carlo Kok8c6719b2013-04-23 13:21:19 +0000350 operations. */
Carlo Kokda0ac722013-04-23 13:45:37 +0000351} LLVMAtomicOrdering;
Carlo Kok8c6719b2013-04-23 13:21:19 +0000352
Carlo Kokda0ac722013-04-23 13:45:37 +0000353typedef enum {
Carlo Kok8c6719b2013-04-23 13:21:19 +0000354 LLVMAtomicRMWBinOpXchg, /**< Set the new value and return the one old */
355 LLVMAtomicRMWBinOpAdd, /**< Add a value and return the old one */
356 LLVMAtomicRMWBinOpSub, /**< Subtract a value and return the old one */
357 LLVMAtomicRMWBinOpAnd, /**< And a value and return the old one */
358 LLVMAtomicRMWBinOpNand, /**< Not-And a value and return the old one */
359 LLVMAtomicRMWBinOpOr, /**< OR a value and return the old one */
360 LLVMAtomicRMWBinOpXor, /**< Xor a value and return the old one */
361 LLVMAtomicRMWBinOpMax, /**< Sets the value if it's greater than the
NAKAMURA Takumia3a81352013-10-23 17:56:29 +0000362 original using a signed comparison and return
Carlo Kok8c6719b2013-04-23 13:21:19 +0000363 the old one */
364 LLVMAtomicRMWBinOpMin, /**< Sets the value if it's Smaller than the
NAKAMURA Takumia3a81352013-10-23 17:56:29 +0000365 original using a signed comparison and return
Carlo Kok8c6719b2013-04-23 13:21:19 +0000366 the old one */
367 LLVMAtomicRMWBinOpUMax, /**< Sets the value if it's greater than the
NAKAMURA Takumia3a81352013-10-23 17:56:29 +0000368 original using an unsigned comparison and return
Carlo Kok8c6719b2013-04-23 13:21:19 +0000369 the old one */
370 LLVMAtomicRMWBinOpUMin /**< Sets the value if it's greater than the
NAKAMURA Takumia3a81352013-10-23 17:56:29 +0000371 original using an unsigned comparison and return
Carlo Kok8c6719b2013-04-23 13:21:19 +0000372 the old one */
Carlo Kokda0ac722013-04-23 13:45:37 +0000373} LLVMAtomicRMWBinOp;
Carlo Kok8c6719b2013-04-23 13:21:19 +0000374
Tom Stellard1580dc72014-04-16 17:45:04 +0000375typedef enum {
376 LLVMDSError,
377 LLVMDSWarning,
378 LLVMDSRemark,
379 LLVMDSNote
380} LLVMDiagnosticSeverity;
381
Gregory Szorc34c863a2012-03-21 03:54:29 +0000382/**
383 * @}
384 */
385
Nick Lewycky0db26542011-05-15 07:20:34 +0000386void LLVMInitializeCore(LLVMPassRegistryRef R);
387
Duncan Sands1cba0a82013-02-17 16:35:51 +0000388/** Deallocate and destroy all ManagedStatic variables.
389 @see llvm::llvm_shutdown
390 @see ManagedStatic */
Benjamin Kramer325ec892013-10-23 16:57:34 +0000391void LLVMShutdown(void);
Duncan Sands1cba0a82013-02-17 16:35:51 +0000392
Gordon Henriksen34eb6d82007-12-19 22:30:40 +0000393/*===-- Error handling ----------------------------------------------------===*/
394
Filip Pizlo3fdbaff2013-05-22 02:46:43 +0000395char *LLVMCreateMessage(const char *Message);
Gordon Henriksen34eb6d82007-12-19 22:30:40 +0000396void LLVMDisposeMessage(char *Message);
397
Filip Pizlo9f50ccd2013-11-03 00:29:47 +0000398/**
Gregory Szorc34c863a2012-03-21 03:54:29 +0000399 * @defgroup LLVMCCoreContext Contexts
400 *
401 * Contexts are execution states for the core LLVM IR system.
402 *
403 * Most types are tied to a context instance. Multiple contexts can
404 * exist simultaneously. A single context is not thread safe. However,
405 * different contexts can execute on different threads simultaneously.
406 *
407 * @{
408 */
Gordon Henriksen76a03742007-09-18 03:18:57 +0000409
Tom Stellard1580dc72014-04-16 17:45:04 +0000410typedef void (*LLVMDiagnosticHandler)(LLVMDiagnosticInfoRef, void *);
Juergen Ributzka34390c72014-05-16 02:33:15 +0000411typedef void (*LLVMYieldCallback)(LLVMContextRef, void *);
Tom Stellard1580dc72014-04-16 17:45:04 +0000412
Gregory Szorc34c863a2012-03-21 03:54:29 +0000413/**
414 * Create a new context.
415 *
416 * Every call to this function should be paired with a call to
417 * LLVMContextDispose() or the context will leak memory.
418 */
Erick Tryzelaarf34cb0c2009-08-30 23:38:06 +0000419LLVMContextRef LLVMContextCreate(void);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000420
421/**
422 * Obtain the global context instance.
423 */
Erick Tryzelaarf34cb0c2009-08-30 23:38:06 +0000424LLVMContextRef LLVMGetGlobalContext(void);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000425
426/**
Tom Stellard1580dc72014-04-16 17:45:04 +0000427 * Set the diagnostic handler for this context.
428 */
429void LLVMContextSetDiagnosticHandler(LLVMContextRef C,
430 LLVMDiagnosticHandler Handler,
431 void *DiagnosticContext);
432
433/**
Juergen Ributzka34390c72014-05-16 02:33:15 +0000434 * Set the yield callback function for this context.
435 *
436 * @see LLVMContext::setYieldCallback()
437 */
438void LLVMContextSetYieldCallback(LLVMContextRef C, LLVMYieldCallback Callback,
439 void *OpaqueHandle);
440
441/**
Gregory Szorc34c863a2012-03-21 03:54:29 +0000442 * Destroy a context instance.
443 *
444 * This should be called for every call to LLVMContextCreate() or memory
445 * will be leaked.
446 */
Owen Anderson6773d382009-07-01 16:58:40 +0000447void LLVMContextDispose(LLVMContextRef C);
448
Tom Stellard1580dc72014-04-16 17:45:04 +0000449/**
450 * Return a string representation of the DiagnosticInfo. Use
451 * LLVMDisposeMessage to free the string.
452 *
453 * @see DiagnosticInfo::print()
454 */
455char *LLVMGetDiagInfoDescription(LLVMDiagnosticInfoRef DI);
456
457/**
458 * Return an enum LLVMDiagnosticSeverity.
459 *
460 * @see DiagnosticInfo::getSeverity()
461 */
462LLVMDiagnosticSeverity LLVMGetDiagInfoSeverity(LLVMDiagnosticInfoRef DI);
463
Amaury Sechet56f056c2016-04-04 22:00:25 +0000464unsigned LLVMGetMDKindIDInContext(LLVMContextRef C, const char *Name,
Erick Tryzelaard8531fa2010-02-28 09:45:59 +0000465 unsigned SLen);
Amaury Sechet56f056c2016-04-04 22:00:25 +0000466unsigned LLVMGetMDKindID(const char *Name, unsigned SLen);
Erick Tryzelaard8531fa2010-02-28 09:45:59 +0000467
Gregory Szorc34c863a2012-03-21 03:54:29 +0000468/**
469 * @}
470 */
471
Gregory Szorc52d26602012-03-21 07:28:27 +0000472/**
473 * @defgroup LLVMCCoreModule Modules
Gregory Szorc34c863a2012-03-21 03:54:29 +0000474 *
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +0000475 * Modules represent the top-level structure in an LLVM program. An LLVM
Gregory Szorc34c863a2012-03-21 03:54:29 +0000476 * module is effectively a translation unit or a collection of
477 * translation units merged together.
478 *
479 * @{
480 */
481
Gregory Szorc34c863a2012-03-21 03:54:29 +0000482/**
483 * Create a new, empty module in the global context.
484 *
485 * This is equivalent to calling LLVMModuleCreateWithNameInContext with
486 * LLVMGetGlobalContext() as the context parameter.
487 *
488 * Every invocation should be paired with LLVMDisposeModule() or memory
489 * will be leaked.
490 */
Gordon Henriksen76a03742007-09-18 03:18:57 +0000491LLVMModuleRef LLVMModuleCreateWithName(const char *ModuleID);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000492
493/**
494 * Create a new, empty module in a specific context.
495 *
496 * Every invocation should be paired with LLVMDisposeModule() or memory
497 * will be leaked.
498 */
Owen Anderson31d44e42009-07-02 07:17:57 +0000499LLVMModuleRef LLVMModuleCreateWithNameInContext(const char *ModuleID,
500 LLVMContextRef C);
Tom Stellard0a4e9a32014-10-01 17:14:57 +0000501/**
502 * Return an exact copy of the specified module.
503 */
504LLVMModuleRef LLVMCloneModule(LLVMModuleRef M);
Gordon Henriksena49d4352008-03-07 19:13:06 +0000505
Gregory Szorc34c863a2012-03-21 03:54:29 +0000506/**
507 * Destroy a module instance.
508 *
509 * This must be called for every created module or memory will be
510 * leaked.
511 */
Gordon Henriksen76a03742007-09-18 03:18:57 +0000512void LLVMDisposeModule(LLVMModuleRef M);
513
Gregory Szorc34c863a2012-03-21 03:54:29 +0000514/**
Peter Zotov0a2fa0a2016-04-05 13:56:59 +0000515 * Obtain the identifier of a module.
516 *
517 * @param M Module to obtain identifier of
518 * @param Len Out parameter which holds the length of the returned string.
519 * @return The identifier of M.
520 * @see Module::getModuleIdentifier()
521 */
522const char *LLVMGetModuleIdentifier(LLVMModuleRef M, size_t *Len);
523
524/**
525 * Set the identifier of a module to a string Ident with length Len.
526 *
527 * @param M The module to set identifier
528 * @param Ident The string to set M's identifier to
529 * @param Len Length of Ident
530 * @see Module::setModuleIdentifier()
531 */
532void LLVMSetModuleIdentifier(LLVMModuleRef M, const char *Ident, size_t Len);
533
534/**
Gregory Szorc34c863a2012-03-21 03:54:29 +0000535 * Obtain the data layout for a module.
536 *
Amaury Sechetf3549c42016-02-16 00:23:52 +0000537 * @see Module::getDataLayoutStr()
538 *
539 * LLVMGetDataLayout is DEPRECATED, as the name is not only incorrect,
540 * but match the name of another method on the module. Prefer the use
541 * of LLVMGetDataLayoutStr, which is not ambiguous.
Gregory Szorc34c863a2012-03-21 03:54:29 +0000542 */
Amaury Sechetf3549c42016-02-16 00:23:52 +0000543const char *LLVMGetDataLayoutStr(LLVMModuleRef M);
Gordon Henriksen05568bb2007-12-27 20:13:47 +0000544const char *LLVMGetDataLayout(LLVMModuleRef M);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000545
546/**
547 * Set the data layout for a module.
548 *
549 * @see Module::setDataLayout()
550 */
Amaury Sechet6ada31c2016-02-15 23:40:06 +0000551void LLVMSetDataLayout(LLVMModuleRef M, const char *DataLayoutStr);
Gordon Henriksen05568bb2007-12-27 20:13:47 +0000552
Gregory Szorc34c863a2012-03-21 03:54:29 +0000553/**
554 * Obtain the target triple for a module.
555 *
556 * @see Module::getTargetTriple()
557 */
Gordon Henriksen05568bb2007-12-27 20:13:47 +0000558const char *LLVMGetTarget(LLVMModuleRef M);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000559
560/**
561 * Set the target triple for a module.
562 *
563 * @see Module::setTargetTriple()
564 */
Gordon Henriksen05568bb2007-12-27 20:13:47 +0000565void LLVMSetTarget(LLVMModuleRef M, const char *Triple);
566
Gregory Szorc34c863a2012-03-21 03:54:29 +0000567/**
568 * Dump a representation of a module to stderr.
569 *
570 * @see Module::dump()
571 */
Gordon Henriksen6c6075e2008-03-14 23:58:56 +0000572void LLVMDumpModule(LLVMModuleRef M);
573
Gregory Szorc34c863a2012-03-21 03:54:29 +0000574/**
Hans Wennborgb7ef2fe2012-05-09 16:54:17 +0000575 * Print a representation of a module to a file. The ErrorMessage needs to be
576 * disposed with LLVMDisposeMessage. Returns 0 on success, 1 otherwise.
577 *
578 * @see Module::print()
579 */
580LLVMBool LLVMPrintModuleToFile(LLVMModuleRef M, const char *Filename,
581 char **ErrorMessage);
582
583/**
Anders Waldenborg84355db2013-10-16 18:00:54 +0000584 * Return a string representation of the module. Use
585 * LLVMDisposeMessage to free the string.
586 *
587 * @see Module::print()
588 */
589char *LLVMPrintModuleToString(LLVMModuleRef M);
590
591/**
Gregory Szorc34c863a2012-03-21 03:54:29 +0000592 * Set inline assembly for a module.
593 *
594 * @see Module::setModuleInlineAsm()
595 */
Chris Lattner26941452010-04-10 17:52:58 +0000596void LLVMSetModuleInlineAsm(LLVMModuleRef M, const char *Asm);
Gordon Henriksen76a03742007-09-18 03:18:57 +0000597
Gregory Szorc34c863a2012-03-21 03:54:29 +0000598/**
599 * Obtain the context to which this module is associated.
600 *
601 * @see Module::getContext()
602 */
Chris Lattnera7e04b02010-11-28 20:03:44 +0000603LLVMContextRef LLVMGetModuleContext(LLVMModuleRef M);
604
Gregory Szorc34c863a2012-03-21 03:54:29 +0000605/**
606 * Obtain a Type from a module by its registered name.
607 */
608LLVMTypeRef LLVMGetTypeByName(LLVMModuleRef M, const char *Name);
Gordon Henriksen76a03742007-09-18 03:18:57 +0000609
Gregory Szorc34c863a2012-03-21 03:54:29 +0000610/**
611 * Obtain the number of operands for named metadata in a module.
612 *
613 * @see llvm::Module::getNamedMetadata()
614 */
615unsigned LLVMGetNamedMetadataNumOperands(LLVMModuleRef M, const char* name);
616
617/**
618 * Obtain the named metadata operands for a module.
619 *
620 * The passed LLVMValueRef pointer should refer to an array of
621 * LLVMValueRef at least LLVMGetNamedMetadataNumOperands long. This
622 * array will be populated with the LLVMValueRef instances. Each
623 * instance corresponds to a llvm::MDNode.
624 *
625 * @see llvm::Module::getNamedMetadata()
626 * @see llvm::MDNode::getOperand()
627 */
628void LLVMGetNamedMetadataOperands(LLVMModuleRef M, const char* name, LLVMValueRef *Dest);
629
630/**
631 * Add an operand to named metadata.
632 *
633 * @see llvm::Module::getNamedMetadata()
634 * @see llvm::MDNode::addOperand()
635 */
636void LLVMAddNamedMetadataOperand(LLVMModuleRef M, const char* name,
637 LLVMValueRef Val);
638
Gregory Szorc52d26602012-03-21 07:28:27 +0000639/**
640 * Add a function to a module under a specified name.
641 *
642 * @see llvm::Function::Create()
643 */
644LLVMValueRef LLVMAddFunction(LLVMModuleRef M, const char *Name,
645 LLVMTypeRef FunctionTy);
646
647/**
648 * Obtain a Function value from a Module by its name.
649 *
650 * The returned value corresponds to a llvm::Function value.
651 *
652 * @see llvm::Module::getFunction()
653 */
654LLVMValueRef LLVMGetNamedFunction(LLVMModuleRef M, const char *Name);
655
656/**
657 * Obtain an iterator to the first Function in a Module.
658 *
659 * @see llvm::Module::begin()
660 */
661LLVMValueRef LLVMGetFirstFunction(LLVMModuleRef M);
662
663/**
664 * Obtain an iterator to the last Function in a Module.
665 *
666 * @see llvm::Module::end()
667 */
668LLVMValueRef LLVMGetLastFunction(LLVMModuleRef M);
669
670/**
671 * Advance a Function iterator to the next Function.
672 *
673 * Returns NULL if the iterator was already at the end and there are no more
674 * functions.
675 */
676LLVMValueRef LLVMGetNextFunction(LLVMValueRef Fn);
677
678/**
679 * Decrement a Function iterator to the previous Function.
680 *
681 * Returns NULL if the iterator was already at the beginning and there are
682 * no previous functions.
683 */
684LLVMValueRef LLVMGetPreviousFunction(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000685
686/**
687 * @}
688 */
689
690/**
691 * @defgroup LLVMCCoreType Types
692 *
693 * Types represent the type of a value.
694 *
695 * Types are associated with a context instance. The context internally
696 * deduplicates types so there is only 1 instance of a specific type
697 * alive at a time. In other words, a unique type is shared among all
698 * consumers within a context.
699 *
700 * A Type in the C API corresponds to llvm::Type.
701 *
702 * Types have the following hierarchy:
703 *
Gordon Henriksen76a03742007-09-18 03:18:57 +0000704 * types:
705 * integer type
706 * real type
707 * function type
708 * sequence types:
709 * array type
710 * pointer type
711 * vector type
712 * void type
713 * label type
714 * opaque type
Gregory Szorc34c863a2012-03-21 03:54:29 +0000715 *
716 * @{
Gordon Henriksen76a03742007-09-18 03:18:57 +0000717 */
718
Gregory Szorc34c863a2012-03-21 03:54:29 +0000719/**
720 * Obtain the enumerated type of a Type instance.
721 *
722 * @see llvm::Type:getTypeID()
723 */
Gordon Henriksen76a03742007-09-18 03:18:57 +0000724LLVMTypeKind LLVMGetTypeKind(LLVMTypeRef Ty);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000725
726/**
727 * Whether the type has a known size.
728 *
729 * Things that don't have a size are abstract types, labels, and void.a
730 *
731 * @see llvm::Type::isSized()
732 */
Torok Edwin1cd9ade2011-10-06 12:13:28 +0000733LLVMBool LLVMTypeIsSized(LLVMTypeRef Ty);
Gordon Henriksena49d4352008-03-07 19:13:06 +0000734
Gregory Szorc34c863a2012-03-21 03:54:29 +0000735/**
736 * Obtain the context to which this type instance is associated.
737 *
738 * @see llvm::Type::getContext()
739 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +0000740LLVMContextRef LLVMGetTypeContext(LLVMTypeRef Ty);
741
Gregory Szorc34c863a2012-03-21 03:54:29 +0000742/**
Anders Waldenborgb822cff2013-10-16 21:30:25 +0000743 * Dump a representation of a type to stderr.
744 *
745 * @see llvm::Type::dump()
746 */
747void LLVMDumpType(LLVMTypeRef Val);
748
749/**
Anders Waldenborg47b3bd32013-10-22 06:58:34 +0000750 * Return a string representation of the type. Use
751 * LLVMDisposeMessage to free the string.
752 *
753 * @see llvm::Type::print()
754 */
755char *LLVMPrintTypeToString(LLVMTypeRef Val);
756
757/**
Gregory Szorc34c863a2012-03-21 03:54:29 +0000758 * @defgroup LLVMCCoreTypeInt Integer Types
759 *
760 * Functions in this section operate on integer types.
761 *
762 * @{
763 */
764
765/**
766 * Obtain an integer type from a context with specified bit width.
767 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +0000768LLVMTypeRef LLVMInt1TypeInContext(LLVMContextRef C);
769LLVMTypeRef LLVMInt8TypeInContext(LLVMContextRef C);
770LLVMTypeRef LLVMInt16TypeInContext(LLVMContextRef C);
771LLVMTypeRef LLVMInt32TypeInContext(LLVMContextRef C);
772LLVMTypeRef LLVMInt64TypeInContext(LLVMContextRef C);
Eugene Zelenkoffec81c2015-11-04 22:32:32 +0000773LLVMTypeRef LLVMInt128TypeInContext(LLVMContextRef C);
Erick Tryzelaar262332f2009-08-14 00:01:31 +0000774LLVMTypeRef LLVMIntTypeInContext(LLVMContextRef C, unsigned NumBits);
775
Gregory Szorc34c863a2012-03-21 03:54:29 +0000776/**
777 * Obtain an integer type from the global context with a specified bit
778 * width.
779 */
Gordon Henriksena735a9c2008-05-04 12:55:34 +0000780LLVMTypeRef LLVMInt1Type(void);
781LLVMTypeRef LLVMInt8Type(void);
782LLVMTypeRef LLVMInt16Type(void);
783LLVMTypeRef LLVMInt32Type(void);
784LLVMTypeRef LLVMInt64Type(void);
Eugene Zelenkoffec81c2015-11-04 22:32:32 +0000785LLVMTypeRef LLVMInt128Type(void);
Gordon Henriksened7beaa2007-10-06 16:05:20 +0000786LLVMTypeRef LLVMIntType(unsigned NumBits);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +0000787unsigned LLVMGetIntTypeWidth(LLVMTypeRef IntegerTy);
Gordon Henriksen76a03742007-09-18 03:18:57 +0000788
Gregory Szorc34c863a2012-03-21 03:54:29 +0000789/**
790 * @}
791 */
792
793/**
794 * @defgroup LLVMCCoreTypeFloat Floating Point Types
795 *
796 * @{
797 */
798
799/**
800 * Obtain a 16-bit floating point type from a context.
801 */
Dan Gohman518cda42011-12-17 00:04:22 +0000802LLVMTypeRef LLVMHalfTypeInContext(LLVMContextRef C);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000803
804/**
805 * Obtain a 32-bit floating point type from a context.
806 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +0000807LLVMTypeRef LLVMFloatTypeInContext(LLVMContextRef C);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000808
809/**
810 * Obtain a 64-bit floating point type from a context.
811 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +0000812LLVMTypeRef LLVMDoubleTypeInContext(LLVMContextRef C);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000813
814/**
815 * Obtain a 80-bit floating point type (X87) from a context.
816 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +0000817LLVMTypeRef LLVMX86FP80TypeInContext(LLVMContextRef C);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000818
819/**
820 * Obtain a 128-bit floating point type (112-bit mantissa) from a
821 * context.
822 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +0000823LLVMTypeRef LLVMFP128TypeInContext(LLVMContextRef C);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000824
825/**
826 * Obtain a 128-bit floating point type (two 64-bits) from a context.
827 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +0000828LLVMTypeRef LLVMPPCFP128TypeInContext(LLVMContextRef C);
829
Gregory Szorc34c863a2012-03-21 03:54:29 +0000830/**
831 * Obtain a floating point type from the global context.
832 *
833 * These map to the functions in this group of the same name.
834 */
Dan Gohman518cda42011-12-17 00:04:22 +0000835LLVMTypeRef LLVMHalfType(void);
Gordon Henriksena735a9c2008-05-04 12:55:34 +0000836LLVMTypeRef LLVMFloatType(void);
837LLVMTypeRef LLVMDoubleType(void);
838LLVMTypeRef LLVMX86FP80Type(void);
839LLVMTypeRef LLVMFP128Type(void);
840LLVMTypeRef LLVMPPCFP128Type(void);
Gordon Henriksen76a03742007-09-18 03:18:57 +0000841
Gregory Szorc34c863a2012-03-21 03:54:29 +0000842/**
843 * @}
844 */
845
846/**
847 * @defgroup LLVMCCoreTypeFunction Function Types
848 *
849 * @{
850 */
851
852/**
853 * Obtain a function type consisting of a specified signature.
854 *
855 * The function is defined as a tuple of a return Type, a list of
856 * parameter types, and whether the function is variadic.
857 */
Gordon Henriksened7beaa2007-10-06 16:05:20 +0000858LLVMTypeRef LLVMFunctionType(LLVMTypeRef ReturnType,
859 LLVMTypeRef *ParamTypes, unsigned ParamCount,
Chris Lattner25963c62010-01-09 22:27:07 +0000860 LLVMBool IsVarArg);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000861
862/**
863 * Returns whether a function type is variadic.
864 */
Chris Lattner25963c62010-01-09 22:27:07 +0000865LLVMBool LLVMIsFunctionVarArg(LLVMTypeRef FunctionTy);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000866
867/**
868 * Obtain the Type this function Type returns.
869 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +0000870LLVMTypeRef LLVMGetReturnType(LLVMTypeRef FunctionTy);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000871
872/**
873 * Obtain the number of parameters this function accepts.
874 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +0000875unsigned LLVMCountParamTypes(LLVMTypeRef FunctionTy);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000876
877/**
878 * Obtain the types of a function's parameters.
879 *
880 * The Dest parameter should point to a pre-allocated array of
881 * LLVMTypeRef at least LLVMCountParamTypes() large. On return, the
882 * first LLVMCountParamTypes() entries in the array will be populated
883 * with LLVMTypeRef instances.
884 *
885 * @param FunctionTy The function type to operate on.
886 * @param Dest Memory address of an array to be filled with result.
887 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +0000888void LLVMGetParamTypes(LLVMTypeRef FunctionTy, LLVMTypeRef *Dest);
Gordon Henriksen76a03742007-09-18 03:18:57 +0000889
Gregory Szorc34c863a2012-03-21 03:54:29 +0000890/**
891 * @}
892 */
893
894/**
895 * @defgroup LLVMCCoreTypeStruct Structure Types
896 *
897 * These functions relate to LLVMTypeRef instances.
898 *
899 * @see llvm::StructType
900 *
901 * @{
902 */
903
904/**
905 * Create a new structure type in a context.
906 *
907 * A structure is specified by a list of inner elements/types and
908 * whether these can be packed together.
909 *
910 * @see llvm::StructType::create()
911 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +0000912LLVMTypeRef LLVMStructTypeInContext(LLVMContextRef C, LLVMTypeRef *ElementTypes,
Chris Lattner25963c62010-01-09 22:27:07 +0000913 unsigned ElementCount, LLVMBool Packed);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000914
915/**
916 * Create a new structure type in the global context.
917 *
918 * @see llvm::StructType::create()
919 */
Gordon Henriksened7beaa2007-10-06 16:05:20 +0000920LLVMTypeRef LLVMStructType(LLVMTypeRef *ElementTypes, unsigned ElementCount,
Chris Lattner25963c62010-01-09 22:27:07 +0000921 LLVMBool Packed);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000922
923/**
924 * Create an empty structure in a context having a specified name.
925 *
926 * @see llvm::StructType::create()
927 */
Chris Lattnere71ccde2011-07-14 05:53:17 +0000928LLVMTypeRef LLVMStructCreateNamed(LLVMContextRef C, const char *Name);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000929
930/**
931 * Obtain the name of a structure.
932 *
933 * @see llvm::StructType::getName()
934 */
Torok Edwin0d5f6ae2011-10-06 12:12:50 +0000935const char *LLVMGetStructName(LLVMTypeRef Ty);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000936
937/**
938 * Set the contents of a structure type.
939 *
940 * @see llvm::StructType::setBody()
941 */
Chris Lattnere71ccde2011-07-14 05:53:17 +0000942void LLVMStructSetBody(LLVMTypeRef StructTy, LLVMTypeRef *ElementTypes,
943 unsigned ElementCount, LLVMBool Packed);
944
Gregory Szorc34c863a2012-03-21 03:54:29 +0000945/**
946 * Get the number of elements defined inside the structure.
947 *
948 * @see llvm::StructType::getNumElements()
949 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +0000950unsigned LLVMCountStructElementTypes(LLVMTypeRef StructTy);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000951
952/**
953 * Get the elements within a structure.
954 *
955 * The function is passed the address of a pre-allocated array of
956 * LLVMTypeRef at least LLVMCountStructElementTypes() long. After
957 * invocation, this array will be populated with the structure's
958 * elements. The objects in the destination array will have a lifetime
959 * of the structure type itself, which is the lifetime of the context it
960 * is contained in.
961 */
Gordon Henriksen76a03742007-09-18 03:18:57 +0000962void LLVMGetStructElementTypes(LLVMTypeRef StructTy, LLVMTypeRef *Dest);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000963
964/**
Peter Zotovc164a3f2015-06-04 09:09:53 +0000965 * Get the type of the element at a given index in the structure.
966 *
967 * @see llvm::StructType::getTypeAtIndex()
968 */
969LLVMTypeRef LLVMStructGetTypeAtIndex(LLVMTypeRef StructTy, unsigned i);
970
971/**
Gregory Szorc34c863a2012-03-21 03:54:29 +0000972 * Determine whether a structure is packed.
973 *
974 * @see llvm::StructType::isPacked()
975 */
Chris Lattner25963c62010-01-09 22:27:07 +0000976LLVMBool LLVMIsPackedStruct(LLVMTypeRef StructTy);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000977
978/**
979 * Determine whether a structure is opaque.
980 *
981 * @see llvm::StructType::isOpaque()
982 */
Chris Lattner17cf05b2011-07-14 16:20:28 +0000983LLVMBool LLVMIsOpaqueStruct(LLVMTypeRef StructTy);
984
Gregory Szorc34c863a2012-03-21 03:54:29 +0000985/**
986 * @}
987 */
Gordon Henriksen76a03742007-09-18 03:18:57 +0000988
Gregory Szorc34c863a2012-03-21 03:54:29 +0000989/**
990 * @defgroup LLVMCCoreTypeSequential Sequential Types
991 *
992 * Sequential types represents "arrays" of types. This is a super class
993 * for array, vector, and pointer types.
994 *
995 * @{
996 */
997
998/**
999 * Obtain the type of elements within a sequential type.
1000 *
1001 * This works on array, vector, and pointer types.
1002 *
1003 * @see llvm::SequentialType::getElementType()
1004 */
1005LLVMTypeRef LLVMGetElementType(LLVMTypeRef Ty);
1006
1007/**
1008 * Create a fixed size array type that refers to a specific type.
1009 *
1010 * The created type will exist in the context that its element type
1011 * exists in.
1012 *
1013 * @see llvm::ArrayType::get()
1014 */
Gordon Henriksened7beaa2007-10-06 16:05:20 +00001015LLVMTypeRef LLVMArrayType(LLVMTypeRef ElementType, unsigned ElementCount);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001016
1017/**
1018 * Obtain the length of an array type.
1019 *
1020 * This only works on types that represent arrays.
1021 *
1022 * @see llvm::ArrayType::getNumElements()
1023 */
1024unsigned LLVMGetArrayLength(LLVMTypeRef ArrayTy);
1025
1026/**
1027 * Create a pointer type that points to a defined type.
1028 *
1029 * The created type will exist in the context that its pointee type
1030 * exists in.
1031 *
1032 * @see llvm::PointerType::get()
1033 */
Gordon Henriksen5a3fe032007-12-17 16:08:32 +00001034LLVMTypeRef LLVMPointerType(LLVMTypeRef ElementType, unsigned AddressSpace);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001035
1036/**
1037 * Obtain the address space of a pointer type.
1038 *
1039 * This only works on types that represent pointers.
1040 *
1041 * @see llvm::PointerType::getAddressSpace()
1042 */
1043unsigned LLVMGetPointerAddressSpace(LLVMTypeRef PointerTy);
1044
1045/**
1046 * Create a vector type that contains a defined type and has a specific
1047 * number of elements.
1048 *
1049 * The created type will exist in the context thats its element type
1050 * exists in.
1051 *
1052 * @see llvm::VectorType::get()
1053 */
Gordon Henriksened7beaa2007-10-06 16:05:20 +00001054LLVMTypeRef LLVMVectorType(LLVMTypeRef ElementType, unsigned ElementCount);
Gordon Henriksen76a03742007-09-18 03:18:57 +00001055
Gregory Szorc34c863a2012-03-21 03:54:29 +00001056/**
1057 * Obtain the number of elements in a vector type.
1058 *
1059 * This only works on types that represent vectors.
1060 *
1061 * @see llvm::VectorType::getNumElements()
1062 */
Gordon Henriksen76a03742007-09-18 03:18:57 +00001063unsigned LLVMGetVectorSize(LLVMTypeRef VectorTy);
1064
Gregory Szorc34c863a2012-03-21 03:54:29 +00001065/**
1066 * @}
1067 */
1068
1069/**
1070 * @defgroup LLVMCCoreTypeOther Other Types
1071 *
1072 * @{
1073 */
1074
1075/**
1076 * Create a void type in a context.
1077 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +00001078LLVMTypeRef LLVMVoidTypeInContext(LLVMContextRef C);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001079
1080/**
1081 * Create a label type in a context.
1082 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +00001083LLVMTypeRef LLVMLabelTypeInContext(LLVMContextRef C);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001084
1085/**
1086 * Create a X86 MMX type in a context.
1087 */
Dale Johannesen95b67af2010-09-10 21:58:02 +00001088LLVMTypeRef LLVMX86MMXTypeInContext(LLVMContextRef C);
Erick Tryzelaar262332f2009-08-14 00:01:31 +00001089
Gregory Szorc34c863a2012-03-21 03:54:29 +00001090/**
1091 * These are similar to the above functions except they operate on the
1092 * global context.
1093 */
Gordon Henriksena735a9c2008-05-04 12:55:34 +00001094LLVMTypeRef LLVMVoidType(void);
1095LLVMTypeRef LLVMLabelType(void);
Dale Johannesen95b67af2010-09-10 21:58:02 +00001096LLVMTypeRef LLVMX86MMXType(void);
Gordon Henriksen76a03742007-09-18 03:18:57 +00001097
Gregory Szorc34c863a2012-03-21 03:54:29 +00001098/**
1099 * @}
1100 */
Gordon Henriksen76a03742007-09-18 03:18:57 +00001101
Gregory Szorc34c863a2012-03-21 03:54:29 +00001102/**
1103 * @}
1104 */
1105
1106/**
1107 * @defgroup LLVMCCoreValues Values
1108 *
1109 * The bulk of LLVM's object model consists of values, which comprise a very
Gordon Henriksen76a03742007-09-18 03:18:57 +00001110 * rich type hierarchy.
Gregory Szorc34c863a2012-03-21 03:54:29 +00001111 *
1112 * LLVMValueRef essentially represents llvm::Value. There is a rich
1113 * hierarchy of classes within this type. Depending on the instance
Eli Benderskyc52863c2012-08-10 18:30:44 +00001114 * obtained, not all APIs are available.
Gregory Szorc34c863a2012-03-21 03:54:29 +00001115 *
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00001116 * Callers can determine the type of an LLVMValueRef by calling the
Gregory Szorc34c863a2012-03-21 03:54:29 +00001117 * LLVMIsA* family of functions (e.g. LLVMIsAArgument()). These
1118 * functions are defined by a macro, so it isn't obvious which are
1119 * available by looking at the Doxygen source code. Instead, look at the
1120 * source definition of LLVM_FOR_EACH_VALUE_SUBCLASS and note the list
1121 * of value names given. These value names also correspond to classes in
1122 * the llvm::Value hierarchy.
1123 *
1124 * @{
Gordon Henriksen76a03742007-09-18 03:18:57 +00001125 */
1126
Gordon Henriksen29e38942008-12-19 18:39:45 +00001127#define LLVM_FOR_EACH_VALUE_SUBCLASS(macro) \
1128 macro(Argument) \
1129 macro(BasicBlock) \
1130 macro(InlineAsm) \
1131 macro(User) \
1132 macro(Constant) \
Torok Edwind09b7572011-10-14 20:37:56 +00001133 macro(BlockAddress) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001134 macro(ConstantAggregateZero) \
1135 macro(ConstantArray) \
Peter Zotovae0344b2013-11-05 12:55:37 +00001136 macro(ConstantDataSequential) \
1137 macro(ConstantDataArray) \
1138 macro(ConstantDataVector) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001139 macro(ConstantExpr) \
1140 macro(ConstantFP) \
1141 macro(ConstantInt) \
1142 macro(ConstantPointerNull) \
1143 macro(ConstantStruct) \
David Majnemerf0f224d2015-11-11 21:57:16 +00001144 macro(ConstantTokenNone) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001145 macro(ConstantVector) \
1146 macro(GlobalValue) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001147 macro(GlobalAlias) \
Rafael Espindola99e05cf2014-05-13 18:45:48 +00001148 macro(GlobalObject) \
1149 macro(Function) \
1150 macro(GlobalVariable) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001151 macro(UndefValue) \
1152 macro(Instruction) \
1153 macro(BinaryOperator) \
1154 macro(CallInst) \
1155 macro(IntrinsicInst) \
1156 macro(DbgInfoIntrinsic) \
1157 macro(DbgDeclareInst) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001158 macro(MemIntrinsic) \
1159 macro(MemCpyInst) \
1160 macro(MemMoveInst) \
1161 macro(MemSetInst) \
1162 macro(CmpInst) \
Torok Edwind09b7572011-10-14 20:37:56 +00001163 macro(FCmpInst) \
1164 macro(ICmpInst) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001165 macro(ExtractElementInst) \
1166 macro(GetElementPtrInst) \
1167 macro(InsertElementInst) \
1168 macro(InsertValueInst) \
Bill Wendlingfae14752011-08-12 20:24:12 +00001169 macro(LandingPadInst) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001170 macro(PHINode) \
1171 macro(SelectInst) \
1172 macro(ShuffleVectorInst) \
1173 macro(StoreInst) \
1174 macro(TerminatorInst) \
1175 macro(BranchInst) \
Torok Edwind09b7572011-10-14 20:37:56 +00001176 macro(IndirectBrInst) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001177 macro(InvokeInst) \
1178 macro(ReturnInst) \
1179 macro(SwitchInst) \
1180 macro(UnreachableInst) \
Bill Wendlingf891bf82011-07-31 06:30:59 +00001181 macro(ResumeInst) \
David Majnemer654e1302015-07-31 17:58:14 +00001182 macro(CleanupReturnInst) \
1183 macro(CatchReturnInst) \
David Majnemer8a1c45d2015-12-12 05:38:55 +00001184 macro(FuncletPadInst) \
1185 macro(CatchPadInst) \
1186 macro(CleanupPadInst) \
Duncan Sands5e37e992013-05-06 08:55:45 +00001187 macro(UnaryInstruction) \
1188 macro(AllocaInst) \
1189 macro(CastInst) \
Matt Arsenaultb03bd4d2013-11-15 01:34:59 +00001190 macro(AddrSpaceCastInst) \
Duncan Sands5e37e992013-05-06 08:55:45 +00001191 macro(BitCastInst) \
1192 macro(FPExtInst) \
1193 macro(FPToSIInst) \
1194 macro(FPToUIInst) \
1195 macro(FPTruncInst) \
1196 macro(IntToPtrInst) \
1197 macro(PtrToIntInst) \
1198 macro(SExtInst) \
1199 macro(SIToFPInst) \
1200 macro(TruncInst) \
1201 macro(UIToFPInst) \
1202 macro(ZExtInst) \
1203 macro(ExtractValueInst) \
1204 macro(LoadInst) \
1205 macro(VAArgInst)
Gordon Henriksen29e38942008-12-19 18:39:45 +00001206
Gregory Szorc34c863a2012-03-21 03:54:29 +00001207/**
1208 * @defgroup LLVMCCoreValueGeneral General APIs
1209 *
1210 * Functions in this section work on all LLVMValueRef instances,
1211 * regardless of their sub-type. They correspond to functions available
1212 * on llvm::Value.
1213 *
1214 * @{
1215 */
Gordon Henriksen76a03742007-09-18 03:18:57 +00001216
Gregory Szorc34c863a2012-03-21 03:54:29 +00001217/**
1218 * Obtain the type of a value.
1219 *
1220 * @see llvm::Value::getType()
1221 */
1222LLVMTypeRef LLVMTypeOf(LLVMValueRef Val);
1223
1224/**
Peter Zotov3e4561c2016-04-06 22:21:29 +00001225 * Obtain the enumerated type of a Value instance.
1226 *
1227 * @see llvm::Value::getValueID()
1228 */
1229LLVMValueKind LLVMGetValueKind(LLVMValueRef Val);
1230
1231/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00001232 * Obtain the string name of a value.
1233 *
1234 * @see llvm::Value::getName()
1235 */
1236const char *LLVMGetValueName(LLVMValueRef Val);
1237
1238/**
1239 * Set the string name of a value.
1240 *
1241 * @see llvm::Value::setName()
1242 */
1243void LLVMSetValueName(LLVMValueRef Val, const char *Name);
1244
1245/**
1246 * Dump a representation of a value to stderr.
1247 *
1248 * @see llvm::Value::dump()
1249 */
1250void LLVMDumpValue(LLVMValueRef Val);
1251
1252/**
Peter Zotovcd93b372013-11-06 09:21:01 +00001253 * Return a string representation of the value. Use
1254 * LLVMDisposeMessage to free the string.
1255 *
1256 * @see llvm::Value::print()
1257 */
1258char *LLVMPrintValueToString(LLVMValueRef Val);
1259
1260/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00001261 * Replace all uses of a value with another one.
1262 *
1263 * @see llvm::Value::replaceAllUsesWith()
1264 */
1265void LLVMReplaceAllUsesWith(LLVMValueRef OldVal, LLVMValueRef NewVal);
1266
1267/**
Amaury Sechet1c395072016-01-18 01:06:52 +00001268 * Determine whether the specified value instance is constant.
Gregory Szorc34c863a2012-03-21 03:54:29 +00001269 */
1270LLVMBool LLVMIsConstant(LLVMValueRef Val);
1271
1272/**
1273 * Determine whether a value instance is undefined.
1274 */
1275LLVMBool LLVMIsUndef(LLVMValueRef Val);
1276
1277/**
1278 * Convert value instances between types.
1279 *
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00001280 * Internally, an LLVMValueRef is "pinned" to a specific type. This
Gregory Szorc34c863a2012-03-21 03:54:29 +00001281 * series of functions allows you to cast an instance to a specific
1282 * type.
1283 *
1284 * If the cast is not valid for the specified type, NULL is returned.
1285 *
1286 * @see llvm::dyn_cast_or_null<>
1287 */
Gordon Henriksen29e38942008-12-19 18:39:45 +00001288#define LLVM_DECLARE_VALUE_CAST(name) \
1289 LLVMValueRef LLVMIsA##name(LLVMValueRef Val);
1290LLVM_FOR_EACH_VALUE_SUBCLASS(LLVM_DECLARE_VALUE_CAST)
1291
Duncan P. N. Exon Smith5bf8fef2014-12-09 18:38:53 +00001292LLVMValueRef LLVMIsAMDNode(LLVMValueRef Val);
1293LLVMValueRef LLVMIsAMDString(LLVMValueRef Val);
1294
Gregory Szorc34c863a2012-03-21 03:54:29 +00001295/**
1296 * @}
1297 */
1298
1299/**
1300 * @defgroup LLVMCCoreValueUses Usage
1301 *
1302 * This module defines functions that allow you to inspect the uses of a
1303 * LLVMValueRef.
1304 *
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00001305 * It is possible to obtain an LLVMUseRef for any LLVMValueRef instance.
Gregory Szorc34c863a2012-03-21 03:54:29 +00001306 * Each LLVMUseRef (which corresponds to a llvm::Use instance) holds a
1307 * llvm::User and llvm::Value.
1308 *
1309 * @{
1310 */
1311
1312/**
1313 * Obtain the first use of a value.
1314 *
1315 * Uses are obtained in an iterator fashion. First, call this function
1316 * to obtain a reference to the first use. Then, call LLVMGetNextUse()
Eli Benderskyc52863c2012-08-10 18:30:44 +00001317 * on that instance and all subsequently obtained instances until
Gregory Szorc34c863a2012-03-21 03:54:29 +00001318 * LLVMGetNextUse() returns NULL.
1319 *
1320 * @see llvm::Value::use_begin()
1321 */
Erick Tryzelaar9f9857e2010-03-02 20:32:28 +00001322LLVMUseRef LLVMGetFirstUse(LLVMValueRef Val);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001323
1324/**
1325 * Obtain the next use of a value.
1326 *
1327 * This effectively advances the iterator. It returns NULL if you are on
1328 * the final use and no more are available.
1329 */
Erick Tryzelaar9f9857e2010-03-02 20:32:28 +00001330LLVMUseRef LLVMGetNextUse(LLVMUseRef U);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001331
1332/**
1333 * Obtain the user value for a user.
1334 *
1335 * The returned value corresponds to a llvm::User type.
1336 *
1337 * @see llvm::Use::getUser()
1338 */
Erick Tryzelaar9f9857e2010-03-02 20:32:28 +00001339LLVMValueRef LLVMGetUser(LLVMUseRef U);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001340
1341/**
1342 * Obtain the value this use corresponds to.
1343 *
1344 * @see llvm::Use::get().
1345 */
Erick Tryzelaar9f9857e2010-03-02 20:32:28 +00001346LLVMValueRef LLVMGetUsedValue(LLVMUseRef U);
Chris Lattner40cf28d2009-10-12 04:01:02 +00001347
Gregory Szorc34c863a2012-03-21 03:54:29 +00001348/**
1349 * @}
1350 */
1351
1352/**
Gregory Szorc52d26602012-03-21 07:28:27 +00001353 * @defgroup LLVMCCoreValueUser User value
Gregory Szorc34c863a2012-03-21 03:54:29 +00001354 *
1355 * Function in this group pertain to LLVMValueRef instances that descent
1356 * from llvm::User. This includes constants, instructions, and
1357 * operators.
1358 *
1359 * @{
1360 */
1361
1362/**
1363 * Obtain an operand at a specific index in a llvm::User value.
1364 *
1365 * @see llvm::User::getOperand()
1366 */
Chris Lattner40cf28d2009-10-12 04:01:02 +00001367LLVMValueRef LLVMGetOperand(LLVMValueRef Val, unsigned Index);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001368
1369/**
Peter Zotovb19f78f2014-08-12 02:55:40 +00001370 * Obtain the use of an operand at a specific index in a llvm::User value.
1371 *
1372 * @see llvm::User::getOperandUse()
1373 */
1374LLVMUseRef LLVMGetOperandUse(LLVMValueRef Val, unsigned Index);
1375
1376/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00001377 * Set an operand at a specific index in a llvm::User value.
1378 *
1379 * @see llvm::User::setOperand()
1380 */
Erick Tryzelaarb4d48702010-08-20 14:51:22 +00001381void LLVMSetOperand(LLVMValueRef User, unsigned Index, LLVMValueRef Val);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001382
1383/**
1384 * Obtain the number of operands in a llvm::User value.
1385 *
1386 * @see llvm::User::getNumOperands()
1387 */
Erick Tryzelaarb4d48702010-08-20 14:51:22 +00001388int LLVMGetNumOperands(LLVMValueRef Val);
Chris Lattner40cf28d2009-10-12 04:01:02 +00001389
Gregory Szorc34c863a2012-03-21 03:54:29 +00001390/**
1391 * @}
1392 */
1393
1394/**
Gregory Szorc52d26602012-03-21 07:28:27 +00001395 * @defgroup LLVMCCoreValueConstant Constants
Gregory Szorc34c863a2012-03-21 03:54:29 +00001396 *
1397 * This section contains APIs for interacting with LLVMValueRef that
1398 * correspond to llvm::Constant instances.
1399 *
1400 * These functions will work for any LLVMValueRef in the llvm::Constant
1401 * class hierarchy.
1402 *
1403 * @{
1404 */
1405
1406/**
1407 * Obtain a constant value referring to the null instance of a type.
1408 *
1409 * @see llvm::Constant::getNullValue()
1410 */
Gordon Henriksen1046c732007-10-06 15:11:06 +00001411LLVMValueRef LLVMConstNull(LLVMTypeRef Ty); /* all zeroes */
Gregory Szorc34c863a2012-03-21 03:54:29 +00001412
1413/**
1414 * Obtain a constant value referring to the instance of a type
1415 * consisting of all ones.
1416 *
1417 * This is only valid for integer types.
1418 *
1419 * @see llvm::Constant::getAllOnesValue()
1420 */
1421LLVMValueRef LLVMConstAllOnes(LLVMTypeRef Ty);
1422
1423/**
1424 * Obtain a constant value referring to an undefined value of a type.
1425 *
1426 * @see llvm::UndefValue::get()
1427 */
Gordon Henriksen76a03742007-09-18 03:18:57 +00001428LLVMValueRef LLVMGetUndef(LLVMTypeRef Ty);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001429
1430/**
1431 * Determine whether a value instance is null.
1432 *
1433 * @see llvm::Constant::isNullValue()
1434 */
Chris Lattner25963c62010-01-09 22:27:07 +00001435LLVMBool LLVMIsNull(LLVMValueRef Val);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001436
1437/**
1438 * Obtain a constant that is a constant pointer pointing to NULL for a
1439 * specified type.
1440 */
Chris Lattner7f318242009-07-06 17:29:59 +00001441LLVMValueRef LLVMConstPointerNull(LLVMTypeRef Ty);
Gordon Henriksen76a03742007-09-18 03:18:57 +00001442
Gregory Szorc34c863a2012-03-21 03:54:29 +00001443/**
1444 * @defgroup LLVMCCoreValueConstantScalar Scalar constants
1445 *
1446 * Functions in this group model LLVMValueRef instances that correspond
1447 * to constants referring to scalar types.
1448 *
1449 * For integer types, the LLVMTypeRef parameter should correspond to a
1450 * llvm::IntegerType instance and the returned LLVMValueRef will
1451 * correspond to a llvm::ConstantInt.
1452 *
1453 * For floating point types, the LLVMTypeRef returned corresponds to a
1454 * llvm::ConstantFP.
1455 *
1456 * @{
1457 */
Erick Tryzelaard8531fa2010-02-28 09:45:59 +00001458
Gregory Szorc34c863a2012-03-21 03:54:29 +00001459/**
1460 * Obtain a constant value for an integer type.
1461 *
1462 * The returned value corresponds to a llvm::ConstantInt.
1463 *
1464 * @see llvm::ConstantInt::get()
1465 *
1466 * @param IntTy Integer type to obtain value of.
1467 * @param N The value the returned instance should refer to.
1468 * @param SignExtend Whether to sign extend the produced value.
1469 */
Gordon Henriksen1046c732007-10-06 15:11:06 +00001470LLVMValueRef LLVMConstInt(LLVMTypeRef IntTy, unsigned long long N,
Chris Lattner25963c62010-01-09 22:27:07 +00001471 LLVMBool SignExtend);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001472
1473/**
1474 * Obtain a constant value for an integer of arbitrary precision.
1475 *
1476 * @see llvm::ConstantInt::get()
1477 */
Chris Lattner4329e072010-11-23 02:47:22 +00001478LLVMValueRef LLVMConstIntOfArbitraryPrecision(LLVMTypeRef IntTy,
1479 unsigned NumWords,
1480 const uint64_t Words[]);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001481
1482/**
1483 * Obtain a constant value for an integer parsed from a string.
1484 *
1485 * A similar API, LLVMConstIntOfStringAndSize is also available. If the
1486 * string's length is available, it is preferred to call that function
1487 * instead.
1488 *
1489 * @see llvm::ConstantInt::get()
1490 */
Erick Tryzelaardd991352009-08-16 23:36:46 +00001491LLVMValueRef LLVMConstIntOfString(LLVMTypeRef IntTy, const char *Text,
1492 uint8_t Radix);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001493
1494/**
1495 * Obtain a constant value for an integer parsed from a string with
1496 * specified length.
1497 *
1498 * @see llvm::ConstantInt::get()
1499 */
Erick Tryzelaardd991352009-08-16 23:36:46 +00001500LLVMValueRef LLVMConstIntOfStringAndSize(LLVMTypeRef IntTy, const char *Text,
1501 unsigned SLen, uint8_t Radix);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001502
1503/**
1504 * Obtain a constant value referring to a double floating point value.
1505 */
Gordon Henriksen1046c732007-10-06 15:11:06 +00001506LLVMValueRef LLVMConstReal(LLVMTypeRef RealTy, double N);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001507
1508/**
1509 * Obtain a constant for a floating point value parsed from a string.
1510 *
1511 * A similar API, LLVMConstRealOfStringAndSize is also available. It
1512 * should be used if the input string's length is known.
1513 */
Gordon Henriksen931e1212008-02-02 01:07:50 +00001514LLVMValueRef LLVMConstRealOfString(LLVMTypeRef RealTy, const char *Text);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001515
1516/**
1517 * Obtain a constant for a floating point value parsed from a string.
1518 */
Erick Tryzelaardd991352009-08-16 23:36:46 +00001519LLVMValueRef LLVMConstRealOfStringAndSize(LLVMTypeRef RealTy, const char *Text,
1520 unsigned SLen);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001521
1522/**
1523 * Obtain the zero extended value for an integer constant value.
1524 *
1525 * @see llvm::ConstantInt::getZExtValue()
1526 */
Chris Lattner40cf28d2009-10-12 04:01:02 +00001527unsigned long long LLVMConstIntGetZExtValue(LLVMValueRef ConstantVal);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001528
1529/**
1530 * Obtain the sign extended value for an integer constant value.
1531 *
1532 * @see llvm::ConstantInt::getSExtValue()
1533 */
Chris Lattner40cf28d2009-10-12 04:01:02 +00001534long long LLVMConstIntGetSExtValue(LLVMValueRef ConstantVal);
Erick Tryzelaardd991352009-08-16 23:36:46 +00001535
Gregory Szorc34c863a2012-03-21 03:54:29 +00001536/**
Peter Zotov1d98e6d2014-10-28 19:46:44 +00001537 * Obtain the double value for an floating point constant value.
1538 * losesInfo indicates if some precision was lost in the conversion.
1539 *
1540 * @see llvm::ConstantFP::getDoubleValue
1541 */
1542double LLVMConstRealGetDouble(LLVMValueRef ConstantVal, LLVMBool *losesInfo);
1543
1544/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00001545 * @}
1546 */
1547
1548/**
Gregory Szorc52d26602012-03-21 07:28:27 +00001549 * @defgroup LLVMCCoreValueConstantComposite Composite Constants
1550 *
1551 * Functions in this group operate on composite constants.
Gregory Szorc34c863a2012-03-21 03:54:29 +00001552 *
1553 * @{
1554 */
1555
1556/**
Gregory Szorc52d26602012-03-21 07:28:27 +00001557 * Create a ConstantDataSequential and initialize it with a string.
Gregory Szorc34c863a2012-03-21 03:54:29 +00001558 *
Gregory Szorc52d26602012-03-21 07:28:27 +00001559 * @see llvm::ConstantDataArray::getString()
Gregory Szorc34c863a2012-03-21 03:54:29 +00001560 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +00001561LLVMValueRef LLVMConstStringInContext(LLVMContextRef C, const char *Str,
Chris Lattner25963c62010-01-09 22:27:07 +00001562 unsigned Length, LLVMBool DontNullTerminate);
Gregory Szorc52d26602012-03-21 07:28:27 +00001563
1564/**
1565 * Create a ConstantDataSequential with string content in the global context.
1566 *
1567 * This is the same as LLVMConstStringInContext except it operates on the
1568 * global context.
1569 *
1570 * @see LLVMConstStringInContext()
1571 * @see llvm::ConstantDataArray::getString()
1572 */
1573LLVMValueRef LLVMConstString(const char *Str, unsigned Length,
1574 LLVMBool DontNullTerminate);
1575
1576/**
Peter Zotovf9aa8822014-08-03 23:54:16 +00001577 * Returns true if the specified constant is an array of i8.
1578 *
1579 * @see ConstantDataSequential::getAsString()
1580 */
1581LLVMBool LLVMIsConstantString(LLVMValueRef c);
1582
1583/**
1584 * Get the given constant data sequential as a string.
1585 *
1586 * @see ConstantDataSequential::getAsString()
1587 */
Amaury Sechet7c2883c2016-04-03 21:06:04 +00001588const char *LLVMGetAsString(LLVMValueRef c, size_t *Length);
Peter Zotovf9aa8822014-08-03 23:54:16 +00001589
1590/**
Gregory Szorc52d26602012-03-21 07:28:27 +00001591 * Create an anonymous ConstantStruct with the specified values.
1592 *
1593 * @see llvm::ConstantStruct::getAnon()
1594 */
1595LLVMValueRef LLVMConstStructInContext(LLVMContextRef C,
Erick Tryzelaar262332f2009-08-14 00:01:31 +00001596 LLVMValueRef *ConstantVals,
Chris Lattner25963c62010-01-09 22:27:07 +00001597 unsigned Count, LLVMBool Packed);
Erick Tryzelaar262332f2009-08-14 00:01:31 +00001598
Gregory Szorc52d26602012-03-21 07:28:27 +00001599/**
1600 * Create a ConstantStruct in the global Context.
1601 *
1602 * This is the same as LLVMConstStructInContext except it operates on the
1603 * global Context.
1604 *
1605 * @see LLVMConstStructInContext()
1606 */
Gordon Henriksen1046c732007-10-06 15:11:06 +00001607LLVMValueRef LLVMConstStruct(LLVMValueRef *ConstantVals, unsigned Count,
Chris Lattner25963c62010-01-09 22:27:07 +00001608 LLVMBool Packed);
Gregory Szorc52d26602012-03-21 07:28:27 +00001609
1610/**
1611 * Create a ConstantArray from values.
1612 *
1613 * @see llvm::ConstantArray::get()
1614 */
1615LLVMValueRef LLVMConstArray(LLVMTypeRef ElementTy,
1616 LLVMValueRef *ConstantVals, unsigned Length);
1617
1618/**
1619 * Create a non-anonymous ConstantStruct from values.
1620 *
1621 * @see llvm::ConstantStruct::get()
1622 */
Rafael Espindola784ad242011-07-14 19:09:08 +00001623LLVMValueRef LLVMConstNamedStruct(LLVMTypeRef StructTy,
1624 LLVMValueRef *ConstantVals,
1625 unsigned Count);
Gregory Szorc52d26602012-03-21 07:28:27 +00001626
1627/**
Peter Zotovf9aa8822014-08-03 23:54:16 +00001628 * Get an element at specified index as a constant.
1629 *
1630 * @see ConstantDataSequential::getElementAsConstant()
1631 */
Amaury Sechet006ce632016-03-13 00:54:40 +00001632LLVMValueRef LLVMGetElementAsConstant(LLVMValueRef C, unsigned idx);
Peter Zotovf9aa8822014-08-03 23:54:16 +00001633
1634/**
Gregory Szorc52d26602012-03-21 07:28:27 +00001635 * Create a ConstantVector from values.
1636 *
1637 * @see llvm::ConstantVector::get()
1638 */
Gordon Henriksen1046c732007-10-06 15:11:06 +00001639LLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals, unsigned Size);
Gordon Henriksen76a03742007-09-18 03:18:57 +00001640
Gregory Szorc52d26602012-03-21 07:28:27 +00001641/**
1642 * @}
1643 */
1644
1645/**
1646 * @defgroup LLVMCCoreValueConstantExpressions Constant Expressions
1647 *
1648 * Functions in this group correspond to APIs on llvm::ConstantExpr.
1649 *
1650 * @see llvm::ConstantExpr.
1651 *
1652 * @{
1653 */
Chris Lattner40cf28d2009-10-12 04:01:02 +00001654LLVMOpcode LLVMGetConstOpcode(LLVMValueRef ConstantVal);
Erick Tryzelaarfd529d72009-08-19 08:36:49 +00001655LLVMValueRef LLVMAlignOf(LLVMTypeRef Ty);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001656LLVMValueRef LLVMSizeOf(LLVMTypeRef Ty);
1657LLVMValueRef LLVMConstNeg(LLVMValueRef ConstantVal);
Erick Tryzelaar4c340c72010-02-28 05:51:43 +00001658LLVMValueRef LLVMConstNSWNeg(LLVMValueRef ConstantVal);
1659LLVMValueRef LLVMConstNUWNeg(LLVMValueRef ConstantVal);
Erick Tryzelaar4cc690c2009-08-16 02:20:12 +00001660LLVMValueRef LLVMConstFNeg(LLVMValueRef ConstantVal);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001661LLVMValueRef LLVMConstNot(LLVMValueRef ConstantVal);
1662LLVMValueRef LLVMConstAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Dan Gohmane4ca02d2009-09-03 23:34:49 +00001663LLVMValueRef LLVMConstNSWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Erick Tryzelaar4c340c72010-02-28 05:51:43 +00001664LLVMValueRef LLVMConstNUWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Erick Tryzelaar4cc690c2009-08-16 02:20:12 +00001665LLVMValueRef LLVMConstFAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001666LLVMValueRef LLVMConstSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Erick Tryzelaar4c340c72010-02-28 05:51:43 +00001667LLVMValueRef LLVMConstNSWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1668LLVMValueRef LLVMConstNUWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Erick Tryzelaar4cc690c2009-08-16 02:20:12 +00001669LLVMValueRef LLVMConstFSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001670LLVMValueRef LLVMConstMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Erick Tryzelaar4c340c72010-02-28 05:51:43 +00001671LLVMValueRef LLVMConstNSWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1672LLVMValueRef LLVMConstNUWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Erick Tryzelaar4cc690c2009-08-16 02:20:12 +00001673LLVMValueRef LLVMConstFMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001674LLVMValueRef LLVMConstUDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1675LLVMValueRef LLVMConstSDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Dan Gohmane4ca02d2009-09-03 23:34:49 +00001676LLVMValueRef LLVMConstExactSDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001677LLVMValueRef LLVMConstFDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1678LLVMValueRef LLVMConstURem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1679LLVMValueRef LLVMConstSRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1680LLVMValueRef LLVMConstFRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1681LLVMValueRef LLVMConstAnd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1682LLVMValueRef LLVMConstOr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1683LLVMValueRef LLVMConstXor(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1684LLVMValueRef LLVMConstICmp(LLVMIntPredicate Predicate,
1685 LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1686LLVMValueRef LLVMConstFCmp(LLVMRealPredicate Predicate,
1687 LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1688LLVMValueRef LLVMConstShl(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1689LLVMValueRef LLVMConstLShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1690LLVMValueRef LLVMConstAShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1691LLVMValueRef LLVMConstGEP(LLVMValueRef ConstantVal,
1692 LLVMValueRef *ConstantIndices, unsigned NumIndices);
Dan Gohmane4ca02d2009-09-03 23:34:49 +00001693LLVMValueRef LLVMConstInBoundsGEP(LLVMValueRef ConstantVal,
1694 LLVMValueRef *ConstantIndices,
1695 unsigned NumIndices);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001696LLVMValueRef LLVMConstTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1697LLVMValueRef LLVMConstSExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1698LLVMValueRef LLVMConstZExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1699LLVMValueRef LLVMConstFPTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1700LLVMValueRef LLVMConstFPExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1701LLVMValueRef LLVMConstUIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1702LLVMValueRef LLVMConstSIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1703LLVMValueRef LLVMConstFPToUI(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1704LLVMValueRef LLVMConstFPToSI(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1705LLVMValueRef LLVMConstPtrToInt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1706LLVMValueRef LLVMConstIntToPtr(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1707LLVMValueRef LLVMConstBitCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
Matt Arsenaultb03bd4d2013-11-15 01:34:59 +00001708LLVMValueRef LLVMConstAddrSpaceCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
Erick Tryzelaar4cc690c2009-08-16 02:20:12 +00001709LLVMValueRef LLVMConstZExtOrBitCast(LLVMValueRef ConstantVal,
1710 LLVMTypeRef ToType);
1711LLVMValueRef LLVMConstSExtOrBitCast(LLVMValueRef ConstantVal,
1712 LLVMTypeRef ToType);
1713LLVMValueRef LLVMConstTruncOrBitCast(LLVMValueRef ConstantVal,
1714 LLVMTypeRef ToType);
1715LLVMValueRef LLVMConstPointerCast(LLVMValueRef ConstantVal,
1716 LLVMTypeRef ToType);
1717LLVMValueRef LLVMConstIntCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType,
Chris Lattner25963c62010-01-09 22:27:07 +00001718 LLVMBool isSigned);
Erick Tryzelaar4cc690c2009-08-16 02:20:12 +00001719LLVMValueRef LLVMConstFPCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001720LLVMValueRef LLVMConstSelect(LLVMValueRef ConstantCondition,
1721 LLVMValueRef ConstantIfTrue,
1722 LLVMValueRef ConstantIfFalse);
1723LLVMValueRef LLVMConstExtractElement(LLVMValueRef VectorConstant,
1724 LLVMValueRef IndexConstant);
1725LLVMValueRef LLVMConstInsertElement(LLVMValueRef VectorConstant,
1726 LLVMValueRef ElementValueConstant,
1727 LLVMValueRef IndexConstant);
1728LLVMValueRef LLVMConstShuffleVector(LLVMValueRef VectorAConstant,
1729 LLVMValueRef VectorBConstant,
1730 LLVMValueRef MaskConstant);
Dan Gohmand5104a52008-11-03 22:55:43 +00001731LLVMValueRef LLVMConstExtractValue(LLVMValueRef AggConstant, unsigned *IdxList,
1732 unsigned NumIdx);
1733LLVMValueRef LLVMConstInsertValue(LLVMValueRef AggConstant,
1734 LLVMValueRef ElementValueConstant,
1735 unsigned *IdxList, unsigned NumIdx);
Chris Lattner25963c62010-01-09 22:27:07 +00001736LLVMValueRef LLVMConstInlineAsm(LLVMTypeRef Ty,
Chris Lattner3d1f5522008-12-17 21:39:50 +00001737 const char *AsmString, const char *Constraints,
Chris Lattner25963c62010-01-09 22:27:07 +00001738 LLVMBool HasSideEffects, LLVMBool IsAlignStack);
Erick Tryzelaar0fb26ef2010-02-28 09:46:06 +00001739LLVMValueRef LLVMBlockAddress(LLVMValueRef F, LLVMBasicBlockRef BB);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001740
Gregory Szorc52d26602012-03-21 07:28:27 +00001741/**
1742 * @}
1743 */
1744
1745/**
1746 * @defgroup LLVMCCoreValueConstantGlobals Global Values
1747 *
1748 * This group contains functions that operate on global values. Functions in
1749 * this group relate to functions in the llvm::GlobalValue class tree.
1750 *
1751 * @see llvm::GlobalValue
1752 *
1753 * @{
1754 */
1755
Gordon Henriksen265f7802008-03-19 01:11:35 +00001756LLVMModuleRef LLVMGetGlobalParent(LLVMValueRef Global);
Chris Lattner25963c62010-01-09 22:27:07 +00001757LLVMBool LLVMIsDeclaration(LLVMValueRef Global);
Gordon Henriksen76a03742007-09-18 03:18:57 +00001758LLVMLinkage LLVMGetLinkage(LLVMValueRef Global);
1759void LLVMSetLinkage(LLVMValueRef Global, LLVMLinkage Linkage);
1760const char *LLVMGetSection(LLVMValueRef Global);
1761void LLVMSetSection(LLVMValueRef Global, const char *Section);
1762LLVMVisibility LLVMGetVisibility(LLVMValueRef Global);
1763void LLVMSetVisibility(LLVMValueRef Global, LLVMVisibility Viz);
Reid Kleckner2fae26f2014-03-05 02:34:23 +00001764LLVMDLLStorageClass LLVMGetDLLStorageClass(LLVMValueRef Global);
1765void LLVMSetDLLStorageClass(LLVMValueRef Global, LLVMDLLStorageClass Class);
Tim Northoverad96d012014-03-10 19:24:35 +00001766LLVMBool LLVMHasUnnamedAddr(LLVMValueRef Global);
1767void LLVMSetUnnamedAddr(LLVMValueRef Global, LLVMBool HasUnnamedAddr);
Anders Waldenborg213a63f2013-10-29 09:02:02 +00001768
1769/**
1770 * @defgroup LLVMCCoreValueWithAlignment Values with alignment
1771 *
1772 * Functions in this group only apply to values with alignment, i.e.
1773 * global variables, load and store instructions.
1774 */
1775
1776/**
1777 * Obtain the preferred alignment of the value.
Peter Zotov9f584e62014-03-05 05:05:34 +00001778 * @see llvm::AllocaInst::getAlignment()
Anders Waldenborg213a63f2013-10-29 09:02:02 +00001779 * @see llvm::LoadInst::getAlignment()
1780 * @see llvm::StoreInst::getAlignment()
1781 * @see llvm::GlobalValue::getAlignment()
1782 */
1783unsigned LLVMGetAlignment(LLVMValueRef V);
1784
1785/**
1786 * Set the preferred alignment of the value.
Peter Zotov9f584e62014-03-05 05:05:34 +00001787 * @see llvm::AllocaInst::setAlignment()
Anders Waldenborg213a63f2013-10-29 09:02:02 +00001788 * @see llvm::LoadInst::setAlignment()
1789 * @see llvm::StoreInst::setAlignment()
1790 * @see llvm::GlobalValue::setAlignment()
1791 */
1792void LLVMSetAlignment(LLVMValueRef V, unsigned Bytes);
1793
1794/**
Amaury Sechet83550102016-02-14 08:58:49 +00001795 * @}
1796 */
Gordon Henriksen76a03742007-09-18 03:18:57 +00001797
Gregory Szorc52d26602012-03-21 07:28:27 +00001798/**
1799 * @defgroup LLVMCoreValueConstantGlobalVariable Global Variables
1800 *
1801 * This group contains functions that operate on global variable values.
1802 *
1803 * @see llvm::GlobalVariable
1804 *
1805 * @{
1806 */
Gordon Henriksen76a03742007-09-18 03:18:57 +00001807LLVMValueRef LLVMAddGlobal(LLVMModuleRef M, LLVMTypeRef Ty, const char *Name);
Erick Tryzelaar06894b32010-02-28 09:46:13 +00001808LLVMValueRef LLVMAddGlobalInAddressSpace(LLVMModuleRef M, LLVMTypeRef Ty,
1809 const char *Name,
1810 unsigned AddressSpace);
Gordon Henriksen783f7bb2007-10-08 03:45:09 +00001811LLVMValueRef LLVMGetNamedGlobal(LLVMModuleRef M, const char *Name);
Gordon Henriksen07a45f42008-03-23 22:21:29 +00001812LLVMValueRef LLVMGetFirstGlobal(LLVMModuleRef M);
1813LLVMValueRef LLVMGetLastGlobal(LLVMModuleRef M);
1814LLVMValueRef LLVMGetNextGlobal(LLVMValueRef GlobalVar);
1815LLVMValueRef LLVMGetPreviousGlobal(LLVMValueRef GlobalVar);
Gordon Henriksen76a03742007-09-18 03:18:57 +00001816void LLVMDeleteGlobal(LLVMValueRef GlobalVar);
Gordon Henriksen76a03742007-09-18 03:18:57 +00001817LLVMValueRef LLVMGetInitializer(LLVMValueRef GlobalVar);
1818void LLVMSetInitializer(LLVMValueRef GlobalVar, LLVMValueRef ConstantVal);
Chris Lattner25963c62010-01-09 22:27:07 +00001819LLVMBool LLVMIsThreadLocal(LLVMValueRef GlobalVar);
1820void LLVMSetThreadLocal(LLVMValueRef GlobalVar, LLVMBool IsThreadLocal);
1821LLVMBool LLVMIsGlobalConstant(LLVMValueRef GlobalVar);
1822void LLVMSetGlobalConstant(LLVMValueRef GlobalVar, LLVMBool IsConstant);
Hans Wennborg5ff71202013-04-16 08:58:59 +00001823LLVMThreadLocalMode LLVMGetThreadLocalMode(LLVMValueRef GlobalVar);
1824void LLVMSetThreadLocalMode(LLVMValueRef GlobalVar, LLVMThreadLocalMode Mode);
1825LLVMBool LLVMIsExternallyInitialized(LLVMValueRef GlobalVar);
1826void LLVMSetExternallyInitialized(LLVMValueRef GlobalVar, LLVMBool IsExtInit);
Gordon Henriksen76a03742007-09-18 03:18:57 +00001827
Gregory Szorc52d26602012-03-21 07:28:27 +00001828/**
1829 * @}
1830 */
1831
1832/**
1833 * @defgroup LLVMCoreValueConstantGlobalAlias Global Aliases
1834 *
1835 * This group contains function that operate on global alias values.
1836 *
1837 * @see llvm::GlobalAlias
1838 *
1839 * @{
1840 */
Chris Lattner3d1f5522008-12-17 21:39:50 +00001841LLVMValueRef LLVMAddAlias(LLVMModuleRef M, LLVMTypeRef Ty, LLVMValueRef Aliasee,
1842 const char *Name);
1843
Gregory Szorc34c863a2012-03-21 03:54:29 +00001844/**
1845 * @}
1846 */
1847
1848/**
1849 * @defgroup LLVMCCoreValueFunction Function values
1850 *
1851 * Functions in this group operate on LLVMValueRef instances that
1852 * correspond to llvm::Function instances.
1853 *
1854 * @see llvm::Function
1855 *
1856 * @{
1857 */
1858
1859/**
1860 * Remove a function from its containing module and deletes it.
1861 *
1862 * @see llvm::Function::eraseFromParent()
1863 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00001864void LLVMDeleteFunction(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001865
1866/**
Amaury Sechete39e8532016-02-18 20:38:32 +00001867 * Check whether the given function has a personality function.
1868 *
1869 * @see llvm::Function::hasPersonalityFn()
1870 */
1871LLVMBool LLVMHasPersonalityFn(LLVMValueRef Fn);
1872
1873/**
Andrew Wilkins3bdfc1c2015-07-14 01:23:06 +00001874 * Obtain the personality function attached to the function.
1875 *
1876 * @see llvm::Function::getPersonalityFn()
1877 */
1878LLVMValueRef LLVMGetPersonalityFn(LLVMValueRef Fn);
1879
1880/**
1881 * Set the personality function attached to the function.
1882 *
1883 * @see llvm::Function::setPersonalityFn()
1884 */
1885void LLVMSetPersonalityFn(LLVMValueRef Fn, LLVMValueRef PersonalityFn);
1886
1887/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00001888 * Obtain the ID number from a function instance.
1889 *
1890 * @see llvm::Function::getIntrinsicID()
1891 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00001892unsigned LLVMGetIntrinsicID(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001893
1894/**
1895 * Obtain the calling function of a function.
1896 *
1897 * The returned value corresponds to the LLVMCallConv enumeration.
1898 *
1899 * @see llvm::Function::getCallingConv()
1900 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00001901unsigned LLVMGetFunctionCallConv(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001902
1903/**
1904 * Set the calling convention of a function.
1905 *
1906 * @see llvm::Function::setCallingConv()
1907 *
1908 * @param Fn Function to operate on
1909 * @param CC LLVMCallConv to set calling convention to
1910 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00001911void LLVMSetFunctionCallConv(LLVMValueRef Fn, unsigned CC);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001912
1913/**
1914 * Obtain the name of the garbage collector to use during code
1915 * generation.
1916 *
1917 * @see llvm::Function::getGC()
1918 */
Gordon Henriksend930f912008-08-17 18:44:35 +00001919const char *LLVMGetGC(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001920
1921/**
1922 * Define the garbage collector to use during code generation.
1923 *
1924 * @see llvm::Function::setGC()
1925 */
Gordon Henriksend930f912008-08-17 18:44:35 +00001926void LLVMSetGC(LLVMValueRef Fn, const char *Name);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001927
1928/**
1929 * Add an attribute to a function.
1930 *
1931 * @see llvm::Function::addAttribute()
1932 */
Duncan Sands7374a012009-05-06 12:21:17 +00001933void LLVMAddFunctionAttr(LLVMValueRef Fn, LLVMAttribute PA);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001934
1935/**
Nick Lewyckyc3890d22015-07-29 22:32:47 +00001936 * Add a target-dependent attribute to a function
Tom Stellarde8f35e12013-04-16 23:12:43 +00001937 * @see llvm::AttrBuilder::addAttribute()
1938 */
1939void LLVMAddTargetDependentFunctionAttr(LLVMValueRef Fn, const char *A,
1940 const char *V);
1941
1942/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00001943 * Obtain an attribute from a function.
1944 *
1945 * @see llvm::Function::getAttributes()
1946 */
Chris Lattner40cf28d2009-10-12 04:01:02 +00001947LLVMAttribute LLVMGetFunctionAttr(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001948
1949/**
1950 * Remove an attribute from a function.
1951 */
Duncan Sands7374a012009-05-06 12:21:17 +00001952void LLVMRemoveFunctionAttr(LLVMValueRef Fn, LLVMAttribute PA);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00001953
Gregory Szorc34c863a2012-03-21 03:54:29 +00001954/**
1955 * @defgroup LLVMCCoreValueFunctionParameters Function Parameters
1956 *
1957 * Functions in this group relate to arguments/parameters on functions.
1958 *
1959 * Functions in this group expect LLVMValueRef instances that correspond
1960 * to llvm::Function instances.
1961 *
1962 * @{
1963 */
1964
1965/**
1966 * Obtain the number of parameters in a function.
1967 *
1968 * @see llvm::Function::arg_size()
1969 */
Gordon Henriksen265f7802008-03-19 01:11:35 +00001970unsigned LLVMCountParams(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001971
1972/**
1973 * Obtain the parameters in a function.
1974 *
1975 * The takes a pointer to a pre-allocated array of LLVMValueRef that is
1976 * at least LLVMCountParams() long. This array will be filled with
1977 * LLVMValueRef instances which correspond to the parameters the
1978 * function receives. Each LLVMValueRef corresponds to a llvm::Argument
1979 * instance.
1980 *
1981 * @see llvm::Function::arg_begin()
1982 */
Gordon Henriksen265f7802008-03-19 01:11:35 +00001983void LLVMGetParams(LLVMValueRef Fn, LLVMValueRef *Params);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001984
1985/**
1986 * Obtain the parameter at the specified index.
1987 *
1988 * Parameters are indexed from 0.
1989 *
1990 * @see llvm::Function::arg_begin()
1991 */
Gordon Henriksen265f7802008-03-19 01:11:35 +00001992LLVMValueRef LLVMGetParam(LLVMValueRef Fn, unsigned Index);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001993
1994/**
1995 * Obtain the function to which this argument belongs.
1996 *
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00001997 * Unlike other functions in this group, this one takes an LLVMValueRef
Gregory Szorc34c863a2012-03-21 03:54:29 +00001998 * that corresponds to a llvm::Attribute.
1999 *
2000 * The returned LLVMValueRef is the llvm::Function to which this
2001 * argument belongs.
2002 */
Gordon Henriksen265f7802008-03-19 01:11:35 +00002003LLVMValueRef LLVMGetParamParent(LLVMValueRef Inst);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002004
2005/**
2006 * Obtain the first parameter to a function.
2007 *
2008 * @see llvm::Function::arg_begin()
2009 */
Gordon Henriksen07a45f42008-03-23 22:21:29 +00002010LLVMValueRef LLVMGetFirstParam(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002011
2012/**
2013 * Obtain the last parameter to a function.
2014 *
2015 * @see llvm::Function::arg_end()
2016 */
Gordon Henriksen07a45f42008-03-23 22:21:29 +00002017LLVMValueRef LLVMGetLastParam(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002018
2019/**
2020 * Obtain the next parameter to a function.
2021 *
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00002022 * This takes an LLVMValueRef obtained from LLVMGetFirstParam() (which is
Gregory Szorc34c863a2012-03-21 03:54:29 +00002023 * actually a wrapped iterator) and obtains the next parameter from the
2024 * underlying iterator.
2025 */
Gordon Henriksen07a45f42008-03-23 22:21:29 +00002026LLVMValueRef LLVMGetNextParam(LLVMValueRef Arg);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002027
2028/**
2029 * Obtain the previous parameter to a function.
2030 *
2031 * This is the opposite of LLVMGetNextParam().
2032 */
Gordon Henriksen07a45f42008-03-23 22:21:29 +00002033LLVMValueRef LLVMGetPreviousParam(LLVMValueRef Arg);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002034
2035/**
2036 * Add an attribute to a function argument.
2037 *
2038 * @see llvm::Argument::addAttr()
2039 */
Devang Patel4c758ea2008-09-25 21:00:45 +00002040void LLVMAddAttribute(LLVMValueRef Arg, LLVMAttribute PA);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002041
2042/**
2043 * Remove an attribute from a function argument.
2044 *
2045 * @see llvm::Argument::removeAttr()
2046 */
Devang Patel4c758ea2008-09-25 21:00:45 +00002047void LLVMRemoveAttribute(LLVMValueRef Arg, LLVMAttribute PA);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002048
2049/**
2050 * Get an attribute from a function argument.
2051 */
Chris Lattner40cf28d2009-10-12 04:01:02 +00002052LLVMAttribute LLVMGetAttribute(LLVMValueRef Arg);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002053
2054/**
2055 * Set the alignment for a function parameter.
2056 *
2057 * @see llvm::Argument::addAttr()
Bill Wendling50d27842012-10-15 20:35:56 +00002058 * @see llvm::AttrBuilder::addAlignmentAttr()
Gregory Szorc34c863a2012-03-21 03:54:29 +00002059 */
Gordon Henriksen2d9cc212008-04-28 17:37:06 +00002060void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned align);
Gordon Henriksen265f7802008-03-19 01:11:35 +00002061
Gregory Szorc34c863a2012-03-21 03:54:29 +00002062/**
2063 * @}
2064 */
2065
2066/**
2067 * @}
2068 */
2069
2070/**
Gregory Szorc52d26602012-03-21 07:28:27 +00002071 * @}
2072 */
2073
2074/**
2075 * @}
2076 */
2077
2078/**
2079 * @defgroup LLVMCCoreValueMetadata Metadata
2080 *
2081 * @{
2082 */
2083
2084/**
2085 * Obtain a MDString value from a context.
2086 *
2087 * The returned instance corresponds to the llvm::MDString class.
2088 *
2089 * The instance is specified by string data of a specified length. The
2090 * string content is copied, so the backing memory can be freed after
2091 * this function returns.
2092 */
2093LLVMValueRef LLVMMDStringInContext(LLVMContextRef C, const char *Str,
2094 unsigned SLen);
2095
2096/**
2097 * Obtain a MDString value from the global context.
2098 */
2099LLVMValueRef LLVMMDString(const char *Str, unsigned SLen);
2100
2101/**
2102 * Obtain a MDNode value from a context.
2103 *
2104 * The returned value corresponds to the llvm::MDNode class.
2105 */
2106LLVMValueRef LLVMMDNodeInContext(LLVMContextRef C, LLVMValueRef *Vals,
2107 unsigned Count);
2108
2109/**
2110 * Obtain a MDNode value from the global context.
2111 */
2112LLVMValueRef LLVMMDNode(LLVMValueRef *Vals, unsigned Count);
2113
2114/**
2115 * Obtain the underlying string from a MDString value.
2116 *
2117 * @param V Instance to obtain string from.
NAKAMURA Takumie4a77052016-04-04 11:54:48 +00002118 * @param Length Memory address which will hold length of returned string.
Gregory Szorc52d26602012-03-21 07:28:27 +00002119 * @return String data in MDString.
2120 */
Amaury Sechet7c2883c2016-04-03 21:06:04 +00002121const char *LLVMGetMDString(LLVMValueRef V, unsigned *Length);
Gregory Szorc52d26602012-03-21 07:28:27 +00002122
2123/**
Duncan Sands12ccbe72012-09-19 20:29:39 +00002124 * Obtain the number of operands from an MDNode value.
2125 *
2126 * @param V MDNode to get number of operands from.
2127 * @return Number of operands of the MDNode.
2128 */
2129unsigned LLVMGetMDNodeNumOperands(LLVMValueRef V);
2130
2131/**
2132 * Obtain the given MDNode's operands.
2133 *
2134 * The passed LLVMValueRef pointer should point to enough memory to hold all of
2135 * the operands of the given MDNode (see LLVMGetMDNodeNumOperands) as
2136 * LLVMValueRefs. This memory will be populated with the LLVMValueRefs of the
2137 * MDNode's operands.
2138 *
2139 * @param V MDNode to get the operands from.
2140 * @param Dest Destination array for operands.
2141 */
2142void LLVMGetMDNodeOperands(LLVMValueRef V, LLVMValueRef *Dest);
2143
2144/**
Gregory Szorc52d26602012-03-21 07:28:27 +00002145 * @}
2146 */
2147
2148/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002149 * @defgroup LLVMCCoreValueBasicBlock Basic Block
2150 *
2151 * A basic block represents a single entry single exit section of code.
2152 * Basic blocks contain a list of instructions which form the body of
2153 * the block.
2154 *
2155 * Basic blocks belong to functions. They have the type of label.
2156 *
2157 * Basic blocks are themselves values. However, the C API models them as
2158 * LLVMBasicBlockRef.
2159 *
2160 * @see llvm::BasicBlock
2161 *
2162 * @{
2163 */
2164
2165/**
2166 * Convert a basic block instance to a value type.
2167 */
Gordon Henriksen07a45f42008-03-23 22:21:29 +00002168LLVMValueRef LLVMBasicBlockAsValue(LLVMBasicBlockRef BB);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002169
2170/**
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00002171 * Determine whether an LLVMValueRef is itself a basic block.
Gregory Szorc34c863a2012-03-21 03:54:29 +00002172 */
Chris Lattner25963c62010-01-09 22:27:07 +00002173LLVMBool LLVMValueIsBasicBlock(LLVMValueRef Val);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002174
2175/**
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00002176 * Convert an LLVMValueRef to an LLVMBasicBlockRef instance.
Gregory Szorc34c863a2012-03-21 03:54:29 +00002177 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002178LLVMBasicBlockRef LLVMValueAsBasicBlock(LLVMValueRef Val);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002179
2180/**
Amaury Secheta82042e2016-02-09 22:36:41 +00002181 * Obtain the string name of a basic block.
2182 */
2183const char *LLVMGetBasicBlockName(LLVMBasicBlockRef BB);
2184
2185/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002186 * Obtain the function to which a basic block belongs.
2187 *
2188 * @see llvm::BasicBlock::getParent()
2189 */
Gordon Henriksen07a45f42008-03-23 22:21:29 +00002190LLVMValueRef LLVMGetBasicBlockParent(LLVMBasicBlockRef BB);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002191
2192/**
2193 * Obtain the terminator instruction for a basic block.
2194 *
2195 * If the basic block does not have a terminator (it is not well-formed
2196 * if it doesn't), then NULL is returned.
2197 *
2198 * The returned LLVMValueRef corresponds to a llvm::TerminatorInst.
2199 *
2200 * @see llvm::BasicBlock::getTerminator()
2201 */
Nate Begeman43c322b2011-08-23 20:27:46 +00002202LLVMValueRef LLVMGetBasicBlockTerminator(LLVMBasicBlockRef BB);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002203
2204/**
2205 * Obtain the number of basic blocks in a function.
2206 *
2207 * @param Fn Function value to operate on.
2208 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002209unsigned LLVMCountBasicBlocks(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002210
2211/**
2212 * Obtain all of the basic blocks in a function.
2213 *
2214 * This operates on a function value. The BasicBlocks parameter is a
2215 * pointer to a pre-allocated array of LLVMBasicBlockRef of at least
2216 * LLVMCountBasicBlocks() in length. This array is populated with
2217 * LLVMBasicBlockRef instances.
2218 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002219void LLVMGetBasicBlocks(LLVMValueRef Fn, LLVMBasicBlockRef *BasicBlocks);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002220
2221/**
2222 * Obtain the first basic block in a function.
2223 *
2224 * The returned basic block can be used as an iterator. You will likely
2225 * eventually call into LLVMGetNextBasicBlock() with it.
2226 *
2227 * @see llvm::Function::begin()
2228 */
Gordon Henriksen054817c2008-03-19 03:47:18 +00002229LLVMBasicBlockRef LLVMGetFirstBasicBlock(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002230
2231/**
2232 * Obtain the last basic block in a function.
2233 *
2234 * @see llvm::Function::end()
2235 */
Gordon Henriksen054817c2008-03-19 03:47:18 +00002236LLVMBasicBlockRef LLVMGetLastBasicBlock(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002237
2238/**
2239 * Advance a basic block iterator.
2240 */
Gordon Henriksen054817c2008-03-19 03:47:18 +00002241LLVMBasicBlockRef LLVMGetNextBasicBlock(LLVMBasicBlockRef BB);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002242
2243/**
2244 * Go backwards in a basic block iterator.
2245 */
Gordon Henriksen054817c2008-03-19 03:47:18 +00002246LLVMBasicBlockRef LLVMGetPreviousBasicBlock(LLVMBasicBlockRef BB);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002247
2248/**
2249 * Obtain the basic block that corresponds to the entry point of a
2250 * function.
2251 *
2252 * @see llvm::Function::getEntryBlock()
2253 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002254LLVMBasicBlockRef LLVMGetEntryBasicBlock(LLVMValueRef Fn);
Erick Tryzelaar262332f2009-08-14 00:01:31 +00002255
Gregory Szorc34c863a2012-03-21 03:54:29 +00002256/**
2257 * Append a basic block to the end of a function.
2258 *
2259 * @see llvm::BasicBlock::Create()
2260 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +00002261LLVMBasicBlockRef LLVMAppendBasicBlockInContext(LLVMContextRef C,
2262 LLVMValueRef Fn,
2263 const char *Name);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002264
2265/**
2266 * Append a basic block to the end of a function using the global
2267 * context.
2268 *
2269 * @see llvm::BasicBlock::Create()
2270 */
2271LLVMBasicBlockRef LLVMAppendBasicBlock(LLVMValueRef Fn, const char *Name);
2272
2273/**
2274 * Insert a basic block in a function before another basic block.
2275 *
2276 * The function to add to is determined by the function of the
2277 * passed basic block.
2278 *
2279 * @see llvm::BasicBlock::Create()
2280 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +00002281LLVMBasicBlockRef LLVMInsertBasicBlockInContext(LLVMContextRef C,
2282 LLVMBasicBlockRef BB,
2283 const char *Name);
2284
Gregory Szorc34c863a2012-03-21 03:54:29 +00002285/**
2286 * Insert a basic block in a function using the global context.
2287 *
2288 * @see llvm::BasicBlock::Create()
2289 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002290LLVMBasicBlockRef LLVMInsertBasicBlock(LLVMBasicBlockRef InsertBeforeBB,
2291 const char *Name);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002292
2293/**
2294 * Remove a basic block from a function and delete it.
2295 *
2296 * This deletes the basic block from its containing function and deletes
2297 * the basic block itself.
2298 *
2299 * @see llvm::BasicBlock::eraseFromParent()
2300 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002301void LLVMDeleteBasicBlock(LLVMBasicBlockRef BB);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002302
2303/**
2304 * Remove a basic block from a function.
2305 *
2306 * This deletes the basic block from its containing function but keep
2307 * the basic block alive.
2308 *
2309 * @see llvm::BasicBlock::removeFromParent()
2310 */
Nate Begeman43c322b2011-08-23 20:27:46 +00002311void LLVMRemoveBasicBlockFromParent(LLVMBasicBlockRef BB);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002312
Gregory Szorc34c863a2012-03-21 03:54:29 +00002313/**
2314 * Move a basic block to before another one.
2315 *
2316 * @see llvm::BasicBlock::moveBefore()
2317 */
Duncan Sandsb1d61aa2010-07-19 15:31:07 +00002318void LLVMMoveBasicBlockBefore(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002319
2320/**
2321 * Move a basic block to after another one.
2322 *
2323 * @see llvm::BasicBlock::moveAfter()
2324 */
Duncan Sandsb1d61aa2010-07-19 15:31:07 +00002325void LLVMMoveBasicBlockAfter(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos);
2326
Gregory Szorc34c863a2012-03-21 03:54:29 +00002327/**
2328 * Obtain the first instruction in a basic block.
2329 *
2330 * The returned LLVMValueRef corresponds to a llvm::Instruction
2331 * instance.
2332 */
Gordon Henriksen054817c2008-03-19 03:47:18 +00002333LLVMValueRef LLVMGetFirstInstruction(LLVMBasicBlockRef BB);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002334
2335/**
2336 * Obtain the last instruction in a basic block.
2337 *
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00002338 * The returned LLVMValueRef corresponds to an LLVM:Instruction.
Gregory Szorc34c863a2012-03-21 03:54:29 +00002339 */
Gordon Henriksen054817c2008-03-19 03:47:18 +00002340LLVMValueRef LLVMGetLastInstruction(LLVMBasicBlockRef BB);
Nate Begeman43c322b2011-08-23 20:27:46 +00002341
Gregory Szorc34c863a2012-03-21 03:54:29 +00002342/**
2343 * @}
2344 */
2345
2346/**
2347 * @defgroup LLVMCCoreValueInstruction Instructions
2348 *
2349 * Functions in this group relate to the inspection and manipulation of
2350 * individual instructions.
2351 *
2352 * In the C++ API, an instruction is modeled by llvm::Instruction. This
2353 * class has a large number of descendents. llvm::Instruction is a
2354 * llvm::Value and in the C API, instructions are modeled by
2355 * LLVMValueRef.
2356 *
2357 * This group also contains sub-groups which operate on specific
2358 * llvm::Instruction types, e.g. llvm::CallInst.
2359 *
2360 * @{
2361 */
2362
2363/**
2364 * Determine whether an instruction has any metadata attached.
2365 */
2366int LLVMHasMetadata(LLVMValueRef Val);
2367
2368/**
2369 * Return metadata associated with an instruction value.
2370 */
2371LLVMValueRef LLVMGetMetadata(LLVMValueRef Val, unsigned KindID);
2372
2373/**
2374 * Set metadata associated with an instruction value.
2375 */
2376void LLVMSetMetadata(LLVMValueRef Val, unsigned KindID, LLVMValueRef Node);
2377
2378/**
2379 * Obtain the basic block to which an instruction belongs.
2380 *
2381 * @see llvm::Instruction::getParent()
2382 */
Nate Begeman43c322b2011-08-23 20:27:46 +00002383LLVMBasicBlockRef LLVMGetInstructionParent(LLVMValueRef Inst);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002384
2385/**
2386 * Obtain the instruction that occurs after the one specified.
2387 *
2388 * The next instruction will be from the same basic block.
2389 *
2390 * If this is the last instruction in a basic block, NULL will be
2391 * returned.
2392 */
Gordon Henriksen054817c2008-03-19 03:47:18 +00002393LLVMValueRef LLVMGetNextInstruction(LLVMValueRef Inst);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002394
2395/**
Benjamin Kramerbde91762012-06-02 10:20:22 +00002396 * Obtain the instruction that occurred before this one.
Gregory Szorc34c863a2012-03-21 03:54:29 +00002397 *
2398 * If the instruction is the first instruction in a basic block, NULL
2399 * will be returned.
2400 */
Gordon Henriksen054817c2008-03-19 03:47:18 +00002401LLVMValueRef LLVMGetPreviousInstruction(LLVMValueRef Inst);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002402
2403/**
2404 * Remove and delete an instruction.
2405 *
2406 * The instruction specified is removed from its containing building
Amaury Sechet2f432082016-02-11 21:37:54 +00002407 * block but is kept alive.
2408 *
2409 * @see llvm::Instruction::removeFromParent()
2410 */
2411void LLVMInstructionRemoveFromParent(LLVMValueRef Inst);
2412
2413/**
2414 * Remove and delete an instruction.
2415 *
2416 * The instruction specified is removed from its containing building
Gregory Szorc34c863a2012-03-21 03:54:29 +00002417 * block and then deleted.
2418 *
2419 * @see llvm::Instruction::eraseFromParent()
2420 */
Devang Pateldbebc6f2011-10-03 20:59:18 +00002421void LLVMInstructionEraseFromParent(LLVMValueRef Inst);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002422
2423/**
2424 * Obtain the code opcode for an individual instruction.
2425 *
2426 * @see llvm::Instruction::getOpCode()
2427 */
Eric Christophera6b96002015-12-18 01:46:52 +00002428LLVMOpcode LLVMGetInstructionOpcode(LLVMValueRef Inst);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002429
2430/**
2431 * Obtain the predicate of an instruction.
2432 *
2433 * This is only valid for instructions that correspond to llvm::ICmpInst
2434 * or llvm::ConstantExpr whose opcode is llvm::Instruction::ICmp.
2435 *
2436 * @see llvm::ICmpInst::getPredicate()
2437 */
Torok Edwin60c40de2011-10-06 12:13:20 +00002438LLVMIntPredicate LLVMGetICmpPredicate(LLVMValueRef Inst);
Gordon Henriksen265f7802008-03-19 01:11:35 +00002439
Gregory Szorc34c863a2012-03-21 03:54:29 +00002440/**
Peter Zotov1d98e6d2014-10-28 19:46:44 +00002441 * Obtain the float predicate of an instruction.
2442 *
2443 * This is only valid for instructions that correspond to llvm::FCmpInst
2444 * or llvm::ConstantExpr whose opcode is llvm::Instruction::FCmp.
2445 *
2446 * @see llvm::FCmpInst::getPredicate()
2447 */
2448LLVMRealPredicate LLVMGetFCmpPredicate(LLVMValueRef Inst);
2449
2450/**
Peter Zotovaff492c2014-10-17 01:02:34 +00002451 * Create a copy of 'this' instruction that is identical in all ways
2452 * except the following:
2453 * * The instruction has no parent
2454 * * The instruction has no name
2455 *
2456 * @see llvm::Instruction::clone()
2457 */
2458LLVMValueRef LLVMInstructionClone(LLVMValueRef Inst);
2459
2460/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002461 * @defgroup LLVMCCoreValueInstructionCall Call Sites and Invocations
2462 *
2463 * Functions in this group apply to instructions that refer to call
2464 * sites and invocations. These correspond to C++ types in the
2465 * llvm::CallInst class tree.
2466 *
2467 * @{
2468 */
2469
2470/**
Amaury Sechet5c7b3af2016-02-10 00:09:37 +00002471 * Obtain the argument count for a call instruction.
2472 *
2473 * This expects an LLVMValueRef that corresponds to a llvm::CallInst or
2474 * llvm::InvokeInst.
2475 *
2476 * @see llvm::CallInst::getNumArgOperands()
2477 * @see llvm::InvokeInst::getNumArgOperands()
2478 */
2479unsigned LLVMGetNumArgOperands(LLVMValueRef Instr);
2480
2481/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002482 * Set the calling convention for a call instruction.
2483 *
2484 * This expects an LLVMValueRef that corresponds to a llvm::CallInst or
2485 * llvm::InvokeInst.
2486 *
2487 * @see llvm::CallInst::setCallingConv()
2488 * @see llvm::InvokeInst::setCallingConv()
2489 */
Gordon Henriksen1158c532007-12-29 20:45:00 +00002490void LLVMSetInstructionCallConv(LLVMValueRef Instr, unsigned CC);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002491
2492/**
2493 * Obtain the calling convention for a call instruction.
2494 *
2495 * This is the opposite of LLVMSetInstructionCallConv(). Reads its
2496 * usage.
2497 *
2498 * @see LLVMSetInstructionCallConv()
2499 */
Gordon Henriksen1158c532007-12-29 20:45:00 +00002500unsigned LLVMGetInstructionCallConv(LLVMValueRef Instr);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002501
2502
Devang Patel4c758ea2008-09-25 21:00:45 +00002503void LLVMAddInstrAttribute(LLVMValueRef Instr, unsigned index, LLVMAttribute);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002504void LLVMRemoveInstrAttribute(LLVMValueRef Instr, unsigned index,
Devang Patel4c758ea2008-09-25 21:00:45 +00002505 LLVMAttribute);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002506void LLVMSetInstrParamAlignment(LLVMValueRef Instr, unsigned index,
Gordon Henriksen2d9cc212008-04-28 17:37:06 +00002507 unsigned align);
Gordon Henriksen1158c532007-12-29 20:45:00 +00002508
Gregory Szorc34c863a2012-03-21 03:54:29 +00002509/**
Amaury Sechet5c7b3af2016-02-10 00:09:37 +00002510 * Obtain the pointer to the function invoked by this instruction.
2511 *
2512 * This expects an LLVMValueRef that corresponds to a llvm::CallInst or
2513 * llvm::InvokeInst.
2514 *
2515 * @see llvm::CallInst::getCalledValue()
2516 * @see llvm::InvokeInst::getCalledValue()
2517 */
2518LLVMValueRef LLVMGetCalledValue(LLVMValueRef Instr);
2519
2520/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002521 * Obtain whether a call instruction is a tail call.
2522 *
2523 * This only works on llvm::CallInst instructions.
2524 *
2525 * @see llvm::CallInst::isTailCall()
2526 */
Chris Lattner25963c62010-01-09 22:27:07 +00002527LLVMBool LLVMIsTailCall(LLVMValueRef CallInst);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002528
2529/**
2530 * Set whether a call instruction is a tail call.
2531 *
2532 * This only works on llvm::CallInst instructions.
2533 *
2534 * @see llvm::CallInst::setTailCall()
2535 */
Chris Lattner25963c62010-01-09 22:27:07 +00002536void LLVMSetTailCall(LLVMValueRef CallInst, LLVMBool IsTailCall);
Gordon Henrikseneeb65372008-08-30 16:34:54 +00002537
Gregory Szorc34c863a2012-03-21 03:54:29 +00002538/**
Amaury Sechete39e8532016-02-18 20:38:32 +00002539 * Return the normal destination basic block.
2540 *
2541 * This only works on llvm::InvokeInst instructions.
2542 *
2543 * @see llvm::InvokeInst::getNormalDest()
2544 */
2545LLVMBasicBlockRef LLVMGetNormalDest(LLVMValueRef InvokeInst);
2546
2547/**
2548 * Return the unwind destination basic block.
2549 *
2550 * This only works on llvm::InvokeInst instructions.
2551 *
2552 * @see llvm::InvokeInst::getUnwindDest()
2553 */
2554LLVMBasicBlockRef LLVMGetUnwindDest(LLVMValueRef InvokeInst);
2555
2556/**
2557 * Set the normal destination basic block.
2558 *
2559 * This only works on llvm::InvokeInst instructions.
2560 *
2561 * @see llvm::InvokeInst::setNormalDest()
2562 */
2563void LLVMSetNormalDest(LLVMValueRef InvokeInst, LLVMBasicBlockRef B);
2564
2565/**
2566 * Set the unwind destination basic block.
2567 *
2568 * This only works on llvm::InvokeInst instructions.
2569 *
2570 * @see llvm::InvokeInst::setUnwindDest()
2571 */
2572void LLVMSetUnwindDest(LLVMValueRef InvokeInst, LLVMBasicBlockRef B);
2573
2574/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002575 * @}
2576 */
2577
2578/**
Peter Zotov2481c752014-10-28 19:46:56 +00002579 * @defgroup LLVMCCoreValueInstructionTerminator Terminators
2580 *
2581 * Functions in this group only apply to instructions that map to
2582 * llvm::TerminatorInst instances.
2583 *
2584 * @{
2585 */
2586
2587/**
2588 * Return the number of successors that this terminator has.
2589 *
2590 * @see llvm::TerminatorInst::getNumSuccessors
2591 */
2592unsigned LLVMGetNumSuccessors(LLVMValueRef Term);
2593
2594/**
2595 * Return the specified successor.
2596 *
2597 * @see llvm::TerminatorInst::getSuccessor
2598 */
2599LLVMBasicBlockRef LLVMGetSuccessor(LLVMValueRef Term, unsigned i);
2600
2601/**
2602 * Update the specified successor to point at the provided block.
2603 *
2604 * @see llvm::TerminatorInst::setSuccessor
2605 */
2606void LLVMSetSuccessor(LLVMValueRef Term, unsigned i, LLVMBasicBlockRef block);
2607
2608/**
2609 * Return if a branch is conditional.
2610 *
2611 * This only works on llvm::BranchInst instructions.
2612 *
2613 * @see llvm::BranchInst::isConditional
2614 */
2615LLVMBool LLVMIsConditional(LLVMValueRef Branch);
2616
2617/**
2618 * Return the condition of a branch instruction.
2619 *
2620 * This only works on llvm::BranchInst instructions.
2621 *
2622 * @see llvm::BranchInst::getCondition
2623 */
2624LLVMValueRef LLVMGetCondition(LLVMValueRef Branch);
2625
2626/**
2627 * Set the condition of a branch instruction.
2628 *
2629 * This only works on llvm::BranchInst instructions.
2630 *
2631 * @see llvm::BranchInst::setCondition
2632 */
2633void LLVMSetCondition(LLVMValueRef Branch, LLVMValueRef Cond);
2634
2635/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002636 * Obtain the default destination basic block of a switch instruction.
2637 *
2638 * This only works on llvm::SwitchInst instructions.
2639 *
2640 * @see llvm::SwitchInst::getDefaultDest()
2641 */
Nate Begeman43c322b2011-08-23 20:27:46 +00002642LLVMBasicBlockRef LLVMGetSwitchDefaultDest(LLVMValueRef SwitchInstr);
2643
Gregory Szorc34c863a2012-03-21 03:54:29 +00002644/**
Peter Zotov2481c752014-10-28 19:46:56 +00002645 * @}
2646 */
2647
2648/**
Amaury Sechet1dcf5772016-02-09 22:50:53 +00002649 * @defgroup LLVMCCoreValueInstructionAlloca Allocas
2650 *
2651 * Functions in this group only apply to instructions that map to
2652 * llvm::AllocaInst instances.
2653 *
2654 * @{
2655 */
2656
2657/**
2658 * Obtain the type that is being allocated by the alloca instruction.
2659 */
2660LLVMTypeRef LLVMGetAllocatedType(LLVMValueRef Alloca);
2661
2662/**
2663 * @}
2664 */
2665
2666/**
Amaury Sechet053ac452016-02-17 22:51:03 +00002667 * @defgroup LLVMCCoreValueInstructionGetElementPointer GEPs
2668 *
2669 * Functions in this group only apply to instructions that map to
2670 * llvm::GetElementPtrInst instances.
2671 *
2672 * @{
2673 */
2674
2675/**
2676 * Check whether the given GEP instruction is inbounds.
2677 */
2678LLVMBool LLVMIsInBounds(LLVMValueRef GEP);
2679
2680/**
2681 * Set the given GEP instruction to be inbounds or not.
2682 */
2683void LLVMSetIsInBounds(LLVMValueRef GEP, LLVMBool b);
2684
2685/**
2686 * @}
2687 */
2688
2689/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002690 * @defgroup LLVMCCoreValueInstructionPHINode PHI Nodes
2691 *
2692 * Functions in this group only apply to instructions that map to
2693 * llvm::PHINode instances.
2694 *
2695 * @{
2696 */
2697
2698/**
2699 * Add an incoming value to the end of a PHI list.
2700 */
Gordon Henriksen44dd8fb2007-10-08 18:14:39 +00002701void LLVMAddIncoming(LLVMValueRef PhiNode, LLVMValueRef *IncomingValues,
2702 LLVMBasicBlockRef *IncomingBlocks, unsigned Count);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002703
2704/**
2705 * Obtain the number of incoming basic blocks to a PHI node.
2706 */
Gordon Henriksen44dd8fb2007-10-08 18:14:39 +00002707unsigned LLVMCountIncoming(LLVMValueRef PhiNode);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002708
2709/**
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00002710 * Obtain an incoming value to a PHI node as an LLVMValueRef.
Gregory Szorc34c863a2012-03-21 03:54:29 +00002711 */
Gordon Henriksen44dd8fb2007-10-08 18:14:39 +00002712LLVMValueRef LLVMGetIncomingValue(LLVMValueRef PhiNode, unsigned Index);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002713
2714/**
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00002715 * Obtain an incoming value to a PHI node as an LLVMBasicBlockRef.
Gregory Szorc34c863a2012-03-21 03:54:29 +00002716 */
Gordon Henriksen44dd8fb2007-10-08 18:14:39 +00002717LLVMBasicBlockRef LLVMGetIncomingBlock(LLVMValueRef PhiNode, unsigned Index);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002718
Gregory Szorc34c863a2012-03-21 03:54:29 +00002719/**
2720 * @}
2721 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002722
Gregory Szorc34c863a2012-03-21 03:54:29 +00002723/**
Amaury Sechetaad93532016-02-10 00:38:50 +00002724 * @defgroup LLVMCCoreValueInstructionExtractValue ExtractValue
2725 * @defgroup LLVMCCoreValueInstructionInsertValue InsertValue
2726 *
2727 * Functions in this group only apply to instructions that map to
2728 * llvm::ExtractValue and llvm::InsertValue instances.
2729 *
2730 * @{
2731 */
2732
2733/**
2734 * Obtain the number of indices.
Amaury Sechet053ac452016-02-17 22:51:03 +00002735 * NB: This also works on GEP.
Amaury Sechetaad93532016-02-10 00:38:50 +00002736 */
2737unsigned LLVMGetNumIndices(LLVMValueRef Inst);
2738
2739/**
2740 * Obtain the indices as an array.
2741 */
2742const unsigned *LLVMGetIndices(LLVMValueRef Inst);
2743
2744/**
2745 * @}
2746 */
2747
2748/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002749 * @}
2750 */
2751
2752/**
2753 * @}
2754 */
2755
2756/**
2757 * @defgroup LLVMCCoreInstructionBuilder Instruction Builders
2758 *
2759 * An instruction builder represents a point within a basic block and is
2760 * the exclusive means of building instructions using the C interface.
2761 *
2762 * @{
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002763 */
2764
Erick Tryzelaar262332f2009-08-14 00:01:31 +00002765LLVMBuilderRef LLVMCreateBuilderInContext(LLVMContextRef C);
Gordon Henriksena735a9c2008-05-04 12:55:34 +00002766LLVMBuilderRef LLVMCreateBuilder(void);
Gordon Henriksen054817c2008-03-19 03:47:18 +00002767void LLVMPositionBuilder(LLVMBuilderRef Builder, LLVMBasicBlockRef Block,
2768 LLVMValueRef Instr);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002769void LLVMPositionBuilderBefore(LLVMBuilderRef Builder, LLVMValueRef Instr);
2770void LLVMPositionBuilderAtEnd(LLVMBuilderRef Builder, LLVMBasicBlockRef Block);
Gordon Henriksen265f7802008-03-19 01:11:35 +00002771LLVMBasicBlockRef LLVMGetInsertBlock(LLVMBuilderRef Builder);
Chris Lattner3d1f5522008-12-17 21:39:50 +00002772void LLVMClearInsertionPosition(LLVMBuilderRef Builder);
2773void LLVMInsertIntoBuilder(LLVMBuilderRef Builder, LLVMValueRef Instr);
Erick Tryzelaar9813bea2009-08-16 02:20:57 +00002774void LLVMInsertIntoBuilderWithName(LLVMBuilderRef Builder, LLVMValueRef Instr,
2775 const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002776void LLVMDisposeBuilder(LLVMBuilderRef Builder);
2777
Erick Tryzelaard8531fa2010-02-28 09:45:59 +00002778/* Metadata */
2779void LLVMSetCurrentDebugLocation(LLVMBuilderRef Builder, LLVMValueRef L);
2780LLVMValueRef LLVMGetCurrentDebugLocation(LLVMBuilderRef Builder);
2781void LLVMSetInstDebugLocation(LLVMBuilderRef Builder, LLVMValueRef Inst);
2782
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002783/* Terminators */
2784LLVMValueRef LLVMBuildRetVoid(LLVMBuilderRef);
2785LLVMValueRef LLVMBuildRet(LLVMBuilderRef, LLVMValueRef V);
Erick Tryzelaarfd529d72009-08-19 08:36:49 +00002786LLVMValueRef LLVMBuildAggregateRet(LLVMBuilderRef, LLVMValueRef *RetVals,
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002787 unsigned N);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002788LLVMValueRef LLVMBuildBr(LLVMBuilderRef, LLVMBasicBlockRef Dest);
2789LLVMValueRef LLVMBuildCondBr(LLVMBuilderRef, LLVMValueRef If,
2790 LLVMBasicBlockRef Then, LLVMBasicBlockRef Else);
2791LLVMValueRef LLVMBuildSwitch(LLVMBuilderRef, LLVMValueRef V,
2792 LLVMBasicBlockRef Else, unsigned NumCases);
Erick Tryzelaar0fb26ef2010-02-28 09:46:06 +00002793LLVMValueRef LLVMBuildIndirectBr(LLVMBuilderRef B, LLVMValueRef Addr,
2794 unsigned NumDests);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002795LLVMValueRef LLVMBuildInvoke(LLVMBuilderRef, LLVMValueRef Fn,
2796 LLVMValueRef *Args, unsigned NumArgs,
2797 LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch,
2798 const char *Name);
Benjamin Kramer5a6568832011-08-19 01:36:54 +00002799LLVMValueRef LLVMBuildLandingPad(LLVMBuilderRef B, LLVMTypeRef Ty,
Reid Kleckneref9828f2015-07-16 01:16:39 +00002800 LLVMValueRef PersFn, unsigned NumClauses,
2801 const char *Name);
Bill Wendlingf891bf82011-07-31 06:30:59 +00002802LLVMValueRef LLVMBuildResume(LLVMBuilderRef B, LLVMValueRef Exn);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002803LLVMValueRef LLVMBuildUnreachable(LLVMBuilderRef);
2804
Gordon Henriksen097102c2008-01-01 05:50:53 +00002805/* Add a case to the switch instruction */
2806void LLVMAddCase(LLVMValueRef Switch, LLVMValueRef OnVal,
2807 LLVMBasicBlockRef Dest);
2808
Erick Tryzelaar0fb26ef2010-02-28 09:46:06 +00002809/* Add a destination to the indirectbr instruction */
2810void LLVMAddDestination(LLVMValueRef IndirectBr, LLVMBasicBlockRef Dest);
2811
Amaury Sechete39e8532016-02-18 20:38:32 +00002812/* Get the number of clauses on the landingpad instruction */
2813unsigned LLVMGetNumClauses(LLVMValueRef LandingPad);
2814
2815/* Get the value of the clause at idnex Idx on the landingpad instruction */
2816LLVMValueRef LLVMGetClause(LLVMValueRef LandingPad, unsigned Idx);
2817
Bill Wendlingfae14752011-08-12 20:24:12 +00002818/* Add a catch or filter clause to the landingpad instruction */
2819void LLVMAddClause(LLVMValueRef LandingPad, LLVMValueRef ClauseVal);
2820
Amaury Sechete39e8532016-02-18 20:38:32 +00002821/* Get the 'cleanup' flag in the landingpad instruction */
2822LLVMBool LLVMIsCleanup(LLVMValueRef LandingPad);
2823
Bill Wendlingfae14752011-08-12 20:24:12 +00002824/* Set the 'cleanup' flag in the landingpad instruction */
2825void LLVMSetCleanup(LLVMValueRef LandingPad, LLVMBool Val);
2826
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002827/* Arithmetic */
2828LLVMValueRef LLVMBuildAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2829 const char *Name);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002830LLVMValueRef LLVMBuildNSWAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2831 const char *Name);
Erick Tryzelaar4c340c72010-02-28 05:51:43 +00002832LLVMValueRef LLVMBuildNUWAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2833 const char *Name);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002834LLVMValueRef LLVMBuildFAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2835 const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002836LLVMValueRef LLVMBuildSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2837 const char *Name);
Erick Tryzelaar4c340c72010-02-28 05:51:43 +00002838LLVMValueRef LLVMBuildNSWSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2839 const char *Name);
2840LLVMValueRef LLVMBuildNUWSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2841 const char *Name);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002842LLVMValueRef LLVMBuildFSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2843 const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002844LLVMValueRef LLVMBuildMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2845 const char *Name);
Erick Tryzelaar4c340c72010-02-28 05:51:43 +00002846LLVMValueRef LLVMBuildNSWMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2847 const char *Name);
2848LLVMValueRef LLVMBuildNUWMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2849 const char *Name);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002850LLVMValueRef LLVMBuildFMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2851 const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002852LLVMValueRef LLVMBuildUDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2853 const char *Name);
2854LLVMValueRef LLVMBuildSDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2855 const char *Name);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002856LLVMValueRef LLVMBuildExactSDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2857 const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002858LLVMValueRef LLVMBuildFDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2859 const char *Name);
2860LLVMValueRef LLVMBuildURem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2861 const char *Name);
2862LLVMValueRef LLVMBuildSRem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2863 const char *Name);
2864LLVMValueRef LLVMBuildFRem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2865 const char *Name);
2866LLVMValueRef LLVMBuildShl(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2867 const char *Name);
2868LLVMValueRef LLVMBuildLShr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2869 const char *Name);
2870LLVMValueRef LLVMBuildAShr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2871 const char *Name);
2872LLVMValueRef LLVMBuildAnd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2873 const char *Name);
2874LLVMValueRef LLVMBuildOr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2875 const char *Name);
2876LLVMValueRef LLVMBuildXor(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2877 const char *Name);
Erick Tryzelaar31831792010-02-28 05:51:27 +00002878LLVMValueRef LLVMBuildBinOp(LLVMBuilderRef B, LLVMOpcode Op,
2879 LLVMValueRef LHS, LLVMValueRef RHS,
2880 const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002881LLVMValueRef LLVMBuildNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name);
Erick Tryzelaar4c340c72010-02-28 05:51:43 +00002882LLVMValueRef LLVMBuildNSWNeg(LLVMBuilderRef B, LLVMValueRef V,
2883 const char *Name);
2884LLVMValueRef LLVMBuildNUWNeg(LLVMBuilderRef B, LLVMValueRef V,
2885 const char *Name);
Dan Gohmanf919bd62009-09-28 21:51:41 +00002886LLVMValueRef LLVMBuildFNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002887LLVMValueRef LLVMBuildNot(LLVMBuilderRef, LLVMValueRef V, const char *Name);
2888
2889/* Memory */
2890LLVMValueRef LLVMBuildMalloc(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
2891LLVMValueRef LLVMBuildArrayMalloc(LLVMBuilderRef, LLVMTypeRef Ty,
2892 LLVMValueRef Val, const char *Name);
2893LLVMValueRef LLVMBuildAlloca(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
2894LLVMValueRef LLVMBuildArrayAlloca(LLVMBuilderRef, LLVMTypeRef Ty,
2895 LLVMValueRef Val, const char *Name);
2896LLVMValueRef LLVMBuildFree(LLVMBuilderRef, LLVMValueRef PointerVal);
2897LLVMValueRef LLVMBuildLoad(LLVMBuilderRef, LLVMValueRef PointerVal,
2898 const char *Name);
2899LLVMValueRef LLVMBuildStore(LLVMBuilderRef, LLVMValueRef Val, LLVMValueRef Ptr);
2900LLVMValueRef LLVMBuildGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
2901 LLVMValueRef *Indices, unsigned NumIndices,
2902 const char *Name);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002903LLVMValueRef LLVMBuildInBoundsGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
2904 LLVMValueRef *Indices, unsigned NumIndices,
2905 const char *Name);
2906LLVMValueRef LLVMBuildStructGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
2907 unsigned Idx, const char *Name);
2908LLVMValueRef LLVMBuildGlobalString(LLVMBuilderRef B, const char *Str,
2909 const char *Name);
2910LLVMValueRef LLVMBuildGlobalStringPtr(LLVMBuilderRef B, const char *Str,
2911 const char *Name);
Chris Lattner2cc6f9d2012-03-22 03:54:15 +00002912LLVMBool LLVMGetVolatile(LLVMValueRef MemoryAccessInst);
2913void LLVMSetVolatile(LLVMValueRef MemoryAccessInst, LLVMBool IsVolatile);
Andrew Wilkinsb7362ce2015-08-02 12:16:57 +00002914LLVMAtomicOrdering LLVMGetOrdering(LLVMValueRef MemoryAccessInst);
2915void LLVMSetOrdering(LLVMValueRef MemoryAccessInst, LLVMAtomicOrdering Ordering);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002916
2917/* Casts */
2918LLVMValueRef LLVMBuildTrunc(LLVMBuilderRef, LLVMValueRef Val,
2919 LLVMTypeRef DestTy, const char *Name);
2920LLVMValueRef LLVMBuildZExt(LLVMBuilderRef, LLVMValueRef Val,
2921 LLVMTypeRef DestTy, const char *Name);
2922LLVMValueRef LLVMBuildSExt(LLVMBuilderRef, LLVMValueRef Val,
2923 LLVMTypeRef DestTy, const char *Name);
2924LLVMValueRef LLVMBuildFPToUI(LLVMBuilderRef, LLVMValueRef Val,
2925 LLVMTypeRef DestTy, const char *Name);
2926LLVMValueRef LLVMBuildFPToSI(LLVMBuilderRef, LLVMValueRef Val,
2927 LLVMTypeRef DestTy, const char *Name);
2928LLVMValueRef LLVMBuildUIToFP(LLVMBuilderRef, LLVMValueRef Val,
2929 LLVMTypeRef DestTy, const char *Name);
2930LLVMValueRef LLVMBuildSIToFP(LLVMBuilderRef, LLVMValueRef Val,
2931 LLVMTypeRef DestTy, const char *Name);
2932LLVMValueRef LLVMBuildFPTrunc(LLVMBuilderRef, LLVMValueRef Val,
2933 LLVMTypeRef DestTy, const char *Name);
2934LLVMValueRef LLVMBuildFPExt(LLVMBuilderRef, LLVMValueRef Val,
2935 LLVMTypeRef DestTy, const char *Name);
2936LLVMValueRef LLVMBuildPtrToInt(LLVMBuilderRef, LLVMValueRef Val,
2937 LLVMTypeRef DestTy, const char *Name);
2938LLVMValueRef LLVMBuildIntToPtr(LLVMBuilderRef, LLVMValueRef Val,
2939 LLVMTypeRef DestTy, const char *Name);
2940LLVMValueRef LLVMBuildBitCast(LLVMBuilderRef, LLVMValueRef Val,
2941 LLVMTypeRef DestTy, const char *Name);
Matt Arsenaultb03bd4d2013-11-15 01:34:59 +00002942LLVMValueRef LLVMBuildAddrSpaceCast(LLVMBuilderRef, LLVMValueRef Val,
2943 LLVMTypeRef DestTy, const char *Name);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002944LLVMValueRef LLVMBuildZExtOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
2945 LLVMTypeRef DestTy, const char *Name);
2946LLVMValueRef LLVMBuildSExtOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
2947 LLVMTypeRef DestTy, const char *Name);
2948LLVMValueRef LLVMBuildTruncOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
2949 LLVMTypeRef DestTy, const char *Name);
Erick Tryzelaar31831792010-02-28 05:51:27 +00002950LLVMValueRef LLVMBuildCast(LLVMBuilderRef B, LLVMOpcode Op, LLVMValueRef Val,
2951 LLVMTypeRef DestTy, const char *Name);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002952LLVMValueRef LLVMBuildPointerCast(LLVMBuilderRef, LLVMValueRef Val,
2953 LLVMTypeRef DestTy, const char *Name);
Duncan Sands9d786d72009-11-23 10:49:03 +00002954LLVMValueRef LLVMBuildIntCast(LLVMBuilderRef, LLVMValueRef Val, /*Signed cast!*/
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002955 LLVMTypeRef DestTy, const char *Name);
2956LLVMValueRef LLVMBuildFPCast(LLVMBuilderRef, LLVMValueRef Val,
2957 LLVMTypeRef DestTy, const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002958
2959/* Comparisons */
2960LLVMValueRef LLVMBuildICmp(LLVMBuilderRef, LLVMIntPredicate Op,
2961 LLVMValueRef LHS, LLVMValueRef RHS,
2962 const char *Name);
2963LLVMValueRef LLVMBuildFCmp(LLVMBuilderRef, LLVMRealPredicate Op,
2964 LLVMValueRef LHS, LLVMValueRef RHS,
2965 const char *Name);
2966
2967/* Miscellaneous instructions */
2968LLVMValueRef LLVMBuildPhi(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
2969LLVMValueRef LLVMBuildCall(LLVMBuilderRef, LLVMValueRef Fn,
2970 LLVMValueRef *Args, unsigned NumArgs,
2971 const char *Name);
2972LLVMValueRef LLVMBuildSelect(LLVMBuilderRef, LLVMValueRef If,
2973 LLVMValueRef Then, LLVMValueRef Else,
2974 const char *Name);
2975LLVMValueRef LLVMBuildVAArg(LLVMBuilderRef, LLVMValueRef List, LLVMTypeRef Ty,
2976 const char *Name);
2977LLVMValueRef LLVMBuildExtractElement(LLVMBuilderRef, LLVMValueRef VecVal,
2978 LLVMValueRef Index, const char *Name);
2979LLVMValueRef LLVMBuildInsertElement(LLVMBuilderRef, LLVMValueRef VecVal,
2980 LLVMValueRef EltVal, LLVMValueRef Index,
2981 const char *Name);
2982LLVMValueRef LLVMBuildShuffleVector(LLVMBuilderRef, LLVMValueRef V1,
2983 LLVMValueRef V2, LLVMValueRef Mask,
2984 const char *Name);
Dan Gohmand5104a52008-11-03 22:55:43 +00002985LLVMValueRef LLVMBuildExtractValue(LLVMBuilderRef, LLVMValueRef AggVal,
2986 unsigned Index, const char *Name);
2987LLVMValueRef LLVMBuildInsertValue(LLVMBuilderRef, LLVMValueRef AggVal,
2988 LLVMValueRef EltVal, unsigned Index,
2989 const char *Name);
Gordon Henriksen76a03742007-09-18 03:18:57 +00002990
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002991LLVMValueRef LLVMBuildIsNull(LLVMBuilderRef, LLVMValueRef Val,
2992 const char *Name);
2993LLVMValueRef LLVMBuildIsNotNull(LLVMBuilderRef, LLVMValueRef Val,
2994 const char *Name);
2995LLVMValueRef LLVMBuildPtrDiff(LLVMBuilderRef, LLVMValueRef LHS,
2996 LLVMValueRef RHS, const char *Name);
Filip Pizlo0d3f7ec2013-11-20 00:07:49 +00002997LLVMValueRef LLVMBuildFence(LLVMBuilderRef B, LLVMAtomicOrdering ordering,
2998 LLVMBool singleThread, const char *Name);
2999LLVMValueRef LLVMBuildAtomicRMW(LLVMBuilderRef B, LLVMAtomicRMWBinOp op,
NAKAMURA Takumia3a81352013-10-23 17:56:29 +00003000 LLVMValueRef PTR, LLVMValueRef Val,
3001 LLVMAtomicOrdering ordering,
Carlo Kok8c6719b2013-04-23 13:21:19 +00003002 LLVMBool singleThread);
Mehdi Amini43165d92016-03-19 21:28:28 +00003003LLVMValueRef LLVMBuildAtomicCmpXchg(LLVMBuilderRef B, LLVMValueRef Ptr,
3004 LLVMValueRef Cmp, LLVMValueRef New,
3005 LLVMAtomicOrdering SuccessOrdering,
3006 LLVMAtomicOrdering FailureOrdering,
3007 LLVMBool SingleThread);
3008
3009LLVMBool LLVMIsAtomicSingleThread(LLVMValueRef AtomicInst);
3010void LLVMSetAtomicSingleThread(LLVMValueRef AtomicInst, LLVMBool SingleThread);
3011
3012LLVMAtomicOrdering LLVMGetCmpXchgSuccessOrdering(LLVMValueRef CmpXchgInst);
3013void LLVMSetCmpXchgSuccessOrdering(LLVMValueRef CmpXchgInst,
3014 LLVMAtomicOrdering Ordering);
3015LLVMAtomicOrdering LLVMGetCmpXchgFailureOrdering(LLVMValueRef CmpXchgInst);
3016void LLVMSetCmpXchgFailureOrdering(LLVMValueRef CmpXchgInst,
3017 LLVMAtomicOrdering Ordering);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00003018
Gregory Szorc34c863a2012-03-21 03:54:29 +00003019/**
3020 * @}
3021 */
Gordon Henriksen34eb6d82007-12-19 22:30:40 +00003022
Gregory Szorc34c863a2012-03-21 03:54:29 +00003023/**
3024 * @defgroup LLVMCCoreModuleProvider Module Providers
3025 *
3026 * @{
3027 */
Gordon Henriksen0a68fe22007-12-12 01:04:30 +00003028
Gregory Szorc34c863a2012-03-21 03:54:29 +00003029/**
3030 * Changes the type of M so it can be passed to FunctionPassManagers and the
Jeffrey Yasskin091217b2010-01-27 20:34:15 +00003031 * JIT. They take ModuleProviders for historical reasons.
Gordon Henriksen0a68fe22007-12-12 01:04:30 +00003032 */
3033LLVMModuleProviderRef
3034LLVMCreateModuleProviderForExistingModule(LLVMModuleRef M);
3035
Gregory Szorc34c863a2012-03-21 03:54:29 +00003036/**
3037 * Destroys the module M.
Gordon Henriksen0a68fe22007-12-12 01:04:30 +00003038 */
Jeffrey Yasskin091217b2010-01-27 20:34:15 +00003039void LLVMDisposeModuleProvider(LLVMModuleProviderRef M);
Gordon Henriksen0a68fe22007-12-12 01:04:30 +00003040
Gregory Szorc34c863a2012-03-21 03:54:29 +00003041/**
3042 * @}
3043 */
Gordon Henriksen34eb6d82007-12-19 22:30:40 +00003044
Gregory Szorc34c863a2012-03-21 03:54:29 +00003045/**
3046 * @defgroup LLVMCCoreMemoryBuffers Memory Buffers
3047 *
3048 * @{
3049 */
Gordon Henriksen34eb6d82007-12-19 22:30:40 +00003050
Chris Lattner25963c62010-01-09 22:27:07 +00003051LLVMBool LLVMCreateMemoryBufferWithContentsOfFile(const char *Path,
3052 LLVMMemoryBufferRef *OutMemBuf,
3053 char **OutMessage);
3054LLVMBool LLVMCreateMemoryBufferWithSTDIN(LLVMMemoryBufferRef *OutMemBuf,
3055 char **OutMessage);
Bill Wendling526276a2013-02-14 19:11:28 +00003056LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRange(const char *InputData,
3057 size_t InputDataLength,
3058 const char *BufferName,
Bill Wendlingc9baa962013-02-14 19:39:14 +00003059 LLVMBool RequiresNullTerminator);
Bill Wendling526276a2013-02-14 19:11:28 +00003060LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRangeCopy(const char *InputData,
3061 size_t InputDataLength,
3062 const char *BufferName);
Tom Stellard62c03202013-04-18 19:50:53 +00003063const char *LLVMGetBufferStart(LLVMMemoryBufferRef MemBuf);
Tom Stellardb7fb7242013-04-16 23:12:51 +00003064size_t LLVMGetBufferSize(LLVMMemoryBufferRef MemBuf);
Gordon Henriksen34eb6d82007-12-19 22:30:40 +00003065void LLVMDisposeMemoryBuffer(LLVMMemoryBufferRef MemBuf);
3066
Gregory Szorc34c863a2012-03-21 03:54:29 +00003067/**
3068 * @}
3069 */
3070
3071/**
3072 * @defgroup LLVMCCorePassRegistry Pass Registry
3073 *
3074 * @{
3075 */
Owen Anderson4698c5d2010-10-07 17:55:47 +00003076
3077/** Return the global pass registry, for use with initialization functions.
Gregory Szorc34c863a2012-03-21 03:54:29 +00003078 @see llvm::PassRegistry::getPassRegistry */
Owen Anderson4698c5d2010-10-07 17:55:47 +00003079LLVMPassRegistryRef LLVMGetGlobalPassRegistry(void);
Gordon Henriksen878114b2008-03-16 04:20:44 +00003080
Gregory Szorc34c863a2012-03-21 03:54:29 +00003081/**
3082 * @}
3083 */
3084
3085/**
3086 * @defgroup LLVMCCorePassManagers Pass Managers
3087 *
3088 * @{
3089 */
Gordon Henriksen878114b2008-03-16 04:20:44 +00003090
3091/** Constructs a new whole-module pass pipeline. This type of pipeline is
3092 suitable for link-time optimization and whole-module transformations.
Gregory Szorc34c863a2012-03-21 03:54:29 +00003093 @see llvm::PassManager::PassManager */
Gordon Henriksena735a9c2008-05-04 12:55:34 +00003094LLVMPassManagerRef LLVMCreatePassManager(void);
Gordon Henriksen878114b2008-03-16 04:20:44 +00003095
3096/** Constructs a new function-by-function pass pipeline over the module
3097 provider. It does not take ownership of the module provider. This type of
3098 pipeline is suitable for code generation and JIT compilation tasks.
Gregory Szorc34c863a2012-03-21 03:54:29 +00003099 @see llvm::FunctionPassManager::FunctionPassManager */
Erick Tryzelaarad0e0cb2010-03-02 23:58:54 +00003100LLVMPassManagerRef LLVMCreateFunctionPassManagerForModule(LLVMModuleRef M);
3101
3102/** Deprecated: Use LLVMCreateFunctionPassManagerForModule instead. */
Gordon Henriksen878114b2008-03-16 04:20:44 +00003103LLVMPassManagerRef LLVMCreateFunctionPassManager(LLVMModuleProviderRef MP);
3104
3105/** Initializes, executes on the provided module, and finalizes all of the
3106 passes scheduled in the pass manager. Returns 1 if any of the passes
Gregory Szorc34c863a2012-03-21 03:54:29 +00003107 modified the module, 0 otherwise.
3108 @see llvm::PassManager::run(Module&) */
Chris Lattner25963c62010-01-09 22:27:07 +00003109LLVMBool LLVMRunPassManager(LLVMPassManagerRef PM, LLVMModuleRef M);
Gordon Henriksen878114b2008-03-16 04:20:44 +00003110
3111/** Initializes all of the function passes scheduled in the function pass
3112 manager. Returns 1 if any of the passes modified the module, 0 otherwise.
Gregory Szorc34c863a2012-03-21 03:54:29 +00003113 @see llvm::FunctionPassManager::doInitialization */
Chris Lattner25963c62010-01-09 22:27:07 +00003114LLVMBool LLVMInitializeFunctionPassManager(LLVMPassManagerRef FPM);
Gordon Henriksen878114b2008-03-16 04:20:44 +00003115
3116/** Executes all of the function passes scheduled in the function pass manager
3117 on the provided function. Returns 1 if any of the passes modified the
3118 function, false otherwise.
Gregory Szorc34c863a2012-03-21 03:54:29 +00003119 @see llvm::FunctionPassManager::run(Function&) */
Chris Lattner25963c62010-01-09 22:27:07 +00003120LLVMBool LLVMRunFunctionPassManager(LLVMPassManagerRef FPM, LLVMValueRef F);
Gordon Henriksen878114b2008-03-16 04:20:44 +00003121
3122/** Finalizes all of the function passes scheduled in in the function pass
3123 manager. Returns 1 if any of the passes modified the module, 0 otherwise.
Gregory Szorc34c863a2012-03-21 03:54:29 +00003124 @see llvm::FunctionPassManager::doFinalization */
Chris Lattner25963c62010-01-09 22:27:07 +00003125LLVMBool LLVMFinalizeFunctionPassManager(LLVMPassManagerRef FPM);
Gordon Henriksen878114b2008-03-16 04:20:44 +00003126
3127/** Frees the memory of a pass pipeline. For function pipelines, does not free
3128 the module provider.
Gregory Szorc34c863a2012-03-21 03:54:29 +00003129 @see llvm::PassManagerBase::~PassManagerBase. */
Gordon Henriksen878114b2008-03-16 04:20:44 +00003130void LLVMDisposePassManager(LLVMPassManagerRef PM);
3131
Gregory Szorc34c863a2012-03-21 03:54:29 +00003132/**
3133 * @}
3134 */
3135
3136/**
Duncan Sands1cba0a82013-02-17 16:35:51 +00003137 * @defgroup LLVMCCoreThreading Threading
3138 *
3139 * Handle the structures needed to make LLVM safe for multithreading.
3140 *
3141 * @{
3142 */
3143
Chandler Carruth39cd2162014-06-27 15:13:01 +00003144/** Deprecated: Multi-threading can only be enabled/disabled with the compile
3145 time define LLVM_ENABLE_THREADS. This function always returns
3146 LLVMIsMultithreaded(). */
Benjamin Kramer325ec892013-10-23 16:57:34 +00003147LLVMBool LLVMStartMultithreaded(void);
Duncan Sands1cba0a82013-02-17 16:35:51 +00003148
Chandler Carruth39cd2162014-06-27 15:13:01 +00003149/** Deprecated: Multi-threading can only be enabled/disabled with the compile
3150 time define LLVM_ENABLE_THREADS. */
Benjamin Kramer325ec892013-10-23 16:57:34 +00003151void LLVMStopMultithreaded(void);
Duncan Sands1cba0a82013-02-17 16:35:51 +00003152
3153/** Check whether LLVM is executing in thread-safe mode or not.
3154 @see llvm::llvm_is_multithreaded */
Benjamin Kramer325ec892013-10-23 16:57:34 +00003155LLVMBool LLVMIsMultithreaded(void);
Duncan Sands1cba0a82013-02-17 16:35:51 +00003156
3157/**
3158 * @}
3159 */
3160
3161/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00003162 * @}
3163 */
3164
3165/**
3166 * @}
3167 */
Gordon Henriksen878114b2008-03-16 04:20:44 +00003168
Gordon Henriksen76a03742007-09-18 03:18:57 +00003169#ifdef __cplusplus
3170}
Eugene Zelenkoffec81c2015-11-04 22:32:32 +00003171#endif
Gordon Henriksen7330acd2007-10-05 23:59:36 +00003172
Eugene Zelenkoffec81c2015-11-04 22:32:32 +00003173#endif /* LLVM_C_CORE_H */