blob: a09c92282a63627731d1bfad1d08c7c7df2227da [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,
Nuno Lopesdef4229972012-09-02 14:19:21 +000097 */
Devang Patel4c758ea2008-09-25 21:00:45 +000098} LLVMAttribute;
Gordon Henriksen2d9cc212008-04-28 17:37:06 +000099
100typedef enum {
Bill Wendlingda52cec2010-02-15 20:53:17 +0000101 /* Terminator Instructions */
Chris Lattner40cf28d2009-10-12 04:01:02 +0000102 LLVMRet = 1,
103 LLVMBr = 2,
104 LLVMSwitch = 3,
Bill Wendling07d6d762010-02-15 20:50:51 +0000105 LLVMIndirectBr = 4,
106 LLVMInvoke = 5,
Bill Wendling46ffaa92011-08-02 06:20:17 +0000107 /* removed 6 due to API changes */
Bill Wendling2641d132011-07-27 21:00:28 +0000108 LLVMUnreachable = 7,
Bill Wendling07d6d762010-02-15 20:50:51 +0000109
Bill Wendlingda52cec2010-02-15 20:53:17 +0000110 /* Standard Binary Operators */
Bill Wendling2641d132011-07-27 21:00:28 +0000111 LLVMAdd = 8,
112 LLVMFAdd = 9,
113 LLVMSub = 10,
114 LLVMFSub = 11,
115 LLVMMul = 12,
116 LLVMFMul = 13,
117 LLVMUDiv = 14,
118 LLVMSDiv = 15,
119 LLVMFDiv = 16,
120 LLVMURem = 17,
121 LLVMSRem = 18,
122 LLVMFRem = 19,
Bill Wendling07d6d762010-02-15 20:50:51 +0000123
Bill Wendlingda52cec2010-02-15 20:53:17 +0000124 /* Logical Operators */
Bill Wendling2641d132011-07-27 21:00:28 +0000125 LLVMShl = 20,
126 LLVMLShr = 21,
127 LLVMAShr = 22,
128 LLVMAnd = 23,
129 LLVMOr = 24,
130 LLVMXor = 25,
Bill Wendling07d6d762010-02-15 20:50:51 +0000131
Bill Wendlingda52cec2010-02-15 20:53:17 +0000132 /* Memory Operators */
Bill Wendling2641d132011-07-27 21:00:28 +0000133 LLVMAlloca = 26,
134 LLVMLoad = 27,
135 LLVMStore = 28,
136 LLVMGetElementPtr = 29,
Bill Wendling07d6d762010-02-15 20:50:51 +0000137
Bill Wendlingda52cec2010-02-15 20:53:17 +0000138 /* Cast Operators */
Bill Wendling2641d132011-07-27 21:00:28 +0000139 LLVMTrunc = 30,
140 LLVMZExt = 31,
141 LLVMSExt = 32,
142 LLVMFPToUI = 33,
143 LLVMFPToSI = 34,
144 LLVMUIToFP = 35,
145 LLVMSIToFP = 36,
146 LLVMFPTrunc = 37,
147 LLVMFPExt = 38,
148 LLVMPtrToInt = 39,
149 LLVMIntToPtr = 40,
150 LLVMBitCast = 41,
Matt Arsenaultb03bd4d2013-11-15 01:34:59 +0000151 LLVMAddrSpaceCast = 60,
Bill Wendling07d6d762010-02-15 20:50:51 +0000152
Bill Wendlingda52cec2010-02-15 20:53:17 +0000153 /* Other Operators */
Bill Wendling2641d132011-07-27 21:00:28 +0000154 LLVMICmp = 42,
155 LLVMFCmp = 43,
156 LLVMPHI = 44,
157 LLVMCall = 45,
158 LLVMSelect = 46,
Torok Edwin05dc9d62011-10-06 12:39:34 +0000159 LLVMUserOp1 = 47,
160 LLVMUserOp2 = 48,
Bill Wendling2641d132011-07-27 21:00:28 +0000161 LLVMVAArg = 49,
162 LLVMExtractElement = 50,
163 LLVMInsertElement = 51,
164 LLVMShuffleVector = 52,
165 LLVMExtractValue = 53,
166 LLVMInsertValue = 54,
Eli Friedman4fc946c2011-07-27 18:59:19 +0000167
168 /* Atomic operators */
Bill Wendling2641d132011-07-27 21:00:28 +0000169 LLVMFence = 55,
Eli Friedmanc9a551e2011-07-28 21:48:00 +0000170 LLVMAtomicCmpXchg = 56,
Bill Wendlingf891bf82011-07-31 06:30:59 +0000171 LLVMAtomicRMW = 57,
172
173 /* Exception Handling Operators */
Bill Wendlingfae14752011-08-12 20:24:12 +0000174 LLVMResume = 58,
David Majnemer654e1302015-07-31 17:58:14 +0000175 LLVMLandingPad = 59,
176 LLVMCleanupRet = 61,
177 LLVMCatchRet = 62,
Joseph Tremoulet9ce71f72015-09-03 09:09:43 +0000178 LLVMCatchPad = 63,
David Majnemerbbfc7212015-12-14 18:34:23 +0000179 LLVMCleanupPad = 64,
180 LLVMCatchSwitch = 65
Chris Lattner40cf28d2009-10-12 04:01:02 +0000181} LLVMOpcode;
182
183typedef enum {
Gordon Henriksen4a4d7352007-12-30 17:46:33 +0000184 LLVMVoidTypeKind, /**< type with no size */
Dan Gohman518cda42011-12-17 00:04:22 +0000185 LLVMHalfTypeKind, /**< 16 bit floating point type */
Gordon Henriksen4a4d7352007-12-30 17:46:33 +0000186 LLVMFloatTypeKind, /**< 32 bit floating point type */
187 LLVMDoubleTypeKind, /**< 64 bit floating point type */
188 LLVMX86_FP80TypeKind, /**< 80 bit floating point type (X87) */
189 LLVMFP128TypeKind, /**< 128 bit floating point type (112-bit mantissa)*/
190 LLVMPPC_FP128TypeKind, /**< 128 bit floating point type (two 64-bits) */
191 LLVMLabelTypeKind, /**< Labels */
192 LLVMIntegerTypeKind, /**< Arbitrary bit width integers */
193 LLVMFunctionTypeKind, /**< Functions */
194 LLVMStructTypeKind, /**< Structures */
195 LLVMArrayTypeKind, /**< Arrays */
196 LLVMPointerTypeKind, /**< Pointers */
Chris Lattnerdac44ec2009-07-15 22:00:31 +0000197 LLVMVectorTypeKind, /**< SIMD 'packed' format, or other vector type */
Dale Johannesenbaa5d042010-09-10 20:55:01 +0000198 LLVMMetadataTypeKind, /**< Metadata */
David Majnemerb611e3f2015-08-14 05:09:07 +0000199 LLVMX86_MMXTypeKind, /**< X86 MMX */
200 LLVMTokenTypeKind /**< Tokens */
Gordon Henriksen76a03742007-09-18 03:18:57 +0000201} LLVMTypeKind;
202
203typedef enum {
Gordon Henriksen4a4d7352007-12-30 17:46:33 +0000204 LLVMExternalLinkage, /**< Externally visible function */
Chris Lattner2dba0f02009-04-13 06:25:37 +0000205 LLVMAvailableExternallyLinkage,
Duncan Sands12da8ce2009-03-07 15:45:40 +0000206 LLVMLinkOnceAnyLinkage, /**< Keep one copy of function when linking (inline)*/
207 LLVMLinkOnceODRLinkage, /**< Same, but only replaced by something
208 equivalent. */
Rafael Espindola716e7402013-11-01 17:09:14 +0000209 LLVMLinkOnceODRAutoHideLinkage, /**< Obsolete */
Duncan Sands12da8ce2009-03-07 15:45:40 +0000210 LLVMWeakAnyLinkage, /**< Keep one copy of function when linking (weak) */
211 LLVMWeakODRLinkage, /**< Same, but only replaced by something
212 equivalent. */
Gordon Henriksen4a4d7352007-12-30 17:46:33 +0000213 LLVMAppendingLinkage, /**< Special purpose, only applies to global arrays */
214 LLVMInternalLinkage, /**< Rename collisions when linking (static
215 functions) */
Duncan Sands12da8ce2009-03-07 15:45:40 +0000216 LLVMPrivateLinkage, /**< Like Internal, but omit from symbol table */
Nico Rieck7157bb72014-01-14 15:22:47 +0000217 LLVMDLLImportLinkage, /**< Obsolete */
218 LLVMDLLExportLinkage, /**< Obsolete */
Duncan Sandse2881052009-03-11 08:08:06 +0000219 LLVMExternalWeakLinkage,/**< ExternalWeak linkage description */
Jeffrey Yasskin091217b2010-01-27 20:34:15 +0000220 LLVMGhostLinkage, /**< Obsolete */
Bill Wendling002b1672009-07-20 18:22:52 +0000221 LLVMCommonLinkage, /**< Tentative definitions */
Bill Wendling03bcd6e2010-07-01 21:55:59 +0000222 LLVMLinkerPrivateLinkage, /**< Like Private, but linker removes. */
Bill Wendling34bc34e2012-08-17 18:33:14 +0000223 LLVMLinkerPrivateWeakLinkage /**< Like LinkerPrivate, but is weak. */
Gordon Henriksen76a03742007-09-18 03:18:57 +0000224} LLVMLinkage;
225
226typedef enum {
Gordon Henriksen4a4d7352007-12-30 17:46:33 +0000227 LLVMDefaultVisibility, /**< The GV is visible */
228 LLVMHiddenVisibility, /**< The GV is hidden */
229 LLVMProtectedVisibility /**< The GV is protected */
Gordon Henriksen76a03742007-09-18 03:18:57 +0000230} LLVMVisibility;
231
Gordon Henriksenc23b66c2007-09-26 20:56:12 +0000232typedef enum {
Reid Kleckner2fae26f2014-03-05 02:34:23 +0000233 LLVMDefaultStorageClass = 0,
234 LLVMDLLImportStorageClass = 1, /**< Function to be imported from DLL. */
235 LLVMDLLExportStorageClass = 2 /**< Function to be accessible from DLL. */
236} LLVMDLLStorageClass;
237
238typedef enum {
Gordon Henriksenc23b66c2007-09-26 20:56:12 +0000239 LLVMCCallConv = 0,
240 LLVMFastCallConv = 8,
241 LLVMColdCallConv = 9,
Filip Pizlodfc9b582013-11-09 06:00:03 +0000242 LLVMWebKitJSCallConv = 12,
243 LLVMAnyRegCallConv = 13,
Gordon Henriksenc23b66c2007-09-26 20:56:12 +0000244 LLVMX86StdcallCallConv = 64,
245 LLVMX86FastcallCallConv = 65
246} LLVMCallConv;
247
248typedef enum {
Gordon Henriksen4a4d7352007-12-30 17:46:33 +0000249 LLVMIntEQ = 32, /**< equal */
250 LLVMIntNE, /**< not equal */
251 LLVMIntUGT, /**< unsigned greater than */
252 LLVMIntUGE, /**< unsigned greater or equal */
253 LLVMIntULT, /**< unsigned less than */
254 LLVMIntULE, /**< unsigned less or equal */
255 LLVMIntSGT, /**< signed greater than */
256 LLVMIntSGE, /**< signed greater or equal */
257 LLVMIntSLT, /**< signed less than */
258 LLVMIntSLE /**< signed less or equal */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +0000259} LLVMIntPredicate;
260
261typedef enum {
Gordon Henriksen4a4d7352007-12-30 17:46:33 +0000262 LLVMRealPredicateFalse, /**< Always false (always folded) */
263 LLVMRealOEQ, /**< True if ordered and equal */
264 LLVMRealOGT, /**< True if ordered and greater than */
265 LLVMRealOGE, /**< True if ordered and greater than or equal */
266 LLVMRealOLT, /**< True if ordered and less than */
267 LLVMRealOLE, /**< True if ordered and less than or equal */
268 LLVMRealONE, /**< True if ordered and operands are unequal */
269 LLVMRealORD, /**< True if ordered (no nans) */
270 LLVMRealUNO, /**< True if unordered: isnan(X) | isnan(Y) */
271 LLVMRealUEQ, /**< True if unordered or equal */
272 LLVMRealUGT, /**< True if unordered or greater than */
273 LLVMRealUGE, /**< True if unordered, greater than, or equal */
274 LLVMRealULT, /**< True if unordered or less than */
275 LLVMRealULE, /**< True if unordered, less than, or equal */
276 LLVMRealUNE, /**< True if unordered or not equal */
277 LLVMRealPredicateTrue /**< Always true (always folded) */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +0000278} LLVMRealPredicate;
279
Bill Wendlingfae14752011-08-12 20:24:12 +0000280typedef enum {
281 LLVMLandingPadCatch, /**< A catch clause */
282 LLVMLandingPadFilter /**< A filter clause */
283} LLVMLandingPadClauseTy;
284
Hans Wennborg5ff71202013-04-16 08:58:59 +0000285typedef enum {
286 LLVMNotThreadLocal = 0,
287 LLVMGeneralDynamicTLSModel,
288 LLVMLocalDynamicTLSModel,
289 LLVMInitialExecTLSModel,
290 LLVMLocalExecTLSModel
291} LLVMThreadLocalMode;
292
Carlo Kokda0ac722013-04-23 13:45:37 +0000293typedef enum {
Carlo Kok8c6719b2013-04-23 13:21:19 +0000294 LLVMAtomicOrderingNotAtomic = 0, /**< A load or store which is not atomic */
295 LLVMAtomicOrderingUnordered = 1, /**< Lowest level of atomicity, guarantees
296 somewhat sane results, lock free. */
NAKAMURA Takumia3a81352013-10-23 17:56:29 +0000297 LLVMAtomicOrderingMonotonic = 2, /**< guarantees that if you take all the
298 operations affecting a specific address,
Carlo Kok8c6719b2013-04-23 13:21:19 +0000299 a consistent ordering exists */
NAKAMURA Takumia3a81352013-10-23 17:56:29 +0000300 LLVMAtomicOrderingAcquire = 4, /**< Acquire provides a barrier of the sort
301 necessary to acquire a lock to access other
Carlo Kok8c6719b2013-04-23 13:21:19 +0000302 memory with normal loads and stores. */
NAKAMURA Takumia3a81352013-10-23 17:56:29 +0000303 LLVMAtomicOrderingRelease = 5, /**< Release is similar to Acquire, but with
304 a barrier of the sort necessary to release
Carlo Kok8c6719b2013-04-23 13:21:19 +0000305 a lock. */
NAKAMURA Takumia3a81352013-10-23 17:56:29 +0000306 LLVMAtomicOrderingAcquireRelease = 6, /**< provides both an Acquire and a
307 Release barrier (for fences and
Carlo Kok8c6719b2013-04-23 13:21:19 +0000308 operations which both read and write
309 memory). */
NAKAMURA Takumia3a81352013-10-23 17:56:29 +0000310 LLVMAtomicOrderingSequentiallyConsistent = 7 /**< provides Acquire semantics
311 for loads and Release
312 semantics for stores.
313 Additionally, it guarantees
314 that a total ordering exists
315 between all
316 SequentiallyConsistent
Carlo Kok8c6719b2013-04-23 13:21:19 +0000317 operations. */
Carlo Kokda0ac722013-04-23 13:45:37 +0000318} LLVMAtomicOrdering;
Carlo Kok8c6719b2013-04-23 13:21:19 +0000319
Carlo Kokda0ac722013-04-23 13:45:37 +0000320typedef enum {
Carlo Kok8c6719b2013-04-23 13:21:19 +0000321 LLVMAtomicRMWBinOpXchg, /**< Set the new value and return the one old */
322 LLVMAtomicRMWBinOpAdd, /**< Add a value and return the old one */
323 LLVMAtomicRMWBinOpSub, /**< Subtract a value and return the old one */
324 LLVMAtomicRMWBinOpAnd, /**< And a value and return the old one */
325 LLVMAtomicRMWBinOpNand, /**< Not-And a value and return the old one */
326 LLVMAtomicRMWBinOpOr, /**< OR a value and return the old one */
327 LLVMAtomicRMWBinOpXor, /**< Xor a value and return the old one */
328 LLVMAtomicRMWBinOpMax, /**< Sets the value if it's greater than the
NAKAMURA Takumia3a81352013-10-23 17:56:29 +0000329 original using a signed comparison and return
Carlo Kok8c6719b2013-04-23 13:21:19 +0000330 the old one */
331 LLVMAtomicRMWBinOpMin, /**< Sets the value if it's Smaller than the
NAKAMURA Takumia3a81352013-10-23 17:56:29 +0000332 original using a signed comparison and return
Carlo Kok8c6719b2013-04-23 13:21:19 +0000333 the old one */
334 LLVMAtomicRMWBinOpUMax, /**< Sets the value if it's greater than the
NAKAMURA Takumia3a81352013-10-23 17:56:29 +0000335 original using an unsigned comparison and return
Carlo Kok8c6719b2013-04-23 13:21:19 +0000336 the old one */
337 LLVMAtomicRMWBinOpUMin /**< Sets the value if it's greater than the
NAKAMURA Takumia3a81352013-10-23 17:56:29 +0000338 original using an unsigned comparison and return
Carlo Kok8c6719b2013-04-23 13:21:19 +0000339 the old one */
Carlo Kokda0ac722013-04-23 13:45:37 +0000340} LLVMAtomicRMWBinOp;
Carlo Kok8c6719b2013-04-23 13:21:19 +0000341
Tom Stellard1580dc72014-04-16 17:45:04 +0000342typedef enum {
343 LLVMDSError,
344 LLVMDSWarning,
345 LLVMDSRemark,
346 LLVMDSNote
347} LLVMDiagnosticSeverity;
348
Gregory Szorc34c863a2012-03-21 03:54:29 +0000349/**
350 * @}
351 */
352
Nick Lewycky0db26542011-05-15 07:20:34 +0000353void LLVMInitializeCore(LLVMPassRegistryRef R);
354
Duncan Sands1cba0a82013-02-17 16:35:51 +0000355/** Deallocate and destroy all ManagedStatic variables.
356 @see llvm::llvm_shutdown
357 @see ManagedStatic */
Benjamin Kramer325ec892013-10-23 16:57:34 +0000358void LLVMShutdown(void);
Duncan Sands1cba0a82013-02-17 16:35:51 +0000359
Gordon Henriksen34eb6d82007-12-19 22:30:40 +0000360/*===-- Error handling ----------------------------------------------------===*/
361
Filip Pizlo3fdbaff2013-05-22 02:46:43 +0000362char *LLVMCreateMessage(const char *Message);
Gordon Henriksen34eb6d82007-12-19 22:30:40 +0000363void LLVMDisposeMessage(char *Message);
364
Filip Pizlo9f50ccd2013-11-03 00:29:47 +0000365/**
Gregory Szorc34c863a2012-03-21 03:54:29 +0000366 * @defgroup LLVMCCoreContext Contexts
367 *
368 * Contexts are execution states for the core LLVM IR system.
369 *
370 * Most types are tied to a context instance. Multiple contexts can
371 * exist simultaneously. A single context is not thread safe. However,
372 * different contexts can execute on different threads simultaneously.
373 *
374 * @{
375 */
Gordon Henriksen76a03742007-09-18 03:18:57 +0000376
Tom Stellard1580dc72014-04-16 17:45:04 +0000377typedef void (*LLVMDiagnosticHandler)(LLVMDiagnosticInfoRef, void *);
Juergen Ributzka34390c72014-05-16 02:33:15 +0000378typedef void (*LLVMYieldCallback)(LLVMContextRef, void *);
Tom Stellard1580dc72014-04-16 17:45:04 +0000379
Gregory Szorc34c863a2012-03-21 03:54:29 +0000380/**
381 * Create a new context.
382 *
383 * Every call to this function should be paired with a call to
384 * LLVMContextDispose() or the context will leak memory.
385 */
Erick Tryzelaarf34cb0c2009-08-30 23:38:06 +0000386LLVMContextRef LLVMContextCreate(void);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000387
388/**
389 * Obtain the global context instance.
390 */
Erick Tryzelaarf34cb0c2009-08-30 23:38:06 +0000391LLVMContextRef LLVMGetGlobalContext(void);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000392
393/**
Tom Stellard1580dc72014-04-16 17:45:04 +0000394 * Set the diagnostic handler for this context.
395 */
396void LLVMContextSetDiagnosticHandler(LLVMContextRef C,
397 LLVMDiagnosticHandler Handler,
398 void *DiagnosticContext);
399
400/**
Juergen Ributzka34390c72014-05-16 02:33:15 +0000401 * Set the yield callback function for this context.
402 *
403 * @see LLVMContext::setYieldCallback()
404 */
405void LLVMContextSetYieldCallback(LLVMContextRef C, LLVMYieldCallback Callback,
406 void *OpaqueHandle);
407
408/**
Gregory Szorc34c863a2012-03-21 03:54:29 +0000409 * Destroy a context instance.
410 *
411 * This should be called for every call to LLVMContextCreate() or memory
412 * will be leaked.
413 */
Owen Anderson6773d382009-07-01 16:58:40 +0000414void LLVMContextDispose(LLVMContextRef C);
415
Tom Stellard1580dc72014-04-16 17:45:04 +0000416/**
417 * Return a string representation of the DiagnosticInfo. Use
418 * LLVMDisposeMessage to free the string.
419 *
420 * @see DiagnosticInfo::print()
421 */
422char *LLVMGetDiagInfoDescription(LLVMDiagnosticInfoRef DI);
423
424/**
425 * Return an enum LLVMDiagnosticSeverity.
426 *
427 * @see DiagnosticInfo::getSeverity()
428 */
429LLVMDiagnosticSeverity LLVMGetDiagInfoSeverity(LLVMDiagnosticInfoRef DI);
430
Erick Tryzelaard8531fa2010-02-28 09:45:59 +0000431unsigned LLVMGetMDKindIDInContext(LLVMContextRef C, const char* Name,
432 unsigned SLen);
433unsigned LLVMGetMDKindID(const char* Name, unsigned SLen);
434
Gregory Szorc34c863a2012-03-21 03:54:29 +0000435/**
436 * @}
437 */
438
Gregory Szorc52d26602012-03-21 07:28:27 +0000439/**
440 * @defgroup LLVMCCoreModule Modules
Gregory Szorc34c863a2012-03-21 03:54:29 +0000441 *
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +0000442 * Modules represent the top-level structure in an LLVM program. An LLVM
Gregory Szorc34c863a2012-03-21 03:54:29 +0000443 * module is effectively a translation unit or a collection of
444 * translation units merged together.
445 *
446 * @{
447 */
448
Gregory Szorc34c863a2012-03-21 03:54:29 +0000449/**
450 * Create a new, empty module in the global context.
451 *
452 * This is equivalent to calling LLVMModuleCreateWithNameInContext with
453 * LLVMGetGlobalContext() as the context parameter.
454 *
455 * Every invocation should be paired with LLVMDisposeModule() or memory
456 * will be leaked.
457 */
Gordon Henriksen76a03742007-09-18 03:18:57 +0000458LLVMModuleRef LLVMModuleCreateWithName(const char *ModuleID);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000459
460/**
461 * Create a new, empty module in a specific context.
462 *
463 * Every invocation should be paired with LLVMDisposeModule() or memory
464 * will be leaked.
465 */
Owen Anderson31d44e42009-07-02 07:17:57 +0000466LLVMModuleRef LLVMModuleCreateWithNameInContext(const char *ModuleID,
467 LLVMContextRef C);
Tom Stellard0a4e9a32014-10-01 17:14:57 +0000468/**
469 * Return an exact copy of the specified module.
470 */
471LLVMModuleRef LLVMCloneModule(LLVMModuleRef M);
Gordon Henriksena49d4352008-03-07 19:13:06 +0000472
Gregory Szorc34c863a2012-03-21 03:54:29 +0000473/**
474 * Destroy a module instance.
475 *
476 * This must be called for every created module or memory will be
477 * leaked.
478 */
Gordon Henriksen76a03742007-09-18 03:18:57 +0000479void LLVMDisposeModule(LLVMModuleRef M);
480
Gregory Szorc34c863a2012-03-21 03:54:29 +0000481/**
482 * Obtain the data layout for a module.
483 *
Amaury Sechetf3549c42016-02-16 00:23:52 +0000484 * @see Module::getDataLayoutStr()
485 *
486 * LLVMGetDataLayout is DEPRECATED, as the name is not only incorrect,
487 * but match the name of another method on the module. Prefer the use
488 * of LLVMGetDataLayoutStr, which is not ambiguous.
Gregory Szorc34c863a2012-03-21 03:54:29 +0000489 */
Amaury Sechetf3549c42016-02-16 00:23:52 +0000490const char *LLVMGetDataLayoutStr(LLVMModuleRef M);
Gordon Henriksen05568bb2007-12-27 20:13:47 +0000491const char *LLVMGetDataLayout(LLVMModuleRef M);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000492
493/**
494 * Set the data layout for a module.
495 *
496 * @see Module::setDataLayout()
497 */
Amaury Sechet6ada31c2016-02-15 23:40:06 +0000498void LLVMSetDataLayout(LLVMModuleRef M, const char *DataLayoutStr);
Gordon Henriksen05568bb2007-12-27 20:13:47 +0000499
Gregory Szorc34c863a2012-03-21 03:54:29 +0000500/**
501 * Obtain the target triple for a module.
502 *
503 * @see Module::getTargetTriple()
504 */
Gordon Henriksen05568bb2007-12-27 20:13:47 +0000505const char *LLVMGetTarget(LLVMModuleRef M);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000506
507/**
508 * Set the target triple for a module.
509 *
510 * @see Module::setTargetTriple()
511 */
Gordon Henriksen05568bb2007-12-27 20:13:47 +0000512void LLVMSetTarget(LLVMModuleRef M, const char *Triple);
513
Gregory Szorc34c863a2012-03-21 03:54:29 +0000514/**
515 * Dump a representation of a module to stderr.
516 *
517 * @see Module::dump()
518 */
Gordon Henriksen6c6075e2008-03-14 23:58:56 +0000519void LLVMDumpModule(LLVMModuleRef M);
520
Gregory Szorc34c863a2012-03-21 03:54:29 +0000521/**
Hans Wennborgb7ef2fe2012-05-09 16:54:17 +0000522 * Print a representation of a module to a file. The ErrorMessage needs to be
523 * disposed with LLVMDisposeMessage. Returns 0 on success, 1 otherwise.
524 *
525 * @see Module::print()
526 */
527LLVMBool LLVMPrintModuleToFile(LLVMModuleRef M, const char *Filename,
528 char **ErrorMessage);
529
530/**
Anders Waldenborg84355db2013-10-16 18:00:54 +0000531 * Return a string representation of the module. Use
532 * LLVMDisposeMessage to free the string.
533 *
534 * @see Module::print()
535 */
536char *LLVMPrintModuleToString(LLVMModuleRef M);
537
538/**
Gregory Szorc34c863a2012-03-21 03:54:29 +0000539 * Set inline assembly for a module.
540 *
541 * @see Module::setModuleInlineAsm()
542 */
Chris Lattner26941452010-04-10 17:52:58 +0000543void LLVMSetModuleInlineAsm(LLVMModuleRef M, const char *Asm);
Gordon Henriksen76a03742007-09-18 03:18:57 +0000544
Gregory Szorc34c863a2012-03-21 03:54:29 +0000545/**
546 * Obtain the context to which this module is associated.
547 *
548 * @see Module::getContext()
549 */
Chris Lattnera7e04b02010-11-28 20:03:44 +0000550LLVMContextRef LLVMGetModuleContext(LLVMModuleRef M);
551
Gregory Szorc34c863a2012-03-21 03:54:29 +0000552/**
553 * Obtain a Type from a module by its registered name.
554 */
555LLVMTypeRef LLVMGetTypeByName(LLVMModuleRef M, const char *Name);
Gordon Henriksen76a03742007-09-18 03:18:57 +0000556
Gregory Szorc34c863a2012-03-21 03:54:29 +0000557/**
558 * Obtain the number of operands for named metadata in a module.
559 *
560 * @see llvm::Module::getNamedMetadata()
561 */
562unsigned LLVMGetNamedMetadataNumOperands(LLVMModuleRef M, const char* name);
563
564/**
565 * Obtain the named metadata operands for a module.
566 *
567 * The passed LLVMValueRef pointer should refer to an array of
568 * LLVMValueRef at least LLVMGetNamedMetadataNumOperands long. This
569 * array will be populated with the LLVMValueRef instances. Each
570 * instance corresponds to a llvm::MDNode.
571 *
572 * @see llvm::Module::getNamedMetadata()
573 * @see llvm::MDNode::getOperand()
574 */
575void LLVMGetNamedMetadataOperands(LLVMModuleRef M, const char* name, LLVMValueRef *Dest);
576
577/**
578 * Add an operand to named metadata.
579 *
580 * @see llvm::Module::getNamedMetadata()
581 * @see llvm::MDNode::addOperand()
582 */
583void LLVMAddNamedMetadataOperand(LLVMModuleRef M, const char* name,
584 LLVMValueRef Val);
585
Gregory Szorc52d26602012-03-21 07:28:27 +0000586/**
587 * Add a function to a module under a specified name.
588 *
589 * @see llvm::Function::Create()
590 */
591LLVMValueRef LLVMAddFunction(LLVMModuleRef M, const char *Name,
592 LLVMTypeRef FunctionTy);
593
594/**
595 * Obtain a Function value from a Module by its name.
596 *
597 * The returned value corresponds to a llvm::Function value.
598 *
599 * @see llvm::Module::getFunction()
600 */
601LLVMValueRef LLVMGetNamedFunction(LLVMModuleRef M, const char *Name);
602
603/**
604 * Obtain an iterator to the first Function in a Module.
605 *
606 * @see llvm::Module::begin()
607 */
608LLVMValueRef LLVMGetFirstFunction(LLVMModuleRef M);
609
610/**
611 * Obtain an iterator to the last Function in a Module.
612 *
613 * @see llvm::Module::end()
614 */
615LLVMValueRef LLVMGetLastFunction(LLVMModuleRef M);
616
617/**
618 * Advance a Function iterator to the next Function.
619 *
620 * Returns NULL if the iterator was already at the end and there are no more
621 * functions.
622 */
623LLVMValueRef LLVMGetNextFunction(LLVMValueRef Fn);
624
625/**
626 * Decrement a Function iterator to the previous Function.
627 *
628 * Returns NULL if the iterator was already at the beginning and there are
629 * no previous functions.
630 */
631LLVMValueRef LLVMGetPreviousFunction(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000632
633/**
634 * @}
635 */
636
637/**
638 * @defgroup LLVMCCoreType Types
639 *
640 * Types represent the type of a value.
641 *
642 * Types are associated with a context instance. The context internally
643 * deduplicates types so there is only 1 instance of a specific type
644 * alive at a time. In other words, a unique type is shared among all
645 * consumers within a context.
646 *
647 * A Type in the C API corresponds to llvm::Type.
648 *
649 * Types have the following hierarchy:
650 *
Gordon Henriksen76a03742007-09-18 03:18:57 +0000651 * types:
652 * integer type
653 * real type
654 * function type
655 * sequence types:
656 * array type
657 * pointer type
658 * vector type
659 * void type
660 * label type
661 * opaque type
Gregory Szorc34c863a2012-03-21 03:54:29 +0000662 *
663 * @{
Gordon Henriksen76a03742007-09-18 03:18:57 +0000664 */
665
Gregory Szorc34c863a2012-03-21 03:54:29 +0000666/**
667 * Obtain the enumerated type of a Type instance.
668 *
669 * @see llvm::Type:getTypeID()
670 */
Gordon Henriksen76a03742007-09-18 03:18:57 +0000671LLVMTypeKind LLVMGetTypeKind(LLVMTypeRef Ty);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000672
673/**
674 * Whether the type has a known size.
675 *
676 * Things that don't have a size are abstract types, labels, and void.a
677 *
678 * @see llvm::Type::isSized()
679 */
Torok Edwin1cd9ade2011-10-06 12:13:28 +0000680LLVMBool LLVMTypeIsSized(LLVMTypeRef Ty);
Gordon Henriksena49d4352008-03-07 19:13:06 +0000681
Gregory Szorc34c863a2012-03-21 03:54:29 +0000682/**
683 * Obtain the context to which this type instance is associated.
684 *
685 * @see llvm::Type::getContext()
686 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +0000687LLVMContextRef LLVMGetTypeContext(LLVMTypeRef Ty);
688
Gregory Szorc34c863a2012-03-21 03:54:29 +0000689/**
Anders Waldenborgb822cff2013-10-16 21:30:25 +0000690 * Dump a representation of a type to stderr.
691 *
692 * @see llvm::Type::dump()
693 */
694void LLVMDumpType(LLVMTypeRef Val);
695
696/**
Anders Waldenborg47b3bd32013-10-22 06:58:34 +0000697 * Return a string representation of the type. Use
698 * LLVMDisposeMessage to free the string.
699 *
700 * @see llvm::Type::print()
701 */
702char *LLVMPrintTypeToString(LLVMTypeRef Val);
703
704/**
Gregory Szorc34c863a2012-03-21 03:54:29 +0000705 * @defgroup LLVMCCoreTypeInt Integer Types
706 *
707 * Functions in this section operate on integer types.
708 *
709 * @{
710 */
711
712/**
713 * Obtain an integer type from a context with specified bit width.
714 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +0000715LLVMTypeRef LLVMInt1TypeInContext(LLVMContextRef C);
716LLVMTypeRef LLVMInt8TypeInContext(LLVMContextRef C);
717LLVMTypeRef LLVMInt16TypeInContext(LLVMContextRef C);
718LLVMTypeRef LLVMInt32TypeInContext(LLVMContextRef C);
719LLVMTypeRef LLVMInt64TypeInContext(LLVMContextRef C);
Eugene Zelenkoffec81c2015-11-04 22:32:32 +0000720LLVMTypeRef LLVMInt128TypeInContext(LLVMContextRef C);
Erick Tryzelaar262332f2009-08-14 00:01:31 +0000721LLVMTypeRef LLVMIntTypeInContext(LLVMContextRef C, unsigned NumBits);
722
Gregory Szorc34c863a2012-03-21 03:54:29 +0000723/**
724 * Obtain an integer type from the global context with a specified bit
725 * width.
726 */
Gordon Henriksena735a9c2008-05-04 12:55:34 +0000727LLVMTypeRef LLVMInt1Type(void);
728LLVMTypeRef LLVMInt8Type(void);
729LLVMTypeRef LLVMInt16Type(void);
730LLVMTypeRef LLVMInt32Type(void);
731LLVMTypeRef LLVMInt64Type(void);
Eugene Zelenkoffec81c2015-11-04 22:32:32 +0000732LLVMTypeRef LLVMInt128Type(void);
Gordon Henriksened7beaa2007-10-06 16:05:20 +0000733LLVMTypeRef LLVMIntType(unsigned NumBits);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +0000734unsigned LLVMGetIntTypeWidth(LLVMTypeRef IntegerTy);
Gordon Henriksen76a03742007-09-18 03:18:57 +0000735
Gregory Szorc34c863a2012-03-21 03:54:29 +0000736/**
737 * @}
738 */
739
740/**
741 * @defgroup LLVMCCoreTypeFloat Floating Point Types
742 *
743 * @{
744 */
745
746/**
747 * Obtain a 16-bit floating point type from a context.
748 */
Dan Gohman518cda42011-12-17 00:04:22 +0000749LLVMTypeRef LLVMHalfTypeInContext(LLVMContextRef C);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000750
751/**
752 * Obtain a 32-bit floating point type from a context.
753 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +0000754LLVMTypeRef LLVMFloatTypeInContext(LLVMContextRef C);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000755
756/**
757 * Obtain a 64-bit floating point type from a context.
758 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +0000759LLVMTypeRef LLVMDoubleTypeInContext(LLVMContextRef C);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000760
761/**
762 * Obtain a 80-bit floating point type (X87) from a context.
763 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +0000764LLVMTypeRef LLVMX86FP80TypeInContext(LLVMContextRef C);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000765
766/**
767 * Obtain a 128-bit floating point type (112-bit mantissa) from a
768 * context.
769 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +0000770LLVMTypeRef LLVMFP128TypeInContext(LLVMContextRef C);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000771
772/**
773 * Obtain a 128-bit floating point type (two 64-bits) from a context.
774 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +0000775LLVMTypeRef LLVMPPCFP128TypeInContext(LLVMContextRef C);
776
Gregory Szorc34c863a2012-03-21 03:54:29 +0000777/**
778 * Obtain a floating point type from the global context.
779 *
780 * These map to the functions in this group of the same name.
781 */
Dan Gohman518cda42011-12-17 00:04:22 +0000782LLVMTypeRef LLVMHalfType(void);
Gordon Henriksena735a9c2008-05-04 12:55:34 +0000783LLVMTypeRef LLVMFloatType(void);
784LLVMTypeRef LLVMDoubleType(void);
785LLVMTypeRef LLVMX86FP80Type(void);
786LLVMTypeRef LLVMFP128Type(void);
787LLVMTypeRef LLVMPPCFP128Type(void);
Gordon Henriksen76a03742007-09-18 03:18:57 +0000788
Gregory Szorc34c863a2012-03-21 03:54:29 +0000789/**
790 * @}
791 */
792
793/**
794 * @defgroup LLVMCCoreTypeFunction Function Types
795 *
796 * @{
797 */
798
799/**
800 * Obtain a function type consisting of a specified signature.
801 *
802 * The function is defined as a tuple of a return Type, a list of
803 * parameter types, and whether the function is variadic.
804 */
Gordon Henriksened7beaa2007-10-06 16:05:20 +0000805LLVMTypeRef LLVMFunctionType(LLVMTypeRef ReturnType,
806 LLVMTypeRef *ParamTypes, unsigned ParamCount,
Chris Lattner25963c62010-01-09 22:27:07 +0000807 LLVMBool IsVarArg);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000808
809/**
810 * Returns whether a function type is variadic.
811 */
Chris Lattner25963c62010-01-09 22:27:07 +0000812LLVMBool LLVMIsFunctionVarArg(LLVMTypeRef FunctionTy);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000813
814/**
815 * Obtain the Type this function Type returns.
816 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +0000817LLVMTypeRef LLVMGetReturnType(LLVMTypeRef FunctionTy);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000818
819/**
820 * Obtain the number of parameters this function accepts.
821 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +0000822unsigned LLVMCountParamTypes(LLVMTypeRef FunctionTy);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000823
824/**
825 * Obtain the types of a function's parameters.
826 *
827 * The Dest parameter should point to a pre-allocated array of
828 * LLVMTypeRef at least LLVMCountParamTypes() large. On return, the
829 * first LLVMCountParamTypes() entries in the array will be populated
830 * with LLVMTypeRef instances.
831 *
832 * @param FunctionTy The function type to operate on.
833 * @param Dest Memory address of an array to be filled with result.
834 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +0000835void LLVMGetParamTypes(LLVMTypeRef FunctionTy, LLVMTypeRef *Dest);
Gordon Henriksen76a03742007-09-18 03:18:57 +0000836
Gregory Szorc34c863a2012-03-21 03:54:29 +0000837/**
838 * @}
839 */
840
841/**
842 * @defgroup LLVMCCoreTypeStruct Structure Types
843 *
844 * These functions relate to LLVMTypeRef instances.
845 *
846 * @see llvm::StructType
847 *
848 * @{
849 */
850
851/**
852 * Create a new structure type in a context.
853 *
854 * A structure is specified by a list of inner elements/types and
855 * whether these can be packed together.
856 *
857 * @see llvm::StructType::create()
858 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +0000859LLVMTypeRef LLVMStructTypeInContext(LLVMContextRef C, LLVMTypeRef *ElementTypes,
Chris Lattner25963c62010-01-09 22:27:07 +0000860 unsigned ElementCount, LLVMBool Packed);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000861
862/**
863 * Create a new structure type in the global context.
864 *
865 * @see llvm::StructType::create()
866 */
Gordon Henriksened7beaa2007-10-06 16:05:20 +0000867LLVMTypeRef LLVMStructType(LLVMTypeRef *ElementTypes, unsigned ElementCount,
Chris Lattner25963c62010-01-09 22:27:07 +0000868 LLVMBool Packed);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000869
870/**
871 * Create an empty structure in a context having a specified name.
872 *
873 * @see llvm::StructType::create()
874 */
Chris Lattnere71ccde2011-07-14 05:53:17 +0000875LLVMTypeRef LLVMStructCreateNamed(LLVMContextRef C, const char *Name);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000876
877/**
878 * Obtain the name of a structure.
879 *
880 * @see llvm::StructType::getName()
881 */
Torok Edwin0d5f6ae2011-10-06 12:12:50 +0000882const char *LLVMGetStructName(LLVMTypeRef Ty);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000883
884/**
885 * Set the contents of a structure type.
886 *
887 * @see llvm::StructType::setBody()
888 */
Chris Lattnere71ccde2011-07-14 05:53:17 +0000889void LLVMStructSetBody(LLVMTypeRef StructTy, LLVMTypeRef *ElementTypes,
890 unsigned ElementCount, LLVMBool Packed);
891
Gregory Szorc34c863a2012-03-21 03:54:29 +0000892/**
893 * Get the number of elements defined inside the structure.
894 *
895 * @see llvm::StructType::getNumElements()
896 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +0000897unsigned LLVMCountStructElementTypes(LLVMTypeRef StructTy);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000898
899/**
900 * Get the elements within a structure.
901 *
902 * The function is passed the address of a pre-allocated array of
903 * LLVMTypeRef at least LLVMCountStructElementTypes() long. After
904 * invocation, this array will be populated with the structure's
905 * elements. The objects in the destination array will have a lifetime
906 * of the structure type itself, which is the lifetime of the context it
907 * is contained in.
908 */
Gordon Henriksen76a03742007-09-18 03:18:57 +0000909void LLVMGetStructElementTypes(LLVMTypeRef StructTy, LLVMTypeRef *Dest);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000910
911/**
Peter Zotovc164a3f2015-06-04 09:09:53 +0000912 * Get the type of the element at a given index in the structure.
913 *
914 * @see llvm::StructType::getTypeAtIndex()
915 */
916LLVMTypeRef LLVMStructGetTypeAtIndex(LLVMTypeRef StructTy, unsigned i);
917
918/**
Gregory Szorc34c863a2012-03-21 03:54:29 +0000919 * Determine whether a structure is packed.
920 *
921 * @see llvm::StructType::isPacked()
922 */
Chris Lattner25963c62010-01-09 22:27:07 +0000923LLVMBool LLVMIsPackedStruct(LLVMTypeRef StructTy);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000924
925/**
926 * Determine whether a structure is opaque.
927 *
928 * @see llvm::StructType::isOpaque()
929 */
Chris Lattner17cf05b2011-07-14 16:20:28 +0000930LLVMBool LLVMIsOpaqueStruct(LLVMTypeRef StructTy);
931
Gregory Szorc34c863a2012-03-21 03:54:29 +0000932/**
933 * @}
934 */
Gordon Henriksen76a03742007-09-18 03:18:57 +0000935
Gregory Szorc34c863a2012-03-21 03:54:29 +0000936/**
937 * @defgroup LLVMCCoreTypeSequential Sequential Types
938 *
939 * Sequential types represents "arrays" of types. This is a super class
940 * for array, vector, and pointer types.
941 *
942 * @{
943 */
944
945/**
946 * Obtain the type of elements within a sequential type.
947 *
948 * This works on array, vector, and pointer types.
949 *
950 * @see llvm::SequentialType::getElementType()
951 */
952LLVMTypeRef LLVMGetElementType(LLVMTypeRef Ty);
953
954/**
955 * Create a fixed size array type that refers to a specific type.
956 *
957 * The created type will exist in the context that its element type
958 * exists in.
959 *
960 * @see llvm::ArrayType::get()
961 */
Gordon Henriksened7beaa2007-10-06 16:05:20 +0000962LLVMTypeRef LLVMArrayType(LLVMTypeRef ElementType, unsigned ElementCount);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000963
964/**
965 * Obtain the length of an array type.
966 *
967 * This only works on types that represent arrays.
968 *
969 * @see llvm::ArrayType::getNumElements()
970 */
971unsigned LLVMGetArrayLength(LLVMTypeRef ArrayTy);
972
973/**
974 * Create a pointer type that points to a defined type.
975 *
976 * The created type will exist in the context that its pointee type
977 * exists in.
978 *
979 * @see llvm::PointerType::get()
980 */
Gordon Henriksen5a3fe032007-12-17 16:08:32 +0000981LLVMTypeRef LLVMPointerType(LLVMTypeRef ElementType, unsigned AddressSpace);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000982
983/**
984 * Obtain the address space of a pointer type.
985 *
986 * This only works on types that represent pointers.
987 *
988 * @see llvm::PointerType::getAddressSpace()
989 */
990unsigned LLVMGetPointerAddressSpace(LLVMTypeRef PointerTy);
991
992/**
993 * Create a vector type that contains a defined type and has a specific
994 * number of elements.
995 *
996 * The created type will exist in the context thats its element type
997 * exists in.
998 *
999 * @see llvm::VectorType::get()
1000 */
Gordon Henriksened7beaa2007-10-06 16:05:20 +00001001LLVMTypeRef LLVMVectorType(LLVMTypeRef ElementType, unsigned ElementCount);
Gordon Henriksen76a03742007-09-18 03:18:57 +00001002
Gregory Szorc34c863a2012-03-21 03:54:29 +00001003/**
1004 * Obtain the number of elements in a vector type.
1005 *
1006 * This only works on types that represent vectors.
1007 *
1008 * @see llvm::VectorType::getNumElements()
1009 */
Gordon Henriksen76a03742007-09-18 03:18:57 +00001010unsigned LLVMGetVectorSize(LLVMTypeRef VectorTy);
1011
Gregory Szorc34c863a2012-03-21 03:54:29 +00001012/**
1013 * @}
1014 */
1015
1016/**
1017 * @defgroup LLVMCCoreTypeOther Other Types
1018 *
1019 * @{
1020 */
1021
1022/**
1023 * Create a void type in a context.
1024 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +00001025LLVMTypeRef LLVMVoidTypeInContext(LLVMContextRef C);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001026
1027/**
1028 * Create a label type in a context.
1029 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +00001030LLVMTypeRef LLVMLabelTypeInContext(LLVMContextRef C);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001031
1032/**
1033 * Create a X86 MMX type in a context.
1034 */
Dale Johannesen95b67af2010-09-10 21:58:02 +00001035LLVMTypeRef LLVMX86MMXTypeInContext(LLVMContextRef C);
Erick Tryzelaar262332f2009-08-14 00:01:31 +00001036
Gregory Szorc34c863a2012-03-21 03:54:29 +00001037/**
1038 * These are similar to the above functions except they operate on the
1039 * global context.
1040 */
Gordon Henriksena735a9c2008-05-04 12:55:34 +00001041LLVMTypeRef LLVMVoidType(void);
1042LLVMTypeRef LLVMLabelType(void);
Dale Johannesen95b67af2010-09-10 21:58:02 +00001043LLVMTypeRef LLVMX86MMXType(void);
Gordon Henriksen76a03742007-09-18 03:18:57 +00001044
Gregory Szorc34c863a2012-03-21 03:54:29 +00001045/**
1046 * @}
1047 */
Gordon Henriksen76a03742007-09-18 03:18:57 +00001048
Gregory Szorc34c863a2012-03-21 03:54:29 +00001049/**
1050 * @}
1051 */
1052
1053/**
1054 * @defgroup LLVMCCoreValues Values
1055 *
1056 * The bulk of LLVM's object model consists of values, which comprise a very
Gordon Henriksen76a03742007-09-18 03:18:57 +00001057 * rich type hierarchy.
Gregory Szorc34c863a2012-03-21 03:54:29 +00001058 *
1059 * LLVMValueRef essentially represents llvm::Value. There is a rich
1060 * hierarchy of classes within this type. Depending on the instance
Eli Benderskyc52863c2012-08-10 18:30:44 +00001061 * obtained, not all APIs are available.
Gregory Szorc34c863a2012-03-21 03:54:29 +00001062 *
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00001063 * Callers can determine the type of an LLVMValueRef by calling the
Gregory Szorc34c863a2012-03-21 03:54:29 +00001064 * LLVMIsA* family of functions (e.g. LLVMIsAArgument()). These
1065 * functions are defined by a macro, so it isn't obvious which are
1066 * available by looking at the Doxygen source code. Instead, look at the
1067 * source definition of LLVM_FOR_EACH_VALUE_SUBCLASS and note the list
1068 * of value names given. These value names also correspond to classes in
1069 * the llvm::Value hierarchy.
1070 *
1071 * @{
Gordon Henriksen76a03742007-09-18 03:18:57 +00001072 */
1073
Gordon Henriksen29e38942008-12-19 18:39:45 +00001074#define LLVM_FOR_EACH_VALUE_SUBCLASS(macro) \
1075 macro(Argument) \
1076 macro(BasicBlock) \
1077 macro(InlineAsm) \
1078 macro(User) \
1079 macro(Constant) \
Torok Edwind09b7572011-10-14 20:37:56 +00001080 macro(BlockAddress) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001081 macro(ConstantAggregateZero) \
1082 macro(ConstantArray) \
Peter Zotovae0344b2013-11-05 12:55:37 +00001083 macro(ConstantDataSequential) \
1084 macro(ConstantDataArray) \
1085 macro(ConstantDataVector) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001086 macro(ConstantExpr) \
1087 macro(ConstantFP) \
1088 macro(ConstantInt) \
1089 macro(ConstantPointerNull) \
1090 macro(ConstantStruct) \
David Majnemerf0f224d2015-11-11 21:57:16 +00001091 macro(ConstantTokenNone) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001092 macro(ConstantVector) \
1093 macro(GlobalValue) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001094 macro(GlobalAlias) \
Rafael Espindola99e05cf2014-05-13 18:45:48 +00001095 macro(GlobalObject) \
1096 macro(Function) \
1097 macro(GlobalVariable) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001098 macro(UndefValue) \
1099 macro(Instruction) \
1100 macro(BinaryOperator) \
1101 macro(CallInst) \
1102 macro(IntrinsicInst) \
1103 macro(DbgInfoIntrinsic) \
1104 macro(DbgDeclareInst) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001105 macro(MemIntrinsic) \
1106 macro(MemCpyInst) \
1107 macro(MemMoveInst) \
1108 macro(MemSetInst) \
1109 macro(CmpInst) \
Torok Edwind09b7572011-10-14 20:37:56 +00001110 macro(FCmpInst) \
1111 macro(ICmpInst) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001112 macro(ExtractElementInst) \
1113 macro(GetElementPtrInst) \
1114 macro(InsertElementInst) \
1115 macro(InsertValueInst) \
Bill Wendlingfae14752011-08-12 20:24:12 +00001116 macro(LandingPadInst) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001117 macro(PHINode) \
1118 macro(SelectInst) \
1119 macro(ShuffleVectorInst) \
1120 macro(StoreInst) \
1121 macro(TerminatorInst) \
1122 macro(BranchInst) \
Torok Edwind09b7572011-10-14 20:37:56 +00001123 macro(IndirectBrInst) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001124 macro(InvokeInst) \
1125 macro(ReturnInst) \
1126 macro(SwitchInst) \
1127 macro(UnreachableInst) \
Bill Wendlingf891bf82011-07-31 06:30:59 +00001128 macro(ResumeInst) \
David Majnemer654e1302015-07-31 17:58:14 +00001129 macro(CleanupReturnInst) \
1130 macro(CatchReturnInst) \
David Majnemer8a1c45d2015-12-12 05:38:55 +00001131 macro(FuncletPadInst) \
1132 macro(CatchPadInst) \
1133 macro(CleanupPadInst) \
Duncan Sands5e37e992013-05-06 08:55:45 +00001134 macro(UnaryInstruction) \
1135 macro(AllocaInst) \
1136 macro(CastInst) \
Matt Arsenaultb03bd4d2013-11-15 01:34:59 +00001137 macro(AddrSpaceCastInst) \
Duncan Sands5e37e992013-05-06 08:55:45 +00001138 macro(BitCastInst) \
1139 macro(FPExtInst) \
1140 macro(FPToSIInst) \
1141 macro(FPToUIInst) \
1142 macro(FPTruncInst) \
1143 macro(IntToPtrInst) \
1144 macro(PtrToIntInst) \
1145 macro(SExtInst) \
1146 macro(SIToFPInst) \
1147 macro(TruncInst) \
1148 macro(UIToFPInst) \
1149 macro(ZExtInst) \
1150 macro(ExtractValueInst) \
1151 macro(LoadInst) \
1152 macro(VAArgInst)
Gordon Henriksen29e38942008-12-19 18:39:45 +00001153
Gregory Szorc34c863a2012-03-21 03:54:29 +00001154/**
1155 * @defgroup LLVMCCoreValueGeneral General APIs
1156 *
1157 * Functions in this section work on all LLVMValueRef instances,
1158 * regardless of their sub-type. They correspond to functions available
1159 * on llvm::Value.
1160 *
1161 * @{
1162 */
Gordon Henriksen76a03742007-09-18 03:18:57 +00001163
Gregory Szorc34c863a2012-03-21 03:54:29 +00001164/**
1165 * Obtain the type of a value.
1166 *
1167 * @see llvm::Value::getType()
1168 */
1169LLVMTypeRef LLVMTypeOf(LLVMValueRef Val);
1170
1171/**
1172 * Obtain the string name of a value.
1173 *
1174 * @see llvm::Value::getName()
1175 */
1176const char *LLVMGetValueName(LLVMValueRef Val);
1177
1178/**
1179 * Set the string name of a value.
1180 *
1181 * @see llvm::Value::setName()
1182 */
1183void LLVMSetValueName(LLVMValueRef Val, const char *Name);
1184
1185/**
1186 * Dump a representation of a value to stderr.
1187 *
1188 * @see llvm::Value::dump()
1189 */
1190void LLVMDumpValue(LLVMValueRef Val);
1191
1192/**
Peter Zotovcd93b372013-11-06 09:21:01 +00001193 * Return a string representation of the value. Use
1194 * LLVMDisposeMessage to free the string.
1195 *
1196 * @see llvm::Value::print()
1197 */
1198char *LLVMPrintValueToString(LLVMValueRef Val);
1199
1200/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00001201 * Replace all uses of a value with another one.
1202 *
1203 * @see llvm::Value::replaceAllUsesWith()
1204 */
1205void LLVMReplaceAllUsesWith(LLVMValueRef OldVal, LLVMValueRef NewVal);
1206
1207/**
Amaury Sechet1c395072016-01-18 01:06:52 +00001208 * Determine whether the specified value instance is constant.
Gregory Szorc34c863a2012-03-21 03:54:29 +00001209 */
1210LLVMBool LLVMIsConstant(LLVMValueRef Val);
1211
1212/**
1213 * Determine whether a value instance is undefined.
1214 */
1215LLVMBool LLVMIsUndef(LLVMValueRef Val);
1216
1217/**
1218 * Convert value instances between types.
1219 *
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00001220 * Internally, an LLVMValueRef is "pinned" to a specific type. This
Gregory Szorc34c863a2012-03-21 03:54:29 +00001221 * series of functions allows you to cast an instance to a specific
1222 * type.
1223 *
1224 * If the cast is not valid for the specified type, NULL is returned.
1225 *
1226 * @see llvm::dyn_cast_or_null<>
1227 */
Gordon Henriksen29e38942008-12-19 18:39:45 +00001228#define LLVM_DECLARE_VALUE_CAST(name) \
1229 LLVMValueRef LLVMIsA##name(LLVMValueRef Val);
1230LLVM_FOR_EACH_VALUE_SUBCLASS(LLVM_DECLARE_VALUE_CAST)
1231
Duncan P. N. Exon Smith5bf8fef2014-12-09 18:38:53 +00001232LLVMValueRef LLVMIsAMDNode(LLVMValueRef Val);
1233LLVMValueRef LLVMIsAMDString(LLVMValueRef Val);
1234
Gregory Szorc34c863a2012-03-21 03:54:29 +00001235/**
1236 * @}
1237 */
1238
1239/**
1240 * @defgroup LLVMCCoreValueUses Usage
1241 *
1242 * This module defines functions that allow you to inspect the uses of a
1243 * LLVMValueRef.
1244 *
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00001245 * It is possible to obtain an LLVMUseRef for any LLVMValueRef instance.
Gregory Szorc34c863a2012-03-21 03:54:29 +00001246 * Each LLVMUseRef (which corresponds to a llvm::Use instance) holds a
1247 * llvm::User and llvm::Value.
1248 *
1249 * @{
1250 */
1251
1252/**
1253 * Obtain the first use of a value.
1254 *
1255 * Uses are obtained in an iterator fashion. First, call this function
1256 * to obtain a reference to the first use. Then, call LLVMGetNextUse()
Eli Benderskyc52863c2012-08-10 18:30:44 +00001257 * on that instance and all subsequently obtained instances until
Gregory Szorc34c863a2012-03-21 03:54:29 +00001258 * LLVMGetNextUse() returns NULL.
1259 *
1260 * @see llvm::Value::use_begin()
1261 */
Erick Tryzelaar9f9857e2010-03-02 20:32:28 +00001262LLVMUseRef LLVMGetFirstUse(LLVMValueRef Val);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001263
1264/**
1265 * Obtain the next use of a value.
1266 *
1267 * This effectively advances the iterator. It returns NULL if you are on
1268 * the final use and no more are available.
1269 */
Erick Tryzelaar9f9857e2010-03-02 20:32:28 +00001270LLVMUseRef LLVMGetNextUse(LLVMUseRef U);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001271
1272/**
1273 * Obtain the user value for a user.
1274 *
1275 * The returned value corresponds to a llvm::User type.
1276 *
1277 * @see llvm::Use::getUser()
1278 */
Erick Tryzelaar9f9857e2010-03-02 20:32:28 +00001279LLVMValueRef LLVMGetUser(LLVMUseRef U);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001280
1281/**
1282 * Obtain the value this use corresponds to.
1283 *
1284 * @see llvm::Use::get().
1285 */
Erick Tryzelaar9f9857e2010-03-02 20:32:28 +00001286LLVMValueRef LLVMGetUsedValue(LLVMUseRef U);
Chris Lattner40cf28d2009-10-12 04:01:02 +00001287
Gregory Szorc34c863a2012-03-21 03:54:29 +00001288/**
1289 * @}
1290 */
1291
1292/**
Gregory Szorc52d26602012-03-21 07:28:27 +00001293 * @defgroup LLVMCCoreValueUser User value
Gregory Szorc34c863a2012-03-21 03:54:29 +00001294 *
1295 * Function in this group pertain to LLVMValueRef instances that descent
1296 * from llvm::User. This includes constants, instructions, and
1297 * operators.
1298 *
1299 * @{
1300 */
1301
1302/**
1303 * Obtain an operand at a specific index in a llvm::User value.
1304 *
1305 * @see llvm::User::getOperand()
1306 */
Chris Lattner40cf28d2009-10-12 04:01:02 +00001307LLVMValueRef LLVMGetOperand(LLVMValueRef Val, unsigned Index);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001308
1309/**
Peter Zotovb19f78f2014-08-12 02:55:40 +00001310 * Obtain the use of an operand at a specific index in a llvm::User value.
1311 *
1312 * @see llvm::User::getOperandUse()
1313 */
1314LLVMUseRef LLVMGetOperandUse(LLVMValueRef Val, unsigned Index);
1315
1316/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00001317 * Set an operand at a specific index in a llvm::User value.
1318 *
1319 * @see llvm::User::setOperand()
1320 */
Erick Tryzelaarb4d48702010-08-20 14:51:22 +00001321void LLVMSetOperand(LLVMValueRef User, unsigned Index, LLVMValueRef Val);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001322
1323/**
1324 * Obtain the number of operands in a llvm::User value.
1325 *
1326 * @see llvm::User::getNumOperands()
1327 */
Erick Tryzelaarb4d48702010-08-20 14:51:22 +00001328int LLVMGetNumOperands(LLVMValueRef Val);
Chris Lattner40cf28d2009-10-12 04:01:02 +00001329
Gregory Szorc34c863a2012-03-21 03:54:29 +00001330/**
1331 * @}
1332 */
1333
1334/**
Gregory Szorc52d26602012-03-21 07:28:27 +00001335 * @defgroup LLVMCCoreValueConstant Constants
Gregory Szorc34c863a2012-03-21 03:54:29 +00001336 *
1337 * This section contains APIs for interacting with LLVMValueRef that
1338 * correspond to llvm::Constant instances.
1339 *
1340 * These functions will work for any LLVMValueRef in the llvm::Constant
1341 * class hierarchy.
1342 *
1343 * @{
1344 */
1345
1346/**
1347 * Obtain a constant value referring to the null instance of a type.
1348 *
1349 * @see llvm::Constant::getNullValue()
1350 */
Gordon Henriksen1046c732007-10-06 15:11:06 +00001351LLVMValueRef LLVMConstNull(LLVMTypeRef Ty); /* all zeroes */
Gregory Szorc34c863a2012-03-21 03:54:29 +00001352
1353/**
1354 * Obtain a constant value referring to the instance of a type
1355 * consisting of all ones.
1356 *
1357 * This is only valid for integer types.
1358 *
1359 * @see llvm::Constant::getAllOnesValue()
1360 */
1361LLVMValueRef LLVMConstAllOnes(LLVMTypeRef Ty);
1362
1363/**
1364 * Obtain a constant value referring to an undefined value of a type.
1365 *
1366 * @see llvm::UndefValue::get()
1367 */
Gordon Henriksen76a03742007-09-18 03:18:57 +00001368LLVMValueRef LLVMGetUndef(LLVMTypeRef Ty);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001369
1370/**
1371 * Determine whether a value instance is null.
1372 *
1373 * @see llvm::Constant::isNullValue()
1374 */
Chris Lattner25963c62010-01-09 22:27:07 +00001375LLVMBool LLVMIsNull(LLVMValueRef Val);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001376
1377/**
1378 * Obtain a constant that is a constant pointer pointing to NULL for a
1379 * specified type.
1380 */
Chris Lattner7f318242009-07-06 17:29:59 +00001381LLVMValueRef LLVMConstPointerNull(LLVMTypeRef Ty);
Gordon Henriksen76a03742007-09-18 03:18:57 +00001382
Gregory Szorc34c863a2012-03-21 03:54:29 +00001383/**
1384 * @defgroup LLVMCCoreValueConstantScalar Scalar constants
1385 *
1386 * Functions in this group model LLVMValueRef instances that correspond
1387 * to constants referring to scalar types.
1388 *
1389 * For integer types, the LLVMTypeRef parameter should correspond to a
1390 * llvm::IntegerType instance and the returned LLVMValueRef will
1391 * correspond to a llvm::ConstantInt.
1392 *
1393 * For floating point types, the LLVMTypeRef returned corresponds to a
1394 * llvm::ConstantFP.
1395 *
1396 * @{
1397 */
Erick Tryzelaard8531fa2010-02-28 09:45:59 +00001398
Gregory Szorc34c863a2012-03-21 03:54:29 +00001399/**
1400 * Obtain a constant value for an integer type.
1401 *
1402 * The returned value corresponds to a llvm::ConstantInt.
1403 *
1404 * @see llvm::ConstantInt::get()
1405 *
1406 * @param IntTy Integer type to obtain value of.
1407 * @param N The value the returned instance should refer to.
1408 * @param SignExtend Whether to sign extend the produced value.
1409 */
Gordon Henriksen1046c732007-10-06 15:11:06 +00001410LLVMValueRef LLVMConstInt(LLVMTypeRef IntTy, unsigned long long N,
Chris Lattner25963c62010-01-09 22:27:07 +00001411 LLVMBool SignExtend);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001412
1413/**
1414 * Obtain a constant value for an integer of arbitrary precision.
1415 *
1416 * @see llvm::ConstantInt::get()
1417 */
Chris Lattner4329e072010-11-23 02:47:22 +00001418LLVMValueRef LLVMConstIntOfArbitraryPrecision(LLVMTypeRef IntTy,
1419 unsigned NumWords,
1420 const uint64_t Words[]);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001421
1422/**
1423 * Obtain a constant value for an integer parsed from a string.
1424 *
1425 * A similar API, LLVMConstIntOfStringAndSize is also available. If the
1426 * string's length is available, it is preferred to call that function
1427 * instead.
1428 *
1429 * @see llvm::ConstantInt::get()
1430 */
Erick Tryzelaardd991352009-08-16 23:36:46 +00001431LLVMValueRef LLVMConstIntOfString(LLVMTypeRef IntTy, const char *Text,
1432 uint8_t Radix);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001433
1434/**
1435 * Obtain a constant value for an integer parsed from a string with
1436 * specified length.
1437 *
1438 * @see llvm::ConstantInt::get()
1439 */
Erick Tryzelaardd991352009-08-16 23:36:46 +00001440LLVMValueRef LLVMConstIntOfStringAndSize(LLVMTypeRef IntTy, const char *Text,
1441 unsigned SLen, uint8_t Radix);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001442
1443/**
1444 * Obtain a constant value referring to a double floating point value.
1445 */
Gordon Henriksen1046c732007-10-06 15:11:06 +00001446LLVMValueRef LLVMConstReal(LLVMTypeRef RealTy, double N);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001447
1448/**
1449 * Obtain a constant for a floating point value parsed from a string.
1450 *
1451 * A similar API, LLVMConstRealOfStringAndSize is also available. It
1452 * should be used if the input string's length is known.
1453 */
Gordon Henriksen931e1212008-02-02 01:07:50 +00001454LLVMValueRef LLVMConstRealOfString(LLVMTypeRef RealTy, const char *Text);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001455
1456/**
1457 * Obtain a constant for a floating point value parsed from a string.
1458 */
Erick Tryzelaardd991352009-08-16 23:36:46 +00001459LLVMValueRef LLVMConstRealOfStringAndSize(LLVMTypeRef RealTy, const char *Text,
1460 unsigned SLen);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001461
1462/**
1463 * Obtain the zero extended value for an integer constant value.
1464 *
1465 * @see llvm::ConstantInt::getZExtValue()
1466 */
Chris Lattner40cf28d2009-10-12 04:01:02 +00001467unsigned long long LLVMConstIntGetZExtValue(LLVMValueRef ConstantVal);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001468
1469/**
1470 * Obtain the sign extended value for an integer constant value.
1471 *
1472 * @see llvm::ConstantInt::getSExtValue()
1473 */
Chris Lattner40cf28d2009-10-12 04:01:02 +00001474long long LLVMConstIntGetSExtValue(LLVMValueRef ConstantVal);
Erick Tryzelaardd991352009-08-16 23:36:46 +00001475
Gregory Szorc34c863a2012-03-21 03:54:29 +00001476/**
Peter Zotov1d98e6d2014-10-28 19:46:44 +00001477 * Obtain the double value for an floating point constant value.
1478 * losesInfo indicates if some precision was lost in the conversion.
1479 *
1480 * @see llvm::ConstantFP::getDoubleValue
1481 */
1482double LLVMConstRealGetDouble(LLVMValueRef ConstantVal, LLVMBool *losesInfo);
1483
1484/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00001485 * @}
1486 */
1487
1488/**
Gregory Szorc52d26602012-03-21 07:28:27 +00001489 * @defgroup LLVMCCoreValueConstantComposite Composite Constants
1490 *
1491 * Functions in this group operate on composite constants.
Gregory Szorc34c863a2012-03-21 03:54:29 +00001492 *
1493 * @{
1494 */
1495
1496/**
Gregory Szorc52d26602012-03-21 07:28:27 +00001497 * Create a ConstantDataSequential and initialize it with a string.
Gregory Szorc34c863a2012-03-21 03:54:29 +00001498 *
Gregory Szorc52d26602012-03-21 07:28:27 +00001499 * @see llvm::ConstantDataArray::getString()
Gregory Szorc34c863a2012-03-21 03:54:29 +00001500 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +00001501LLVMValueRef LLVMConstStringInContext(LLVMContextRef C, const char *Str,
Chris Lattner25963c62010-01-09 22:27:07 +00001502 unsigned Length, LLVMBool DontNullTerminate);
Gregory Szorc52d26602012-03-21 07:28:27 +00001503
1504/**
1505 * Create a ConstantDataSequential with string content in the global context.
1506 *
1507 * This is the same as LLVMConstStringInContext except it operates on the
1508 * global context.
1509 *
1510 * @see LLVMConstStringInContext()
1511 * @see llvm::ConstantDataArray::getString()
1512 */
1513LLVMValueRef LLVMConstString(const char *Str, unsigned Length,
1514 LLVMBool DontNullTerminate);
1515
1516/**
Peter Zotovf9aa8822014-08-03 23:54:16 +00001517 * Returns true if the specified constant is an array of i8.
1518 *
1519 * @see ConstantDataSequential::getAsString()
1520 */
1521LLVMBool LLVMIsConstantString(LLVMValueRef c);
1522
1523/**
1524 * Get the given constant data sequential as a string.
1525 *
1526 * @see ConstantDataSequential::getAsString()
1527 */
1528const char *LLVMGetAsString(LLVMValueRef c, size_t* out);
1529
1530/**
Gregory Szorc52d26602012-03-21 07:28:27 +00001531 * Create an anonymous ConstantStruct with the specified values.
1532 *
1533 * @see llvm::ConstantStruct::getAnon()
1534 */
1535LLVMValueRef LLVMConstStructInContext(LLVMContextRef C,
Erick Tryzelaar262332f2009-08-14 00:01:31 +00001536 LLVMValueRef *ConstantVals,
Chris Lattner25963c62010-01-09 22:27:07 +00001537 unsigned Count, LLVMBool Packed);
Erick Tryzelaar262332f2009-08-14 00:01:31 +00001538
Gregory Szorc52d26602012-03-21 07:28:27 +00001539/**
1540 * Create a ConstantStruct in the global Context.
1541 *
1542 * This is the same as LLVMConstStructInContext except it operates on the
1543 * global Context.
1544 *
1545 * @see LLVMConstStructInContext()
1546 */
Gordon Henriksen1046c732007-10-06 15:11:06 +00001547LLVMValueRef LLVMConstStruct(LLVMValueRef *ConstantVals, unsigned Count,
Chris Lattner25963c62010-01-09 22:27:07 +00001548 LLVMBool Packed);
Gregory Szorc52d26602012-03-21 07:28:27 +00001549
1550/**
1551 * Create a ConstantArray from values.
1552 *
1553 * @see llvm::ConstantArray::get()
1554 */
1555LLVMValueRef LLVMConstArray(LLVMTypeRef ElementTy,
1556 LLVMValueRef *ConstantVals, unsigned Length);
1557
1558/**
1559 * Create a non-anonymous ConstantStruct from values.
1560 *
1561 * @see llvm::ConstantStruct::get()
1562 */
Rafael Espindola784ad242011-07-14 19:09:08 +00001563LLVMValueRef LLVMConstNamedStruct(LLVMTypeRef StructTy,
1564 LLVMValueRef *ConstantVals,
1565 unsigned Count);
Gregory Szorc52d26602012-03-21 07:28:27 +00001566
1567/**
Peter Zotovf9aa8822014-08-03 23:54:16 +00001568 * Get an element at specified index as a constant.
1569 *
1570 * @see ConstantDataSequential::getElementAsConstant()
1571 */
Amaury Sechet006ce632016-03-13 00:54:40 +00001572LLVMValueRef LLVMGetElementAsConstant(LLVMValueRef C, unsigned idx);
Peter Zotovf9aa8822014-08-03 23:54:16 +00001573
1574/**
Gregory Szorc52d26602012-03-21 07:28:27 +00001575 * Create a ConstantVector from values.
1576 *
1577 * @see llvm::ConstantVector::get()
1578 */
Gordon Henriksen1046c732007-10-06 15:11:06 +00001579LLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals, unsigned Size);
Gordon Henriksen76a03742007-09-18 03:18:57 +00001580
Gregory Szorc52d26602012-03-21 07:28:27 +00001581/**
1582 * @}
1583 */
1584
1585/**
1586 * @defgroup LLVMCCoreValueConstantExpressions Constant Expressions
1587 *
1588 * Functions in this group correspond to APIs on llvm::ConstantExpr.
1589 *
1590 * @see llvm::ConstantExpr.
1591 *
1592 * @{
1593 */
Chris Lattner40cf28d2009-10-12 04:01:02 +00001594LLVMOpcode LLVMGetConstOpcode(LLVMValueRef ConstantVal);
Erick Tryzelaarfd529d72009-08-19 08:36:49 +00001595LLVMValueRef LLVMAlignOf(LLVMTypeRef Ty);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001596LLVMValueRef LLVMSizeOf(LLVMTypeRef Ty);
1597LLVMValueRef LLVMConstNeg(LLVMValueRef ConstantVal);
Erick Tryzelaar4c340c72010-02-28 05:51:43 +00001598LLVMValueRef LLVMConstNSWNeg(LLVMValueRef ConstantVal);
1599LLVMValueRef LLVMConstNUWNeg(LLVMValueRef ConstantVal);
Erick Tryzelaar4cc690c2009-08-16 02:20:12 +00001600LLVMValueRef LLVMConstFNeg(LLVMValueRef ConstantVal);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001601LLVMValueRef LLVMConstNot(LLVMValueRef ConstantVal);
1602LLVMValueRef LLVMConstAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Dan Gohmane4ca02d2009-09-03 23:34:49 +00001603LLVMValueRef LLVMConstNSWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Erick Tryzelaar4c340c72010-02-28 05:51:43 +00001604LLVMValueRef LLVMConstNUWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Erick Tryzelaar4cc690c2009-08-16 02:20:12 +00001605LLVMValueRef LLVMConstFAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001606LLVMValueRef LLVMConstSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Erick Tryzelaar4c340c72010-02-28 05:51:43 +00001607LLVMValueRef LLVMConstNSWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1608LLVMValueRef LLVMConstNUWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Erick Tryzelaar4cc690c2009-08-16 02:20:12 +00001609LLVMValueRef LLVMConstFSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001610LLVMValueRef LLVMConstMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Erick Tryzelaar4c340c72010-02-28 05:51:43 +00001611LLVMValueRef LLVMConstNSWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1612LLVMValueRef LLVMConstNUWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Erick Tryzelaar4cc690c2009-08-16 02:20:12 +00001613LLVMValueRef LLVMConstFMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001614LLVMValueRef LLVMConstUDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1615LLVMValueRef LLVMConstSDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Dan Gohmane4ca02d2009-09-03 23:34:49 +00001616LLVMValueRef LLVMConstExactSDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001617LLVMValueRef LLVMConstFDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1618LLVMValueRef LLVMConstURem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1619LLVMValueRef LLVMConstSRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1620LLVMValueRef LLVMConstFRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1621LLVMValueRef LLVMConstAnd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1622LLVMValueRef LLVMConstOr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1623LLVMValueRef LLVMConstXor(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1624LLVMValueRef LLVMConstICmp(LLVMIntPredicate Predicate,
1625 LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1626LLVMValueRef LLVMConstFCmp(LLVMRealPredicate Predicate,
1627 LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1628LLVMValueRef LLVMConstShl(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1629LLVMValueRef LLVMConstLShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1630LLVMValueRef LLVMConstAShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1631LLVMValueRef LLVMConstGEP(LLVMValueRef ConstantVal,
1632 LLVMValueRef *ConstantIndices, unsigned NumIndices);
Dan Gohmane4ca02d2009-09-03 23:34:49 +00001633LLVMValueRef LLVMConstInBoundsGEP(LLVMValueRef ConstantVal,
1634 LLVMValueRef *ConstantIndices,
1635 unsigned NumIndices);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001636LLVMValueRef LLVMConstTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1637LLVMValueRef LLVMConstSExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1638LLVMValueRef LLVMConstZExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1639LLVMValueRef LLVMConstFPTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1640LLVMValueRef LLVMConstFPExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1641LLVMValueRef LLVMConstUIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1642LLVMValueRef LLVMConstSIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1643LLVMValueRef LLVMConstFPToUI(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1644LLVMValueRef LLVMConstFPToSI(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1645LLVMValueRef LLVMConstPtrToInt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1646LLVMValueRef LLVMConstIntToPtr(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1647LLVMValueRef LLVMConstBitCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
Matt Arsenaultb03bd4d2013-11-15 01:34:59 +00001648LLVMValueRef LLVMConstAddrSpaceCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
Erick Tryzelaar4cc690c2009-08-16 02:20:12 +00001649LLVMValueRef LLVMConstZExtOrBitCast(LLVMValueRef ConstantVal,
1650 LLVMTypeRef ToType);
1651LLVMValueRef LLVMConstSExtOrBitCast(LLVMValueRef ConstantVal,
1652 LLVMTypeRef ToType);
1653LLVMValueRef LLVMConstTruncOrBitCast(LLVMValueRef ConstantVal,
1654 LLVMTypeRef ToType);
1655LLVMValueRef LLVMConstPointerCast(LLVMValueRef ConstantVal,
1656 LLVMTypeRef ToType);
1657LLVMValueRef LLVMConstIntCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType,
Chris Lattner25963c62010-01-09 22:27:07 +00001658 LLVMBool isSigned);
Erick Tryzelaar4cc690c2009-08-16 02:20:12 +00001659LLVMValueRef LLVMConstFPCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001660LLVMValueRef LLVMConstSelect(LLVMValueRef ConstantCondition,
1661 LLVMValueRef ConstantIfTrue,
1662 LLVMValueRef ConstantIfFalse);
1663LLVMValueRef LLVMConstExtractElement(LLVMValueRef VectorConstant,
1664 LLVMValueRef IndexConstant);
1665LLVMValueRef LLVMConstInsertElement(LLVMValueRef VectorConstant,
1666 LLVMValueRef ElementValueConstant,
1667 LLVMValueRef IndexConstant);
1668LLVMValueRef LLVMConstShuffleVector(LLVMValueRef VectorAConstant,
1669 LLVMValueRef VectorBConstant,
1670 LLVMValueRef MaskConstant);
Dan Gohmand5104a52008-11-03 22:55:43 +00001671LLVMValueRef LLVMConstExtractValue(LLVMValueRef AggConstant, unsigned *IdxList,
1672 unsigned NumIdx);
1673LLVMValueRef LLVMConstInsertValue(LLVMValueRef AggConstant,
1674 LLVMValueRef ElementValueConstant,
1675 unsigned *IdxList, unsigned NumIdx);
Chris Lattner25963c62010-01-09 22:27:07 +00001676LLVMValueRef LLVMConstInlineAsm(LLVMTypeRef Ty,
Chris Lattner3d1f5522008-12-17 21:39:50 +00001677 const char *AsmString, const char *Constraints,
Chris Lattner25963c62010-01-09 22:27:07 +00001678 LLVMBool HasSideEffects, LLVMBool IsAlignStack);
Erick Tryzelaar0fb26ef2010-02-28 09:46:06 +00001679LLVMValueRef LLVMBlockAddress(LLVMValueRef F, LLVMBasicBlockRef BB);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001680
Gregory Szorc52d26602012-03-21 07:28:27 +00001681/**
1682 * @}
1683 */
1684
1685/**
1686 * @defgroup LLVMCCoreValueConstantGlobals Global Values
1687 *
1688 * This group contains functions that operate on global values. Functions in
1689 * this group relate to functions in the llvm::GlobalValue class tree.
1690 *
1691 * @see llvm::GlobalValue
1692 *
1693 * @{
1694 */
1695
Gordon Henriksen265f7802008-03-19 01:11:35 +00001696LLVMModuleRef LLVMGetGlobalParent(LLVMValueRef Global);
Chris Lattner25963c62010-01-09 22:27:07 +00001697LLVMBool LLVMIsDeclaration(LLVMValueRef Global);
Gordon Henriksen76a03742007-09-18 03:18:57 +00001698LLVMLinkage LLVMGetLinkage(LLVMValueRef Global);
1699void LLVMSetLinkage(LLVMValueRef Global, LLVMLinkage Linkage);
1700const char *LLVMGetSection(LLVMValueRef Global);
1701void LLVMSetSection(LLVMValueRef Global, const char *Section);
1702LLVMVisibility LLVMGetVisibility(LLVMValueRef Global);
1703void LLVMSetVisibility(LLVMValueRef Global, LLVMVisibility Viz);
Reid Kleckner2fae26f2014-03-05 02:34:23 +00001704LLVMDLLStorageClass LLVMGetDLLStorageClass(LLVMValueRef Global);
1705void LLVMSetDLLStorageClass(LLVMValueRef Global, LLVMDLLStorageClass Class);
Tim Northoverad96d012014-03-10 19:24:35 +00001706LLVMBool LLVMHasUnnamedAddr(LLVMValueRef Global);
1707void LLVMSetUnnamedAddr(LLVMValueRef Global, LLVMBool HasUnnamedAddr);
Anders Waldenborg213a63f2013-10-29 09:02:02 +00001708
1709/**
1710 * @defgroup LLVMCCoreValueWithAlignment Values with alignment
1711 *
1712 * Functions in this group only apply to values with alignment, i.e.
1713 * global variables, load and store instructions.
1714 */
1715
1716/**
1717 * Obtain the preferred alignment of the value.
Peter Zotov9f584e62014-03-05 05:05:34 +00001718 * @see llvm::AllocaInst::getAlignment()
Anders Waldenborg213a63f2013-10-29 09:02:02 +00001719 * @see llvm::LoadInst::getAlignment()
1720 * @see llvm::StoreInst::getAlignment()
1721 * @see llvm::GlobalValue::getAlignment()
1722 */
1723unsigned LLVMGetAlignment(LLVMValueRef V);
1724
1725/**
1726 * Set the preferred alignment of the value.
Peter Zotov9f584e62014-03-05 05:05:34 +00001727 * @see llvm::AllocaInst::setAlignment()
Anders Waldenborg213a63f2013-10-29 09:02:02 +00001728 * @see llvm::LoadInst::setAlignment()
1729 * @see llvm::StoreInst::setAlignment()
1730 * @see llvm::GlobalValue::setAlignment()
1731 */
1732void LLVMSetAlignment(LLVMValueRef V, unsigned Bytes);
1733
1734/**
Amaury Sechet83550102016-02-14 08:58:49 +00001735 * @}
1736 */
Gordon Henriksen76a03742007-09-18 03:18:57 +00001737
Gregory Szorc52d26602012-03-21 07:28:27 +00001738/**
1739 * @defgroup LLVMCoreValueConstantGlobalVariable Global Variables
1740 *
1741 * This group contains functions that operate on global variable values.
1742 *
1743 * @see llvm::GlobalVariable
1744 *
1745 * @{
1746 */
Gordon Henriksen76a03742007-09-18 03:18:57 +00001747LLVMValueRef LLVMAddGlobal(LLVMModuleRef M, LLVMTypeRef Ty, const char *Name);
Erick Tryzelaar06894b32010-02-28 09:46:13 +00001748LLVMValueRef LLVMAddGlobalInAddressSpace(LLVMModuleRef M, LLVMTypeRef Ty,
1749 const char *Name,
1750 unsigned AddressSpace);
Gordon Henriksen783f7bb2007-10-08 03:45:09 +00001751LLVMValueRef LLVMGetNamedGlobal(LLVMModuleRef M, const char *Name);
Gordon Henriksen07a45f42008-03-23 22:21:29 +00001752LLVMValueRef LLVMGetFirstGlobal(LLVMModuleRef M);
1753LLVMValueRef LLVMGetLastGlobal(LLVMModuleRef M);
1754LLVMValueRef LLVMGetNextGlobal(LLVMValueRef GlobalVar);
1755LLVMValueRef LLVMGetPreviousGlobal(LLVMValueRef GlobalVar);
Gordon Henriksen76a03742007-09-18 03:18:57 +00001756void LLVMDeleteGlobal(LLVMValueRef GlobalVar);
Gordon Henriksen76a03742007-09-18 03:18:57 +00001757LLVMValueRef LLVMGetInitializer(LLVMValueRef GlobalVar);
1758void LLVMSetInitializer(LLVMValueRef GlobalVar, LLVMValueRef ConstantVal);
Chris Lattner25963c62010-01-09 22:27:07 +00001759LLVMBool LLVMIsThreadLocal(LLVMValueRef GlobalVar);
1760void LLVMSetThreadLocal(LLVMValueRef GlobalVar, LLVMBool IsThreadLocal);
1761LLVMBool LLVMIsGlobalConstant(LLVMValueRef GlobalVar);
1762void LLVMSetGlobalConstant(LLVMValueRef GlobalVar, LLVMBool IsConstant);
Hans Wennborg5ff71202013-04-16 08:58:59 +00001763LLVMThreadLocalMode LLVMGetThreadLocalMode(LLVMValueRef GlobalVar);
1764void LLVMSetThreadLocalMode(LLVMValueRef GlobalVar, LLVMThreadLocalMode Mode);
1765LLVMBool LLVMIsExternallyInitialized(LLVMValueRef GlobalVar);
1766void LLVMSetExternallyInitialized(LLVMValueRef GlobalVar, LLVMBool IsExtInit);
Gordon Henriksen76a03742007-09-18 03:18:57 +00001767
Gregory Szorc52d26602012-03-21 07:28:27 +00001768/**
1769 * @}
1770 */
1771
1772/**
1773 * @defgroup LLVMCoreValueConstantGlobalAlias Global Aliases
1774 *
1775 * This group contains function that operate on global alias values.
1776 *
1777 * @see llvm::GlobalAlias
1778 *
1779 * @{
1780 */
Chris Lattner3d1f5522008-12-17 21:39:50 +00001781LLVMValueRef LLVMAddAlias(LLVMModuleRef M, LLVMTypeRef Ty, LLVMValueRef Aliasee,
1782 const char *Name);
1783
Gregory Szorc34c863a2012-03-21 03:54:29 +00001784/**
1785 * @}
1786 */
1787
1788/**
1789 * @defgroup LLVMCCoreValueFunction Function values
1790 *
1791 * Functions in this group operate on LLVMValueRef instances that
1792 * correspond to llvm::Function instances.
1793 *
1794 * @see llvm::Function
1795 *
1796 * @{
1797 */
1798
1799/**
1800 * Remove a function from its containing module and deletes it.
1801 *
1802 * @see llvm::Function::eraseFromParent()
1803 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00001804void LLVMDeleteFunction(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001805
1806/**
Amaury Sechete39e8532016-02-18 20:38:32 +00001807 * Check whether the given function has a personality function.
1808 *
1809 * @see llvm::Function::hasPersonalityFn()
1810 */
1811LLVMBool LLVMHasPersonalityFn(LLVMValueRef Fn);
1812
1813/**
Andrew Wilkins3bdfc1c2015-07-14 01:23:06 +00001814 * Obtain the personality function attached to the function.
1815 *
1816 * @see llvm::Function::getPersonalityFn()
1817 */
1818LLVMValueRef LLVMGetPersonalityFn(LLVMValueRef Fn);
1819
1820/**
1821 * Set the personality function attached to the function.
1822 *
1823 * @see llvm::Function::setPersonalityFn()
1824 */
1825void LLVMSetPersonalityFn(LLVMValueRef Fn, LLVMValueRef PersonalityFn);
1826
1827/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00001828 * Obtain the ID number from a function instance.
1829 *
1830 * @see llvm::Function::getIntrinsicID()
1831 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00001832unsigned LLVMGetIntrinsicID(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001833
1834/**
1835 * Obtain the calling function of a function.
1836 *
1837 * The returned value corresponds to the LLVMCallConv enumeration.
1838 *
1839 * @see llvm::Function::getCallingConv()
1840 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00001841unsigned LLVMGetFunctionCallConv(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001842
1843/**
1844 * Set the calling convention of a function.
1845 *
1846 * @see llvm::Function::setCallingConv()
1847 *
1848 * @param Fn Function to operate on
1849 * @param CC LLVMCallConv to set calling convention to
1850 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00001851void LLVMSetFunctionCallConv(LLVMValueRef Fn, unsigned CC);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001852
1853/**
1854 * Obtain the name of the garbage collector to use during code
1855 * generation.
1856 *
1857 * @see llvm::Function::getGC()
1858 */
Gordon Henriksend930f912008-08-17 18:44:35 +00001859const char *LLVMGetGC(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001860
1861/**
1862 * Define the garbage collector to use during code generation.
1863 *
1864 * @see llvm::Function::setGC()
1865 */
Gordon Henriksend930f912008-08-17 18:44:35 +00001866void LLVMSetGC(LLVMValueRef Fn, const char *Name);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001867
1868/**
1869 * Add an attribute to a function.
1870 *
1871 * @see llvm::Function::addAttribute()
1872 */
Duncan Sands7374a012009-05-06 12:21:17 +00001873void LLVMAddFunctionAttr(LLVMValueRef Fn, LLVMAttribute PA);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001874
1875/**
Nick Lewyckyc3890d22015-07-29 22:32:47 +00001876 * Add a target-dependent attribute to a function
Tom Stellarde8f35e12013-04-16 23:12:43 +00001877 * @see llvm::AttrBuilder::addAttribute()
1878 */
1879void LLVMAddTargetDependentFunctionAttr(LLVMValueRef Fn, const char *A,
1880 const char *V);
1881
1882/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00001883 * Obtain an attribute from a function.
1884 *
1885 * @see llvm::Function::getAttributes()
1886 */
Chris Lattner40cf28d2009-10-12 04:01:02 +00001887LLVMAttribute LLVMGetFunctionAttr(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001888
1889/**
1890 * Remove an attribute from a function.
1891 */
Duncan Sands7374a012009-05-06 12:21:17 +00001892void LLVMRemoveFunctionAttr(LLVMValueRef Fn, LLVMAttribute PA);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00001893
Gregory Szorc34c863a2012-03-21 03:54:29 +00001894/**
1895 * @defgroup LLVMCCoreValueFunctionParameters Function Parameters
1896 *
1897 * Functions in this group relate to arguments/parameters on functions.
1898 *
1899 * Functions in this group expect LLVMValueRef instances that correspond
1900 * to llvm::Function instances.
1901 *
1902 * @{
1903 */
1904
1905/**
1906 * Obtain the number of parameters in a function.
1907 *
1908 * @see llvm::Function::arg_size()
1909 */
Gordon Henriksen265f7802008-03-19 01:11:35 +00001910unsigned LLVMCountParams(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001911
1912/**
1913 * Obtain the parameters in a function.
1914 *
1915 * The takes a pointer to a pre-allocated array of LLVMValueRef that is
1916 * at least LLVMCountParams() long. This array will be filled with
1917 * LLVMValueRef instances which correspond to the parameters the
1918 * function receives. Each LLVMValueRef corresponds to a llvm::Argument
1919 * instance.
1920 *
1921 * @see llvm::Function::arg_begin()
1922 */
Gordon Henriksen265f7802008-03-19 01:11:35 +00001923void LLVMGetParams(LLVMValueRef Fn, LLVMValueRef *Params);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001924
1925/**
1926 * Obtain the parameter at the specified index.
1927 *
1928 * Parameters are indexed from 0.
1929 *
1930 * @see llvm::Function::arg_begin()
1931 */
Gordon Henriksen265f7802008-03-19 01:11:35 +00001932LLVMValueRef LLVMGetParam(LLVMValueRef Fn, unsigned Index);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001933
1934/**
1935 * Obtain the function to which this argument belongs.
1936 *
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00001937 * Unlike other functions in this group, this one takes an LLVMValueRef
Gregory Szorc34c863a2012-03-21 03:54:29 +00001938 * that corresponds to a llvm::Attribute.
1939 *
1940 * The returned LLVMValueRef is the llvm::Function to which this
1941 * argument belongs.
1942 */
Gordon Henriksen265f7802008-03-19 01:11:35 +00001943LLVMValueRef LLVMGetParamParent(LLVMValueRef Inst);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001944
1945/**
1946 * Obtain the first parameter to a function.
1947 *
1948 * @see llvm::Function::arg_begin()
1949 */
Gordon Henriksen07a45f42008-03-23 22:21:29 +00001950LLVMValueRef LLVMGetFirstParam(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001951
1952/**
1953 * Obtain the last parameter to a function.
1954 *
1955 * @see llvm::Function::arg_end()
1956 */
Gordon Henriksen07a45f42008-03-23 22:21:29 +00001957LLVMValueRef LLVMGetLastParam(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001958
1959/**
1960 * Obtain the next parameter to a function.
1961 *
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00001962 * This takes an LLVMValueRef obtained from LLVMGetFirstParam() (which is
Gregory Szorc34c863a2012-03-21 03:54:29 +00001963 * actually a wrapped iterator) and obtains the next parameter from the
1964 * underlying iterator.
1965 */
Gordon Henriksen07a45f42008-03-23 22:21:29 +00001966LLVMValueRef LLVMGetNextParam(LLVMValueRef Arg);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001967
1968/**
1969 * Obtain the previous parameter to a function.
1970 *
1971 * This is the opposite of LLVMGetNextParam().
1972 */
Gordon Henriksen07a45f42008-03-23 22:21:29 +00001973LLVMValueRef LLVMGetPreviousParam(LLVMValueRef Arg);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001974
1975/**
1976 * Add an attribute to a function argument.
1977 *
1978 * @see llvm::Argument::addAttr()
1979 */
Devang Patel4c758ea2008-09-25 21:00:45 +00001980void LLVMAddAttribute(LLVMValueRef Arg, LLVMAttribute PA);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001981
1982/**
1983 * Remove an attribute from a function argument.
1984 *
1985 * @see llvm::Argument::removeAttr()
1986 */
Devang Patel4c758ea2008-09-25 21:00:45 +00001987void LLVMRemoveAttribute(LLVMValueRef Arg, LLVMAttribute PA);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001988
1989/**
1990 * Get an attribute from a function argument.
1991 */
Chris Lattner40cf28d2009-10-12 04:01:02 +00001992LLVMAttribute LLVMGetAttribute(LLVMValueRef Arg);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001993
1994/**
1995 * Set the alignment for a function parameter.
1996 *
1997 * @see llvm::Argument::addAttr()
Bill Wendling50d27842012-10-15 20:35:56 +00001998 * @see llvm::AttrBuilder::addAlignmentAttr()
Gregory Szorc34c863a2012-03-21 03:54:29 +00001999 */
Gordon Henriksen2d9cc212008-04-28 17:37:06 +00002000void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned align);
Gordon Henriksen265f7802008-03-19 01:11:35 +00002001
Gregory Szorc34c863a2012-03-21 03:54:29 +00002002/**
2003 * @}
2004 */
2005
2006/**
2007 * @}
2008 */
2009
2010/**
Gregory Szorc52d26602012-03-21 07:28:27 +00002011 * @}
2012 */
2013
2014/**
2015 * @}
2016 */
2017
2018/**
2019 * @defgroup LLVMCCoreValueMetadata Metadata
2020 *
2021 * @{
2022 */
2023
2024/**
2025 * Obtain a MDString value from a context.
2026 *
2027 * The returned instance corresponds to the llvm::MDString class.
2028 *
2029 * The instance is specified by string data of a specified length. The
2030 * string content is copied, so the backing memory can be freed after
2031 * this function returns.
2032 */
2033LLVMValueRef LLVMMDStringInContext(LLVMContextRef C, const char *Str,
2034 unsigned SLen);
2035
2036/**
2037 * Obtain a MDString value from the global context.
2038 */
2039LLVMValueRef LLVMMDString(const char *Str, unsigned SLen);
2040
2041/**
2042 * Obtain a MDNode value from a context.
2043 *
2044 * The returned value corresponds to the llvm::MDNode class.
2045 */
2046LLVMValueRef LLVMMDNodeInContext(LLVMContextRef C, LLVMValueRef *Vals,
2047 unsigned Count);
2048
2049/**
2050 * Obtain a MDNode value from the global context.
2051 */
2052LLVMValueRef LLVMMDNode(LLVMValueRef *Vals, unsigned Count);
2053
2054/**
2055 * Obtain the underlying string from a MDString value.
2056 *
2057 * @param V Instance to obtain string from.
2058 * @param Len Memory address which will hold length of returned string.
2059 * @return String data in MDString.
2060 */
2061const char *LLVMGetMDString(LLVMValueRef V, unsigned* Len);
2062
2063/**
Duncan Sands12ccbe72012-09-19 20:29:39 +00002064 * Obtain the number of operands from an MDNode value.
2065 *
2066 * @param V MDNode to get number of operands from.
2067 * @return Number of operands of the MDNode.
2068 */
2069unsigned LLVMGetMDNodeNumOperands(LLVMValueRef V);
2070
2071/**
2072 * Obtain the given MDNode's operands.
2073 *
2074 * The passed LLVMValueRef pointer should point to enough memory to hold all of
2075 * the operands of the given MDNode (see LLVMGetMDNodeNumOperands) as
2076 * LLVMValueRefs. This memory will be populated with the LLVMValueRefs of the
2077 * MDNode's operands.
2078 *
2079 * @param V MDNode to get the operands from.
2080 * @param Dest Destination array for operands.
2081 */
2082void LLVMGetMDNodeOperands(LLVMValueRef V, LLVMValueRef *Dest);
2083
2084/**
Gregory Szorc52d26602012-03-21 07:28:27 +00002085 * @}
2086 */
2087
2088/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002089 * @defgroup LLVMCCoreValueBasicBlock Basic Block
2090 *
2091 * A basic block represents a single entry single exit section of code.
2092 * Basic blocks contain a list of instructions which form the body of
2093 * the block.
2094 *
2095 * Basic blocks belong to functions. They have the type of label.
2096 *
2097 * Basic blocks are themselves values. However, the C API models them as
2098 * LLVMBasicBlockRef.
2099 *
2100 * @see llvm::BasicBlock
2101 *
2102 * @{
2103 */
2104
2105/**
2106 * Convert a basic block instance to a value type.
2107 */
Gordon Henriksen07a45f42008-03-23 22:21:29 +00002108LLVMValueRef LLVMBasicBlockAsValue(LLVMBasicBlockRef BB);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002109
2110/**
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00002111 * Determine whether an LLVMValueRef is itself a basic block.
Gregory Szorc34c863a2012-03-21 03:54:29 +00002112 */
Chris Lattner25963c62010-01-09 22:27:07 +00002113LLVMBool LLVMValueIsBasicBlock(LLVMValueRef Val);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002114
2115/**
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00002116 * Convert an LLVMValueRef to an LLVMBasicBlockRef instance.
Gregory Szorc34c863a2012-03-21 03:54:29 +00002117 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002118LLVMBasicBlockRef LLVMValueAsBasicBlock(LLVMValueRef Val);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002119
2120/**
Amaury Secheta82042e2016-02-09 22:36:41 +00002121 * Obtain the string name of a basic block.
2122 */
2123const char *LLVMGetBasicBlockName(LLVMBasicBlockRef BB);
2124
2125/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002126 * Obtain the function to which a basic block belongs.
2127 *
2128 * @see llvm::BasicBlock::getParent()
2129 */
Gordon Henriksen07a45f42008-03-23 22:21:29 +00002130LLVMValueRef LLVMGetBasicBlockParent(LLVMBasicBlockRef BB);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002131
2132/**
2133 * Obtain the terminator instruction for a basic block.
2134 *
2135 * If the basic block does not have a terminator (it is not well-formed
2136 * if it doesn't), then NULL is returned.
2137 *
2138 * The returned LLVMValueRef corresponds to a llvm::TerminatorInst.
2139 *
2140 * @see llvm::BasicBlock::getTerminator()
2141 */
Nate Begeman43c322b2011-08-23 20:27:46 +00002142LLVMValueRef LLVMGetBasicBlockTerminator(LLVMBasicBlockRef BB);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002143
2144/**
2145 * Obtain the number of basic blocks in a function.
2146 *
2147 * @param Fn Function value to operate on.
2148 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002149unsigned LLVMCountBasicBlocks(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002150
2151/**
2152 * Obtain all of the basic blocks in a function.
2153 *
2154 * This operates on a function value. The BasicBlocks parameter is a
2155 * pointer to a pre-allocated array of LLVMBasicBlockRef of at least
2156 * LLVMCountBasicBlocks() in length. This array is populated with
2157 * LLVMBasicBlockRef instances.
2158 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002159void LLVMGetBasicBlocks(LLVMValueRef Fn, LLVMBasicBlockRef *BasicBlocks);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002160
2161/**
2162 * Obtain the first basic block in a function.
2163 *
2164 * The returned basic block can be used as an iterator. You will likely
2165 * eventually call into LLVMGetNextBasicBlock() with it.
2166 *
2167 * @see llvm::Function::begin()
2168 */
Gordon Henriksen054817c2008-03-19 03:47:18 +00002169LLVMBasicBlockRef LLVMGetFirstBasicBlock(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002170
2171/**
2172 * Obtain the last basic block in a function.
2173 *
2174 * @see llvm::Function::end()
2175 */
Gordon Henriksen054817c2008-03-19 03:47:18 +00002176LLVMBasicBlockRef LLVMGetLastBasicBlock(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002177
2178/**
2179 * Advance a basic block iterator.
2180 */
Gordon Henriksen054817c2008-03-19 03:47:18 +00002181LLVMBasicBlockRef LLVMGetNextBasicBlock(LLVMBasicBlockRef BB);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002182
2183/**
2184 * Go backwards in a basic block iterator.
2185 */
Gordon Henriksen054817c2008-03-19 03:47:18 +00002186LLVMBasicBlockRef LLVMGetPreviousBasicBlock(LLVMBasicBlockRef BB);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002187
2188/**
2189 * Obtain the basic block that corresponds to the entry point of a
2190 * function.
2191 *
2192 * @see llvm::Function::getEntryBlock()
2193 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002194LLVMBasicBlockRef LLVMGetEntryBasicBlock(LLVMValueRef Fn);
Erick Tryzelaar262332f2009-08-14 00:01:31 +00002195
Gregory Szorc34c863a2012-03-21 03:54:29 +00002196/**
2197 * Append a basic block to the end of a function.
2198 *
2199 * @see llvm::BasicBlock::Create()
2200 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +00002201LLVMBasicBlockRef LLVMAppendBasicBlockInContext(LLVMContextRef C,
2202 LLVMValueRef Fn,
2203 const char *Name);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002204
2205/**
2206 * Append a basic block to the end of a function using the global
2207 * context.
2208 *
2209 * @see llvm::BasicBlock::Create()
2210 */
2211LLVMBasicBlockRef LLVMAppendBasicBlock(LLVMValueRef Fn, const char *Name);
2212
2213/**
2214 * Insert a basic block in a function before another basic block.
2215 *
2216 * The function to add to is determined by the function of the
2217 * passed basic block.
2218 *
2219 * @see llvm::BasicBlock::Create()
2220 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +00002221LLVMBasicBlockRef LLVMInsertBasicBlockInContext(LLVMContextRef C,
2222 LLVMBasicBlockRef BB,
2223 const char *Name);
2224
Gregory Szorc34c863a2012-03-21 03:54:29 +00002225/**
2226 * Insert a basic block in a function using the global context.
2227 *
2228 * @see llvm::BasicBlock::Create()
2229 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002230LLVMBasicBlockRef LLVMInsertBasicBlock(LLVMBasicBlockRef InsertBeforeBB,
2231 const char *Name);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002232
2233/**
2234 * Remove a basic block from a function and delete it.
2235 *
2236 * This deletes the basic block from its containing function and deletes
2237 * the basic block itself.
2238 *
2239 * @see llvm::BasicBlock::eraseFromParent()
2240 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002241void LLVMDeleteBasicBlock(LLVMBasicBlockRef BB);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002242
2243/**
2244 * Remove a basic block from a function.
2245 *
2246 * This deletes the basic block from its containing function but keep
2247 * the basic block alive.
2248 *
2249 * @see llvm::BasicBlock::removeFromParent()
2250 */
Nate Begeman43c322b2011-08-23 20:27:46 +00002251void LLVMRemoveBasicBlockFromParent(LLVMBasicBlockRef BB);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002252
Gregory Szorc34c863a2012-03-21 03:54:29 +00002253/**
2254 * Move a basic block to before another one.
2255 *
2256 * @see llvm::BasicBlock::moveBefore()
2257 */
Duncan Sandsb1d61aa2010-07-19 15:31:07 +00002258void LLVMMoveBasicBlockBefore(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002259
2260/**
2261 * Move a basic block to after another one.
2262 *
2263 * @see llvm::BasicBlock::moveAfter()
2264 */
Duncan Sandsb1d61aa2010-07-19 15:31:07 +00002265void LLVMMoveBasicBlockAfter(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos);
2266
Gregory Szorc34c863a2012-03-21 03:54:29 +00002267/**
2268 * Obtain the first instruction in a basic block.
2269 *
2270 * The returned LLVMValueRef corresponds to a llvm::Instruction
2271 * instance.
2272 */
Gordon Henriksen054817c2008-03-19 03:47:18 +00002273LLVMValueRef LLVMGetFirstInstruction(LLVMBasicBlockRef BB);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002274
2275/**
2276 * Obtain the last instruction in a basic block.
2277 *
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00002278 * The returned LLVMValueRef corresponds to an LLVM:Instruction.
Gregory Szorc34c863a2012-03-21 03:54:29 +00002279 */
Gordon Henriksen054817c2008-03-19 03:47:18 +00002280LLVMValueRef LLVMGetLastInstruction(LLVMBasicBlockRef BB);
Nate Begeman43c322b2011-08-23 20:27:46 +00002281
Gregory Szorc34c863a2012-03-21 03:54:29 +00002282/**
2283 * @}
2284 */
2285
2286/**
2287 * @defgroup LLVMCCoreValueInstruction Instructions
2288 *
2289 * Functions in this group relate to the inspection and manipulation of
2290 * individual instructions.
2291 *
2292 * In the C++ API, an instruction is modeled by llvm::Instruction. This
2293 * class has a large number of descendents. llvm::Instruction is a
2294 * llvm::Value and in the C API, instructions are modeled by
2295 * LLVMValueRef.
2296 *
2297 * This group also contains sub-groups which operate on specific
2298 * llvm::Instruction types, e.g. llvm::CallInst.
2299 *
2300 * @{
2301 */
2302
2303/**
2304 * Determine whether an instruction has any metadata attached.
2305 */
2306int LLVMHasMetadata(LLVMValueRef Val);
2307
2308/**
2309 * Return metadata associated with an instruction value.
2310 */
2311LLVMValueRef LLVMGetMetadata(LLVMValueRef Val, unsigned KindID);
2312
2313/**
2314 * Set metadata associated with an instruction value.
2315 */
2316void LLVMSetMetadata(LLVMValueRef Val, unsigned KindID, LLVMValueRef Node);
2317
2318/**
2319 * Obtain the basic block to which an instruction belongs.
2320 *
2321 * @see llvm::Instruction::getParent()
2322 */
Nate Begeman43c322b2011-08-23 20:27:46 +00002323LLVMBasicBlockRef LLVMGetInstructionParent(LLVMValueRef Inst);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002324
2325/**
2326 * Obtain the instruction that occurs after the one specified.
2327 *
2328 * The next instruction will be from the same basic block.
2329 *
2330 * If this is the last instruction in a basic block, NULL will be
2331 * returned.
2332 */
Gordon Henriksen054817c2008-03-19 03:47:18 +00002333LLVMValueRef LLVMGetNextInstruction(LLVMValueRef Inst);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002334
2335/**
Benjamin Kramerbde91762012-06-02 10:20:22 +00002336 * Obtain the instruction that occurred before this one.
Gregory Szorc34c863a2012-03-21 03:54:29 +00002337 *
2338 * If the instruction is the first instruction in a basic block, NULL
2339 * will be returned.
2340 */
Gordon Henriksen054817c2008-03-19 03:47:18 +00002341LLVMValueRef LLVMGetPreviousInstruction(LLVMValueRef Inst);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002342
2343/**
2344 * Remove and delete an instruction.
2345 *
2346 * The instruction specified is removed from its containing building
Amaury Sechet2f432082016-02-11 21:37:54 +00002347 * block but is kept alive.
2348 *
2349 * @see llvm::Instruction::removeFromParent()
2350 */
2351void LLVMInstructionRemoveFromParent(LLVMValueRef Inst);
2352
2353/**
2354 * Remove and delete an instruction.
2355 *
2356 * The instruction specified is removed from its containing building
Gregory Szorc34c863a2012-03-21 03:54:29 +00002357 * block and then deleted.
2358 *
2359 * @see llvm::Instruction::eraseFromParent()
2360 */
Devang Pateldbebc6f2011-10-03 20:59:18 +00002361void LLVMInstructionEraseFromParent(LLVMValueRef Inst);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002362
2363/**
2364 * Obtain the code opcode for an individual instruction.
2365 *
2366 * @see llvm::Instruction::getOpCode()
2367 */
Eric Christophera6b96002015-12-18 01:46:52 +00002368LLVMOpcode LLVMGetInstructionOpcode(LLVMValueRef Inst);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002369
2370/**
2371 * Obtain the predicate of an instruction.
2372 *
2373 * This is only valid for instructions that correspond to llvm::ICmpInst
2374 * or llvm::ConstantExpr whose opcode is llvm::Instruction::ICmp.
2375 *
2376 * @see llvm::ICmpInst::getPredicate()
2377 */
Torok Edwin60c40de2011-10-06 12:13:20 +00002378LLVMIntPredicate LLVMGetICmpPredicate(LLVMValueRef Inst);
Gordon Henriksen265f7802008-03-19 01:11:35 +00002379
Gregory Szorc34c863a2012-03-21 03:54:29 +00002380/**
Peter Zotov1d98e6d2014-10-28 19:46:44 +00002381 * Obtain the float predicate of an instruction.
2382 *
2383 * This is only valid for instructions that correspond to llvm::FCmpInst
2384 * or llvm::ConstantExpr whose opcode is llvm::Instruction::FCmp.
2385 *
2386 * @see llvm::FCmpInst::getPredicate()
2387 */
2388LLVMRealPredicate LLVMGetFCmpPredicate(LLVMValueRef Inst);
2389
2390/**
Peter Zotovaff492c2014-10-17 01:02:34 +00002391 * Create a copy of 'this' instruction that is identical in all ways
2392 * except the following:
2393 * * The instruction has no parent
2394 * * The instruction has no name
2395 *
2396 * @see llvm::Instruction::clone()
2397 */
2398LLVMValueRef LLVMInstructionClone(LLVMValueRef Inst);
2399
2400/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002401 * @defgroup LLVMCCoreValueInstructionCall Call Sites and Invocations
2402 *
2403 * Functions in this group apply to instructions that refer to call
2404 * sites and invocations. These correspond to C++ types in the
2405 * llvm::CallInst class tree.
2406 *
2407 * @{
2408 */
2409
2410/**
Amaury Sechet5c7b3af2016-02-10 00:09:37 +00002411 * Obtain the argument count for a call instruction.
2412 *
2413 * This expects an LLVMValueRef that corresponds to a llvm::CallInst or
2414 * llvm::InvokeInst.
2415 *
2416 * @see llvm::CallInst::getNumArgOperands()
2417 * @see llvm::InvokeInst::getNumArgOperands()
2418 */
2419unsigned LLVMGetNumArgOperands(LLVMValueRef Instr);
2420
2421/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002422 * Set the calling convention for a call instruction.
2423 *
2424 * This expects an LLVMValueRef that corresponds to a llvm::CallInst or
2425 * llvm::InvokeInst.
2426 *
2427 * @see llvm::CallInst::setCallingConv()
2428 * @see llvm::InvokeInst::setCallingConv()
2429 */
Gordon Henriksen1158c532007-12-29 20:45:00 +00002430void LLVMSetInstructionCallConv(LLVMValueRef Instr, unsigned CC);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002431
2432/**
2433 * Obtain the calling convention for a call instruction.
2434 *
2435 * This is the opposite of LLVMSetInstructionCallConv(). Reads its
2436 * usage.
2437 *
2438 * @see LLVMSetInstructionCallConv()
2439 */
Gordon Henriksen1158c532007-12-29 20:45:00 +00002440unsigned LLVMGetInstructionCallConv(LLVMValueRef Instr);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002441
2442
Devang Patel4c758ea2008-09-25 21:00:45 +00002443void LLVMAddInstrAttribute(LLVMValueRef Instr, unsigned index, LLVMAttribute);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002444void LLVMRemoveInstrAttribute(LLVMValueRef Instr, unsigned index,
Devang Patel4c758ea2008-09-25 21:00:45 +00002445 LLVMAttribute);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002446void LLVMSetInstrParamAlignment(LLVMValueRef Instr, unsigned index,
Gordon Henriksen2d9cc212008-04-28 17:37:06 +00002447 unsigned align);
Gordon Henriksen1158c532007-12-29 20:45:00 +00002448
Gregory Szorc34c863a2012-03-21 03:54:29 +00002449/**
Amaury Sechet5c7b3af2016-02-10 00:09:37 +00002450 * Obtain the pointer to the function invoked by this instruction.
2451 *
2452 * This expects an LLVMValueRef that corresponds to a llvm::CallInst or
2453 * llvm::InvokeInst.
2454 *
2455 * @see llvm::CallInst::getCalledValue()
2456 * @see llvm::InvokeInst::getCalledValue()
2457 */
2458LLVMValueRef LLVMGetCalledValue(LLVMValueRef Instr);
2459
2460/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002461 * Obtain whether a call instruction is a tail call.
2462 *
2463 * This only works on llvm::CallInst instructions.
2464 *
2465 * @see llvm::CallInst::isTailCall()
2466 */
Chris Lattner25963c62010-01-09 22:27:07 +00002467LLVMBool LLVMIsTailCall(LLVMValueRef CallInst);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002468
2469/**
2470 * Set whether a call instruction is a tail call.
2471 *
2472 * This only works on llvm::CallInst instructions.
2473 *
2474 * @see llvm::CallInst::setTailCall()
2475 */
Chris Lattner25963c62010-01-09 22:27:07 +00002476void LLVMSetTailCall(LLVMValueRef CallInst, LLVMBool IsTailCall);
Gordon Henrikseneeb65372008-08-30 16:34:54 +00002477
Gregory Szorc34c863a2012-03-21 03:54:29 +00002478/**
Amaury Sechete39e8532016-02-18 20:38:32 +00002479 * Return the normal destination basic block.
2480 *
2481 * This only works on llvm::InvokeInst instructions.
2482 *
2483 * @see llvm::InvokeInst::getNormalDest()
2484 */
2485LLVMBasicBlockRef LLVMGetNormalDest(LLVMValueRef InvokeInst);
2486
2487/**
2488 * Return the unwind destination basic block.
2489 *
2490 * This only works on llvm::InvokeInst instructions.
2491 *
2492 * @see llvm::InvokeInst::getUnwindDest()
2493 */
2494LLVMBasicBlockRef LLVMGetUnwindDest(LLVMValueRef InvokeInst);
2495
2496/**
2497 * Set the normal destination basic block.
2498 *
2499 * This only works on llvm::InvokeInst instructions.
2500 *
2501 * @see llvm::InvokeInst::setNormalDest()
2502 */
2503void LLVMSetNormalDest(LLVMValueRef InvokeInst, LLVMBasicBlockRef B);
2504
2505/**
2506 * Set the unwind destination basic block.
2507 *
2508 * This only works on llvm::InvokeInst instructions.
2509 *
2510 * @see llvm::InvokeInst::setUnwindDest()
2511 */
2512void LLVMSetUnwindDest(LLVMValueRef InvokeInst, LLVMBasicBlockRef B);
2513
2514/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002515 * @}
2516 */
2517
2518/**
Peter Zotov2481c752014-10-28 19:46:56 +00002519 * @defgroup LLVMCCoreValueInstructionTerminator Terminators
2520 *
2521 * Functions in this group only apply to instructions that map to
2522 * llvm::TerminatorInst instances.
2523 *
2524 * @{
2525 */
2526
2527/**
2528 * Return the number of successors that this terminator has.
2529 *
2530 * @see llvm::TerminatorInst::getNumSuccessors
2531 */
2532unsigned LLVMGetNumSuccessors(LLVMValueRef Term);
2533
2534/**
2535 * Return the specified successor.
2536 *
2537 * @see llvm::TerminatorInst::getSuccessor
2538 */
2539LLVMBasicBlockRef LLVMGetSuccessor(LLVMValueRef Term, unsigned i);
2540
2541/**
2542 * Update the specified successor to point at the provided block.
2543 *
2544 * @see llvm::TerminatorInst::setSuccessor
2545 */
2546void LLVMSetSuccessor(LLVMValueRef Term, unsigned i, LLVMBasicBlockRef block);
2547
2548/**
2549 * Return if a branch is conditional.
2550 *
2551 * This only works on llvm::BranchInst instructions.
2552 *
2553 * @see llvm::BranchInst::isConditional
2554 */
2555LLVMBool LLVMIsConditional(LLVMValueRef Branch);
2556
2557/**
2558 * Return the condition of a branch instruction.
2559 *
2560 * This only works on llvm::BranchInst instructions.
2561 *
2562 * @see llvm::BranchInst::getCondition
2563 */
2564LLVMValueRef LLVMGetCondition(LLVMValueRef Branch);
2565
2566/**
2567 * Set the condition of a branch instruction.
2568 *
2569 * This only works on llvm::BranchInst instructions.
2570 *
2571 * @see llvm::BranchInst::setCondition
2572 */
2573void LLVMSetCondition(LLVMValueRef Branch, LLVMValueRef Cond);
2574
2575/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002576 * Obtain the default destination basic block of a switch instruction.
2577 *
2578 * This only works on llvm::SwitchInst instructions.
2579 *
2580 * @see llvm::SwitchInst::getDefaultDest()
2581 */
Nate Begeman43c322b2011-08-23 20:27:46 +00002582LLVMBasicBlockRef LLVMGetSwitchDefaultDest(LLVMValueRef SwitchInstr);
2583
Gregory Szorc34c863a2012-03-21 03:54:29 +00002584/**
Peter Zotov2481c752014-10-28 19:46:56 +00002585 * @}
2586 */
2587
2588/**
Amaury Sechet1dcf5772016-02-09 22:50:53 +00002589 * @defgroup LLVMCCoreValueInstructionAlloca Allocas
2590 *
2591 * Functions in this group only apply to instructions that map to
2592 * llvm::AllocaInst instances.
2593 *
2594 * @{
2595 */
2596
2597/**
2598 * Obtain the type that is being allocated by the alloca instruction.
2599 */
2600LLVMTypeRef LLVMGetAllocatedType(LLVMValueRef Alloca);
2601
2602/**
2603 * @}
2604 */
2605
2606/**
Amaury Sechet053ac452016-02-17 22:51:03 +00002607 * @defgroup LLVMCCoreValueInstructionGetElementPointer GEPs
2608 *
2609 * Functions in this group only apply to instructions that map to
2610 * llvm::GetElementPtrInst instances.
2611 *
2612 * @{
2613 */
2614
2615/**
2616 * Check whether the given GEP instruction is inbounds.
2617 */
2618LLVMBool LLVMIsInBounds(LLVMValueRef GEP);
2619
2620/**
2621 * Set the given GEP instruction to be inbounds or not.
2622 */
2623void LLVMSetIsInBounds(LLVMValueRef GEP, LLVMBool b);
2624
2625/**
2626 * @}
2627 */
2628
2629/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002630 * @defgroup LLVMCCoreValueInstructionPHINode PHI Nodes
2631 *
2632 * Functions in this group only apply to instructions that map to
2633 * llvm::PHINode instances.
2634 *
2635 * @{
2636 */
2637
2638/**
2639 * Add an incoming value to the end of a PHI list.
2640 */
Gordon Henriksen44dd8fb2007-10-08 18:14:39 +00002641void LLVMAddIncoming(LLVMValueRef PhiNode, LLVMValueRef *IncomingValues,
2642 LLVMBasicBlockRef *IncomingBlocks, unsigned Count);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002643
2644/**
2645 * Obtain the number of incoming basic blocks to a PHI node.
2646 */
Gordon Henriksen44dd8fb2007-10-08 18:14:39 +00002647unsigned LLVMCountIncoming(LLVMValueRef PhiNode);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002648
2649/**
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00002650 * Obtain an incoming value to a PHI node as an LLVMValueRef.
Gregory Szorc34c863a2012-03-21 03:54:29 +00002651 */
Gordon Henriksen44dd8fb2007-10-08 18:14:39 +00002652LLVMValueRef LLVMGetIncomingValue(LLVMValueRef PhiNode, unsigned Index);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002653
2654/**
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00002655 * Obtain an incoming value to a PHI node as an LLVMBasicBlockRef.
Gregory Szorc34c863a2012-03-21 03:54:29 +00002656 */
Gordon Henriksen44dd8fb2007-10-08 18:14:39 +00002657LLVMBasicBlockRef LLVMGetIncomingBlock(LLVMValueRef PhiNode, unsigned Index);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002658
Gregory Szorc34c863a2012-03-21 03:54:29 +00002659/**
2660 * @}
2661 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002662
Gregory Szorc34c863a2012-03-21 03:54:29 +00002663/**
Amaury Sechetaad93532016-02-10 00:38:50 +00002664 * @defgroup LLVMCCoreValueInstructionExtractValue ExtractValue
2665 * @defgroup LLVMCCoreValueInstructionInsertValue InsertValue
2666 *
2667 * Functions in this group only apply to instructions that map to
2668 * llvm::ExtractValue and llvm::InsertValue instances.
2669 *
2670 * @{
2671 */
2672
2673/**
2674 * Obtain the number of indices.
Amaury Sechet053ac452016-02-17 22:51:03 +00002675 * NB: This also works on GEP.
Amaury Sechetaad93532016-02-10 00:38:50 +00002676 */
2677unsigned LLVMGetNumIndices(LLVMValueRef Inst);
2678
2679/**
2680 * Obtain the indices as an array.
2681 */
2682const unsigned *LLVMGetIndices(LLVMValueRef Inst);
2683
2684/**
2685 * @}
2686 */
2687
2688/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002689 * @}
2690 */
2691
2692/**
2693 * @}
2694 */
2695
2696/**
2697 * @defgroup LLVMCCoreInstructionBuilder Instruction Builders
2698 *
2699 * An instruction builder represents a point within a basic block and is
2700 * the exclusive means of building instructions using the C interface.
2701 *
2702 * @{
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002703 */
2704
Erick Tryzelaar262332f2009-08-14 00:01:31 +00002705LLVMBuilderRef LLVMCreateBuilderInContext(LLVMContextRef C);
Gordon Henriksena735a9c2008-05-04 12:55:34 +00002706LLVMBuilderRef LLVMCreateBuilder(void);
Gordon Henriksen054817c2008-03-19 03:47:18 +00002707void LLVMPositionBuilder(LLVMBuilderRef Builder, LLVMBasicBlockRef Block,
2708 LLVMValueRef Instr);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002709void LLVMPositionBuilderBefore(LLVMBuilderRef Builder, LLVMValueRef Instr);
2710void LLVMPositionBuilderAtEnd(LLVMBuilderRef Builder, LLVMBasicBlockRef Block);
Gordon Henriksen265f7802008-03-19 01:11:35 +00002711LLVMBasicBlockRef LLVMGetInsertBlock(LLVMBuilderRef Builder);
Chris Lattner3d1f5522008-12-17 21:39:50 +00002712void LLVMClearInsertionPosition(LLVMBuilderRef Builder);
2713void LLVMInsertIntoBuilder(LLVMBuilderRef Builder, LLVMValueRef Instr);
Erick Tryzelaar9813bea2009-08-16 02:20:57 +00002714void LLVMInsertIntoBuilderWithName(LLVMBuilderRef Builder, LLVMValueRef Instr,
2715 const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002716void LLVMDisposeBuilder(LLVMBuilderRef Builder);
2717
Erick Tryzelaard8531fa2010-02-28 09:45:59 +00002718/* Metadata */
2719void LLVMSetCurrentDebugLocation(LLVMBuilderRef Builder, LLVMValueRef L);
2720LLVMValueRef LLVMGetCurrentDebugLocation(LLVMBuilderRef Builder);
2721void LLVMSetInstDebugLocation(LLVMBuilderRef Builder, LLVMValueRef Inst);
2722
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002723/* Terminators */
2724LLVMValueRef LLVMBuildRetVoid(LLVMBuilderRef);
2725LLVMValueRef LLVMBuildRet(LLVMBuilderRef, LLVMValueRef V);
Erick Tryzelaarfd529d72009-08-19 08:36:49 +00002726LLVMValueRef LLVMBuildAggregateRet(LLVMBuilderRef, LLVMValueRef *RetVals,
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002727 unsigned N);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002728LLVMValueRef LLVMBuildBr(LLVMBuilderRef, LLVMBasicBlockRef Dest);
2729LLVMValueRef LLVMBuildCondBr(LLVMBuilderRef, LLVMValueRef If,
2730 LLVMBasicBlockRef Then, LLVMBasicBlockRef Else);
2731LLVMValueRef LLVMBuildSwitch(LLVMBuilderRef, LLVMValueRef V,
2732 LLVMBasicBlockRef Else, unsigned NumCases);
Erick Tryzelaar0fb26ef2010-02-28 09:46:06 +00002733LLVMValueRef LLVMBuildIndirectBr(LLVMBuilderRef B, LLVMValueRef Addr,
2734 unsigned NumDests);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002735LLVMValueRef LLVMBuildInvoke(LLVMBuilderRef, LLVMValueRef Fn,
2736 LLVMValueRef *Args, unsigned NumArgs,
2737 LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch,
2738 const char *Name);
Benjamin Kramer5a6568832011-08-19 01:36:54 +00002739LLVMValueRef LLVMBuildLandingPad(LLVMBuilderRef B, LLVMTypeRef Ty,
Reid Kleckneref9828f2015-07-16 01:16:39 +00002740 LLVMValueRef PersFn, unsigned NumClauses,
2741 const char *Name);
Bill Wendlingf891bf82011-07-31 06:30:59 +00002742LLVMValueRef LLVMBuildResume(LLVMBuilderRef B, LLVMValueRef Exn);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002743LLVMValueRef LLVMBuildUnreachable(LLVMBuilderRef);
2744
Gordon Henriksen097102c2008-01-01 05:50:53 +00002745/* Add a case to the switch instruction */
2746void LLVMAddCase(LLVMValueRef Switch, LLVMValueRef OnVal,
2747 LLVMBasicBlockRef Dest);
2748
Erick Tryzelaar0fb26ef2010-02-28 09:46:06 +00002749/* Add a destination to the indirectbr instruction */
2750void LLVMAddDestination(LLVMValueRef IndirectBr, LLVMBasicBlockRef Dest);
2751
Amaury Sechete39e8532016-02-18 20:38:32 +00002752/* Get the number of clauses on the landingpad instruction */
2753unsigned LLVMGetNumClauses(LLVMValueRef LandingPad);
2754
2755/* Get the value of the clause at idnex Idx on the landingpad instruction */
2756LLVMValueRef LLVMGetClause(LLVMValueRef LandingPad, unsigned Idx);
2757
Bill Wendlingfae14752011-08-12 20:24:12 +00002758/* Add a catch or filter clause to the landingpad instruction */
2759void LLVMAddClause(LLVMValueRef LandingPad, LLVMValueRef ClauseVal);
2760
Amaury Sechete39e8532016-02-18 20:38:32 +00002761/* Get the 'cleanup' flag in the landingpad instruction */
2762LLVMBool LLVMIsCleanup(LLVMValueRef LandingPad);
2763
Bill Wendlingfae14752011-08-12 20:24:12 +00002764/* Set the 'cleanup' flag in the landingpad instruction */
2765void LLVMSetCleanup(LLVMValueRef LandingPad, LLVMBool Val);
2766
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002767/* Arithmetic */
2768LLVMValueRef LLVMBuildAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2769 const char *Name);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002770LLVMValueRef LLVMBuildNSWAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2771 const char *Name);
Erick Tryzelaar4c340c72010-02-28 05:51:43 +00002772LLVMValueRef LLVMBuildNUWAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2773 const char *Name);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002774LLVMValueRef LLVMBuildFAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2775 const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002776LLVMValueRef LLVMBuildSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2777 const char *Name);
Erick Tryzelaar4c340c72010-02-28 05:51:43 +00002778LLVMValueRef LLVMBuildNSWSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2779 const char *Name);
2780LLVMValueRef LLVMBuildNUWSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2781 const char *Name);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002782LLVMValueRef LLVMBuildFSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2783 const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002784LLVMValueRef LLVMBuildMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2785 const char *Name);
Erick Tryzelaar4c340c72010-02-28 05:51:43 +00002786LLVMValueRef LLVMBuildNSWMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2787 const char *Name);
2788LLVMValueRef LLVMBuildNUWMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2789 const char *Name);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002790LLVMValueRef LLVMBuildFMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2791 const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002792LLVMValueRef LLVMBuildUDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2793 const char *Name);
2794LLVMValueRef LLVMBuildSDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2795 const char *Name);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002796LLVMValueRef LLVMBuildExactSDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2797 const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002798LLVMValueRef LLVMBuildFDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2799 const char *Name);
2800LLVMValueRef LLVMBuildURem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2801 const char *Name);
2802LLVMValueRef LLVMBuildSRem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2803 const char *Name);
2804LLVMValueRef LLVMBuildFRem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2805 const char *Name);
2806LLVMValueRef LLVMBuildShl(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2807 const char *Name);
2808LLVMValueRef LLVMBuildLShr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2809 const char *Name);
2810LLVMValueRef LLVMBuildAShr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2811 const char *Name);
2812LLVMValueRef LLVMBuildAnd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2813 const char *Name);
2814LLVMValueRef LLVMBuildOr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2815 const char *Name);
2816LLVMValueRef LLVMBuildXor(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2817 const char *Name);
Erick Tryzelaar31831792010-02-28 05:51:27 +00002818LLVMValueRef LLVMBuildBinOp(LLVMBuilderRef B, LLVMOpcode Op,
2819 LLVMValueRef LHS, LLVMValueRef RHS,
2820 const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002821LLVMValueRef LLVMBuildNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name);
Erick Tryzelaar4c340c72010-02-28 05:51:43 +00002822LLVMValueRef LLVMBuildNSWNeg(LLVMBuilderRef B, LLVMValueRef V,
2823 const char *Name);
2824LLVMValueRef LLVMBuildNUWNeg(LLVMBuilderRef B, LLVMValueRef V,
2825 const char *Name);
Dan Gohmanf919bd62009-09-28 21:51:41 +00002826LLVMValueRef LLVMBuildFNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002827LLVMValueRef LLVMBuildNot(LLVMBuilderRef, LLVMValueRef V, const char *Name);
2828
2829/* Memory */
2830LLVMValueRef LLVMBuildMalloc(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
2831LLVMValueRef LLVMBuildArrayMalloc(LLVMBuilderRef, LLVMTypeRef Ty,
2832 LLVMValueRef Val, const char *Name);
2833LLVMValueRef LLVMBuildAlloca(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
2834LLVMValueRef LLVMBuildArrayAlloca(LLVMBuilderRef, LLVMTypeRef Ty,
2835 LLVMValueRef Val, const char *Name);
2836LLVMValueRef LLVMBuildFree(LLVMBuilderRef, LLVMValueRef PointerVal);
2837LLVMValueRef LLVMBuildLoad(LLVMBuilderRef, LLVMValueRef PointerVal,
2838 const char *Name);
2839LLVMValueRef LLVMBuildStore(LLVMBuilderRef, LLVMValueRef Val, LLVMValueRef Ptr);
2840LLVMValueRef LLVMBuildGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
2841 LLVMValueRef *Indices, unsigned NumIndices,
2842 const char *Name);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002843LLVMValueRef LLVMBuildInBoundsGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
2844 LLVMValueRef *Indices, unsigned NumIndices,
2845 const char *Name);
2846LLVMValueRef LLVMBuildStructGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
2847 unsigned Idx, const char *Name);
2848LLVMValueRef LLVMBuildGlobalString(LLVMBuilderRef B, const char *Str,
2849 const char *Name);
2850LLVMValueRef LLVMBuildGlobalStringPtr(LLVMBuilderRef B, const char *Str,
2851 const char *Name);
Chris Lattner2cc6f9d2012-03-22 03:54:15 +00002852LLVMBool LLVMGetVolatile(LLVMValueRef MemoryAccessInst);
2853void LLVMSetVolatile(LLVMValueRef MemoryAccessInst, LLVMBool IsVolatile);
Andrew Wilkinsb7362ce2015-08-02 12:16:57 +00002854LLVMAtomicOrdering LLVMGetOrdering(LLVMValueRef MemoryAccessInst);
2855void LLVMSetOrdering(LLVMValueRef MemoryAccessInst, LLVMAtomicOrdering Ordering);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002856
2857/* Casts */
2858LLVMValueRef LLVMBuildTrunc(LLVMBuilderRef, LLVMValueRef Val,
2859 LLVMTypeRef DestTy, const char *Name);
2860LLVMValueRef LLVMBuildZExt(LLVMBuilderRef, LLVMValueRef Val,
2861 LLVMTypeRef DestTy, const char *Name);
2862LLVMValueRef LLVMBuildSExt(LLVMBuilderRef, LLVMValueRef Val,
2863 LLVMTypeRef DestTy, const char *Name);
2864LLVMValueRef LLVMBuildFPToUI(LLVMBuilderRef, LLVMValueRef Val,
2865 LLVMTypeRef DestTy, const char *Name);
2866LLVMValueRef LLVMBuildFPToSI(LLVMBuilderRef, LLVMValueRef Val,
2867 LLVMTypeRef DestTy, const char *Name);
2868LLVMValueRef LLVMBuildUIToFP(LLVMBuilderRef, LLVMValueRef Val,
2869 LLVMTypeRef DestTy, const char *Name);
2870LLVMValueRef LLVMBuildSIToFP(LLVMBuilderRef, LLVMValueRef Val,
2871 LLVMTypeRef DestTy, const char *Name);
2872LLVMValueRef LLVMBuildFPTrunc(LLVMBuilderRef, LLVMValueRef Val,
2873 LLVMTypeRef DestTy, const char *Name);
2874LLVMValueRef LLVMBuildFPExt(LLVMBuilderRef, LLVMValueRef Val,
2875 LLVMTypeRef DestTy, const char *Name);
2876LLVMValueRef LLVMBuildPtrToInt(LLVMBuilderRef, LLVMValueRef Val,
2877 LLVMTypeRef DestTy, const char *Name);
2878LLVMValueRef LLVMBuildIntToPtr(LLVMBuilderRef, LLVMValueRef Val,
2879 LLVMTypeRef DestTy, const char *Name);
2880LLVMValueRef LLVMBuildBitCast(LLVMBuilderRef, LLVMValueRef Val,
2881 LLVMTypeRef DestTy, const char *Name);
Matt Arsenaultb03bd4d2013-11-15 01:34:59 +00002882LLVMValueRef LLVMBuildAddrSpaceCast(LLVMBuilderRef, LLVMValueRef Val,
2883 LLVMTypeRef DestTy, const char *Name);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002884LLVMValueRef LLVMBuildZExtOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
2885 LLVMTypeRef DestTy, const char *Name);
2886LLVMValueRef LLVMBuildSExtOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
2887 LLVMTypeRef DestTy, const char *Name);
2888LLVMValueRef LLVMBuildTruncOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
2889 LLVMTypeRef DestTy, const char *Name);
Erick Tryzelaar31831792010-02-28 05:51:27 +00002890LLVMValueRef LLVMBuildCast(LLVMBuilderRef B, LLVMOpcode Op, LLVMValueRef Val,
2891 LLVMTypeRef DestTy, const char *Name);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002892LLVMValueRef LLVMBuildPointerCast(LLVMBuilderRef, LLVMValueRef Val,
2893 LLVMTypeRef DestTy, const char *Name);
Duncan Sands9d786d72009-11-23 10:49:03 +00002894LLVMValueRef LLVMBuildIntCast(LLVMBuilderRef, LLVMValueRef Val, /*Signed cast!*/
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002895 LLVMTypeRef DestTy, const char *Name);
2896LLVMValueRef LLVMBuildFPCast(LLVMBuilderRef, LLVMValueRef Val,
2897 LLVMTypeRef DestTy, const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002898
2899/* Comparisons */
2900LLVMValueRef LLVMBuildICmp(LLVMBuilderRef, LLVMIntPredicate Op,
2901 LLVMValueRef LHS, LLVMValueRef RHS,
2902 const char *Name);
2903LLVMValueRef LLVMBuildFCmp(LLVMBuilderRef, LLVMRealPredicate Op,
2904 LLVMValueRef LHS, LLVMValueRef RHS,
2905 const char *Name);
2906
2907/* Miscellaneous instructions */
2908LLVMValueRef LLVMBuildPhi(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
2909LLVMValueRef LLVMBuildCall(LLVMBuilderRef, LLVMValueRef Fn,
2910 LLVMValueRef *Args, unsigned NumArgs,
2911 const char *Name);
2912LLVMValueRef LLVMBuildSelect(LLVMBuilderRef, LLVMValueRef If,
2913 LLVMValueRef Then, LLVMValueRef Else,
2914 const char *Name);
2915LLVMValueRef LLVMBuildVAArg(LLVMBuilderRef, LLVMValueRef List, LLVMTypeRef Ty,
2916 const char *Name);
2917LLVMValueRef LLVMBuildExtractElement(LLVMBuilderRef, LLVMValueRef VecVal,
2918 LLVMValueRef Index, const char *Name);
2919LLVMValueRef LLVMBuildInsertElement(LLVMBuilderRef, LLVMValueRef VecVal,
2920 LLVMValueRef EltVal, LLVMValueRef Index,
2921 const char *Name);
2922LLVMValueRef LLVMBuildShuffleVector(LLVMBuilderRef, LLVMValueRef V1,
2923 LLVMValueRef V2, LLVMValueRef Mask,
2924 const char *Name);
Dan Gohmand5104a52008-11-03 22:55:43 +00002925LLVMValueRef LLVMBuildExtractValue(LLVMBuilderRef, LLVMValueRef AggVal,
2926 unsigned Index, const char *Name);
2927LLVMValueRef LLVMBuildInsertValue(LLVMBuilderRef, LLVMValueRef AggVal,
2928 LLVMValueRef EltVal, unsigned Index,
2929 const char *Name);
Gordon Henriksen76a03742007-09-18 03:18:57 +00002930
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002931LLVMValueRef LLVMBuildIsNull(LLVMBuilderRef, LLVMValueRef Val,
2932 const char *Name);
2933LLVMValueRef LLVMBuildIsNotNull(LLVMBuilderRef, LLVMValueRef Val,
2934 const char *Name);
2935LLVMValueRef LLVMBuildPtrDiff(LLVMBuilderRef, LLVMValueRef LHS,
2936 LLVMValueRef RHS, const char *Name);
Filip Pizlo0d3f7ec2013-11-20 00:07:49 +00002937LLVMValueRef LLVMBuildFence(LLVMBuilderRef B, LLVMAtomicOrdering ordering,
2938 LLVMBool singleThread, const char *Name);
2939LLVMValueRef LLVMBuildAtomicRMW(LLVMBuilderRef B, LLVMAtomicRMWBinOp op,
NAKAMURA Takumia3a81352013-10-23 17:56:29 +00002940 LLVMValueRef PTR, LLVMValueRef Val,
2941 LLVMAtomicOrdering ordering,
Carlo Kok8c6719b2013-04-23 13:21:19 +00002942 LLVMBool singleThread);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002943
Gregory Szorc34c863a2012-03-21 03:54:29 +00002944/**
2945 * @}
2946 */
Gordon Henriksen34eb6d82007-12-19 22:30:40 +00002947
Gregory Szorc34c863a2012-03-21 03:54:29 +00002948/**
2949 * @defgroup LLVMCCoreModuleProvider Module Providers
2950 *
2951 * @{
2952 */
Gordon Henriksen0a68fe22007-12-12 01:04:30 +00002953
Gregory Szorc34c863a2012-03-21 03:54:29 +00002954/**
2955 * Changes the type of M so it can be passed to FunctionPassManagers and the
Jeffrey Yasskin091217b2010-01-27 20:34:15 +00002956 * JIT. They take ModuleProviders for historical reasons.
Gordon Henriksen0a68fe22007-12-12 01:04:30 +00002957 */
2958LLVMModuleProviderRef
2959LLVMCreateModuleProviderForExistingModule(LLVMModuleRef M);
2960
Gregory Szorc34c863a2012-03-21 03:54:29 +00002961/**
2962 * Destroys the module M.
Gordon Henriksen0a68fe22007-12-12 01:04:30 +00002963 */
Jeffrey Yasskin091217b2010-01-27 20:34:15 +00002964void LLVMDisposeModuleProvider(LLVMModuleProviderRef M);
Gordon Henriksen0a68fe22007-12-12 01:04:30 +00002965
Gregory Szorc34c863a2012-03-21 03:54:29 +00002966/**
2967 * @}
2968 */
Gordon Henriksen34eb6d82007-12-19 22:30:40 +00002969
Gregory Szorc34c863a2012-03-21 03:54:29 +00002970/**
2971 * @defgroup LLVMCCoreMemoryBuffers Memory Buffers
2972 *
2973 * @{
2974 */
Gordon Henriksen34eb6d82007-12-19 22:30:40 +00002975
Chris Lattner25963c62010-01-09 22:27:07 +00002976LLVMBool LLVMCreateMemoryBufferWithContentsOfFile(const char *Path,
2977 LLVMMemoryBufferRef *OutMemBuf,
2978 char **OutMessage);
2979LLVMBool LLVMCreateMemoryBufferWithSTDIN(LLVMMemoryBufferRef *OutMemBuf,
2980 char **OutMessage);
Bill Wendling526276a2013-02-14 19:11:28 +00002981LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRange(const char *InputData,
2982 size_t InputDataLength,
2983 const char *BufferName,
Bill Wendlingc9baa962013-02-14 19:39:14 +00002984 LLVMBool RequiresNullTerminator);
Bill Wendling526276a2013-02-14 19:11:28 +00002985LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRangeCopy(const char *InputData,
2986 size_t InputDataLength,
2987 const char *BufferName);
Tom Stellard62c03202013-04-18 19:50:53 +00002988const char *LLVMGetBufferStart(LLVMMemoryBufferRef MemBuf);
Tom Stellardb7fb7242013-04-16 23:12:51 +00002989size_t LLVMGetBufferSize(LLVMMemoryBufferRef MemBuf);
Gordon Henriksen34eb6d82007-12-19 22:30:40 +00002990void LLVMDisposeMemoryBuffer(LLVMMemoryBufferRef MemBuf);
2991
Gregory Szorc34c863a2012-03-21 03:54:29 +00002992/**
2993 * @}
2994 */
2995
2996/**
2997 * @defgroup LLVMCCorePassRegistry Pass Registry
2998 *
2999 * @{
3000 */
Owen Anderson4698c5d2010-10-07 17:55:47 +00003001
3002/** Return the global pass registry, for use with initialization functions.
Gregory Szorc34c863a2012-03-21 03:54:29 +00003003 @see llvm::PassRegistry::getPassRegistry */
Owen Anderson4698c5d2010-10-07 17:55:47 +00003004LLVMPassRegistryRef LLVMGetGlobalPassRegistry(void);
Gordon Henriksen878114b2008-03-16 04:20:44 +00003005
Gregory Szorc34c863a2012-03-21 03:54:29 +00003006/**
3007 * @}
3008 */
3009
3010/**
3011 * @defgroup LLVMCCorePassManagers Pass Managers
3012 *
3013 * @{
3014 */
Gordon Henriksen878114b2008-03-16 04:20:44 +00003015
3016/** Constructs a new whole-module pass pipeline. This type of pipeline is
3017 suitable for link-time optimization and whole-module transformations.
Gregory Szorc34c863a2012-03-21 03:54:29 +00003018 @see llvm::PassManager::PassManager */
Gordon Henriksena735a9c2008-05-04 12:55:34 +00003019LLVMPassManagerRef LLVMCreatePassManager(void);
Gordon Henriksen878114b2008-03-16 04:20:44 +00003020
3021/** Constructs a new function-by-function pass pipeline over the module
3022 provider. It does not take ownership of the module provider. This type of
3023 pipeline is suitable for code generation and JIT compilation tasks.
Gregory Szorc34c863a2012-03-21 03:54:29 +00003024 @see llvm::FunctionPassManager::FunctionPassManager */
Erick Tryzelaarad0e0cb2010-03-02 23:58:54 +00003025LLVMPassManagerRef LLVMCreateFunctionPassManagerForModule(LLVMModuleRef M);
3026
3027/** Deprecated: Use LLVMCreateFunctionPassManagerForModule instead. */
Gordon Henriksen878114b2008-03-16 04:20:44 +00003028LLVMPassManagerRef LLVMCreateFunctionPassManager(LLVMModuleProviderRef MP);
3029
3030/** Initializes, executes on the provided module, and finalizes all of the
3031 passes scheduled in the pass manager. Returns 1 if any of the passes
Gregory Szorc34c863a2012-03-21 03:54:29 +00003032 modified the module, 0 otherwise.
3033 @see llvm::PassManager::run(Module&) */
Chris Lattner25963c62010-01-09 22:27:07 +00003034LLVMBool LLVMRunPassManager(LLVMPassManagerRef PM, LLVMModuleRef M);
Gordon Henriksen878114b2008-03-16 04:20:44 +00003035
3036/** Initializes all of the function passes scheduled in the function pass
3037 manager. Returns 1 if any of the passes modified the module, 0 otherwise.
Gregory Szorc34c863a2012-03-21 03:54:29 +00003038 @see llvm::FunctionPassManager::doInitialization */
Chris Lattner25963c62010-01-09 22:27:07 +00003039LLVMBool LLVMInitializeFunctionPassManager(LLVMPassManagerRef FPM);
Gordon Henriksen878114b2008-03-16 04:20:44 +00003040
3041/** Executes all of the function passes scheduled in the function pass manager
3042 on the provided function. Returns 1 if any of the passes modified the
3043 function, false otherwise.
Gregory Szorc34c863a2012-03-21 03:54:29 +00003044 @see llvm::FunctionPassManager::run(Function&) */
Chris Lattner25963c62010-01-09 22:27:07 +00003045LLVMBool LLVMRunFunctionPassManager(LLVMPassManagerRef FPM, LLVMValueRef F);
Gordon Henriksen878114b2008-03-16 04:20:44 +00003046
3047/** Finalizes all of the function passes scheduled in in the function pass
3048 manager. Returns 1 if any of the passes modified the module, 0 otherwise.
Gregory Szorc34c863a2012-03-21 03:54:29 +00003049 @see llvm::FunctionPassManager::doFinalization */
Chris Lattner25963c62010-01-09 22:27:07 +00003050LLVMBool LLVMFinalizeFunctionPassManager(LLVMPassManagerRef FPM);
Gordon Henriksen878114b2008-03-16 04:20:44 +00003051
3052/** Frees the memory of a pass pipeline. For function pipelines, does not free
3053 the module provider.
Gregory Szorc34c863a2012-03-21 03:54:29 +00003054 @see llvm::PassManagerBase::~PassManagerBase. */
Gordon Henriksen878114b2008-03-16 04:20:44 +00003055void LLVMDisposePassManager(LLVMPassManagerRef PM);
3056
Gregory Szorc34c863a2012-03-21 03:54:29 +00003057/**
3058 * @}
3059 */
3060
3061/**
Duncan Sands1cba0a82013-02-17 16:35:51 +00003062 * @defgroup LLVMCCoreThreading Threading
3063 *
3064 * Handle the structures needed to make LLVM safe for multithreading.
3065 *
3066 * @{
3067 */
3068
Chandler Carruth39cd2162014-06-27 15:13:01 +00003069/** Deprecated: Multi-threading can only be enabled/disabled with the compile
3070 time define LLVM_ENABLE_THREADS. This function always returns
3071 LLVMIsMultithreaded(). */
Benjamin Kramer325ec892013-10-23 16:57:34 +00003072LLVMBool LLVMStartMultithreaded(void);
Duncan Sands1cba0a82013-02-17 16:35:51 +00003073
Chandler Carruth39cd2162014-06-27 15:13:01 +00003074/** Deprecated: Multi-threading can only be enabled/disabled with the compile
3075 time define LLVM_ENABLE_THREADS. */
Benjamin Kramer325ec892013-10-23 16:57:34 +00003076void LLVMStopMultithreaded(void);
Duncan Sands1cba0a82013-02-17 16:35:51 +00003077
3078/** Check whether LLVM is executing in thread-safe mode or not.
3079 @see llvm::llvm_is_multithreaded */
Benjamin Kramer325ec892013-10-23 16:57:34 +00003080LLVMBool LLVMIsMultithreaded(void);
Duncan Sands1cba0a82013-02-17 16:35:51 +00003081
3082/**
3083 * @}
3084 */
3085
3086/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00003087 * @}
3088 */
3089
3090/**
3091 * @}
3092 */
Gordon Henriksen878114b2008-03-16 04:20:44 +00003093
Gordon Henriksen76a03742007-09-18 03:18:57 +00003094#ifdef __cplusplus
3095}
Eugene Zelenkoffec81c2015-11-04 22:32:32 +00003096#endif
Gordon Henriksen7330acd2007-10-05 23:59:36 +00003097
Eugene Zelenkoffec81c2015-11-04 22:32:32 +00003098#endif /* LLVM_C_CORE_H */