blob: 76f8b31580ac25a5dd9170ef65879c5a86ad49ec [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/**
Amaury Sechet5db224e2016-06-12 06:17:24 +0000384 * Attribute index are either LLVMAttributeReturnIndex,
385 * LLVMAttributeFunctionIndex or a parameter number from 1 to N.
386 */
387enum {
388 LLVMAttributeReturnIndex = 0U,
389 // ISO C restricts enumerator values to range of 'int'
390 // (4294967295 is too large)
391 // LLVMAttributeFunctionIndex = ~0U,
392 LLVMAttributeFunctionIndex = -1,
393};
394
395typedef unsigned LLVMAttributeIndex;
396
397/**
Gregory Szorc34c863a2012-03-21 03:54:29 +0000398 * @}
399 */
400
Nick Lewycky0db26542011-05-15 07:20:34 +0000401void LLVMInitializeCore(LLVMPassRegistryRef R);
402
Duncan Sands1cba0a82013-02-17 16:35:51 +0000403/** Deallocate and destroy all ManagedStatic variables.
404 @see llvm::llvm_shutdown
405 @see ManagedStatic */
Benjamin Kramer325ec892013-10-23 16:57:34 +0000406void LLVMShutdown(void);
Duncan Sands1cba0a82013-02-17 16:35:51 +0000407
Gordon Henriksen34eb6d82007-12-19 22:30:40 +0000408/*===-- Error handling ----------------------------------------------------===*/
409
Filip Pizlo3fdbaff2013-05-22 02:46:43 +0000410char *LLVMCreateMessage(const char *Message);
Gordon Henriksen34eb6d82007-12-19 22:30:40 +0000411void LLVMDisposeMessage(char *Message);
412
Filip Pizlo9f50ccd2013-11-03 00:29:47 +0000413/**
Gregory Szorc34c863a2012-03-21 03:54:29 +0000414 * @defgroup LLVMCCoreContext Contexts
415 *
416 * Contexts are execution states for the core LLVM IR system.
417 *
418 * Most types are tied to a context instance. Multiple contexts can
419 * exist simultaneously. A single context is not thread safe. However,
420 * different contexts can execute on different threads simultaneously.
421 *
422 * @{
423 */
Gordon Henriksen76a03742007-09-18 03:18:57 +0000424
Tom Stellard1580dc72014-04-16 17:45:04 +0000425typedef void (*LLVMDiagnosticHandler)(LLVMDiagnosticInfoRef, void *);
Juergen Ributzka34390c72014-05-16 02:33:15 +0000426typedef void (*LLVMYieldCallback)(LLVMContextRef, void *);
Tom Stellard1580dc72014-04-16 17:45:04 +0000427
Gregory Szorc34c863a2012-03-21 03:54:29 +0000428/**
429 * Create a new context.
430 *
431 * Every call to this function should be paired with a call to
432 * LLVMContextDispose() or the context will leak memory.
433 */
Erick Tryzelaarf34cb0c2009-08-30 23:38:06 +0000434LLVMContextRef LLVMContextCreate(void);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000435
436/**
437 * Obtain the global context instance.
438 */
Erick Tryzelaarf34cb0c2009-08-30 23:38:06 +0000439LLVMContextRef LLVMGetGlobalContext(void);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000440
441/**
Tom Stellard1580dc72014-04-16 17:45:04 +0000442 * Set the diagnostic handler for this context.
443 */
444void LLVMContextSetDiagnosticHandler(LLVMContextRef C,
445 LLVMDiagnosticHandler Handler,
446 void *DiagnosticContext);
447
448/**
Jeroen Ketemaad659c32016-04-08 09:19:02 +0000449 * Get the diagnostic handler of this context.
450 */
451LLVMDiagnosticHandler LLVMContextGetDiagnosticHandler(LLVMContextRef C);
452
453/**
454 * Get the diagnostic context of this context.
455 */
456void *LLVMContextGetDiagnosticContext(LLVMContextRef C);
457
458/**
Juergen Ributzka34390c72014-05-16 02:33:15 +0000459 * Set the yield callback function for this context.
460 *
461 * @see LLVMContext::setYieldCallback()
462 */
463void LLVMContextSetYieldCallback(LLVMContextRef C, LLVMYieldCallback Callback,
464 void *OpaqueHandle);
465
466/**
Gregory Szorc34c863a2012-03-21 03:54:29 +0000467 * Destroy a context instance.
468 *
469 * This should be called for every call to LLVMContextCreate() or memory
470 * will be leaked.
471 */
Owen Anderson6773d382009-07-01 16:58:40 +0000472void LLVMContextDispose(LLVMContextRef C);
473
Tom Stellard1580dc72014-04-16 17:45:04 +0000474/**
475 * Return a string representation of the DiagnosticInfo. Use
476 * LLVMDisposeMessage to free the string.
477 *
478 * @see DiagnosticInfo::print()
479 */
480char *LLVMGetDiagInfoDescription(LLVMDiagnosticInfoRef DI);
481
482/**
483 * Return an enum LLVMDiagnosticSeverity.
484 *
485 * @see DiagnosticInfo::getSeverity()
486 */
487LLVMDiagnosticSeverity LLVMGetDiagInfoSeverity(LLVMDiagnosticInfoRef DI);
488
Amaury Sechet56f056c2016-04-04 22:00:25 +0000489unsigned LLVMGetMDKindIDInContext(LLVMContextRef C, const char *Name,
Erick Tryzelaard8531fa2010-02-28 09:45:59 +0000490 unsigned SLen);
Amaury Sechet56f056c2016-04-04 22:00:25 +0000491unsigned LLVMGetMDKindID(const char *Name, unsigned SLen);
Erick Tryzelaard8531fa2010-02-28 09:45:59 +0000492
Gregory Szorc34c863a2012-03-21 03:54:29 +0000493/**
Amaury Sechet5db224e2016-06-12 06:17:24 +0000494 * Return an unique id given the name of a enum attribute,
Amaury Sechet60b31452016-04-20 01:02:12 +0000495 * or 0 if no attribute by that name exists.
496 *
497 * See http://llvm.org/docs/LangRef.html#parameter-attributes
498 * and http://llvm.org/docs/LangRef.html#function-attributes
499 * for the list of available attributes.
500 *
501 * NB: Attribute names and/or id are subject to change without
502 * going through the C API deprecation cycle.
503 */
Amaury Sechet5db224e2016-06-12 06:17:24 +0000504unsigned LLVMGetEnumAttributeKindForName(const char *Name, size_t SLen);
Amaury Sechet48b06652016-06-12 07:56:21 +0000505unsigned LLVMGetLastEnumAttributeKind(void);
Amaury Sechet5db224e2016-06-12 06:17:24 +0000506
507/**
508 * Create an enum attribute.
509 */
510LLVMAttributeRef LLVMCreateEnumAttribute(LLVMContextRef C, unsigned KindID,
511 uint64_t Val);
512
513/**
514 * Get the unique id corresponding to the enum attribute
515 * passed as argument.
516 */
517unsigned LLVMGetEnumAttributeKind(LLVMAttributeRef A);
518
519/**
520 * Get the enum attribute's value. 0 is returned if none exists.
521 */
522uint64_t LLVMGetEnumAttributeValue(LLVMAttributeRef A);
523
524/**
525 * Create a string attribute.
526 */
527LLVMAttributeRef LLVMCreateStringAttribute(LLVMContextRef C,
528 const char *K, unsigned KLength,
529 const char *V, unsigned VLength);
530
531/**
532 * Get the string attribute's kind.
533 */
534const char *LLVMGetStringAttributeKind(LLVMAttributeRef A, unsigned *Length);
535
536/**
537 * Get the string attribute's value.
538 */
539const char *LLVMGetStringAttributeValue(LLVMAttributeRef A, unsigned *Length);
540
541/**
542 * Check for the different types of attributes.
543 */
544LLVMBool LLVMIsEnumAttribute(LLVMAttributeRef A);
545LLVMBool LLVMIsStringAttribute(LLVMAttributeRef A);
Amaury Sechet60b31452016-04-20 01:02:12 +0000546
547/**
Gregory Szorc34c863a2012-03-21 03:54:29 +0000548 * @}
549 */
550
Gregory Szorc52d26602012-03-21 07:28:27 +0000551/**
552 * @defgroup LLVMCCoreModule Modules
Gregory Szorc34c863a2012-03-21 03:54:29 +0000553 *
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +0000554 * Modules represent the top-level structure in an LLVM program. An LLVM
Gregory Szorc34c863a2012-03-21 03:54:29 +0000555 * module is effectively a translation unit or a collection of
556 * translation units merged together.
557 *
558 * @{
559 */
560
Gregory Szorc34c863a2012-03-21 03:54:29 +0000561/**
562 * Create a new, empty module in the global context.
563 *
564 * This is equivalent to calling LLVMModuleCreateWithNameInContext with
565 * LLVMGetGlobalContext() as the context parameter.
566 *
567 * Every invocation should be paired with LLVMDisposeModule() or memory
568 * will be leaked.
569 */
Gordon Henriksen76a03742007-09-18 03:18:57 +0000570LLVMModuleRef LLVMModuleCreateWithName(const char *ModuleID);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000571
572/**
573 * Create a new, empty module in a specific context.
574 *
575 * Every invocation should be paired with LLVMDisposeModule() or memory
576 * will be leaked.
577 */
Owen Anderson31d44e42009-07-02 07:17:57 +0000578LLVMModuleRef LLVMModuleCreateWithNameInContext(const char *ModuleID,
579 LLVMContextRef C);
Tom Stellard0a4e9a32014-10-01 17:14:57 +0000580/**
581 * Return an exact copy of the specified module.
582 */
583LLVMModuleRef LLVMCloneModule(LLVMModuleRef M);
Gordon Henriksena49d4352008-03-07 19:13:06 +0000584
Gregory Szorc34c863a2012-03-21 03:54:29 +0000585/**
586 * Destroy a module instance.
587 *
588 * This must be called for every created module or memory will be
589 * leaked.
590 */
Gordon Henriksen76a03742007-09-18 03:18:57 +0000591void LLVMDisposeModule(LLVMModuleRef M);
592
Gregory Szorc34c863a2012-03-21 03:54:29 +0000593/**
Peter Zotov0a2fa0a2016-04-05 13:56:59 +0000594 * Obtain the identifier of a module.
595 *
596 * @param M Module to obtain identifier of
597 * @param Len Out parameter which holds the length of the returned string.
598 * @return The identifier of M.
599 * @see Module::getModuleIdentifier()
600 */
601const char *LLVMGetModuleIdentifier(LLVMModuleRef M, size_t *Len);
602
603/**
604 * Set the identifier of a module to a string Ident with length Len.
605 *
606 * @param M The module to set identifier
607 * @param Ident The string to set M's identifier to
608 * @param Len Length of Ident
609 * @see Module::setModuleIdentifier()
610 */
611void LLVMSetModuleIdentifier(LLVMModuleRef M, const char *Ident, size_t Len);
612
613/**
Gregory Szorc34c863a2012-03-21 03:54:29 +0000614 * Obtain the data layout for a module.
615 *
Amaury Sechetf3549c42016-02-16 00:23:52 +0000616 * @see Module::getDataLayoutStr()
617 *
618 * LLVMGetDataLayout is DEPRECATED, as the name is not only incorrect,
619 * but match the name of another method on the module. Prefer the use
620 * of LLVMGetDataLayoutStr, which is not ambiguous.
Gregory Szorc34c863a2012-03-21 03:54:29 +0000621 */
Amaury Sechetf3549c42016-02-16 00:23:52 +0000622const char *LLVMGetDataLayoutStr(LLVMModuleRef M);
Gordon Henriksen05568bb2007-12-27 20:13:47 +0000623const char *LLVMGetDataLayout(LLVMModuleRef M);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000624
625/**
626 * Set the data layout for a module.
627 *
628 * @see Module::setDataLayout()
629 */
Amaury Sechet6ada31c2016-02-15 23:40:06 +0000630void LLVMSetDataLayout(LLVMModuleRef M, const char *DataLayoutStr);
Gordon Henriksen05568bb2007-12-27 20:13:47 +0000631
Gregory Szorc34c863a2012-03-21 03:54:29 +0000632/**
633 * Obtain the target triple for a module.
634 *
635 * @see Module::getTargetTriple()
636 */
Gordon Henriksen05568bb2007-12-27 20:13:47 +0000637const char *LLVMGetTarget(LLVMModuleRef M);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000638
639/**
640 * Set the target triple for a module.
641 *
642 * @see Module::setTargetTriple()
643 */
Gordon Henriksen05568bb2007-12-27 20:13:47 +0000644void LLVMSetTarget(LLVMModuleRef M, const char *Triple);
645
Gregory Szorc34c863a2012-03-21 03:54:29 +0000646/**
647 * Dump a representation of a module to stderr.
648 *
649 * @see Module::dump()
650 */
Gordon Henriksen6c6075e2008-03-14 23:58:56 +0000651void LLVMDumpModule(LLVMModuleRef M);
652
Gregory Szorc34c863a2012-03-21 03:54:29 +0000653/**
Hans Wennborgb7ef2fe2012-05-09 16:54:17 +0000654 * Print a representation of a module to a file. The ErrorMessage needs to be
655 * disposed with LLVMDisposeMessage. Returns 0 on success, 1 otherwise.
656 *
657 * @see Module::print()
658 */
659LLVMBool LLVMPrintModuleToFile(LLVMModuleRef M, const char *Filename,
660 char **ErrorMessage);
661
662/**
Anders Waldenborg84355db2013-10-16 18:00:54 +0000663 * Return a string representation of the module. Use
664 * LLVMDisposeMessage to free the string.
665 *
666 * @see Module::print()
667 */
668char *LLVMPrintModuleToString(LLVMModuleRef M);
669
670/**
Gregory Szorc34c863a2012-03-21 03:54:29 +0000671 * Set inline assembly for a module.
672 *
673 * @see Module::setModuleInlineAsm()
674 */
Chris Lattner26941452010-04-10 17:52:58 +0000675void LLVMSetModuleInlineAsm(LLVMModuleRef M, const char *Asm);
Gordon Henriksen76a03742007-09-18 03:18:57 +0000676
Gregory Szorc34c863a2012-03-21 03:54:29 +0000677/**
678 * Obtain the context to which this module is associated.
679 *
680 * @see Module::getContext()
681 */
Chris Lattnera7e04b02010-11-28 20:03:44 +0000682LLVMContextRef LLVMGetModuleContext(LLVMModuleRef M);
683
Gregory Szorc34c863a2012-03-21 03:54:29 +0000684/**
685 * Obtain a Type from a module by its registered name.
686 */
687LLVMTypeRef LLVMGetTypeByName(LLVMModuleRef M, const char *Name);
Gordon Henriksen76a03742007-09-18 03:18:57 +0000688
Gregory Szorc34c863a2012-03-21 03:54:29 +0000689/**
690 * Obtain the number of operands for named metadata in a module.
691 *
692 * @see llvm::Module::getNamedMetadata()
693 */
Amaury Sechetb130f432016-04-23 00:12:45 +0000694unsigned LLVMGetNamedMetadataNumOperands(LLVMModuleRef M, const char *Name);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000695
696/**
697 * Obtain the named metadata operands for a module.
698 *
699 * The passed LLVMValueRef pointer should refer to an array of
700 * LLVMValueRef at least LLVMGetNamedMetadataNumOperands long. This
701 * array will be populated with the LLVMValueRef instances. Each
702 * instance corresponds to a llvm::MDNode.
703 *
704 * @see llvm::Module::getNamedMetadata()
705 * @see llvm::MDNode::getOperand()
706 */
Amaury Sechetb130f432016-04-23 00:12:45 +0000707void LLVMGetNamedMetadataOperands(LLVMModuleRef M, const char *Name,
708 LLVMValueRef *Dest);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000709
710/**
711 * Add an operand to named metadata.
712 *
713 * @see llvm::Module::getNamedMetadata()
714 * @see llvm::MDNode::addOperand()
715 */
Amaury Sechetb130f432016-04-23 00:12:45 +0000716void LLVMAddNamedMetadataOperand(LLVMModuleRef M, const char *Name,
Gregory Szorc34c863a2012-03-21 03:54:29 +0000717 LLVMValueRef Val);
718
Gregory Szorc52d26602012-03-21 07:28:27 +0000719/**
720 * Add a function to a module under a specified name.
721 *
722 * @see llvm::Function::Create()
723 */
724LLVMValueRef LLVMAddFunction(LLVMModuleRef M, const char *Name,
725 LLVMTypeRef FunctionTy);
726
727/**
728 * Obtain a Function value from a Module by its name.
729 *
730 * The returned value corresponds to a llvm::Function value.
731 *
732 * @see llvm::Module::getFunction()
733 */
734LLVMValueRef LLVMGetNamedFunction(LLVMModuleRef M, const char *Name);
735
736/**
737 * Obtain an iterator to the first Function in a Module.
738 *
739 * @see llvm::Module::begin()
740 */
741LLVMValueRef LLVMGetFirstFunction(LLVMModuleRef M);
742
743/**
744 * Obtain an iterator to the last Function in a Module.
745 *
746 * @see llvm::Module::end()
747 */
748LLVMValueRef LLVMGetLastFunction(LLVMModuleRef M);
749
750/**
751 * Advance a Function iterator to the next Function.
752 *
753 * Returns NULL if the iterator was already at the end and there are no more
754 * functions.
755 */
756LLVMValueRef LLVMGetNextFunction(LLVMValueRef Fn);
757
758/**
759 * Decrement a Function iterator to the previous Function.
760 *
761 * Returns NULL if the iterator was already at the beginning and there are
762 * no previous functions.
763 */
764LLVMValueRef LLVMGetPreviousFunction(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000765
766/**
767 * @}
768 */
769
770/**
771 * @defgroup LLVMCCoreType Types
772 *
773 * Types represent the type of a value.
774 *
775 * Types are associated with a context instance. The context internally
776 * deduplicates types so there is only 1 instance of a specific type
777 * alive at a time. In other words, a unique type is shared among all
778 * consumers within a context.
779 *
780 * A Type in the C API corresponds to llvm::Type.
781 *
782 * Types have the following hierarchy:
783 *
Gordon Henriksen76a03742007-09-18 03:18:57 +0000784 * types:
785 * integer type
786 * real type
787 * function type
788 * sequence types:
789 * array type
790 * pointer type
791 * vector type
792 * void type
793 * label type
794 * opaque type
Gregory Szorc34c863a2012-03-21 03:54:29 +0000795 *
796 * @{
Gordon Henriksen76a03742007-09-18 03:18:57 +0000797 */
798
Gregory Szorc34c863a2012-03-21 03:54:29 +0000799/**
800 * Obtain the enumerated type of a Type instance.
801 *
802 * @see llvm::Type:getTypeID()
803 */
Gordon Henriksen76a03742007-09-18 03:18:57 +0000804LLVMTypeKind LLVMGetTypeKind(LLVMTypeRef Ty);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000805
806/**
807 * Whether the type has a known size.
808 *
809 * Things that don't have a size are abstract types, labels, and void.a
810 *
811 * @see llvm::Type::isSized()
812 */
Torok Edwin1cd9ade2011-10-06 12:13:28 +0000813LLVMBool LLVMTypeIsSized(LLVMTypeRef Ty);
Gordon Henriksena49d4352008-03-07 19:13:06 +0000814
Gregory Szorc34c863a2012-03-21 03:54:29 +0000815/**
816 * Obtain the context to which this type instance is associated.
817 *
818 * @see llvm::Type::getContext()
819 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +0000820LLVMContextRef LLVMGetTypeContext(LLVMTypeRef Ty);
821
Gregory Szorc34c863a2012-03-21 03:54:29 +0000822/**
Anders Waldenborgb822cff2013-10-16 21:30:25 +0000823 * Dump a representation of a type to stderr.
824 *
825 * @see llvm::Type::dump()
826 */
827void LLVMDumpType(LLVMTypeRef Val);
828
829/**
Anders Waldenborg47b3bd32013-10-22 06:58:34 +0000830 * Return a string representation of the type. Use
831 * LLVMDisposeMessage to free the string.
832 *
833 * @see llvm::Type::print()
834 */
835char *LLVMPrintTypeToString(LLVMTypeRef Val);
836
837/**
Gregory Szorc34c863a2012-03-21 03:54:29 +0000838 * @defgroup LLVMCCoreTypeInt Integer Types
839 *
840 * Functions in this section operate on integer types.
841 *
842 * @{
843 */
844
845/**
846 * Obtain an integer type from a context with specified bit width.
847 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +0000848LLVMTypeRef LLVMInt1TypeInContext(LLVMContextRef C);
849LLVMTypeRef LLVMInt8TypeInContext(LLVMContextRef C);
850LLVMTypeRef LLVMInt16TypeInContext(LLVMContextRef C);
851LLVMTypeRef LLVMInt32TypeInContext(LLVMContextRef C);
852LLVMTypeRef LLVMInt64TypeInContext(LLVMContextRef C);
Eugene Zelenkoffec81c2015-11-04 22:32:32 +0000853LLVMTypeRef LLVMInt128TypeInContext(LLVMContextRef C);
Erick Tryzelaar262332f2009-08-14 00:01:31 +0000854LLVMTypeRef LLVMIntTypeInContext(LLVMContextRef C, unsigned NumBits);
855
Gregory Szorc34c863a2012-03-21 03:54:29 +0000856/**
857 * Obtain an integer type from the global context with a specified bit
858 * width.
859 */
Gordon Henriksena735a9c2008-05-04 12:55:34 +0000860LLVMTypeRef LLVMInt1Type(void);
861LLVMTypeRef LLVMInt8Type(void);
862LLVMTypeRef LLVMInt16Type(void);
863LLVMTypeRef LLVMInt32Type(void);
864LLVMTypeRef LLVMInt64Type(void);
Eugene Zelenkoffec81c2015-11-04 22:32:32 +0000865LLVMTypeRef LLVMInt128Type(void);
Gordon Henriksened7beaa2007-10-06 16:05:20 +0000866LLVMTypeRef LLVMIntType(unsigned NumBits);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +0000867unsigned LLVMGetIntTypeWidth(LLVMTypeRef IntegerTy);
Gordon Henriksen76a03742007-09-18 03:18:57 +0000868
Gregory Szorc34c863a2012-03-21 03:54:29 +0000869/**
870 * @}
871 */
872
873/**
874 * @defgroup LLVMCCoreTypeFloat Floating Point Types
875 *
876 * @{
877 */
878
879/**
880 * Obtain a 16-bit floating point type from a context.
881 */
Dan Gohman518cda42011-12-17 00:04:22 +0000882LLVMTypeRef LLVMHalfTypeInContext(LLVMContextRef C);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000883
884/**
885 * Obtain a 32-bit floating point type from a context.
886 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +0000887LLVMTypeRef LLVMFloatTypeInContext(LLVMContextRef C);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000888
889/**
890 * Obtain a 64-bit floating point type from a context.
891 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +0000892LLVMTypeRef LLVMDoubleTypeInContext(LLVMContextRef C);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000893
894/**
895 * Obtain a 80-bit floating point type (X87) from a context.
896 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +0000897LLVMTypeRef LLVMX86FP80TypeInContext(LLVMContextRef C);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000898
899/**
900 * Obtain a 128-bit floating point type (112-bit mantissa) from a
901 * context.
902 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +0000903LLVMTypeRef LLVMFP128TypeInContext(LLVMContextRef C);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000904
905/**
906 * Obtain a 128-bit floating point type (two 64-bits) from a context.
907 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +0000908LLVMTypeRef LLVMPPCFP128TypeInContext(LLVMContextRef C);
909
Gregory Szorc34c863a2012-03-21 03:54:29 +0000910/**
911 * Obtain a floating point type from the global context.
912 *
913 * These map to the functions in this group of the same name.
914 */
Dan Gohman518cda42011-12-17 00:04:22 +0000915LLVMTypeRef LLVMHalfType(void);
Gordon Henriksena735a9c2008-05-04 12:55:34 +0000916LLVMTypeRef LLVMFloatType(void);
917LLVMTypeRef LLVMDoubleType(void);
918LLVMTypeRef LLVMX86FP80Type(void);
919LLVMTypeRef LLVMFP128Type(void);
920LLVMTypeRef LLVMPPCFP128Type(void);
Gordon Henriksen76a03742007-09-18 03:18:57 +0000921
Gregory Szorc34c863a2012-03-21 03:54:29 +0000922/**
923 * @}
924 */
925
926/**
927 * @defgroup LLVMCCoreTypeFunction Function Types
928 *
929 * @{
930 */
931
932/**
933 * Obtain a function type consisting of a specified signature.
934 *
935 * The function is defined as a tuple of a return Type, a list of
936 * parameter types, and whether the function is variadic.
937 */
Gordon Henriksened7beaa2007-10-06 16:05:20 +0000938LLVMTypeRef LLVMFunctionType(LLVMTypeRef ReturnType,
939 LLVMTypeRef *ParamTypes, unsigned ParamCount,
Chris Lattner25963c62010-01-09 22:27:07 +0000940 LLVMBool IsVarArg);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000941
942/**
943 * Returns whether a function type is variadic.
944 */
Chris Lattner25963c62010-01-09 22:27:07 +0000945LLVMBool LLVMIsFunctionVarArg(LLVMTypeRef FunctionTy);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000946
947/**
948 * Obtain the Type this function Type returns.
949 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +0000950LLVMTypeRef LLVMGetReturnType(LLVMTypeRef FunctionTy);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000951
952/**
953 * Obtain the number of parameters this function accepts.
954 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +0000955unsigned LLVMCountParamTypes(LLVMTypeRef FunctionTy);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000956
957/**
958 * Obtain the types of a function's parameters.
959 *
960 * The Dest parameter should point to a pre-allocated array of
961 * LLVMTypeRef at least LLVMCountParamTypes() large. On return, the
962 * first LLVMCountParamTypes() entries in the array will be populated
963 * with LLVMTypeRef instances.
964 *
965 * @param FunctionTy The function type to operate on.
966 * @param Dest Memory address of an array to be filled with result.
967 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +0000968void LLVMGetParamTypes(LLVMTypeRef FunctionTy, LLVMTypeRef *Dest);
Gordon Henriksen76a03742007-09-18 03:18:57 +0000969
Gregory Szorc34c863a2012-03-21 03:54:29 +0000970/**
971 * @}
972 */
973
974/**
975 * @defgroup LLVMCCoreTypeStruct Structure Types
976 *
977 * These functions relate to LLVMTypeRef instances.
978 *
979 * @see llvm::StructType
980 *
981 * @{
982 */
983
984/**
985 * Create a new structure type in a context.
986 *
987 * A structure is specified by a list of inner elements/types and
988 * whether these can be packed together.
989 *
990 * @see llvm::StructType::create()
991 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +0000992LLVMTypeRef LLVMStructTypeInContext(LLVMContextRef C, LLVMTypeRef *ElementTypes,
Chris Lattner25963c62010-01-09 22:27:07 +0000993 unsigned ElementCount, LLVMBool Packed);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000994
995/**
996 * Create a new structure type in the global context.
997 *
998 * @see llvm::StructType::create()
999 */
Gordon Henriksened7beaa2007-10-06 16:05:20 +00001000LLVMTypeRef LLVMStructType(LLVMTypeRef *ElementTypes, unsigned ElementCount,
Chris Lattner25963c62010-01-09 22:27:07 +00001001 LLVMBool Packed);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001002
1003/**
1004 * Create an empty structure in a context having a specified name.
1005 *
1006 * @see llvm::StructType::create()
1007 */
Chris Lattnere71ccde2011-07-14 05:53:17 +00001008LLVMTypeRef LLVMStructCreateNamed(LLVMContextRef C, const char *Name);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001009
1010/**
1011 * Obtain the name of a structure.
1012 *
1013 * @see llvm::StructType::getName()
1014 */
Torok Edwin0d5f6ae2011-10-06 12:12:50 +00001015const char *LLVMGetStructName(LLVMTypeRef Ty);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001016
1017/**
1018 * Set the contents of a structure type.
1019 *
1020 * @see llvm::StructType::setBody()
1021 */
Chris Lattnere71ccde2011-07-14 05:53:17 +00001022void LLVMStructSetBody(LLVMTypeRef StructTy, LLVMTypeRef *ElementTypes,
1023 unsigned ElementCount, LLVMBool Packed);
1024
Gregory Szorc34c863a2012-03-21 03:54:29 +00001025/**
1026 * Get the number of elements defined inside the structure.
1027 *
1028 * @see llvm::StructType::getNumElements()
1029 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00001030unsigned LLVMCountStructElementTypes(LLVMTypeRef StructTy);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001031
1032/**
1033 * Get the elements within a structure.
1034 *
1035 * The function is passed the address of a pre-allocated array of
1036 * LLVMTypeRef at least LLVMCountStructElementTypes() long. After
1037 * invocation, this array will be populated with the structure's
1038 * elements. The objects in the destination array will have a lifetime
1039 * of the structure type itself, which is the lifetime of the context it
1040 * is contained in.
1041 */
Gordon Henriksen76a03742007-09-18 03:18:57 +00001042void LLVMGetStructElementTypes(LLVMTypeRef StructTy, LLVMTypeRef *Dest);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001043
1044/**
Peter Zotovc164a3f2015-06-04 09:09:53 +00001045 * Get the type of the element at a given index in the structure.
1046 *
1047 * @see llvm::StructType::getTypeAtIndex()
1048 */
1049LLVMTypeRef LLVMStructGetTypeAtIndex(LLVMTypeRef StructTy, unsigned i);
1050
1051/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00001052 * Determine whether a structure is packed.
1053 *
1054 * @see llvm::StructType::isPacked()
1055 */
Chris Lattner25963c62010-01-09 22:27:07 +00001056LLVMBool LLVMIsPackedStruct(LLVMTypeRef StructTy);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001057
1058/**
1059 * Determine whether a structure is opaque.
1060 *
1061 * @see llvm::StructType::isOpaque()
1062 */
Chris Lattner17cf05b2011-07-14 16:20:28 +00001063LLVMBool LLVMIsOpaqueStruct(LLVMTypeRef StructTy);
1064
Gregory Szorc34c863a2012-03-21 03:54:29 +00001065/**
1066 * @}
1067 */
Gordon Henriksen76a03742007-09-18 03:18:57 +00001068
Gregory Szorc34c863a2012-03-21 03:54:29 +00001069/**
1070 * @defgroup LLVMCCoreTypeSequential Sequential Types
1071 *
1072 * Sequential types represents "arrays" of types. This is a super class
1073 * for array, vector, and pointer types.
1074 *
1075 * @{
1076 */
1077
1078/**
1079 * Obtain the type of elements within a sequential type.
1080 *
1081 * This works on array, vector, and pointer types.
1082 *
1083 * @see llvm::SequentialType::getElementType()
1084 */
1085LLVMTypeRef LLVMGetElementType(LLVMTypeRef Ty);
1086
1087/**
1088 * Create a fixed size array type that refers to a specific type.
1089 *
1090 * The created type will exist in the context that its element type
1091 * exists in.
1092 *
1093 * @see llvm::ArrayType::get()
1094 */
Gordon Henriksened7beaa2007-10-06 16:05:20 +00001095LLVMTypeRef LLVMArrayType(LLVMTypeRef ElementType, unsigned ElementCount);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001096
1097/**
1098 * Obtain the length of an array type.
1099 *
1100 * This only works on types that represent arrays.
1101 *
1102 * @see llvm::ArrayType::getNumElements()
1103 */
1104unsigned LLVMGetArrayLength(LLVMTypeRef ArrayTy);
1105
1106/**
1107 * Create a pointer type that points to a defined type.
1108 *
1109 * The created type will exist in the context that its pointee type
1110 * exists in.
1111 *
1112 * @see llvm::PointerType::get()
1113 */
Gordon Henriksen5a3fe032007-12-17 16:08:32 +00001114LLVMTypeRef LLVMPointerType(LLVMTypeRef ElementType, unsigned AddressSpace);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001115
1116/**
1117 * Obtain the address space of a pointer type.
1118 *
1119 * This only works on types that represent pointers.
1120 *
1121 * @see llvm::PointerType::getAddressSpace()
1122 */
1123unsigned LLVMGetPointerAddressSpace(LLVMTypeRef PointerTy);
1124
1125/**
1126 * Create a vector type that contains a defined type and has a specific
1127 * number of elements.
1128 *
1129 * The created type will exist in the context thats its element type
1130 * exists in.
1131 *
1132 * @see llvm::VectorType::get()
1133 */
Gordon Henriksened7beaa2007-10-06 16:05:20 +00001134LLVMTypeRef LLVMVectorType(LLVMTypeRef ElementType, unsigned ElementCount);
Gordon Henriksen76a03742007-09-18 03:18:57 +00001135
Gregory Szorc34c863a2012-03-21 03:54:29 +00001136/**
1137 * Obtain the number of elements in a vector type.
1138 *
1139 * This only works on types that represent vectors.
1140 *
1141 * @see llvm::VectorType::getNumElements()
1142 */
Gordon Henriksen76a03742007-09-18 03:18:57 +00001143unsigned LLVMGetVectorSize(LLVMTypeRef VectorTy);
1144
Gregory Szorc34c863a2012-03-21 03:54:29 +00001145/**
1146 * @}
1147 */
1148
1149/**
1150 * @defgroup LLVMCCoreTypeOther Other Types
1151 *
1152 * @{
1153 */
1154
1155/**
1156 * Create a void type in a context.
1157 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +00001158LLVMTypeRef LLVMVoidTypeInContext(LLVMContextRef C);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001159
1160/**
1161 * Create a label type in a context.
1162 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +00001163LLVMTypeRef LLVMLabelTypeInContext(LLVMContextRef C);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001164
1165/**
1166 * Create a X86 MMX type in a context.
1167 */
Dale Johannesen95b67af2010-09-10 21:58:02 +00001168LLVMTypeRef LLVMX86MMXTypeInContext(LLVMContextRef C);
Erick Tryzelaar262332f2009-08-14 00:01:31 +00001169
Gregory Szorc34c863a2012-03-21 03:54:29 +00001170/**
1171 * These are similar to the above functions except they operate on the
1172 * global context.
1173 */
Gordon Henriksena735a9c2008-05-04 12:55:34 +00001174LLVMTypeRef LLVMVoidType(void);
1175LLVMTypeRef LLVMLabelType(void);
Dale Johannesen95b67af2010-09-10 21:58:02 +00001176LLVMTypeRef LLVMX86MMXType(void);
Gordon Henriksen76a03742007-09-18 03:18:57 +00001177
Gregory Szorc34c863a2012-03-21 03:54:29 +00001178/**
1179 * @}
1180 */
Gordon Henriksen76a03742007-09-18 03:18:57 +00001181
Gregory Szorc34c863a2012-03-21 03:54:29 +00001182/**
1183 * @}
1184 */
1185
1186/**
1187 * @defgroup LLVMCCoreValues Values
1188 *
1189 * The bulk of LLVM's object model consists of values, which comprise a very
Gordon Henriksen76a03742007-09-18 03:18:57 +00001190 * rich type hierarchy.
Gregory Szorc34c863a2012-03-21 03:54:29 +00001191 *
1192 * LLVMValueRef essentially represents llvm::Value. There is a rich
1193 * hierarchy of classes within this type. Depending on the instance
Eli Benderskyc52863c2012-08-10 18:30:44 +00001194 * obtained, not all APIs are available.
Gregory Szorc34c863a2012-03-21 03:54:29 +00001195 *
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00001196 * Callers can determine the type of an LLVMValueRef by calling the
Gregory Szorc34c863a2012-03-21 03:54:29 +00001197 * LLVMIsA* family of functions (e.g. LLVMIsAArgument()). These
1198 * functions are defined by a macro, so it isn't obvious which are
1199 * available by looking at the Doxygen source code. Instead, look at the
1200 * source definition of LLVM_FOR_EACH_VALUE_SUBCLASS and note the list
1201 * of value names given. These value names also correspond to classes in
1202 * the llvm::Value hierarchy.
1203 *
1204 * @{
Gordon Henriksen76a03742007-09-18 03:18:57 +00001205 */
1206
Gordon Henriksen29e38942008-12-19 18:39:45 +00001207#define LLVM_FOR_EACH_VALUE_SUBCLASS(macro) \
1208 macro(Argument) \
1209 macro(BasicBlock) \
1210 macro(InlineAsm) \
1211 macro(User) \
1212 macro(Constant) \
Torok Edwind09b7572011-10-14 20:37:56 +00001213 macro(BlockAddress) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001214 macro(ConstantAggregateZero) \
1215 macro(ConstantArray) \
Peter Zotovae0344b2013-11-05 12:55:37 +00001216 macro(ConstantDataSequential) \
1217 macro(ConstantDataArray) \
1218 macro(ConstantDataVector) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001219 macro(ConstantExpr) \
1220 macro(ConstantFP) \
1221 macro(ConstantInt) \
1222 macro(ConstantPointerNull) \
1223 macro(ConstantStruct) \
David Majnemerf0f224d2015-11-11 21:57:16 +00001224 macro(ConstantTokenNone) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001225 macro(ConstantVector) \
1226 macro(GlobalValue) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001227 macro(GlobalAlias) \
Rafael Espindola99e05cf2014-05-13 18:45:48 +00001228 macro(GlobalObject) \
1229 macro(Function) \
1230 macro(GlobalVariable) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001231 macro(UndefValue) \
1232 macro(Instruction) \
1233 macro(BinaryOperator) \
1234 macro(CallInst) \
1235 macro(IntrinsicInst) \
1236 macro(DbgInfoIntrinsic) \
1237 macro(DbgDeclareInst) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001238 macro(MemIntrinsic) \
1239 macro(MemCpyInst) \
1240 macro(MemMoveInst) \
1241 macro(MemSetInst) \
1242 macro(CmpInst) \
Torok Edwind09b7572011-10-14 20:37:56 +00001243 macro(FCmpInst) \
1244 macro(ICmpInst) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001245 macro(ExtractElementInst) \
1246 macro(GetElementPtrInst) \
1247 macro(InsertElementInst) \
1248 macro(InsertValueInst) \
Bill Wendlingfae14752011-08-12 20:24:12 +00001249 macro(LandingPadInst) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001250 macro(PHINode) \
1251 macro(SelectInst) \
1252 macro(ShuffleVectorInst) \
1253 macro(StoreInst) \
1254 macro(TerminatorInst) \
1255 macro(BranchInst) \
Torok Edwind09b7572011-10-14 20:37:56 +00001256 macro(IndirectBrInst) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001257 macro(InvokeInst) \
1258 macro(ReturnInst) \
1259 macro(SwitchInst) \
1260 macro(UnreachableInst) \
Bill Wendlingf891bf82011-07-31 06:30:59 +00001261 macro(ResumeInst) \
David Majnemer654e1302015-07-31 17:58:14 +00001262 macro(CleanupReturnInst) \
1263 macro(CatchReturnInst) \
David Majnemer8a1c45d2015-12-12 05:38:55 +00001264 macro(FuncletPadInst) \
1265 macro(CatchPadInst) \
1266 macro(CleanupPadInst) \
Duncan Sands5e37e992013-05-06 08:55:45 +00001267 macro(UnaryInstruction) \
1268 macro(AllocaInst) \
1269 macro(CastInst) \
Matt Arsenaultb03bd4d2013-11-15 01:34:59 +00001270 macro(AddrSpaceCastInst) \
Duncan Sands5e37e992013-05-06 08:55:45 +00001271 macro(BitCastInst) \
1272 macro(FPExtInst) \
1273 macro(FPToSIInst) \
1274 macro(FPToUIInst) \
1275 macro(FPTruncInst) \
1276 macro(IntToPtrInst) \
1277 macro(PtrToIntInst) \
1278 macro(SExtInst) \
1279 macro(SIToFPInst) \
1280 macro(TruncInst) \
1281 macro(UIToFPInst) \
1282 macro(ZExtInst) \
1283 macro(ExtractValueInst) \
1284 macro(LoadInst) \
1285 macro(VAArgInst)
Gordon Henriksen29e38942008-12-19 18:39:45 +00001286
Gregory Szorc34c863a2012-03-21 03:54:29 +00001287/**
1288 * @defgroup LLVMCCoreValueGeneral General APIs
1289 *
1290 * Functions in this section work on all LLVMValueRef instances,
1291 * regardless of their sub-type. They correspond to functions available
1292 * on llvm::Value.
1293 *
1294 * @{
1295 */
Gordon Henriksen76a03742007-09-18 03:18:57 +00001296
Gregory Szorc34c863a2012-03-21 03:54:29 +00001297/**
1298 * Obtain the type of a value.
1299 *
1300 * @see llvm::Value::getType()
1301 */
1302LLVMTypeRef LLVMTypeOf(LLVMValueRef Val);
1303
1304/**
Peter Zotov3e4561c2016-04-06 22:21:29 +00001305 * Obtain the enumerated type of a Value instance.
1306 *
1307 * @see llvm::Value::getValueID()
1308 */
1309LLVMValueKind LLVMGetValueKind(LLVMValueRef Val);
1310
1311/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00001312 * Obtain the string name of a value.
1313 *
1314 * @see llvm::Value::getName()
1315 */
1316const char *LLVMGetValueName(LLVMValueRef Val);
1317
1318/**
1319 * Set the string name of a value.
1320 *
1321 * @see llvm::Value::setName()
1322 */
1323void LLVMSetValueName(LLVMValueRef Val, const char *Name);
1324
1325/**
1326 * Dump a representation of a value to stderr.
1327 *
1328 * @see llvm::Value::dump()
1329 */
1330void LLVMDumpValue(LLVMValueRef Val);
1331
1332/**
Peter Zotovcd93b372013-11-06 09:21:01 +00001333 * Return a string representation of the value. Use
1334 * LLVMDisposeMessage to free the string.
1335 *
1336 * @see llvm::Value::print()
1337 */
1338char *LLVMPrintValueToString(LLVMValueRef Val);
1339
1340/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00001341 * Replace all uses of a value with another one.
1342 *
1343 * @see llvm::Value::replaceAllUsesWith()
1344 */
1345void LLVMReplaceAllUsesWith(LLVMValueRef OldVal, LLVMValueRef NewVal);
1346
1347/**
Amaury Sechet1c395072016-01-18 01:06:52 +00001348 * Determine whether the specified value instance is constant.
Gregory Szorc34c863a2012-03-21 03:54:29 +00001349 */
1350LLVMBool LLVMIsConstant(LLVMValueRef Val);
1351
1352/**
1353 * Determine whether a value instance is undefined.
1354 */
1355LLVMBool LLVMIsUndef(LLVMValueRef Val);
1356
1357/**
1358 * Convert value instances between types.
1359 *
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00001360 * Internally, an LLVMValueRef is "pinned" to a specific type. This
Gregory Szorc34c863a2012-03-21 03:54:29 +00001361 * series of functions allows you to cast an instance to a specific
1362 * type.
1363 *
1364 * If the cast is not valid for the specified type, NULL is returned.
1365 *
1366 * @see llvm::dyn_cast_or_null<>
1367 */
Gordon Henriksen29e38942008-12-19 18:39:45 +00001368#define LLVM_DECLARE_VALUE_CAST(name) \
1369 LLVMValueRef LLVMIsA##name(LLVMValueRef Val);
1370LLVM_FOR_EACH_VALUE_SUBCLASS(LLVM_DECLARE_VALUE_CAST)
1371
Duncan P. N. Exon Smith5bf8fef2014-12-09 18:38:53 +00001372LLVMValueRef LLVMIsAMDNode(LLVMValueRef Val);
1373LLVMValueRef LLVMIsAMDString(LLVMValueRef Val);
1374
Gregory Szorc34c863a2012-03-21 03:54:29 +00001375/**
1376 * @}
1377 */
1378
1379/**
1380 * @defgroup LLVMCCoreValueUses Usage
1381 *
1382 * This module defines functions that allow you to inspect the uses of a
1383 * LLVMValueRef.
1384 *
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00001385 * It is possible to obtain an LLVMUseRef for any LLVMValueRef instance.
Gregory Szorc34c863a2012-03-21 03:54:29 +00001386 * Each LLVMUseRef (which corresponds to a llvm::Use instance) holds a
1387 * llvm::User and llvm::Value.
1388 *
1389 * @{
1390 */
1391
1392/**
1393 * Obtain the first use of a value.
1394 *
1395 * Uses are obtained in an iterator fashion. First, call this function
1396 * to obtain a reference to the first use. Then, call LLVMGetNextUse()
Eli Benderskyc52863c2012-08-10 18:30:44 +00001397 * on that instance and all subsequently obtained instances until
Gregory Szorc34c863a2012-03-21 03:54:29 +00001398 * LLVMGetNextUse() returns NULL.
1399 *
1400 * @see llvm::Value::use_begin()
1401 */
Erick Tryzelaar9f9857e2010-03-02 20:32:28 +00001402LLVMUseRef LLVMGetFirstUse(LLVMValueRef Val);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001403
1404/**
1405 * Obtain the next use of a value.
1406 *
1407 * This effectively advances the iterator. It returns NULL if you are on
1408 * the final use and no more are available.
1409 */
Erick Tryzelaar9f9857e2010-03-02 20:32:28 +00001410LLVMUseRef LLVMGetNextUse(LLVMUseRef U);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001411
1412/**
1413 * Obtain the user value for a user.
1414 *
1415 * The returned value corresponds to a llvm::User type.
1416 *
1417 * @see llvm::Use::getUser()
1418 */
Erick Tryzelaar9f9857e2010-03-02 20:32:28 +00001419LLVMValueRef LLVMGetUser(LLVMUseRef U);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001420
1421/**
1422 * Obtain the value this use corresponds to.
1423 *
1424 * @see llvm::Use::get().
1425 */
Erick Tryzelaar9f9857e2010-03-02 20:32:28 +00001426LLVMValueRef LLVMGetUsedValue(LLVMUseRef U);
Chris Lattner40cf28d2009-10-12 04:01:02 +00001427
Gregory Szorc34c863a2012-03-21 03:54:29 +00001428/**
1429 * @}
1430 */
1431
1432/**
Gregory Szorc52d26602012-03-21 07:28:27 +00001433 * @defgroup LLVMCCoreValueUser User value
Gregory Szorc34c863a2012-03-21 03:54:29 +00001434 *
1435 * Function in this group pertain to LLVMValueRef instances that descent
1436 * from llvm::User. This includes constants, instructions, and
1437 * operators.
1438 *
1439 * @{
1440 */
1441
1442/**
1443 * Obtain an operand at a specific index in a llvm::User value.
1444 *
1445 * @see llvm::User::getOperand()
1446 */
Chris Lattner40cf28d2009-10-12 04:01:02 +00001447LLVMValueRef LLVMGetOperand(LLVMValueRef Val, unsigned Index);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001448
1449/**
Peter Zotovb19f78f2014-08-12 02:55:40 +00001450 * Obtain the use of an operand at a specific index in a llvm::User value.
1451 *
1452 * @see llvm::User::getOperandUse()
1453 */
1454LLVMUseRef LLVMGetOperandUse(LLVMValueRef Val, unsigned Index);
1455
1456/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00001457 * Set an operand at a specific index in a llvm::User value.
1458 *
1459 * @see llvm::User::setOperand()
1460 */
Erick Tryzelaarb4d48702010-08-20 14:51:22 +00001461void LLVMSetOperand(LLVMValueRef User, unsigned Index, LLVMValueRef Val);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001462
1463/**
1464 * Obtain the number of operands in a llvm::User value.
1465 *
1466 * @see llvm::User::getNumOperands()
1467 */
Erick Tryzelaarb4d48702010-08-20 14:51:22 +00001468int LLVMGetNumOperands(LLVMValueRef Val);
Chris Lattner40cf28d2009-10-12 04:01:02 +00001469
Gregory Szorc34c863a2012-03-21 03:54:29 +00001470/**
1471 * @}
1472 */
1473
1474/**
Gregory Szorc52d26602012-03-21 07:28:27 +00001475 * @defgroup LLVMCCoreValueConstant Constants
Gregory Szorc34c863a2012-03-21 03:54:29 +00001476 *
1477 * This section contains APIs for interacting with LLVMValueRef that
1478 * correspond to llvm::Constant instances.
1479 *
1480 * These functions will work for any LLVMValueRef in the llvm::Constant
1481 * class hierarchy.
1482 *
1483 * @{
1484 */
1485
1486/**
1487 * Obtain a constant value referring to the null instance of a type.
1488 *
1489 * @see llvm::Constant::getNullValue()
1490 */
Gordon Henriksen1046c732007-10-06 15:11:06 +00001491LLVMValueRef LLVMConstNull(LLVMTypeRef Ty); /* all zeroes */
Gregory Szorc34c863a2012-03-21 03:54:29 +00001492
1493/**
1494 * Obtain a constant value referring to the instance of a type
1495 * consisting of all ones.
1496 *
1497 * This is only valid for integer types.
1498 *
1499 * @see llvm::Constant::getAllOnesValue()
1500 */
1501LLVMValueRef LLVMConstAllOnes(LLVMTypeRef Ty);
1502
1503/**
1504 * Obtain a constant value referring to an undefined value of a type.
1505 *
1506 * @see llvm::UndefValue::get()
1507 */
Gordon Henriksen76a03742007-09-18 03:18:57 +00001508LLVMValueRef LLVMGetUndef(LLVMTypeRef Ty);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001509
1510/**
1511 * Determine whether a value instance is null.
1512 *
1513 * @see llvm::Constant::isNullValue()
1514 */
Chris Lattner25963c62010-01-09 22:27:07 +00001515LLVMBool LLVMIsNull(LLVMValueRef Val);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001516
1517/**
1518 * Obtain a constant that is a constant pointer pointing to NULL for a
1519 * specified type.
1520 */
Chris Lattner7f318242009-07-06 17:29:59 +00001521LLVMValueRef LLVMConstPointerNull(LLVMTypeRef Ty);
Gordon Henriksen76a03742007-09-18 03:18:57 +00001522
Gregory Szorc34c863a2012-03-21 03:54:29 +00001523/**
1524 * @defgroup LLVMCCoreValueConstantScalar Scalar constants
1525 *
1526 * Functions in this group model LLVMValueRef instances that correspond
1527 * to constants referring to scalar types.
1528 *
1529 * For integer types, the LLVMTypeRef parameter should correspond to a
1530 * llvm::IntegerType instance and the returned LLVMValueRef will
1531 * correspond to a llvm::ConstantInt.
1532 *
1533 * For floating point types, the LLVMTypeRef returned corresponds to a
1534 * llvm::ConstantFP.
1535 *
1536 * @{
1537 */
Erick Tryzelaard8531fa2010-02-28 09:45:59 +00001538
Gregory Szorc34c863a2012-03-21 03:54:29 +00001539/**
1540 * Obtain a constant value for an integer type.
1541 *
1542 * The returned value corresponds to a llvm::ConstantInt.
1543 *
1544 * @see llvm::ConstantInt::get()
1545 *
1546 * @param IntTy Integer type to obtain value of.
1547 * @param N The value the returned instance should refer to.
1548 * @param SignExtend Whether to sign extend the produced value.
1549 */
Gordon Henriksen1046c732007-10-06 15:11:06 +00001550LLVMValueRef LLVMConstInt(LLVMTypeRef IntTy, unsigned long long N,
Chris Lattner25963c62010-01-09 22:27:07 +00001551 LLVMBool SignExtend);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001552
1553/**
1554 * Obtain a constant value for an integer of arbitrary precision.
1555 *
1556 * @see llvm::ConstantInt::get()
1557 */
Chris Lattner4329e072010-11-23 02:47:22 +00001558LLVMValueRef LLVMConstIntOfArbitraryPrecision(LLVMTypeRef IntTy,
1559 unsigned NumWords,
1560 const uint64_t Words[]);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001561
1562/**
1563 * Obtain a constant value for an integer parsed from a string.
1564 *
1565 * A similar API, LLVMConstIntOfStringAndSize is also available. If the
1566 * string's length is available, it is preferred to call that function
1567 * instead.
1568 *
1569 * @see llvm::ConstantInt::get()
1570 */
Erick Tryzelaardd991352009-08-16 23:36:46 +00001571LLVMValueRef LLVMConstIntOfString(LLVMTypeRef IntTy, const char *Text,
1572 uint8_t Radix);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001573
1574/**
1575 * Obtain a constant value for an integer parsed from a string with
1576 * specified length.
1577 *
1578 * @see llvm::ConstantInt::get()
1579 */
Erick Tryzelaardd991352009-08-16 23:36:46 +00001580LLVMValueRef LLVMConstIntOfStringAndSize(LLVMTypeRef IntTy, const char *Text,
1581 unsigned SLen, uint8_t Radix);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001582
1583/**
1584 * Obtain a constant value referring to a double floating point value.
1585 */
Gordon Henriksen1046c732007-10-06 15:11:06 +00001586LLVMValueRef LLVMConstReal(LLVMTypeRef RealTy, double N);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001587
1588/**
1589 * Obtain a constant for a floating point value parsed from a string.
1590 *
1591 * A similar API, LLVMConstRealOfStringAndSize is also available. It
1592 * should be used if the input string's length is known.
1593 */
Gordon Henriksen931e1212008-02-02 01:07:50 +00001594LLVMValueRef LLVMConstRealOfString(LLVMTypeRef RealTy, const char *Text);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001595
1596/**
1597 * Obtain a constant for a floating point value parsed from a string.
1598 */
Erick Tryzelaardd991352009-08-16 23:36:46 +00001599LLVMValueRef LLVMConstRealOfStringAndSize(LLVMTypeRef RealTy, const char *Text,
1600 unsigned SLen);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001601
1602/**
1603 * Obtain the zero extended value for an integer constant value.
1604 *
1605 * @see llvm::ConstantInt::getZExtValue()
1606 */
Chris Lattner40cf28d2009-10-12 04:01:02 +00001607unsigned long long LLVMConstIntGetZExtValue(LLVMValueRef ConstantVal);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001608
1609/**
1610 * Obtain the sign extended value for an integer constant value.
1611 *
1612 * @see llvm::ConstantInt::getSExtValue()
1613 */
Chris Lattner40cf28d2009-10-12 04:01:02 +00001614long long LLVMConstIntGetSExtValue(LLVMValueRef ConstantVal);
Erick Tryzelaardd991352009-08-16 23:36:46 +00001615
Gregory Szorc34c863a2012-03-21 03:54:29 +00001616/**
Peter Zotov1d98e6d2014-10-28 19:46:44 +00001617 * Obtain the double value for an floating point constant value.
1618 * losesInfo indicates if some precision was lost in the conversion.
1619 *
1620 * @see llvm::ConstantFP::getDoubleValue
1621 */
1622double LLVMConstRealGetDouble(LLVMValueRef ConstantVal, LLVMBool *losesInfo);
1623
1624/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00001625 * @}
1626 */
1627
1628/**
Gregory Szorc52d26602012-03-21 07:28:27 +00001629 * @defgroup LLVMCCoreValueConstantComposite Composite Constants
1630 *
1631 * Functions in this group operate on composite constants.
Gregory Szorc34c863a2012-03-21 03:54:29 +00001632 *
1633 * @{
1634 */
1635
1636/**
Gregory Szorc52d26602012-03-21 07:28:27 +00001637 * Create a ConstantDataSequential and initialize it with a string.
Gregory Szorc34c863a2012-03-21 03:54:29 +00001638 *
Gregory Szorc52d26602012-03-21 07:28:27 +00001639 * @see llvm::ConstantDataArray::getString()
Gregory Szorc34c863a2012-03-21 03:54:29 +00001640 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +00001641LLVMValueRef LLVMConstStringInContext(LLVMContextRef C, const char *Str,
Chris Lattner25963c62010-01-09 22:27:07 +00001642 unsigned Length, LLVMBool DontNullTerminate);
Gregory Szorc52d26602012-03-21 07:28:27 +00001643
1644/**
1645 * Create a ConstantDataSequential with string content in the global context.
1646 *
1647 * This is the same as LLVMConstStringInContext except it operates on the
1648 * global context.
1649 *
1650 * @see LLVMConstStringInContext()
1651 * @see llvm::ConstantDataArray::getString()
1652 */
1653LLVMValueRef LLVMConstString(const char *Str, unsigned Length,
1654 LLVMBool DontNullTerminate);
1655
1656/**
Peter Zotovf9aa8822014-08-03 23:54:16 +00001657 * Returns true if the specified constant is an array of i8.
1658 *
1659 * @see ConstantDataSequential::getAsString()
1660 */
1661LLVMBool LLVMIsConstantString(LLVMValueRef c);
1662
1663/**
1664 * Get the given constant data sequential as a string.
1665 *
1666 * @see ConstantDataSequential::getAsString()
1667 */
Amaury Sechet7c2883c2016-04-03 21:06:04 +00001668const char *LLVMGetAsString(LLVMValueRef c, size_t *Length);
Peter Zotovf9aa8822014-08-03 23:54:16 +00001669
1670/**
Gregory Szorc52d26602012-03-21 07:28:27 +00001671 * Create an anonymous ConstantStruct with the specified values.
1672 *
1673 * @see llvm::ConstantStruct::getAnon()
1674 */
1675LLVMValueRef LLVMConstStructInContext(LLVMContextRef C,
Erick Tryzelaar262332f2009-08-14 00:01:31 +00001676 LLVMValueRef *ConstantVals,
Chris Lattner25963c62010-01-09 22:27:07 +00001677 unsigned Count, LLVMBool Packed);
Erick Tryzelaar262332f2009-08-14 00:01:31 +00001678
Gregory Szorc52d26602012-03-21 07:28:27 +00001679/**
1680 * Create a ConstantStruct in the global Context.
1681 *
1682 * This is the same as LLVMConstStructInContext except it operates on the
1683 * global Context.
1684 *
1685 * @see LLVMConstStructInContext()
1686 */
Gordon Henriksen1046c732007-10-06 15:11:06 +00001687LLVMValueRef LLVMConstStruct(LLVMValueRef *ConstantVals, unsigned Count,
Chris Lattner25963c62010-01-09 22:27:07 +00001688 LLVMBool Packed);
Gregory Szorc52d26602012-03-21 07:28:27 +00001689
1690/**
1691 * Create a ConstantArray from values.
1692 *
1693 * @see llvm::ConstantArray::get()
1694 */
1695LLVMValueRef LLVMConstArray(LLVMTypeRef ElementTy,
1696 LLVMValueRef *ConstantVals, unsigned Length);
1697
1698/**
1699 * Create a non-anonymous ConstantStruct from values.
1700 *
1701 * @see llvm::ConstantStruct::get()
1702 */
Rafael Espindola784ad242011-07-14 19:09:08 +00001703LLVMValueRef LLVMConstNamedStruct(LLVMTypeRef StructTy,
1704 LLVMValueRef *ConstantVals,
1705 unsigned Count);
Gregory Szorc52d26602012-03-21 07:28:27 +00001706
1707/**
Peter Zotovf9aa8822014-08-03 23:54:16 +00001708 * Get an element at specified index as a constant.
1709 *
1710 * @see ConstantDataSequential::getElementAsConstant()
1711 */
Amaury Sechet006ce632016-03-13 00:54:40 +00001712LLVMValueRef LLVMGetElementAsConstant(LLVMValueRef C, unsigned idx);
Peter Zotovf9aa8822014-08-03 23:54:16 +00001713
1714/**
Gregory Szorc52d26602012-03-21 07:28:27 +00001715 * Create a ConstantVector from values.
1716 *
1717 * @see llvm::ConstantVector::get()
1718 */
Gordon Henriksen1046c732007-10-06 15:11:06 +00001719LLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals, unsigned Size);
Gordon Henriksen76a03742007-09-18 03:18:57 +00001720
Gregory Szorc52d26602012-03-21 07:28:27 +00001721/**
1722 * @}
1723 */
1724
1725/**
1726 * @defgroup LLVMCCoreValueConstantExpressions Constant Expressions
1727 *
1728 * Functions in this group correspond to APIs on llvm::ConstantExpr.
1729 *
1730 * @see llvm::ConstantExpr.
1731 *
1732 * @{
1733 */
Chris Lattner40cf28d2009-10-12 04:01:02 +00001734LLVMOpcode LLVMGetConstOpcode(LLVMValueRef ConstantVal);
Erick Tryzelaarfd529d72009-08-19 08:36:49 +00001735LLVMValueRef LLVMAlignOf(LLVMTypeRef Ty);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001736LLVMValueRef LLVMSizeOf(LLVMTypeRef Ty);
1737LLVMValueRef LLVMConstNeg(LLVMValueRef ConstantVal);
Erick Tryzelaar4c340c72010-02-28 05:51:43 +00001738LLVMValueRef LLVMConstNSWNeg(LLVMValueRef ConstantVal);
1739LLVMValueRef LLVMConstNUWNeg(LLVMValueRef ConstantVal);
Erick Tryzelaar4cc690c2009-08-16 02:20:12 +00001740LLVMValueRef LLVMConstFNeg(LLVMValueRef ConstantVal);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001741LLVMValueRef LLVMConstNot(LLVMValueRef ConstantVal);
1742LLVMValueRef LLVMConstAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Dan Gohmane4ca02d2009-09-03 23:34:49 +00001743LLVMValueRef LLVMConstNSWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Erick Tryzelaar4c340c72010-02-28 05:51:43 +00001744LLVMValueRef LLVMConstNUWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Erick Tryzelaar4cc690c2009-08-16 02:20:12 +00001745LLVMValueRef LLVMConstFAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001746LLVMValueRef LLVMConstSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Erick Tryzelaar4c340c72010-02-28 05:51:43 +00001747LLVMValueRef LLVMConstNSWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1748LLVMValueRef LLVMConstNUWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Erick Tryzelaar4cc690c2009-08-16 02:20:12 +00001749LLVMValueRef LLVMConstFSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001750LLVMValueRef LLVMConstMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Erick Tryzelaar4c340c72010-02-28 05:51:43 +00001751LLVMValueRef LLVMConstNSWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1752LLVMValueRef LLVMConstNUWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Erick Tryzelaar4cc690c2009-08-16 02:20:12 +00001753LLVMValueRef LLVMConstFMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001754LLVMValueRef LLVMConstUDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1755LLVMValueRef LLVMConstSDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Dan Gohmane4ca02d2009-09-03 23:34:49 +00001756LLVMValueRef LLVMConstExactSDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001757LLVMValueRef LLVMConstFDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1758LLVMValueRef LLVMConstURem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1759LLVMValueRef LLVMConstSRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1760LLVMValueRef LLVMConstFRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1761LLVMValueRef LLVMConstAnd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1762LLVMValueRef LLVMConstOr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1763LLVMValueRef LLVMConstXor(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1764LLVMValueRef LLVMConstICmp(LLVMIntPredicate Predicate,
1765 LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1766LLVMValueRef LLVMConstFCmp(LLVMRealPredicate Predicate,
1767 LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1768LLVMValueRef LLVMConstShl(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1769LLVMValueRef LLVMConstLShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1770LLVMValueRef LLVMConstAShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1771LLVMValueRef LLVMConstGEP(LLVMValueRef ConstantVal,
1772 LLVMValueRef *ConstantIndices, unsigned NumIndices);
Dan Gohmane4ca02d2009-09-03 23:34:49 +00001773LLVMValueRef LLVMConstInBoundsGEP(LLVMValueRef ConstantVal,
1774 LLVMValueRef *ConstantIndices,
1775 unsigned NumIndices);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001776LLVMValueRef LLVMConstTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1777LLVMValueRef LLVMConstSExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1778LLVMValueRef LLVMConstZExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1779LLVMValueRef LLVMConstFPTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1780LLVMValueRef LLVMConstFPExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1781LLVMValueRef LLVMConstUIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1782LLVMValueRef LLVMConstSIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1783LLVMValueRef LLVMConstFPToUI(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1784LLVMValueRef LLVMConstFPToSI(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1785LLVMValueRef LLVMConstPtrToInt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1786LLVMValueRef LLVMConstIntToPtr(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1787LLVMValueRef LLVMConstBitCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
Matt Arsenaultb03bd4d2013-11-15 01:34:59 +00001788LLVMValueRef LLVMConstAddrSpaceCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
Erick Tryzelaar4cc690c2009-08-16 02:20:12 +00001789LLVMValueRef LLVMConstZExtOrBitCast(LLVMValueRef ConstantVal,
1790 LLVMTypeRef ToType);
1791LLVMValueRef LLVMConstSExtOrBitCast(LLVMValueRef ConstantVal,
1792 LLVMTypeRef ToType);
1793LLVMValueRef LLVMConstTruncOrBitCast(LLVMValueRef ConstantVal,
1794 LLVMTypeRef ToType);
1795LLVMValueRef LLVMConstPointerCast(LLVMValueRef ConstantVal,
1796 LLVMTypeRef ToType);
1797LLVMValueRef LLVMConstIntCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType,
Chris Lattner25963c62010-01-09 22:27:07 +00001798 LLVMBool isSigned);
Erick Tryzelaar4cc690c2009-08-16 02:20:12 +00001799LLVMValueRef LLVMConstFPCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001800LLVMValueRef LLVMConstSelect(LLVMValueRef ConstantCondition,
1801 LLVMValueRef ConstantIfTrue,
1802 LLVMValueRef ConstantIfFalse);
1803LLVMValueRef LLVMConstExtractElement(LLVMValueRef VectorConstant,
1804 LLVMValueRef IndexConstant);
1805LLVMValueRef LLVMConstInsertElement(LLVMValueRef VectorConstant,
1806 LLVMValueRef ElementValueConstant,
1807 LLVMValueRef IndexConstant);
1808LLVMValueRef LLVMConstShuffleVector(LLVMValueRef VectorAConstant,
1809 LLVMValueRef VectorBConstant,
1810 LLVMValueRef MaskConstant);
Dan Gohmand5104a52008-11-03 22:55:43 +00001811LLVMValueRef LLVMConstExtractValue(LLVMValueRef AggConstant, unsigned *IdxList,
1812 unsigned NumIdx);
1813LLVMValueRef LLVMConstInsertValue(LLVMValueRef AggConstant,
1814 LLVMValueRef ElementValueConstant,
1815 unsigned *IdxList, unsigned NumIdx);
Chris Lattner25963c62010-01-09 22:27:07 +00001816LLVMValueRef LLVMConstInlineAsm(LLVMTypeRef Ty,
Chris Lattner3d1f5522008-12-17 21:39:50 +00001817 const char *AsmString, const char *Constraints,
Chris Lattner25963c62010-01-09 22:27:07 +00001818 LLVMBool HasSideEffects, LLVMBool IsAlignStack);
Erick Tryzelaar0fb26ef2010-02-28 09:46:06 +00001819LLVMValueRef LLVMBlockAddress(LLVMValueRef F, LLVMBasicBlockRef BB);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001820
Gregory Szorc52d26602012-03-21 07:28:27 +00001821/**
1822 * @}
1823 */
1824
1825/**
1826 * @defgroup LLVMCCoreValueConstantGlobals Global Values
1827 *
1828 * This group contains functions that operate on global values. Functions in
1829 * this group relate to functions in the llvm::GlobalValue class tree.
1830 *
1831 * @see llvm::GlobalValue
1832 *
1833 * @{
1834 */
1835
Gordon Henriksen265f7802008-03-19 01:11:35 +00001836LLVMModuleRef LLVMGetGlobalParent(LLVMValueRef Global);
Chris Lattner25963c62010-01-09 22:27:07 +00001837LLVMBool LLVMIsDeclaration(LLVMValueRef Global);
Gordon Henriksen76a03742007-09-18 03:18:57 +00001838LLVMLinkage LLVMGetLinkage(LLVMValueRef Global);
1839void LLVMSetLinkage(LLVMValueRef Global, LLVMLinkage Linkage);
1840const char *LLVMGetSection(LLVMValueRef Global);
1841void LLVMSetSection(LLVMValueRef Global, const char *Section);
1842LLVMVisibility LLVMGetVisibility(LLVMValueRef Global);
1843void LLVMSetVisibility(LLVMValueRef Global, LLVMVisibility Viz);
Reid Kleckner2fae26f2014-03-05 02:34:23 +00001844LLVMDLLStorageClass LLVMGetDLLStorageClass(LLVMValueRef Global);
1845void LLVMSetDLLStorageClass(LLVMValueRef Global, LLVMDLLStorageClass Class);
Tim Northoverad96d012014-03-10 19:24:35 +00001846LLVMBool LLVMHasUnnamedAddr(LLVMValueRef Global);
1847void LLVMSetUnnamedAddr(LLVMValueRef Global, LLVMBool HasUnnamedAddr);
Anders Waldenborg213a63f2013-10-29 09:02:02 +00001848
1849/**
1850 * @defgroup LLVMCCoreValueWithAlignment Values with alignment
1851 *
1852 * Functions in this group only apply to values with alignment, i.e.
1853 * global variables, load and store instructions.
1854 */
1855
1856/**
1857 * Obtain the preferred alignment of the value.
Peter Zotov9f584e62014-03-05 05:05:34 +00001858 * @see llvm::AllocaInst::getAlignment()
Anders Waldenborg213a63f2013-10-29 09:02:02 +00001859 * @see llvm::LoadInst::getAlignment()
1860 * @see llvm::StoreInst::getAlignment()
1861 * @see llvm::GlobalValue::getAlignment()
1862 */
1863unsigned LLVMGetAlignment(LLVMValueRef V);
1864
1865/**
1866 * Set the preferred alignment of the value.
Peter Zotov9f584e62014-03-05 05:05:34 +00001867 * @see llvm::AllocaInst::setAlignment()
Anders Waldenborg213a63f2013-10-29 09:02:02 +00001868 * @see llvm::LoadInst::setAlignment()
1869 * @see llvm::StoreInst::setAlignment()
1870 * @see llvm::GlobalValue::setAlignment()
1871 */
1872void LLVMSetAlignment(LLVMValueRef V, unsigned Bytes);
1873
1874/**
Amaury Sechet83550102016-02-14 08:58:49 +00001875 * @}
1876 */
Gordon Henriksen76a03742007-09-18 03:18:57 +00001877
Gregory Szorc52d26602012-03-21 07:28:27 +00001878/**
1879 * @defgroup LLVMCoreValueConstantGlobalVariable Global Variables
1880 *
1881 * This group contains functions that operate on global variable values.
1882 *
1883 * @see llvm::GlobalVariable
1884 *
1885 * @{
1886 */
Gordon Henriksen76a03742007-09-18 03:18:57 +00001887LLVMValueRef LLVMAddGlobal(LLVMModuleRef M, LLVMTypeRef Ty, const char *Name);
Erick Tryzelaar06894b32010-02-28 09:46:13 +00001888LLVMValueRef LLVMAddGlobalInAddressSpace(LLVMModuleRef M, LLVMTypeRef Ty,
1889 const char *Name,
1890 unsigned AddressSpace);
Gordon Henriksen783f7bb2007-10-08 03:45:09 +00001891LLVMValueRef LLVMGetNamedGlobal(LLVMModuleRef M, const char *Name);
Gordon Henriksen07a45f42008-03-23 22:21:29 +00001892LLVMValueRef LLVMGetFirstGlobal(LLVMModuleRef M);
1893LLVMValueRef LLVMGetLastGlobal(LLVMModuleRef M);
1894LLVMValueRef LLVMGetNextGlobal(LLVMValueRef GlobalVar);
1895LLVMValueRef LLVMGetPreviousGlobal(LLVMValueRef GlobalVar);
Gordon Henriksen76a03742007-09-18 03:18:57 +00001896void LLVMDeleteGlobal(LLVMValueRef GlobalVar);
Gordon Henriksen76a03742007-09-18 03:18:57 +00001897LLVMValueRef LLVMGetInitializer(LLVMValueRef GlobalVar);
1898void LLVMSetInitializer(LLVMValueRef GlobalVar, LLVMValueRef ConstantVal);
Chris Lattner25963c62010-01-09 22:27:07 +00001899LLVMBool LLVMIsThreadLocal(LLVMValueRef GlobalVar);
1900void LLVMSetThreadLocal(LLVMValueRef GlobalVar, LLVMBool IsThreadLocal);
1901LLVMBool LLVMIsGlobalConstant(LLVMValueRef GlobalVar);
1902void LLVMSetGlobalConstant(LLVMValueRef GlobalVar, LLVMBool IsConstant);
Hans Wennborg5ff71202013-04-16 08:58:59 +00001903LLVMThreadLocalMode LLVMGetThreadLocalMode(LLVMValueRef GlobalVar);
1904void LLVMSetThreadLocalMode(LLVMValueRef GlobalVar, LLVMThreadLocalMode Mode);
1905LLVMBool LLVMIsExternallyInitialized(LLVMValueRef GlobalVar);
1906void LLVMSetExternallyInitialized(LLVMValueRef GlobalVar, LLVMBool IsExtInit);
Gordon Henriksen76a03742007-09-18 03:18:57 +00001907
Gregory Szorc52d26602012-03-21 07:28:27 +00001908/**
1909 * @}
1910 */
1911
1912/**
1913 * @defgroup LLVMCoreValueConstantGlobalAlias Global Aliases
1914 *
1915 * This group contains function that operate on global alias values.
1916 *
1917 * @see llvm::GlobalAlias
1918 *
1919 * @{
1920 */
Chris Lattner3d1f5522008-12-17 21:39:50 +00001921LLVMValueRef LLVMAddAlias(LLVMModuleRef M, LLVMTypeRef Ty, LLVMValueRef Aliasee,
1922 const char *Name);
1923
Gregory Szorc34c863a2012-03-21 03:54:29 +00001924/**
1925 * @}
1926 */
1927
1928/**
1929 * @defgroup LLVMCCoreValueFunction Function values
1930 *
1931 * Functions in this group operate on LLVMValueRef instances that
1932 * correspond to llvm::Function instances.
1933 *
1934 * @see llvm::Function
1935 *
1936 * @{
1937 */
1938
1939/**
1940 * Remove a function from its containing module and deletes it.
1941 *
1942 * @see llvm::Function::eraseFromParent()
1943 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00001944void LLVMDeleteFunction(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001945
1946/**
Amaury Sechete39e8532016-02-18 20:38:32 +00001947 * Check whether the given function has a personality function.
1948 *
1949 * @see llvm::Function::hasPersonalityFn()
1950 */
1951LLVMBool LLVMHasPersonalityFn(LLVMValueRef Fn);
1952
1953/**
Andrew Wilkins3bdfc1c2015-07-14 01:23:06 +00001954 * Obtain the personality function attached to the function.
1955 *
1956 * @see llvm::Function::getPersonalityFn()
1957 */
1958LLVMValueRef LLVMGetPersonalityFn(LLVMValueRef Fn);
1959
1960/**
1961 * Set the personality function attached to the function.
1962 *
1963 * @see llvm::Function::setPersonalityFn()
1964 */
1965void LLVMSetPersonalityFn(LLVMValueRef Fn, LLVMValueRef PersonalityFn);
1966
1967/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00001968 * Obtain the ID number from a function instance.
1969 *
1970 * @see llvm::Function::getIntrinsicID()
1971 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00001972unsigned LLVMGetIntrinsicID(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001973
1974/**
1975 * Obtain the calling function of a function.
1976 *
1977 * The returned value corresponds to the LLVMCallConv enumeration.
1978 *
1979 * @see llvm::Function::getCallingConv()
1980 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00001981unsigned LLVMGetFunctionCallConv(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001982
1983/**
1984 * Set the calling convention of a function.
1985 *
1986 * @see llvm::Function::setCallingConv()
1987 *
1988 * @param Fn Function to operate on
1989 * @param CC LLVMCallConv to set calling convention to
1990 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00001991void LLVMSetFunctionCallConv(LLVMValueRef Fn, unsigned CC);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001992
1993/**
1994 * Obtain the name of the garbage collector to use during code
1995 * generation.
1996 *
1997 * @see llvm::Function::getGC()
1998 */
Gordon Henriksend930f912008-08-17 18:44:35 +00001999const char *LLVMGetGC(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002000
2001/**
2002 * Define the garbage collector to use during code generation.
2003 *
2004 * @see llvm::Function::setGC()
2005 */
Gordon Henriksend930f912008-08-17 18:44:35 +00002006void LLVMSetGC(LLVMValueRef Fn, const char *Name);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002007
2008/**
2009 * Add an attribute to a function.
2010 *
2011 * @see llvm::Function::addAttribute()
2012 */
Duncan Sands7374a012009-05-06 12:21:17 +00002013void LLVMAddFunctionAttr(LLVMValueRef Fn, LLVMAttribute PA);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002014
Amaury Sechet5db224e2016-06-12 06:17:24 +00002015void LLVMAddAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx,
2016 LLVMAttributeRef A);
Amaury Sechet17b67cd2016-07-21 04:25:06 +00002017unsigned LLVMGetAttributeCountAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx);
2018void LLVMGetAttributesAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx,
2019 LLVMAttributeRef *Attrs);
Amaury Sechet5db224e2016-06-12 06:17:24 +00002020LLVMAttributeRef LLVMGetEnumAttributeAtIndex(LLVMValueRef F,
2021 LLVMAttributeIndex Idx,
2022 unsigned KindID);
Amaury Sechet6100adf2016-06-15 17:50:39 +00002023LLVMAttributeRef LLVMGetStringAttributeAtIndex(LLVMValueRef F,
2024 LLVMAttributeIndex Idx,
2025 const char *K, unsigned KLen);
Amaury Sechet5db224e2016-06-12 06:17:24 +00002026void LLVMRemoveEnumAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx,
2027 unsigned KindID);
Amaury Sechet6100adf2016-06-15 17:50:39 +00002028void LLVMRemoveStringAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx,
2029 const char *K, unsigned KLen);
Amaury Sechet5db224e2016-06-12 06:17:24 +00002030
Gregory Szorc34c863a2012-03-21 03:54:29 +00002031/**
Nick Lewyckyc3890d22015-07-29 22:32:47 +00002032 * Add a target-dependent attribute to a function
Tom Stellarde8f35e12013-04-16 23:12:43 +00002033 * @see llvm::AttrBuilder::addAttribute()
2034 */
2035void LLVMAddTargetDependentFunctionAttr(LLVMValueRef Fn, const char *A,
2036 const char *V);
2037
2038/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002039 * Obtain an attribute from a function.
2040 *
2041 * @see llvm::Function::getAttributes()
2042 */
Chris Lattner40cf28d2009-10-12 04:01:02 +00002043LLVMAttribute LLVMGetFunctionAttr(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002044
2045/**
2046 * Remove an attribute from a function.
2047 */
Duncan Sands7374a012009-05-06 12:21:17 +00002048void LLVMRemoveFunctionAttr(LLVMValueRef Fn, LLVMAttribute PA);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002049
Gregory Szorc34c863a2012-03-21 03:54:29 +00002050/**
2051 * @defgroup LLVMCCoreValueFunctionParameters Function Parameters
2052 *
2053 * Functions in this group relate to arguments/parameters on functions.
2054 *
2055 * Functions in this group expect LLVMValueRef instances that correspond
2056 * to llvm::Function instances.
2057 *
2058 * @{
2059 */
2060
2061/**
2062 * Obtain the number of parameters in a function.
2063 *
2064 * @see llvm::Function::arg_size()
2065 */
Gordon Henriksen265f7802008-03-19 01:11:35 +00002066unsigned LLVMCountParams(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002067
2068/**
2069 * Obtain the parameters in a function.
2070 *
2071 * The takes a pointer to a pre-allocated array of LLVMValueRef that is
2072 * at least LLVMCountParams() long. This array will be filled with
2073 * LLVMValueRef instances which correspond to the parameters the
2074 * function receives. Each LLVMValueRef corresponds to a llvm::Argument
2075 * instance.
2076 *
2077 * @see llvm::Function::arg_begin()
2078 */
Gordon Henriksen265f7802008-03-19 01:11:35 +00002079void LLVMGetParams(LLVMValueRef Fn, LLVMValueRef *Params);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002080
2081/**
2082 * Obtain the parameter at the specified index.
2083 *
2084 * Parameters are indexed from 0.
2085 *
2086 * @see llvm::Function::arg_begin()
2087 */
Gordon Henriksen265f7802008-03-19 01:11:35 +00002088LLVMValueRef LLVMGetParam(LLVMValueRef Fn, unsigned Index);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002089
2090/**
2091 * Obtain the function to which this argument belongs.
2092 *
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00002093 * Unlike other functions in this group, this one takes an LLVMValueRef
Gregory Szorc34c863a2012-03-21 03:54:29 +00002094 * that corresponds to a llvm::Attribute.
2095 *
2096 * The returned LLVMValueRef is the llvm::Function to which this
2097 * argument belongs.
2098 */
Gordon Henriksen265f7802008-03-19 01:11:35 +00002099LLVMValueRef LLVMGetParamParent(LLVMValueRef Inst);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002100
2101/**
2102 * Obtain the first parameter to a function.
2103 *
2104 * @see llvm::Function::arg_begin()
2105 */
Gordon Henriksen07a45f42008-03-23 22:21:29 +00002106LLVMValueRef LLVMGetFirstParam(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002107
2108/**
2109 * Obtain the last parameter to a function.
2110 *
2111 * @see llvm::Function::arg_end()
2112 */
Gordon Henriksen07a45f42008-03-23 22:21:29 +00002113LLVMValueRef LLVMGetLastParam(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002114
2115/**
2116 * Obtain the next parameter to a function.
2117 *
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00002118 * This takes an LLVMValueRef obtained from LLVMGetFirstParam() (which is
Gregory Szorc34c863a2012-03-21 03:54:29 +00002119 * actually a wrapped iterator) and obtains the next parameter from the
2120 * underlying iterator.
2121 */
Gordon Henriksen07a45f42008-03-23 22:21:29 +00002122LLVMValueRef LLVMGetNextParam(LLVMValueRef Arg);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002123
2124/**
2125 * Obtain the previous parameter to a function.
2126 *
2127 * This is the opposite of LLVMGetNextParam().
2128 */
Gordon Henriksen07a45f42008-03-23 22:21:29 +00002129LLVMValueRef LLVMGetPreviousParam(LLVMValueRef Arg);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002130
2131/**
2132 * Add an attribute to a function argument.
2133 *
2134 * @see llvm::Argument::addAttr()
2135 */
Devang Patel4c758ea2008-09-25 21:00:45 +00002136void LLVMAddAttribute(LLVMValueRef Arg, LLVMAttribute PA);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002137
2138/**
2139 * Remove an attribute from a function argument.
2140 *
2141 * @see llvm::Argument::removeAttr()
2142 */
Devang Patel4c758ea2008-09-25 21:00:45 +00002143void LLVMRemoveAttribute(LLVMValueRef Arg, LLVMAttribute PA);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002144
2145/**
2146 * Get an attribute from a function argument.
2147 */
Chris Lattner40cf28d2009-10-12 04:01:02 +00002148LLVMAttribute LLVMGetAttribute(LLVMValueRef Arg);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002149
2150/**
2151 * Set the alignment for a function parameter.
2152 *
2153 * @see llvm::Argument::addAttr()
Bill Wendling50d27842012-10-15 20:35:56 +00002154 * @see llvm::AttrBuilder::addAlignmentAttr()
Gregory Szorc34c863a2012-03-21 03:54:29 +00002155 */
Amaury Sechet81243a72016-05-01 01:42:34 +00002156void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned Align);
Gordon Henriksen265f7802008-03-19 01:11:35 +00002157
Gregory Szorc34c863a2012-03-21 03:54:29 +00002158/**
2159 * @}
2160 */
2161
2162/**
2163 * @}
2164 */
2165
2166/**
Gregory Szorc52d26602012-03-21 07:28:27 +00002167 * @}
2168 */
2169
2170/**
2171 * @}
2172 */
2173
2174/**
2175 * @defgroup LLVMCCoreValueMetadata Metadata
2176 *
2177 * @{
2178 */
2179
2180/**
2181 * Obtain a MDString value from a context.
2182 *
2183 * The returned instance corresponds to the llvm::MDString class.
2184 *
2185 * The instance is specified by string data of a specified length. The
2186 * string content is copied, so the backing memory can be freed after
2187 * this function returns.
2188 */
2189LLVMValueRef LLVMMDStringInContext(LLVMContextRef C, const char *Str,
2190 unsigned SLen);
2191
2192/**
2193 * Obtain a MDString value from the global context.
2194 */
2195LLVMValueRef LLVMMDString(const char *Str, unsigned SLen);
2196
2197/**
2198 * Obtain a MDNode value from a context.
2199 *
2200 * The returned value corresponds to the llvm::MDNode class.
2201 */
2202LLVMValueRef LLVMMDNodeInContext(LLVMContextRef C, LLVMValueRef *Vals,
2203 unsigned Count);
2204
2205/**
2206 * Obtain a MDNode value from the global context.
2207 */
2208LLVMValueRef LLVMMDNode(LLVMValueRef *Vals, unsigned Count);
2209
2210/**
2211 * Obtain the underlying string from a MDString value.
2212 *
2213 * @param V Instance to obtain string from.
NAKAMURA Takumie4a77052016-04-04 11:54:48 +00002214 * @param Length Memory address which will hold length of returned string.
Gregory Szorc52d26602012-03-21 07:28:27 +00002215 * @return String data in MDString.
2216 */
Amaury Sechet7c2883c2016-04-03 21:06:04 +00002217const char *LLVMGetMDString(LLVMValueRef V, unsigned *Length);
Gregory Szorc52d26602012-03-21 07:28:27 +00002218
2219/**
Duncan Sands12ccbe72012-09-19 20:29:39 +00002220 * Obtain the number of operands from an MDNode value.
2221 *
2222 * @param V MDNode to get number of operands from.
2223 * @return Number of operands of the MDNode.
2224 */
2225unsigned LLVMGetMDNodeNumOperands(LLVMValueRef V);
2226
2227/**
2228 * Obtain the given MDNode's operands.
2229 *
2230 * The passed LLVMValueRef pointer should point to enough memory to hold all of
2231 * the operands of the given MDNode (see LLVMGetMDNodeNumOperands) as
2232 * LLVMValueRefs. This memory will be populated with the LLVMValueRefs of the
2233 * MDNode's operands.
2234 *
2235 * @param V MDNode to get the operands from.
2236 * @param Dest Destination array for operands.
2237 */
2238void LLVMGetMDNodeOperands(LLVMValueRef V, LLVMValueRef *Dest);
2239
2240/**
Gregory Szorc52d26602012-03-21 07:28:27 +00002241 * @}
2242 */
2243
2244/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002245 * @defgroup LLVMCCoreValueBasicBlock Basic Block
2246 *
2247 * A basic block represents a single entry single exit section of code.
2248 * Basic blocks contain a list of instructions which form the body of
2249 * the block.
2250 *
2251 * Basic blocks belong to functions. They have the type of label.
2252 *
2253 * Basic blocks are themselves values. However, the C API models them as
2254 * LLVMBasicBlockRef.
2255 *
2256 * @see llvm::BasicBlock
2257 *
2258 * @{
2259 */
2260
2261/**
2262 * Convert a basic block instance to a value type.
2263 */
Gordon Henriksen07a45f42008-03-23 22:21:29 +00002264LLVMValueRef LLVMBasicBlockAsValue(LLVMBasicBlockRef BB);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002265
2266/**
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00002267 * Determine whether an LLVMValueRef is itself a basic block.
Gregory Szorc34c863a2012-03-21 03:54:29 +00002268 */
Chris Lattner25963c62010-01-09 22:27:07 +00002269LLVMBool LLVMValueIsBasicBlock(LLVMValueRef Val);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002270
2271/**
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00002272 * Convert an LLVMValueRef to an LLVMBasicBlockRef instance.
Gregory Szorc34c863a2012-03-21 03:54:29 +00002273 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002274LLVMBasicBlockRef LLVMValueAsBasicBlock(LLVMValueRef Val);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002275
2276/**
Amaury Secheta82042e2016-02-09 22:36:41 +00002277 * Obtain the string name of a basic block.
2278 */
2279const char *LLVMGetBasicBlockName(LLVMBasicBlockRef BB);
2280
2281/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002282 * Obtain the function to which a basic block belongs.
2283 *
2284 * @see llvm::BasicBlock::getParent()
2285 */
Gordon Henriksen07a45f42008-03-23 22:21:29 +00002286LLVMValueRef LLVMGetBasicBlockParent(LLVMBasicBlockRef BB);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002287
2288/**
2289 * Obtain the terminator instruction for a basic block.
2290 *
2291 * If the basic block does not have a terminator (it is not well-formed
2292 * if it doesn't), then NULL is returned.
2293 *
2294 * The returned LLVMValueRef corresponds to a llvm::TerminatorInst.
2295 *
2296 * @see llvm::BasicBlock::getTerminator()
2297 */
Nate Begeman43c322b2011-08-23 20:27:46 +00002298LLVMValueRef LLVMGetBasicBlockTerminator(LLVMBasicBlockRef BB);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002299
2300/**
2301 * Obtain the number of basic blocks in a function.
2302 *
2303 * @param Fn Function value to operate on.
2304 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002305unsigned LLVMCountBasicBlocks(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002306
2307/**
2308 * Obtain all of the basic blocks in a function.
2309 *
2310 * This operates on a function value. The BasicBlocks parameter is a
2311 * pointer to a pre-allocated array of LLVMBasicBlockRef of at least
2312 * LLVMCountBasicBlocks() in length. This array is populated with
2313 * LLVMBasicBlockRef instances.
2314 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002315void LLVMGetBasicBlocks(LLVMValueRef Fn, LLVMBasicBlockRef *BasicBlocks);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002316
2317/**
2318 * Obtain the first basic block in a function.
2319 *
2320 * The returned basic block can be used as an iterator. You will likely
2321 * eventually call into LLVMGetNextBasicBlock() with it.
2322 *
2323 * @see llvm::Function::begin()
2324 */
Gordon Henriksen054817c2008-03-19 03:47:18 +00002325LLVMBasicBlockRef LLVMGetFirstBasicBlock(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002326
2327/**
2328 * Obtain the last basic block in a function.
2329 *
2330 * @see llvm::Function::end()
2331 */
Gordon Henriksen054817c2008-03-19 03:47:18 +00002332LLVMBasicBlockRef LLVMGetLastBasicBlock(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002333
2334/**
2335 * Advance a basic block iterator.
2336 */
Gordon Henriksen054817c2008-03-19 03:47:18 +00002337LLVMBasicBlockRef LLVMGetNextBasicBlock(LLVMBasicBlockRef BB);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002338
2339/**
2340 * Go backwards in a basic block iterator.
2341 */
Gordon Henriksen054817c2008-03-19 03:47:18 +00002342LLVMBasicBlockRef LLVMGetPreviousBasicBlock(LLVMBasicBlockRef BB);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002343
2344/**
2345 * Obtain the basic block that corresponds to the entry point of a
2346 * function.
2347 *
2348 * @see llvm::Function::getEntryBlock()
2349 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002350LLVMBasicBlockRef LLVMGetEntryBasicBlock(LLVMValueRef Fn);
Erick Tryzelaar262332f2009-08-14 00:01:31 +00002351
Gregory Szorc34c863a2012-03-21 03:54:29 +00002352/**
2353 * Append a basic block to the end of a function.
2354 *
2355 * @see llvm::BasicBlock::Create()
2356 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +00002357LLVMBasicBlockRef LLVMAppendBasicBlockInContext(LLVMContextRef C,
2358 LLVMValueRef Fn,
2359 const char *Name);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002360
2361/**
2362 * Append a basic block to the end of a function using the global
2363 * context.
2364 *
2365 * @see llvm::BasicBlock::Create()
2366 */
2367LLVMBasicBlockRef LLVMAppendBasicBlock(LLVMValueRef Fn, const char *Name);
2368
2369/**
2370 * Insert a basic block in a function before another basic block.
2371 *
2372 * The function to add to is determined by the function of the
2373 * passed basic block.
2374 *
2375 * @see llvm::BasicBlock::Create()
2376 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +00002377LLVMBasicBlockRef LLVMInsertBasicBlockInContext(LLVMContextRef C,
2378 LLVMBasicBlockRef BB,
2379 const char *Name);
2380
Gregory Szorc34c863a2012-03-21 03:54:29 +00002381/**
2382 * Insert a basic block in a function using the global context.
2383 *
2384 * @see llvm::BasicBlock::Create()
2385 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002386LLVMBasicBlockRef LLVMInsertBasicBlock(LLVMBasicBlockRef InsertBeforeBB,
2387 const char *Name);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002388
2389/**
2390 * Remove a basic block from a function and delete it.
2391 *
2392 * This deletes the basic block from its containing function and deletes
2393 * the basic block itself.
2394 *
2395 * @see llvm::BasicBlock::eraseFromParent()
2396 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002397void LLVMDeleteBasicBlock(LLVMBasicBlockRef BB);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002398
2399/**
2400 * Remove a basic block from a function.
2401 *
2402 * This deletes the basic block from its containing function but keep
2403 * the basic block alive.
2404 *
2405 * @see llvm::BasicBlock::removeFromParent()
2406 */
Nate Begeman43c322b2011-08-23 20:27:46 +00002407void LLVMRemoveBasicBlockFromParent(LLVMBasicBlockRef BB);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002408
Gregory Szorc34c863a2012-03-21 03:54:29 +00002409/**
2410 * Move a basic block to before another one.
2411 *
2412 * @see llvm::BasicBlock::moveBefore()
2413 */
Duncan Sandsb1d61aa2010-07-19 15:31:07 +00002414void LLVMMoveBasicBlockBefore(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002415
2416/**
2417 * Move a basic block to after another one.
2418 *
2419 * @see llvm::BasicBlock::moveAfter()
2420 */
Duncan Sandsb1d61aa2010-07-19 15:31:07 +00002421void LLVMMoveBasicBlockAfter(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos);
2422
Gregory Szorc34c863a2012-03-21 03:54:29 +00002423/**
2424 * Obtain the first instruction in a basic block.
2425 *
2426 * The returned LLVMValueRef corresponds to a llvm::Instruction
2427 * instance.
2428 */
Gordon Henriksen054817c2008-03-19 03:47:18 +00002429LLVMValueRef LLVMGetFirstInstruction(LLVMBasicBlockRef BB);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002430
2431/**
2432 * Obtain the last instruction in a basic block.
2433 *
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00002434 * The returned LLVMValueRef corresponds to an LLVM:Instruction.
Gregory Szorc34c863a2012-03-21 03:54:29 +00002435 */
Gordon Henriksen054817c2008-03-19 03:47:18 +00002436LLVMValueRef LLVMGetLastInstruction(LLVMBasicBlockRef BB);
Nate Begeman43c322b2011-08-23 20:27:46 +00002437
Gregory Szorc34c863a2012-03-21 03:54:29 +00002438/**
2439 * @}
2440 */
2441
2442/**
2443 * @defgroup LLVMCCoreValueInstruction Instructions
2444 *
2445 * Functions in this group relate to the inspection and manipulation of
2446 * individual instructions.
2447 *
2448 * In the C++ API, an instruction is modeled by llvm::Instruction. This
2449 * class has a large number of descendents. llvm::Instruction is a
2450 * llvm::Value and in the C API, instructions are modeled by
2451 * LLVMValueRef.
2452 *
2453 * This group also contains sub-groups which operate on specific
2454 * llvm::Instruction types, e.g. llvm::CallInst.
2455 *
2456 * @{
2457 */
2458
2459/**
2460 * Determine whether an instruction has any metadata attached.
2461 */
2462int LLVMHasMetadata(LLVMValueRef Val);
2463
2464/**
2465 * Return metadata associated with an instruction value.
2466 */
2467LLVMValueRef LLVMGetMetadata(LLVMValueRef Val, unsigned KindID);
2468
2469/**
2470 * Set metadata associated with an instruction value.
2471 */
2472void LLVMSetMetadata(LLVMValueRef Val, unsigned KindID, LLVMValueRef Node);
2473
2474/**
2475 * Obtain the basic block to which an instruction belongs.
2476 *
2477 * @see llvm::Instruction::getParent()
2478 */
Nate Begeman43c322b2011-08-23 20:27:46 +00002479LLVMBasicBlockRef LLVMGetInstructionParent(LLVMValueRef Inst);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002480
2481/**
2482 * Obtain the instruction that occurs after the one specified.
2483 *
2484 * The next instruction will be from the same basic block.
2485 *
2486 * If this is the last instruction in a basic block, NULL will be
2487 * returned.
2488 */
Gordon Henriksen054817c2008-03-19 03:47:18 +00002489LLVMValueRef LLVMGetNextInstruction(LLVMValueRef Inst);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002490
2491/**
Benjamin Kramerbde91762012-06-02 10:20:22 +00002492 * Obtain the instruction that occurred before this one.
Gregory Szorc34c863a2012-03-21 03:54:29 +00002493 *
2494 * If the instruction is the first instruction in a basic block, NULL
2495 * will be returned.
2496 */
Gordon Henriksen054817c2008-03-19 03:47:18 +00002497LLVMValueRef LLVMGetPreviousInstruction(LLVMValueRef Inst);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002498
2499/**
2500 * Remove and delete an instruction.
2501 *
2502 * The instruction specified is removed from its containing building
Amaury Sechet2f432082016-02-11 21:37:54 +00002503 * block but is kept alive.
2504 *
2505 * @see llvm::Instruction::removeFromParent()
2506 */
2507void LLVMInstructionRemoveFromParent(LLVMValueRef Inst);
2508
2509/**
2510 * Remove and delete an instruction.
2511 *
2512 * The instruction specified is removed from its containing building
Gregory Szorc34c863a2012-03-21 03:54:29 +00002513 * block and then deleted.
2514 *
2515 * @see llvm::Instruction::eraseFromParent()
2516 */
Devang Pateldbebc6f2011-10-03 20:59:18 +00002517void LLVMInstructionEraseFromParent(LLVMValueRef Inst);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002518
2519/**
2520 * Obtain the code opcode for an individual instruction.
2521 *
2522 * @see llvm::Instruction::getOpCode()
2523 */
Eric Christophera6b96002015-12-18 01:46:52 +00002524LLVMOpcode LLVMGetInstructionOpcode(LLVMValueRef Inst);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002525
2526/**
2527 * Obtain the predicate of an instruction.
2528 *
2529 * This is only valid for instructions that correspond to llvm::ICmpInst
2530 * or llvm::ConstantExpr whose opcode is llvm::Instruction::ICmp.
2531 *
2532 * @see llvm::ICmpInst::getPredicate()
2533 */
Torok Edwin60c40de2011-10-06 12:13:20 +00002534LLVMIntPredicate LLVMGetICmpPredicate(LLVMValueRef Inst);
Gordon Henriksen265f7802008-03-19 01:11:35 +00002535
Gregory Szorc34c863a2012-03-21 03:54:29 +00002536/**
Peter Zotov1d98e6d2014-10-28 19:46:44 +00002537 * Obtain the float predicate of an instruction.
2538 *
2539 * This is only valid for instructions that correspond to llvm::FCmpInst
2540 * or llvm::ConstantExpr whose opcode is llvm::Instruction::FCmp.
2541 *
2542 * @see llvm::FCmpInst::getPredicate()
2543 */
2544LLVMRealPredicate LLVMGetFCmpPredicate(LLVMValueRef Inst);
2545
2546/**
Peter Zotovaff492c2014-10-17 01:02:34 +00002547 * Create a copy of 'this' instruction that is identical in all ways
2548 * except the following:
2549 * * The instruction has no parent
2550 * * The instruction has no name
2551 *
2552 * @see llvm::Instruction::clone()
2553 */
2554LLVMValueRef LLVMInstructionClone(LLVMValueRef Inst);
2555
2556/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002557 * @defgroup LLVMCCoreValueInstructionCall Call Sites and Invocations
2558 *
2559 * Functions in this group apply to instructions that refer to call
2560 * sites and invocations. These correspond to C++ types in the
2561 * llvm::CallInst class tree.
2562 *
2563 * @{
2564 */
2565
2566/**
Amaury Sechet5c7b3af2016-02-10 00:09:37 +00002567 * Obtain the argument count for a call instruction.
2568 *
2569 * This expects an LLVMValueRef that corresponds to a llvm::CallInst or
2570 * llvm::InvokeInst.
2571 *
2572 * @see llvm::CallInst::getNumArgOperands()
2573 * @see llvm::InvokeInst::getNumArgOperands()
2574 */
2575unsigned LLVMGetNumArgOperands(LLVMValueRef Instr);
2576
2577/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002578 * Set the calling convention for a call instruction.
2579 *
2580 * This expects an LLVMValueRef that corresponds to a llvm::CallInst or
2581 * llvm::InvokeInst.
2582 *
2583 * @see llvm::CallInst::setCallingConv()
2584 * @see llvm::InvokeInst::setCallingConv()
2585 */
Gordon Henriksen1158c532007-12-29 20:45:00 +00002586void LLVMSetInstructionCallConv(LLVMValueRef Instr, unsigned CC);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002587
2588/**
2589 * Obtain the calling convention for a call instruction.
2590 *
2591 * This is the opposite of LLVMSetInstructionCallConv(). Reads its
2592 * usage.
2593 *
2594 * @see LLVMSetInstructionCallConv()
2595 */
Gordon Henriksen1158c532007-12-29 20:45:00 +00002596unsigned LLVMGetInstructionCallConv(LLVMValueRef Instr);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002597
Devang Patel4c758ea2008-09-25 21:00:45 +00002598void LLVMAddInstrAttribute(LLVMValueRef Instr, unsigned index, LLVMAttribute);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002599void LLVMRemoveInstrAttribute(LLVMValueRef Instr, unsigned index,
Devang Patel4c758ea2008-09-25 21:00:45 +00002600 LLVMAttribute);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002601void LLVMSetInstrParamAlignment(LLVMValueRef Instr, unsigned index,
Amaury Sechet81243a72016-05-01 01:42:34 +00002602 unsigned Align);
Gordon Henriksen1158c532007-12-29 20:45:00 +00002603
Amaury Secheta65a2372016-06-15 05:14:29 +00002604void LLVMAddCallSiteAttribute(LLVMValueRef C, LLVMAttributeIndex Idx,
2605 LLVMAttributeRef A);
Amaury Sechet17b67cd2016-07-21 04:25:06 +00002606unsigned LLVMGetCallSiteAttributeCount(LLVMValueRef C, LLVMAttributeIndex Idx);
2607void LLVMGetCallSiteAttributes(LLVMValueRef C, LLVMAttributeIndex Idx,
2608 LLVMAttributeRef *Attrs);
Amaury Secheta65a2372016-06-15 05:14:29 +00002609LLVMAttributeRef LLVMGetCallSiteEnumAttribute(LLVMValueRef C,
2610 LLVMAttributeIndex Idx,
2611 unsigned KindID);
Amaury Sechet6100adf2016-06-15 17:50:39 +00002612LLVMAttributeRef LLVMGetCallSiteStringAttribute(LLVMValueRef C,
2613 LLVMAttributeIndex Idx,
2614 const char *K, unsigned KLen);
Amaury Secheta65a2372016-06-15 05:14:29 +00002615void LLVMRemoveCallSiteEnumAttribute(LLVMValueRef C, LLVMAttributeIndex Idx,
2616 unsigned KindID);
Amaury Sechet6100adf2016-06-15 17:50:39 +00002617void LLVMRemoveCallSiteStringAttribute(LLVMValueRef C, LLVMAttributeIndex Idx,
2618 const char *K, unsigned KLen);
Amaury Secheta65a2372016-06-15 05:14:29 +00002619
Gregory Szorc34c863a2012-03-21 03:54:29 +00002620/**
Amaury Sechet5c7b3af2016-02-10 00:09:37 +00002621 * Obtain the pointer to the function invoked by this instruction.
2622 *
2623 * This expects an LLVMValueRef that corresponds to a llvm::CallInst or
2624 * llvm::InvokeInst.
2625 *
2626 * @see llvm::CallInst::getCalledValue()
2627 * @see llvm::InvokeInst::getCalledValue()
2628 */
2629LLVMValueRef LLVMGetCalledValue(LLVMValueRef Instr);
2630
2631/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002632 * Obtain whether a call instruction is a tail call.
2633 *
2634 * This only works on llvm::CallInst instructions.
2635 *
2636 * @see llvm::CallInst::isTailCall()
2637 */
Chris Lattner25963c62010-01-09 22:27:07 +00002638LLVMBool LLVMIsTailCall(LLVMValueRef CallInst);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002639
2640/**
2641 * Set whether a call instruction is a tail call.
2642 *
2643 * This only works on llvm::CallInst instructions.
2644 *
2645 * @see llvm::CallInst::setTailCall()
2646 */
Chris Lattner25963c62010-01-09 22:27:07 +00002647void LLVMSetTailCall(LLVMValueRef CallInst, LLVMBool IsTailCall);
Gordon Henrikseneeb65372008-08-30 16:34:54 +00002648
Gregory Szorc34c863a2012-03-21 03:54:29 +00002649/**
Amaury Sechete39e8532016-02-18 20:38:32 +00002650 * Return the normal destination basic block.
2651 *
2652 * This only works on llvm::InvokeInst instructions.
2653 *
2654 * @see llvm::InvokeInst::getNormalDest()
2655 */
2656LLVMBasicBlockRef LLVMGetNormalDest(LLVMValueRef InvokeInst);
2657
2658/**
2659 * Return the unwind destination basic block.
2660 *
2661 * This only works on llvm::InvokeInst instructions.
2662 *
2663 * @see llvm::InvokeInst::getUnwindDest()
2664 */
2665LLVMBasicBlockRef LLVMGetUnwindDest(LLVMValueRef InvokeInst);
2666
2667/**
2668 * Set the normal destination basic block.
2669 *
2670 * This only works on llvm::InvokeInst instructions.
2671 *
2672 * @see llvm::InvokeInst::setNormalDest()
2673 */
2674void LLVMSetNormalDest(LLVMValueRef InvokeInst, LLVMBasicBlockRef B);
2675
2676/**
2677 * Set the unwind destination basic block.
2678 *
2679 * This only works on llvm::InvokeInst instructions.
2680 *
2681 * @see llvm::InvokeInst::setUnwindDest()
2682 */
2683void LLVMSetUnwindDest(LLVMValueRef InvokeInst, LLVMBasicBlockRef B);
2684
2685/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002686 * @}
2687 */
2688
2689/**
Peter Zotov2481c752014-10-28 19:46:56 +00002690 * @defgroup LLVMCCoreValueInstructionTerminator Terminators
2691 *
2692 * Functions in this group only apply to instructions that map to
2693 * llvm::TerminatorInst instances.
2694 *
2695 * @{
2696 */
2697
2698/**
2699 * Return the number of successors that this terminator has.
2700 *
2701 * @see llvm::TerminatorInst::getNumSuccessors
2702 */
2703unsigned LLVMGetNumSuccessors(LLVMValueRef Term);
2704
2705/**
2706 * Return the specified successor.
2707 *
2708 * @see llvm::TerminatorInst::getSuccessor
2709 */
2710LLVMBasicBlockRef LLVMGetSuccessor(LLVMValueRef Term, unsigned i);
2711
2712/**
2713 * Update the specified successor to point at the provided block.
2714 *
2715 * @see llvm::TerminatorInst::setSuccessor
2716 */
2717void LLVMSetSuccessor(LLVMValueRef Term, unsigned i, LLVMBasicBlockRef block);
2718
2719/**
2720 * Return if a branch is conditional.
2721 *
2722 * This only works on llvm::BranchInst instructions.
2723 *
2724 * @see llvm::BranchInst::isConditional
2725 */
2726LLVMBool LLVMIsConditional(LLVMValueRef Branch);
2727
2728/**
2729 * Return the condition of a branch instruction.
2730 *
2731 * This only works on llvm::BranchInst instructions.
2732 *
2733 * @see llvm::BranchInst::getCondition
2734 */
2735LLVMValueRef LLVMGetCondition(LLVMValueRef Branch);
2736
2737/**
2738 * Set the condition of a branch instruction.
2739 *
2740 * This only works on llvm::BranchInst instructions.
2741 *
2742 * @see llvm::BranchInst::setCondition
2743 */
2744void LLVMSetCondition(LLVMValueRef Branch, LLVMValueRef Cond);
2745
2746/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002747 * Obtain the default destination basic block of a switch instruction.
2748 *
2749 * This only works on llvm::SwitchInst instructions.
2750 *
2751 * @see llvm::SwitchInst::getDefaultDest()
2752 */
Nate Begeman43c322b2011-08-23 20:27:46 +00002753LLVMBasicBlockRef LLVMGetSwitchDefaultDest(LLVMValueRef SwitchInstr);
2754
Gregory Szorc34c863a2012-03-21 03:54:29 +00002755/**
Peter Zotov2481c752014-10-28 19:46:56 +00002756 * @}
2757 */
2758
2759/**
Amaury Sechet1dcf5772016-02-09 22:50:53 +00002760 * @defgroup LLVMCCoreValueInstructionAlloca Allocas
2761 *
2762 * Functions in this group only apply to instructions that map to
2763 * llvm::AllocaInst instances.
2764 *
2765 * @{
2766 */
2767
2768/**
2769 * Obtain the type that is being allocated by the alloca instruction.
2770 */
2771LLVMTypeRef LLVMGetAllocatedType(LLVMValueRef Alloca);
2772
2773/**
2774 * @}
2775 */
2776
2777/**
Amaury Sechet053ac452016-02-17 22:51:03 +00002778 * @defgroup LLVMCCoreValueInstructionGetElementPointer GEPs
2779 *
2780 * Functions in this group only apply to instructions that map to
2781 * llvm::GetElementPtrInst instances.
2782 *
2783 * @{
2784 */
2785
2786/**
2787 * Check whether the given GEP instruction is inbounds.
2788 */
2789LLVMBool LLVMIsInBounds(LLVMValueRef GEP);
2790
2791/**
2792 * Set the given GEP instruction to be inbounds or not.
2793 */
Amaury Sechet8a367d42016-05-01 02:23:14 +00002794void LLVMSetIsInBounds(LLVMValueRef GEP, LLVMBool InBounds);
Amaury Sechet053ac452016-02-17 22:51:03 +00002795
2796/**
2797 * @}
2798 */
2799
2800/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002801 * @defgroup LLVMCCoreValueInstructionPHINode PHI Nodes
2802 *
2803 * Functions in this group only apply to instructions that map to
2804 * llvm::PHINode instances.
2805 *
2806 * @{
2807 */
2808
2809/**
2810 * Add an incoming value to the end of a PHI list.
2811 */
Gordon Henriksen44dd8fb2007-10-08 18:14:39 +00002812void LLVMAddIncoming(LLVMValueRef PhiNode, LLVMValueRef *IncomingValues,
2813 LLVMBasicBlockRef *IncomingBlocks, unsigned Count);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002814
2815/**
2816 * Obtain the number of incoming basic blocks to a PHI node.
2817 */
Gordon Henriksen44dd8fb2007-10-08 18:14:39 +00002818unsigned LLVMCountIncoming(LLVMValueRef PhiNode);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002819
2820/**
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00002821 * Obtain an incoming value to a PHI node as an LLVMValueRef.
Gregory Szorc34c863a2012-03-21 03:54:29 +00002822 */
Gordon Henriksen44dd8fb2007-10-08 18:14:39 +00002823LLVMValueRef LLVMGetIncomingValue(LLVMValueRef PhiNode, unsigned Index);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002824
2825/**
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00002826 * Obtain an incoming value to a PHI node as an LLVMBasicBlockRef.
Gregory Szorc34c863a2012-03-21 03:54:29 +00002827 */
Gordon Henriksen44dd8fb2007-10-08 18:14:39 +00002828LLVMBasicBlockRef LLVMGetIncomingBlock(LLVMValueRef PhiNode, unsigned Index);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002829
Gregory Szorc34c863a2012-03-21 03:54:29 +00002830/**
2831 * @}
2832 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002833
Gregory Szorc34c863a2012-03-21 03:54:29 +00002834/**
Amaury Sechetaad93532016-02-10 00:38:50 +00002835 * @defgroup LLVMCCoreValueInstructionExtractValue ExtractValue
2836 * @defgroup LLVMCCoreValueInstructionInsertValue InsertValue
2837 *
2838 * Functions in this group only apply to instructions that map to
2839 * llvm::ExtractValue and llvm::InsertValue instances.
2840 *
2841 * @{
2842 */
2843
2844/**
2845 * Obtain the number of indices.
Amaury Sechet053ac452016-02-17 22:51:03 +00002846 * NB: This also works on GEP.
Amaury Sechetaad93532016-02-10 00:38:50 +00002847 */
2848unsigned LLVMGetNumIndices(LLVMValueRef Inst);
2849
2850/**
2851 * Obtain the indices as an array.
2852 */
2853const unsigned *LLVMGetIndices(LLVMValueRef Inst);
2854
2855/**
2856 * @}
2857 */
2858
2859/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002860 * @}
2861 */
2862
2863/**
2864 * @}
2865 */
2866
2867/**
2868 * @defgroup LLVMCCoreInstructionBuilder Instruction Builders
2869 *
2870 * An instruction builder represents a point within a basic block and is
2871 * the exclusive means of building instructions using the C interface.
2872 *
2873 * @{
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002874 */
2875
Erick Tryzelaar262332f2009-08-14 00:01:31 +00002876LLVMBuilderRef LLVMCreateBuilderInContext(LLVMContextRef C);
Gordon Henriksena735a9c2008-05-04 12:55:34 +00002877LLVMBuilderRef LLVMCreateBuilder(void);
Gordon Henriksen054817c2008-03-19 03:47:18 +00002878void LLVMPositionBuilder(LLVMBuilderRef Builder, LLVMBasicBlockRef Block,
2879 LLVMValueRef Instr);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002880void LLVMPositionBuilderBefore(LLVMBuilderRef Builder, LLVMValueRef Instr);
2881void LLVMPositionBuilderAtEnd(LLVMBuilderRef Builder, LLVMBasicBlockRef Block);
Gordon Henriksen265f7802008-03-19 01:11:35 +00002882LLVMBasicBlockRef LLVMGetInsertBlock(LLVMBuilderRef Builder);
Chris Lattner3d1f5522008-12-17 21:39:50 +00002883void LLVMClearInsertionPosition(LLVMBuilderRef Builder);
2884void LLVMInsertIntoBuilder(LLVMBuilderRef Builder, LLVMValueRef Instr);
Erick Tryzelaar9813bea2009-08-16 02:20:57 +00002885void LLVMInsertIntoBuilderWithName(LLVMBuilderRef Builder, LLVMValueRef Instr,
2886 const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002887void LLVMDisposeBuilder(LLVMBuilderRef Builder);
2888
Erick Tryzelaard8531fa2010-02-28 09:45:59 +00002889/* Metadata */
2890void LLVMSetCurrentDebugLocation(LLVMBuilderRef Builder, LLVMValueRef L);
2891LLVMValueRef LLVMGetCurrentDebugLocation(LLVMBuilderRef Builder);
2892void LLVMSetInstDebugLocation(LLVMBuilderRef Builder, LLVMValueRef Inst);
2893
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002894/* Terminators */
2895LLVMValueRef LLVMBuildRetVoid(LLVMBuilderRef);
2896LLVMValueRef LLVMBuildRet(LLVMBuilderRef, LLVMValueRef V);
Erick Tryzelaarfd529d72009-08-19 08:36:49 +00002897LLVMValueRef LLVMBuildAggregateRet(LLVMBuilderRef, LLVMValueRef *RetVals,
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002898 unsigned N);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002899LLVMValueRef LLVMBuildBr(LLVMBuilderRef, LLVMBasicBlockRef Dest);
2900LLVMValueRef LLVMBuildCondBr(LLVMBuilderRef, LLVMValueRef If,
2901 LLVMBasicBlockRef Then, LLVMBasicBlockRef Else);
2902LLVMValueRef LLVMBuildSwitch(LLVMBuilderRef, LLVMValueRef V,
2903 LLVMBasicBlockRef Else, unsigned NumCases);
Erick Tryzelaar0fb26ef2010-02-28 09:46:06 +00002904LLVMValueRef LLVMBuildIndirectBr(LLVMBuilderRef B, LLVMValueRef Addr,
2905 unsigned NumDests);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002906LLVMValueRef LLVMBuildInvoke(LLVMBuilderRef, LLVMValueRef Fn,
2907 LLVMValueRef *Args, unsigned NumArgs,
2908 LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch,
2909 const char *Name);
Benjamin Kramer5a6568832011-08-19 01:36:54 +00002910LLVMValueRef LLVMBuildLandingPad(LLVMBuilderRef B, LLVMTypeRef Ty,
Reid Kleckneref9828f2015-07-16 01:16:39 +00002911 LLVMValueRef PersFn, unsigned NumClauses,
2912 const char *Name);
Bill Wendlingf891bf82011-07-31 06:30:59 +00002913LLVMValueRef LLVMBuildResume(LLVMBuilderRef B, LLVMValueRef Exn);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002914LLVMValueRef LLVMBuildUnreachable(LLVMBuilderRef);
2915
Gordon Henriksen097102c2008-01-01 05:50:53 +00002916/* Add a case to the switch instruction */
2917void LLVMAddCase(LLVMValueRef Switch, LLVMValueRef OnVal,
2918 LLVMBasicBlockRef Dest);
2919
Erick Tryzelaar0fb26ef2010-02-28 09:46:06 +00002920/* Add a destination to the indirectbr instruction */
2921void LLVMAddDestination(LLVMValueRef IndirectBr, LLVMBasicBlockRef Dest);
2922
Amaury Sechete39e8532016-02-18 20:38:32 +00002923/* Get the number of clauses on the landingpad instruction */
2924unsigned LLVMGetNumClauses(LLVMValueRef LandingPad);
2925
2926/* Get the value of the clause at idnex Idx on the landingpad instruction */
2927LLVMValueRef LLVMGetClause(LLVMValueRef LandingPad, unsigned Idx);
2928
Bill Wendlingfae14752011-08-12 20:24:12 +00002929/* Add a catch or filter clause to the landingpad instruction */
2930void LLVMAddClause(LLVMValueRef LandingPad, LLVMValueRef ClauseVal);
2931
Amaury Sechete39e8532016-02-18 20:38:32 +00002932/* Get the 'cleanup' flag in the landingpad instruction */
2933LLVMBool LLVMIsCleanup(LLVMValueRef LandingPad);
2934
Bill Wendlingfae14752011-08-12 20:24:12 +00002935/* Set the 'cleanup' flag in the landingpad instruction */
2936void LLVMSetCleanup(LLVMValueRef LandingPad, LLVMBool Val);
2937
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002938/* Arithmetic */
2939LLVMValueRef LLVMBuildAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2940 const char *Name);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002941LLVMValueRef LLVMBuildNSWAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2942 const char *Name);
Erick Tryzelaar4c340c72010-02-28 05:51:43 +00002943LLVMValueRef LLVMBuildNUWAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2944 const char *Name);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002945LLVMValueRef LLVMBuildFAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2946 const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002947LLVMValueRef LLVMBuildSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2948 const char *Name);
Erick Tryzelaar4c340c72010-02-28 05:51:43 +00002949LLVMValueRef LLVMBuildNSWSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2950 const char *Name);
2951LLVMValueRef LLVMBuildNUWSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2952 const char *Name);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002953LLVMValueRef LLVMBuildFSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2954 const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002955LLVMValueRef LLVMBuildMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2956 const char *Name);
Erick Tryzelaar4c340c72010-02-28 05:51:43 +00002957LLVMValueRef LLVMBuildNSWMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2958 const char *Name);
2959LLVMValueRef LLVMBuildNUWMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2960 const char *Name);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002961LLVMValueRef LLVMBuildFMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2962 const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002963LLVMValueRef LLVMBuildUDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2964 const char *Name);
2965LLVMValueRef LLVMBuildSDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2966 const char *Name);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002967LLVMValueRef LLVMBuildExactSDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2968 const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002969LLVMValueRef LLVMBuildFDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2970 const char *Name);
2971LLVMValueRef LLVMBuildURem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2972 const char *Name);
2973LLVMValueRef LLVMBuildSRem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2974 const char *Name);
2975LLVMValueRef LLVMBuildFRem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2976 const char *Name);
2977LLVMValueRef LLVMBuildShl(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2978 const char *Name);
2979LLVMValueRef LLVMBuildLShr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2980 const char *Name);
2981LLVMValueRef LLVMBuildAShr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2982 const char *Name);
2983LLVMValueRef LLVMBuildAnd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2984 const char *Name);
2985LLVMValueRef LLVMBuildOr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2986 const char *Name);
2987LLVMValueRef LLVMBuildXor(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2988 const char *Name);
Erick Tryzelaar31831792010-02-28 05:51:27 +00002989LLVMValueRef LLVMBuildBinOp(LLVMBuilderRef B, LLVMOpcode Op,
2990 LLVMValueRef LHS, LLVMValueRef RHS,
2991 const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002992LLVMValueRef LLVMBuildNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name);
Erick Tryzelaar4c340c72010-02-28 05:51:43 +00002993LLVMValueRef LLVMBuildNSWNeg(LLVMBuilderRef B, LLVMValueRef V,
2994 const char *Name);
2995LLVMValueRef LLVMBuildNUWNeg(LLVMBuilderRef B, LLVMValueRef V,
2996 const char *Name);
Dan Gohmanf919bd62009-09-28 21:51:41 +00002997LLVMValueRef LLVMBuildFNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002998LLVMValueRef LLVMBuildNot(LLVMBuilderRef, LLVMValueRef V, const char *Name);
2999
3000/* Memory */
3001LLVMValueRef LLVMBuildMalloc(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
3002LLVMValueRef LLVMBuildArrayMalloc(LLVMBuilderRef, LLVMTypeRef Ty,
3003 LLVMValueRef Val, const char *Name);
3004LLVMValueRef LLVMBuildAlloca(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
3005LLVMValueRef LLVMBuildArrayAlloca(LLVMBuilderRef, LLVMTypeRef Ty,
3006 LLVMValueRef Val, const char *Name);
3007LLVMValueRef LLVMBuildFree(LLVMBuilderRef, LLVMValueRef PointerVal);
3008LLVMValueRef LLVMBuildLoad(LLVMBuilderRef, LLVMValueRef PointerVal,
3009 const char *Name);
3010LLVMValueRef LLVMBuildStore(LLVMBuilderRef, LLVMValueRef Val, LLVMValueRef Ptr);
3011LLVMValueRef LLVMBuildGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
3012 LLVMValueRef *Indices, unsigned NumIndices,
3013 const char *Name);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00003014LLVMValueRef LLVMBuildInBoundsGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
3015 LLVMValueRef *Indices, unsigned NumIndices,
3016 const char *Name);
3017LLVMValueRef LLVMBuildStructGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
3018 unsigned Idx, const char *Name);
3019LLVMValueRef LLVMBuildGlobalString(LLVMBuilderRef B, const char *Str,
3020 const char *Name);
3021LLVMValueRef LLVMBuildGlobalStringPtr(LLVMBuilderRef B, const char *Str,
3022 const char *Name);
Chris Lattner2cc6f9d2012-03-22 03:54:15 +00003023LLVMBool LLVMGetVolatile(LLVMValueRef MemoryAccessInst);
3024void LLVMSetVolatile(LLVMValueRef MemoryAccessInst, LLVMBool IsVolatile);
Andrew Wilkinsb7362ce2015-08-02 12:16:57 +00003025LLVMAtomicOrdering LLVMGetOrdering(LLVMValueRef MemoryAccessInst);
3026void LLVMSetOrdering(LLVMValueRef MemoryAccessInst, LLVMAtomicOrdering Ordering);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00003027
3028/* Casts */
3029LLVMValueRef LLVMBuildTrunc(LLVMBuilderRef, LLVMValueRef Val,
3030 LLVMTypeRef DestTy, const char *Name);
3031LLVMValueRef LLVMBuildZExt(LLVMBuilderRef, LLVMValueRef Val,
3032 LLVMTypeRef DestTy, const char *Name);
3033LLVMValueRef LLVMBuildSExt(LLVMBuilderRef, LLVMValueRef Val,
3034 LLVMTypeRef DestTy, const char *Name);
3035LLVMValueRef LLVMBuildFPToUI(LLVMBuilderRef, LLVMValueRef Val,
3036 LLVMTypeRef DestTy, const char *Name);
3037LLVMValueRef LLVMBuildFPToSI(LLVMBuilderRef, LLVMValueRef Val,
3038 LLVMTypeRef DestTy, const char *Name);
3039LLVMValueRef LLVMBuildUIToFP(LLVMBuilderRef, LLVMValueRef Val,
3040 LLVMTypeRef DestTy, const char *Name);
3041LLVMValueRef LLVMBuildSIToFP(LLVMBuilderRef, LLVMValueRef Val,
3042 LLVMTypeRef DestTy, const char *Name);
3043LLVMValueRef LLVMBuildFPTrunc(LLVMBuilderRef, LLVMValueRef Val,
3044 LLVMTypeRef DestTy, const char *Name);
3045LLVMValueRef LLVMBuildFPExt(LLVMBuilderRef, LLVMValueRef Val,
3046 LLVMTypeRef DestTy, const char *Name);
3047LLVMValueRef LLVMBuildPtrToInt(LLVMBuilderRef, LLVMValueRef Val,
3048 LLVMTypeRef DestTy, const char *Name);
3049LLVMValueRef LLVMBuildIntToPtr(LLVMBuilderRef, LLVMValueRef Val,
3050 LLVMTypeRef DestTy, const char *Name);
3051LLVMValueRef LLVMBuildBitCast(LLVMBuilderRef, LLVMValueRef Val,
3052 LLVMTypeRef DestTy, const char *Name);
Matt Arsenaultb03bd4d2013-11-15 01:34:59 +00003053LLVMValueRef LLVMBuildAddrSpaceCast(LLVMBuilderRef, LLVMValueRef Val,
3054 LLVMTypeRef DestTy, const char *Name);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00003055LLVMValueRef LLVMBuildZExtOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
3056 LLVMTypeRef DestTy, const char *Name);
3057LLVMValueRef LLVMBuildSExtOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
3058 LLVMTypeRef DestTy, const char *Name);
3059LLVMValueRef LLVMBuildTruncOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
3060 LLVMTypeRef DestTy, const char *Name);
Erick Tryzelaar31831792010-02-28 05:51:27 +00003061LLVMValueRef LLVMBuildCast(LLVMBuilderRef B, LLVMOpcode Op, LLVMValueRef Val,
3062 LLVMTypeRef DestTy, const char *Name);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00003063LLVMValueRef LLVMBuildPointerCast(LLVMBuilderRef, LLVMValueRef Val,
3064 LLVMTypeRef DestTy, const char *Name);
Duncan Sands9d786d72009-11-23 10:49:03 +00003065LLVMValueRef LLVMBuildIntCast(LLVMBuilderRef, LLVMValueRef Val, /*Signed cast!*/
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00003066 LLVMTypeRef DestTy, const char *Name);
3067LLVMValueRef LLVMBuildFPCast(LLVMBuilderRef, LLVMValueRef Val,
3068 LLVMTypeRef DestTy, const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00003069
3070/* Comparisons */
3071LLVMValueRef LLVMBuildICmp(LLVMBuilderRef, LLVMIntPredicate Op,
3072 LLVMValueRef LHS, LLVMValueRef RHS,
3073 const char *Name);
3074LLVMValueRef LLVMBuildFCmp(LLVMBuilderRef, LLVMRealPredicate Op,
3075 LLVMValueRef LHS, LLVMValueRef RHS,
3076 const char *Name);
3077
3078/* Miscellaneous instructions */
3079LLVMValueRef LLVMBuildPhi(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
3080LLVMValueRef LLVMBuildCall(LLVMBuilderRef, LLVMValueRef Fn,
3081 LLVMValueRef *Args, unsigned NumArgs,
3082 const char *Name);
3083LLVMValueRef LLVMBuildSelect(LLVMBuilderRef, LLVMValueRef If,
3084 LLVMValueRef Then, LLVMValueRef Else,
3085 const char *Name);
3086LLVMValueRef LLVMBuildVAArg(LLVMBuilderRef, LLVMValueRef List, LLVMTypeRef Ty,
3087 const char *Name);
3088LLVMValueRef LLVMBuildExtractElement(LLVMBuilderRef, LLVMValueRef VecVal,
3089 LLVMValueRef Index, const char *Name);
3090LLVMValueRef LLVMBuildInsertElement(LLVMBuilderRef, LLVMValueRef VecVal,
3091 LLVMValueRef EltVal, LLVMValueRef Index,
3092 const char *Name);
3093LLVMValueRef LLVMBuildShuffleVector(LLVMBuilderRef, LLVMValueRef V1,
3094 LLVMValueRef V2, LLVMValueRef Mask,
3095 const char *Name);
Dan Gohmand5104a52008-11-03 22:55:43 +00003096LLVMValueRef LLVMBuildExtractValue(LLVMBuilderRef, LLVMValueRef AggVal,
3097 unsigned Index, const char *Name);
3098LLVMValueRef LLVMBuildInsertValue(LLVMBuilderRef, LLVMValueRef AggVal,
3099 LLVMValueRef EltVal, unsigned Index,
3100 const char *Name);
Gordon Henriksen76a03742007-09-18 03:18:57 +00003101
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00003102LLVMValueRef LLVMBuildIsNull(LLVMBuilderRef, LLVMValueRef Val,
3103 const char *Name);
3104LLVMValueRef LLVMBuildIsNotNull(LLVMBuilderRef, LLVMValueRef Val,
3105 const char *Name);
3106LLVMValueRef LLVMBuildPtrDiff(LLVMBuilderRef, LLVMValueRef LHS,
3107 LLVMValueRef RHS, const char *Name);
Filip Pizlo0d3f7ec2013-11-20 00:07:49 +00003108LLVMValueRef LLVMBuildFence(LLVMBuilderRef B, LLVMAtomicOrdering ordering,
3109 LLVMBool singleThread, const char *Name);
3110LLVMValueRef LLVMBuildAtomicRMW(LLVMBuilderRef B, LLVMAtomicRMWBinOp op,
NAKAMURA Takumia3a81352013-10-23 17:56:29 +00003111 LLVMValueRef PTR, LLVMValueRef Val,
3112 LLVMAtomicOrdering ordering,
Carlo Kok8c6719b2013-04-23 13:21:19 +00003113 LLVMBool singleThread);
Mehdi Amini43165d92016-03-19 21:28:28 +00003114LLVMValueRef LLVMBuildAtomicCmpXchg(LLVMBuilderRef B, LLVMValueRef Ptr,
3115 LLVMValueRef Cmp, LLVMValueRef New,
3116 LLVMAtomicOrdering SuccessOrdering,
3117 LLVMAtomicOrdering FailureOrdering,
3118 LLVMBool SingleThread);
3119
3120LLVMBool LLVMIsAtomicSingleThread(LLVMValueRef AtomicInst);
3121void LLVMSetAtomicSingleThread(LLVMValueRef AtomicInst, LLVMBool SingleThread);
3122
3123LLVMAtomicOrdering LLVMGetCmpXchgSuccessOrdering(LLVMValueRef CmpXchgInst);
3124void LLVMSetCmpXchgSuccessOrdering(LLVMValueRef CmpXchgInst,
3125 LLVMAtomicOrdering Ordering);
3126LLVMAtomicOrdering LLVMGetCmpXchgFailureOrdering(LLVMValueRef CmpXchgInst);
3127void LLVMSetCmpXchgFailureOrdering(LLVMValueRef CmpXchgInst,
3128 LLVMAtomicOrdering Ordering);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00003129
Gregory Szorc34c863a2012-03-21 03:54:29 +00003130/**
3131 * @}
3132 */
Gordon Henriksen34eb6d82007-12-19 22:30:40 +00003133
Gregory Szorc34c863a2012-03-21 03:54:29 +00003134/**
3135 * @defgroup LLVMCCoreModuleProvider Module Providers
3136 *
3137 * @{
3138 */
Gordon Henriksen0a68fe22007-12-12 01:04:30 +00003139
Gregory Szorc34c863a2012-03-21 03:54:29 +00003140/**
3141 * Changes the type of M so it can be passed to FunctionPassManagers and the
Jeffrey Yasskin091217b2010-01-27 20:34:15 +00003142 * JIT. They take ModuleProviders for historical reasons.
Gordon Henriksen0a68fe22007-12-12 01:04:30 +00003143 */
3144LLVMModuleProviderRef
3145LLVMCreateModuleProviderForExistingModule(LLVMModuleRef M);
3146
Gregory Szorc34c863a2012-03-21 03:54:29 +00003147/**
3148 * Destroys the module M.
Gordon Henriksen0a68fe22007-12-12 01:04:30 +00003149 */
Jeffrey Yasskin091217b2010-01-27 20:34:15 +00003150void LLVMDisposeModuleProvider(LLVMModuleProviderRef M);
Gordon Henriksen0a68fe22007-12-12 01:04:30 +00003151
Gregory Szorc34c863a2012-03-21 03:54:29 +00003152/**
3153 * @}
3154 */
Gordon Henriksen34eb6d82007-12-19 22:30:40 +00003155
Gregory Szorc34c863a2012-03-21 03:54:29 +00003156/**
3157 * @defgroup LLVMCCoreMemoryBuffers Memory Buffers
3158 *
3159 * @{
3160 */
Gordon Henriksen34eb6d82007-12-19 22:30:40 +00003161
Chris Lattner25963c62010-01-09 22:27:07 +00003162LLVMBool LLVMCreateMemoryBufferWithContentsOfFile(const char *Path,
3163 LLVMMemoryBufferRef *OutMemBuf,
3164 char **OutMessage);
3165LLVMBool LLVMCreateMemoryBufferWithSTDIN(LLVMMemoryBufferRef *OutMemBuf,
3166 char **OutMessage);
Bill Wendling526276a2013-02-14 19:11:28 +00003167LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRange(const char *InputData,
3168 size_t InputDataLength,
3169 const char *BufferName,
Bill Wendlingc9baa962013-02-14 19:39:14 +00003170 LLVMBool RequiresNullTerminator);
Bill Wendling526276a2013-02-14 19:11:28 +00003171LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRangeCopy(const char *InputData,
3172 size_t InputDataLength,
3173 const char *BufferName);
Tom Stellard62c03202013-04-18 19:50:53 +00003174const char *LLVMGetBufferStart(LLVMMemoryBufferRef MemBuf);
Tom Stellardb7fb7242013-04-16 23:12:51 +00003175size_t LLVMGetBufferSize(LLVMMemoryBufferRef MemBuf);
Gordon Henriksen34eb6d82007-12-19 22:30:40 +00003176void LLVMDisposeMemoryBuffer(LLVMMemoryBufferRef MemBuf);
3177
Gregory Szorc34c863a2012-03-21 03:54:29 +00003178/**
3179 * @}
3180 */
3181
3182/**
3183 * @defgroup LLVMCCorePassRegistry Pass Registry
3184 *
3185 * @{
3186 */
Owen Anderson4698c5d2010-10-07 17:55:47 +00003187
3188/** Return the global pass registry, for use with initialization functions.
Gregory Szorc34c863a2012-03-21 03:54:29 +00003189 @see llvm::PassRegistry::getPassRegistry */
Owen Anderson4698c5d2010-10-07 17:55:47 +00003190LLVMPassRegistryRef LLVMGetGlobalPassRegistry(void);
Gordon Henriksen878114b2008-03-16 04:20:44 +00003191
Gregory Szorc34c863a2012-03-21 03:54:29 +00003192/**
3193 * @}
3194 */
3195
3196/**
3197 * @defgroup LLVMCCorePassManagers Pass Managers
3198 *
3199 * @{
3200 */
Gordon Henriksen878114b2008-03-16 04:20:44 +00003201
3202/** Constructs a new whole-module pass pipeline. This type of pipeline is
3203 suitable for link-time optimization and whole-module transformations.
Gregory Szorc34c863a2012-03-21 03:54:29 +00003204 @see llvm::PassManager::PassManager */
Gordon Henriksena735a9c2008-05-04 12:55:34 +00003205LLVMPassManagerRef LLVMCreatePassManager(void);
Gordon Henriksen878114b2008-03-16 04:20:44 +00003206
3207/** Constructs a new function-by-function pass pipeline over the module
3208 provider. It does not take ownership of the module provider. This type of
3209 pipeline is suitable for code generation and JIT compilation tasks.
Gregory Szorc34c863a2012-03-21 03:54:29 +00003210 @see llvm::FunctionPassManager::FunctionPassManager */
Erick Tryzelaarad0e0cb2010-03-02 23:58:54 +00003211LLVMPassManagerRef LLVMCreateFunctionPassManagerForModule(LLVMModuleRef M);
3212
3213/** Deprecated: Use LLVMCreateFunctionPassManagerForModule instead. */
Gordon Henriksen878114b2008-03-16 04:20:44 +00003214LLVMPassManagerRef LLVMCreateFunctionPassManager(LLVMModuleProviderRef MP);
3215
3216/** Initializes, executes on the provided module, and finalizes all of the
3217 passes scheduled in the pass manager. Returns 1 if any of the passes
Gregory Szorc34c863a2012-03-21 03:54:29 +00003218 modified the module, 0 otherwise.
3219 @see llvm::PassManager::run(Module&) */
Chris Lattner25963c62010-01-09 22:27:07 +00003220LLVMBool LLVMRunPassManager(LLVMPassManagerRef PM, LLVMModuleRef M);
Gordon Henriksen878114b2008-03-16 04:20:44 +00003221
3222/** Initializes all of the function passes scheduled in the function pass
3223 manager. Returns 1 if any of the passes modified the module, 0 otherwise.
Gregory Szorc34c863a2012-03-21 03:54:29 +00003224 @see llvm::FunctionPassManager::doInitialization */
Chris Lattner25963c62010-01-09 22:27:07 +00003225LLVMBool LLVMInitializeFunctionPassManager(LLVMPassManagerRef FPM);
Gordon Henriksen878114b2008-03-16 04:20:44 +00003226
3227/** Executes all of the function passes scheduled in the function pass manager
3228 on the provided function. Returns 1 if any of the passes modified the
3229 function, false otherwise.
Gregory Szorc34c863a2012-03-21 03:54:29 +00003230 @see llvm::FunctionPassManager::run(Function&) */
Chris Lattner25963c62010-01-09 22:27:07 +00003231LLVMBool LLVMRunFunctionPassManager(LLVMPassManagerRef FPM, LLVMValueRef F);
Gordon Henriksen878114b2008-03-16 04:20:44 +00003232
3233/** Finalizes all of the function passes scheduled in in the function pass
3234 manager. Returns 1 if any of the passes modified the module, 0 otherwise.
Gregory Szorc34c863a2012-03-21 03:54:29 +00003235 @see llvm::FunctionPassManager::doFinalization */
Chris Lattner25963c62010-01-09 22:27:07 +00003236LLVMBool LLVMFinalizeFunctionPassManager(LLVMPassManagerRef FPM);
Gordon Henriksen878114b2008-03-16 04:20:44 +00003237
3238/** Frees the memory of a pass pipeline. For function pipelines, does not free
3239 the module provider.
Gregory Szorc34c863a2012-03-21 03:54:29 +00003240 @see llvm::PassManagerBase::~PassManagerBase. */
Gordon Henriksen878114b2008-03-16 04:20:44 +00003241void LLVMDisposePassManager(LLVMPassManagerRef PM);
3242
Gregory Szorc34c863a2012-03-21 03:54:29 +00003243/**
3244 * @}
3245 */
3246
3247/**
Duncan Sands1cba0a82013-02-17 16:35:51 +00003248 * @defgroup LLVMCCoreThreading Threading
3249 *
3250 * Handle the structures needed to make LLVM safe for multithreading.
3251 *
3252 * @{
3253 */
3254
Chandler Carruth39cd2162014-06-27 15:13:01 +00003255/** Deprecated: Multi-threading can only be enabled/disabled with the compile
3256 time define LLVM_ENABLE_THREADS. This function always returns
3257 LLVMIsMultithreaded(). */
Benjamin Kramer325ec892013-10-23 16:57:34 +00003258LLVMBool LLVMStartMultithreaded(void);
Duncan Sands1cba0a82013-02-17 16:35:51 +00003259
Chandler Carruth39cd2162014-06-27 15:13:01 +00003260/** Deprecated: Multi-threading can only be enabled/disabled with the compile
3261 time define LLVM_ENABLE_THREADS. */
Benjamin Kramer325ec892013-10-23 16:57:34 +00003262void LLVMStopMultithreaded(void);
Duncan Sands1cba0a82013-02-17 16:35:51 +00003263
3264/** Check whether LLVM is executing in thread-safe mode or not.
3265 @see llvm::llvm_is_multithreaded */
Benjamin Kramer325ec892013-10-23 16:57:34 +00003266LLVMBool LLVMIsMultithreaded(void);
Duncan Sands1cba0a82013-02-17 16:35:51 +00003267
3268/**
3269 * @}
3270 */
3271
3272/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00003273 * @}
3274 */
3275
3276/**
3277 * @}
3278 */
Gordon Henriksen878114b2008-03-16 04:20:44 +00003279
Gordon Henriksen76a03742007-09-18 03:18:57 +00003280#ifdef __cplusplus
3281}
Eugene Zelenkoffec81c2015-11-04 22:32:32 +00003282#endif
Gordon Henriksen7330acd2007-10-05 23:59:36 +00003283
Eugene Zelenkoffec81c2015-11-04 22:32:32 +00003284#endif /* LLVM_C_CORE_H */