blob: d9b6712ac2703b4d578553fd97e1e20c370749a6 [file] [log] [blame]
Gordon Henriksen76a03742007-09-18 03:18:57 +00001/*===-- llvm-c/Core.h - Core Library C Interface ------------------*- C -*-===*\
2|* *|
3|* The LLVM Compiler Infrastructure *|
4|* *|
Chris Lattnere9cc7422007-12-29 19:59:42 +00005|* This file is distributed under the University of Illinois Open Source *|
6|* License. See LICENSE.TXT for details. *|
Gordon Henriksen76a03742007-09-18 03:18:57 +00007|* *|
8|*===----------------------------------------------------------------------===*|
9|* *|
10|* This header declares the C interface to libLLVMCore.a, which implements *|
11|* the LLVM intermediate representation. *|
12|* *|
Gordon Henriksen76a03742007-09-18 03:18:57 +000013\*===----------------------------------------------------------------------===*/
14
15#ifndef LLVM_C_CORE_H
16#define LLVM_C_CORE_H
17
Eric Christophera6b96002015-12-18 01:46:52 +000018#include "llvm-c/ErrorHandling.h"
19#include "llvm-c/Types.h"
Erick Tryzelaardd991352009-08-16 23:36:46 +000020
Evan Cheng2e254d02013-04-04 17:40:53 +000021#ifdef __cplusplus
Gordon Henriksen76a03742007-09-18 03:18:57 +000022extern "C" {
23#endif
24
Gregory Szorc34c863a2012-03-21 03:54:29 +000025/**
26 * @defgroup LLVMC LLVM-C: C interface to LLVM
27 *
28 * This module exposes parts of the LLVM library as a C API.
29 *
30 * @{
31 */
32
33/**
34 * @defgroup LLVMCTransforms Transforms
35 */
36
37/**
38 * @defgroup LLVMCCore Core
39 *
40 * This modules provide an interface to libLLVMCore, which implements
41 * the LLVM intermediate representation as well as other related types
42 * and utilities.
43 *
Gregory Szorc34c863a2012-03-21 03:54:29 +000044 * Many exotic languages can interoperate with C code but have a harder time
45 * with C++ due to name mangling. So in addition to C, this interface enables
46 * tools written in such languages.
47 *
Gregory Szorc34c863a2012-03-21 03:54:29 +000048 * @{
49 */
50
51/**
52 * @defgroup LLVMCCoreTypes Types and Enumerations
53 *
54 * @{
55 */
Gordon Henriksen76a03742007-09-18 03:18:57 +000056
Gordon Henriksen76a03742007-09-18 03:18:57 +000057typedef enum {
Devang Patel4c758ea2008-09-25 21:00:45 +000058 LLVMZExtAttribute = 1<<0,
59 LLVMSExtAttribute = 1<<1,
60 LLVMNoReturnAttribute = 1<<2,
61 LLVMInRegAttribute = 1<<3,
62 LLVMStructRetAttribute = 1<<4,
63 LLVMNoUnwindAttribute = 1<<5,
64 LLVMNoAliasAttribute = 1<<6,
65 LLVMByValAttribute = 1<<7,
66 LLVMNestAttribute = 1<<8,
67 LLVMReadNoneAttribute = 1<<9,
Anton Korobeynikovc8ce7b082009-07-17 18:07:26 +000068 LLVMReadOnlyAttribute = 1<<10,
Anton Korobeynikov9750be92009-07-17 18:57:16 +000069 LLVMNoInlineAttribute = 1<<11,
70 LLVMAlwaysInlineAttribute = 1<<12,
71 LLVMOptimizeForSizeAttribute = 1<<13,
72 LLVMStackProtectAttribute = 1<<14,
73 LLVMStackProtectReqAttribute = 1<<15,
Erick Tryzelaar8f69fea2010-03-03 23:51:25 +000074 LLVMAlignment = 31<<16,
Anton Korobeynikov9750be92009-07-17 18:57:16 +000075 LLVMNoCaptureAttribute = 1<<21,
76 LLVMNoRedZoneAttribute = 1<<22,
77 LLVMNoImplicitFloatAttribute = 1<<23,
Jakob Stoklund Olesen74bb06c2010-02-06 01:16:28 +000078 LLVMNakedAttribute = 1<<24,
Erick Tryzelaar8f69fea2010-03-03 23:51:25 +000079 LLVMInlineHintAttribute = 1<<25,
Torok Edwin1db48c02011-10-06 12:13:32 +000080 LLVMStackAlignment = 7<<26,
81 LLVMReturnsTwice = 1 << 29,
82 LLVMUWTable = 1 << 30,
Chandler Carruth44d69d92012-01-25 07:40:15 +000083 LLVMNonLazyBind = 1 << 31
84
Bill Wendlingd154e2832013-01-23 06:41:41 +000085 /* FIXME: These attributes are currently not included in the C API as
Nuno Lopesdef4229972012-09-02 14:19:21 +000086 a temporary measure until the API/ABI impact to the C API is understood
87 and the path forward agreed upon.
Peter Collingbourne58af6d12015-06-15 22:16:51 +000088 LLVMSanitizeAddressAttribute = 1ULL << 32,
89 LLVMStackProtectStrongAttribute = 1ULL<<35,
90 LLVMColdAttribute = 1ULL << 40,
91 LLVMOptimizeNoneAttribute = 1ULL << 42,
92 LLVMInAllocaAttribute = 1ULL << 43,
93 LLVMNonNullAttribute = 1ULL << 44,
94 LLVMJumpTableAttribute = 1ULL << 45,
95 LLVMConvergentAttribute = 1ULL << 46,
96 LLVMSafeStackAttribute = 1ULL << 47,
Manman Renf46262e2016-03-29 17:37:21 +000097 LLVMSwiftSelfAttribute = 1ULL << 48,
Manman Ren9bfd0d02016-04-01 21:41:15 +000098 LLVMSwiftErrorAttribute = 1ULL << 49,
Nuno Lopesdef4229972012-09-02 14:19:21 +000099 */
Devang Patel4c758ea2008-09-25 21:00:45 +0000100} LLVMAttribute;
Gordon Henriksen2d9cc212008-04-28 17:37:06 +0000101
102typedef enum {
Bill Wendlingda52cec2010-02-15 20:53:17 +0000103 /* Terminator Instructions */
Chris Lattner40cf28d2009-10-12 04:01:02 +0000104 LLVMRet = 1,
105 LLVMBr = 2,
106 LLVMSwitch = 3,
Bill Wendling07d6d762010-02-15 20:50:51 +0000107 LLVMIndirectBr = 4,
108 LLVMInvoke = 5,
Bill Wendling46ffaa92011-08-02 06:20:17 +0000109 /* removed 6 due to API changes */
Bill Wendling2641d132011-07-27 21:00:28 +0000110 LLVMUnreachable = 7,
Bill Wendling07d6d762010-02-15 20:50:51 +0000111
Bill Wendlingda52cec2010-02-15 20:53:17 +0000112 /* Standard Binary Operators */
Bill Wendling2641d132011-07-27 21:00:28 +0000113 LLVMAdd = 8,
114 LLVMFAdd = 9,
115 LLVMSub = 10,
116 LLVMFSub = 11,
117 LLVMMul = 12,
118 LLVMFMul = 13,
119 LLVMUDiv = 14,
120 LLVMSDiv = 15,
121 LLVMFDiv = 16,
122 LLVMURem = 17,
123 LLVMSRem = 18,
124 LLVMFRem = 19,
Bill Wendling07d6d762010-02-15 20:50:51 +0000125
Bill Wendlingda52cec2010-02-15 20:53:17 +0000126 /* Logical Operators */
Bill Wendling2641d132011-07-27 21:00:28 +0000127 LLVMShl = 20,
128 LLVMLShr = 21,
129 LLVMAShr = 22,
130 LLVMAnd = 23,
131 LLVMOr = 24,
132 LLVMXor = 25,
Bill Wendling07d6d762010-02-15 20:50:51 +0000133
Bill Wendlingda52cec2010-02-15 20:53:17 +0000134 /* Memory Operators */
Bill Wendling2641d132011-07-27 21:00:28 +0000135 LLVMAlloca = 26,
136 LLVMLoad = 27,
137 LLVMStore = 28,
138 LLVMGetElementPtr = 29,
Bill Wendling07d6d762010-02-15 20:50:51 +0000139
Bill Wendlingda52cec2010-02-15 20:53:17 +0000140 /* Cast Operators */
Bill Wendling2641d132011-07-27 21:00:28 +0000141 LLVMTrunc = 30,
142 LLVMZExt = 31,
143 LLVMSExt = 32,
144 LLVMFPToUI = 33,
145 LLVMFPToSI = 34,
146 LLVMUIToFP = 35,
147 LLVMSIToFP = 36,
148 LLVMFPTrunc = 37,
149 LLVMFPExt = 38,
150 LLVMPtrToInt = 39,
151 LLVMIntToPtr = 40,
152 LLVMBitCast = 41,
Matt Arsenaultb03bd4d2013-11-15 01:34:59 +0000153 LLVMAddrSpaceCast = 60,
Bill Wendling07d6d762010-02-15 20:50:51 +0000154
Bill Wendlingda52cec2010-02-15 20:53:17 +0000155 /* Other Operators */
Bill Wendling2641d132011-07-27 21:00:28 +0000156 LLVMICmp = 42,
157 LLVMFCmp = 43,
158 LLVMPHI = 44,
159 LLVMCall = 45,
160 LLVMSelect = 46,
Torok Edwin05dc9d62011-10-06 12:39:34 +0000161 LLVMUserOp1 = 47,
162 LLVMUserOp2 = 48,
Bill Wendling2641d132011-07-27 21:00:28 +0000163 LLVMVAArg = 49,
164 LLVMExtractElement = 50,
165 LLVMInsertElement = 51,
166 LLVMShuffleVector = 52,
167 LLVMExtractValue = 53,
168 LLVMInsertValue = 54,
Eli Friedman4fc946c2011-07-27 18:59:19 +0000169
170 /* Atomic operators */
Bill Wendling2641d132011-07-27 21:00:28 +0000171 LLVMFence = 55,
Eli Friedmanc9a551e2011-07-28 21:48:00 +0000172 LLVMAtomicCmpXchg = 56,
Bill Wendlingf891bf82011-07-31 06:30:59 +0000173 LLVMAtomicRMW = 57,
174
175 /* Exception Handling Operators */
Bill Wendlingfae14752011-08-12 20:24:12 +0000176 LLVMResume = 58,
David Majnemer654e1302015-07-31 17:58:14 +0000177 LLVMLandingPad = 59,
178 LLVMCleanupRet = 61,
179 LLVMCatchRet = 62,
Joseph Tremoulet9ce71f72015-09-03 09:09:43 +0000180 LLVMCatchPad = 63,
David Majnemerbbfc7212015-12-14 18:34:23 +0000181 LLVMCleanupPad = 64,
182 LLVMCatchSwitch = 65
Chris Lattner40cf28d2009-10-12 04:01:02 +0000183} LLVMOpcode;
184
185typedef enum {
Gordon Henriksen4a4d7352007-12-30 17:46:33 +0000186 LLVMVoidTypeKind, /**< type with no size */
Dan Gohman518cda42011-12-17 00:04:22 +0000187 LLVMHalfTypeKind, /**< 16 bit floating point type */
Gordon Henriksen4a4d7352007-12-30 17:46:33 +0000188 LLVMFloatTypeKind, /**< 32 bit floating point type */
189 LLVMDoubleTypeKind, /**< 64 bit floating point type */
190 LLVMX86_FP80TypeKind, /**< 80 bit floating point type (X87) */
191 LLVMFP128TypeKind, /**< 128 bit floating point type (112-bit mantissa)*/
192 LLVMPPC_FP128TypeKind, /**< 128 bit floating point type (two 64-bits) */
193 LLVMLabelTypeKind, /**< Labels */
194 LLVMIntegerTypeKind, /**< Arbitrary bit width integers */
195 LLVMFunctionTypeKind, /**< Functions */
196 LLVMStructTypeKind, /**< Structures */
197 LLVMArrayTypeKind, /**< Arrays */
198 LLVMPointerTypeKind, /**< Pointers */
Chris Lattnerdac44ec2009-07-15 22:00:31 +0000199 LLVMVectorTypeKind, /**< SIMD 'packed' format, or other vector type */
Dale Johannesenbaa5d042010-09-10 20:55:01 +0000200 LLVMMetadataTypeKind, /**< Metadata */
David Majnemerb611e3f2015-08-14 05:09:07 +0000201 LLVMX86_MMXTypeKind, /**< X86 MMX */
202 LLVMTokenTypeKind /**< Tokens */
Gordon Henriksen76a03742007-09-18 03:18:57 +0000203} LLVMTypeKind;
204
205typedef enum {
Gordon Henriksen4a4d7352007-12-30 17:46:33 +0000206 LLVMExternalLinkage, /**< Externally visible function */
Chris Lattner2dba0f02009-04-13 06:25:37 +0000207 LLVMAvailableExternallyLinkage,
Duncan Sands12da8ce2009-03-07 15:45:40 +0000208 LLVMLinkOnceAnyLinkage, /**< Keep one copy of function when linking (inline)*/
209 LLVMLinkOnceODRLinkage, /**< Same, but only replaced by something
210 equivalent. */
Rafael Espindola716e7402013-11-01 17:09:14 +0000211 LLVMLinkOnceODRAutoHideLinkage, /**< Obsolete */
Duncan Sands12da8ce2009-03-07 15:45:40 +0000212 LLVMWeakAnyLinkage, /**< Keep one copy of function when linking (weak) */
213 LLVMWeakODRLinkage, /**< Same, but only replaced by something
214 equivalent. */
Gordon Henriksen4a4d7352007-12-30 17:46:33 +0000215 LLVMAppendingLinkage, /**< Special purpose, only applies to global arrays */
216 LLVMInternalLinkage, /**< Rename collisions when linking (static
217 functions) */
Duncan Sands12da8ce2009-03-07 15:45:40 +0000218 LLVMPrivateLinkage, /**< Like Internal, but omit from symbol table */
Nico Rieck7157bb72014-01-14 15:22:47 +0000219 LLVMDLLImportLinkage, /**< Obsolete */
220 LLVMDLLExportLinkage, /**< Obsolete */
Duncan Sandse2881052009-03-11 08:08:06 +0000221 LLVMExternalWeakLinkage,/**< ExternalWeak linkage description */
Jeffrey Yasskin091217b2010-01-27 20:34:15 +0000222 LLVMGhostLinkage, /**< Obsolete */
Bill Wendling002b1672009-07-20 18:22:52 +0000223 LLVMCommonLinkage, /**< Tentative definitions */
Bill Wendling03bcd6e2010-07-01 21:55:59 +0000224 LLVMLinkerPrivateLinkage, /**< Like Private, but linker removes. */
Bill Wendling34bc34e2012-08-17 18:33:14 +0000225 LLVMLinkerPrivateWeakLinkage /**< Like LinkerPrivate, but is weak. */
Gordon Henriksen76a03742007-09-18 03:18:57 +0000226} LLVMLinkage;
227
228typedef enum {
Gordon Henriksen4a4d7352007-12-30 17:46:33 +0000229 LLVMDefaultVisibility, /**< The GV is visible */
230 LLVMHiddenVisibility, /**< The GV is hidden */
231 LLVMProtectedVisibility /**< The GV is protected */
Gordon Henriksen76a03742007-09-18 03:18:57 +0000232} LLVMVisibility;
233
Gordon Henriksenc23b66c2007-09-26 20:56:12 +0000234typedef enum {
Reid Kleckner2fae26f2014-03-05 02:34:23 +0000235 LLVMDefaultStorageClass = 0,
236 LLVMDLLImportStorageClass = 1, /**< Function to be imported from DLL. */
237 LLVMDLLExportStorageClass = 2 /**< Function to be accessible from DLL. */
238} LLVMDLLStorageClass;
239
240typedef enum {
Gordon Henriksenc23b66c2007-09-26 20:56:12 +0000241 LLVMCCallConv = 0,
242 LLVMFastCallConv = 8,
243 LLVMColdCallConv = 9,
Filip Pizlodfc9b582013-11-09 06:00:03 +0000244 LLVMWebKitJSCallConv = 12,
245 LLVMAnyRegCallConv = 13,
Gordon Henriksenc23b66c2007-09-26 20:56:12 +0000246 LLVMX86StdcallCallConv = 64,
247 LLVMX86FastcallCallConv = 65
248} LLVMCallConv;
249
250typedef enum {
Peter Zotov3e4561c2016-04-06 22:21:29 +0000251 LLVMArgumentValueKind,
252 LLVMBasicBlockValueKind,
253 LLVMMemoryUseValueKind,
254 LLVMMemoryDefValueKind,
255 LLVMMemoryPhiValueKind,
256
257 LLVMFunctionValueKind,
258 LLVMGlobalAliasValueKind,
Dmitry Polukhina1feff72016-04-07 12:32:19 +0000259 LLVMGlobalIFuncValueKind,
Peter Zotov3e4561c2016-04-06 22:21:29 +0000260 LLVMGlobalVariableValueKind,
261 LLVMBlockAddressValueKind,
262 LLVMConstantExprValueKind,
263 LLVMConstantArrayValueKind,
264 LLVMConstantStructValueKind,
265 LLVMConstantVectorValueKind,
266
267 LLVMUndefValueValueKind,
268 LLVMConstantAggregateZeroValueKind,
269 LLVMConstantDataArrayValueKind,
270 LLVMConstantDataVectorValueKind,
271 LLVMConstantIntValueKind,
272 LLVMConstantFPValueKind,
273 LLVMConstantPointerNullValueKind,
274 LLVMConstantTokenNoneValueKind,
275
276 LLVMMetadataAsValueValueKind,
277 LLVMInlineAsmValueKind,
278
279 LLVMInstructionValueKind,
280} LLVMValueKind;
281
282typedef enum {
Gordon Henriksen4a4d7352007-12-30 17:46:33 +0000283 LLVMIntEQ = 32, /**< equal */
284 LLVMIntNE, /**< not equal */
285 LLVMIntUGT, /**< unsigned greater than */
286 LLVMIntUGE, /**< unsigned greater or equal */
287 LLVMIntULT, /**< unsigned less than */
288 LLVMIntULE, /**< unsigned less or equal */
289 LLVMIntSGT, /**< signed greater than */
290 LLVMIntSGE, /**< signed greater or equal */
291 LLVMIntSLT, /**< signed less than */
292 LLVMIntSLE /**< signed less or equal */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +0000293} LLVMIntPredicate;
294
295typedef enum {
Gordon Henriksen4a4d7352007-12-30 17:46:33 +0000296 LLVMRealPredicateFalse, /**< Always false (always folded) */
297 LLVMRealOEQ, /**< True if ordered and equal */
298 LLVMRealOGT, /**< True if ordered and greater than */
299 LLVMRealOGE, /**< True if ordered and greater than or equal */
300 LLVMRealOLT, /**< True if ordered and less than */
301 LLVMRealOLE, /**< True if ordered and less than or equal */
302 LLVMRealONE, /**< True if ordered and operands are unequal */
303 LLVMRealORD, /**< True if ordered (no nans) */
304 LLVMRealUNO, /**< True if unordered: isnan(X) | isnan(Y) */
305 LLVMRealUEQ, /**< True if unordered or equal */
306 LLVMRealUGT, /**< True if unordered or greater than */
307 LLVMRealUGE, /**< True if unordered, greater than, or equal */
308 LLVMRealULT, /**< True if unordered or less than */
309 LLVMRealULE, /**< True if unordered, less than, or equal */
310 LLVMRealUNE, /**< True if unordered or not equal */
311 LLVMRealPredicateTrue /**< Always true (always folded) */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +0000312} LLVMRealPredicate;
313
Bill Wendlingfae14752011-08-12 20:24:12 +0000314typedef enum {
315 LLVMLandingPadCatch, /**< A catch clause */
316 LLVMLandingPadFilter /**< A filter clause */
317} LLVMLandingPadClauseTy;
318
Hans Wennborg5ff71202013-04-16 08:58:59 +0000319typedef enum {
320 LLVMNotThreadLocal = 0,
321 LLVMGeneralDynamicTLSModel,
322 LLVMLocalDynamicTLSModel,
323 LLVMInitialExecTLSModel,
324 LLVMLocalExecTLSModel
325} LLVMThreadLocalMode;
326
Carlo Kokda0ac722013-04-23 13:45:37 +0000327typedef enum {
Carlo Kok8c6719b2013-04-23 13:21:19 +0000328 LLVMAtomicOrderingNotAtomic = 0, /**< A load or store which is not atomic */
329 LLVMAtomicOrderingUnordered = 1, /**< Lowest level of atomicity, guarantees
330 somewhat sane results, lock free. */
NAKAMURA Takumia3a81352013-10-23 17:56:29 +0000331 LLVMAtomicOrderingMonotonic = 2, /**< guarantees that if you take all the
332 operations affecting a specific address,
Carlo Kok8c6719b2013-04-23 13:21:19 +0000333 a consistent ordering exists */
NAKAMURA Takumia3a81352013-10-23 17:56:29 +0000334 LLVMAtomicOrderingAcquire = 4, /**< Acquire provides a barrier of the sort
335 necessary to acquire a lock to access other
Carlo Kok8c6719b2013-04-23 13:21:19 +0000336 memory with normal loads and stores. */
NAKAMURA Takumia3a81352013-10-23 17:56:29 +0000337 LLVMAtomicOrderingRelease = 5, /**< Release is similar to Acquire, but with
338 a barrier of the sort necessary to release
Carlo Kok8c6719b2013-04-23 13:21:19 +0000339 a lock. */
NAKAMURA Takumia3a81352013-10-23 17:56:29 +0000340 LLVMAtomicOrderingAcquireRelease = 6, /**< provides both an Acquire and a
341 Release barrier (for fences and
Carlo Kok8c6719b2013-04-23 13:21:19 +0000342 operations which both read and write
343 memory). */
NAKAMURA Takumia3a81352013-10-23 17:56:29 +0000344 LLVMAtomicOrderingSequentiallyConsistent = 7 /**< provides Acquire semantics
345 for loads and Release
346 semantics for stores.
347 Additionally, it guarantees
348 that a total ordering exists
349 between all
350 SequentiallyConsistent
Carlo Kok8c6719b2013-04-23 13:21:19 +0000351 operations. */
Carlo Kokda0ac722013-04-23 13:45:37 +0000352} LLVMAtomicOrdering;
Carlo Kok8c6719b2013-04-23 13:21:19 +0000353
Carlo Kokda0ac722013-04-23 13:45:37 +0000354typedef enum {
Carlo Kok8c6719b2013-04-23 13:21:19 +0000355 LLVMAtomicRMWBinOpXchg, /**< Set the new value and return the one old */
356 LLVMAtomicRMWBinOpAdd, /**< Add a value and return the old one */
357 LLVMAtomicRMWBinOpSub, /**< Subtract a value and return the old one */
358 LLVMAtomicRMWBinOpAnd, /**< And a value and return the old one */
359 LLVMAtomicRMWBinOpNand, /**< Not-And a value and return the old one */
360 LLVMAtomicRMWBinOpOr, /**< OR a value and return the old one */
361 LLVMAtomicRMWBinOpXor, /**< Xor a value and return the old one */
362 LLVMAtomicRMWBinOpMax, /**< Sets the value if it's greater than the
NAKAMURA Takumia3a81352013-10-23 17:56:29 +0000363 original using a signed comparison and return
Carlo Kok8c6719b2013-04-23 13:21:19 +0000364 the old one */
365 LLVMAtomicRMWBinOpMin, /**< Sets the value if it's Smaller than the
NAKAMURA Takumia3a81352013-10-23 17:56:29 +0000366 original using a signed comparison and return
Carlo Kok8c6719b2013-04-23 13:21:19 +0000367 the old one */
368 LLVMAtomicRMWBinOpUMax, /**< Sets the value if it's greater than the
NAKAMURA Takumia3a81352013-10-23 17:56:29 +0000369 original using an unsigned comparison and return
Carlo Kok8c6719b2013-04-23 13:21:19 +0000370 the old one */
371 LLVMAtomicRMWBinOpUMin /**< Sets the value if it's greater than the
NAKAMURA Takumia3a81352013-10-23 17:56:29 +0000372 original using an unsigned comparison and return
Carlo Kok8c6719b2013-04-23 13:21:19 +0000373 the old one */
Carlo Kokda0ac722013-04-23 13:45:37 +0000374} LLVMAtomicRMWBinOp;
Carlo Kok8c6719b2013-04-23 13:21:19 +0000375
Tom Stellard1580dc72014-04-16 17:45:04 +0000376typedef enum {
377 LLVMDSError,
378 LLVMDSWarning,
379 LLVMDSRemark,
380 LLVMDSNote
381} LLVMDiagnosticSeverity;
382
Gregory Szorc34c863a2012-03-21 03:54:29 +0000383/**
384 * @}
385 */
386
Nick Lewycky0db26542011-05-15 07:20:34 +0000387void LLVMInitializeCore(LLVMPassRegistryRef R);
388
Duncan Sands1cba0a82013-02-17 16:35:51 +0000389/** Deallocate and destroy all ManagedStatic variables.
390 @see llvm::llvm_shutdown
391 @see ManagedStatic */
Benjamin Kramer325ec892013-10-23 16:57:34 +0000392void LLVMShutdown(void);
Duncan Sands1cba0a82013-02-17 16:35:51 +0000393
Gordon Henriksen34eb6d82007-12-19 22:30:40 +0000394/*===-- Error handling ----------------------------------------------------===*/
395
Filip Pizlo3fdbaff2013-05-22 02:46:43 +0000396char *LLVMCreateMessage(const char *Message);
Gordon Henriksen34eb6d82007-12-19 22:30:40 +0000397void LLVMDisposeMessage(char *Message);
398
Filip Pizlo9f50ccd2013-11-03 00:29:47 +0000399/**
Gregory Szorc34c863a2012-03-21 03:54:29 +0000400 * @defgroup LLVMCCoreContext Contexts
401 *
402 * Contexts are execution states for the core LLVM IR system.
403 *
404 * Most types are tied to a context instance. Multiple contexts can
405 * exist simultaneously. A single context is not thread safe. However,
406 * different contexts can execute on different threads simultaneously.
407 *
408 * @{
409 */
Gordon Henriksen76a03742007-09-18 03:18:57 +0000410
Tom Stellard1580dc72014-04-16 17:45:04 +0000411typedef void (*LLVMDiagnosticHandler)(LLVMDiagnosticInfoRef, void *);
Juergen Ributzka34390c72014-05-16 02:33:15 +0000412typedef void (*LLVMYieldCallback)(LLVMContextRef, void *);
Tom Stellard1580dc72014-04-16 17:45:04 +0000413
Gregory Szorc34c863a2012-03-21 03:54:29 +0000414/**
415 * Create a new context.
416 *
417 * Every call to this function should be paired with a call to
418 * LLVMContextDispose() or the context will leak memory.
419 */
Erick Tryzelaarf34cb0c2009-08-30 23:38:06 +0000420LLVMContextRef LLVMContextCreate(void);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000421
422/**
423 * Obtain the global context instance.
424 */
Erick Tryzelaarf34cb0c2009-08-30 23:38:06 +0000425LLVMContextRef LLVMGetGlobalContext(void);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000426
427/**
Tom Stellard1580dc72014-04-16 17:45:04 +0000428 * Set the diagnostic handler for this context.
429 */
430void LLVMContextSetDiagnosticHandler(LLVMContextRef C,
431 LLVMDiagnosticHandler Handler,
432 void *DiagnosticContext);
433
434/**
Jeroen Ketemaad659c32016-04-08 09:19:02 +0000435 * Get the diagnostic handler of this context.
436 */
437LLVMDiagnosticHandler LLVMContextGetDiagnosticHandler(LLVMContextRef C);
438
439/**
440 * Get the diagnostic context of this context.
441 */
442void *LLVMContextGetDiagnosticContext(LLVMContextRef C);
443
444/**
Juergen Ributzka34390c72014-05-16 02:33:15 +0000445 * Set the yield callback function for this context.
446 *
447 * @see LLVMContext::setYieldCallback()
448 */
449void LLVMContextSetYieldCallback(LLVMContextRef C, LLVMYieldCallback Callback,
450 void *OpaqueHandle);
451
452/**
Gregory Szorc34c863a2012-03-21 03:54:29 +0000453 * Destroy a context instance.
454 *
455 * This should be called for every call to LLVMContextCreate() or memory
456 * will be leaked.
457 */
Owen Anderson6773d382009-07-01 16:58:40 +0000458void LLVMContextDispose(LLVMContextRef C);
459
Tom Stellard1580dc72014-04-16 17:45:04 +0000460/**
461 * Return a string representation of the DiagnosticInfo. Use
462 * LLVMDisposeMessage to free the string.
463 *
464 * @see DiagnosticInfo::print()
465 */
466char *LLVMGetDiagInfoDescription(LLVMDiagnosticInfoRef DI);
467
468/**
469 * Return an enum LLVMDiagnosticSeverity.
470 *
471 * @see DiagnosticInfo::getSeverity()
472 */
473LLVMDiagnosticSeverity LLVMGetDiagInfoSeverity(LLVMDiagnosticInfoRef DI);
474
Amaury Sechet56f056c2016-04-04 22:00:25 +0000475unsigned LLVMGetMDKindIDInContext(LLVMContextRef C, const char *Name,
Erick Tryzelaard8531fa2010-02-28 09:45:59 +0000476 unsigned SLen);
Amaury Sechet56f056c2016-04-04 22:00:25 +0000477unsigned LLVMGetMDKindID(const char *Name, unsigned SLen);
Erick Tryzelaard8531fa2010-02-28 09:45:59 +0000478
Gregory Szorc34c863a2012-03-21 03:54:29 +0000479/**
480 * @}
481 */
482
Gregory Szorc52d26602012-03-21 07:28:27 +0000483/**
484 * @defgroup LLVMCCoreModule Modules
Gregory Szorc34c863a2012-03-21 03:54:29 +0000485 *
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +0000486 * Modules represent the top-level structure in an LLVM program. An LLVM
Gregory Szorc34c863a2012-03-21 03:54:29 +0000487 * module is effectively a translation unit or a collection of
488 * translation units merged together.
489 *
490 * @{
491 */
492
Gregory Szorc34c863a2012-03-21 03:54:29 +0000493/**
494 * Create a new, empty module in the global context.
495 *
496 * This is equivalent to calling LLVMModuleCreateWithNameInContext with
497 * LLVMGetGlobalContext() as the context parameter.
498 *
499 * Every invocation should be paired with LLVMDisposeModule() or memory
500 * will be leaked.
501 */
Gordon Henriksen76a03742007-09-18 03:18:57 +0000502LLVMModuleRef LLVMModuleCreateWithName(const char *ModuleID);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000503
504/**
505 * Create a new, empty module in a specific context.
506 *
507 * Every invocation should be paired with LLVMDisposeModule() or memory
508 * will be leaked.
509 */
Owen Anderson31d44e42009-07-02 07:17:57 +0000510LLVMModuleRef LLVMModuleCreateWithNameInContext(const char *ModuleID,
511 LLVMContextRef C);
Tom Stellard0a4e9a32014-10-01 17:14:57 +0000512/**
513 * Return an exact copy of the specified module.
514 */
515LLVMModuleRef LLVMCloneModule(LLVMModuleRef M);
Gordon Henriksena49d4352008-03-07 19:13:06 +0000516
Gregory Szorc34c863a2012-03-21 03:54:29 +0000517/**
518 * Destroy a module instance.
519 *
520 * This must be called for every created module or memory will be
521 * leaked.
522 */
Gordon Henriksen76a03742007-09-18 03:18:57 +0000523void LLVMDisposeModule(LLVMModuleRef M);
524
Gregory Szorc34c863a2012-03-21 03:54:29 +0000525/**
Peter Zotov0a2fa0a2016-04-05 13:56:59 +0000526 * Obtain the identifier of a module.
527 *
528 * @param M Module to obtain identifier of
529 * @param Len Out parameter which holds the length of the returned string.
530 * @return The identifier of M.
531 * @see Module::getModuleIdentifier()
532 */
533const char *LLVMGetModuleIdentifier(LLVMModuleRef M, size_t *Len);
534
535/**
536 * Set the identifier of a module to a string Ident with length Len.
537 *
538 * @param M The module to set identifier
539 * @param Ident The string to set M's identifier to
540 * @param Len Length of Ident
541 * @see Module::setModuleIdentifier()
542 */
543void LLVMSetModuleIdentifier(LLVMModuleRef M, const char *Ident, size_t Len);
544
545/**
Gregory Szorc34c863a2012-03-21 03:54:29 +0000546 * Obtain the data layout for a module.
547 *
Amaury Sechetf3549c42016-02-16 00:23:52 +0000548 * @see Module::getDataLayoutStr()
549 *
550 * LLVMGetDataLayout is DEPRECATED, as the name is not only incorrect,
551 * but match the name of another method on the module. Prefer the use
552 * of LLVMGetDataLayoutStr, which is not ambiguous.
Gregory Szorc34c863a2012-03-21 03:54:29 +0000553 */
Amaury Sechetf3549c42016-02-16 00:23:52 +0000554const char *LLVMGetDataLayoutStr(LLVMModuleRef M);
Gordon Henriksen05568bb2007-12-27 20:13:47 +0000555const char *LLVMGetDataLayout(LLVMModuleRef M);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000556
557/**
558 * Set the data layout for a module.
559 *
560 * @see Module::setDataLayout()
561 */
Amaury Sechet6ada31c2016-02-15 23:40:06 +0000562void LLVMSetDataLayout(LLVMModuleRef M, const char *DataLayoutStr);
Gordon Henriksen05568bb2007-12-27 20:13:47 +0000563
Gregory Szorc34c863a2012-03-21 03:54:29 +0000564/**
565 * Obtain the target triple for a module.
566 *
567 * @see Module::getTargetTriple()
568 */
Gordon Henriksen05568bb2007-12-27 20:13:47 +0000569const char *LLVMGetTarget(LLVMModuleRef M);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000570
571/**
572 * Set the target triple for a module.
573 *
574 * @see Module::setTargetTriple()
575 */
Gordon Henriksen05568bb2007-12-27 20:13:47 +0000576void LLVMSetTarget(LLVMModuleRef M, const char *Triple);
577
Gregory Szorc34c863a2012-03-21 03:54:29 +0000578/**
579 * Dump a representation of a module to stderr.
580 *
581 * @see Module::dump()
582 */
Gordon Henriksen6c6075e2008-03-14 23:58:56 +0000583void LLVMDumpModule(LLVMModuleRef M);
584
Gregory Szorc34c863a2012-03-21 03:54:29 +0000585/**
Hans Wennborgb7ef2fe2012-05-09 16:54:17 +0000586 * Print a representation of a module to a file. The ErrorMessage needs to be
587 * disposed with LLVMDisposeMessage. Returns 0 on success, 1 otherwise.
588 *
589 * @see Module::print()
590 */
591LLVMBool LLVMPrintModuleToFile(LLVMModuleRef M, const char *Filename,
592 char **ErrorMessage);
593
594/**
Anders Waldenborg84355db2013-10-16 18:00:54 +0000595 * Return a string representation of the module. Use
596 * LLVMDisposeMessage to free the string.
597 *
598 * @see Module::print()
599 */
600char *LLVMPrintModuleToString(LLVMModuleRef M);
601
602/**
Gregory Szorc34c863a2012-03-21 03:54:29 +0000603 * Set inline assembly for a module.
604 *
605 * @see Module::setModuleInlineAsm()
606 */
Chris Lattner26941452010-04-10 17:52:58 +0000607void LLVMSetModuleInlineAsm(LLVMModuleRef M, const char *Asm);
Gordon Henriksen76a03742007-09-18 03:18:57 +0000608
Gregory Szorc34c863a2012-03-21 03:54:29 +0000609/**
610 * Obtain the context to which this module is associated.
611 *
612 * @see Module::getContext()
613 */
Chris Lattnera7e04b02010-11-28 20:03:44 +0000614LLVMContextRef LLVMGetModuleContext(LLVMModuleRef M);
615
Gregory Szorc34c863a2012-03-21 03:54:29 +0000616/**
617 * Obtain a Type from a module by its registered name.
618 */
619LLVMTypeRef LLVMGetTypeByName(LLVMModuleRef M, const char *Name);
Gordon Henriksen76a03742007-09-18 03:18:57 +0000620
Gregory Szorc34c863a2012-03-21 03:54:29 +0000621/**
622 * Obtain the number of operands for named metadata in a module.
623 *
624 * @see llvm::Module::getNamedMetadata()
625 */
626unsigned LLVMGetNamedMetadataNumOperands(LLVMModuleRef M, const char* name);
627
628/**
629 * Obtain the named metadata operands for a module.
630 *
631 * The passed LLVMValueRef pointer should refer to an array of
632 * LLVMValueRef at least LLVMGetNamedMetadataNumOperands long. This
633 * array will be populated with the LLVMValueRef instances. Each
634 * instance corresponds to a llvm::MDNode.
635 *
636 * @see llvm::Module::getNamedMetadata()
637 * @see llvm::MDNode::getOperand()
638 */
639void LLVMGetNamedMetadataOperands(LLVMModuleRef M, const char* name, LLVMValueRef *Dest);
640
641/**
642 * Add an operand to named metadata.
643 *
644 * @see llvm::Module::getNamedMetadata()
645 * @see llvm::MDNode::addOperand()
646 */
647void LLVMAddNamedMetadataOperand(LLVMModuleRef M, const char* name,
648 LLVMValueRef Val);
649
Gregory Szorc52d26602012-03-21 07:28:27 +0000650/**
651 * Add a function to a module under a specified name.
652 *
653 * @see llvm::Function::Create()
654 */
655LLVMValueRef LLVMAddFunction(LLVMModuleRef M, const char *Name,
656 LLVMTypeRef FunctionTy);
657
658/**
659 * Obtain a Function value from a Module by its name.
660 *
661 * The returned value corresponds to a llvm::Function value.
662 *
663 * @see llvm::Module::getFunction()
664 */
665LLVMValueRef LLVMGetNamedFunction(LLVMModuleRef M, const char *Name);
666
667/**
668 * Obtain an iterator to the first Function in a Module.
669 *
670 * @see llvm::Module::begin()
671 */
672LLVMValueRef LLVMGetFirstFunction(LLVMModuleRef M);
673
674/**
675 * Obtain an iterator to the last Function in a Module.
676 *
677 * @see llvm::Module::end()
678 */
679LLVMValueRef LLVMGetLastFunction(LLVMModuleRef M);
680
681/**
682 * Advance a Function iterator to the next Function.
683 *
684 * Returns NULL if the iterator was already at the end and there are no more
685 * functions.
686 */
687LLVMValueRef LLVMGetNextFunction(LLVMValueRef Fn);
688
689/**
690 * Decrement a Function iterator to the previous Function.
691 *
692 * Returns NULL if the iterator was already at the beginning and there are
693 * no previous functions.
694 */
695LLVMValueRef LLVMGetPreviousFunction(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000696
697/**
698 * @}
699 */
700
701/**
702 * @defgroup LLVMCCoreType Types
703 *
704 * Types represent the type of a value.
705 *
706 * Types are associated with a context instance. The context internally
707 * deduplicates types so there is only 1 instance of a specific type
708 * alive at a time. In other words, a unique type is shared among all
709 * consumers within a context.
710 *
711 * A Type in the C API corresponds to llvm::Type.
712 *
713 * Types have the following hierarchy:
714 *
Gordon Henriksen76a03742007-09-18 03:18:57 +0000715 * types:
716 * integer type
717 * real type
718 * function type
719 * sequence types:
720 * array type
721 * pointer type
722 * vector type
723 * void type
724 * label type
725 * opaque type
Gregory Szorc34c863a2012-03-21 03:54:29 +0000726 *
727 * @{
Gordon Henriksen76a03742007-09-18 03:18:57 +0000728 */
729
Gregory Szorc34c863a2012-03-21 03:54:29 +0000730/**
731 * Obtain the enumerated type of a Type instance.
732 *
733 * @see llvm::Type:getTypeID()
734 */
Gordon Henriksen76a03742007-09-18 03:18:57 +0000735LLVMTypeKind LLVMGetTypeKind(LLVMTypeRef Ty);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000736
737/**
738 * Whether the type has a known size.
739 *
740 * Things that don't have a size are abstract types, labels, and void.a
741 *
742 * @see llvm::Type::isSized()
743 */
Torok Edwin1cd9ade2011-10-06 12:13:28 +0000744LLVMBool LLVMTypeIsSized(LLVMTypeRef Ty);
Gordon Henriksena49d4352008-03-07 19:13:06 +0000745
Gregory Szorc34c863a2012-03-21 03:54:29 +0000746/**
747 * Obtain the context to which this type instance is associated.
748 *
749 * @see llvm::Type::getContext()
750 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +0000751LLVMContextRef LLVMGetTypeContext(LLVMTypeRef Ty);
752
Gregory Szorc34c863a2012-03-21 03:54:29 +0000753/**
Anders Waldenborgb822cff2013-10-16 21:30:25 +0000754 * Dump a representation of a type to stderr.
755 *
756 * @see llvm::Type::dump()
757 */
758void LLVMDumpType(LLVMTypeRef Val);
759
760/**
Anders Waldenborg47b3bd32013-10-22 06:58:34 +0000761 * Return a string representation of the type. Use
762 * LLVMDisposeMessage to free the string.
763 *
764 * @see llvm::Type::print()
765 */
766char *LLVMPrintTypeToString(LLVMTypeRef Val);
767
768/**
Gregory Szorc34c863a2012-03-21 03:54:29 +0000769 * @defgroup LLVMCCoreTypeInt Integer Types
770 *
771 * Functions in this section operate on integer types.
772 *
773 * @{
774 */
775
776/**
777 * Obtain an integer type from a context with specified bit width.
778 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +0000779LLVMTypeRef LLVMInt1TypeInContext(LLVMContextRef C);
780LLVMTypeRef LLVMInt8TypeInContext(LLVMContextRef C);
781LLVMTypeRef LLVMInt16TypeInContext(LLVMContextRef C);
782LLVMTypeRef LLVMInt32TypeInContext(LLVMContextRef C);
783LLVMTypeRef LLVMInt64TypeInContext(LLVMContextRef C);
Eugene Zelenkoffec81c2015-11-04 22:32:32 +0000784LLVMTypeRef LLVMInt128TypeInContext(LLVMContextRef C);
Erick Tryzelaar262332f2009-08-14 00:01:31 +0000785LLVMTypeRef LLVMIntTypeInContext(LLVMContextRef C, unsigned NumBits);
786
Gregory Szorc34c863a2012-03-21 03:54:29 +0000787/**
788 * Obtain an integer type from the global context with a specified bit
789 * width.
790 */
Gordon Henriksena735a9c2008-05-04 12:55:34 +0000791LLVMTypeRef LLVMInt1Type(void);
792LLVMTypeRef LLVMInt8Type(void);
793LLVMTypeRef LLVMInt16Type(void);
794LLVMTypeRef LLVMInt32Type(void);
795LLVMTypeRef LLVMInt64Type(void);
Eugene Zelenkoffec81c2015-11-04 22:32:32 +0000796LLVMTypeRef LLVMInt128Type(void);
Gordon Henriksened7beaa2007-10-06 16:05:20 +0000797LLVMTypeRef LLVMIntType(unsigned NumBits);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +0000798unsigned LLVMGetIntTypeWidth(LLVMTypeRef IntegerTy);
Gordon Henriksen76a03742007-09-18 03:18:57 +0000799
Gregory Szorc34c863a2012-03-21 03:54:29 +0000800/**
801 * @}
802 */
803
804/**
805 * @defgroup LLVMCCoreTypeFloat Floating Point Types
806 *
807 * @{
808 */
809
810/**
811 * Obtain a 16-bit floating point type from a context.
812 */
Dan Gohman518cda42011-12-17 00:04:22 +0000813LLVMTypeRef LLVMHalfTypeInContext(LLVMContextRef C);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000814
815/**
816 * Obtain a 32-bit floating point type from a context.
817 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +0000818LLVMTypeRef LLVMFloatTypeInContext(LLVMContextRef C);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000819
820/**
821 * Obtain a 64-bit floating point type from a context.
822 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +0000823LLVMTypeRef LLVMDoubleTypeInContext(LLVMContextRef C);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000824
825/**
826 * Obtain a 80-bit floating point type (X87) from a context.
827 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +0000828LLVMTypeRef LLVMX86FP80TypeInContext(LLVMContextRef C);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000829
830/**
831 * Obtain a 128-bit floating point type (112-bit mantissa) from a
832 * context.
833 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +0000834LLVMTypeRef LLVMFP128TypeInContext(LLVMContextRef C);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000835
836/**
837 * Obtain a 128-bit floating point type (two 64-bits) from a context.
838 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +0000839LLVMTypeRef LLVMPPCFP128TypeInContext(LLVMContextRef C);
840
Gregory Szorc34c863a2012-03-21 03:54:29 +0000841/**
842 * Obtain a floating point type from the global context.
843 *
844 * These map to the functions in this group of the same name.
845 */
Dan Gohman518cda42011-12-17 00:04:22 +0000846LLVMTypeRef LLVMHalfType(void);
Gordon Henriksena735a9c2008-05-04 12:55:34 +0000847LLVMTypeRef LLVMFloatType(void);
848LLVMTypeRef LLVMDoubleType(void);
849LLVMTypeRef LLVMX86FP80Type(void);
850LLVMTypeRef LLVMFP128Type(void);
851LLVMTypeRef LLVMPPCFP128Type(void);
Gordon Henriksen76a03742007-09-18 03:18:57 +0000852
Gregory Szorc34c863a2012-03-21 03:54:29 +0000853/**
854 * @}
855 */
856
857/**
858 * @defgroup LLVMCCoreTypeFunction Function Types
859 *
860 * @{
861 */
862
863/**
864 * Obtain a function type consisting of a specified signature.
865 *
866 * The function is defined as a tuple of a return Type, a list of
867 * parameter types, and whether the function is variadic.
868 */
Gordon Henriksened7beaa2007-10-06 16:05:20 +0000869LLVMTypeRef LLVMFunctionType(LLVMTypeRef ReturnType,
870 LLVMTypeRef *ParamTypes, unsigned ParamCount,
Chris Lattner25963c62010-01-09 22:27:07 +0000871 LLVMBool IsVarArg);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000872
873/**
874 * Returns whether a function type is variadic.
875 */
Chris Lattner25963c62010-01-09 22:27:07 +0000876LLVMBool LLVMIsFunctionVarArg(LLVMTypeRef FunctionTy);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000877
878/**
879 * Obtain the Type this function Type returns.
880 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +0000881LLVMTypeRef LLVMGetReturnType(LLVMTypeRef FunctionTy);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000882
883/**
884 * Obtain the number of parameters this function accepts.
885 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +0000886unsigned LLVMCountParamTypes(LLVMTypeRef FunctionTy);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000887
888/**
889 * Obtain the types of a function's parameters.
890 *
891 * The Dest parameter should point to a pre-allocated array of
892 * LLVMTypeRef at least LLVMCountParamTypes() large. On return, the
893 * first LLVMCountParamTypes() entries in the array will be populated
894 * with LLVMTypeRef instances.
895 *
896 * @param FunctionTy The function type to operate on.
897 * @param Dest Memory address of an array to be filled with result.
898 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +0000899void LLVMGetParamTypes(LLVMTypeRef FunctionTy, LLVMTypeRef *Dest);
Gordon Henriksen76a03742007-09-18 03:18:57 +0000900
Gregory Szorc34c863a2012-03-21 03:54:29 +0000901/**
902 * @}
903 */
904
905/**
906 * @defgroup LLVMCCoreTypeStruct Structure Types
907 *
908 * These functions relate to LLVMTypeRef instances.
909 *
910 * @see llvm::StructType
911 *
912 * @{
913 */
914
915/**
916 * Create a new structure type in a context.
917 *
918 * A structure is specified by a list of inner elements/types and
919 * whether these can be packed together.
920 *
921 * @see llvm::StructType::create()
922 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +0000923LLVMTypeRef LLVMStructTypeInContext(LLVMContextRef C, LLVMTypeRef *ElementTypes,
Chris Lattner25963c62010-01-09 22:27:07 +0000924 unsigned ElementCount, LLVMBool Packed);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000925
926/**
927 * Create a new structure type in the global context.
928 *
929 * @see llvm::StructType::create()
930 */
Gordon Henriksened7beaa2007-10-06 16:05:20 +0000931LLVMTypeRef LLVMStructType(LLVMTypeRef *ElementTypes, unsigned ElementCount,
Chris Lattner25963c62010-01-09 22:27:07 +0000932 LLVMBool Packed);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000933
934/**
935 * Create an empty structure in a context having a specified name.
936 *
937 * @see llvm::StructType::create()
938 */
Chris Lattnere71ccde2011-07-14 05:53:17 +0000939LLVMTypeRef LLVMStructCreateNamed(LLVMContextRef C, const char *Name);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000940
941/**
942 * Obtain the name of a structure.
943 *
944 * @see llvm::StructType::getName()
945 */
Torok Edwin0d5f6ae2011-10-06 12:12:50 +0000946const char *LLVMGetStructName(LLVMTypeRef Ty);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000947
948/**
949 * Set the contents of a structure type.
950 *
951 * @see llvm::StructType::setBody()
952 */
Chris Lattnere71ccde2011-07-14 05:53:17 +0000953void LLVMStructSetBody(LLVMTypeRef StructTy, LLVMTypeRef *ElementTypes,
954 unsigned ElementCount, LLVMBool Packed);
955
Gregory Szorc34c863a2012-03-21 03:54:29 +0000956/**
957 * Get the number of elements defined inside the structure.
958 *
959 * @see llvm::StructType::getNumElements()
960 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +0000961unsigned LLVMCountStructElementTypes(LLVMTypeRef StructTy);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000962
963/**
964 * Get the elements within a structure.
965 *
966 * The function is passed the address of a pre-allocated array of
967 * LLVMTypeRef at least LLVMCountStructElementTypes() long. After
968 * invocation, this array will be populated with the structure's
969 * elements. The objects in the destination array will have a lifetime
970 * of the structure type itself, which is the lifetime of the context it
971 * is contained in.
972 */
Gordon Henriksen76a03742007-09-18 03:18:57 +0000973void LLVMGetStructElementTypes(LLVMTypeRef StructTy, LLVMTypeRef *Dest);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000974
975/**
Peter Zotovc164a3f2015-06-04 09:09:53 +0000976 * Get the type of the element at a given index in the structure.
977 *
978 * @see llvm::StructType::getTypeAtIndex()
979 */
980LLVMTypeRef LLVMStructGetTypeAtIndex(LLVMTypeRef StructTy, unsigned i);
981
982/**
Gregory Szorc34c863a2012-03-21 03:54:29 +0000983 * Determine whether a structure is packed.
984 *
985 * @see llvm::StructType::isPacked()
986 */
Chris Lattner25963c62010-01-09 22:27:07 +0000987LLVMBool LLVMIsPackedStruct(LLVMTypeRef StructTy);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000988
989/**
990 * Determine whether a structure is opaque.
991 *
992 * @see llvm::StructType::isOpaque()
993 */
Chris Lattner17cf05b2011-07-14 16:20:28 +0000994LLVMBool LLVMIsOpaqueStruct(LLVMTypeRef StructTy);
995
Gregory Szorc34c863a2012-03-21 03:54:29 +0000996/**
997 * @}
998 */
Gordon Henriksen76a03742007-09-18 03:18:57 +0000999
Gregory Szorc34c863a2012-03-21 03:54:29 +00001000/**
1001 * @defgroup LLVMCCoreTypeSequential Sequential Types
1002 *
1003 * Sequential types represents "arrays" of types. This is a super class
1004 * for array, vector, and pointer types.
1005 *
1006 * @{
1007 */
1008
1009/**
1010 * Obtain the type of elements within a sequential type.
1011 *
1012 * This works on array, vector, and pointer types.
1013 *
1014 * @see llvm::SequentialType::getElementType()
1015 */
1016LLVMTypeRef LLVMGetElementType(LLVMTypeRef Ty);
1017
1018/**
1019 * Create a fixed size array type that refers to a specific type.
1020 *
1021 * The created type will exist in the context that its element type
1022 * exists in.
1023 *
1024 * @see llvm::ArrayType::get()
1025 */
Gordon Henriksened7beaa2007-10-06 16:05:20 +00001026LLVMTypeRef LLVMArrayType(LLVMTypeRef ElementType, unsigned ElementCount);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001027
1028/**
1029 * Obtain the length of an array type.
1030 *
1031 * This only works on types that represent arrays.
1032 *
1033 * @see llvm::ArrayType::getNumElements()
1034 */
1035unsigned LLVMGetArrayLength(LLVMTypeRef ArrayTy);
1036
1037/**
1038 * Create a pointer type that points to a defined type.
1039 *
1040 * The created type will exist in the context that its pointee type
1041 * exists in.
1042 *
1043 * @see llvm::PointerType::get()
1044 */
Gordon Henriksen5a3fe032007-12-17 16:08:32 +00001045LLVMTypeRef LLVMPointerType(LLVMTypeRef ElementType, unsigned AddressSpace);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001046
1047/**
1048 * Obtain the address space of a pointer type.
1049 *
1050 * This only works on types that represent pointers.
1051 *
1052 * @see llvm::PointerType::getAddressSpace()
1053 */
1054unsigned LLVMGetPointerAddressSpace(LLVMTypeRef PointerTy);
1055
1056/**
1057 * Create a vector type that contains a defined type and has a specific
1058 * number of elements.
1059 *
1060 * The created type will exist in the context thats its element type
1061 * exists in.
1062 *
1063 * @see llvm::VectorType::get()
1064 */
Gordon Henriksened7beaa2007-10-06 16:05:20 +00001065LLVMTypeRef LLVMVectorType(LLVMTypeRef ElementType, unsigned ElementCount);
Gordon Henriksen76a03742007-09-18 03:18:57 +00001066
Gregory Szorc34c863a2012-03-21 03:54:29 +00001067/**
1068 * Obtain the number of elements in a vector type.
1069 *
1070 * This only works on types that represent vectors.
1071 *
1072 * @see llvm::VectorType::getNumElements()
1073 */
Gordon Henriksen76a03742007-09-18 03:18:57 +00001074unsigned LLVMGetVectorSize(LLVMTypeRef VectorTy);
1075
Gregory Szorc34c863a2012-03-21 03:54:29 +00001076/**
1077 * @}
1078 */
1079
1080/**
1081 * @defgroup LLVMCCoreTypeOther Other Types
1082 *
1083 * @{
1084 */
1085
1086/**
1087 * Create a void type in a context.
1088 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +00001089LLVMTypeRef LLVMVoidTypeInContext(LLVMContextRef C);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001090
1091/**
1092 * Create a label type in a context.
1093 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +00001094LLVMTypeRef LLVMLabelTypeInContext(LLVMContextRef C);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001095
1096/**
1097 * Create a X86 MMX type in a context.
1098 */
Dale Johannesen95b67af2010-09-10 21:58:02 +00001099LLVMTypeRef LLVMX86MMXTypeInContext(LLVMContextRef C);
Erick Tryzelaar262332f2009-08-14 00:01:31 +00001100
Gregory Szorc34c863a2012-03-21 03:54:29 +00001101/**
1102 * These are similar to the above functions except they operate on the
1103 * global context.
1104 */
Gordon Henriksena735a9c2008-05-04 12:55:34 +00001105LLVMTypeRef LLVMVoidType(void);
1106LLVMTypeRef LLVMLabelType(void);
Dale Johannesen95b67af2010-09-10 21:58:02 +00001107LLVMTypeRef LLVMX86MMXType(void);
Gordon Henriksen76a03742007-09-18 03:18:57 +00001108
Gregory Szorc34c863a2012-03-21 03:54:29 +00001109/**
1110 * @}
1111 */
Gordon Henriksen76a03742007-09-18 03:18:57 +00001112
Gregory Szorc34c863a2012-03-21 03:54:29 +00001113/**
1114 * @}
1115 */
1116
1117/**
1118 * @defgroup LLVMCCoreValues Values
1119 *
1120 * The bulk of LLVM's object model consists of values, which comprise a very
Gordon Henriksen76a03742007-09-18 03:18:57 +00001121 * rich type hierarchy.
Gregory Szorc34c863a2012-03-21 03:54:29 +00001122 *
1123 * LLVMValueRef essentially represents llvm::Value. There is a rich
1124 * hierarchy of classes within this type. Depending on the instance
Eli Benderskyc52863c2012-08-10 18:30:44 +00001125 * obtained, not all APIs are available.
Gregory Szorc34c863a2012-03-21 03:54:29 +00001126 *
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00001127 * Callers can determine the type of an LLVMValueRef by calling the
Gregory Szorc34c863a2012-03-21 03:54:29 +00001128 * LLVMIsA* family of functions (e.g. LLVMIsAArgument()). These
1129 * functions are defined by a macro, so it isn't obvious which are
1130 * available by looking at the Doxygen source code. Instead, look at the
1131 * source definition of LLVM_FOR_EACH_VALUE_SUBCLASS and note the list
1132 * of value names given. These value names also correspond to classes in
1133 * the llvm::Value hierarchy.
1134 *
1135 * @{
Gordon Henriksen76a03742007-09-18 03:18:57 +00001136 */
1137
Gordon Henriksen29e38942008-12-19 18:39:45 +00001138#define LLVM_FOR_EACH_VALUE_SUBCLASS(macro) \
1139 macro(Argument) \
1140 macro(BasicBlock) \
1141 macro(InlineAsm) \
1142 macro(User) \
1143 macro(Constant) \
Torok Edwind09b7572011-10-14 20:37:56 +00001144 macro(BlockAddress) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001145 macro(ConstantAggregateZero) \
1146 macro(ConstantArray) \
Peter Zotovae0344b2013-11-05 12:55:37 +00001147 macro(ConstantDataSequential) \
1148 macro(ConstantDataArray) \
1149 macro(ConstantDataVector) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001150 macro(ConstantExpr) \
1151 macro(ConstantFP) \
1152 macro(ConstantInt) \
1153 macro(ConstantPointerNull) \
1154 macro(ConstantStruct) \
David Majnemerf0f224d2015-11-11 21:57:16 +00001155 macro(ConstantTokenNone) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001156 macro(ConstantVector) \
1157 macro(GlobalValue) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001158 macro(GlobalAlias) \
Rafael Espindola99e05cf2014-05-13 18:45:48 +00001159 macro(GlobalObject) \
1160 macro(Function) \
1161 macro(GlobalVariable) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001162 macro(UndefValue) \
1163 macro(Instruction) \
1164 macro(BinaryOperator) \
1165 macro(CallInst) \
1166 macro(IntrinsicInst) \
1167 macro(DbgInfoIntrinsic) \
1168 macro(DbgDeclareInst) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001169 macro(MemIntrinsic) \
1170 macro(MemCpyInst) \
1171 macro(MemMoveInst) \
1172 macro(MemSetInst) \
1173 macro(CmpInst) \
Torok Edwind09b7572011-10-14 20:37:56 +00001174 macro(FCmpInst) \
1175 macro(ICmpInst) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001176 macro(ExtractElementInst) \
1177 macro(GetElementPtrInst) \
1178 macro(InsertElementInst) \
1179 macro(InsertValueInst) \
Bill Wendlingfae14752011-08-12 20:24:12 +00001180 macro(LandingPadInst) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001181 macro(PHINode) \
1182 macro(SelectInst) \
1183 macro(ShuffleVectorInst) \
1184 macro(StoreInst) \
1185 macro(TerminatorInst) \
1186 macro(BranchInst) \
Torok Edwind09b7572011-10-14 20:37:56 +00001187 macro(IndirectBrInst) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001188 macro(InvokeInst) \
1189 macro(ReturnInst) \
1190 macro(SwitchInst) \
1191 macro(UnreachableInst) \
Bill Wendlingf891bf82011-07-31 06:30:59 +00001192 macro(ResumeInst) \
David Majnemer654e1302015-07-31 17:58:14 +00001193 macro(CleanupReturnInst) \
1194 macro(CatchReturnInst) \
David Majnemer8a1c45d2015-12-12 05:38:55 +00001195 macro(FuncletPadInst) \
1196 macro(CatchPadInst) \
1197 macro(CleanupPadInst) \
Duncan Sands5e37e992013-05-06 08:55:45 +00001198 macro(UnaryInstruction) \
1199 macro(AllocaInst) \
1200 macro(CastInst) \
Matt Arsenaultb03bd4d2013-11-15 01:34:59 +00001201 macro(AddrSpaceCastInst) \
Duncan Sands5e37e992013-05-06 08:55:45 +00001202 macro(BitCastInst) \
1203 macro(FPExtInst) \
1204 macro(FPToSIInst) \
1205 macro(FPToUIInst) \
1206 macro(FPTruncInst) \
1207 macro(IntToPtrInst) \
1208 macro(PtrToIntInst) \
1209 macro(SExtInst) \
1210 macro(SIToFPInst) \
1211 macro(TruncInst) \
1212 macro(UIToFPInst) \
1213 macro(ZExtInst) \
1214 macro(ExtractValueInst) \
1215 macro(LoadInst) \
1216 macro(VAArgInst)
Gordon Henriksen29e38942008-12-19 18:39:45 +00001217
Gregory Szorc34c863a2012-03-21 03:54:29 +00001218/**
1219 * @defgroup LLVMCCoreValueGeneral General APIs
1220 *
1221 * Functions in this section work on all LLVMValueRef instances,
1222 * regardless of their sub-type. They correspond to functions available
1223 * on llvm::Value.
1224 *
1225 * @{
1226 */
Gordon Henriksen76a03742007-09-18 03:18:57 +00001227
Gregory Szorc34c863a2012-03-21 03:54:29 +00001228/**
1229 * Obtain the type of a value.
1230 *
1231 * @see llvm::Value::getType()
1232 */
1233LLVMTypeRef LLVMTypeOf(LLVMValueRef Val);
1234
1235/**
Peter Zotov3e4561c2016-04-06 22:21:29 +00001236 * Obtain the enumerated type of a Value instance.
1237 *
1238 * @see llvm::Value::getValueID()
1239 */
1240LLVMValueKind LLVMGetValueKind(LLVMValueRef Val);
1241
1242/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00001243 * Obtain the string name of a value.
1244 *
1245 * @see llvm::Value::getName()
1246 */
1247const char *LLVMGetValueName(LLVMValueRef Val);
1248
1249/**
1250 * Set the string name of a value.
1251 *
1252 * @see llvm::Value::setName()
1253 */
1254void LLVMSetValueName(LLVMValueRef Val, const char *Name);
1255
1256/**
1257 * Dump a representation of a value to stderr.
1258 *
1259 * @see llvm::Value::dump()
1260 */
1261void LLVMDumpValue(LLVMValueRef Val);
1262
1263/**
Peter Zotovcd93b372013-11-06 09:21:01 +00001264 * Return a string representation of the value. Use
1265 * LLVMDisposeMessage to free the string.
1266 *
1267 * @see llvm::Value::print()
1268 */
1269char *LLVMPrintValueToString(LLVMValueRef Val);
1270
1271/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00001272 * Replace all uses of a value with another one.
1273 *
1274 * @see llvm::Value::replaceAllUsesWith()
1275 */
1276void LLVMReplaceAllUsesWith(LLVMValueRef OldVal, LLVMValueRef NewVal);
1277
1278/**
Amaury Sechet1c395072016-01-18 01:06:52 +00001279 * Determine whether the specified value instance is constant.
Gregory Szorc34c863a2012-03-21 03:54:29 +00001280 */
1281LLVMBool LLVMIsConstant(LLVMValueRef Val);
1282
1283/**
1284 * Determine whether a value instance is undefined.
1285 */
1286LLVMBool LLVMIsUndef(LLVMValueRef Val);
1287
1288/**
1289 * Convert value instances between types.
1290 *
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00001291 * Internally, an LLVMValueRef is "pinned" to a specific type. This
Gregory Szorc34c863a2012-03-21 03:54:29 +00001292 * series of functions allows you to cast an instance to a specific
1293 * type.
1294 *
1295 * If the cast is not valid for the specified type, NULL is returned.
1296 *
1297 * @see llvm::dyn_cast_or_null<>
1298 */
Gordon Henriksen29e38942008-12-19 18:39:45 +00001299#define LLVM_DECLARE_VALUE_CAST(name) \
1300 LLVMValueRef LLVMIsA##name(LLVMValueRef Val);
1301LLVM_FOR_EACH_VALUE_SUBCLASS(LLVM_DECLARE_VALUE_CAST)
1302
Duncan P. N. Exon Smith5bf8fef2014-12-09 18:38:53 +00001303LLVMValueRef LLVMIsAMDNode(LLVMValueRef Val);
1304LLVMValueRef LLVMIsAMDString(LLVMValueRef Val);
1305
Gregory Szorc34c863a2012-03-21 03:54:29 +00001306/**
1307 * @}
1308 */
1309
1310/**
1311 * @defgroup LLVMCCoreValueUses Usage
1312 *
1313 * This module defines functions that allow you to inspect the uses of a
1314 * LLVMValueRef.
1315 *
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00001316 * It is possible to obtain an LLVMUseRef for any LLVMValueRef instance.
Gregory Szorc34c863a2012-03-21 03:54:29 +00001317 * Each LLVMUseRef (which corresponds to a llvm::Use instance) holds a
1318 * llvm::User and llvm::Value.
1319 *
1320 * @{
1321 */
1322
1323/**
1324 * Obtain the first use of a value.
1325 *
1326 * Uses are obtained in an iterator fashion. First, call this function
1327 * to obtain a reference to the first use. Then, call LLVMGetNextUse()
Eli Benderskyc52863c2012-08-10 18:30:44 +00001328 * on that instance and all subsequently obtained instances until
Gregory Szorc34c863a2012-03-21 03:54:29 +00001329 * LLVMGetNextUse() returns NULL.
1330 *
1331 * @see llvm::Value::use_begin()
1332 */
Erick Tryzelaar9f9857e2010-03-02 20:32:28 +00001333LLVMUseRef LLVMGetFirstUse(LLVMValueRef Val);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001334
1335/**
1336 * Obtain the next use of a value.
1337 *
1338 * This effectively advances the iterator. It returns NULL if you are on
1339 * the final use and no more are available.
1340 */
Erick Tryzelaar9f9857e2010-03-02 20:32:28 +00001341LLVMUseRef LLVMGetNextUse(LLVMUseRef U);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001342
1343/**
1344 * Obtain the user value for a user.
1345 *
1346 * The returned value corresponds to a llvm::User type.
1347 *
1348 * @see llvm::Use::getUser()
1349 */
Erick Tryzelaar9f9857e2010-03-02 20:32:28 +00001350LLVMValueRef LLVMGetUser(LLVMUseRef U);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001351
1352/**
1353 * Obtain the value this use corresponds to.
1354 *
1355 * @see llvm::Use::get().
1356 */
Erick Tryzelaar9f9857e2010-03-02 20:32:28 +00001357LLVMValueRef LLVMGetUsedValue(LLVMUseRef U);
Chris Lattner40cf28d2009-10-12 04:01:02 +00001358
Gregory Szorc34c863a2012-03-21 03:54:29 +00001359/**
1360 * @}
1361 */
1362
1363/**
Gregory Szorc52d26602012-03-21 07:28:27 +00001364 * @defgroup LLVMCCoreValueUser User value
Gregory Szorc34c863a2012-03-21 03:54:29 +00001365 *
1366 * Function in this group pertain to LLVMValueRef instances that descent
1367 * from llvm::User. This includes constants, instructions, and
1368 * operators.
1369 *
1370 * @{
1371 */
1372
1373/**
1374 * Obtain an operand at a specific index in a llvm::User value.
1375 *
1376 * @see llvm::User::getOperand()
1377 */
Chris Lattner40cf28d2009-10-12 04:01:02 +00001378LLVMValueRef LLVMGetOperand(LLVMValueRef Val, unsigned Index);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001379
1380/**
Peter Zotovb19f78f2014-08-12 02:55:40 +00001381 * Obtain the use of an operand at a specific index in a llvm::User value.
1382 *
1383 * @see llvm::User::getOperandUse()
1384 */
1385LLVMUseRef LLVMGetOperandUse(LLVMValueRef Val, unsigned Index);
1386
1387/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00001388 * Set an operand at a specific index in a llvm::User value.
1389 *
1390 * @see llvm::User::setOperand()
1391 */
Erick Tryzelaarb4d48702010-08-20 14:51:22 +00001392void LLVMSetOperand(LLVMValueRef User, unsigned Index, LLVMValueRef Val);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001393
1394/**
1395 * Obtain the number of operands in a llvm::User value.
1396 *
1397 * @see llvm::User::getNumOperands()
1398 */
Erick Tryzelaarb4d48702010-08-20 14:51:22 +00001399int LLVMGetNumOperands(LLVMValueRef Val);
Chris Lattner40cf28d2009-10-12 04:01:02 +00001400
Gregory Szorc34c863a2012-03-21 03:54:29 +00001401/**
1402 * @}
1403 */
1404
1405/**
Gregory Szorc52d26602012-03-21 07:28:27 +00001406 * @defgroup LLVMCCoreValueConstant Constants
Gregory Szorc34c863a2012-03-21 03:54:29 +00001407 *
1408 * This section contains APIs for interacting with LLVMValueRef that
1409 * correspond to llvm::Constant instances.
1410 *
1411 * These functions will work for any LLVMValueRef in the llvm::Constant
1412 * class hierarchy.
1413 *
1414 * @{
1415 */
1416
1417/**
1418 * Obtain a constant value referring to the null instance of a type.
1419 *
1420 * @see llvm::Constant::getNullValue()
1421 */
Gordon Henriksen1046c732007-10-06 15:11:06 +00001422LLVMValueRef LLVMConstNull(LLVMTypeRef Ty); /* all zeroes */
Gregory Szorc34c863a2012-03-21 03:54:29 +00001423
1424/**
1425 * Obtain a constant value referring to the instance of a type
1426 * consisting of all ones.
1427 *
1428 * This is only valid for integer types.
1429 *
1430 * @see llvm::Constant::getAllOnesValue()
1431 */
1432LLVMValueRef LLVMConstAllOnes(LLVMTypeRef Ty);
1433
1434/**
1435 * Obtain a constant value referring to an undefined value of a type.
1436 *
1437 * @see llvm::UndefValue::get()
1438 */
Gordon Henriksen76a03742007-09-18 03:18:57 +00001439LLVMValueRef LLVMGetUndef(LLVMTypeRef Ty);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001440
1441/**
1442 * Determine whether a value instance is null.
1443 *
1444 * @see llvm::Constant::isNullValue()
1445 */
Chris Lattner25963c62010-01-09 22:27:07 +00001446LLVMBool LLVMIsNull(LLVMValueRef Val);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001447
1448/**
1449 * Obtain a constant that is a constant pointer pointing to NULL for a
1450 * specified type.
1451 */
Chris Lattner7f318242009-07-06 17:29:59 +00001452LLVMValueRef LLVMConstPointerNull(LLVMTypeRef Ty);
Gordon Henriksen76a03742007-09-18 03:18:57 +00001453
Gregory Szorc34c863a2012-03-21 03:54:29 +00001454/**
1455 * @defgroup LLVMCCoreValueConstantScalar Scalar constants
1456 *
1457 * Functions in this group model LLVMValueRef instances that correspond
1458 * to constants referring to scalar types.
1459 *
1460 * For integer types, the LLVMTypeRef parameter should correspond to a
1461 * llvm::IntegerType instance and the returned LLVMValueRef will
1462 * correspond to a llvm::ConstantInt.
1463 *
1464 * For floating point types, the LLVMTypeRef returned corresponds to a
1465 * llvm::ConstantFP.
1466 *
1467 * @{
1468 */
Erick Tryzelaard8531fa2010-02-28 09:45:59 +00001469
Gregory Szorc34c863a2012-03-21 03:54:29 +00001470/**
1471 * Obtain a constant value for an integer type.
1472 *
1473 * The returned value corresponds to a llvm::ConstantInt.
1474 *
1475 * @see llvm::ConstantInt::get()
1476 *
1477 * @param IntTy Integer type to obtain value of.
1478 * @param N The value the returned instance should refer to.
1479 * @param SignExtend Whether to sign extend the produced value.
1480 */
Gordon Henriksen1046c732007-10-06 15:11:06 +00001481LLVMValueRef LLVMConstInt(LLVMTypeRef IntTy, unsigned long long N,
Chris Lattner25963c62010-01-09 22:27:07 +00001482 LLVMBool SignExtend);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001483
1484/**
1485 * Obtain a constant value for an integer of arbitrary precision.
1486 *
1487 * @see llvm::ConstantInt::get()
1488 */
Chris Lattner4329e072010-11-23 02:47:22 +00001489LLVMValueRef LLVMConstIntOfArbitraryPrecision(LLVMTypeRef IntTy,
1490 unsigned NumWords,
1491 const uint64_t Words[]);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001492
1493/**
1494 * Obtain a constant value for an integer parsed from a string.
1495 *
1496 * A similar API, LLVMConstIntOfStringAndSize is also available. If the
1497 * string's length is available, it is preferred to call that function
1498 * instead.
1499 *
1500 * @see llvm::ConstantInt::get()
1501 */
Erick Tryzelaardd991352009-08-16 23:36:46 +00001502LLVMValueRef LLVMConstIntOfString(LLVMTypeRef IntTy, const char *Text,
1503 uint8_t Radix);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001504
1505/**
1506 * Obtain a constant value for an integer parsed from a string with
1507 * specified length.
1508 *
1509 * @see llvm::ConstantInt::get()
1510 */
Erick Tryzelaardd991352009-08-16 23:36:46 +00001511LLVMValueRef LLVMConstIntOfStringAndSize(LLVMTypeRef IntTy, const char *Text,
1512 unsigned SLen, uint8_t Radix);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001513
1514/**
1515 * Obtain a constant value referring to a double floating point value.
1516 */
Gordon Henriksen1046c732007-10-06 15:11:06 +00001517LLVMValueRef LLVMConstReal(LLVMTypeRef RealTy, double N);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001518
1519/**
1520 * Obtain a constant for a floating point value parsed from a string.
1521 *
1522 * A similar API, LLVMConstRealOfStringAndSize is also available. It
1523 * should be used if the input string's length is known.
1524 */
Gordon Henriksen931e1212008-02-02 01:07:50 +00001525LLVMValueRef LLVMConstRealOfString(LLVMTypeRef RealTy, const char *Text);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001526
1527/**
1528 * Obtain a constant for a floating point value parsed from a string.
1529 */
Erick Tryzelaardd991352009-08-16 23:36:46 +00001530LLVMValueRef LLVMConstRealOfStringAndSize(LLVMTypeRef RealTy, const char *Text,
1531 unsigned SLen);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001532
1533/**
1534 * Obtain the zero extended value for an integer constant value.
1535 *
1536 * @see llvm::ConstantInt::getZExtValue()
1537 */
Chris Lattner40cf28d2009-10-12 04:01:02 +00001538unsigned long long LLVMConstIntGetZExtValue(LLVMValueRef ConstantVal);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001539
1540/**
1541 * Obtain the sign extended value for an integer constant value.
1542 *
1543 * @see llvm::ConstantInt::getSExtValue()
1544 */
Chris Lattner40cf28d2009-10-12 04:01:02 +00001545long long LLVMConstIntGetSExtValue(LLVMValueRef ConstantVal);
Erick Tryzelaardd991352009-08-16 23:36:46 +00001546
Gregory Szorc34c863a2012-03-21 03:54:29 +00001547/**
Peter Zotov1d98e6d2014-10-28 19:46:44 +00001548 * Obtain the double value for an floating point constant value.
1549 * losesInfo indicates if some precision was lost in the conversion.
1550 *
1551 * @see llvm::ConstantFP::getDoubleValue
1552 */
1553double LLVMConstRealGetDouble(LLVMValueRef ConstantVal, LLVMBool *losesInfo);
1554
1555/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00001556 * @}
1557 */
1558
1559/**
Gregory Szorc52d26602012-03-21 07:28:27 +00001560 * @defgroup LLVMCCoreValueConstantComposite Composite Constants
1561 *
1562 * Functions in this group operate on composite constants.
Gregory Szorc34c863a2012-03-21 03:54:29 +00001563 *
1564 * @{
1565 */
1566
1567/**
Gregory Szorc52d26602012-03-21 07:28:27 +00001568 * Create a ConstantDataSequential and initialize it with a string.
Gregory Szorc34c863a2012-03-21 03:54:29 +00001569 *
Gregory Szorc52d26602012-03-21 07:28:27 +00001570 * @see llvm::ConstantDataArray::getString()
Gregory Szorc34c863a2012-03-21 03:54:29 +00001571 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +00001572LLVMValueRef LLVMConstStringInContext(LLVMContextRef C, const char *Str,
Chris Lattner25963c62010-01-09 22:27:07 +00001573 unsigned Length, LLVMBool DontNullTerminate);
Gregory Szorc52d26602012-03-21 07:28:27 +00001574
1575/**
1576 * Create a ConstantDataSequential with string content in the global context.
1577 *
1578 * This is the same as LLVMConstStringInContext except it operates on the
1579 * global context.
1580 *
1581 * @see LLVMConstStringInContext()
1582 * @see llvm::ConstantDataArray::getString()
1583 */
1584LLVMValueRef LLVMConstString(const char *Str, unsigned Length,
1585 LLVMBool DontNullTerminate);
1586
1587/**
Peter Zotovf9aa8822014-08-03 23:54:16 +00001588 * Returns true if the specified constant is an array of i8.
1589 *
1590 * @see ConstantDataSequential::getAsString()
1591 */
1592LLVMBool LLVMIsConstantString(LLVMValueRef c);
1593
1594/**
1595 * Get the given constant data sequential as a string.
1596 *
1597 * @see ConstantDataSequential::getAsString()
1598 */
Amaury Sechet7c2883c2016-04-03 21:06:04 +00001599const char *LLVMGetAsString(LLVMValueRef c, size_t *Length);
Peter Zotovf9aa8822014-08-03 23:54:16 +00001600
1601/**
Gregory Szorc52d26602012-03-21 07:28:27 +00001602 * Create an anonymous ConstantStruct with the specified values.
1603 *
1604 * @see llvm::ConstantStruct::getAnon()
1605 */
1606LLVMValueRef LLVMConstStructInContext(LLVMContextRef C,
Erick Tryzelaar262332f2009-08-14 00:01:31 +00001607 LLVMValueRef *ConstantVals,
Chris Lattner25963c62010-01-09 22:27:07 +00001608 unsigned Count, LLVMBool Packed);
Erick Tryzelaar262332f2009-08-14 00:01:31 +00001609
Gregory Szorc52d26602012-03-21 07:28:27 +00001610/**
1611 * Create a ConstantStruct in the global Context.
1612 *
1613 * This is the same as LLVMConstStructInContext except it operates on the
1614 * global Context.
1615 *
1616 * @see LLVMConstStructInContext()
1617 */
Gordon Henriksen1046c732007-10-06 15:11:06 +00001618LLVMValueRef LLVMConstStruct(LLVMValueRef *ConstantVals, unsigned Count,
Chris Lattner25963c62010-01-09 22:27:07 +00001619 LLVMBool Packed);
Gregory Szorc52d26602012-03-21 07:28:27 +00001620
1621/**
1622 * Create a ConstantArray from values.
1623 *
1624 * @see llvm::ConstantArray::get()
1625 */
1626LLVMValueRef LLVMConstArray(LLVMTypeRef ElementTy,
1627 LLVMValueRef *ConstantVals, unsigned Length);
1628
1629/**
1630 * Create a non-anonymous ConstantStruct from values.
1631 *
1632 * @see llvm::ConstantStruct::get()
1633 */
Rafael Espindola784ad242011-07-14 19:09:08 +00001634LLVMValueRef LLVMConstNamedStruct(LLVMTypeRef StructTy,
1635 LLVMValueRef *ConstantVals,
1636 unsigned Count);
Gregory Szorc52d26602012-03-21 07:28:27 +00001637
1638/**
Peter Zotovf9aa8822014-08-03 23:54:16 +00001639 * Get an element at specified index as a constant.
1640 *
1641 * @see ConstantDataSequential::getElementAsConstant()
1642 */
Amaury Sechet006ce632016-03-13 00:54:40 +00001643LLVMValueRef LLVMGetElementAsConstant(LLVMValueRef C, unsigned idx);
Peter Zotovf9aa8822014-08-03 23:54:16 +00001644
1645/**
Gregory Szorc52d26602012-03-21 07:28:27 +00001646 * Create a ConstantVector from values.
1647 *
1648 * @see llvm::ConstantVector::get()
1649 */
Gordon Henriksen1046c732007-10-06 15:11:06 +00001650LLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals, unsigned Size);
Gordon Henriksen76a03742007-09-18 03:18:57 +00001651
Gregory Szorc52d26602012-03-21 07:28:27 +00001652/**
1653 * @}
1654 */
1655
1656/**
1657 * @defgroup LLVMCCoreValueConstantExpressions Constant Expressions
1658 *
1659 * Functions in this group correspond to APIs on llvm::ConstantExpr.
1660 *
1661 * @see llvm::ConstantExpr.
1662 *
1663 * @{
1664 */
Chris Lattner40cf28d2009-10-12 04:01:02 +00001665LLVMOpcode LLVMGetConstOpcode(LLVMValueRef ConstantVal);
Erick Tryzelaarfd529d72009-08-19 08:36:49 +00001666LLVMValueRef LLVMAlignOf(LLVMTypeRef Ty);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001667LLVMValueRef LLVMSizeOf(LLVMTypeRef Ty);
1668LLVMValueRef LLVMConstNeg(LLVMValueRef ConstantVal);
Erick Tryzelaar4c340c72010-02-28 05:51:43 +00001669LLVMValueRef LLVMConstNSWNeg(LLVMValueRef ConstantVal);
1670LLVMValueRef LLVMConstNUWNeg(LLVMValueRef ConstantVal);
Erick Tryzelaar4cc690c2009-08-16 02:20:12 +00001671LLVMValueRef LLVMConstFNeg(LLVMValueRef ConstantVal);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001672LLVMValueRef LLVMConstNot(LLVMValueRef ConstantVal);
1673LLVMValueRef LLVMConstAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Dan Gohmane4ca02d2009-09-03 23:34:49 +00001674LLVMValueRef LLVMConstNSWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Erick Tryzelaar4c340c72010-02-28 05:51:43 +00001675LLVMValueRef LLVMConstNUWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Erick Tryzelaar4cc690c2009-08-16 02:20:12 +00001676LLVMValueRef LLVMConstFAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001677LLVMValueRef LLVMConstSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Erick Tryzelaar4c340c72010-02-28 05:51:43 +00001678LLVMValueRef LLVMConstNSWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1679LLVMValueRef LLVMConstNUWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Erick Tryzelaar4cc690c2009-08-16 02:20:12 +00001680LLVMValueRef LLVMConstFSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001681LLVMValueRef LLVMConstMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Erick Tryzelaar4c340c72010-02-28 05:51:43 +00001682LLVMValueRef LLVMConstNSWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1683LLVMValueRef LLVMConstNUWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Erick Tryzelaar4cc690c2009-08-16 02:20:12 +00001684LLVMValueRef LLVMConstFMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001685LLVMValueRef LLVMConstUDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1686LLVMValueRef LLVMConstSDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Dan Gohmane4ca02d2009-09-03 23:34:49 +00001687LLVMValueRef LLVMConstExactSDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001688LLVMValueRef LLVMConstFDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1689LLVMValueRef LLVMConstURem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1690LLVMValueRef LLVMConstSRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1691LLVMValueRef LLVMConstFRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1692LLVMValueRef LLVMConstAnd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1693LLVMValueRef LLVMConstOr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1694LLVMValueRef LLVMConstXor(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1695LLVMValueRef LLVMConstICmp(LLVMIntPredicate Predicate,
1696 LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1697LLVMValueRef LLVMConstFCmp(LLVMRealPredicate Predicate,
1698 LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1699LLVMValueRef LLVMConstShl(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1700LLVMValueRef LLVMConstLShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1701LLVMValueRef LLVMConstAShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1702LLVMValueRef LLVMConstGEP(LLVMValueRef ConstantVal,
1703 LLVMValueRef *ConstantIndices, unsigned NumIndices);
Dan Gohmane4ca02d2009-09-03 23:34:49 +00001704LLVMValueRef LLVMConstInBoundsGEP(LLVMValueRef ConstantVal,
1705 LLVMValueRef *ConstantIndices,
1706 unsigned NumIndices);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001707LLVMValueRef LLVMConstTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1708LLVMValueRef LLVMConstSExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1709LLVMValueRef LLVMConstZExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1710LLVMValueRef LLVMConstFPTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1711LLVMValueRef LLVMConstFPExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1712LLVMValueRef LLVMConstUIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1713LLVMValueRef LLVMConstSIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1714LLVMValueRef LLVMConstFPToUI(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1715LLVMValueRef LLVMConstFPToSI(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1716LLVMValueRef LLVMConstPtrToInt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1717LLVMValueRef LLVMConstIntToPtr(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1718LLVMValueRef LLVMConstBitCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
Matt Arsenaultb03bd4d2013-11-15 01:34:59 +00001719LLVMValueRef LLVMConstAddrSpaceCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
Erick Tryzelaar4cc690c2009-08-16 02:20:12 +00001720LLVMValueRef LLVMConstZExtOrBitCast(LLVMValueRef ConstantVal,
1721 LLVMTypeRef ToType);
1722LLVMValueRef LLVMConstSExtOrBitCast(LLVMValueRef ConstantVal,
1723 LLVMTypeRef ToType);
1724LLVMValueRef LLVMConstTruncOrBitCast(LLVMValueRef ConstantVal,
1725 LLVMTypeRef ToType);
1726LLVMValueRef LLVMConstPointerCast(LLVMValueRef ConstantVal,
1727 LLVMTypeRef ToType);
1728LLVMValueRef LLVMConstIntCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType,
Chris Lattner25963c62010-01-09 22:27:07 +00001729 LLVMBool isSigned);
Erick Tryzelaar4cc690c2009-08-16 02:20:12 +00001730LLVMValueRef LLVMConstFPCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001731LLVMValueRef LLVMConstSelect(LLVMValueRef ConstantCondition,
1732 LLVMValueRef ConstantIfTrue,
1733 LLVMValueRef ConstantIfFalse);
1734LLVMValueRef LLVMConstExtractElement(LLVMValueRef VectorConstant,
1735 LLVMValueRef IndexConstant);
1736LLVMValueRef LLVMConstInsertElement(LLVMValueRef VectorConstant,
1737 LLVMValueRef ElementValueConstant,
1738 LLVMValueRef IndexConstant);
1739LLVMValueRef LLVMConstShuffleVector(LLVMValueRef VectorAConstant,
1740 LLVMValueRef VectorBConstant,
1741 LLVMValueRef MaskConstant);
Dan Gohmand5104a52008-11-03 22:55:43 +00001742LLVMValueRef LLVMConstExtractValue(LLVMValueRef AggConstant, unsigned *IdxList,
1743 unsigned NumIdx);
1744LLVMValueRef LLVMConstInsertValue(LLVMValueRef AggConstant,
1745 LLVMValueRef ElementValueConstant,
1746 unsigned *IdxList, unsigned NumIdx);
Chris Lattner25963c62010-01-09 22:27:07 +00001747LLVMValueRef LLVMConstInlineAsm(LLVMTypeRef Ty,
Chris Lattner3d1f5522008-12-17 21:39:50 +00001748 const char *AsmString, const char *Constraints,
Chris Lattner25963c62010-01-09 22:27:07 +00001749 LLVMBool HasSideEffects, LLVMBool IsAlignStack);
Erick Tryzelaar0fb26ef2010-02-28 09:46:06 +00001750LLVMValueRef LLVMBlockAddress(LLVMValueRef F, LLVMBasicBlockRef BB);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001751
Gregory Szorc52d26602012-03-21 07:28:27 +00001752/**
1753 * @}
1754 */
1755
1756/**
1757 * @defgroup LLVMCCoreValueConstantGlobals Global Values
1758 *
1759 * This group contains functions that operate on global values. Functions in
1760 * this group relate to functions in the llvm::GlobalValue class tree.
1761 *
1762 * @see llvm::GlobalValue
1763 *
1764 * @{
1765 */
1766
Gordon Henriksen265f7802008-03-19 01:11:35 +00001767LLVMModuleRef LLVMGetGlobalParent(LLVMValueRef Global);
Chris Lattner25963c62010-01-09 22:27:07 +00001768LLVMBool LLVMIsDeclaration(LLVMValueRef Global);
Gordon Henriksen76a03742007-09-18 03:18:57 +00001769LLVMLinkage LLVMGetLinkage(LLVMValueRef Global);
1770void LLVMSetLinkage(LLVMValueRef Global, LLVMLinkage Linkage);
1771const char *LLVMGetSection(LLVMValueRef Global);
1772void LLVMSetSection(LLVMValueRef Global, const char *Section);
1773LLVMVisibility LLVMGetVisibility(LLVMValueRef Global);
1774void LLVMSetVisibility(LLVMValueRef Global, LLVMVisibility Viz);
Reid Kleckner2fae26f2014-03-05 02:34:23 +00001775LLVMDLLStorageClass LLVMGetDLLStorageClass(LLVMValueRef Global);
1776void LLVMSetDLLStorageClass(LLVMValueRef Global, LLVMDLLStorageClass Class);
Tim Northoverad96d012014-03-10 19:24:35 +00001777LLVMBool LLVMHasUnnamedAddr(LLVMValueRef Global);
1778void LLVMSetUnnamedAddr(LLVMValueRef Global, LLVMBool HasUnnamedAddr);
Anders Waldenborg213a63f2013-10-29 09:02:02 +00001779
1780/**
1781 * @defgroup LLVMCCoreValueWithAlignment Values with alignment
1782 *
1783 * Functions in this group only apply to values with alignment, i.e.
1784 * global variables, load and store instructions.
1785 */
1786
1787/**
1788 * Obtain the preferred alignment of the value.
Peter Zotov9f584e62014-03-05 05:05:34 +00001789 * @see llvm::AllocaInst::getAlignment()
Anders Waldenborg213a63f2013-10-29 09:02:02 +00001790 * @see llvm::LoadInst::getAlignment()
1791 * @see llvm::StoreInst::getAlignment()
1792 * @see llvm::GlobalValue::getAlignment()
1793 */
1794unsigned LLVMGetAlignment(LLVMValueRef V);
1795
1796/**
1797 * Set the preferred alignment of the value.
Peter Zotov9f584e62014-03-05 05:05:34 +00001798 * @see llvm::AllocaInst::setAlignment()
Anders Waldenborg213a63f2013-10-29 09:02:02 +00001799 * @see llvm::LoadInst::setAlignment()
1800 * @see llvm::StoreInst::setAlignment()
1801 * @see llvm::GlobalValue::setAlignment()
1802 */
1803void LLVMSetAlignment(LLVMValueRef V, unsigned Bytes);
1804
1805/**
Amaury Sechet83550102016-02-14 08:58:49 +00001806 * @}
1807 */
Gordon Henriksen76a03742007-09-18 03:18:57 +00001808
Gregory Szorc52d26602012-03-21 07:28:27 +00001809/**
1810 * @defgroup LLVMCoreValueConstantGlobalVariable Global Variables
1811 *
1812 * This group contains functions that operate on global variable values.
1813 *
1814 * @see llvm::GlobalVariable
1815 *
1816 * @{
1817 */
Gordon Henriksen76a03742007-09-18 03:18:57 +00001818LLVMValueRef LLVMAddGlobal(LLVMModuleRef M, LLVMTypeRef Ty, const char *Name);
Erick Tryzelaar06894b32010-02-28 09:46:13 +00001819LLVMValueRef LLVMAddGlobalInAddressSpace(LLVMModuleRef M, LLVMTypeRef Ty,
1820 const char *Name,
1821 unsigned AddressSpace);
Gordon Henriksen783f7bb2007-10-08 03:45:09 +00001822LLVMValueRef LLVMGetNamedGlobal(LLVMModuleRef M, const char *Name);
Gordon Henriksen07a45f42008-03-23 22:21:29 +00001823LLVMValueRef LLVMGetFirstGlobal(LLVMModuleRef M);
1824LLVMValueRef LLVMGetLastGlobal(LLVMModuleRef M);
1825LLVMValueRef LLVMGetNextGlobal(LLVMValueRef GlobalVar);
1826LLVMValueRef LLVMGetPreviousGlobal(LLVMValueRef GlobalVar);
Gordon Henriksen76a03742007-09-18 03:18:57 +00001827void LLVMDeleteGlobal(LLVMValueRef GlobalVar);
Gordon Henriksen76a03742007-09-18 03:18:57 +00001828LLVMValueRef LLVMGetInitializer(LLVMValueRef GlobalVar);
1829void LLVMSetInitializer(LLVMValueRef GlobalVar, LLVMValueRef ConstantVal);
Chris Lattner25963c62010-01-09 22:27:07 +00001830LLVMBool LLVMIsThreadLocal(LLVMValueRef GlobalVar);
1831void LLVMSetThreadLocal(LLVMValueRef GlobalVar, LLVMBool IsThreadLocal);
1832LLVMBool LLVMIsGlobalConstant(LLVMValueRef GlobalVar);
1833void LLVMSetGlobalConstant(LLVMValueRef GlobalVar, LLVMBool IsConstant);
Hans Wennborg5ff71202013-04-16 08:58:59 +00001834LLVMThreadLocalMode LLVMGetThreadLocalMode(LLVMValueRef GlobalVar);
1835void LLVMSetThreadLocalMode(LLVMValueRef GlobalVar, LLVMThreadLocalMode Mode);
1836LLVMBool LLVMIsExternallyInitialized(LLVMValueRef GlobalVar);
1837void LLVMSetExternallyInitialized(LLVMValueRef GlobalVar, LLVMBool IsExtInit);
Gordon Henriksen76a03742007-09-18 03:18:57 +00001838
Gregory Szorc52d26602012-03-21 07:28:27 +00001839/**
1840 * @}
1841 */
1842
1843/**
1844 * @defgroup LLVMCoreValueConstantGlobalAlias Global Aliases
1845 *
1846 * This group contains function that operate on global alias values.
1847 *
1848 * @see llvm::GlobalAlias
1849 *
1850 * @{
1851 */
Chris Lattner3d1f5522008-12-17 21:39:50 +00001852LLVMValueRef LLVMAddAlias(LLVMModuleRef M, LLVMTypeRef Ty, LLVMValueRef Aliasee,
1853 const char *Name);
1854
Gregory Szorc34c863a2012-03-21 03:54:29 +00001855/**
1856 * @}
1857 */
1858
1859/**
1860 * @defgroup LLVMCCoreValueFunction Function values
1861 *
1862 * Functions in this group operate on LLVMValueRef instances that
1863 * correspond to llvm::Function instances.
1864 *
1865 * @see llvm::Function
1866 *
1867 * @{
1868 */
1869
1870/**
1871 * Remove a function from its containing module and deletes it.
1872 *
1873 * @see llvm::Function::eraseFromParent()
1874 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00001875void LLVMDeleteFunction(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001876
1877/**
Amaury Sechete39e8532016-02-18 20:38:32 +00001878 * Check whether the given function has a personality function.
1879 *
1880 * @see llvm::Function::hasPersonalityFn()
1881 */
1882LLVMBool LLVMHasPersonalityFn(LLVMValueRef Fn);
1883
1884/**
Andrew Wilkins3bdfc1c2015-07-14 01:23:06 +00001885 * Obtain the personality function attached to the function.
1886 *
1887 * @see llvm::Function::getPersonalityFn()
1888 */
1889LLVMValueRef LLVMGetPersonalityFn(LLVMValueRef Fn);
1890
1891/**
1892 * Set the personality function attached to the function.
1893 *
1894 * @see llvm::Function::setPersonalityFn()
1895 */
1896void LLVMSetPersonalityFn(LLVMValueRef Fn, LLVMValueRef PersonalityFn);
1897
1898/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00001899 * Obtain the ID number from a function instance.
1900 *
1901 * @see llvm::Function::getIntrinsicID()
1902 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00001903unsigned LLVMGetIntrinsicID(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001904
1905/**
1906 * Obtain the calling function of a function.
1907 *
1908 * The returned value corresponds to the LLVMCallConv enumeration.
1909 *
1910 * @see llvm::Function::getCallingConv()
1911 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00001912unsigned LLVMGetFunctionCallConv(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001913
1914/**
1915 * Set the calling convention of a function.
1916 *
1917 * @see llvm::Function::setCallingConv()
1918 *
1919 * @param Fn Function to operate on
1920 * @param CC LLVMCallConv to set calling convention to
1921 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00001922void LLVMSetFunctionCallConv(LLVMValueRef Fn, unsigned CC);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001923
1924/**
1925 * Obtain the name of the garbage collector to use during code
1926 * generation.
1927 *
1928 * @see llvm::Function::getGC()
1929 */
Gordon Henriksend930f912008-08-17 18:44:35 +00001930const char *LLVMGetGC(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001931
1932/**
1933 * Define the garbage collector to use during code generation.
1934 *
1935 * @see llvm::Function::setGC()
1936 */
Gordon Henriksend930f912008-08-17 18:44:35 +00001937void LLVMSetGC(LLVMValueRef Fn, const char *Name);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001938
1939/**
1940 * Add an attribute to a function.
1941 *
1942 * @see llvm::Function::addAttribute()
1943 */
Duncan Sands7374a012009-05-06 12:21:17 +00001944void LLVMAddFunctionAttr(LLVMValueRef Fn, LLVMAttribute PA);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001945
1946/**
Nick Lewyckyc3890d22015-07-29 22:32:47 +00001947 * Add a target-dependent attribute to a function
Tom Stellarde8f35e12013-04-16 23:12:43 +00001948 * @see llvm::AttrBuilder::addAttribute()
1949 */
1950void LLVMAddTargetDependentFunctionAttr(LLVMValueRef Fn, const char *A,
1951 const char *V);
1952
1953/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00001954 * Obtain an attribute from a function.
1955 *
1956 * @see llvm::Function::getAttributes()
1957 */
Chris Lattner40cf28d2009-10-12 04:01:02 +00001958LLVMAttribute LLVMGetFunctionAttr(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001959
1960/**
1961 * Remove an attribute from a function.
1962 */
Duncan Sands7374a012009-05-06 12:21:17 +00001963void LLVMRemoveFunctionAttr(LLVMValueRef Fn, LLVMAttribute PA);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00001964
Gregory Szorc34c863a2012-03-21 03:54:29 +00001965/**
1966 * @defgroup LLVMCCoreValueFunctionParameters Function Parameters
1967 *
1968 * Functions in this group relate to arguments/parameters on functions.
1969 *
1970 * Functions in this group expect LLVMValueRef instances that correspond
1971 * to llvm::Function instances.
1972 *
1973 * @{
1974 */
1975
1976/**
1977 * Obtain the number of parameters in a function.
1978 *
1979 * @see llvm::Function::arg_size()
1980 */
Gordon Henriksen265f7802008-03-19 01:11:35 +00001981unsigned LLVMCountParams(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001982
1983/**
1984 * Obtain the parameters in a function.
1985 *
1986 * The takes a pointer to a pre-allocated array of LLVMValueRef that is
1987 * at least LLVMCountParams() long. This array will be filled with
1988 * LLVMValueRef instances which correspond to the parameters the
1989 * function receives. Each LLVMValueRef corresponds to a llvm::Argument
1990 * instance.
1991 *
1992 * @see llvm::Function::arg_begin()
1993 */
Gordon Henriksen265f7802008-03-19 01:11:35 +00001994void LLVMGetParams(LLVMValueRef Fn, LLVMValueRef *Params);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001995
1996/**
1997 * Obtain the parameter at the specified index.
1998 *
1999 * Parameters are indexed from 0.
2000 *
2001 * @see llvm::Function::arg_begin()
2002 */
Gordon Henriksen265f7802008-03-19 01:11:35 +00002003LLVMValueRef LLVMGetParam(LLVMValueRef Fn, unsigned Index);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002004
2005/**
2006 * Obtain the function to which this argument belongs.
2007 *
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00002008 * Unlike other functions in this group, this one takes an LLVMValueRef
Gregory Szorc34c863a2012-03-21 03:54:29 +00002009 * that corresponds to a llvm::Attribute.
2010 *
2011 * The returned LLVMValueRef is the llvm::Function to which this
2012 * argument belongs.
2013 */
Gordon Henriksen265f7802008-03-19 01:11:35 +00002014LLVMValueRef LLVMGetParamParent(LLVMValueRef Inst);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002015
2016/**
2017 * Obtain the first parameter to a function.
2018 *
2019 * @see llvm::Function::arg_begin()
2020 */
Gordon Henriksen07a45f42008-03-23 22:21:29 +00002021LLVMValueRef LLVMGetFirstParam(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002022
2023/**
2024 * Obtain the last parameter to a function.
2025 *
2026 * @see llvm::Function::arg_end()
2027 */
Gordon Henriksen07a45f42008-03-23 22:21:29 +00002028LLVMValueRef LLVMGetLastParam(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002029
2030/**
2031 * Obtain the next parameter to a function.
2032 *
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00002033 * This takes an LLVMValueRef obtained from LLVMGetFirstParam() (which is
Gregory Szorc34c863a2012-03-21 03:54:29 +00002034 * actually a wrapped iterator) and obtains the next parameter from the
2035 * underlying iterator.
2036 */
Gordon Henriksen07a45f42008-03-23 22:21:29 +00002037LLVMValueRef LLVMGetNextParam(LLVMValueRef Arg);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002038
2039/**
2040 * Obtain the previous parameter to a function.
2041 *
2042 * This is the opposite of LLVMGetNextParam().
2043 */
Gordon Henriksen07a45f42008-03-23 22:21:29 +00002044LLVMValueRef LLVMGetPreviousParam(LLVMValueRef Arg);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002045
2046/**
2047 * Add an attribute to a function argument.
2048 *
2049 * @see llvm::Argument::addAttr()
2050 */
Devang Patel4c758ea2008-09-25 21:00:45 +00002051void LLVMAddAttribute(LLVMValueRef Arg, LLVMAttribute PA);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002052
2053/**
2054 * Remove an attribute from a function argument.
2055 *
2056 * @see llvm::Argument::removeAttr()
2057 */
Devang Patel4c758ea2008-09-25 21:00:45 +00002058void LLVMRemoveAttribute(LLVMValueRef Arg, LLVMAttribute PA);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002059
2060/**
2061 * Get an attribute from a function argument.
2062 */
Chris Lattner40cf28d2009-10-12 04:01:02 +00002063LLVMAttribute LLVMGetAttribute(LLVMValueRef Arg);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002064
2065/**
2066 * Set the alignment for a function parameter.
2067 *
2068 * @see llvm::Argument::addAttr()
Bill Wendling50d27842012-10-15 20:35:56 +00002069 * @see llvm::AttrBuilder::addAlignmentAttr()
Gregory Szorc34c863a2012-03-21 03:54:29 +00002070 */
Gordon Henriksen2d9cc212008-04-28 17:37:06 +00002071void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned align);
Gordon Henriksen265f7802008-03-19 01:11:35 +00002072
Gregory Szorc34c863a2012-03-21 03:54:29 +00002073/**
2074 * @}
2075 */
2076
2077/**
2078 * @}
2079 */
2080
2081/**
Gregory Szorc52d26602012-03-21 07:28:27 +00002082 * @}
2083 */
2084
2085/**
2086 * @}
2087 */
2088
2089/**
2090 * @defgroup LLVMCCoreValueMetadata Metadata
2091 *
2092 * @{
2093 */
2094
2095/**
2096 * Obtain a MDString value from a context.
2097 *
2098 * The returned instance corresponds to the llvm::MDString class.
2099 *
2100 * The instance is specified by string data of a specified length. The
2101 * string content is copied, so the backing memory can be freed after
2102 * this function returns.
2103 */
2104LLVMValueRef LLVMMDStringInContext(LLVMContextRef C, const char *Str,
2105 unsigned SLen);
2106
2107/**
2108 * Obtain a MDString value from the global context.
2109 */
2110LLVMValueRef LLVMMDString(const char *Str, unsigned SLen);
2111
2112/**
2113 * Obtain a MDNode value from a context.
2114 *
2115 * The returned value corresponds to the llvm::MDNode class.
2116 */
2117LLVMValueRef LLVMMDNodeInContext(LLVMContextRef C, LLVMValueRef *Vals,
2118 unsigned Count);
2119
2120/**
2121 * Obtain a MDNode value from the global context.
2122 */
2123LLVMValueRef LLVMMDNode(LLVMValueRef *Vals, unsigned Count);
2124
2125/**
2126 * Obtain the underlying string from a MDString value.
2127 *
2128 * @param V Instance to obtain string from.
NAKAMURA Takumie4a77052016-04-04 11:54:48 +00002129 * @param Length Memory address which will hold length of returned string.
Gregory Szorc52d26602012-03-21 07:28:27 +00002130 * @return String data in MDString.
2131 */
Amaury Sechet7c2883c2016-04-03 21:06:04 +00002132const char *LLVMGetMDString(LLVMValueRef V, unsigned *Length);
Gregory Szorc52d26602012-03-21 07:28:27 +00002133
2134/**
Duncan Sands12ccbe72012-09-19 20:29:39 +00002135 * Obtain the number of operands from an MDNode value.
2136 *
2137 * @param V MDNode to get number of operands from.
2138 * @return Number of operands of the MDNode.
2139 */
2140unsigned LLVMGetMDNodeNumOperands(LLVMValueRef V);
2141
2142/**
2143 * Obtain the given MDNode's operands.
2144 *
2145 * The passed LLVMValueRef pointer should point to enough memory to hold all of
2146 * the operands of the given MDNode (see LLVMGetMDNodeNumOperands) as
2147 * LLVMValueRefs. This memory will be populated with the LLVMValueRefs of the
2148 * MDNode's operands.
2149 *
2150 * @param V MDNode to get the operands from.
2151 * @param Dest Destination array for operands.
2152 */
2153void LLVMGetMDNodeOperands(LLVMValueRef V, LLVMValueRef *Dest);
2154
2155/**
Gregory Szorc52d26602012-03-21 07:28:27 +00002156 * @}
2157 */
2158
2159/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002160 * @defgroup LLVMCCoreValueBasicBlock Basic Block
2161 *
2162 * A basic block represents a single entry single exit section of code.
2163 * Basic blocks contain a list of instructions which form the body of
2164 * the block.
2165 *
2166 * Basic blocks belong to functions. They have the type of label.
2167 *
2168 * Basic blocks are themselves values. However, the C API models them as
2169 * LLVMBasicBlockRef.
2170 *
2171 * @see llvm::BasicBlock
2172 *
2173 * @{
2174 */
2175
2176/**
2177 * Convert a basic block instance to a value type.
2178 */
Gordon Henriksen07a45f42008-03-23 22:21:29 +00002179LLVMValueRef LLVMBasicBlockAsValue(LLVMBasicBlockRef BB);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002180
2181/**
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00002182 * Determine whether an LLVMValueRef is itself a basic block.
Gregory Szorc34c863a2012-03-21 03:54:29 +00002183 */
Chris Lattner25963c62010-01-09 22:27:07 +00002184LLVMBool LLVMValueIsBasicBlock(LLVMValueRef Val);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002185
2186/**
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00002187 * Convert an LLVMValueRef to an LLVMBasicBlockRef instance.
Gregory Szorc34c863a2012-03-21 03:54:29 +00002188 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002189LLVMBasicBlockRef LLVMValueAsBasicBlock(LLVMValueRef Val);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002190
2191/**
Amaury Secheta82042e2016-02-09 22:36:41 +00002192 * Obtain the string name of a basic block.
2193 */
2194const char *LLVMGetBasicBlockName(LLVMBasicBlockRef BB);
2195
2196/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002197 * Obtain the function to which a basic block belongs.
2198 *
2199 * @see llvm::BasicBlock::getParent()
2200 */
Gordon Henriksen07a45f42008-03-23 22:21:29 +00002201LLVMValueRef LLVMGetBasicBlockParent(LLVMBasicBlockRef BB);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002202
2203/**
2204 * Obtain the terminator instruction for a basic block.
2205 *
2206 * If the basic block does not have a terminator (it is not well-formed
2207 * if it doesn't), then NULL is returned.
2208 *
2209 * The returned LLVMValueRef corresponds to a llvm::TerminatorInst.
2210 *
2211 * @see llvm::BasicBlock::getTerminator()
2212 */
Nate Begeman43c322b2011-08-23 20:27:46 +00002213LLVMValueRef LLVMGetBasicBlockTerminator(LLVMBasicBlockRef BB);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002214
2215/**
2216 * Obtain the number of basic blocks in a function.
2217 *
2218 * @param Fn Function value to operate on.
2219 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002220unsigned LLVMCountBasicBlocks(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002221
2222/**
2223 * Obtain all of the basic blocks in a function.
2224 *
2225 * This operates on a function value. The BasicBlocks parameter is a
2226 * pointer to a pre-allocated array of LLVMBasicBlockRef of at least
2227 * LLVMCountBasicBlocks() in length. This array is populated with
2228 * LLVMBasicBlockRef instances.
2229 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002230void LLVMGetBasicBlocks(LLVMValueRef Fn, LLVMBasicBlockRef *BasicBlocks);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002231
2232/**
2233 * Obtain the first basic block in a function.
2234 *
2235 * The returned basic block can be used as an iterator. You will likely
2236 * eventually call into LLVMGetNextBasicBlock() with it.
2237 *
2238 * @see llvm::Function::begin()
2239 */
Gordon Henriksen054817c2008-03-19 03:47:18 +00002240LLVMBasicBlockRef LLVMGetFirstBasicBlock(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002241
2242/**
2243 * Obtain the last basic block in a function.
2244 *
2245 * @see llvm::Function::end()
2246 */
Gordon Henriksen054817c2008-03-19 03:47:18 +00002247LLVMBasicBlockRef LLVMGetLastBasicBlock(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002248
2249/**
2250 * Advance a basic block iterator.
2251 */
Gordon Henriksen054817c2008-03-19 03:47:18 +00002252LLVMBasicBlockRef LLVMGetNextBasicBlock(LLVMBasicBlockRef BB);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002253
2254/**
2255 * Go backwards in a basic block iterator.
2256 */
Gordon Henriksen054817c2008-03-19 03:47:18 +00002257LLVMBasicBlockRef LLVMGetPreviousBasicBlock(LLVMBasicBlockRef BB);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002258
2259/**
2260 * Obtain the basic block that corresponds to the entry point of a
2261 * function.
2262 *
2263 * @see llvm::Function::getEntryBlock()
2264 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002265LLVMBasicBlockRef LLVMGetEntryBasicBlock(LLVMValueRef Fn);
Erick Tryzelaar262332f2009-08-14 00:01:31 +00002266
Gregory Szorc34c863a2012-03-21 03:54:29 +00002267/**
2268 * Append a basic block to the end of a function.
2269 *
2270 * @see llvm::BasicBlock::Create()
2271 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +00002272LLVMBasicBlockRef LLVMAppendBasicBlockInContext(LLVMContextRef C,
2273 LLVMValueRef Fn,
2274 const char *Name);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002275
2276/**
2277 * Append a basic block to the end of a function using the global
2278 * context.
2279 *
2280 * @see llvm::BasicBlock::Create()
2281 */
2282LLVMBasicBlockRef LLVMAppendBasicBlock(LLVMValueRef Fn, const char *Name);
2283
2284/**
2285 * Insert a basic block in a function before another basic block.
2286 *
2287 * The function to add to is determined by the function of the
2288 * passed basic block.
2289 *
2290 * @see llvm::BasicBlock::Create()
2291 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +00002292LLVMBasicBlockRef LLVMInsertBasicBlockInContext(LLVMContextRef C,
2293 LLVMBasicBlockRef BB,
2294 const char *Name);
2295
Gregory Szorc34c863a2012-03-21 03:54:29 +00002296/**
2297 * Insert a basic block in a function using the global context.
2298 *
2299 * @see llvm::BasicBlock::Create()
2300 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002301LLVMBasicBlockRef LLVMInsertBasicBlock(LLVMBasicBlockRef InsertBeforeBB,
2302 const char *Name);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002303
2304/**
2305 * Remove a basic block from a function and delete it.
2306 *
2307 * This deletes the basic block from its containing function and deletes
2308 * the basic block itself.
2309 *
2310 * @see llvm::BasicBlock::eraseFromParent()
2311 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002312void LLVMDeleteBasicBlock(LLVMBasicBlockRef BB);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002313
2314/**
2315 * Remove a basic block from a function.
2316 *
2317 * This deletes the basic block from its containing function but keep
2318 * the basic block alive.
2319 *
2320 * @see llvm::BasicBlock::removeFromParent()
2321 */
Nate Begeman43c322b2011-08-23 20:27:46 +00002322void LLVMRemoveBasicBlockFromParent(LLVMBasicBlockRef BB);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002323
Gregory Szorc34c863a2012-03-21 03:54:29 +00002324/**
2325 * Move a basic block to before another one.
2326 *
2327 * @see llvm::BasicBlock::moveBefore()
2328 */
Duncan Sandsb1d61aa2010-07-19 15:31:07 +00002329void LLVMMoveBasicBlockBefore(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002330
2331/**
2332 * Move a basic block to after another one.
2333 *
2334 * @see llvm::BasicBlock::moveAfter()
2335 */
Duncan Sandsb1d61aa2010-07-19 15:31:07 +00002336void LLVMMoveBasicBlockAfter(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos);
2337
Gregory Szorc34c863a2012-03-21 03:54:29 +00002338/**
2339 * Obtain the first instruction in a basic block.
2340 *
2341 * The returned LLVMValueRef corresponds to a llvm::Instruction
2342 * instance.
2343 */
Gordon Henriksen054817c2008-03-19 03:47:18 +00002344LLVMValueRef LLVMGetFirstInstruction(LLVMBasicBlockRef BB);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002345
2346/**
2347 * Obtain the last instruction in a basic block.
2348 *
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00002349 * The returned LLVMValueRef corresponds to an LLVM:Instruction.
Gregory Szorc34c863a2012-03-21 03:54:29 +00002350 */
Gordon Henriksen054817c2008-03-19 03:47:18 +00002351LLVMValueRef LLVMGetLastInstruction(LLVMBasicBlockRef BB);
Nate Begeman43c322b2011-08-23 20:27:46 +00002352
Gregory Szorc34c863a2012-03-21 03:54:29 +00002353/**
2354 * @}
2355 */
2356
2357/**
2358 * @defgroup LLVMCCoreValueInstruction Instructions
2359 *
2360 * Functions in this group relate to the inspection and manipulation of
2361 * individual instructions.
2362 *
2363 * In the C++ API, an instruction is modeled by llvm::Instruction. This
2364 * class has a large number of descendents. llvm::Instruction is a
2365 * llvm::Value and in the C API, instructions are modeled by
2366 * LLVMValueRef.
2367 *
2368 * This group also contains sub-groups which operate on specific
2369 * llvm::Instruction types, e.g. llvm::CallInst.
2370 *
2371 * @{
2372 */
2373
2374/**
2375 * Determine whether an instruction has any metadata attached.
2376 */
2377int LLVMHasMetadata(LLVMValueRef Val);
2378
2379/**
2380 * Return metadata associated with an instruction value.
2381 */
2382LLVMValueRef LLVMGetMetadata(LLVMValueRef Val, unsigned KindID);
2383
2384/**
2385 * Set metadata associated with an instruction value.
2386 */
2387void LLVMSetMetadata(LLVMValueRef Val, unsigned KindID, LLVMValueRef Node);
2388
2389/**
2390 * Obtain the basic block to which an instruction belongs.
2391 *
2392 * @see llvm::Instruction::getParent()
2393 */
Nate Begeman43c322b2011-08-23 20:27:46 +00002394LLVMBasicBlockRef LLVMGetInstructionParent(LLVMValueRef Inst);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002395
2396/**
2397 * Obtain the instruction that occurs after the one specified.
2398 *
2399 * The next instruction will be from the same basic block.
2400 *
2401 * If this is the last instruction in a basic block, NULL will be
2402 * returned.
2403 */
Gordon Henriksen054817c2008-03-19 03:47:18 +00002404LLVMValueRef LLVMGetNextInstruction(LLVMValueRef Inst);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002405
2406/**
Benjamin Kramerbde91762012-06-02 10:20:22 +00002407 * Obtain the instruction that occurred before this one.
Gregory Szorc34c863a2012-03-21 03:54:29 +00002408 *
2409 * If the instruction is the first instruction in a basic block, NULL
2410 * will be returned.
2411 */
Gordon Henriksen054817c2008-03-19 03:47:18 +00002412LLVMValueRef LLVMGetPreviousInstruction(LLVMValueRef Inst);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002413
2414/**
2415 * Remove and delete an instruction.
2416 *
2417 * The instruction specified is removed from its containing building
Amaury Sechet2f432082016-02-11 21:37:54 +00002418 * block but is kept alive.
2419 *
2420 * @see llvm::Instruction::removeFromParent()
2421 */
2422void LLVMInstructionRemoveFromParent(LLVMValueRef Inst);
2423
2424/**
2425 * Remove and delete an instruction.
2426 *
2427 * The instruction specified is removed from its containing building
Gregory Szorc34c863a2012-03-21 03:54:29 +00002428 * block and then deleted.
2429 *
2430 * @see llvm::Instruction::eraseFromParent()
2431 */
Devang Pateldbebc6f2011-10-03 20:59:18 +00002432void LLVMInstructionEraseFromParent(LLVMValueRef Inst);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002433
2434/**
2435 * Obtain the code opcode for an individual instruction.
2436 *
2437 * @see llvm::Instruction::getOpCode()
2438 */
Eric Christophera6b96002015-12-18 01:46:52 +00002439LLVMOpcode LLVMGetInstructionOpcode(LLVMValueRef Inst);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002440
2441/**
2442 * Obtain the predicate of an instruction.
2443 *
2444 * This is only valid for instructions that correspond to llvm::ICmpInst
2445 * or llvm::ConstantExpr whose opcode is llvm::Instruction::ICmp.
2446 *
2447 * @see llvm::ICmpInst::getPredicate()
2448 */
Torok Edwin60c40de2011-10-06 12:13:20 +00002449LLVMIntPredicate LLVMGetICmpPredicate(LLVMValueRef Inst);
Gordon Henriksen265f7802008-03-19 01:11:35 +00002450
Gregory Szorc34c863a2012-03-21 03:54:29 +00002451/**
Peter Zotov1d98e6d2014-10-28 19:46:44 +00002452 * Obtain the float predicate of an instruction.
2453 *
2454 * This is only valid for instructions that correspond to llvm::FCmpInst
2455 * or llvm::ConstantExpr whose opcode is llvm::Instruction::FCmp.
2456 *
2457 * @see llvm::FCmpInst::getPredicate()
2458 */
2459LLVMRealPredicate LLVMGetFCmpPredicate(LLVMValueRef Inst);
2460
2461/**
Peter Zotovaff492c2014-10-17 01:02:34 +00002462 * Create a copy of 'this' instruction that is identical in all ways
2463 * except the following:
2464 * * The instruction has no parent
2465 * * The instruction has no name
2466 *
2467 * @see llvm::Instruction::clone()
2468 */
2469LLVMValueRef LLVMInstructionClone(LLVMValueRef Inst);
2470
2471/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002472 * @defgroup LLVMCCoreValueInstructionCall Call Sites and Invocations
2473 *
2474 * Functions in this group apply to instructions that refer to call
2475 * sites and invocations. These correspond to C++ types in the
2476 * llvm::CallInst class tree.
2477 *
2478 * @{
2479 */
2480
2481/**
Amaury Sechet5c7b3af2016-02-10 00:09:37 +00002482 * Obtain the argument count 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::getNumArgOperands()
2488 * @see llvm::InvokeInst::getNumArgOperands()
2489 */
2490unsigned LLVMGetNumArgOperands(LLVMValueRef Instr);
2491
2492/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002493 * Set the calling convention for a call instruction.
2494 *
2495 * This expects an LLVMValueRef that corresponds to a llvm::CallInst or
2496 * llvm::InvokeInst.
2497 *
2498 * @see llvm::CallInst::setCallingConv()
2499 * @see llvm::InvokeInst::setCallingConv()
2500 */
Gordon Henriksen1158c532007-12-29 20:45:00 +00002501void LLVMSetInstructionCallConv(LLVMValueRef Instr, unsigned CC);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002502
2503/**
2504 * Obtain the calling convention for a call instruction.
2505 *
2506 * This is the opposite of LLVMSetInstructionCallConv(). Reads its
2507 * usage.
2508 *
2509 * @see LLVMSetInstructionCallConv()
2510 */
Gordon Henriksen1158c532007-12-29 20:45:00 +00002511unsigned LLVMGetInstructionCallConv(LLVMValueRef Instr);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002512
2513
Devang Patel4c758ea2008-09-25 21:00:45 +00002514void LLVMAddInstrAttribute(LLVMValueRef Instr, unsigned index, LLVMAttribute);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002515void LLVMRemoveInstrAttribute(LLVMValueRef Instr, unsigned index,
Devang Patel4c758ea2008-09-25 21:00:45 +00002516 LLVMAttribute);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002517void LLVMSetInstrParamAlignment(LLVMValueRef Instr, unsigned index,
Gordon Henriksen2d9cc212008-04-28 17:37:06 +00002518 unsigned align);
Gordon Henriksen1158c532007-12-29 20:45:00 +00002519
Gregory Szorc34c863a2012-03-21 03:54:29 +00002520/**
Amaury Sechet5c7b3af2016-02-10 00:09:37 +00002521 * Obtain the pointer to the function invoked by this instruction.
2522 *
2523 * This expects an LLVMValueRef that corresponds to a llvm::CallInst or
2524 * llvm::InvokeInst.
2525 *
2526 * @see llvm::CallInst::getCalledValue()
2527 * @see llvm::InvokeInst::getCalledValue()
2528 */
2529LLVMValueRef LLVMGetCalledValue(LLVMValueRef Instr);
2530
2531/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002532 * Obtain whether a call instruction is a tail call.
2533 *
2534 * This only works on llvm::CallInst instructions.
2535 *
2536 * @see llvm::CallInst::isTailCall()
2537 */
Chris Lattner25963c62010-01-09 22:27:07 +00002538LLVMBool LLVMIsTailCall(LLVMValueRef CallInst);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002539
2540/**
2541 * Set whether a call instruction is a tail call.
2542 *
2543 * This only works on llvm::CallInst instructions.
2544 *
2545 * @see llvm::CallInst::setTailCall()
2546 */
Chris Lattner25963c62010-01-09 22:27:07 +00002547void LLVMSetTailCall(LLVMValueRef CallInst, LLVMBool IsTailCall);
Gordon Henrikseneeb65372008-08-30 16:34:54 +00002548
Gregory Szorc34c863a2012-03-21 03:54:29 +00002549/**
Amaury Sechete39e8532016-02-18 20:38:32 +00002550 * Return the normal destination basic block.
2551 *
2552 * This only works on llvm::InvokeInst instructions.
2553 *
2554 * @see llvm::InvokeInst::getNormalDest()
2555 */
2556LLVMBasicBlockRef LLVMGetNormalDest(LLVMValueRef InvokeInst);
2557
2558/**
2559 * Return the unwind destination basic block.
2560 *
2561 * This only works on llvm::InvokeInst instructions.
2562 *
2563 * @see llvm::InvokeInst::getUnwindDest()
2564 */
2565LLVMBasicBlockRef LLVMGetUnwindDest(LLVMValueRef InvokeInst);
2566
2567/**
2568 * Set the normal destination basic block.
2569 *
2570 * This only works on llvm::InvokeInst instructions.
2571 *
2572 * @see llvm::InvokeInst::setNormalDest()
2573 */
2574void LLVMSetNormalDest(LLVMValueRef InvokeInst, LLVMBasicBlockRef B);
2575
2576/**
2577 * Set the unwind destination basic block.
2578 *
2579 * This only works on llvm::InvokeInst instructions.
2580 *
2581 * @see llvm::InvokeInst::setUnwindDest()
2582 */
2583void LLVMSetUnwindDest(LLVMValueRef InvokeInst, LLVMBasicBlockRef B);
2584
2585/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002586 * @}
2587 */
2588
2589/**
Peter Zotov2481c752014-10-28 19:46:56 +00002590 * @defgroup LLVMCCoreValueInstructionTerminator Terminators
2591 *
2592 * Functions in this group only apply to instructions that map to
2593 * llvm::TerminatorInst instances.
2594 *
2595 * @{
2596 */
2597
2598/**
2599 * Return the number of successors that this terminator has.
2600 *
2601 * @see llvm::TerminatorInst::getNumSuccessors
2602 */
2603unsigned LLVMGetNumSuccessors(LLVMValueRef Term);
2604
2605/**
2606 * Return the specified successor.
2607 *
2608 * @see llvm::TerminatorInst::getSuccessor
2609 */
2610LLVMBasicBlockRef LLVMGetSuccessor(LLVMValueRef Term, unsigned i);
2611
2612/**
2613 * Update the specified successor to point at the provided block.
2614 *
2615 * @see llvm::TerminatorInst::setSuccessor
2616 */
2617void LLVMSetSuccessor(LLVMValueRef Term, unsigned i, LLVMBasicBlockRef block);
2618
2619/**
2620 * Return if a branch is conditional.
2621 *
2622 * This only works on llvm::BranchInst instructions.
2623 *
2624 * @see llvm::BranchInst::isConditional
2625 */
2626LLVMBool LLVMIsConditional(LLVMValueRef Branch);
2627
2628/**
2629 * Return the condition of a branch instruction.
2630 *
2631 * This only works on llvm::BranchInst instructions.
2632 *
2633 * @see llvm::BranchInst::getCondition
2634 */
2635LLVMValueRef LLVMGetCondition(LLVMValueRef Branch);
2636
2637/**
2638 * Set the condition of a branch instruction.
2639 *
2640 * This only works on llvm::BranchInst instructions.
2641 *
2642 * @see llvm::BranchInst::setCondition
2643 */
2644void LLVMSetCondition(LLVMValueRef Branch, LLVMValueRef Cond);
2645
2646/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002647 * Obtain the default destination basic block of a switch instruction.
2648 *
2649 * This only works on llvm::SwitchInst instructions.
2650 *
2651 * @see llvm::SwitchInst::getDefaultDest()
2652 */
Nate Begeman43c322b2011-08-23 20:27:46 +00002653LLVMBasicBlockRef LLVMGetSwitchDefaultDest(LLVMValueRef SwitchInstr);
2654
Gregory Szorc34c863a2012-03-21 03:54:29 +00002655/**
Peter Zotov2481c752014-10-28 19:46:56 +00002656 * @}
2657 */
2658
2659/**
Amaury Sechet1dcf5772016-02-09 22:50:53 +00002660 * @defgroup LLVMCCoreValueInstructionAlloca Allocas
2661 *
2662 * Functions in this group only apply to instructions that map to
2663 * llvm::AllocaInst instances.
2664 *
2665 * @{
2666 */
2667
2668/**
2669 * Obtain the type that is being allocated by the alloca instruction.
2670 */
2671LLVMTypeRef LLVMGetAllocatedType(LLVMValueRef Alloca);
2672
2673/**
2674 * @}
2675 */
2676
2677/**
Amaury Sechet053ac452016-02-17 22:51:03 +00002678 * @defgroup LLVMCCoreValueInstructionGetElementPointer GEPs
2679 *
2680 * Functions in this group only apply to instructions that map to
2681 * llvm::GetElementPtrInst instances.
2682 *
2683 * @{
2684 */
2685
2686/**
2687 * Check whether the given GEP instruction is inbounds.
2688 */
2689LLVMBool LLVMIsInBounds(LLVMValueRef GEP);
2690
2691/**
2692 * Set the given GEP instruction to be inbounds or not.
2693 */
2694void LLVMSetIsInBounds(LLVMValueRef GEP, LLVMBool b);
2695
2696/**
2697 * @}
2698 */
2699
2700/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002701 * @defgroup LLVMCCoreValueInstructionPHINode PHI Nodes
2702 *
2703 * Functions in this group only apply to instructions that map to
2704 * llvm::PHINode instances.
2705 *
2706 * @{
2707 */
2708
2709/**
2710 * Add an incoming value to the end of a PHI list.
2711 */
Gordon Henriksen44dd8fb2007-10-08 18:14:39 +00002712void LLVMAddIncoming(LLVMValueRef PhiNode, LLVMValueRef *IncomingValues,
2713 LLVMBasicBlockRef *IncomingBlocks, unsigned Count);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002714
2715/**
2716 * Obtain the number of incoming basic blocks to a PHI node.
2717 */
Gordon Henriksen44dd8fb2007-10-08 18:14:39 +00002718unsigned LLVMCountIncoming(LLVMValueRef PhiNode);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002719
2720/**
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00002721 * Obtain an incoming value to a PHI node as an LLVMValueRef.
Gregory Szorc34c863a2012-03-21 03:54:29 +00002722 */
Gordon Henriksen44dd8fb2007-10-08 18:14:39 +00002723LLVMValueRef LLVMGetIncomingValue(LLVMValueRef PhiNode, unsigned Index);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002724
2725/**
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00002726 * Obtain an incoming value to a PHI node as an LLVMBasicBlockRef.
Gregory Szorc34c863a2012-03-21 03:54:29 +00002727 */
Gordon Henriksen44dd8fb2007-10-08 18:14:39 +00002728LLVMBasicBlockRef LLVMGetIncomingBlock(LLVMValueRef PhiNode, unsigned Index);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002729
Gregory Szorc34c863a2012-03-21 03:54:29 +00002730/**
2731 * @}
2732 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002733
Gregory Szorc34c863a2012-03-21 03:54:29 +00002734/**
Amaury Sechetaad93532016-02-10 00:38:50 +00002735 * @defgroup LLVMCCoreValueInstructionExtractValue ExtractValue
2736 * @defgroup LLVMCCoreValueInstructionInsertValue InsertValue
2737 *
2738 * Functions in this group only apply to instructions that map to
2739 * llvm::ExtractValue and llvm::InsertValue instances.
2740 *
2741 * @{
2742 */
2743
2744/**
2745 * Obtain the number of indices.
Amaury Sechet053ac452016-02-17 22:51:03 +00002746 * NB: This also works on GEP.
Amaury Sechetaad93532016-02-10 00:38:50 +00002747 */
2748unsigned LLVMGetNumIndices(LLVMValueRef Inst);
2749
2750/**
2751 * Obtain the indices as an array.
2752 */
2753const unsigned *LLVMGetIndices(LLVMValueRef Inst);
2754
2755/**
2756 * @}
2757 */
2758
2759/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002760 * @}
2761 */
2762
2763/**
2764 * @}
2765 */
2766
2767/**
2768 * @defgroup LLVMCCoreInstructionBuilder Instruction Builders
2769 *
2770 * An instruction builder represents a point within a basic block and is
2771 * the exclusive means of building instructions using the C interface.
2772 *
2773 * @{
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002774 */
2775
Erick Tryzelaar262332f2009-08-14 00:01:31 +00002776LLVMBuilderRef LLVMCreateBuilderInContext(LLVMContextRef C);
Gordon Henriksena735a9c2008-05-04 12:55:34 +00002777LLVMBuilderRef LLVMCreateBuilder(void);
Gordon Henriksen054817c2008-03-19 03:47:18 +00002778void LLVMPositionBuilder(LLVMBuilderRef Builder, LLVMBasicBlockRef Block,
2779 LLVMValueRef Instr);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002780void LLVMPositionBuilderBefore(LLVMBuilderRef Builder, LLVMValueRef Instr);
2781void LLVMPositionBuilderAtEnd(LLVMBuilderRef Builder, LLVMBasicBlockRef Block);
Gordon Henriksen265f7802008-03-19 01:11:35 +00002782LLVMBasicBlockRef LLVMGetInsertBlock(LLVMBuilderRef Builder);
Chris Lattner3d1f5522008-12-17 21:39:50 +00002783void LLVMClearInsertionPosition(LLVMBuilderRef Builder);
2784void LLVMInsertIntoBuilder(LLVMBuilderRef Builder, LLVMValueRef Instr);
Erick Tryzelaar9813bea2009-08-16 02:20:57 +00002785void LLVMInsertIntoBuilderWithName(LLVMBuilderRef Builder, LLVMValueRef Instr,
2786 const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002787void LLVMDisposeBuilder(LLVMBuilderRef Builder);
2788
Erick Tryzelaard8531fa2010-02-28 09:45:59 +00002789/* Metadata */
2790void LLVMSetCurrentDebugLocation(LLVMBuilderRef Builder, LLVMValueRef L);
2791LLVMValueRef LLVMGetCurrentDebugLocation(LLVMBuilderRef Builder);
2792void LLVMSetInstDebugLocation(LLVMBuilderRef Builder, LLVMValueRef Inst);
2793
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002794/* Terminators */
2795LLVMValueRef LLVMBuildRetVoid(LLVMBuilderRef);
2796LLVMValueRef LLVMBuildRet(LLVMBuilderRef, LLVMValueRef V);
Erick Tryzelaarfd529d72009-08-19 08:36:49 +00002797LLVMValueRef LLVMBuildAggregateRet(LLVMBuilderRef, LLVMValueRef *RetVals,
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002798 unsigned N);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002799LLVMValueRef LLVMBuildBr(LLVMBuilderRef, LLVMBasicBlockRef Dest);
2800LLVMValueRef LLVMBuildCondBr(LLVMBuilderRef, LLVMValueRef If,
2801 LLVMBasicBlockRef Then, LLVMBasicBlockRef Else);
2802LLVMValueRef LLVMBuildSwitch(LLVMBuilderRef, LLVMValueRef V,
2803 LLVMBasicBlockRef Else, unsigned NumCases);
Erick Tryzelaar0fb26ef2010-02-28 09:46:06 +00002804LLVMValueRef LLVMBuildIndirectBr(LLVMBuilderRef B, LLVMValueRef Addr,
2805 unsigned NumDests);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002806LLVMValueRef LLVMBuildInvoke(LLVMBuilderRef, LLVMValueRef Fn,
2807 LLVMValueRef *Args, unsigned NumArgs,
2808 LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch,
2809 const char *Name);
Benjamin Kramer5a6568832011-08-19 01:36:54 +00002810LLVMValueRef LLVMBuildLandingPad(LLVMBuilderRef B, LLVMTypeRef Ty,
Reid Kleckneref9828f2015-07-16 01:16:39 +00002811 LLVMValueRef PersFn, unsigned NumClauses,
2812 const char *Name);
Bill Wendlingf891bf82011-07-31 06:30:59 +00002813LLVMValueRef LLVMBuildResume(LLVMBuilderRef B, LLVMValueRef Exn);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002814LLVMValueRef LLVMBuildUnreachable(LLVMBuilderRef);
2815
Gordon Henriksen097102c2008-01-01 05:50:53 +00002816/* Add a case to the switch instruction */
2817void LLVMAddCase(LLVMValueRef Switch, LLVMValueRef OnVal,
2818 LLVMBasicBlockRef Dest);
2819
Erick Tryzelaar0fb26ef2010-02-28 09:46:06 +00002820/* Add a destination to the indirectbr instruction */
2821void LLVMAddDestination(LLVMValueRef IndirectBr, LLVMBasicBlockRef Dest);
2822
Amaury Sechete39e8532016-02-18 20:38:32 +00002823/* Get the number of clauses on the landingpad instruction */
2824unsigned LLVMGetNumClauses(LLVMValueRef LandingPad);
2825
2826/* Get the value of the clause at idnex Idx on the landingpad instruction */
2827LLVMValueRef LLVMGetClause(LLVMValueRef LandingPad, unsigned Idx);
2828
Bill Wendlingfae14752011-08-12 20:24:12 +00002829/* Add a catch or filter clause to the landingpad instruction */
2830void LLVMAddClause(LLVMValueRef LandingPad, LLVMValueRef ClauseVal);
2831
Amaury Sechete39e8532016-02-18 20:38:32 +00002832/* Get the 'cleanup' flag in the landingpad instruction */
2833LLVMBool LLVMIsCleanup(LLVMValueRef LandingPad);
2834
Bill Wendlingfae14752011-08-12 20:24:12 +00002835/* Set the 'cleanup' flag in the landingpad instruction */
2836void LLVMSetCleanup(LLVMValueRef LandingPad, LLVMBool Val);
2837
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002838/* Arithmetic */
2839LLVMValueRef LLVMBuildAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2840 const char *Name);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002841LLVMValueRef LLVMBuildNSWAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2842 const char *Name);
Erick Tryzelaar4c340c72010-02-28 05:51:43 +00002843LLVMValueRef LLVMBuildNUWAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2844 const char *Name);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002845LLVMValueRef LLVMBuildFAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2846 const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002847LLVMValueRef LLVMBuildSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2848 const char *Name);
Erick Tryzelaar4c340c72010-02-28 05:51:43 +00002849LLVMValueRef LLVMBuildNSWSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2850 const char *Name);
2851LLVMValueRef LLVMBuildNUWSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2852 const char *Name);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002853LLVMValueRef LLVMBuildFSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2854 const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002855LLVMValueRef LLVMBuildMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2856 const char *Name);
Erick Tryzelaar4c340c72010-02-28 05:51:43 +00002857LLVMValueRef LLVMBuildNSWMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2858 const char *Name);
2859LLVMValueRef LLVMBuildNUWMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2860 const char *Name);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002861LLVMValueRef LLVMBuildFMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2862 const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002863LLVMValueRef LLVMBuildUDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2864 const char *Name);
2865LLVMValueRef LLVMBuildSDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2866 const char *Name);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002867LLVMValueRef LLVMBuildExactSDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2868 const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002869LLVMValueRef LLVMBuildFDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2870 const char *Name);
2871LLVMValueRef LLVMBuildURem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2872 const char *Name);
2873LLVMValueRef LLVMBuildSRem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2874 const char *Name);
2875LLVMValueRef LLVMBuildFRem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2876 const char *Name);
2877LLVMValueRef LLVMBuildShl(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2878 const char *Name);
2879LLVMValueRef LLVMBuildLShr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2880 const char *Name);
2881LLVMValueRef LLVMBuildAShr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2882 const char *Name);
2883LLVMValueRef LLVMBuildAnd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2884 const char *Name);
2885LLVMValueRef LLVMBuildOr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2886 const char *Name);
2887LLVMValueRef LLVMBuildXor(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2888 const char *Name);
Erick Tryzelaar31831792010-02-28 05:51:27 +00002889LLVMValueRef LLVMBuildBinOp(LLVMBuilderRef B, LLVMOpcode Op,
2890 LLVMValueRef LHS, LLVMValueRef RHS,
2891 const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002892LLVMValueRef LLVMBuildNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name);
Erick Tryzelaar4c340c72010-02-28 05:51:43 +00002893LLVMValueRef LLVMBuildNSWNeg(LLVMBuilderRef B, LLVMValueRef V,
2894 const char *Name);
2895LLVMValueRef LLVMBuildNUWNeg(LLVMBuilderRef B, LLVMValueRef V,
2896 const char *Name);
Dan Gohmanf919bd62009-09-28 21:51:41 +00002897LLVMValueRef LLVMBuildFNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002898LLVMValueRef LLVMBuildNot(LLVMBuilderRef, LLVMValueRef V, const char *Name);
2899
2900/* Memory */
2901LLVMValueRef LLVMBuildMalloc(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
2902LLVMValueRef LLVMBuildArrayMalloc(LLVMBuilderRef, LLVMTypeRef Ty,
2903 LLVMValueRef Val, const char *Name);
2904LLVMValueRef LLVMBuildAlloca(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
2905LLVMValueRef LLVMBuildArrayAlloca(LLVMBuilderRef, LLVMTypeRef Ty,
2906 LLVMValueRef Val, const char *Name);
2907LLVMValueRef LLVMBuildFree(LLVMBuilderRef, LLVMValueRef PointerVal);
2908LLVMValueRef LLVMBuildLoad(LLVMBuilderRef, LLVMValueRef PointerVal,
2909 const char *Name);
2910LLVMValueRef LLVMBuildStore(LLVMBuilderRef, LLVMValueRef Val, LLVMValueRef Ptr);
2911LLVMValueRef LLVMBuildGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
2912 LLVMValueRef *Indices, unsigned NumIndices,
2913 const char *Name);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002914LLVMValueRef LLVMBuildInBoundsGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
2915 LLVMValueRef *Indices, unsigned NumIndices,
2916 const char *Name);
2917LLVMValueRef LLVMBuildStructGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
2918 unsigned Idx, const char *Name);
2919LLVMValueRef LLVMBuildGlobalString(LLVMBuilderRef B, const char *Str,
2920 const char *Name);
2921LLVMValueRef LLVMBuildGlobalStringPtr(LLVMBuilderRef B, const char *Str,
2922 const char *Name);
Chris Lattner2cc6f9d2012-03-22 03:54:15 +00002923LLVMBool LLVMGetVolatile(LLVMValueRef MemoryAccessInst);
2924void LLVMSetVolatile(LLVMValueRef MemoryAccessInst, LLVMBool IsVolatile);
Andrew Wilkinsb7362ce2015-08-02 12:16:57 +00002925LLVMAtomicOrdering LLVMGetOrdering(LLVMValueRef MemoryAccessInst);
2926void LLVMSetOrdering(LLVMValueRef MemoryAccessInst, LLVMAtomicOrdering Ordering);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002927
2928/* Casts */
2929LLVMValueRef LLVMBuildTrunc(LLVMBuilderRef, LLVMValueRef Val,
2930 LLVMTypeRef DestTy, const char *Name);
2931LLVMValueRef LLVMBuildZExt(LLVMBuilderRef, LLVMValueRef Val,
2932 LLVMTypeRef DestTy, const char *Name);
2933LLVMValueRef LLVMBuildSExt(LLVMBuilderRef, LLVMValueRef Val,
2934 LLVMTypeRef DestTy, const char *Name);
2935LLVMValueRef LLVMBuildFPToUI(LLVMBuilderRef, LLVMValueRef Val,
2936 LLVMTypeRef DestTy, const char *Name);
2937LLVMValueRef LLVMBuildFPToSI(LLVMBuilderRef, LLVMValueRef Val,
2938 LLVMTypeRef DestTy, const char *Name);
2939LLVMValueRef LLVMBuildUIToFP(LLVMBuilderRef, LLVMValueRef Val,
2940 LLVMTypeRef DestTy, const char *Name);
2941LLVMValueRef LLVMBuildSIToFP(LLVMBuilderRef, LLVMValueRef Val,
2942 LLVMTypeRef DestTy, const char *Name);
2943LLVMValueRef LLVMBuildFPTrunc(LLVMBuilderRef, LLVMValueRef Val,
2944 LLVMTypeRef DestTy, const char *Name);
2945LLVMValueRef LLVMBuildFPExt(LLVMBuilderRef, LLVMValueRef Val,
2946 LLVMTypeRef DestTy, const char *Name);
2947LLVMValueRef LLVMBuildPtrToInt(LLVMBuilderRef, LLVMValueRef Val,
2948 LLVMTypeRef DestTy, const char *Name);
2949LLVMValueRef LLVMBuildIntToPtr(LLVMBuilderRef, LLVMValueRef Val,
2950 LLVMTypeRef DestTy, const char *Name);
2951LLVMValueRef LLVMBuildBitCast(LLVMBuilderRef, LLVMValueRef Val,
2952 LLVMTypeRef DestTy, const char *Name);
Matt Arsenaultb03bd4d2013-11-15 01:34:59 +00002953LLVMValueRef LLVMBuildAddrSpaceCast(LLVMBuilderRef, LLVMValueRef Val,
2954 LLVMTypeRef DestTy, const char *Name);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002955LLVMValueRef LLVMBuildZExtOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
2956 LLVMTypeRef DestTy, const char *Name);
2957LLVMValueRef LLVMBuildSExtOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
2958 LLVMTypeRef DestTy, const char *Name);
2959LLVMValueRef LLVMBuildTruncOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
2960 LLVMTypeRef DestTy, const char *Name);
Erick Tryzelaar31831792010-02-28 05:51:27 +00002961LLVMValueRef LLVMBuildCast(LLVMBuilderRef B, LLVMOpcode Op, LLVMValueRef Val,
2962 LLVMTypeRef DestTy, const char *Name);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002963LLVMValueRef LLVMBuildPointerCast(LLVMBuilderRef, LLVMValueRef Val,
2964 LLVMTypeRef DestTy, const char *Name);
Duncan Sands9d786d72009-11-23 10:49:03 +00002965LLVMValueRef LLVMBuildIntCast(LLVMBuilderRef, LLVMValueRef Val, /*Signed cast!*/
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002966 LLVMTypeRef DestTy, const char *Name);
2967LLVMValueRef LLVMBuildFPCast(LLVMBuilderRef, LLVMValueRef Val,
2968 LLVMTypeRef DestTy, const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002969
2970/* Comparisons */
2971LLVMValueRef LLVMBuildICmp(LLVMBuilderRef, LLVMIntPredicate Op,
2972 LLVMValueRef LHS, LLVMValueRef RHS,
2973 const char *Name);
2974LLVMValueRef LLVMBuildFCmp(LLVMBuilderRef, LLVMRealPredicate Op,
2975 LLVMValueRef LHS, LLVMValueRef RHS,
2976 const char *Name);
2977
2978/* Miscellaneous instructions */
2979LLVMValueRef LLVMBuildPhi(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
2980LLVMValueRef LLVMBuildCall(LLVMBuilderRef, LLVMValueRef Fn,
2981 LLVMValueRef *Args, unsigned NumArgs,
2982 const char *Name);
2983LLVMValueRef LLVMBuildSelect(LLVMBuilderRef, LLVMValueRef If,
2984 LLVMValueRef Then, LLVMValueRef Else,
2985 const char *Name);
2986LLVMValueRef LLVMBuildVAArg(LLVMBuilderRef, LLVMValueRef List, LLVMTypeRef Ty,
2987 const char *Name);
2988LLVMValueRef LLVMBuildExtractElement(LLVMBuilderRef, LLVMValueRef VecVal,
2989 LLVMValueRef Index, const char *Name);
2990LLVMValueRef LLVMBuildInsertElement(LLVMBuilderRef, LLVMValueRef VecVal,
2991 LLVMValueRef EltVal, LLVMValueRef Index,
2992 const char *Name);
2993LLVMValueRef LLVMBuildShuffleVector(LLVMBuilderRef, LLVMValueRef V1,
2994 LLVMValueRef V2, LLVMValueRef Mask,
2995 const char *Name);
Dan Gohmand5104a52008-11-03 22:55:43 +00002996LLVMValueRef LLVMBuildExtractValue(LLVMBuilderRef, LLVMValueRef AggVal,
2997 unsigned Index, const char *Name);
2998LLVMValueRef LLVMBuildInsertValue(LLVMBuilderRef, LLVMValueRef AggVal,
2999 LLVMValueRef EltVal, unsigned Index,
3000 const char *Name);
Gordon Henriksen76a03742007-09-18 03:18:57 +00003001
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00003002LLVMValueRef LLVMBuildIsNull(LLVMBuilderRef, LLVMValueRef Val,
3003 const char *Name);
3004LLVMValueRef LLVMBuildIsNotNull(LLVMBuilderRef, LLVMValueRef Val,
3005 const char *Name);
3006LLVMValueRef LLVMBuildPtrDiff(LLVMBuilderRef, LLVMValueRef LHS,
3007 LLVMValueRef RHS, const char *Name);
Filip Pizlo0d3f7ec2013-11-20 00:07:49 +00003008LLVMValueRef LLVMBuildFence(LLVMBuilderRef B, LLVMAtomicOrdering ordering,
3009 LLVMBool singleThread, const char *Name);
3010LLVMValueRef LLVMBuildAtomicRMW(LLVMBuilderRef B, LLVMAtomicRMWBinOp op,
NAKAMURA Takumia3a81352013-10-23 17:56:29 +00003011 LLVMValueRef PTR, LLVMValueRef Val,
3012 LLVMAtomicOrdering ordering,
Carlo Kok8c6719b2013-04-23 13:21:19 +00003013 LLVMBool singleThread);
Mehdi Amini43165d92016-03-19 21:28:28 +00003014LLVMValueRef LLVMBuildAtomicCmpXchg(LLVMBuilderRef B, LLVMValueRef Ptr,
3015 LLVMValueRef Cmp, LLVMValueRef New,
3016 LLVMAtomicOrdering SuccessOrdering,
3017 LLVMAtomicOrdering FailureOrdering,
3018 LLVMBool SingleThread);
3019
3020LLVMBool LLVMIsAtomicSingleThread(LLVMValueRef AtomicInst);
3021void LLVMSetAtomicSingleThread(LLVMValueRef AtomicInst, LLVMBool SingleThread);
3022
3023LLVMAtomicOrdering LLVMGetCmpXchgSuccessOrdering(LLVMValueRef CmpXchgInst);
3024void LLVMSetCmpXchgSuccessOrdering(LLVMValueRef CmpXchgInst,
3025 LLVMAtomicOrdering Ordering);
3026LLVMAtomicOrdering LLVMGetCmpXchgFailureOrdering(LLVMValueRef CmpXchgInst);
3027void LLVMSetCmpXchgFailureOrdering(LLVMValueRef CmpXchgInst,
3028 LLVMAtomicOrdering Ordering);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00003029
Gregory Szorc34c863a2012-03-21 03:54:29 +00003030/**
3031 * @}
3032 */
Gordon Henriksen34eb6d82007-12-19 22:30:40 +00003033
Gregory Szorc34c863a2012-03-21 03:54:29 +00003034/**
3035 * @defgroup LLVMCCoreModuleProvider Module Providers
3036 *
3037 * @{
3038 */
Gordon Henriksen0a68fe22007-12-12 01:04:30 +00003039
Gregory Szorc34c863a2012-03-21 03:54:29 +00003040/**
3041 * Changes the type of M so it can be passed to FunctionPassManagers and the
Jeffrey Yasskin091217b2010-01-27 20:34:15 +00003042 * JIT. They take ModuleProviders for historical reasons.
Gordon Henriksen0a68fe22007-12-12 01:04:30 +00003043 */
3044LLVMModuleProviderRef
3045LLVMCreateModuleProviderForExistingModule(LLVMModuleRef M);
3046
Gregory Szorc34c863a2012-03-21 03:54:29 +00003047/**
3048 * Destroys the module M.
Gordon Henriksen0a68fe22007-12-12 01:04:30 +00003049 */
Jeffrey Yasskin091217b2010-01-27 20:34:15 +00003050void LLVMDisposeModuleProvider(LLVMModuleProviderRef M);
Gordon Henriksen0a68fe22007-12-12 01:04:30 +00003051
Gregory Szorc34c863a2012-03-21 03:54:29 +00003052/**
3053 * @}
3054 */
Gordon Henriksen34eb6d82007-12-19 22:30:40 +00003055
Gregory Szorc34c863a2012-03-21 03:54:29 +00003056/**
3057 * @defgroup LLVMCCoreMemoryBuffers Memory Buffers
3058 *
3059 * @{
3060 */
Gordon Henriksen34eb6d82007-12-19 22:30:40 +00003061
Chris Lattner25963c62010-01-09 22:27:07 +00003062LLVMBool LLVMCreateMemoryBufferWithContentsOfFile(const char *Path,
3063 LLVMMemoryBufferRef *OutMemBuf,
3064 char **OutMessage);
3065LLVMBool LLVMCreateMemoryBufferWithSTDIN(LLVMMemoryBufferRef *OutMemBuf,
3066 char **OutMessage);
Bill Wendling526276a2013-02-14 19:11:28 +00003067LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRange(const char *InputData,
3068 size_t InputDataLength,
3069 const char *BufferName,
Bill Wendlingc9baa962013-02-14 19:39:14 +00003070 LLVMBool RequiresNullTerminator);
Bill Wendling526276a2013-02-14 19:11:28 +00003071LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRangeCopy(const char *InputData,
3072 size_t InputDataLength,
3073 const char *BufferName);
Tom Stellard62c03202013-04-18 19:50:53 +00003074const char *LLVMGetBufferStart(LLVMMemoryBufferRef MemBuf);
Tom Stellardb7fb7242013-04-16 23:12:51 +00003075size_t LLVMGetBufferSize(LLVMMemoryBufferRef MemBuf);
Gordon Henriksen34eb6d82007-12-19 22:30:40 +00003076void LLVMDisposeMemoryBuffer(LLVMMemoryBufferRef MemBuf);
3077
Gregory Szorc34c863a2012-03-21 03:54:29 +00003078/**
3079 * @}
3080 */
3081
3082/**
3083 * @defgroup LLVMCCorePassRegistry Pass Registry
3084 *
3085 * @{
3086 */
Owen Anderson4698c5d2010-10-07 17:55:47 +00003087
3088/** Return the global pass registry, for use with initialization functions.
Gregory Szorc34c863a2012-03-21 03:54:29 +00003089 @see llvm::PassRegistry::getPassRegistry */
Owen Anderson4698c5d2010-10-07 17:55:47 +00003090LLVMPassRegistryRef LLVMGetGlobalPassRegistry(void);
Gordon Henriksen878114b2008-03-16 04:20:44 +00003091
Gregory Szorc34c863a2012-03-21 03:54:29 +00003092/**
3093 * @}
3094 */
3095
3096/**
3097 * @defgroup LLVMCCorePassManagers Pass Managers
3098 *
3099 * @{
3100 */
Gordon Henriksen878114b2008-03-16 04:20:44 +00003101
3102/** Constructs a new whole-module pass pipeline. This type of pipeline is
3103 suitable for link-time optimization and whole-module transformations.
Gregory Szorc34c863a2012-03-21 03:54:29 +00003104 @see llvm::PassManager::PassManager */
Gordon Henriksena735a9c2008-05-04 12:55:34 +00003105LLVMPassManagerRef LLVMCreatePassManager(void);
Gordon Henriksen878114b2008-03-16 04:20:44 +00003106
3107/** Constructs a new function-by-function pass pipeline over the module
3108 provider. It does not take ownership of the module provider. This type of
3109 pipeline is suitable for code generation and JIT compilation tasks.
Gregory Szorc34c863a2012-03-21 03:54:29 +00003110 @see llvm::FunctionPassManager::FunctionPassManager */
Erick Tryzelaarad0e0cb2010-03-02 23:58:54 +00003111LLVMPassManagerRef LLVMCreateFunctionPassManagerForModule(LLVMModuleRef M);
3112
3113/** Deprecated: Use LLVMCreateFunctionPassManagerForModule instead. */
Gordon Henriksen878114b2008-03-16 04:20:44 +00003114LLVMPassManagerRef LLVMCreateFunctionPassManager(LLVMModuleProviderRef MP);
3115
3116/** Initializes, executes on the provided module, and finalizes all of the
3117 passes scheduled in the pass manager. Returns 1 if any of the passes
Gregory Szorc34c863a2012-03-21 03:54:29 +00003118 modified the module, 0 otherwise.
3119 @see llvm::PassManager::run(Module&) */
Chris Lattner25963c62010-01-09 22:27:07 +00003120LLVMBool LLVMRunPassManager(LLVMPassManagerRef PM, LLVMModuleRef M);
Gordon Henriksen878114b2008-03-16 04:20:44 +00003121
3122/** Initializes all of the function passes scheduled 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::doInitialization */
Chris Lattner25963c62010-01-09 22:27:07 +00003125LLVMBool LLVMInitializeFunctionPassManager(LLVMPassManagerRef FPM);
Gordon Henriksen878114b2008-03-16 04:20:44 +00003126
3127/** Executes all of the function passes scheduled in the function pass manager
3128 on the provided function. Returns 1 if any of the passes modified the
3129 function, false otherwise.
Gregory Szorc34c863a2012-03-21 03:54:29 +00003130 @see llvm::FunctionPassManager::run(Function&) */
Chris Lattner25963c62010-01-09 22:27:07 +00003131LLVMBool LLVMRunFunctionPassManager(LLVMPassManagerRef FPM, LLVMValueRef F);
Gordon Henriksen878114b2008-03-16 04:20:44 +00003132
3133/** Finalizes all of the function passes scheduled in in the function pass
3134 manager. Returns 1 if any of the passes modified the module, 0 otherwise.
Gregory Szorc34c863a2012-03-21 03:54:29 +00003135 @see llvm::FunctionPassManager::doFinalization */
Chris Lattner25963c62010-01-09 22:27:07 +00003136LLVMBool LLVMFinalizeFunctionPassManager(LLVMPassManagerRef FPM);
Gordon Henriksen878114b2008-03-16 04:20:44 +00003137
3138/** Frees the memory of a pass pipeline. For function pipelines, does not free
3139 the module provider.
Gregory Szorc34c863a2012-03-21 03:54:29 +00003140 @see llvm::PassManagerBase::~PassManagerBase. */
Gordon Henriksen878114b2008-03-16 04:20:44 +00003141void LLVMDisposePassManager(LLVMPassManagerRef PM);
3142
Gregory Szorc34c863a2012-03-21 03:54:29 +00003143/**
3144 * @}
3145 */
3146
3147/**
Duncan Sands1cba0a82013-02-17 16:35:51 +00003148 * @defgroup LLVMCCoreThreading Threading
3149 *
3150 * Handle the structures needed to make LLVM safe for multithreading.
3151 *
3152 * @{
3153 */
3154
Chandler Carruth39cd2162014-06-27 15:13:01 +00003155/** Deprecated: Multi-threading can only be enabled/disabled with the compile
3156 time define LLVM_ENABLE_THREADS. This function always returns
3157 LLVMIsMultithreaded(). */
Benjamin Kramer325ec892013-10-23 16:57:34 +00003158LLVMBool LLVMStartMultithreaded(void);
Duncan Sands1cba0a82013-02-17 16:35:51 +00003159
Chandler Carruth39cd2162014-06-27 15:13:01 +00003160/** Deprecated: Multi-threading can only be enabled/disabled with the compile
3161 time define LLVM_ENABLE_THREADS. */
Benjamin Kramer325ec892013-10-23 16:57:34 +00003162void LLVMStopMultithreaded(void);
Duncan Sands1cba0a82013-02-17 16:35:51 +00003163
3164/** Check whether LLVM is executing in thread-safe mode or not.
3165 @see llvm::llvm_is_multithreaded */
Benjamin Kramer325ec892013-10-23 16:57:34 +00003166LLVMBool LLVMIsMultithreaded(void);
Duncan Sands1cba0a82013-02-17 16:35:51 +00003167
3168/**
3169 * @}
3170 */
3171
3172/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00003173 * @}
3174 */
3175
3176/**
3177 * @}
3178 */
Gordon Henriksen878114b2008-03-16 04:20:44 +00003179
Gordon Henriksen76a03742007-09-18 03:18:57 +00003180#ifdef __cplusplus
3181}
Eugene Zelenkoffec81c2015-11-04 22:32:32 +00003182#endif
Gordon Henriksen7330acd2007-10-05 23:59:36 +00003183
Eugene Zelenkoffec81c2015-11-04 22:32:32 +00003184#endif /* LLVM_C_CORE_H */