blob: e84dd39092fb22bef8c64fddc4188eac6fdfdea9 [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
Chandler Carruth3c57aa42014-03-06 04:13:12 +000018#include "llvm-c/Support.h"
Erick Tryzelaardd991352009-08-16 23:36:46 +000019
Evan Cheng2e254d02013-04-04 17:40:53 +000020#ifdef __cplusplus
Gordon Henriksen76a03742007-09-18 03:18:57 +000021extern "C" {
22#endif
23
Gregory Szorc34c863a2012-03-21 03:54:29 +000024/**
25 * @defgroup LLVMC LLVM-C: C interface to LLVM
26 *
27 * This module exposes parts of the LLVM library as a C API.
28 *
29 * @{
30 */
31
32/**
33 * @defgroup LLVMCTransforms Transforms
34 */
35
36/**
37 * @defgroup LLVMCCore Core
38 *
39 * This modules provide an interface to libLLVMCore, which implements
40 * the LLVM intermediate representation as well as other related types
41 * and utilities.
42 *
43 * LLVM uses a polymorphic type hierarchy which C cannot represent, therefore
44 * parameters must be passed as base types. Despite the declared types, most
45 * of the functions provided operate only on branches of the type hierarchy.
46 * The declared parameter names are descriptive and specify which type is
47 * required. Additionally, each type hierarchy is documented along with the
48 * functions that operate upon it. For more detail, refer to LLVM's C++ code.
Eli Bendersky870d0572012-08-10 18:26:20 +000049 * If in doubt, refer to Core.cpp, which performs parameter downcasts in the
Gregory Szorc34c863a2012-03-21 03:54:29 +000050 * form unwrap<RequiredType>(Param).
51 *
52 * Many exotic languages can interoperate with C code but have a harder time
53 * with C++ due to name mangling. So in addition to C, this interface enables
54 * tools written in such languages.
55 *
Gregory Szorc34c863a2012-03-21 03:54:29 +000056 * @{
57 */
58
59/**
60 * @defgroup LLVMCCoreTypes Types and Enumerations
61 *
62 * @{
63 */
Gordon Henriksen76a03742007-09-18 03:18:57 +000064
65/* Opaque types. */
Gordon Henriksen4a4d7352007-12-30 17:46:33 +000066
67/**
Gregory Szorc34c863a2012-03-21 03:54:29 +000068 * The top-level container for all LLVM global data. See the LLVMContext class.
Owen Anderson6773d382009-07-01 16:58:40 +000069 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +000070typedef struct LLVMOpaqueContext *LLVMContextRef;
Owen Anderson6773d382009-07-01 16:58:40 +000071
72/**
Gordon Henriksen4a4d7352007-12-30 17:46:33 +000073 * The top-level container for all other LLVM Intermediate Representation (IR)
Gregory Szorc34c863a2012-03-21 03:54:29 +000074 * objects.
75 *
76 * @see llvm::Module
Gordon Henriksen4a4d7352007-12-30 17:46:33 +000077 */
Gordon Henriksen76a03742007-09-18 03:18:57 +000078typedef struct LLVMOpaqueModule *LLVMModuleRef;
Gordon Henriksen4a4d7352007-12-30 17:46:33 +000079
80/**
Gregory Szorc34c863a2012-03-21 03:54:29 +000081 * Each value in the LLVM IR has a type, an LLVMTypeRef.
82 *
83 * @see llvm::Type
Gordon Henriksen4a4d7352007-12-30 17:46:33 +000084 */
Gordon Henriksen76a03742007-09-18 03:18:57 +000085typedef struct LLVMOpaqueType *LLVMTypeRef;
Gordon Henriksen4a4d7352007-12-30 17:46:33 +000086
Gregory Szorc34c863a2012-03-21 03:54:29 +000087/**
88 * Represents an individual value in LLVM IR.
89 *
90 * This models llvm::Value.
91 */
Gordon Henriksen76a03742007-09-18 03:18:57 +000092typedef struct LLVMOpaqueValue *LLVMValueRef;
Gregory Szorc34c863a2012-03-21 03:54:29 +000093
94/**
Eli Bendersky870d0572012-08-10 18:26:20 +000095 * Represents a basic block of instructions in LLVM IR.
Gregory Szorc34c863a2012-03-21 03:54:29 +000096 *
97 * This models llvm::BasicBlock.
98 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +000099typedef struct LLVMOpaqueBasicBlock *LLVMBasicBlockRef;
Gregory Szorc34c863a2012-03-21 03:54:29 +0000100
101/**
102 * Represents an LLVM basic block builder.
103 *
104 * This models llvm::IRBuilder.
105 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +0000106typedef struct LLVMOpaqueBuilder *LLVMBuilderRef;
Gordon Henriksen34eb6d82007-12-19 22:30:40 +0000107
Gregory Szorc34c863a2012-03-21 03:54:29 +0000108/**
109 * Interface used to provide a module to JIT or interpreter.
110 * This is now just a synonym for llvm::Module, but we have to keep using the
111 * different type to keep binary compatibility.
Gordon Henriksen34eb6d82007-12-19 22:30:40 +0000112 */
Gordon Henriksen0a68fe22007-12-12 01:04:30 +0000113typedef struct LLVMOpaqueModuleProvider *LLVMModuleProviderRef;
Gordon Henriksen76a03742007-09-18 03:18:57 +0000114
Gregory Szorc34c863a2012-03-21 03:54:29 +0000115/** @see llvm::PassManagerBase */
Gordon Henriksen878114b2008-03-16 04:20:44 +0000116typedef struct LLVMOpaquePassManager *LLVMPassManagerRef;
117
Gregory Szorc34c863a2012-03-21 03:54:29 +0000118/** @see llvm::PassRegistry */
Owen Anderson4698c5d2010-10-07 17:55:47 +0000119typedef struct LLVMOpaquePassRegistry *LLVMPassRegistryRef;
120
Gregory Szorc34c863a2012-03-21 03:54:29 +0000121/**
122 * Used to get the users and usees of a Value.
123 *
124 * @see llvm::Use */
Erick Tryzelaar9f9857e2010-03-02 20:32:28 +0000125typedef struct LLVMOpaqueUse *LLVMUseRef;
Chris Lattner40cf28d2009-10-12 04:01:02 +0000126
Tom Stellard1580dc72014-04-16 17:45:04 +0000127
128/**
129 * @see llvm::DiagnosticInfo
130 */
131typedef struct LLVMOpaqueDiagnosticInfo *LLVMDiagnosticInfoRef;
132
Gordon Henriksen76a03742007-09-18 03:18:57 +0000133typedef enum {
Devang Patel4c758ea2008-09-25 21:00:45 +0000134 LLVMZExtAttribute = 1<<0,
135 LLVMSExtAttribute = 1<<1,
136 LLVMNoReturnAttribute = 1<<2,
137 LLVMInRegAttribute = 1<<3,
138 LLVMStructRetAttribute = 1<<4,
139 LLVMNoUnwindAttribute = 1<<5,
140 LLVMNoAliasAttribute = 1<<6,
141 LLVMByValAttribute = 1<<7,
142 LLVMNestAttribute = 1<<8,
143 LLVMReadNoneAttribute = 1<<9,
Anton Korobeynikovc8ce7b082009-07-17 18:07:26 +0000144 LLVMReadOnlyAttribute = 1<<10,
Anton Korobeynikov9750be92009-07-17 18:57:16 +0000145 LLVMNoInlineAttribute = 1<<11,
146 LLVMAlwaysInlineAttribute = 1<<12,
147 LLVMOptimizeForSizeAttribute = 1<<13,
148 LLVMStackProtectAttribute = 1<<14,
149 LLVMStackProtectReqAttribute = 1<<15,
Erick Tryzelaar8f69fea2010-03-03 23:51:25 +0000150 LLVMAlignment = 31<<16,
Anton Korobeynikov9750be92009-07-17 18:57:16 +0000151 LLVMNoCaptureAttribute = 1<<21,
152 LLVMNoRedZoneAttribute = 1<<22,
153 LLVMNoImplicitFloatAttribute = 1<<23,
Jakob Stoklund Olesen74bb06c2010-02-06 01:16:28 +0000154 LLVMNakedAttribute = 1<<24,
Erick Tryzelaar8f69fea2010-03-03 23:51:25 +0000155 LLVMInlineHintAttribute = 1<<25,
Torok Edwin1db48c02011-10-06 12:13:32 +0000156 LLVMStackAlignment = 7<<26,
157 LLVMReturnsTwice = 1 << 29,
158 LLVMUWTable = 1 << 30,
Chandler Carruth44d69d92012-01-25 07:40:15 +0000159 LLVMNonLazyBind = 1 << 31
160
Bill Wendlingd154e2832013-01-23 06:41:41 +0000161 /* FIXME: These attributes are currently not included in the C API as
Nuno Lopesdef4229972012-09-02 14:19:21 +0000162 a temporary measure until the API/ABI impact to the C API is understood
163 and the path forward agreed upon.
Peter Collingbourne58af6d12015-06-15 22:16:51 +0000164 LLVMSanitizeAddressAttribute = 1ULL << 32,
165 LLVMStackProtectStrongAttribute = 1ULL<<35,
166 LLVMColdAttribute = 1ULL << 40,
167 LLVMOptimizeNoneAttribute = 1ULL << 42,
168 LLVMInAllocaAttribute = 1ULL << 43,
169 LLVMNonNullAttribute = 1ULL << 44,
170 LLVMJumpTableAttribute = 1ULL << 45,
171 LLVMConvergentAttribute = 1ULL << 46,
172 LLVMSafeStackAttribute = 1ULL << 47,
Nuno Lopesdef4229972012-09-02 14:19:21 +0000173 */
Devang Patel4c758ea2008-09-25 21:00:45 +0000174} LLVMAttribute;
Gordon Henriksen2d9cc212008-04-28 17:37:06 +0000175
176typedef enum {
Bill Wendlingda52cec2010-02-15 20:53:17 +0000177 /* Terminator Instructions */
Chris Lattner40cf28d2009-10-12 04:01:02 +0000178 LLVMRet = 1,
179 LLVMBr = 2,
180 LLVMSwitch = 3,
Bill Wendling07d6d762010-02-15 20:50:51 +0000181 LLVMIndirectBr = 4,
182 LLVMInvoke = 5,
Bill Wendling46ffaa92011-08-02 06:20:17 +0000183 /* removed 6 due to API changes */
Bill Wendling2641d132011-07-27 21:00:28 +0000184 LLVMUnreachable = 7,
Bill Wendling07d6d762010-02-15 20:50:51 +0000185
Bill Wendlingda52cec2010-02-15 20:53:17 +0000186 /* Standard Binary Operators */
Bill Wendling2641d132011-07-27 21:00:28 +0000187 LLVMAdd = 8,
188 LLVMFAdd = 9,
189 LLVMSub = 10,
190 LLVMFSub = 11,
191 LLVMMul = 12,
192 LLVMFMul = 13,
193 LLVMUDiv = 14,
194 LLVMSDiv = 15,
195 LLVMFDiv = 16,
196 LLVMURem = 17,
197 LLVMSRem = 18,
198 LLVMFRem = 19,
Bill Wendling07d6d762010-02-15 20:50:51 +0000199
Bill Wendlingda52cec2010-02-15 20:53:17 +0000200 /* Logical Operators */
Bill Wendling2641d132011-07-27 21:00:28 +0000201 LLVMShl = 20,
202 LLVMLShr = 21,
203 LLVMAShr = 22,
204 LLVMAnd = 23,
205 LLVMOr = 24,
206 LLVMXor = 25,
Bill Wendling07d6d762010-02-15 20:50:51 +0000207
Bill Wendlingda52cec2010-02-15 20:53:17 +0000208 /* Memory Operators */
Bill Wendling2641d132011-07-27 21:00:28 +0000209 LLVMAlloca = 26,
210 LLVMLoad = 27,
211 LLVMStore = 28,
212 LLVMGetElementPtr = 29,
Bill Wendling07d6d762010-02-15 20:50:51 +0000213
Bill Wendlingda52cec2010-02-15 20:53:17 +0000214 /* Cast Operators */
Bill Wendling2641d132011-07-27 21:00:28 +0000215 LLVMTrunc = 30,
216 LLVMZExt = 31,
217 LLVMSExt = 32,
218 LLVMFPToUI = 33,
219 LLVMFPToSI = 34,
220 LLVMUIToFP = 35,
221 LLVMSIToFP = 36,
222 LLVMFPTrunc = 37,
223 LLVMFPExt = 38,
224 LLVMPtrToInt = 39,
225 LLVMIntToPtr = 40,
226 LLVMBitCast = 41,
Matt Arsenaultb03bd4d2013-11-15 01:34:59 +0000227 LLVMAddrSpaceCast = 60,
Bill Wendling07d6d762010-02-15 20:50:51 +0000228
Bill Wendlingda52cec2010-02-15 20:53:17 +0000229 /* Other Operators */
Bill Wendling2641d132011-07-27 21:00:28 +0000230 LLVMICmp = 42,
231 LLVMFCmp = 43,
232 LLVMPHI = 44,
233 LLVMCall = 45,
234 LLVMSelect = 46,
Torok Edwin05dc9d62011-10-06 12:39:34 +0000235 LLVMUserOp1 = 47,
236 LLVMUserOp2 = 48,
Bill Wendling2641d132011-07-27 21:00:28 +0000237 LLVMVAArg = 49,
238 LLVMExtractElement = 50,
239 LLVMInsertElement = 51,
240 LLVMShuffleVector = 52,
241 LLVMExtractValue = 53,
242 LLVMInsertValue = 54,
Eli Friedman4fc946c2011-07-27 18:59:19 +0000243
244 /* Atomic operators */
Bill Wendling2641d132011-07-27 21:00:28 +0000245 LLVMFence = 55,
Eli Friedmanc9a551e2011-07-28 21:48:00 +0000246 LLVMAtomicCmpXchg = 56,
Bill Wendlingf891bf82011-07-31 06:30:59 +0000247 LLVMAtomicRMW = 57,
248
249 /* Exception Handling Operators */
Bill Wendlingfae14752011-08-12 20:24:12 +0000250 LLVMResume = 58,
David Majnemer654e1302015-07-31 17:58:14 +0000251 LLVMLandingPad = 59,
252 LLVMCleanupRet = 61,
253 LLVMCatchRet = 62,
Joseph Tremoulet9ce71f72015-09-03 09:09:43 +0000254 LLVMCatchPad = 63,
255 LLVMTerminatePad = 64,
256 LLVMCleanupPad = 65,
David Majnemer8a1c45d2015-12-12 05:38:55 +0000257 LLVMCatchSwitch = 66
Chris Lattner40cf28d2009-10-12 04:01:02 +0000258} LLVMOpcode;
259
260typedef enum {
Gordon Henriksen4a4d7352007-12-30 17:46:33 +0000261 LLVMVoidTypeKind, /**< type with no size */
Dan Gohman518cda42011-12-17 00:04:22 +0000262 LLVMHalfTypeKind, /**< 16 bit floating point type */
Gordon Henriksen4a4d7352007-12-30 17:46:33 +0000263 LLVMFloatTypeKind, /**< 32 bit floating point type */
264 LLVMDoubleTypeKind, /**< 64 bit floating point type */
265 LLVMX86_FP80TypeKind, /**< 80 bit floating point type (X87) */
266 LLVMFP128TypeKind, /**< 128 bit floating point type (112-bit mantissa)*/
267 LLVMPPC_FP128TypeKind, /**< 128 bit floating point type (two 64-bits) */
268 LLVMLabelTypeKind, /**< Labels */
269 LLVMIntegerTypeKind, /**< Arbitrary bit width integers */
270 LLVMFunctionTypeKind, /**< Functions */
271 LLVMStructTypeKind, /**< Structures */
272 LLVMArrayTypeKind, /**< Arrays */
273 LLVMPointerTypeKind, /**< Pointers */
Chris Lattnerdac44ec2009-07-15 22:00:31 +0000274 LLVMVectorTypeKind, /**< SIMD 'packed' format, or other vector type */
Dale Johannesenbaa5d042010-09-10 20:55:01 +0000275 LLVMMetadataTypeKind, /**< Metadata */
David Majnemerb611e3f2015-08-14 05:09:07 +0000276 LLVMX86_MMXTypeKind, /**< X86 MMX */
277 LLVMTokenTypeKind /**< Tokens */
Gordon Henriksen76a03742007-09-18 03:18:57 +0000278} LLVMTypeKind;
279
280typedef enum {
Gordon Henriksen4a4d7352007-12-30 17:46:33 +0000281 LLVMExternalLinkage, /**< Externally visible function */
Chris Lattner2dba0f02009-04-13 06:25:37 +0000282 LLVMAvailableExternallyLinkage,
Duncan Sands12da8ce2009-03-07 15:45:40 +0000283 LLVMLinkOnceAnyLinkage, /**< Keep one copy of function when linking (inline)*/
284 LLVMLinkOnceODRLinkage, /**< Same, but only replaced by something
285 equivalent. */
Rafael Espindola716e7402013-11-01 17:09:14 +0000286 LLVMLinkOnceODRAutoHideLinkage, /**< Obsolete */
Duncan Sands12da8ce2009-03-07 15:45:40 +0000287 LLVMWeakAnyLinkage, /**< Keep one copy of function when linking (weak) */
288 LLVMWeakODRLinkage, /**< Same, but only replaced by something
289 equivalent. */
Gordon Henriksen4a4d7352007-12-30 17:46:33 +0000290 LLVMAppendingLinkage, /**< Special purpose, only applies to global arrays */
291 LLVMInternalLinkage, /**< Rename collisions when linking (static
292 functions) */
Duncan Sands12da8ce2009-03-07 15:45:40 +0000293 LLVMPrivateLinkage, /**< Like Internal, but omit from symbol table */
Nico Rieck7157bb72014-01-14 15:22:47 +0000294 LLVMDLLImportLinkage, /**< Obsolete */
295 LLVMDLLExportLinkage, /**< Obsolete */
Duncan Sandse2881052009-03-11 08:08:06 +0000296 LLVMExternalWeakLinkage,/**< ExternalWeak linkage description */
Jeffrey Yasskin091217b2010-01-27 20:34:15 +0000297 LLVMGhostLinkage, /**< Obsolete */
Bill Wendling002b1672009-07-20 18:22:52 +0000298 LLVMCommonLinkage, /**< Tentative definitions */
Bill Wendling03bcd6e2010-07-01 21:55:59 +0000299 LLVMLinkerPrivateLinkage, /**< Like Private, but linker removes. */
Bill Wendling34bc34e2012-08-17 18:33:14 +0000300 LLVMLinkerPrivateWeakLinkage /**< Like LinkerPrivate, but is weak. */
Gordon Henriksen76a03742007-09-18 03:18:57 +0000301} LLVMLinkage;
302
303typedef enum {
Gordon Henriksen4a4d7352007-12-30 17:46:33 +0000304 LLVMDefaultVisibility, /**< The GV is visible */
305 LLVMHiddenVisibility, /**< The GV is hidden */
306 LLVMProtectedVisibility /**< The GV is protected */
Gordon Henriksen76a03742007-09-18 03:18:57 +0000307} LLVMVisibility;
308
Gordon Henriksenc23b66c2007-09-26 20:56:12 +0000309typedef enum {
Reid Kleckner2fae26f2014-03-05 02:34:23 +0000310 LLVMDefaultStorageClass = 0,
311 LLVMDLLImportStorageClass = 1, /**< Function to be imported from DLL. */
312 LLVMDLLExportStorageClass = 2 /**< Function to be accessible from DLL. */
313} LLVMDLLStorageClass;
314
315typedef enum {
Gordon Henriksenc23b66c2007-09-26 20:56:12 +0000316 LLVMCCallConv = 0,
317 LLVMFastCallConv = 8,
318 LLVMColdCallConv = 9,
Filip Pizlodfc9b582013-11-09 06:00:03 +0000319 LLVMWebKitJSCallConv = 12,
320 LLVMAnyRegCallConv = 13,
Gordon Henriksenc23b66c2007-09-26 20:56:12 +0000321 LLVMX86StdcallCallConv = 64,
322 LLVMX86FastcallCallConv = 65
323} LLVMCallConv;
324
325typedef enum {
Gordon Henriksen4a4d7352007-12-30 17:46:33 +0000326 LLVMIntEQ = 32, /**< equal */
327 LLVMIntNE, /**< not equal */
328 LLVMIntUGT, /**< unsigned greater than */
329 LLVMIntUGE, /**< unsigned greater or equal */
330 LLVMIntULT, /**< unsigned less than */
331 LLVMIntULE, /**< unsigned less or equal */
332 LLVMIntSGT, /**< signed greater than */
333 LLVMIntSGE, /**< signed greater or equal */
334 LLVMIntSLT, /**< signed less than */
335 LLVMIntSLE /**< signed less or equal */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +0000336} LLVMIntPredicate;
337
338typedef enum {
Gordon Henriksen4a4d7352007-12-30 17:46:33 +0000339 LLVMRealPredicateFalse, /**< Always false (always folded) */
340 LLVMRealOEQ, /**< True if ordered and equal */
341 LLVMRealOGT, /**< True if ordered and greater than */
342 LLVMRealOGE, /**< True if ordered and greater than or equal */
343 LLVMRealOLT, /**< True if ordered and less than */
344 LLVMRealOLE, /**< True if ordered and less than or equal */
345 LLVMRealONE, /**< True if ordered and operands are unequal */
346 LLVMRealORD, /**< True if ordered (no nans) */
347 LLVMRealUNO, /**< True if unordered: isnan(X) | isnan(Y) */
348 LLVMRealUEQ, /**< True if unordered or equal */
349 LLVMRealUGT, /**< True if unordered or greater than */
350 LLVMRealUGE, /**< True if unordered, greater than, or equal */
351 LLVMRealULT, /**< True if unordered or less than */
352 LLVMRealULE, /**< True if unordered, less than, or equal */
353 LLVMRealUNE, /**< True if unordered or not equal */
354 LLVMRealPredicateTrue /**< Always true (always folded) */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +0000355} LLVMRealPredicate;
356
Bill Wendlingfae14752011-08-12 20:24:12 +0000357typedef enum {
358 LLVMLandingPadCatch, /**< A catch clause */
359 LLVMLandingPadFilter /**< A filter clause */
360} LLVMLandingPadClauseTy;
361
Hans Wennborg5ff71202013-04-16 08:58:59 +0000362typedef enum {
363 LLVMNotThreadLocal = 0,
364 LLVMGeneralDynamicTLSModel,
365 LLVMLocalDynamicTLSModel,
366 LLVMInitialExecTLSModel,
367 LLVMLocalExecTLSModel
368} LLVMThreadLocalMode;
369
Carlo Kokda0ac722013-04-23 13:45:37 +0000370typedef enum {
Carlo Kok8c6719b2013-04-23 13:21:19 +0000371 LLVMAtomicOrderingNotAtomic = 0, /**< A load or store which is not atomic */
372 LLVMAtomicOrderingUnordered = 1, /**< Lowest level of atomicity, guarantees
373 somewhat sane results, lock free. */
NAKAMURA Takumia3a81352013-10-23 17:56:29 +0000374 LLVMAtomicOrderingMonotonic = 2, /**< guarantees that if you take all the
375 operations affecting a specific address,
Carlo Kok8c6719b2013-04-23 13:21:19 +0000376 a consistent ordering exists */
NAKAMURA Takumia3a81352013-10-23 17:56:29 +0000377 LLVMAtomicOrderingAcquire = 4, /**< Acquire provides a barrier of the sort
378 necessary to acquire a lock to access other
Carlo Kok8c6719b2013-04-23 13:21:19 +0000379 memory with normal loads and stores. */
NAKAMURA Takumia3a81352013-10-23 17:56:29 +0000380 LLVMAtomicOrderingRelease = 5, /**< Release is similar to Acquire, but with
381 a barrier of the sort necessary to release
Carlo Kok8c6719b2013-04-23 13:21:19 +0000382 a lock. */
NAKAMURA Takumia3a81352013-10-23 17:56:29 +0000383 LLVMAtomicOrderingAcquireRelease = 6, /**< provides both an Acquire and a
384 Release barrier (for fences and
Carlo Kok8c6719b2013-04-23 13:21:19 +0000385 operations which both read and write
386 memory). */
NAKAMURA Takumia3a81352013-10-23 17:56:29 +0000387 LLVMAtomicOrderingSequentiallyConsistent = 7 /**< provides Acquire semantics
388 for loads and Release
389 semantics for stores.
390 Additionally, it guarantees
391 that a total ordering exists
392 between all
393 SequentiallyConsistent
Carlo Kok8c6719b2013-04-23 13:21:19 +0000394 operations. */
Carlo Kokda0ac722013-04-23 13:45:37 +0000395} LLVMAtomicOrdering;
Carlo Kok8c6719b2013-04-23 13:21:19 +0000396
Carlo Kokda0ac722013-04-23 13:45:37 +0000397typedef enum {
Carlo Kok8c6719b2013-04-23 13:21:19 +0000398 LLVMAtomicRMWBinOpXchg, /**< Set the new value and return the one old */
399 LLVMAtomicRMWBinOpAdd, /**< Add a value and return the old one */
400 LLVMAtomicRMWBinOpSub, /**< Subtract a value and return the old one */
401 LLVMAtomicRMWBinOpAnd, /**< And a value and return the old one */
402 LLVMAtomicRMWBinOpNand, /**< Not-And a value and return the old one */
403 LLVMAtomicRMWBinOpOr, /**< OR a value and return the old one */
404 LLVMAtomicRMWBinOpXor, /**< Xor a value and return the old one */
405 LLVMAtomicRMWBinOpMax, /**< Sets the value if it's greater than the
NAKAMURA Takumia3a81352013-10-23 17:56:29 +0000406 original using a signed comparison and return
Carlo Kok8c6719b2013-04-23 13:21:19 +0000407 the old one */
408 LLVMAtomicRMWBinOpMin, /**< Sets the value if it's Smaller than the
NAKAMURA Takumia3a81352013-10-23 17:56:29 +0000409 original using a signed comparison and return
Carlo Kok8c6719b2013-04-23 13:21:19 +0000410 the old one */
411 LLVMAtomicRMWBinOpUMax, /**< Sets the value if it's greater than the
NAKAMURA Takumia3a81352013-10-23 17:56:29 +0000412 original using an unsigned comparison and return
Carlo Kok8c6719b2013-04-23 13:21:19 +0000413 the old one */
414 LLVMAtomicRMWBinOpUMin /**< Sets the value if it's greater than the
NAKAMURA Takumia3a81352013-10-23 17:56:29 +0000415 original using an unsigned comparison and return
Carlo Kok8c6719b2013-04-23 13:21:19 +0000416 the old one */
Carlo Kokda0ac722013-04-23 13:45:37 +0000417} LLVMAtomicRMWBinOp;
Carlo Kok8c6719b2013-04-23 13:21:19 +0000418
Tom Stellard1580dc72014-04-16 17:45:04 +0000419typedef enum {
420 LLVMDSError,
421 LLVMDSWarning,
422 LLVMDSRemark,
423 LLVMDSNote
424} LLVMDiagnosticSeverity;
425
Gregory Szorc34c863a2012-03-21 03:54:29 +0000426/**
427 * @}
428 */
429
Nick Lewycky0db26542011-05-15 07:20:34 +0000430void LLVMInitializeCore(LLVMPassRegistryRef R);
431
Duncan Sands1cba0a82013-02-17 16:35:51 +0000432/** Deallocate and destroy all ManagedStatic variables.
433 @see llvm::llvm_shutdown
434 @see ManagedStatic */
Benjamin Kramer325ec892013-10-23 16:57:34 +0000435void LLVMShutdown(void);
Duncan Sands1cba0a82013-02-17 16:35:51 +0000436
Gordon Henriksen34eb6d82007-12-19 22:30:40 +0000437/*===-- Error handling ----------------------------------------------------===*/
438
Filip Pizlo3fdbaff2013-05-22 02:46:43 +0000439char *LLVMCreateMessage(const char *Message);
Gordon Henriksen34eb6d82007-12-19 22:30:40 +0000440void LLVMDisposeMessage(char *Message);
441
Filip Pizloa535b142013-10-17 01:38:28 +0000442typedef void (*LLVMFatalErrorHandler)(const char *Reason);
443
444/**
445 * Install a fatal error handler. By default, if LLVM detects a fatal error, it
446 * will call exit(1). This may not be appropriate in many contexts. For example,
447 * doing exit(1) will bypass many crash reporting/tracing system tools. This
448 * function allows you to install a callback that will be invoked prior to the
449 * call to exit(1).
450 */
451void LLVMInstallFatalErrorHandler(LLVMFatalErrorHandler Handler);
452
453/**
454 * Reset the fatal error handler. This resets LLVM's fatal error handling
455 * behavior to the default.
456 */
457void LLVMResetFatalErrorHandler(void);
Gordon Henriksen34eb6d82007-12-19 22:30:40 +0000458
Gregory Szorc34c863a2012-03-21 03:54:29 +0000459/**
Filip Pizloc10ca902013-11-04 02:22:25 +0000460 * Enable LLVM's built-in stack trace code. This intercepts the OS's crash
461 * signals and prints which component of LLVM you were in at the time if the
462 * crash.
Filip Pizlo9f50ccd2013-11-03 00:29:47 +0000463 */
Filip Pizloc10ca902013-11-04 02:22:25 +0000464void LLVMEnablePrettyStackTrace(void);
Filip Pizlo9f50ccd2013-11-03 00:29:47 +0000465
466/**
Gregory Szorc34c863a2012-03-21 03:54:29 +0000467 * @defgroup LLVMCCoreContext Contexts
468 *
469 * Contexts are execution states for the core LLVM IR system.
470 *
471 * Most types are tied to a context instance. Multiple contexts can
472 * exist simultaneously. A single context is not thread safe. However,
473 * different contexts can execute on different threads simultaneously.
474 *
475 * @{
476 */
Gordon Henriksen76a03742007-09-18 03:18:57 +0000477
Tom Stellard1580dc72014-04-16 17:45:04 +0000478typedef void (*LLVMDiagnosticHandler)(LLVMDiagnosticInfoRef, void *);
Juergen Ributzka34390c72014-05-16 02:33:15 +0000479typedef void (*LLVMYieldCallback)(LLVMContextRef, void *);
Tom Stellard1580dc72014-04-16 17:45:04 +0000480
Gregory Szorc34c863a2012-03-21 03:54:29 +0000481/**
482 * Create a new context.
483 *
484 * Every call to this function should be paired with a call to
485 * LLVMContextDispose() or the context will leak memory.
486 */
Erick Tryzelaarf34cb0c2009-08-30 23:38:06 +0000487LLVMContextRef LLVMContextCreate(void);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000488
489/**
490 * Obtain the global context instance.
491 */
Erick Tryzelaarf34cb0c2009-08-30 23:38:06 +0000492LLVMContextRef LLVMGetGlobalContext(void);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000493
494/**
Tom Stellard1580dc72014-04-16 17:45:04 +0000495 * Set the diagnostic handler for this context.
496 */
497void LLVMContextSetDiagnosticHandler(LLVMContextRef C,
498 LLVMDiagnosticHandler Handler,
499 void *DiagnosticContext);
500
501/**
Juergen Ributzka34390c72014-05-16 02:33:15 +0000502 * Set the yield callback function for this context.
503 *
504 * @see LLVMContext::setYieldCallback()
505 */
506void LLVMContextSetYieldCallback(LLVMContextRef C, LLVMYieldCallback Callback,
507 void *OpaqueHandle);
508
509/**
Gregory Szorc34c863a2012-03-21 03:54:29 +0000510 * Destroy a context instance.
511 *
512 * This should be called for every call to LLVMContextCreate() or memory
513 * will be leaked.
514 */
Owen Anderson6773d382009-07-01 16:58:40 +0000515void LLVMContextDispose(LLVMContextRef C);
516
Tom Stellard1580dc72014-04-16 17:45:04 +0000517/**
518 * Return a string representation of the DiagnosticInfo. Use
519 * LLVMDisposeMessage to free the string.
520 *
521 * @see DiagnosticInfo::print()
522 */
523char *LLVMGetDiagInfoDescription(LLVMDiagnosticInfoRef DI);
524
525/**
526 * Return an enum LLVMDiagnosticSeverity.
527 *
528 * @see DiagnosticInfo::getSeverity()
529 */
530LLVMDiagnosticSeverity LLVMGetDiagInfoSeverity(LLVMDiagnosticInfoRef DI);
531
Erick Tryzelaard8531fa2010-02-28 09:45:59 +0000532unsigned LLVMGetMDKindIDInContext(LLVMContextRef C, const char* Name,
533 unsigned SLen);
534unsigned LLVMGetMDKindID(const char* Name, unsigned SLen);
535
Gregory Szorc34c863a2012-03-21 03:54:29 +0000536/**
537 * @}
538 */
539
Gregory Szorc52d26602012-03-21 07:28:27 +0000540/**
541 * @defgroup LLVMCCoreModule Modules
Gregory Szorc34c863a2012-03-21 03:54:29 +0000542 *
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +0000543 * Modules represent the top-level structure in an LLVM program. An LLVM
Gregory Szorc34c863a2012-03-21 03:54:29 +0000544 * module is effectively a translation unit or a collection of
545 * translation units merged together.
546 *
547 * @{
548 */
549
Gregory Szorc34c863a2012-03-21 03:54:29 +0000550/**
551 * Create a new, empty module in the global context.
552 *
553 * This is equivalent to calling LLVMModuleCreateWithNameInContext with
554 * LLVMGetGlobalContext() as the context parameter.
555 *
556 * Every invocation should be paired with LLVMDisposeModule() or memory
557 * will be leaked.
558 */
Gordon Henriksen76a03742007-09-18 03:18:57 +0000559LLVMModuleRef LLVMModuleCreateWithName(const char *ModuleID);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000560
561/**
562 * Create a new, empty module in a specific context.
563 *
564 * Every invocation should be paired with LLVMDisposeModule() or memory
565 * will be leaked.
566 */
Owen Anderson31d44e42009-07-02 07:17:57 +0000567LLVMModuleRef LLVMModuleCreateWithNameInContext(const char *ModuleID,
568 LLVMContextRef C);
Tom Stellard0a4e9a32014-10-01 17:14:57 +0000569/**
570 * Return an exact copy of the specified module.
571 */
572LLVMModuleRef LLVMCloneModule(LLVMModuleRef M);
Gordon Henriksena49d4352008-03-07 19:13:06 +0000573
Gregory Szorc34c863a2012-03-21 03:54:29 +0000574/**
575 * Destroy a module instance.
576 *
577 * This must be called for every created module or memory will be
578 * leaked.
579 */
Gordon Henriksen76a03742007-09-18 03:18:57 +0000580void LLVMDisposeModule(LLVMModuleRef M);
581
Gregory Szorc34c863a2012-03-21 03:54:29 +0000582/**
583 * Obtain the data layout for a module.
584 *
585 * @see Module::getDataLayout()
586 */
Gordon Henriksen05568bb2007-12-27 20:13:47 +0000587const char *LLVMGetDataLayout(LLVMModuleRef M);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000588
589/**
590 * Set the data layout for a module.
591 *
592 * @see Module::setDataLayout()
593 */
Gordon Henriksen05568bb2007-12-27 20:13:47 +0000594void LLVMSetDataLayout(LLVMModuleRef M, const char *Triple);
595
Gregory Szorc34c863a2012-03-21 03:54:29 +0000596/**
597 * Obtain the target triple for a module.
598 *
599 * @see Module::getTargetTriple()
600 */
Gordon Henriksen05568bb2007-12-27 20:13:47 +0000601const char *LLVMGetTarget(LLVMModuleRef M);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000602
603/**
604 * Set the target triple for a module.
605 *
606 * @see Module::setTargetTriple()
607 */
Gordon Henriksen05568bb2007-12-27 20:13:47 +0000608void LLVMSetTarget(LLVMModuleRef M, const char *Triple);
609
Gregory Szorc34c863a2012-03-21 03:54:29 +0000610/**
611 * Dump a representation of a module to stderr.
612 *
613 * @see Module::dump()
614 */
Gordon Henriksen6c6075e2008-03-14 23:58:56 +0000615void LLVMDumpModule(LLVMModuleRef M);
616
Gregory Szorc34c863a2012-03-21 03:54:29 +0000617/**
Hans Wennborgb7ef2fe2012-05-09 16:54:17 +0000618 * Print a representation of a module to a file. The ErrorMessage needs to be
619 * disposed with LLVMDisposeMessage. Returns 0 on success, 1 otherwise.
620 *
621 * @see Module::print()
622 */
623LLVMBool LLVMPrintModuleToFile(LLVMModuleRef M, const char *Filename,
624 char **ErrorMessage);
625
626/**
Anders Waldenborg84355db2013-10-16 18:00:54 +0000627 * Return a string representation of the module. Use
628 * LLVMDisposeMessage to free the string.
629 *
630 * @see Module::print()
631 */
632char *LLVMPrintModuleToString(LLVMModuleRef M);
633
634/**
Gregory Szorc34c863a2012-03-21 03:54:29 +0000635 * Set inline assembly for a module.
636 *
637 * @see Module::setModuleInlineAsm()
638 */
Chris Lattner26941452010-04-10 17:52:58 +0000639void LLVMSetModuleInlineAsm(LLVMModuleRef M, const char *Asm);
Gordon Henriksen76a03742007-09-18 03:18:57 +0000640
Gregory Szorc34c863a2012-03-21 03:54:29 +0000641/**
642 * Obtain the context to which this module is associated.
643 *
644 * @see Module::getContext()
645 */
Chris Lattnera7e04b02010-11-28 20:03:44 +0000646LLVMContextRef LLVMGetModuleContext(LLVMModuleRef M);
647
Gregory Szorc34c863a2012-03-21 03:54:29 +0000648/**
649 * Obtain a Type from a module by its registered name.
650 */
651LLVMTypeRef LLVMGetTypeByName(LLVMModuleRef M, const char *Name);
Gordon Henriksen76a03742007-09-18 03:18:57 +0000652
Gregory Szorc34c863a2012-03-21 03:54:29 +0000653/**
654 * Obtain the number of operands for named metadata in a module.
655 *
656 * @see llvm::Module::getNamedMetadata()
657 */
658unsigned LLVMGetNamedMetadataNumOperands(LLVMModuleRef M, const char* name);
659
660/**
661 * Obtain the named metadata operands for a module.
662 *
663 * The passed LLVMValueRef pointer should refer to an array of
664 * LLVMValueRef at least LLVMGetNamedMetadataNumOperands long. This
665 * array will be populated with the LLVMValueRef instances. Each
666 * instance corresponds to a llvm::MDNode.
667 *
668 * @see llvm::Module::getNamedMetadata()
669 * @see llvm::MDNode::getOperand()
670 */
671void LLVMGetNamedMetadataOperands(LLVMModuleRef M, const char* name, LLVMValueRef *Dest);
672
673/**
674 * Add an operand to named metadata.
675 *
676 * @see llvm::Module::getNamedMetadata()
677 * @see llvm::MDNode::addOperand()
678 */
679void LLVMAddNamedMetadataOperand(LLVMModuleRef M, const char* name,
680 LLVMValueRef Val);
681
Gregory Szorc52d26602012-03-21 07:28:27 +0000682/**
683 * Add a function to a module under a specified name.
684 *
685 * @see llvm::Function::Create()
686 */
687LLVMValueRef LLVMAddFunction(LLVMModuleRef M, const char *Name,
688 LLVMTypeRef FunctionTy);
689
690/**
691 * Obtain a Function value from a Module by its name.
692 *
693 * The returned value corresponds to a llvm::Function value.
694 *
695 * @see llvm::Module::getFunction()
696 */
697LLVMValueRef LLVMGetNamedFunction(LLVMModuleRef M, const char *Name);
698
699/**
700 * Obtain an iterator to the first Function in a Module.
701 *
702 * @see llvm::Module::begin()
703 */
704LLVMValueRef LLVMGetFirstFunction(LLVMModuleRef M);
705
706/**
707 * Obtain an iterator to the last Function in a Module.
708 *
709 * @see llvm::Module::end()
710 */
711LLVMValueRef LLVMGetLastFunction(LLVMModuleRef M);
712
713/**
714 * Advance a Function iterator to the next Function.
715 *
716 * Returns NULL if the iterator was already at the end and there are no more
717 * functions.
718 */
719LLVMValueRef LLVMGetNextFunction(LLVMValueRef Fn);
720
721/**
722 * Decrement a Function iterator to the previous Function.
723 *
724 * Returns NULL if the iterator was already at the beginning and there are
725 * no previous functions.
726 */
727LLVMValueRef LLVMGetPreviousFunction(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000728
729/**
730 * @}
731 */
732
733/**
734 * @defgroup LLVMCCoreType Types
735 *
736 * Types represent the type of a value.
737 *
738 * Types are associated with a context instance. The context internally
739 * deduplicates types so there is only 1 instance of a specific type
740 * alive at a time. In other words, a unique type is shared among all
741 * consumers within a context.
742 *
743 * A Type in the C API corresponds to llvm::Type.
744 *
745 * Types have the following hierarchy:
746 *
Gordon Henriksen76a03742007-09-18 03:18:57 +0000747 * types:
748 * integer type
749 * real type
750 * function type
751 * sequence types:
752 * array type
753 * pointer type
754 * vector type
755 * void type
756 * label type
757 * opaque type
Gregory Szorc34c863a2012-03-21 03:54:29 +0000758 *
759 * @{
Gordon Henriksen76a03742007-09-18 03:18:57 +0000760 */
761
Gregory Szorc34c863a2012-03-21 03:54:29 +0000762/**
763 * Obtain the enumerated type of a Type instance.
764 *
765 * @see llvm::Type:getTypeID()
766 */
Gordon Henriksen76a03742007-09-18 03:18:57 +0000767LLVMTypeKind LLVMGetTypeKind(LLVMTypeRef Ty);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000768
769/**
770 * Whether the type has a known size.
771 *
772 * Things that don't have a size are abstract types, labels, and void.a
773 *
774 * @see llvm::Type::isSized()
775 */
Torok Edwin1cd9ade2011-10-06 12:13:28 +0000776LLVMBool LLVMTypeIsSized(LLVMTypeRef Ty);
Gordon Henriksena49d4352008-03-07 19:13:06 +0000777
Gregory Szorc34c863a2012-03-21 03:54:29 +0000778/**
779 * Obtain the context to which this type instance is associated.
780 *
781 * @see llvm::Type::getContext()
782 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +0000783LLVMContextRef LLVMGetTypeContext(LLVMTypeRef Ty);
784
Gregory Szorc34c863a2012-03-21 03:54:29 +0000785/**
Anders Waldenborgb822cff2013-10-16 21:30:25 +0000786 * Dump a representation of a type to stderr.
787 *
788 * @see llvm::Type::dump()
789 */
790void LLVMDumpType(LLVMTypeRef Val);
791
792/**
Anders Waldenborg47b3bd32013-10-22 06:58:34 +0000793 * Return a string representation of the type. Use
794 * LLVMDisposeMessage to free the string.
795 *
796 * @see llvm::Type::print()
797 */
798char *LLVMPrintTypeToString(LLVMTypeRef Val);
799
800/**
Gregory Szorc34c863a2012-03-21 03:54:29 +0000801 * @defgroup LLVMCCoreTypeInt Integer Types
802 *
803 * Functions in this section operate on integer types.
804 *
805 * @{
806 */
807
808/**
809 * Obtain an integer type from a context with specified bit width.
810 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +0000811LLVMTypeRef LLVMInt1TypeInContext(LLVMContextRef C);
812LLVMTypeRef LLVMInt8TypeInContext(LLVMContextRef C);
813LLVMTypeRef LLVMInt16TypeInContext(LLVMContextRef C);
814LLVMTypeRef LLVMInt32TypeInContext(LLVMContextRef C);
815LLVMTypeRef LLVMInt64TypeInContext(LLVMContextRef C);
Eugene Zelenkoffec81c2015-11-04 22:32:32 +0000816LLVMTypeRef LLVMInt128TypeInContext(LLVMContextRef C);
Erick Tryzelaar262332f2009-08-14 00:01:31 +0000817LLVMTypeRef LLVMIntTypeInContext(LLVMContextRef C, unsigned NumBits);
818
Gregory Szorc34c863a2012-03-21 03:54:29 +0000819/**
820 * Obtain an integer type from the global context with a specified bit
821 * width.
822 */
Gordon Henriksena735a9c2008-05-04 12:55:34 +0000823LLVMTypeRef LLVMInt1Type(void);
824LLVMTypeRef LLVMInt8Type(void);
825LLVMTypeRef LLVMInt16Type(void);
826LLVMTypeRef LLVMInt32Type(void);
827LLVMTypeRef LLVMInt64Type(void);
Eugene Zelenkoffec81c2015-11-04 22:32:32 +0000828LLVMTypeRef LLVMInt128Type(void);
Gordon Henriksened7beaa2007-10-06 16:05:20 +0000829LLVMTypeRef LLVMIntType(unsigned NumBits);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +0000830unsigned LLVMGetIntTypeWidth(LLVMTypeRef IntegerTy);
Gordon Henriksen76a03742007-09-18 03:18:57 +0000831
Gregory Szorc34c863a2012-03-21 03:54:29 +0000832/**
833 * @}
834 */
835
836/**
837 * @defgroup LLVMCCoreTypeFloat Floating Point Types
838 *
839 * @{
840 */
841
842/**
843 * Obtain a 16-bit floating point type from a context.
844 */
Dan Gohman518cda42011-12-17 00:04:22 +0000845LLVMTypeRef LLVMHalfTypeInContext(LLVMContextRef C);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000846
847/**
848 * Obtain a 32-bit floating point type from a context.
849 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +0000850LLVMTypeRef LLVMFloatTypeInContext(LLVMContextRef C);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000851
852/**
853 * Obtain a 64-bit floating point type from a context.
854 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +0000855LLVMTypeRef LLVMDoubleTypeInContext(LLVMContextRef C);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000856
857/**
858 * Obtain a 80-bit floating point type (X87) from a context.
859 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +0000860LLVMTypeRef LLVMX86FP80TypeInContext(LLVMContextRef C);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000861
862/**
863 * Obtain a 128-bit floating point type (112-bit mantissa) from a
864 * context.
865 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +0000866LLVMTypeRef LLVMFP128TypeInContext(LLVMContextRef C);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000867
868/**
869 * Obtain a 128-bit floating point type (two 64-bits) from a context.
870 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +0000871LLVMTypeRef LLVMPPCFP128TypeInContext(LLVMContextRef C);
872
Gregory Szorc34c863a2012-03-21 03:54:29 +0000873/**
874 * Obtain a floating point type from the global context.
875 *
876 * These map to the functions in this group of the same name.
877 */
Dan Gohman518cda42011-12-17 00:04:22 +0000878LLVMTypeRef LLVMHalfType(void);
Gordon Henriksena735a9c2008-05-04 12:55:34 +0000879LLVMTypeRef LLVMFloatType(void);
880LLVMTypeRef LLVMDoubleType(void);
881LLVMTypeRef LLVMX86FP80Type(void);
882LLVMTypeRef LLVMFP128Type(void);
883LLVMTypeRef LLVMPPCFP128Type(void);
Gordon Henriksen76a03742007-09-18 03:18:57 +0000884
Gregory Szorc34c863a2012-03-21 03:54:29 +0000885/**
886 * @}
887 */
888
889/**
890 * @defgroup LLVMCCoreTypeFunction Function Types
891 *
892 * @{
893 */
894
895/**
896 * Obtain a function type consisting of a specified signature.
897 *
898 * The function is defined as a tuple of a return Type, a list of
899 * parameter types, and whether the function is variadic.
900 */
Gordon Henriksened7beaa2007-10-06 16:05:20 +0000901LLVMTypeRef LLVMFunctionType(LLVMTypeRef ReturnType,
902 LLVMTypeRef *ParamTypes, unsigned ParamCount,
Chris Lattner25963c62010-01-09 22:27:07 +0000903 LLVMBool IsVarArg);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000904
905/**
906 * Returns whether a function type is variadic.
907 */
Chris Lattner25963c62010-01-09 22:27:07 +0000908LLVMBool LLVMIsFunctionVarArg(LLVMTypeRef FunctionTy);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000909
910/**
911 * Obtain the Type this function Type returns.
912 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +0000913LLVMTypeRef LLVMGetReturnType(LLVMTypeRef FunctionTy);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000914
915/**
916 * Obtain the number of parameters this function accepts.
917 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +0000918unsigned LLVMCountParamTypes(LLVMTypeRef FunctionTy);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000919
920/**
921 * Obtain the types of a function's parameters.
922 *
923 * The Dest parameter should point to a pre-allocated array of
924 * LLVMTypeRef at least LLVMCountParamTypes() large. On return, the
925 * first LLVMCountParamTypes() entries in the array will be populated
926 * with LLVMTypeRef instances.
927 *
928 * @param FunctionTy The function type to operate on.
929 * @param Dest Memory address of an array to be filled with result.
930 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +0000931void LLVMGetParamTypes(LLVMTypeRef FunctionTy, LLVMTypeRef *Dest);
Gordon Henriksen76a03742007-09-18 03:18:57 +0000932
Gregory Szorc34c863a2012-03-21 03:54:29 +0000933/**
934 * @}
935 */
936
937/**
938 * @defgroup LLVMCCoreTypeStruct Structure Types
939 *
940 * These functions relate to LLVMTypeRef instances.
941 *
942 * @see llvm::StructType
943 *
944 * @{
945 */
946
947/**
948 * Create a new structure type in a context.
949 *
950 * A structure is specified by a list of inner elements/types and
951 * whether these can be packed together.
952 *
953 * @see llvm::StructType::create()
954 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +0000955LLVMTypeRef LLVMStructTypeInContext(LLVMContextRef C, LLVMTypeRef *ElementTypes,
Chris Lattner25963c62010-01-09 22:27:07 +0000956 unsigned ElementCount, LLVMBool Packed);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000957
958/**
959 * Create a new structure type in the global context.
960 *
961 * @see llvm::StructType::create()
962 */
Gordon Henriksened7beaa2007-10-06 16:05:20 +0000963LLVMTypeRef LLVMStructType(LLVMTypeRef *ElementTypes, unsigned ElementCount,
Chris Lattner25963c62010-01-09 22:27:07 +0000964 LLVMBool Packed);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000965
966/**
967 * Create an empty structure in a context having a specified name.
968 *
969 * @see llvm::StructType::create()
970 */
Chris Lattnere71ccde2011-07-14 05:53:17 +0000971LLVMTypeRef LLVMStructCreateNamed(LLVMContextRef C, const char *Name);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000972
973/**
974 * Obtain the name of a structure.
975 *
976 * @see llvm::StructType::getName()
977 */
Torok Edwin0d5f6ae2011-10-06 12:12:50 +0000978const char *LLVMGetStructName(LLVMTypeRef Ty);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000979
980/**
981 * Set the contents of a structure type.
982 *
983 * @see llvm::StructType::setBody()
984 */
Chris Lattnere71ccde2011-07-14 05:53:17 +0000985void LLVMStructSetBody(LLVMTypeRef StructTy, LLVMTypeRef *ElementTypes,
986 unsigned ElementCount, LLVMBool Packed);
987
Gregory Szorc34c863a2012-03-21 03:54:29 +0000988/**
989 * Get the number of elements defined inside the structure.
990 *
991 * @see llvm::StructType::getNumElements()
992 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +0000993unsigned LLVMCountStructElementTypes(LLVMTypeRef StructTy);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000994
995/**
996 * Get the elements within a structure.
997 *
998 * The function is passed the address of a pre-allocated array of
999 * LLVMTypeRef at least LLVMCountStructElementTypes() long. After
1000 * invocation, this array will be populated with the structure's
1001 * elements. The objects in the destination array will have a lifetime
1002 * of the structure type itself, which is the lifetime of the context it
1003 * is contained in.
1004 */
Gordon Henriksen76a03742007-09-18 03:18:57 +00001005void LLVMGetStructElementTypes(LLVMTypeRef StructTy, LLVMTypeRef *Dest);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001006
1007/**
Peter Zotovc164a3f2015-06-04 09:09:53 +00001008 * Get the type of the element at a given index in the structure.
1009 *
1010 * @see llvm::StructType::getTypeAtIndex()
1011 */
1012LLVMTypeRef LLVMStructGetTypeAtIndex(LLVMTypeRef StructTy, unsigned i);
1013
1014/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00001015 * Determine whether a structure is packed.
1016 *
1017 * @see llvm::StructType::isPacked()
1018 */
Chris Lattner25963c62010-01-09 22:27:07 +00001019LLVMBool LLVMIsPackedStruct(LLVMTypeRef StructTy);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001020
1021/**
1022 * Determine whether a structure is opaque.
1023 *
1024 * @see llvm::StructType::isOpaque()
1025 */
Chris Lattner17cf05b2011-07-14 16:20:28 +00001026LLVMBool LLVMIsOpaqueStruct(LLVMTypeRef StructTy);
1027
Gregory Szorc34c863a2012-03-21 03:54:29 +00001028/**
1029 * @}
1030 */
Gordon Henriksen76a03742007-09-18 03:18:57 +00001031
Gregory Szorc34c863a2012-03-21 03:54:29 +00001032/**
1033 * @defgroup LLVMCCoreTypeSequential Sequential Types
1034 *
1035 * Sequential types represents "arrays" of types. This is a super class
1036 * for array, vector, and pointer types.
1037 *
1038 * @{
1039 */
1040
1041/**
1042 * Obtain the type of elements within a sequential type.
1043 *
1044 * This works on array, vector, and pointer types.
1045 *
1046 * @see llvm::SequentialType::getElementType()
1047 */
1048LLVMTypeRef LLVMGetElementType(LLVMTypeRef Ty);
1049
1050/**
1051 * Create a fixed size array type that refers to a specific type.
1052 *
1053 * The created type will exist in the context that its element type
1054 * exists in.
1055 *
1056 * @see llvm::ArrayType::get()
1057 */
Gordon Henriksened7beaa2007-10-06 16:05:20 +00001058LLVMTypeRef LLVMArrayType(LLVMTypeRef ElementType, unsigned ElementCount);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001059
1060/**
1061 * Obtain the length of an array type.
1062 *
1063 * This only works on types that represent arrays.
1064 *
1065 * @see llvm::ArrayType::getNumElements()
1066 */
1067unsigned LLVMGetArrayLength(LLVMTypeRef ArrayTy);
1068
1069/**
1070 * Create a pointer type that points to a defined type.
1071 *
1072 * The created type will exist in the context that its pointee type
1073 * exists in.
1074 *
1075 * @see llvm::PointerType::get()
1076 */
Gordon Henriksen5a3fe032007-12-17 16:08:32 +00001077LLVMTypeRef LLVMPointerType(LLVMTypeRef ElementType, unsigned AddressSpace);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001078
1079/**
1080 * Obtain the address space of a pointer type.
1081 *
1082 * This only works on types that represent pointers.
1083 *
1084 * @see llvm::PointerType::getAddressSpace()
1085 */
1086unsigned LLVMGetPointerAddressSpace(LLVMTypeRef PointerTy);
1087
1088/**
1089 * Create a vector type that contains a defined type and has a specific
1090 * number of elements.
1091 *
1092 * The created type will exist in the context thats its element type
1093 * exists in.
1094 *
1095 * @see llvm::VectorType::get()
1096 */
Gordon Henriksened7beaa2007-10-06 16:05:20 +00001097LLVMTypeRef LLVMVectorType(LLVMTypeRef ElementType, unsigned ElementCount);
Gordon Henriksen76a03742007-09-18 03:18:57 +00001098
Gregory Szorc34c863a2012-03-21 03:54:29 +00001099/**
1100 * Obtain the number of elements in a vector type.
1101 *
1102 * This only works on types that represent vectors.
1103 *
1104 * @see llvm::VectorType::getNumElements()
1105 */
Gordon Henriksen76a03742007-09-18 03:18:57 +00001106unsigned LLVMGetVectorSize(LLVMTypeRef VectorTy);
1107
Gregory Szorc34c863a2012-03-21 03:54:29 +00001108/**
1109 * @}
1110 */
1111
1112/**
1113 * @defgroup LLVMCCoreTypeOther Other Types
1114 *
1115 * @{
1116 */
1117
1118/**
1119 * Create a void type in a context.
1120 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +00001121LLVMTypeRef LLVMVoidTypeInContext(LLVMContextRef C);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001122
1123/**
1124 * Create a label type in a context.
1125 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +00001126LLVMTypeRef LLVMLabelTypeInContext(LLVMContextRef C);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001127
1128/**
1129 * Create a X86 MMX type in a context.
1130 */
Dale Johannesen95b67af2010-09-10 21:58:02 +00001131LLVMTypeRef LLVMX86MMXTypeInContext(LLVMContextRef C);
Erick Tryzelaar262332f2009-08-14 00:01:31 +00001132
Gregory Szorc34c863a2012-03-21 03:54:29 +00001133/**
1134 * These are similar to the above functions except they operate on the
1135 * global context.
1136 */
Gordon Henriksena735a9c2008-05-04 12:55:34 +00001137LLVMTypeRef LLVMVoidType(void);
1138LLVMTypeRef LLVMLabelType(void);
Dale Johannesen95b67af2010-09-10 21:58:02 +00001139LLVMTypeRef LLVMX86MMXType(void);
Gordon Henriksen76a03742007-09-18 03:18:57 +00001140
Gregory Szorc34c863a2012-03-21 03:54:29 +00001141/**
1142 * @}
1143 */
Gordon Henriksen76a03742007-09-18 03:18:57 +00001144
Gregory Szorc34c863a2012-03-21 03:54:29 +00001145/**
1146 * @}
1147 */
1148
1149/**
1150 * @defgroup LLVMCCoreValues Values
1151 *
1152 * The bulk of LLVM's object model consists of values, which comprise a very
Gordon Henriksen76a03742007-09-18 03:18:57 +00001153 * rich type hierarchy.
Gregory Szorc34c863a2012-03-21 03:54:29 +00001154 *
1155 * LLVMValueRef essentially represents llvm::Value. There is a rich
1156 * hierarchy of classes within this type. Depending on the instance
Eli Benderskyc52863c2012-08-10 18:30:44 +00001157 * obtained, not all APIs are available.
Gregory Szorc34c863a2012-03-21 03:54:29 +00001158 *
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00001159 * Callers can determine the type of an LLVMValueRef by calling the
Gregory Szorc34c863a2012-03-21 03:54:29 +00001160 * LLVMIsA* family of functions (e.g. LLVMIsAArgument()). These
1161 * functions are defined by a macro, so it isn't obvious which are
1162 * available by looking at the Doxygen source code. Instead, look at the
1163 * source definition of LLVM_FOR_EACH_VALUE_SUBCLASS and note the list
1164 * of value names given. These value names also correspond to classes in
1165 * the llvm::Value hierarchy.
1166 *
1167 * @{
Gordon Henriksen76a03742007-09-18 03:18:57 +00001168 */
1169
Gordon Henriksen29e38942008-12-19 18:39:45 +00001170#define LLVM_FOR_EACH_VALUE_SUBCLASS(macro) \
1171 macro(Argument) \
1172 macro(BasicBlock) \
1173 macro(InlineAsm) \
1174 macro(User) \
1175 macro(Constant) \
Torok Edwind09b7572011-10-14 20:37:56 +00001176 macro(BlockAddress) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001177 macro(ConstantAggregateZero) \
1178 macro(ConstantArray) \
Peter Zotovae0344b2013-11-05 12:55:37 +00001179 macro(ConstantDataSequential) \
1180 macro(ConstantDataArray) \
1181 macro(ConstantDataVector) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001182 macro(ConstantExpr) \
1183 macro(ConstantFP) \
1184 macro(ConstantInt) \
1185 macro(ConstantPointerNull) \
1186 macro(ConstantStruct) \
David Majnemerf0f224d2015-11-11 21:57:16 +00001187 macro(ConstantTokenNone) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001188 macro(ConstantVector) \
1189 macro(GlobalValue) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001190 macro(GlobalAlias) \
Rafael Espindola99e05cf2014-05-13 18:45:48 +00001191 macro(GlobalObject) \
1192 macro(Function) \
1193 macro(GlobalVariable) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001194 macro(UndefValue) \
1195 macro(Instruction) \
1196 macro(BinaryOperator) \
1197 macro(CallInst) \
1198 macro(IntrinsicInst) \
1199 macro(DbgInfoIntrinsic) \
1200 macro(DbgDeclareInst) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001201 macro(MemIntrinsic) \
1202 macro(MemCpyInst) \
1203 macro(MemMoveInst) \
1204 macro(MemSetInst) \
1205 macro(CmpInst) \
Torok Edwind09b7572011-10-14 20:37:56 +00001206 macro(FCmpInst) \
1207 macro(ICmpInst) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001208 macro(ExtractElementInst) \
1209 macro(GetElementPtrInst) \
1210 macro(InsertElementInst) \
1211 macro(InsertValueInst) \
Bill Wendlingfae14752011-08-12 20:24:12 +00001212 macro(LandingPadInst) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001213 macro(PHINode) \
1214 macro(SelectInst) \
1215 macro(ShuffleVectorInst) \
1216 macro(StoreInst) \
1217 macro(TerminatorInst) \
1218 macro(BranchInst) \
Torok Edwind09b7572011-10-14 20:37:56 +00001219 macro(IndirectBrInst) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001220 macro(InvokeInst) \
1221 macro(ReturnInst) \
1222 macro(SwitchInst) \
1223 macro(UnreachableInst) \
Bill Wendlingf891bf82011-07-31 06:30:59 +00001224 macro(ResumeInst) \
David Majnemer654e1302015-07-31 17:58:14 +00001225 macro(CleanupReturnInst) \
1226 macro(CatchReturnInst) \
Eugene Zelenkoffec81c2015-11-04 22:32:32 +00001227 macro(TerminatePadInst) \
David Majnemer8a1c45d2015-12-12 05:38:55 +00001228 macro(FuncletPadInst) \
1229 macro(CatchPadInst) \
1230 macro(CleanupPadInst) \
Duncan Sands5e37e992013-05-06 08:55:45 +00001231 macro(UnaryInstruction) \
1232 macro(AllocaInst) \
1233 macro(CastInst) \
Matt Arsenaultb03bd4d2013-11-15 01:34:59 +00001234 macro(AddrSpaceCastInst) \
Duncan Sands5e37e992013-05-06 08:55:45 +00001235 macro(BitCastInst) \
1236 macro(FPExtInst) \
1237 macro(FPToSIInst) \
1238 macro(FPToUIInst) \
1239 macro(FPTruncInst) \
1240 macro(IntToPtrInst) \
1241 macro(PtrToIntInst) \
1242 macro(SExtInst) \
1243 macro(SIToFPInst) \
1244 macro(TruncInst) \
1245 macro(UIToFPInst) \
1246 macro(ZExtInst) \
1247 macro(ExtractValueInst) \
1248 macro(LoadInst) \
1249 macro(VAArgInst)
Gordon Henriksen29e38942008-12-19 18:39:45 +00001250
Gregory Szorc34c863a2012-03-21 03:54:29 +00001251/**
1252 * @defgroup LLVMCCoreValueGeneral General APIs
1253 *
1254 * Functions in this section work on all LLVMValueRef instances,
1255 * regardless of their sub-type. They correspond to functions available
1256 * on llvm::Value.
1257 *
1258 * @{
1259 */
Gordon Henriksen76a03742007-09-18 03:18:57 +00001260
Gregory Szorc34c863a2012-03-21 03:54:29 +00001261/**
1262 * Obtain the type of a value.
1263 *
1264 * @see llvm::Value::getType()
1265 */
1266LLVMTypeRef LLVMTypeOf(LLVMValueRef Val);
1267
1268/**
1269 * Obtain the string name of a value.
1270 *
1271 * @see llvm::Value::getName()
1272 */
1273const char *LLVMGetValueName(LLVMValueRef Val);
1274
1275/**
1276 * Set the string name of a value.
1277 *
1278 * @see llvm::Value::setName()
1279 */
1280void LLVMSetValueName(LLVMValueRef Val, const char *Name);
1281
1282/**
1283 * Dump a representation of a value to stderr.
1284 *
1285 * @see llvm::Value::dump()
1286 */
1287void LLVMDumpValue(LLVMValueRef Val);
1288
1289/**
Peter Zotovcd93b372013-11-06 09:21:01 +00001290 * Return a string representation of the value. Use
1291 * LLVMDisposeMessage to free the string.
1292 *
1293 * @see llvm::Value::print()
1294 */
1295char *LLVMPrintValueToString(LLVMValueRef Val);
1296
1297/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00001298 * Replace all uses of a value with another one.
1299 *
1300 * @see llvm::Value::replaceAllUsesWith()
1301 */
1302void LLVMReplaceAllUsesWith(LLVMValueRef OldVal, LLVMValueRef NewVal);
1303
1304/**
1305 * Determine whether the specified constant instance is constant.
1306 */
1307LLVMBool LLVMIsConstant(LLVMValueRef Val);
1308
1309/**
1310 * Determine whether a value instance is undefined.
1311 */
1312LLVMBool LLVMIsUndef(LLVMValueRef Val);
1313
1314/**
1315 * Convert value instances between types.
1316 *
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00001317 * Internally, an LLVMValueRef is "pinned" to a specific type. This
Gregory Szorc34c863a2012-03-21 03:54:29 +00001318 * series of functions allows you to cast an instance to a specific
1319 * type.
1320 *
1321 * If the cast is not valid for the specified type, NULL is returned.
1322 *
1323 * @see llvm::dyn_cast_or_null<>
1324 */
Gordon Henriksen29e38942008-12-19 18:39:45 +00001325#define LLVM_DECLARE_VALUE_CAST(name) \
1326 LLVMValueRef LLVMIsA##name(LLVMValueRef Val);
1327LLVM_FOR_EACH_VALUE_SUBCLASS(LLVM_DECLARE_VALUE_CAST)
1328
Duncan P. N. Exon Smith5bf8fef2014-12-09 18:38:53 +00001329LLVMValueRef LLVMIsAMDNode(LLVMValueRef Val);
1330LLVMValueRef LLVMIsAMDString(LLVMValueRef Val);
1331
Gregory Szorc34c863a2012-03-21 03:54:29 +00001332/**
1333 * @}
1334 */
1335
1336/**
1337 * @defgroup LLVMCCoreValueUses Usage
1338 *
1339 * This module defines functions that allow you to inspect the uses of a
1340 * LLVMValueRef.
1341 *
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00001342 * It is possible to obtain an LLVMUseRef for any LLVMValueRef instance.
Gregory Szorc34c863a2012-03-21 03:54:29 +00001343 * Each LLVMUseRef (which corresponds to a llvm::Use instance) holds a
1344 * llvm::User and llvm::Value.
1345 *
1346 * @{
1347 */
1348
1349/**
1350 * Obtain the first use of a value.
1351 *
1352 * Uses are obtained in an iterator fashion. First, call this function
1353 * to obtain a reference to the first use. Then, call LLVMGetNextUse()
Eli Benderskyc52863c2012-08-10 18:30:44 +00001354 * on that instance and all subsequently obtained instances until
Gregory Szorc34c863a2012-03-21 03:54:29 +00001355 * LLVMGetNextUse() returns NULL.
1356 *
1357 * @see llvm::Value::use_begin()
1358 */
Erick Tryzelaar9f9857e2010-03-02 20:32:28 +00001359LLVMUseRef LLVMGetFirstUse(LLVMValueRef Val);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001360
1361/**
1362 * Obtain the next use of a value.
1363 *
1364 * This effectively advances the iterator. It returns NULL if you are on
1365 * the final use and no more are available.
1366 */
Erick Tryzelaar9f9857e2010-03-02 20:32:28 +00001367LLVMUseRef LLVMGetNextUse(LLVMUseRef U);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001368
1369/**
1370 * Obtain the user value for a user.
1371 *
1372 * The returned value corresponds to a llvm::User type.
1373 *
1374 * @see llvm::Use::getUser()
1375 */
Erick Tryzelaar9f9857e2010-03-02 20:32:28 +00001376LLVMValueRef LLVMGetUser(LLVMUseRef U);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001377
1378/**
1379 * Obtain the value this use corresponds to.
1380 *
1381 * @see llvm::Use::get().
1382 */
Erick Tryzelaar9f9857e2010-03-02 20:32:28 +00001383LLVMValueRef LLVMGetUsedValue(LLVMUseRef U);
Chris Lattner40cf28d2009-10-12 04:01:02 +00001384
Gregory Szorc34c863a2012-03-21 03:54:29 +00001385/**
1386 * @}
1387 */
1388
1389/**
Gregory Szorc52d26602012-03-21 07:28:27 +00001390 * @defgroup LLVMCCoreValueUser User value
Gregory Szorc34c863a2012-03-21 03:54:29 +00001391 *
1392 * Function in this group pertain to LLVMValueRef instances that descent
1393 * from llvm::User. This includes constants, instructions, and
1394 * operators.
1395 *
1396 * @{
1397 */
1398
1399/**
1400 * Obtain an operand at a specific index in a llvm::User value.
1401 *
1402 * @see llvm::User::getOperand()
1403 */
Chris Lattner40cf28d2009-10-12 04:01:02 +00001404LLVMValueRef LLVMGetOperand(LLVMValueRef Val, unsigned Index);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001405
1406/**
Peter Zotovb19f78f2014-08-12 02:55:40 +00001407 * Obtain the use of an operand at a specific index in a llvm::User value.
1408 *
1409 * @see llvm::User::getOperandUse()
1410 */
1411LLVMUseRef LLVMGetOperandUse(LLVMValueRef Val, unsigned Index);
1412
1413/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00001414 * Set an operand at a specific index in a llvm::User value.
1415 *
1416 * @see llvm::User::setOperand()
1417 */
Erick Tryzelaarb4d48702010-08-20 14:51:22 +00001418void LLVMSetOperand(LLVMValueRef User, unsigned Index, LLVMValueRef Val);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001419
1420/**
1421 * Obtain the number of operands in a llvm::User value.
1422 *
1423 * @see llvm::User::getNumOperands()
1424 */
Erick Tryzelaarb4d48702010-08-20 14:51:22 +00001425int LLVMGetNumOperands(LLVMValueRef Val);
Chris Lattner40cf28d2009-10-12 04:01:02 +00001426
Gregory Szorc34c863a2012-03-21 03:54:29 +00001427/**
1428 * @}
1429 */
1430
1431/**
Gregory Szorc52d26602012-03-21 07:28:27 +00001432 * @defgroup LLVMCCoreValueConstant Constants
Gregory Szorc34c863a2012-03-21 03:54:29 +00001433 *
1434 * This section contains APIs for interacting with LLVMValueRef that
1435 * correspond to llvm::Constant instances.
1436 *
1437 * These functions will work for any LLVMValueRef in the llvm::Constant
1438 * class hierarchy.
1439 *
1440 * @{
1441 */
1442
1443/**
1444 * Obtain a constant value referring to the null instance of a type.
1445 *
1446 * @see llvm::Constant::getNullValue()
1447 */
Gordon Henriksen1046c732007-10-06 15:11:06 +00001448LLVMValueRef LLVMConstNull(LLVMTypeRef Ty); /* all zeroes */
Gregory Szorc34c863a2012-03-21 03:54:29 +00001449
1450/**
1451 * Obtain a constant value referring to the instance of a type
1452 * consisting of all ones.
1453 *
1454 * This is only valid for integer types.
1455 *
1456 * @see llvm::Constant::getAllOnesValue()
1457 */
1458LLVMValueRef LLVMConstAllOnes(LLVMTypeRef Ty);
1459
1460/**
1461 * Obtain a constant value referring to an undefined value of a type.
1462 *
1463 * @see llvm::UndefValue::get()
1464 */
Gordon Henriksen76a03742007-09-18 03:18:57 +00001465LLVMValueRef LLVMGetUndef(LLVMTypeRef Ty);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001466
1467/**
1468 * Determine whether a value instance is null.
1469 *
1470 * @see llvm::Constant::isNullValue()
1471 */
Chris Lattner25963c62010-01-09 22:27:07 +00001472LLVMBool LLVMIsNull(LLVMValueRef Val);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001473
1474/**
1475 * Obtain a constant that is a constant pointer pointing to NULL for a
1476 * specified type.
1477 */
Chris Lattner7f318242009-07-06 17:29:59 +00001478LLVMValueRef LLVMConstPointerNull(LLVMTypeRef Ty);
Gordon Henriksen76a03742007-09-18 03:18:57 +00001479
Gregory Szorc34c863a2012-03-21 03:54:29 +00001480/**
1481 * @defgroup LLVMCCoreValueConstantScalar Scalar constants
1482 *
1483 * Functions in this group model LLVMValueRef instances that correspond
1484 * to constants referring to scalar types.
1485 *
1486 * For integer types, the LLVMTypeRef parameter should correspond to a
1487 * llvm::IntegerType instance and the returned LLVMValueRef will
1488 * correspond to a llvm::ConstantInt.
1489 *
1490 * For floating point types, the LLVMTypeRef returned corresponds to a
1491 * llvm::ConstantFP.
1492 *
1493 * @{
1494 */
Erick Tryzelaard8531fa2010-02-28 09:45:59 +00001495
Gregory Szorc34c863a2012-03-21 03:54:29 +00001496/**
1497 * Obtain a constant value for an integer type.
1498 *
1499 * The returned value corresponds to a llvm::ConstantInt.
1500 *
1501 * @see llvm::ConstantInt::get()
1502 *
1503 * @param IntTy Integer type to obtain value of.
1504 * @param N The value the returned instance should refer to.
1505 * @param SignExtend Whether to sign extend the produced value.
1506 */
Gordon Henriksen1046c732007-10-06 15:11:06 +00001507LLVMValueRef LLVMConstInt(LLVMTypeRef IntTy, unsigned long long N,
Chris Lattner25963c62010-01-09 22:27:07 +00001508 LLVMBool SignExtend);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001509
1510/**
1511 * Obtain a constant value for an integer of arbitrary precision.
1512 *
1513 * @see llvm::ConstantInt::get()
1514 */
Chris Lattner4329e072010-11-23 02:47:22 +00001515LLVMValueRef LLVMConstIntOfArbitraryPrecision(LLVMTypeRef IntTy,
1516 unsigned NumWords,
1517 const uint64_t Words[]);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001518
1519/**
1520 * Obtain a constant value for an integer parsed from a string.
1521 *
1522 * A similar API, LLVMConstIntOfStringAndSize is also available. If the
1523 * string's length is available, it is preferred to call that function
1524 * instead.
1525 *
1526 * @see llvm::ConstantInt::get()
1527 */
Erick Tryzelaardd991352009-08-16 23:36:46 +00001528LLVMValueRef LLVMConstIntOfString(LLVMTypeRef IntTy, const char *Text,
1529 uint8_t Radix);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001530
1531/**
1532 * Obtain a constant value for an integer parsed from a string with
1533 * specified length.
1534 *
1535 * @see llvm::ConstantInt::get()
1536 */
Erick Tryzelaardd991352009-08-16 23:36:46 +00001537LLVMValueRef LLVMConstIntOfStringAndSize(LLVMTypeRef IntTy, const char *Text,
1538 unsigned SLen, uint8_t Radix);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001539
1540/**
1541 * Obtain a constant value referring to a double floating point value.
1542 */
Gordon Henriksen1046c732007-10-06 15:11:06 +00001543LLVMValueRef LLVMConstReal(LLVMTypeRef RealTy, double N);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001544
1545/**
1546 * Obtain a constant for a floating point value parsed from a string.
1547 *
1548 * A similar API, LLVMConstRealOfStringAndSize is also available. It
1549 * should be used if the input string's length is known.
1550 */
Gordon Henriksen931e1212008-02-02 01:07:50 +00001551LLVMValueRef LLVMConstRealOfString(LLVMTypeRef RealTy, const char *Text);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001552
1553/**
1554 * Obtain a constant for a floating point value parsed from a string.
1555 */
Erick Tryzelaardd991352009-08-16 23:36:46 +00001556LLVMValueRef LLVMConstRealOfStringAndSize(LLVMTypeRef RealTy, const char *Text,
1557 unsigned SLen);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001558
1559/**
1560 * Obtain the zero extended value for an integer constant value.
1561 *
1562 * @see llvm::ConstantInt::getZExtValue()
1563 */
Chris Lattner40cf28d2009-10-12 04:01:02 +00001564unsigned long long LLVMConstIntGetZExtValue(LLVMValueRef ConstantVal);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001565
1566/**
1567 * Obtain the sign extended value for an integer constant value.
1568 *
1569 * @see llvm::ConstantInt::getSExtValue()
1570 */
Chris Lattner40cf28d2009-10-12 04:01:02 +00001571long long LLVMConstIntGetSExtValue(LLVMValueRef ConstantVal);
Erick Tryzelaardd991352009-08-16 23:36:46 +00001572
Gregory Szorc34c863a2012-03-21 03:54:29 +00001573/**
Peter Zotov1d98e6d2014-10-28 19:46:44 +00001574 * Obtain the double value for an floating point constant value.
1575 * losesInfo indicates if some precision was lost in the conversion.
1576 *
1577 * @see llvm::ConstantFP::getDoubleValue
1578 */
1579double LLVMConstRealGetDouble(LLVMValueRef ConstantVal, LLVMBool *losesInfo);
1580
1581/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00001582 * @}
1583 */
1584
1585/**
Gregory Szorc52d26602012-03-21 07:28:27 +00001586 * @defgroup LLVMCCoreValueConstantComposite Composite Constants
1587 *
1588 * Functions in this group operate on composite constants.
Gregory Szorc34c863a2012-03-21 03:54:29 +00001589 *
1590 * @{
1591 */
1592
1593/**
Gregory Szorc52d26602012-03-21 07:28:27 +00001594 * Create a ConstantDataSequential and initialize it with a string.
Gregory Szorc34c863a2012-03-21 03:54:29 +00001595 *
Gregory Szorc52d26602012-03-21 07:28:27 +00001596 * @see llvm::ConstantDataArray::getString()
Gregory Szorc34c863a2012-03-21 03:54:29 +00001597 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +00001598LLVMValueRef LLVMConstStringInContext(LLVMContextRef C, const char *Str,
Chris Lattner25963c62010-01-09 22:27:07 +00001599 unsigned Length, LLVMBool DontNullTerminate);
Gregory Szorc52d26602012-03-21 07:28:27 +00001600
1601/**
1602 * Create a ConstantDataSequential with string content in the global context.
1603 *
1604 * This is the same as LLVMConstStringInContext except it operates on the
1605 * global context.
1606 *
1607 * @see LLVMConstStringInContext()
1608 * @see llvm::ConstantDataArray::getString()
1609 */
1610LLVMValueRef LLVMConstString(const char *Str, unsigned Length,
1611 LLVMBool DontNullTerminate);
1612
1613/**
Peter Zotovf9aa8822014-08-03 23:54:16 +00001614 * Returns true if the specified constant is an array of i8.
1615 *
1616 * @see ConstantDataSequential::getAsString()
1617 */
1618LLVMBool LLVMIsConstantString(LLVMValueRef c);
1619
1620/**
1621 * Get the given constant data sequential as a string.
1622 *
1623 * @see ConstantDataSequential::getAsString()
1624 */
1625const char *LLVMGetAsString(LLVMValueRef c, size_t* out);
1626
1627/**
Gregory Szorc52d26602012-03-21 07:28:27 +00001628 * Create an anonymous ConstantStruct with the specified values.
1629 *
1630 * @see llvm::ConstantStruct::getAnon()
1631 */
1632LLVMValueRef LLVMConstStructInContext(LLVMContextRef C,
Erick Tryzelaar262332f2009-08-14 00:01:31 +00001633 LLVMValueRef *ConstantVals,
Chris Lattner25963c62010-01-09 22:27:07 +00001634 unsigned Count, LLVMBool Packed);
Erick Tryzelaar262332f2009-08-14 00:01:31 +00001635
Gregory Szorc52d26602012-03-21 07:28:27 +00001636/**
1637 * Create a ConstantStruct in the global Context.
1638 *
1639 * This is the same as LLVMConstStructInContext except it operates on the
1640 * global Context.
1641 *
1642 * @see LLVMConstStructInContext()
1643 */
Gordon Henriksen1046c732007-10-06 15:11:06 +00001644LLVMValueRef LLVMConstStruct(LLVMValueRef *ConstantVals, unsigned Count,
Chris Lattner25963c62010-01-09 22:27:07 +00001645 LLVMBool Packed);
Gregory Szorc52d26602012-03-21 07:28:27 +00001646
1647/**
1648 * Create a ConstantArray from values.
1649 *
1650 * @see llvm::ConstantArray::get()
1651 */
1652LLVMValueRef LLVMConstArray(LLVMTypeRef ElementTy,
1653 LLVMValueRef *ConstantVals, unsigned Length);
1654
1655/**
1656 * Create a non-anonymous ConstantStruct from values.
1657 *
1658 * @see llvm::ConstantStruct::get()
1659 */
Rafael Espindola784ad242011-07-14 19:09:08 +00001660LLVMValueRef LLVMConstNamedStruct(LLVMTypeRef StructTy,
1661 LLVMValueRef *ConstantVals,
1662 unsigned Count);
Gregory Szorc52d26602012-03-21 07:28:27 +00001663
1664/**
Peter Zotovf9aa8822014-08-03 23:54:16 +00001665 * Get an element at specified index as a constant.
1666 *
1667 * @see ConstantDataSequential::getElementAsConstant()
1668 */
1669LLVMValueRef LLVMGetElementAsConstant(LLVMValueRef c, unsigned idx);
1670
1671/**
Gregory Szorc52d26602012-03-21 07:28:27 +00001672 * Create a ConstantVector from values.
1673 *
1674 * @see llvm::ConstantVector::get()
1675 */
Gordon Henriksen1046c732007-10-06 15:11:06 +00001676LLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals, unsigned Size);
Gordon Henriksen76a03742007-09-18 03:18:57 +00001677
Gregory Szorc52d26602012-03-21 07:28:27 +00001678/**
1679 * @}
1680 */
1681
1682/**
1683 * @defgroup LLVMCCoreValueConstantExpressions Constant Expressions
1684 *
1685 * Functions in this group correspond to APIs on llvm::ConstantExpr.
1686 *
1687 * @see llvm::ConstantExpr.
1688 *
1689 * @{
1690 */
Chris Lattner40cf28d2009-10-12 04:01:02 +00001691LLVMOpcode LLVMGetConstOpcode(LLVMValueRef ConstantVal);
Erick Tryzelaarfd529d72009-08-19 08:36:49 +00001692LLVMValueRef LLVMAlignOf(LLVMTypeRef Ty);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001693LLVMValueRef LLVMSizeOf(LLVMTypeRef Ty);
1694LLVMValueRef LLVMConstNeg(LLVMValueRef ConstantVal);
Erick Tryzelaar4c340c72010-02-28 05:51:43 +00001695LLVMValueRef LLVMConstNSWNeg(LLVMValueRef ConstantVal);
1696LLVMValueRef LLVMConstNUWNeg(LLVMValueRef ConstantVal);
Erick Tryzelaar4cc690c2009-08-16 02:20:12 +00001697LLVMValueRef LLVMConstFNeg(LLVMValueRef ConstantVal);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001698LLVMValueRef LLVMConstNot(LLVMValueRef ConstantVal);
1699LLVMValueRef LLVMConstAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Dan Gohmane4ca02d2009-09-03 23:34:49 +00001700LLVMValueRef LLVMConstNSWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Erick Tryzelaar4c340c72010-02-28 05:51:43 +00001701LLVMValueRef LLVMConstNUWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Erick Tryzelaar4cc690c2009-08-16 02:20:12 +00001702LLVMValueRef LLVMConstFAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001703LLVMValueRef LLVMConstSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Erick Tryzelaar4c340c72010-02-28 05:51:43 +00001704LLVMValueRef LLVMConstNSWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1705LLVMValueRef LLVMConstNUWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Erick Tryzelaar4cc690c2009-08-16 02:20:12 +00001706LLVMValueRef LLVMConstFSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001707LLVMValueRef LLVMConstMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Erick Tryzelaar4c340c72010-02-28 05:51:43 +00001708LLVMValueRef LLVMConstNSWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1709LLVMValueRef LLVMConstNUWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Erick Tryzelaar4cc690c2009-08-16 02:20:12 +00001710LLVMValueRef LLVMConstFMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001711LLVMValueRef LLVMConstUDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1712LLVMValueRef LLVMConstSDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Dan Gohmane4ca02d2009-09-03 23:34:49 +00001713LLVMValueRef LLVMConstExactSDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001714LLVMValueRef LLVMConstFDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1715LLVMValueRef LLVMConstURem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1716LLVMValueRef LLVMConstSRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1717LLVMValueRef LLVMConstFRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1718LLVMValueRef LLVMConstAnd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1719LLVMValueRef LLVMConstOr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1720LLVMValueRef LLVMConstXor(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1721LLVMValueRef LLVMConstICmp(LLVMIntPredicate Predicate,
1722 LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1723LLVMValueRef LLVMConstFCmp(LLVMRealPredicate Predicate,
1724 LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1725LLVMValueRef LLVMConstShl(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1726LLVMValueRef LLVMConstLShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1727LLVMValueRef LLVMConstAShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1728LLVMValueRef LLVMConstGEP(LLVMValueRef ConstantVal,
1729 LLVMValueRef *ConstantIndices, unsigned NumIndices);
Dan Gohmane4ca02d2009-09-03 23:34:49 +00001730LLVMValueRef LLVMConstInBoundsGEP(LLVMValueRef ConstantVal,
1731 LLVMValueRef *ConstantIndices,
1732 unsigned NumIndices);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001733LLVMValueRef LLVMConstTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1734LLVMValueRef LLVMConstSExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1735LLVMValueRef LLVMConstZExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1736LLVMValueRef LLVMConstFPTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1737LLVMValueRef LLVMConstFPExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1738LLVMValueRef LLVMConstUIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1739LLVMValueRef LLVMConstSIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1740LLVMValueRef LLVMConstFPToUI(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1741LLVMValueRef LLVMConstFPToSI(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1742LLVMValueRef LLVMConstPtrToInt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1743LLVMValueRef LLVMConstIntToPtr(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1744LLVMValueRef LLVMConstBitCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
Matt Arsenaultb03bd4d2013-11-15 01:34:59 +00001745LLVMValueRef LLVMConstAddrSpaceCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
Erick Tryzelaar4cc690c2009-08-16 02:20:12 +00001746LLVMValueRef LLVMConstZExtOrBitCast(LLVMValueRef ConstantVal,
1747 LLVMTypeRef ToType);
1748LLVMValueRef LLVMConstSExtOrBitCast(LLVMValueRef ConstantVal,
1749 LLVMTypeRef ToType);
1750LLVMValueRef LLVMConstTruncOrBitCast(LLVMValueRef ConstantVal,
1751 LLVMTypeRef ToType);
1752LLVMValueRef LLVMConstPointerCast(LLVMValueRef ConstantVal,
1753 LLVMTypeRef ToType);
1754LLVMValueRef LLVMConstIntCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType,
Chris Lattner25963c62010-01-09 22:27:07 +00001755 LLVMBool isSigned);
Erick Tryzelaar4cc690c2009-08-16 02:20:12 +00001756LLVMValueRef LLVMConstFPCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001757LLVMValueRef LLVMConstSelect(LLVMValueRef ConstantCondition,
1758 LLVMValueRef ConstantIfTrue,
1759 LLVMValueRef ConstantIfFalse);
1760LLVMValueRef LLVMConstExtractElement(LLVMValueRef VectorConstant,
1761 LLVMValueRef IndexConstant);
1762LLVMValueRef LLVMConstInsertElement(LLVMValueRef VectorConstant,
1763 LLVMValueRef ElementValueConstant,
1764 LLVMValueRef IndexConstant);
1765LLVMValueRef LLVMConstShuffleVector(LLVMValueRef VectorAConstant,
1766 LLVMValueRef VectorBConstant,
1767 LLVMValueRef MaskConstant);
Dan Gohmand5104a52008-11-03 22:55:43 +00001768LLVMValueRef LLVMConstExtractValue(LLVMValueRef AggConstant, unsigned *IdxList,
1769 unsigned NumIdx);
1770LLVMValueRef LLVMConstInsertValue(LLVMValueRef AggConstant,
1771 LLVMValueRef ElementValueConstant,
1772 unsigned *IdxList, unsigned NumIdx);
Chris Lattner25963c62010-01-09 22:27:07 +00001773LLVMValueRef LLVMConstInlineAsm(LLVMTypeRef Ty,
Chris Lattner3d1f5522008-12-17 21:39:50 +00001774 const char *AsmString, const char *Constraints,
Chris Lattner25963c62010-01-09 22:27:07 +00001775 LLVMBool HasSideEffects, LLVMBool IsAlignStack);
Erick Tryzelaar0fb26ef2010-02-28 09:46:06 +00001776LLVMValueRef LLVMBlockAddress(LLVMValueRef F, LLVMBasicBlockRef BB);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001777
Gregory Szorc52d26602012-03-21 07:28:27 +00001778/**
1779 * @}
1780 */
1781
1782/**
1783 * @defgroup LLVMCCoreValueConstantGlobals Global Values
1784 *
1785 * This group contains functions that operate on global values. Functions in
1786 * this group relate to functions in the llvm::GlobalValue class tree.
1787 *
1788 * @see llvm::GlobalValue
1789 *
1790 * @{
1791 */
1792
Gordon Henriksen265f7802008-03-19 01:11:35 +00001793LLVMModuleRef LLVMGetGlobalParent(LLVMValueRef Global);
Chris Lattner25963c62010-01-09 22:27:07 +00001794LLVMBool LLVMIsDeclaration(LLVMValueRef Global);
Gordon Henriksen76a03742007-09-18 03:18:57 +00001795LLVMLinkage LLVMGetLinkage(LLVMValueRef Global);
1796void LLVMSetLinkage(LLVMValueRef Global, LLVMLinkage Linkage);
1797const char *LLVMGetSection(LLVMValueRef Global);
1798void LLVMSetSection(LLVMValueRef Global, const char *Section);
1799LLVMVisibility LLVMGetVisibility(LLVMValueRef Global);
1800void LLVMSetVisibility(LLVMValueRef Global, LLVMVisibility Viz);
Reid Kleckner2fae26f2014-03-05 02:34:23 +00001801LLVMDLLStorageClass LLVMGetDLLStorageClass(LLVMValueRef Global);
1802void LLVMSetDLLStorageClass(LLVMValueRef Global, LLVMDLLStorageClass Class);
Tim Northoverad96d012014-03-10 19:24:35 +00001803LLVMBool LLVMHasUnnamedAddr(LLVMValueRef Global);
1804void LLVMSetUnnamedAddr(LLVMValueRef Global, LLVMBool HasUnnamedAddr);
Anders Waldenborg213a63f2013-10-29 09:02:02 +00001805
1806/**
1807 * @defgroup LLVMCCoreValueWithAlignment Values with alignment
1808 *
1809 * Functions in this group only apply to values with alignment, i.e.
1810 * global variables, load and store instructions.
1811 */
1812
1813/**
1814 * Obtain the preferred alignment of the value.
Peter Zotov9f584e62014-03-05 05:05:34 +00001815 * @see llvm::AllocaInst::getAlignment()
Anders Waldenborg213a63f2013-10-29 09:02:02 +00001816 * @see llvm::LoadInst::getAlignment()
1817 * @see llvm::StoreInst::getAlignment()
1818 * @see llvm::GlobalValue::getAlignment()
1819 */
1820unsigned LLVMGetAlignment(LLVMValueRef V);
1821
1822/**
1823 * Set the preferred alignment of the value.
Peter Zotov9f584e62014-03-05 05:05:34 +00001824 * @see llvm::AllocaInst::setAlignment()
Anders Waldenborg213a63f2013-10-29 09:02:02 +00001825 * @see llvm::LoadInst::setAlignment()
1826 * @see llvm::StoreInst::setAlignment()
1827 * @see llvm::GlobalValue::setAlignment()
1828 */
1829void LLVMSetAlignment(LLVMValueRef V, unsigned Bytes);
1830
1831/**
1832 * @}
1833 */
Gordon Henriksen76a03742007-09-18 03:18:57 +00001834
Gregory Szorc52d26602012-03-21 07:28:27 +00001835/**
1836 * @defgroup LLVMCoreValueConstantGlobalVariable Global Variables
1837 *
1838 * This group contains functions that operate on global variable values.
1839 *
1840 * @see llvm::GlobalVariable
1841 *
1842 * @{
1843 */
Gordon Henriksen76a03742007-09-18 03:18:57 +00001844LLVMValueRef LLVMAddGlobal(LLVMModuleRef M, LLVMTypeRef Ty, const char *Name);
Erick Tryzelaar06894b32010-02-28 09:46:13 +00001845LLVMValueRef LLVMAddGlobalInAddressSpace(LLVMModuleRef M, LLVMTypeRef Ty,
1846 const char *Name,
1847 unsigned AddressSpace);
Gordon Henriksen783f7bb2007-10-08 03:45:09 +00001848LLVMValueRef LLVMGetNamedGlobal(LLVMModuleRef M, const char *Name);
Gordon Henriksen07a45f42008-03-23 22:21:29 +00001849LLVMValueRef LLVMGetFirstGlobal(LLVMModuleRef M);
1850LLVMValueRef LLVMGetLastGlobal(LLVMModuleRef M);
1851LLVMValueRef LLVMGetNextGlobal(LLVMValueRef GlobalVar);
1852LLVMValueRef LLVMGetPreviousGlobal(LLVMValueRef GlobalVar);
Gordon Henriksen76a03742007-09-18 03:18:57 +00001853void LLVMDeleteGlobal(LLVMValueRef GlobalVar);
Gordon Henriksen76a03742007-09-18 03:18:57 +00001854LLVMValueRef LLVMGetInitializer(LLVMValueRef GlobalVar);
1855void LLVMSetInitializer(LLVMValueRef GlobalVar, LLVMValueRef ConstantVal);
Chris Lattner25963c62010-01-09 22:27:07 +00001856LLVMBool LLVMIsThreadLocal(LLVMValueRef GlobalVar);
1857void LLVMSetThreadLocal(LLVMValueRef GlobalVar, LLVMBool IsThreadLocal);
1858LLVMBool LLVMIsGlobalConstant(LLVMValueRef GlobalVar);
1859void LLVMSetGlobalConstant(LLVMValueRef GlobalVar, LLVMBool IsConstant);
Hans Wennborg5ff71202013-04-16 08:58:59 +00001860LLVMThreadLocalMode LLVMGetThreadLocalMode(LLVMValueRef GlobalVar);
1861void LLVMSetThreadLocalMode(LLVMValueRef GlobalVar, LLVMThreadLocalMode Mode);
1862LLVMBool LLVMIsExternallyInitialized(LLVMValueRef GlobalVar);
1863void LLVMSetExternallyInitialized(LLVMValueRef GlobalVar, LLVMBool IsExtInit);
Gordon Henriksen76a03742007-09-18 03:18:57 +00001864
Gregory Szorc52d26602012-03-21 07:28:27 +00001865/**
1866 * @}
1867 */
1868
1869/**
1870 * @defgroup LLVMCoreValueConstantGlobalAlias Global Aliases
1871 *
1872 * This group contains function that operate on global alias values.
1873 *
1874 * @see llvm::GlobalAlias
1875 *
1876 * @{
1877 */
Chris Lattner3d1f5522008-12-17 21:39:50 +00001878LLVMValueRef LLVMAddAlias(LLVMModuleRef M, LLVMTypeRef Ty, LLVMValueRef Aliasee,
1879 const char *Name);
1880
Gregory Szorc34c863a2012-03-21 03:54:29 +00001881/**
1882 * @}
1883 */
1884
1885/**
1886 * @defgroup LLVMCCoreValueFunction Function values
1887 *
1888 * Functions in this group operate on LLVMValueRef instances that
1889 * correspond to llvm::Function instances.
1890 *
1891 * @see llvm::Function
1892 *
1893 * @{
1894 */
1895
1896/**
1897 * Remove a function from its containing module and deletes it.
1898 *
1899 * @see llvm::Function::eraseFromParent()
1900 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00001901void LLVMDeleteFunction(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001902
1903/**
Andrew Wilkins3bdfc1c2015-07-14 01:23:06 +00001904 * Obtain the personality function attached to the function.
1905 *
1906 * @see llvm::Function::getPersonalityFn()
1907 */
1908LLVMValueRef LLVMGetPersonalityFn(LLVMValueRef Fn);
1909
1910/**
1911 * Set the personality function attached to the function.
1912 *
1913 * @see llvm::Function::setPersonalityFn()
1914 */
1915void LLVMSetPersonalityFn(LLVMValueRef Fn, LLVMValueRef PersonalityFn);
1916
1917/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00001918 * Obtain the ID number from a function instance.
1919 *
1920 * @see llvm::Function::getIntrinsicID()
1921 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00001922unsigned LLVMGetIntrinsicID(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001923
1924/**
1925 * Obtain the calling function of a function.
1926 *
1927 * The returned value corresponds to the LLVMCallConv enumeration.
1928 *
1929 * @see llvm::Function::getCallingConv()
1930 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00001931unsigned LLVMGetFunctionCallConv(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001932
1933/**
1934 * Set the calling convention of a function.
1935 *
1936 * @see llvm::Function::setCallingConv()
1937 *
1938 * @param Fn Function to operate on
1939 * @param CC LLVMCallConv to set calling convention to
1940 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00001941void LLVMSetFunctionCallConv(LLVMValueRef Fn, unsigned CC);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001942
1943/**
1944 * Obtain the name of the garbage collector to use during code
1945 * generation.
1946 *
1947 * @see llvm::Function::getGC()
1948 */
Gordon Henriksend930f912008-08-17 18:44:35 +00001949const char *LLVMGetGC(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001950
1951/**
1952 * Define the garbage collector to use during code generation.
1953 *
1954 * @see llvm::Function::setGC()
1955 */
Gordon Henriksend930f912008-08-17 18:44:35 +00001956void LLVMSetGC(LLVMValueRef Fn, const char *Name);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001957
1958/**
1959 * Add an attribute to a function.
1960 *
1961 * @see llvm::Function::addAttribute()
1962 */
Duncan Sands7374a012009-05-06 12:21:17 +00001963void LLVMAddFunctionAttr(LLVMValueRef Fn, LLVMAttribute PA);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001964
1965/**
Nick Lewyckyc3890d22015-07-29 22:32:47 +00001966 * Add a target-dependent attribute to a function
Tom Stellarde8f35e12013-04-16 23:12:43 +00001967 * @see llvm::AttrBuilder::addAttribute()
1968 */
1969void LLVMAddTargetDependentFunctionAttr(LLVMValueRef Fn, const char *A,
1970 const char *V);
1971
1972/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00001973 * Obtain an attribute from a function.
1974 *
1975 * @see llvm::Function::getAttributes()
1976 */
Chris Lattner40cf28d2009-10-12 04:01:02 +00001977LLVMAttribute LLVMGetFunctionAttr(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001978
1979/**
1980 * Remove an attribute from a function.
1981 */
Duncan Sands7374a012009-05-06 12:21:17 +00001982void LLVMRemoveFunctionAttr(LLVMValueRef Fn, LLVMAttribute PA);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00001983
Gregory Szorc34c863a2012-03-21 03:54:29 +00001984/**
1985 * @defgroup LLVMCCoreValueFunctionParameters Function Parameters
1986 *
1987 * Functions in this group relate to arguments/parameters on functions.
1988 *
1989 * Functions in this group expect LLVMValueRef instances that correspond
1990 * to llvm::Function instances.
1991 *
1992 * @{
1993 */
1994
1995/**
1996 * Obtain the number of parameters in a function.
1997 *
1998 * @see llvm::Function::arg_size()
1999 */
Gordon Henriksen265f7802008-03-19 01:11:35 +00002000unsigned LLVMCountParams(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002001
2002/**
2003 * Obtain the parameters in a function.
2004 *
2005 * The takes a pointer to a pre-allocated array of LLVMValueRef that is
2006 * at least LLVMCountParams() long. This array will be filled with
2007 * LLVMValueRef instances which correspond to the parameters the
2008 * function receives. Each LLVMValueRef corresponds to a llvm::Argument
2009 * instance.
2010 *
2011 * @see llvm::Function::arg_begin()
2012 */
Gordon Henriksen265f7802008-03-19 01:11:35 +00002013void LLVMGetParams(LLVMValueRef Fn, LLVMValueRef *Params);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002014
2015/**
2016 * Obtain the parameter at the specified index.
2017 *
2018 * Parameters are indexed from 0.
2019 *
2020 * @see llvm::Function::arg_begin()
2021 */
Gordon Henriksen265f7802008-03-19 01:11:35 +00002022LLVMValueRef LLVMGetParam(LLVMValueRef Fn, unsigned Index);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002023
2024/**
2025 * Obtain the function to which this argument belongs.
2026 *
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00002027 * Unlike other functions in this group, this one takes an LLVMValueRef
Gregory Szorc34c863a2012-03-21 03:54:29 +00002028 * that corresponds to a llvm::Attribute.
2029 *
2030 * The returned LLVMValueRef is the llvm::Function to which this
2031 * argument belongs.
2032 */
Gordon Henriksen265f7802008-03-19 01:11:35 +00002033LLVMValueRef LLVMGetParamParent(LLVMValueRef Inst);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002034
2035/**
2036 * Obtain the first parameter to a function.
2037 *
2038 * @see llvm::Function::arg_begin()
2039 */
Gordon Henriksen07a45f42008-03-23 22:21:29 +00002040LLVMValueRef LLVMGetFirstParam(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002041
2042/**
2043 * Obtain the last parameter to a function.
2044 *
2045 * @see llvm::Function::arg_end()
2046 */
Gordon Henriksen07a45f42008-03-23 22:21:29 +00002047LLVMValueRef LLVMGetLastParam(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002048
2049/**
2050 * Obtain the next parameter to a function.
2051 *
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00002052 * This takes an LLVMValueRef obtained from LLVMGetFirstParam() (which is
Gregory Szorc34c863a2012-03-21 03:54:29 +00002053 * actually a wrapped iterator) and obtains the next parameter from the
2054 * underlying iterator.
2055 */
Gordon Henriksen07a45f42008-03-23 22:21:29 +00002056LLVMValueRef LLVMGetNextParam(LLVMValueRef Arg);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002057
2058/**
2059 * Obtain the previous parameter to a function.
2060 *
2061 * This is the opposite of LLVMGetNextParam().
2062 */
Gordon Henriksen07a45f42008-03-23 22:21:29 +00002063LLVMValueRef LLVMGetPreviousParam(LLVMValueRef Arg);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002064
2065/**
2066 * Add an attribute to a function argument.
2067 *
2068 * @see llvm::Argument::addAttr()
2069 */
Devang Patel4c758ea2008-09-25 21:00:45 +00002070void LLVMAddAttribute(LLVMValueRef Arg, LLVMAttribute PA);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002071
2072/**
2073 * Remove an attribute from a function argument.
2074 *
2075 * @see llvm::Argument::removeAttr()
2076 */
Devang Patel4c758ea2008-09-25 21:00:45 +00002077void LLVMRemoveAttribute(LLVMValueRef Arg, LLVMAttribute PA);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002078
2079/**
2080 * Get an attribute from a function argument.
2081 */
Chris Lattner40cf28d2009-10-12 04:01:02 +00002082LLVMAttribute LLVMGetAttribute(LLVMValueRef Arg);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002083
2084/**
2085 * Set the alignment for a function parameter.
2086 *
2087 * @see llvm::Argument::addAttr()
Bill Wendling50d27842012-10-15 20:35:56 +00002088 * @see llvm::AttrBuilder::addAlignmentAttr()
Gregory Szorc34c863a2012-03-21 03:54:29 +00002089 */
Gordon Henriksen2d9cc212008-04-28 17:37:06 +00002090void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned align);
Gordon Henriksen265f7802008-03-19 01:11:35 +00002091
Gregory Szorc34c863a2012-03-21 03:54:29 +00002092/**
2093 * @}
2094 */
2095
2096/**
2097 * @}
2098 */
2099
2100/**
Gregory Szorc52d26602012-03-21 07:28:27 +00002101 * @}
2102 */
2103
2104/**
2105 * @}
2106 */
2107
2108/**
2109 * @defgroup LLVMCCoreValueMetadata Metadata
2110 *
2111 * @{
2112 */
2113
2114/**
2115 * Obtain a MDString value from a context.
2116 *
2117 * The returned instance corresponds to the llvm::MDString class.
2118 *
2119 * The instance is specified by string data of a specified length. The
2120 * string content is copied, so the backing memory can be freed after
2121 * this function returns.
2122 */
2123LLVMValueRef LLVMMDStringInContext(LLVMContextRef C, const char *Str,
2124 unsigned SLen);
2125
2126/**
2127 * Obtain a MDString value from the global context.
2128 */
2129LLVMValueRef LLVMMDString(const char *Str, unsigned SLen);
2130
2131/**
2132 * Obtain a MDNode value from a context.
2133 *
2134 * The returned value corresponds to the llvm::MDNode class.
2135 */
2136LLVMValueRef LLVMMDNodeInContext(LLVMContextRef C, LLVMValueRef *Vals,
2137 unsigned Count);
2138
2139/**
2140 * Obtain a MDNode value from the global context.
2141 */
2142LLVMValueRef LLVMMDNode(LLVMValueRef *Vals, unsigned Count);
2143
2144/**
2145 * Obtain the underlying string from a MDString value.
2146 *
2147 * @param V Instance to obtain string from.
2148 * @param Len Memory address which will hold length of returned string.
2149 * @return String data in MDString.
2150 */
2151const char *LLVMGetMDString(LLVMValueRef V, unsigned* Len);
2152
2153/**
Duncan Sands12ccbe72012-09-19 20:29:39 +00002154 * Obtain the number of operands from an MDNode value.
2155 *
2156 * @param V MDNode to get number of operands from.
2157 * @return Number of operands of the MDNode.
2158 */
2159unsigned LLVMGetMDNodeNumOperands(LLVMValueRef V);
2160
2161/**
2162 * Obtain the given MDNode's operands.
2163 *
2164 * The passed LLVMValueRef pointer should point to enough memory to hold all of
2165 * the operands of the given MDNode (see LLVMGetMDNodeNumOperands) as
2166 * LLVMValueRefs. This memory will be populated with the LLVMValueRefs of the
2167 * MDNode's operands.
2168 *
2169 * @param V MDNode to get the operands from.
2170 * @param Dest Destination array for operands.
2171 */
2172void LLVMGetMDNodeOperands(LLVMValueRef V, LLVMValueRef *Dest);
2173
2174/**
Gregory Szorc52d26602012-03-21 07:28:27 +00002175 * @}
2176 */
2177
2178/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002179 * @defgroup LLVMCCoreValueBasicBlock Basic Block
2180 *
2181 * A basic block represents a single entry single exit section of code.
2182 * Basic blocks contain a list of instructions which form the body of
2183 * the block.
2184 *
2185 * Basic blocks belong to functions. They have the type of label.
2186 *
2187 * Basic blocks are themselves values. However, the C API models them as
2188 * LLVMBasicBlockRef.
2189 *
2190 * @see llvm::BasicBlock
2191 *
2192 * @{
2193 */
2194
2195/**
2196 * Convert a basic block instance to a value type.
2197 */
Gordon Henriksen07a45f42008-03-23 22:21:29 +00002198LLVMValueRef LLVMBasicBlockAsValue(LLVMBasicBlockRef BB);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002199
2200/**
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00002201 * Determine whether an LLVMValueRef is itself a basic block.
Gregory Szorc34c863a2012-03-21 03:54:29 +00002202 */
Chris Lattner25963c62010-01-09 22:27:07 +00002203LLVMBool LLVMValueIsBasicBlock(LLVMValueRef Val);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002204
2205/**
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00002206 * Convert an LLVMValueRef to an LLVMBasicBlockRef instance.
Gregory Szorc34c863a2012-03-21 03:54:29 +00002207 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002208LLVMBasicBlockRef LLVMValueAsBasicBlock(LLVMValueRef Val);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002209
2210/**
2211 * Obtain the function to which a basic block belongs.
2212 *
2213 * @see llvm::BasicBlock::getParent()
2214 */
Gordon Henriksen07a45f42008-03-23 22:21:29 +00002215LLVMValueRef LLVMGetBasicBlockParent(LLVMBasicBlockRef BB);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002216
2217/**
2218 * Obtain the terminator instruction for a basic block.
2219 *
2220 * If the basic block does not have a terminator (it is not well-formed
2221 * if it doesn't), then NULL is returned.
2222 *
2223 * The returned LLVMValueRef corresponds to a llvm::TerminatorInst.
2224 *
2225 * @see llvm::BasicBlock::getTerminator()
2226 */
Nate Begeman43c322b2011-08-23 20:27:46 +00002227LLVMValueRef LLVMGetBasicBlockTerminator(LLVMBasicBlockRef BB);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002228
2229/**
2230 * Obtain the number of basic blocks in a function.
2231 *
2232 * @param Fn Function value to operate on.
2233 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002234unsigned LLVMCountBasicBlocks(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002235
2236/**
2237 * Obtain all of the basic blocks in a function.
2238 *
2239 * This operates on a function value. The BasicBlocks parameter is a
2240 * pointer to a pre-allocated array of LLVMBasicBlockRef of at least
2241 * LLVMCountBasicBlocks() in length. This array is populated with
2242 * LLVMBasicBlockRef instances.
2243 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002244void LLVMGetBasicBlocks(LLVMValueRef Fn, LLVMBasicBlockRef *BasicBlocks);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002245
2246/**
2247 * Obtain the first basic block in a function.
2248 *
2249 * The returned basic block can be used as an iterator. You will likely
2250 * eventually call into LLVMGetNextBasicBlock() with it.
2251 *
2252 * @see llvm::Function::begin()
2253 */
Gordon Henriksen054817c2008-03-19 03:47:18 +00002254LLVMBasicBlockRef LLVMGetFirstBasicBlock(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002255
2256/**
2257 * Obtain the last basic block in a function.
2258 *
2259 * @see llvm::Function::end()
2260 */
Gordon Henriksen054817c2008-03-19 03:47:18 +00002261LLVMBasicBlockRef LLVMGetLastBasicBlock(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002262
2263/**
2264 * Advance a basic block iterator.
2265 */
Gordon Henriksen054817c2008-03-19 03:47:18 +00002266LLVMBasicBlockRef LLVMGetNextBasicBlock(LLVMBasicBlockRef BB);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002267
2268/**
2269 * Go backwards in a basic block iterator.
2270 */
Gordon Henriksen054817c2008-03-19 03:47:18 +00002271LLVMBasicBlockRef LLVMGetPreviousBasicBlock(LLVMBasicBlockRef BB);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002272
2273/**
2274 * Obtain the basic block that corresponds to the entry point of a
2275 * function.
2276 *
2277 * @see llvm::Function::getEntryBlock()
2278 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002279LLVMBasicBlockRef LLVMGetEntryBasicBlock(LLVMValueRef Fn);
Erick Tryzelaar262332f2009-08-14 00:01:31 +00002280
Gregory Szorc34c863a2012-03-21 03:54:29 +00002281/**
2282 * Append a basic block to the end of a function.
2283 *
2284 * @see llvm::BasicBlock::Create()
2285 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +00002286LLVMBasicBlockRef LLVMAppendBasicBlockInContext(LLVMContextRef C,
2287 LLVMValueRef Fn,
2288 const char *Name);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002289
2290/**
2291 * Append a basic block to the end of a function using the global
2292 * context.
2293 *
2294 * @see llvm::BasicBlock::Create()
2295 */
2296LLVMBasicBlockRef LLVMAppendBasicBlock(LLVMValueRef Fn, const char *Name);
2297
2298/**
2299 * Insert a basic block in a function before another basic block.
2300 *
2301 * The function to add to is determined by the function of the
2302 * passed basic block.
2303 *
2304 * @see llvm::BasicBlock::Create()
2305 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +00002306LLVMBasicBlockRef LLVMInsertBasicBlockInContext(LLVMContextRef C,
2307 LLVMBasicBlockRef BB,
2308 const char *Name);
2309
Gregory Szorc34c863a2012-03-21 03:54:29 +00002310/**
2311 * Insert a basic block in a function using the global context.
2312 *
2313 * @see llvm::BasicBlock::Create()
2314 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002315LLVMBasicBlockRef LLVMInsertBasicBlock(LLVMBasicBlockRef InsertBeforeBB,
2316 const char *Name);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002317
2318/**
2319 * Remove a basic block from a function and delete it.
2320 *
2321 * This deletes the basic block from its containing function and deletes
2322 * the basic block itself.
2323 *
2324 * @see llvm::BasicBlock::eraseFromParent()
2325 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002326void LLVMDeleteBasicBlock(LLVMBasicBlockRef BB);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002327
2328/**
2329 * Remove a basic block from a function.
2330 *
2331 * This deletes the basic block from its containing function but keep
2332 * the basic block alive.
2333 *
2334 * @see llvm::BasicBlock::removeFromParent()
2335 */
Nate Begeman43c322b2011-08-23 20:27:46 +00002336void LLVMRemoveBasicBlockFromParent(LLVMBasicBlockRef BB);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002337
Gregory Szorc34c863a2012-03-21 03:54:29 +00002338/**
2339 * Move a basic block to before another one.
2340 *
2341 * @see llvm::BasicBlock::moveBefore()
2342 */
Duncan Sandsb1d61aa2010-07-19 15:31:07 +00002343void LLVMMoveBasicBlockBefore(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002344
2345/**
2346 * Move a basic block to after another one.
2347 *
2348 * @see llvm::BasicBlock::moveAfter()
2349 */
Duncan Sandsb1d61aa2010-07-19 15:31:07 +00002350void LLVMMoveBasicBlockAfter(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos);
2351
Gregory Szorc34c863a2012-03-21 03:54:29 +00002352/**
2353 * Obtain the first instruction in a basic block.
2354 *
2355 * The returned LLVMValueRef corresponds to a llvm::Instruction
2356 * instance.
2357 */
Gordon Henriksen054817c2008-03-19 03:47:18 +00002358LLVMValueRef LLVMGetFirstInstruction(LLVMBasicBlockRef BB);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002359
2360/**
2361 * Obtain the last instruction in a basic block.
2362 *
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00002363 * The returned LLVMValueRef corresponds to an LLVM:Instruction.
Gregory Szorc34c863a2012-03-21 03:54:29 +00002364 */
Gordon Henriksen054817c2008-03-19 03:47:18 +00002365LLVMValueRef LLVMGetLastInstruction(LLVMBasicBlockRef BB);
Nate Begeman43c322b2011-08-23 20:27:46 +00002366
Gregory Szorc34c863a2012-03-21 03:54:29 +00002367/**
2368 * @}
2369 */
2370
2371/**
2372 * @defgroup LLVMCCoreValueInstruction Instructions
2373 *
2374 * Functions in this group relate to the inspection and manipulation of
2375 * individual instructions.
2376 *
2377 * In the C++ API, an instruction is modeled by llvm::Instruction. This
2378 * class has a large number of descendents. llvm::Instruction is a
2379 * llvm::Value and in the C API, instructions are modeled by
2380 * LLVMValueRef.
2381 *
2382 * This group also contains sub-groups which operate on specific
2383 * llvm::Instruction types, e.g. llvm::CallInst.
2384 *
2385 * @{
2386 */
2387
2388/**
2389 * Determine whether an instruction has any metadata attached.
2390 */
2391int LLVMHasMetadata(LLVMValueRef Val);
2392
2393/**
2394 * Return metadata associated with an instruction value.
2395 */
2396LLVMValueRef LLVMGetMetadata(LLVMValueRef Val, unsigned KindID);
2397
2398/**
2399 * Set metadata associated with an instruction value.
2400 */
2401void LLVMSetMetadata(LLVMValueRef Val, unsigned KindID, LLVMValueRef Node);
2402
2403/**
2404 * Obtain the basic block to which an instruction belongs.
2405 *
2406 * @see llvm::Instruction::getParent()
2407 */
Nate Begeman43c322b2011-08-23 20:27:46 +00002408LLVMBasicBlockRef LLVMGetInstructionParent(LLVMValueRef Inst);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002409
2410/**
2411 * Obtain the instruction that occurs after the one specified.
2412 *
2413 * The next instruction will be from the same basic block.
2414 *
2415 * If this is the last instruction in a basic block, NULL will be
2416 * returned.
2417 */
Gordon Henriksen054817c2008-03-19 03:47:18 +00002418LLVMValueRef LLVMGetNextInstruction(LLVMValueRef Inst);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002419
2420/**
Benjamin Kramerbde91762012-06-02 10:20:22 +00002421 * Obtain the instruction that occurred before this one.
Gregory Szorc34c863a2012-03-21 03:54:29 +00002422 *
2423 * If the instruction is the first instruction in a basic block, NULL
2424 * will be returned.
2425 */
Gordon Henriksen054817c2008-03-19 03:47:18 +00002426LLVMValueRef LLVMGetPreviousInstruction(LLVMValueRef Inst);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002427
2428/**
2429 * Remove and delete an instruction.
2430 *
2431 * The instruction specified is removed from its containing building
2432 * block and then deleted.
2433 *
2434 * @see llvm::Instruction::eraseFromParent()
2435 */
Devang Pateldbebc6f2011-10-03 20:59:18 +00002436void LLVMInstructionEraseFromParent(LLVMValueRef Inst);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002437
2438/**
2439 * Obtain the code opcode for an individual instruction.
2440 *
2441 * @see llvm::Instruction::getOpCode()
2442 */
Torok Edwinab6158e2011-10-14 20:37:49 +00002443LLVMOpcode LLVMGetInstructionOpcode(LLVMValueRef Inst);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002444
2445/**
2446 * Obtain the predicate of an instruction.
2447 *
2448 * This is only valid for instructions that correspond to llvm::ICmpInst
2449 * or llvm::ConstantExpr whose opcode is llvm::Instruction::ICmp.
2450 *
2451 * @see llvm::ICmpInst::getPredicate()
2452 */
Torok Edwin60c40de2011-10-06 12:13:20 +00002453LLVMIntPredicate LLVMGetICmpPredicate(LLVMValueRef Inst);
Gordon Henriksen265f7802008-03-19 01:11:35 +00002454
Gregory Szorc34c863a2012-03-21 03:54:29 +00002455/**
Peter Zotov1d98e6d2014-10-28 19:46:44 +00002456 * Obtain the float predicate of an instruction.
2457 *
2458 * This is only valid for instructions that correspond to llvm::FCmpInst
2459 * or llvm::ConstantExpr whose opcode is llvm::Instruction::FCmp.
2460 *
2461 * @see llvm::FCmpInst::getPredicate()
2462 */
2463LLVMRealPredicate LLVMGetFCmpPredicate(LLVMValueRef Inst);
2464
2465/**
Peter Zotovaff492c2014-10-17 01:02:34 +00002466 * Create a copy of 'this' instruction that is identical in all ways
2467 * except the following:
2468 * * The instruction has no parent
2469 * * The instruction has no name
2470 *
2471 * @see llvm::Instruction::clone()
2472 */
2473LLVMValueRef LLVMInstructionClone(LLVMValueRef Inst);
2474
2475/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002476 * @defgroup LLVMCCoreValueInstructionCall Call Sites and Invocations
2477 *
2478 * Functions in this group apply to instructions that refer to call
2479 * sites and invocations. These correspond to C++ types in the
2480 * llvm::CallInst class tree.
2481 *
2482 * @{
2483 */
2484
2485/**
2486 * Set the calling convention for a call instruction.
2487 *
2488 * This expects an LLVMValueRef that corresponds to a llvm::CallInst or
2489 * llvm::InvokeInst.
2490 *
2491 * @see llvm::CallInst::setCallingConv()
2492 * @see llvm::InvokeInst::setCallingConv()
2493 */
Gordon Henriksen1158c532007-12-29 20:45:00 +00002494void LLVMSetInstructionCallConv(LLVMValueRef Instr, unsigned CC);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002495
2496/**
2497 * Obtain the calling convention for a call instruction.
2498 *
2499 * This is the opposite of LLVMSetInstructionCallConv(). Reads its
2500 * usage.
2501 *
2502 * @see LLVMSetInstructionCallConv()
2503 */
Gordon Henriksen1158c532007-12-29 20:45:00 +00002504unsigned LLVMGetInstructionCallConv(LLVMValueRef Instr);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002505
2506
Devang Patel4c758ea2008-09-25 21:00:45 +00002507void LLVMAddInstrAttribute(LLVMValueRef Instr, unsigned index, LLVMAttribute);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002508void LLVMRemoveInstrAttribute(LLVMValueRef Instr, unsigned index,
Devang Patel4c758ea2008-09-25 21:00:45 +00002509 LLVMAttribute);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002510void LLVMSetInstrParamAlignment(LLVMValueRef Instr, unsigned index,
Gordon Henriksen2d9cc212008-04-28 17:37:06 +00002511 unsigned align);
Gordon Henriksen1158c532007-12-29 20:45:00 +00002512
Gregory Szorc34c863a2012-03-21 03:54:29 +00002513/**
2514 * Obtain whether a call instruction is a tail call.
2515 *
2516 * This only works on llvm::CallInst instructions.
2517 *
2518 * @see llvm::CallInst::isTailCall()
2519 */
Chris Lattner25963c62010-01-09 22:27:07 +00002520LLVMBool LLVMIsTailCall(LLVMValueRef CallInst);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002521
2522/**
2523 * Set whether a call instruction is a tail call.
2524 *
2525 * This only works on llvm::CallInst instructions.
2526 *
2527 * @see llvm::CallInst::setTailCall()
2528 */
Chris Lattner25963c62010-01-09 22:27:07 +00002529void LLVMSetTailCall(LLVMValueRef CallInst, LLVMBool IsTailCall);
Gordon Henrikseneeb65372008-08-30 16:34:54 +00002530
Gregory Szorc34c863a2012-03-21 03:54:29 +00002531/**
2532 * @}
2533 */
2534
2535/**
Peter Zotov2481c752014-10-28 19:46:56 +00002536 * @defgroup LLVMCCoreValueInstructionTerminator Terminators
2537 *
2538 * Functions in this group only apply to instructions that map to
2539 * llvm::TerminatorInst instances.
2540 *
2541 * @{
2542 */
2543
2544/**
2545 * Return the number of successors that this terminator has.
2546 *
2547 * @see llvm::TerminatorInst::getNumSuccessors
2548 */
2549unsigned LLVMGetNumSuccessors(LLVMValueRef Term);
2550
2551/**
2552 * Return the specified successor.
2553 *
2554 * @see llvm::TerminatorInst::getSuccessor
2555 */
2556LLVMBasicBlockRef LLVMGetSuccessor(LLVMValueRef Term, unsigned i);
2557
2558/**
2559 * Update the specified successor to point at the provided block.
2560 *
2561 * @see llvm::TerminatorInst::setSuccessor
2562 */
2563void LLVMSetSuccessor(LLVMValueRef Term, unsigned i, LLVMBasicBlockRef block);
2564
2565/**
2566 * Return if a branch is conditional.
2567 *
2568 * This only works on llvm::BranchInst instructions.
2569 *
2570 * @see llvm::BranchInst::isConditional
2571 */
2572LLVMBool LLVMIsConditional(LLVMValueRef Branch);
2573
2574/**
2575 * Return the condition of a branch instruction.
2576 *
2577 * This only works on llvm::BranchInst instructions.
2578 *
2579 * @see llvm::BranchInst::getCondition
2580 */
2581LLVMValueRef LLVMGetCondition(LLVMValueRef Branch);
2582
2583/**
2584 * Set the condition of a branch instruction.
2585 *
2586 * This only works on llvm::BranchInst instructions.
2587 *
2588 * @see llvm::BranchInst::setCondition
2589 */
2590void LLVMSetCondition(LLVMValueRef Branch, LLVMValueRef Cond);
2591
2592/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002593 * Obtain the default destination basic block of a switch instruction.
2594 *
2595 * This only works on llvm::SwitchInst instructions.
2596 *
2597 * @see llvm::SwitchInst::getDefaultDest()
2598 */
Nate Begeman43c322b2011-08-23 20:27:46 +00002599LLVMBasicBlockRef LLVMGetSwitchDefaultDest(LLVMValueRef SwitchInstr);
2600
Gregory Szorc34c863a2012-03-21 03:54:29 +00002601/**
Peter Zotov2481c752014-10-28 19:46:56 +00002602 * @}
2603 */
2604
2605/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002606 * @defgroup LLVMCCoreValueInstructionPHINode PHI Nodes
2607 *
2608 * Functions in this group only apply to instructions that map to
2609 * llvm::PHINode instances.
2610 *
2611 * @{
2612 */
2613
2614/**
2615 * Add an incoming value to the end of a PHI list.
2616 */
Gordon Henriksen44dd8fb2007-10-08 18:14:39 +00002617void LLVMAddIncoming(LLVMValueRef PhiNode, LLVMValueRef *IncomingValues,
2618 LLVMBasicBlockRef *IncomingBlocks, unsigned Count);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002619
2620/**
2621 * Obtain the number of incoming basic blocks to a PHI node.
2622 */
Gordon Henriksen44dd8fb2007-10-08 18:14:39 +00002623unsigned LLVMCountIncoming(LLVMValueRef PhiNode);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002624
2625/**
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00002626 * Obtain an incoming value to a PHI node as an LLVMValueRef.
Gregory Szorc34c863a2012-03-21 03:54:29 +00002627 */
Gordon Henriksen44dd8fb2007-10-08 18:14:39 +00002628LLVMValueRef LLVMGetIncomingValue(LLVMValueRef PhiNode, unsigned Index);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002629
2630/**
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00002631 * Obtain an incoming value to a PHI node as an LLVMBasicBlockRef.
Gregory Szorc34c863a2012-03-21 03:54:29 +00002632 */
Gordon Henriksen44dd8fb2007-10-08 18:14:39 +00002633LLVMBasicBlockRef LLVMGetIncomingBlock(LLVMValueRef PhiNode, unsigned Index);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002634
Gregory Szorc34c863a2012-03-21 03:54:29 +00002635/**
2636 * @}
2637 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002638
Gregory Szorc34c863a2012-03-21 03:54:29 +00002639/**
2640 * @}
2641 */
2642
2643/**
2644 * @}
2645 */
2646
2647/**
2648 * @defgroup LLVMCCoreInstructionBuilder Instruction Builders
2649 *
2650 * An instruction builder represents a point within a basic block and is
2651 * the exclusive means of building instructions using the C interface.
2652 *
2653 * @{
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002654 */
2655
Erick Tryzelaar262332f2009-08-14 00:01:31 +00002656LLVMBuilderRef LLVMCreateBuilderInContext(LLVMContextRef C);
Gordon Henriksena735a9c2008-05-04 12:55:34 +00002657LLVMBuilderRef LLVMCreateBuilder(void);
Gordon Henriksen054817c2008-03-19 03:47:18 +00002658void LLVMPositionBuilder(LLVMBuilderRef Builder, LLVMBasicBlockRef Block,
2659 LLVMValueRef Instr);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002660void LLVMPositionBuilderBefore(LLVMBuilderRef Builder, LLVMValueRef Instr);
2661void LLVMPositionBuilderAtEnd(LLVMBuilderRef Builder, LLVMBasicBlockRef Block);
Gordon Henriksen265f7802008-03-19 01:11:35 +00002662LLVMBasicBlockRef LLVMGetInsertBlock(LLVMBuilderRef Builder);
Chris Lattner3d1f5522008-12-17 21:39:50 +00002663void LLVMClearInsertionPosition(LLVMBuilderRef Builder);
2664void LLVMInsertIntoBuilder(LLVMBuilderRef Builder, LLVMValueRef Instr);
Erick Tryzelaar9813bea2009-08-16 02:20:57 +00002665void LLVMInsertIntoBuilderWithName(LLVMBuilderRef Builder, LLVMValueRef Instr,
2666 const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002667void LLVMDisposeBuilder(LLVMBuilderRef Builder);
2668
Erick Tryzelaard8531fa2010-02-28 09:45:59 +00002669/* Metadata */
2670void LLVMSetCurrentDebugLocation(LLVMBuilderRef Builder, LLVMValueRef L);
2671LLVMValueRef LLVMGetCurrentDebugLocation(LLVMBuilderRef Builder);
2672void LLVMSetInstDebugLocation(LLVMBuilderRef Builder, LLVMValueRef Inst);
2673
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002674/* Terminators */
2675LLVMValueRef LLVMBuildRetVoid(LLVMBuilderRef);
2676LLVMValueRef LLVMBuildRet(LLVMBuilderRef, LLVMValueRef V);
Erick Tryzelaarfd529d72009-08-19 08:36:49 +00002677LLVMValueRef LLVMBuildAggregateRet(LLVMBuilderRef, LLVMValueRef *RetVals,
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002678 unsigned N);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002679LLVMValueRef LLVMBuildBr(LLVMBuilderRef, LLVMBasicBlockRef Dest);
2680LLVMValueRef LLVMBuildCondBr(LLVMBuilderRef, LLVMValueRef If,
2681 LLVMBasicBlockRef Then, LLVMBasicBlockRef Else);
2682LLVMValueRef LLVMBuildSwitch(LLVMBuilderRef, LLVMValueRef V,
2683 LLVMBasicBlockRef Else, unsigned NumCases);
Erick Tryzelaar0fb26ef2010-02-28 09:46:06 +00002684LLVMValueRef LLVMBuildIndirectBr(LLVMBuilderRef B, LLVMValueRef Addr,
2685 unsigned NumDests);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002686LLVMValueRef LLVMBuildInvoke(LLVMBuilderRef, LLVMValueRef Fn,
2687 LLVMValueRef *Args, unsigned NumArgs,
2688 LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch,
2689 const char *Name);
Benjamin Kramer5a6568832011-08-19 01:36:54 +00002690LLVMValueRef LLVMBuildLandingPad(LLVMBuilderRef B, LLVMTypeRef Ty,
Reid Kleckneref9828f2015-07-16 01:16:39 +00002691 LLVMValueRef PersFn, unsigned NumClauses,
2692 const char *Name);
Bill Wendlingf891bf82011-07-31 06:30:59 +00002693LLVMValueRef LLVMBuildResume(LLVMBuilderRef B, LLVMValueRef Exn);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002694LLVMValueRef LLVMBuildUnreachable(LLVMBuilderRef);
2695
Gordon Henriksen097102c2008-01-01 05:50:53 +00002696/* Add a case to the switch instruction */
2697void LLVMAddCase(LLVMValueRef Switch, LLVMValueRef OnVal,
2698 LLVMBasicBlockRef Dest);
2699
Erick Tryzelaar0fb26ef2010-02-28 09:46:06 +00002700/* Add a destination to the indirectbr instruction */
2701void LLVMAddDestination(LLVMValueRef IndirectBr, LLVMBasicBlockRef Dest);
2702
Bill Wendlingfae14752011-08-12 20:24:12 +00002703/* Add a catch or filter clause to the landingpad instruction */
2704void LLVMAddClause(LLVMValueRef LandingPad, LLVMValueRef ClauseVal);
2705
2706/* Set the 'cleanup' flag in the landingpad instruction */
2707void LLVMSetCleanup(LLVMValueRef LandingPad, LLVMBool Val);
2708
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002709/* Arithmetic */
2710LLVMValueRef LLVMBuildAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2711 const char *Name);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002712LLVMValueRef LLVMBuildNSWAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2713 const char *Name);
Erick Tryzelaar4c340c72010-02-28 05:51:43 +00002714LLVMValueRef LLVMBuildNUWAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2715 const char *Name);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002716LLVMValueRef LLVMBuildFAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2717 const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002718LLVMValueRef LLVMBuildSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2719 const char *Name);
Erick Tryzelaar4c340c72010-02-28 05:51:43 +00002720LLVMValueRef LLVMBuildNSWSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2721 const char *Name);
2722LLVMValueRef LLVMBuildNUWSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2723 const char *Name);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002724LLVMValueRef LLVMBuildFSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2725 const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002726LLVMValueRef LLVMBuildMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2727 const char *Name);
Erick Tryzelaar4c340c72010-02-28 05:51:43 +00002728LLVMValueRef LLVMBuildNSWMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2729 const char *Name);
2730LLVMValueRef LLVMBuildNUWMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2731 const char *Name);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002732LLVMValueRef LLVMBuildFMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2733 const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002734LLVMValueRef LLVMBuildUDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2735 const char *Name);
2736LLVMValueRef LLVMBuildSDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2737 const char *Name);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002738LLVMValueRef LLVMBuildExactSDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2739 const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002740LLVMValueRef LLVMBuildFDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2741 const char *Name);
2742LLVMValueRef LLVMBuildURem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2743 const char *Name);
2744LLVMValueRef LLVMBuildSRem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2745 const char *Name);
2746LLVMValueRef LLVMBuildFRem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2747 const char *Name);
2748LLVMValueRef LLVMBuildShl(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2749 const char *Name);
2750LLVMValueRef LLVMBuildLShr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2751 const char *Name);
2752LLVMValueRef LLVMBuildAShr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2753 const char *Name);
2754LLVMValueRef LLVMBuildAnd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2755 const char *Name);
2756LLVMValueRef LLVMBuildOr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2757 const char *Name);
2758LLVMValueRef LLVMBuildXor(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2759 const char *Name);
Erick Tryzelaar31831792010-02-28 05:51:27 +00002760LLVMValueRef LLVMBuildBinOp(LLVMBuilderRef B, LLVMOpcode Op,
2761 LLVMValueRef LHS, LLVMValueRef RHS,
2762 const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002763LLVMValueRef LLVMBuildNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name);
Erick Tryzelaar4c340c72010-02-28 05:51:43 +00002764LLVMValueRef LLVMBuildNSWNeg(LLVMBuilderRef B, LLVMValueRef V,
2765 const char *Name);
2766LLVMValueRef LLVMBuildNUWNeg(LLVMBuilderRef B, LLVMValueRef V,
2767 const char *Name);
Dan Gohmanf919bd62009-09-28 21:51:41 +00002768LLVMValueRef LLVMBuildFNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002769LLVMValueRef LLVMBuildNot(LLVMBuilderRef, LLVMValueRef V, const char *Name);
2770
2771/* Memory */
2772LLVMValueRef LLVMBuildMalloc(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
2773LLVMValueRef LLVMBuildArrayMalloc(LLVMBuilderRef, LLVMTypeRef Ty,
2774 LLVMValueRef Val, const char *Name);
2775LLVMValueRef LLVMBuildAlloca(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
2776LLVMValueRef LLVMBuildArrayAlloca(LLVMBuilderRef, LLVMTypeRef Ty,
2777 LLVMValueRef Val, const char *Name);
2778LLVMValueRef LLVMBuildFree(LLVMBuilderRef, LLVMValueRef PointerVal);
2779LLVMValueRef LLVMBuildLoad(LLVMBuilderRef, LLVMValueRef PointerVal,
2780 const char *Name);
2781LLVMValueRef LLVMBuildStore(LLVMBuilderRef, LLVMValueRef Val, LLVMValueRef Ptr);
2782LLVMValueRef LLVMBuildGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
2783 LLVMValueRef *Indices, unsigned NumIndices,
2784 const char *Name);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002785LLVMValueRef LLVMBuildInBoundsGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
2786 LLVMValueRef *Indices, unsigned NumIndices,
2787 const char *Name);
2788LLVMValueRef LLVMBuildStructGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
2789 unsigned Idx, const char *Name);
2790LLVMValueRef LLVMBuildGlobalString(LLVMBuilderRef B, const char *Str,
2791 const char *Name);
2792LLVMValueRef LLVMBuildGlobalStringPtr(LLVMBuilderRef B, const char *Str,
2793 const char *Name);
Chris Lattner2cc6f9d2012-03-22 03:54:15 +00002794LLVMBool LLVMGetVolatile(LLVMValueRef MemoryAccessInst);
2795void LLVMSetVolatile(LLVMValueRef MemoryAccessInst, LLVMBool IsVolatile);
Andrew Wilkinsb7362ce2015-08-02 12:16:57 +00002796LLVMAtomicOrdering LLVMGetOrdering(LLVMValueRef MemoryAccessInst);
2797void LLVMSetOrdering(LLVMValueRef MemoryAccessInst, LLVMAtomicOrdering Ordering);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002798
2799/* Casts */
2800LLVMValueRef LLVMBuildTrunc(LLVMBuilderRef, LLVMValueRef Val,
2801 LLVMTypeRef DestTy, const char *Name);
2802LLVMValueRef LLVMBuildZExt(LLVMBuilderRef, LLVMValueRef Val,
2803 LLVMTypeRef DestTy, const char *Name);
2804LLVMValueRef LLVMBuildSExt(LLVMBuilderRef, LLVMValueRef Val,
2805 LLVMTypeRef DestTy, const char *Name);
2806LLVMValueRef LLVMBuildFPToUI(LLVMBuilderRef, LLVMValueRef Val,
2807 LLVMTypeRef DestTy, const char *Name);
2808LLVMValueRef LLVMBuildFPToSI(LLVMBuilderRef, LLVMValueRef Val,
2809 LLVMTypeRef DestTy, const char *Name);
2810LLVMValueRef LLVMBuildUIToFP(LLVMBuilderRef, LLVMValueRef Val,
2811 LLVMTypeRef DestTy, const char *Name);
2812LLVMValueRef LLVMBuildSIToFP(LLVMBuilderRef, LLVMValueRef Val,
2813 LLVMTypeRef DestTy, const char *Name);
2814LLVMValueRef LLVMBuildFPTrunc(LLVMBuilderRef, LLVMValueRef Val,
2815 LLVMTypeRef DestTy, const char *Name);
2816LLVMValueRef LLVMBuildFPExt(LLVMBuilderRef, LLVMValueRef Val,
2817 LLVMTypeRef DestTy, const char *Name);
2818LLVMValueRef LLVMBuildPtrToInt(LLVMBuilderRef, LLVMValueRef Val,
2819 LLVMTypeRef DestTy, const char *Name);
2820LLVMValueRef LLVMBuildIntToPtr(LLVMBuilderRef, LLVMValueRef Val,
2821 LLVMTypeRef DestTy, const char *Name);
2822LLVMValueRef LLVMBuildBitCast(LLVMBuilderRef, LLVMValueRef Val,
2823 LLVMTypeRef DestTy, const char *Name);
Matt Arsenaultb03bd4d2013-11-15 01:34:59 +00002824LLVMValueRef LLVMBuildAddrSpaceCast(LLVMBuilderRef, LLVMValueRef Val,
2825 LLVMTypeRef DestTy, const char *Name);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002826LLVMValueRef LLVMBuildZExtOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
2827 LLVMTypeRef DestTy, const char *Name);
2828LLVMValueRef LLVMBuildSExtOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
2829 LLVMTypeRef DestTy, const char *Name);
2830LLVMValueRef LLVMBuildTruncOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
2831 LLVMTypeRef DestTy, const char *Name);
Erick Tryzelaar31831792010-02-28 05:51:27 +00002832LLVMValueRef LLVMBuildCast(LLVMBuilderRef B, LLVMOpcode Op, LLVMValueRef Val,
2833 LLVMTypeRef DestTy, const char *Name);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002834LLVMValueRef LLVMBuildPointerCast(LLVMBuilderRef, LLVMValueRef Val,
2835 LLVMTypeRef DestTy, const char *Name);
Duncan Sands9d786d72009-11-23 10:49:03 +00002836LLVMValueRef LLVMBuildIntCast(LLVMBuilderRef, LLVMValueRef Val, /*Signed cast!*/
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002837 LLVMTypeRef DestTy, const char *Name);
2838LLVMValueRef LLVMBuildFPCast(LLVMBuilderRef, LLVMValueRef Val,
2839 LLVMTypeRef DestTy, const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002840
2841/* Comparisons */
2842LLVMValueRef LLVMBuildICmp(LLVMBuilderRef, LLVMIntPredicate Op,
2843 LLVMValueRef LHS, LLVMValueRef RHS,
2844 const char *Name);
2845LLVMValueRef LLVMBuildFCmp(LLVMBuilderRef, LLVMRealPredicate Op,
2846 LLVMValueRef LHS, LLVMValueRef RHS,
2847 const char *Name);
2848
2849/* Miscellaneous instructions */
2850LLVMValueRef LLVMBuildPhi(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
2851LLVMValueRef LLVMBuildCall(LLVMBuilderRef, LLVMValueRef Fn,
2852 LLVMValueRef *Args, unsigned NumArgs,
2853 const char *Name);
2854LLVMValueRef LLVMBuildSelect(LLVMBuilderRef, LLVMValueRef If,
2855 LLVMValueRef Then, LLVMValueRef Else,
2856 const char *Name);
2857LLVMValueRef LLVMBuildVAArg(LLVMBuilderRef, LLVMValueRef List, LLVMTypeRef Ty,
2858 const char *Name);
2859LLVMValueRef LLVMBuildExtractElement(LLVMBuilderRef, LLVMValueRef VecVal,
2860 LLVMValueRef Index, const char *Name);
2861LLVMValueRef LLVMBuildInsertElement(LLVMBuilderRef, LLVMValueRef VecVal,
2862 LLVMValueRef EltVal, LLVMValueRef Index,
2863 const char *Name);
2864LLVMValueRef LLVMBuildShuffleVector(LLVMBuilderRef, LLVMValueRef V1,
2865 LLVMValueRef V2, LLVMValueRef Mask,
2866 const char *Name);
Dan Gohmand5104a52008-11-03 22:55:43 +00002867LLVMValueRef LLVMBuildExtractValue(LLVMBuilderRef, LLVMValueRef AggVal,
2868 unsigned Index, const char *Name);
2869LLVMValueRef LLVMBuildInsertValue(LLVMBuilderRef, LLVMValueRef AggVal,
2870 LLVMValueRef EltVal, unsigned Index,
2871 const char *Name);
Gordon Henriksen76a03742007-09-18 03:18:57 +00002872
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002873LLVMValueRef LLVMBuildIsNull(LLVMBuilderRef, LLVMValueRef Val,
2874 const char *Name);
2875LLVMValueRef LLVMBuildIsNotNull(LLVMBuilderRef, LLVMValueRef Val,
2876 const char *Name);
2877LLVMValueRef LLVMBuildPtrDiff(LLVMBuilderRef, LLVMValueRef LHS,
2878 LLVMValueRef RHS, const char *Name);
Filip Pizlo0d3f7ec2013-11-20 00:07:49 +00002879LLVMValueRef LLVMBuildFence(LLVMBuilderRef B, LLVMAtomicOrdering ordering,
2880 LLVMBool singleThread, const char *Name);
2881LLVMValueRef LLVMBuildAtomicRMW(LLVMBuilderRef B, LLVMAtomicRMWBinOp op,
NAKAMURA Takumia3a81352013-10-23 17:56:29 +00002882 LLVMValueRef PTR, LLVMValueRef Val,
2883 LLVMAtomicOrdering ordering,
Carlo Kok8c6719b2013-04-23 13:21:19 +00002884 LLVMBool singleThread);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002885
Gregory Szorc34c863a2012-03-21 03:54:29 +00002886/**
2887 * @}
2888 */
Gordon Henriksen34eb6d82007-12-19 22:30:40 +00002889
Gregory Szorc34c863a2012-03-21 03:54:29 +00002890/**
2891 * @defgroup LLVMCCoreModuleProvider Module Providers
2892 *
2893 * @{
2894 */
Gordon Henriksen0a68fe22007-12-12 01:04:30 +00002895
Gregory Szorc34c863a2012-03-21 03:54:29 +00002896/**
2897 * Changes the type of M so it can be passed to FunctionPassManagers and the
Jeffrey Yasskin091217b2010-01-27 20:34:15 +00002898 * JIT. They take ModuleProviders for historical reasons.
Gordon Henriksen0a68fe22007-12-12 01:04:30 +00002899 */
2900LLVMModuleProviderRef
2901LLVMCreateModuleProviderForExistingModule(LLVMModuleRef M);
2902
Gregory Szorc34c863a2012-03-21 03:54:29 +00002903/**
2904 * Destroys the module M.
Gordon Henriksen0a68fe22007-12-12 01:04:30 +00002905 */
Jeffrey Yasskin091217b2010-01-27 20:34:15 +00002906void LLVMDisposeModuleProvider(LLVMModuleProviderRef M);
Gordon Henriksen0a68fe22007-12-12 01:04:30 +00002907
Gregory Szorc34c863a2012-03-21 03:54:29 +00002908/**
2909 * @}
2910 */
Gordon Henriksen34eb6d82007-12-19 22:30:40 +00002911
Gregory Szorc34c863a2012-03-21 03:54:29 +00002912/**
2913 * @defgroup LLVMCCoreMemoryBuffers Memory Buffers
2914 *
2915 * @{
2916 */
Gordon Henriksen34eb6d82007-12-19 22:30:40 +00002917
Chris Lattner25963c62010-01-09 22:27:07 +00002918LLVMBool LLVMCreateMemoryBufferWithContentsOfFile(const char *Path,
2919 LLVMMemoryBufferRef *OutMemBuf,
2920 char **OutMessage);
2921LLVMBool LLVMCreateMemoryBufferWithSTDIN(LLVMMemoryBufferRef *OutMemBuf,
2922 char **OutMessage);
Bill Wendling526276a2013-02-14 19:11:28 +00002923LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRange(const char *InputData,
2924 size_t InputDataLength,
2925 const char *BufferName,
Bill Wendlingc9baa962013-02-14 19:39:14 +00002926 LLVMBool RequiresNullTerminator);
Bill Wendling526276a2013-02-14 19:11:28 +00002927LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRangeCopy(const char *InputData,
2928 size_t InputDataLength,
2929 const char *BufferName);
Tom Stellard62c03202013-04-18 19:50:53 +00002930const char *LLVMGetBufferStart(LLVMMemoryBufferRef MemBuf);
Tom Stellardb7fb7242013-04-16 23:12:51 +00002931size_t LLVMGetBufferSize(LLVMMemoryBufferRef MemBuf);
Gordon Henriksen34eb6d82007-12-19 22:30:40 +00002932void LLVMDisposeMemoryBuffer(LLVMMemoryBufferRef MemBuf);
2933
Gregory Szorc34c863a2012-03-21 03:54:29 +00002934/**
2935 * @}
2936 */
2937
2938/**
2939 * @defgroup LLVMCCorePassRegistry Pass Registry
2940 *
2941 * @{
2942 */
Owen Anderson4698c5d2010-10-07 17:55:47 +00002943
2944/** Return the global pass registry, for use with initialization functions.
Gregory Szorc34c863a2012-03-21 03:54:29 +00002945 @see llvm::PassRegistry::getPassRegistry */
Owen Anderson4698c5d2010-10-07 17:55:47 +00002946LLVMPassRegistryRef LLVMGetGlobalPassRegistry(void);
Gordon Henriksen878114b2008-03-16 04:20:44 +00002947
Gregory Szorc34c863a2012-03-21 03:54:29 +00002948/**
2949 * @}
2950 */
2951
2952/**
2953 * @defgroup LLVMCCorePassManagers Pass Managers
2954 *
2955 * @{
2956 */
Gordon Henriksen878114b2008-03-16 04:20:44 +00002957
2958/** Constructs a new whole-module pass pipeline. This type of pipeline is
2959 suitable for link-time optimization and whole-module transformations.
Gregory Szorc34c863a2012-03-21 03:54:29 +00002960 @see llvm::PassManager::PassManager */
Gordon Henriksena735a9c2008-05-04 12:55:34 +00002961LLVMPassManagerRef LLVMCreatePassManager(void);
Gordon Henriksen878114b2008-03-16 04:20:44 +00002962
2963/** Constructs a new function-by-function pass pipeline over the module
2964 provider. It does not take ownership of the module provider. This type of
2965 pipeline is suitable for code generation and JIT compilation tasks.
Gregory Szorc34c863a2012-03-21 03:54:29 +00002966 @see llvm::FunctionPassManager::FunctionPassManager */
Erick Tryzelaarad0e0cb2010-03-02 23:58:54 +00002967LLVMPassManagerRef LLVMCreateFunctionPassManagerForModule(LLVMModuleRef M);
2968
2969/** Deprecated: Use LLVMCreateFunctionPassManagerForModule instead. */
Gordon Henriksen878114b2008-03-16 04:20:44 +00002970LLVMPassManagerRef LLVMCreateFunctionPassManager(LLVMModuleProviderRef MP);
2971
2972/** Initializes, executes on the provided module, and finalizes all of the
2973 passes scheduled in the pass manager. Returns 1 if any of the passes
Gregory Szorc34c863a2012-03-21 03:54:29 +00002974 modified the module, 0 otherwise.
2975 @see llvm::PassManager::run(Module&) */
Chris Lattner25963c62010-01-09 22:27:07 +00002976LLVMBool LLVMRunPassManager(LLVMPassManagerRef PM, LLVMModuleRef M);
Gordon Henriksen878114b2008-03-16 04:20:44 +00002977
2978/** Initializes all of the function passes scheduled in the function pass
2979 manager. Returns 1 if any of the passes modified the module, 0 otherwise.
Gregory Szorc34c863a2012-03-21 03:54:29 +00002980 @see llvm::FunctionPassManager::doInitialization */
Chris Lattner25963c62010-01-09 22:27:07 +00002981LLVMBool LLVMInitializeFunctionPassManager(LLVMPassManagerRef FPM);
Gordon Henriksen878114b2008-03-16 04:20:44 +00002982
2983/** Executes all of the function passes scheduled in the function pass manager
2984 on the provided function. Returns 1 if any of the passes modified the
2985 function, false otherwise.
Gregory Szorc34c863a2012-03-21 03:54:29 +00002986 @see llvm::FunctionPassManager::run(Function&) */
Chris Lattner25963c62010-01-09 22:27:07 +00002987LLVMBool LLVMRunFunctionPassManager(LLVMPassManagerRef FPM, LLVMValueRef F);
Gordon Henriksen878114b2008-03-16 04:20:44 +00002988
2989/** Finalizes all of the function passes scheduled in in the function pass
2990 manager. Returns 1 if any of the passes modified the module, 0 otherwise.
Gregory Szorc34c863a2012-03-21 03:54:29 +00002991 @see llvm::FunctionPassManager::doFinalization */
Chris Lattner25963c62010-01-09 22:27:07 +00002992LLVMBool LLVMFinalizeFunctionPassManager(LLVMPassManagerRef FPM);
Gordon Henriksen878114b2008-03-16 04:20:44 +00002993
2994/** Frees the memory of a pass pipeline. For function pipelines, does not free
2995 the module provider.
Gregory Szorc34c863a2012-03-21 03:54:29 +00002996 @see llvm::PassManagerBase::~PassManagerBase. */
Gordon Henriksen878114b2008-03-16 04:20:44 +00002997void LLVMDisposePassManager(LLVMPassManagerRef PM);
2998
Gregory Szorc34c863a2012-03-21 03:54:29 +00002999/**
3000 * @}
3001 */
3002
3003/**
Duncan Sands1cba0a82013-02-17 16:35:51 +00003004 * @defgroup LLVMCCoreThreading Threading
3005 *
3006 * Handle the structures needed to make LLVM safe for multithreading.
3007 *
3008 * @{
3009 */
3010
Chandler Carruth39cd2162014-06-27 15:13:01 +00003011/** Deprecated: Multi-threading can only be enabled/disabled with the compile
3012 time define LLVM_ENABLE_THREADS. This function always returns
3013 LLVMIsMultithreaded(). */
Benjamin Kramer325ec892013-10-23 16:57:34 +00003014LLVMBool LLVMStartMultithreaded(void);
Duncan Sands1cba0a82013-02-17 16:35:51 +00003015
Chandler Carruth39cd2162014-06-27 15:13:01 +00003016/** Deprecated: Multi-threading can only be enabled/disabled with the compile
3017 time define LLVM_ENABLE_THREADS. */
Benjamin Kramer325ec892013-10-23 16:57:34 +00003018void LLVMStopMultithreaded(void);
Duncan Sands1cba0a82013-02-17 16:35:51 +00003019
3020/** Check whether LLVM is executing in thread-safe mode or not.
3021 @see llvm::llvm_is_multithreaded */
Benjamin Kramer325ec892013-10-23 16:57:34 +00003022LLVMBool LLVMIsMultithreaded(void);
Duncan Sands1cba0a82013-02-17 16:35:51 +00003023
3024/**
3025 * @}
3026 */
3027
3028/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00003029 * @}
3030 */
3031
3032/**
3033 * @}
3034 */
Gordon Henriksen878114b2008-03-16 04:20:44 +00003035
Gordon Henriksen76a03742007-09-18 03:18:57 +00003036#ifdef __cplusplus
3037}
Eugene Zelenkoffec81c2015-11-04 22:32:32 +00003038#endif
Gordon Henriksen7330acd2007-10-05 23:59:36 +00003039
Eugene Zelenkoffec81c2015-11-04 22:32:32 +00003040#endif /* LLVM_C_CORE_H */