blob: 7f5c05d21e650758a07cf73d9456c7e2e3ed71df [file] [log] [blame]
Gordon Henriksen76a03742007-09-18 03:18:57 +00001/*===-- llvm-c/Core.h - Core Library C Interface ------------------*- C -*-===*\
2|* *|
3|* The LLVM Compiler Infrastructure *|
4|* *|
Chris Lattnere9cc7422007-12-29 19:59:42 +00005|* This file is distributed under the University of Illinois Open Source *|
6|* License. See LICENSE.TXT for details. *|
Gordon Henriksen76a03742007-09-18 03:18:57 +00007|* *|
8|*===----------------------------------------------------------------------===*|
9|* *|
10|* This header declares the C interface to libLLVMCore.a, which implements *|
11|* the LLVM intermediate representation. *|
12|* *|
Gordon Henriksen76a03742007-09-18 03:18:57 +000013\*===----------------------------------------------------------------------===*/
14
15#ifndef LLVM_C_CORE_H
16#define LLVM_C_CORE_H
17
Eric Christophera6b96002015-12-18 01:46:52 +000018#include "llvm-c/ErrorHandling.h"
19#include "llvm-c/Types.h"
Erick Tryzelaardd991352009-08-16 23:36:46 +000020
Evan Cheng2e254d02013-04-04 17:40:53 +000021#ifdef __cplusplus
Gordon Henriksen76a03742007-09-18 03:18:57 +000022extern "C" {
23#endif
24
Gregory Szorc34c863a2012-03-21 03:54:29 +000025/**
26 * @defgroup LLVMC LLVM-C: C interface to LLVM
27 *
28 * This module exposes parts of the LLVM library as a C API.
29 *
30 * @{
31 */
32
33/**
34 * @defgroup LLVMCTransforms Transforms
35 */
36
37/**
38 * @defgroup LLVMCCore Core
39 *
40 * This modules provide an interface to libLLVMCore, which implements
41 * the LLVM intermediate representation as well as other related types
42 * and utilities.
43 *
Gregory Szorc34c863a2012-03-21 03:54:29 +000044 * Many exotic languages can interoperate with C code but have a harder time
45 * with C++ due to name mangling. So in addition to C, this interface enables
46 * tools written in such languages.
47 *
Gregory Szorc34c863a2012-03-21 03:54:29 +000048 * @{
49 */
50
51/**
52 * @defgroup LLVMCCoreTypes Types and Enumerations
53 *
54 * @{
55 */
Gordon Henriksen76a03742007-09-18 03:18:57 +000056
Gordon Henriksen76a03742007-09-18 03:18:57 +000057typedef enum {
Bill Wendlingda52cec2010-02-15 20:53:17 +000058 /* Terminator Instructions */
Chris Lattner40cf28d2009-10-12 04:01:02 +000059 LLVMRet = 1,
60 LLVMBr = 2,
61 LLVMSwitch = 3,
Bill Wendling07d6d762010-02-15 20:50:51 +000062 LLVMIndirectBr = 4,
63 LLVMInvoke = 5,
Bill Wendling46ffaa92011-08-02 06:20:17 +000064 /* removed 6 due to API changes */
Bill Wendling2641d132011-07-27 21:00:28 +000065 LLVMUnreachable = 7,
Bill Wendling07d6d762010-02-15 20:50:51 +000066
Bill Wendlingda52cec2010-02-15 20:53:17 +000067 /* Standard Binary Operators */
Bill Wendling2641d132011-07-27 21:00:28 +000068 LLVMAdd = 8,
69 LLVMFAdd = 9,
70 LLVMSub = 10,
71 LLVMFSub = 11,
72 LLVMMul = 12,
73 LLVMFMul = 13,
74 LLVMUDiv = 14,
75 LLVMSDiv = 15,
76 LLVMFDiv = 16,
77 LLVMURem = 17,
78 LLVMSRem = 18,
79 LLVMFRem = 19,
Bill Wendling07d6d762010-02-15 20:50:51 +000080
Bill Wendlingda52cec2010-02-15 20:53:17 +000081 /* Logical Operators */
Bill Wendling2641d132011-07-27 21:00:28 +000082 LLVMShl = 20,
83 LLVMLShr = 21,
84 LLVMAShr = 22,
85 LLVMAnd = 23,
86 LLVMOr = 24,
87 LLVMXor = 25,
Bill Wendling07d6d762010-02-15 20:50:51 +000088
Bill Wendlingda52cec2010-02-15 20:53:17 +000089 /* Memory Operators */
Bill Wendling2641d132011-07-27 21:00:28 +000090 LLVMAlloca = 26,
91 LLVMLoad = 27,
92 LLVMStore = 28,
93 LLVMGetElementPtr = 29,
Bill Wendling07d6d762010-02-15 20:50:51 +000094
Bill Wendlingda52cec2010-02-15 20:53:17 +000095 /* Cast Operators */
Bill Wendling2641d132011-07-27 21:00:28 +000096 LLVMTrunc = 30,
97 LLVMZExt = 31,
98 LLVMSExt = 32,
99 LLVMFPToUI = 33,
100 LLVMFPToSI = 34,
101 LLVMUIToFP = 35,
102 LLVMSIToFP = 36,
103 LLVMFPTrunc = 37,
104 LLVMFPExt = 38,
105 LLVMPtrToInt = 39,
106 LLVMIntToPtr = 40,
107 LLVMBitCast = 41,
Matt Arsenaultb03bd4d2013-11-15 01:34:59 +0000108 LLVMAddrSpaceCast = 60,
Bill Wendling07d6d762010-02-15 20:50:51 +0000109
Bill Wendlingda52cec2010-02-15 20:53:17 +0000110 /* Other Operators */
Bill Wendling2641d132011-07-27 21:00:28 +0000111 LLVMICmp = 42,
112 LLVMFCmp = 43,
113 LLVMPHI = 44,
114 LLVMCall = 45,
115 LLVMSelect = 46,
Torok Edwin05dc9d62011-10-06 12:39:34 +0000116 LLVMUserOp1 = 47,
117 LLVMUserOp2 = 48,
Bill Wendling2641d132011-07-27 21:00:28 +0000118 LLVMVAArg = 49,
119 LLVMExtractElement = 50,
120 LLVMInsertElement = 51,
121 LLVMShuffleVector = 52,
122 LLVMExtractValue = 53,
123 LLVMInsertValue = 54,
Eli Friedman4fc946c2011-07-27 18:59:19 +0000124
125 /* Atomic operators */
Bill Wendling2641d132011-07-27 21:00:28 +0000126 LLVMFence = 55,
Eli Friedmanc9a551e2011-07-28 21:48:00 +0000127 LLVMAtomicCmpXchg = 56,
Bill Wendlingf891bf82011-07-31 06:30:59 +0000128 LLVMAtomicRMW = 57,
129
130 /* Exception Handling Operators */
Bill Wendlingfae14752011-08-12 20:24:12 +0000131 LLVMResume = 58,
David Majnemer654e1302015-07-31 17:58:14 +0000132 LLVMLandingPad = 59,
133 LLVMCleanupRet = 61,
134 LLVMCatchRet = 62,
Joseph Tremoulet9ce71f72015-09-03 09:09:43 +0000135 LLVMCatchPad = 63,
David Majnemerbbfc7212015-12-14 18:34:23 +0000136 LLVMCleanupPad = 64,
137 LLVMCatchSwitch = 65
Chris Lattner40cf28d2009-10-12 04:01:02 +0000138} LLVMOpcode;
139
140typedef enum {
Gordon Henriksen4a4d7352007-12-30 17:46:33 +0000141 LLVMVoidTypeKind, /**< type with no size */
Dan Gohman518cda42011-12-17 00:04:22 +0000142 LLVMHalfTypeKind, /**< 16 bit floating point type */
Gordon Henriksen4a4d7352007-12-30 17:46:33 +0000143 LLVMFloatTypeKind, /**< 32 bit floating point type */
144 LLVMDoubleTypeKind, /**< 64 bit floating point type */
145 LLVMX86_FP80TypeKind, /**< 80 bit floating point type (X87) */
146 LLVMFP128TypeKind, /**< 128 bit floating point type (112-bit mantissa)*/
147 LLVMPPC_FP128TypeKind, /**< 128 bit floating point type (two 64-bits) */
148 LLVMLabelTypeKind, /**< Labels */
149 LLVMIntegerTypeKind, /**< Arbitrary bit width integers */
150 LLVMFunctionTypeKind, /**< Functions */
151 LLVMStructTypeKind, /**< Structures */
152 LLVMArrayTypeKind, /**< Arrays */
153 LLVMPointerTypeKind, /**< Pointers */
Chris Lattnerdac44ec2009-07-15 22:00:31 +0000154 LLVMVectorTypeKind, /**< SIMD 'packed' format, or other vector type */
Dale Johannesenbaa5d042010-09-10 20:55:01 +0000155 LLVMMetadataTypeKind, /**< Metadata */
David Majnemerb611e3f2015-08-14 05:09:07 +0000156 LLVMX86_MMXTypeKind, /**< X86 MMX */
157 LLVMTokenTypeKind /**< Tokens */
Gordon Henriksen76a03742007-09-18 03:18:57 +0000158} LLVMTypeKind;
159
160typedef enum {
Gordon Henriksen4a4d7352007-12-30 17:46:33 +0000161 LLVMExternalLinkage, /**< Externally visible function */
Chris Lattner2dba0f02009-04-13 06:25:37 +0000162 LLVMAvailableExternallyLinkage,
Duncan Sands12da8ce2009-03-07 15:45:40 +0000163 LLVMLinkOnceAnyLinkage, /**< Keep one copy of function when linking (inline)*/
164 LLVMLinkOnceODRLinkage, /**< Same, but only replaced by something
165 equivalent. */
Rafael Espindola716e7402013-11-01 17:09:14 +0000166 LLVMLinkOnceODRAutoHideLinkage, /**< Obsolete */
Duncan Sands12da8ce2009-03-07 15:45:40 +0000167 LLVMWeakAnyLinkage, /**< Keep one copy of function when linking (weak) */
168 LLVMWeakODRLinkage, /**< Same, but only replaced by something
169 equivalent. */
Gordon Henriksen4a4d7352007-12-30 17:46:33 +0000170 LLVMAppendingLinkage, /**< Special purpose, only applies to global arrays */
171 LLVMInternalLinkage, /**< Rename collisions when linking (static
172 functions) */
Duncan Sands12da8ce2009-03-07 15:45:40 +0000173 LLVMPrivateLinkage, /**< Like Internal, but omit from symbol table */
Nico Rieck7157bb72014-01-14 15:22:47 +0000174 LLVMDLLImportLinkage, /**< Obsolete */
175 LLVMDLLExportLinkage, /**< Obsolete */
Duncan Sandse2881052009-03-11 08:08:06 +0000176 LLVMExternalWeakLinkage,/**< ExternalWeak linkage description */
Jeffrey Yasskin091217b2010-01-27 20:34:15 +0000177 LLVMGhostLinkage, /**< Obsolete */
Bill Wendling002b1672009-07-20 18:22:52 +0000178 LLVMCommonLinkage, /**< Tentative definitions */
Bill Wendling03bcd6e2010-07-01 21:55:59 +0000179 LLVMLinkerPrivateLinkage, /**< Like Private, but linker removes. */
Bill Wendling34bc34e2012-08-17 18:33:14 +0000180 LLVMLinkerPrivateWeakLinkage /**< Like LinkerPrivate, but is weak. */
Gordon Henriksen76a03742007-09-18 03:18:57 +0000181} LLVMLinkage;
182
183typedef enum {
Gordon Henriksen4a4d7352007-12-30 17:46:33 +0000184 LLVMDefaultVisibility, /**< The GV is visible */
185 LLVMHiddenVisibility, /**< The GV is hidden */
186 LLVMProtectedVisibility /**< The GV is protected */
Gordon Henriksen76a03742007-09-18 03:18:57 +0000187} LLVMVisibility;
188
Gordon Henriksenc23b66c2007-09-26 20:56:12 +0000189typedef enum {
Reid Kleckner2fae26f2014-03-05 02:34:23 +0000190 LLVMDefaultStorageClass = 0,
191 LLVMDLLImportStorageClass = 1, /**< Function to be imported from DLL. */
192 LLVMDLLExportStorageClass = 2 /**< Function to be accessible from DLL. */
193} LLVMDLLStorageClass;
194
195typedef enum {
Gordon Henriksenc23b66c2007-09-26 20:56:12 +0000196 LLVMCCallConv = 0,
197 LLVMFastCallConv = 8,
198 LLVMColdCallConv = 9,
Filip Pizlodfc9b582013-11-09 06:00:03 +0000199 LLVMWebKitJSCallConv = 12,
200 LLVMAnyRegCallConv = 13,
Gordon Henriksenc23b66c2007-09-26 20:56:12 +0000201 LLVMX86StdcallCallConv = 64,
202 LLVMX86FastcallCallConv = 65
203} LLVMCallConv;
204
205typedef enum {
Peter Zotov3e4561c2016-04-06 22:21:29 +0000206 LLVMArgumentValueKind,
207 LLVMBasicBlockValueKind,
208 LLVMMemoryUseValueKind,
209 LLVMMemoryDefValueKind,
210 LLVMMemoryPhiValueKind,
211
212 LLVMFunctionValueKind,
213 LLVMGlobalAliasValueKind,
Dmitry Polukhina1feff72016-04-07 12:32:19 +0000214 LLVMGlobalIFuncValueKind,
Peter Zotov3e4561c2016-04-06 22:21:29 +0000215 LLVMGlobalVariableValueKind,
216 LLVMBlockAddressValueKind,
217 LLVMConstantExprValueKind,
218 LLVMConstantArrayValueKind,
219 LLVMConstantStructValueKind,
220 LLVMConstantVectorValueKind,
221
222 LLVMUndefValueValueKind,
223 LLVMConstantAggregateZeroValueKind,
224 LLVMConstantDataArrayValueKind,
225 LLVMConstantDataVectorValueKind,
226 LLVMConstantIntValueKind,
227 LLVMConstantFPValueKind,
228 LLVMConstantPointerNullValueKind,
229 LLVMConstantTokenNoneValueKind,
230
231 LLVMMetadataAsValueValueKind,
232 LLVMInlineAsmValueKind,
233
234 LLVMInstructionValueKind,
235} LLVMValueKind;
236
237typedef enum {
Gordon Henriksen4a4d7352007-12-30 17:46:33 +0000238 LLVMIntEQ = 32, /**< equal */
239 LLVMIntNE, /**< not equal */
240 LLVMIntUGT, /**< unsigned greater than */
241 LLVMIntUGE, /**< unsigned greater or equal */
242 LLVMIntULT, /**< unsigned less than */
243 LLVMIntULE, /**< unsigned less or equal */
244 LLVMIntSGT, /**< signed greater than */
245 LLVMIntSGE, /**< signed greater or equal */
246 LLVMIntSLT, /**< signed less than */
247 LLVMIntSLE /**< signed less or equal */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +0000248} LLVMIntPredicate;
249
250typedef enum {
Gordon Henriksen4a4d7352007-12-30 17:46:33 +0000251 LLVMRealPredicateFalse, /**< Always false (always folded) */
252 LLVMRealOEQ, /**< True if ordered and equal */
253 LLVMRealOGT, /**< True if ordered and greater than */
254 LLVMRealOGE, /**< True if ordered and greater than or equal */
255 LLVMRealOLT, /**< True if ordered and less than */
256 LLVMRealOLE, /**< True if ordered and less than or equal */
257 LLVMRealONE, /**< True if ordered and operands are unequal */
258 LLVMRealORD, /**< True if ordered (no nans) */
259 LLVMRealUNO, /**< True if unordered: isnan(X) | isnan(Y) */
260 LLVMRealUEQ, /**< True if unordered or equal */
261 LLVMRealUGT, /**< True if unordered or greater than */
262 LLVMRealUGE, /**< True if unordered, greater than, or equal */
263 LLVMRealULT, /**< True if unordered or less than */
264 LLVMRealULE, /**< True if unordered, less than, or equal */
265 LLVMRealUNE, /**< True if unordered or not equal */
266 LLVMRealPredicateTrue /**< Always true (always folded) */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +0000267} LLVMRealPredicate;
268
Bill Wendlingfae14752011-08-12 20:24:12 +0000269typedef enum {
270 LLVMLandingPadCatch, /**< A catch clause */
271 LLVMLandingPadFilter /**< A filter clause */
272} LLVMLandingPadClauseTy;
273
Hans Wennborg5ff71202013-04-16 08:58:59 +0000274typedef enum {
275 LLVMNotThreadLocal = 0,
276 LLVMGeneralDynamicTLSModel,
277 LLVMLocalDynamicTLSModel,
278 LLVMInitialExecTLSModel,
279 LLVMLocalExecTLSModel
280} LLVMThreadLocalMode;
281
Carlo Kokda0ac722013-04-23 13:45:37 +0000282typedef enum {
Carlo Kok8c6719b2013-04-23 13:21:19 +0000283 LLVMAtomicOrderingNotAtomic = 0, /**< A load or store which is not atomic */
284 LLVMAtomicOrderingUnordered = 1, /**< Lowest level of atomicity, guarantees
285 somewhat sane results, lock free. */
NAKAMURA Takumia3a81352013-10-23 17:56:29 +0000286 LLVMAtomicOrderingMonotonic = 2, /**< guarantees that if you take all the
287 operations affecting a specific address,
Carlo Kok8c6719b2013-04-23 13:21:19 +0000288 a consistent ordering exists */
NAKAMURA Takumia3a81352013-10-23 17:56:29 +0000289 LLVMAtomicOrderingAcquire = 4, /**< Acquire provides a barrier of the sort
290 necessary to acquire a lock to access other
Carlo Kok8c6719b2013-04-23 13:21:19 +0000291 memory with normal loads and stores. */
NAKAMURA Takumia3a81352013-10-23 17:56:29 +0000292 LLVMAtomicOrderingRelease = 5, /**< Release is similar to Acquire, but with
293 a barrier of the sort necessary to release
Carlo Kok8c6719b2013-04-23 13:21:19 +0000294 a lock. */
NAKAMURA Takumia3a81352013-10-23 17:56:29 +0000295 LLVMAtomicOrderingAcquireRelease = 6, /**< provides both an Acquire and a
296 Release barrier (for fences and
Carlo Kok8c6719b2013-04-23 13:21:19 +0000297 operations which both read and write
298 memory). */
NAKAMURA Takumia3a81352013-10-23 17:56:29 +0000299 LLVMAtomicOrderingSequentiallyConsistent = 7 /**< provides Acquire semantics
300 for loads and Release
301 semantics for stores.
302 Additionally, it guarantees
303 that a total ordering exists
304 between all
305 SequentiallyConsistent
Carlo Kok8c6719b2013-04-23 13:21:19 +0000306 operations. */
Carlo Kokda0ac722013-04-23 13:45:37 +0000307} LLVMAtomicOrdering;
Carlo Kok8c6719b2013-04-23 13:21:19 +0000308
Carlo Kokda0ac722013-04-23 13:45:37 +0000309typedef enum {
Carlo Kok8c6719b2013-04-23 13:21:19 +0000310 LLVMAtomicRMWBinOpXchg, /**< Set the new value and return the one old */
311 LLVMAtomicRMWBinOpAdd, /**< Add a value and return the old one */
312 LLVMAtomicRMWBinOpSub, /**< Subtract a value and return the old one */
313 LLVMAtomicRMWBinOpAnd, /**< And a value and return the old one */
314 LLVMAtomicRMWBinOpNand, /**< Not-And a value and return the old one */
315 LLVMAtomicRMWBinOpOr, /**< OR a value and return the old one */
316 LLVMAtomicRMWBinOpXor, /**< Xor a value and return the old one */
317 LLVMAtomicRMWBinOpMax, /**< Sets the value if it's greater than the
NAKAMURA Takumia3a81352013-10-23 17:56:29 +0000318 original using a signed comparison and return
Carlo Kok8c6719b2013-04-23 13:21:19 +0000319 the old one */
320 LLVMAtomicRMWBinOpMin, /**< Sets the value if it's Smaller than the
NAKAMURA Takumia3a81352013-10-23 17:56:29 +0000321 original using a signed comparison and return
Carlo Kok8c6719b2013-04-23 13:21:19 +0000322 the old one */
323 LLVMAtomicRMWBinOpUMax, /**< Sets the value if it's greater than the
NAKAMURA Takumia3a81352013-10-23 17:56:29 +0000324 original using an unsigned comparison and return
Carlo Kok8c6719b2013-04-23 13:21:19 +0000325 the old one */
326 LLVMAtomicRMWBinOpUMin /**< Sets the value if it's greater than the
NAKAMURA Takumia3a81352013-10-23 17:56:29 +0000327 original using an unsigned comparison and return
Carlo Kok8c6719b2013-04-23 13:21:19 +0000328 the old one */
Carlo Kokda0ac722013-04-23 13:45:37 +0000329} LLVMAtomicRMWBinOp;
Carlo Kok8c6719b2013-04-23 13:21:19 +0000330
Tom Stellard1580dc72014-04-16 17:45:04 +0000331typedef enum {
332 LLVMDSError,
333 LLVMDSWarning,
334 LLVMDSRemark,
335 LLVMDSNote
336} LLVMDiagnosticSeverity;
337
Gregory Szorc34c863a2012-03-21 03:54:29 +0000338/**
Amaury Sechet5db224e2016-06-12 06:17:24 +0000339 * Attribute index are either LLVMAttributeReturnIndex,
340 * LLVMAttributeFunctionIndex or a parameter number from 1 to N.
341 */
342enum {
343 LLVMAttributeReturnIndex = 0U,
344 // ISO C restricts enumerator values to range of 'int'
345 // (4294967295 is too large)
346 // LLVMAttributeFunctionIndex = ~0U,
347 LLVMAttributeFunctionIndex = -1,
348};
349
350typedef unsigned LLVMAttributeIndex;
351
352/**
Gregory Szorc34c863a2012-03-21 03:54:29 +0000353 * @}
354 */
355
Nick Lewycky0db26542011-05-15 07:20:34 +0000356void LLVMInitializeCore(LLVMPassRegistryRef R);
357
Duncan Sands1cba0a82013-02-17 16:35:51 +0000358/** Deallocate and destroy all ManagedStatic variables.
359 @see llvm::llvm_shutdown
360 @see ManagedStatic */
Benjamin Kramer325ec892013-10-23 16:57:34 +0000361void LLVMShutdown(void);
Duncan Sands1cba0a82013-02-17 16:35:51 +0000362
Gordon Henriksen34eb6d82007-12-19 22:30:40 +0000363/*===-- Error handling ----------------------------------------------------===*/
364
Filip Pizlo3fdbaff2013-05-22 02:46:43 +0000365char *LLVMCreateMessage(const char *Message);
Gordon Henriksen34eb6d82007-12-19 22:30:40 +0000366void LLVMDisposeMessage(char *Message);
367
Filip Pizlo9f50ccd2013-11-03 00:29:47 +0000368/**
Gregory Szorc34c863a2012-03-21 03:54:29 +0000369 * @defgroup LLVMCCoreContext Contexts
370 *
371 * Contexts are execution states for the core LLVM IR system.
372 *
373 * Most types are tied to a context instance. Multiple contexts can
374 * exist simultaneously. A single context is not thread safe. However,
375 * different contexts can execute on different threads simultaneously.
376 *
377 * @{
378 */
Gordon Henriksen76a03742007-09-18 03:18:57 +0000379
Tom Stellard1580dc72014-04-16 17:45:04 +0000380typedef void (*LLVMDiagnosticHandler)(LLVMDiagnosticInfoRef, void *);
Juergen Ributzka34390c72014-05-16 02:33:15 +0000381typedef void (*LLVMYieldCallback)(LLVMContextRef, void *);
Tom Stellard1580dc72014-04-16 17:45:04 +0000382
Gregory Szorc34c863a2012-03-21 03:54:29 +0000383/**
384 * Create a new context.
385 *
386 * Every call to this function should be paired with a call to
387 * LLVMContextDispose() or the context will leak memory.
388 */
Erick Tryzelaarf34cb0c2009-08-30 23:38:06 +0000389LLVMContextRef LLVMContextCreate(void);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000390
391/**
392 * Obtain the global context instance.
393 */
Erick Tryzelaarf34cb0c2009-08-30 23:38:06 +0000394LLVMContextRef LLVMGetGlobalContext(void);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000395
396/**
Tom Stellard1580dc72014-04-16 17:45:04 +0000397 * Set the diagnostic handler for this context.
398 */
399void LLVMContextSetDiagnosticHandler(LLVMContextRef C,
400 LLVMDiagnosticHandler Handler,
401 void *DiagnosticContext);
402
403/**
Jeroen Ketemaad659c32016-04-08 09:19:02 +0000404 * Get the diagnostic handler of this context.
405 */
406LLVMDiagnosticHandler LLVMContextGetDiagnosticHandler(LLVMContextRef C);
407
408/**
409 * Get the diagnostic context of this context.
410 */
411void *LLVMContextGetDiagnosticContext(LLVMContextRef C);
412
413/**
Juergen Ributzka34390c72014-05-16 02:33:15 +0000414 * Set the yield callback function for this context.
415 *
416 * @see LLVMContext::setYieldCallback()
417 */
418void LLVMContextSetYieldCallback(LLVMContextRef C, LLVMYieldCallback Callback,
419 void *OpaqueHandle);
420
421/**
Gregory Szorc34c863a2012-03-21 03:54:29 +0000422 * Destroy a context instance.
423 *
424 * This should be called for every call to LLVMContextCreate() or memory
425 * will be leaked.
426 */
Owen Anderson6773d382009-07-01 16:58:40 +0000427void LLVMContextDispose(LLVMContextRef C);
428
Tom Stellard1580dc72014-04-16 17:45:04 +0000429/**
430 * Return a string representation of the DiagnosticInfo. Use
431 * LLVMDisposeMessage to free the string.
432 *
433 * @see DiagnosticInfo::print()
434 */
435char *LLVMGetDiagInfoDescription(LLVMDiagnosticInfoRef DI);
436
437/**
438 * Return an enum LLVMDiagnosticSeverity.
439 *
440 * @see DiagnosticInfo::getSeverity()
441 */
442LLVMDiagnosticSeverity LLVMGetDiagInfoSeverity(LLVMDiagnosticInfoRef DI);
443
Amaury Sechet56f056c2016-04-04 22:00:25 +0000444unsigned LLVMGetMDKindIDInContext(LLVMContextRef C, const char *Name,
Erick Tryzelaard8531fa2010-02-28 09:45:59 +0000445 unsigned SLen);
Amaury Sechet56f056c2016-04-04 22:00:25 +0000446unsigned LLVMGetMDKindID(const char *Name, unsigned SLen);
Erick Tryzelaard8531fa2010-02-28 09:45:59 +0000447
Gregory Szorc34c863a2012-03-21 03:54:29 +0000448/**
Amaury Sechet5db224e2016-06-12 06:17:24 +0000449 * Return an unique id given the name of a enum attribute,
Amaury Sechet60b31452016-04-20 01:02:12 +0000450 * or 0 if no attribute by that name exists.
451 *
452 * See http://llvm.org/docs/LangRef.html#parameter-attributes
453 * and http://llvm.org/docs/LangRef.html#function-attributes
454 * for the list of available attributes.
455 *
456 * NB: Attribute names and/or id are subject to change without
457 * going through the C API deprecation cycle.
458 */
Amaury Sechet5db224e2016-06-12 06:17:24 +0000459unsigned LLVMGetEnumAttributeKindForName(const char *Name, size_t SLen);
Amaury Sechet48b06652016-06-12 07:56:21 +0000460unsigned LLVMGetLastEnumAttributeKind(void);
Amaury Sechet5db224e2016-06-12 06:17:24 +0000461
462/**
463 * Create an enum attribute.
464 */
465LLVMAttributeRef LLVMCreateEnumAttribute(LLVMContextRef C, unsigned KindID,
466 uint64_t Val);
467
468/**
469 * Get the unique id corresponding to the enum attribute
470 * passed as argument.
471 */
472unsigned LLVMGetEnumAttributeKind(LLVMAttributeRef A);
473
474/**
475 * Get the enum attribute's value. 0 is returned if none exists.
476 */
477uint64_t LLVMGetEnumAttributeValue(LLVMAttributeRef A);
478
479/**
480 * Create a string attribute.
481 */
482LLVMAttributeRef LLVMCreateStringAttribute(LLVMContextRef C,
483 const char *K, unsigned KLength,
484 const char *V, unsigned VLength);
485
486/**
487 * Get the string attribute's kind.
488 */
489const char *LLVMGetStringAttributeKind(LLVMAttributeRef A, unsigned *Length);
490
491/**
492 * Get the string attribute's value.
493 */
494const char *LLVMGetStringAttributeValue(LLVMAttributeRef A, unsigned *Length);
495
496/**
497 * Check for the different types of attributes.
498 */
499LLVMBool LLVMIsEnumAttribute(LLVMAttributeRef A);
500LLVMBool LLVMIsStringAttribute(LLVMAttributeRef A);
Amaury Sechet60b31452016-04-20 01:02:12 +0000501
502/**
Gregory Szorc34c863a2012-03-21 03:54:29 +0000503 * @}
504 */
505
Gregory Szorc52d26602012-03-21 07:28:27 +0000506/**
507 * @defgroup LLVMCCoreModule Modules
Gregory Szorc34c863a2012-03-21 03:54:29 +0000508 *
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +0000509 * Modules represent the top-level structure in an LLVM program. An LLVM
Gregory Szorc34c863a2012-03-21 03:54:29 +0000510 * module is effectively a translation unit or a collection of
511 * translation units merged together.
512 *
513 * @{
514 */
515
Gregory Szorc34c863a2012-03-21 03:54:29 +0000516/**
517 * Create a new, empty module in the global context.
518 *
519 * This is equivalent to calling LLVMModuleCreateWithNameInContext with
520 * LLVMGetGlobalContext() as the context parameter.
521 *
522 * Every invocation should be paired with LLVMDisposeModule() or memory
523 * will be leaked.
524 */
Gordon Henriksen76a03742007-09-18 03:18:57 +0000525LLVMModuleRef LLVMModuleCreateWithName(const char *ModuleID);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000526
527/**
528 * Create a new, empty module in a specific context.
529 *
530 * Every invocation should be paired with LLVMDisposeModule() or memory
531 * will be leaked.
532 */
Owen Anderson31d44e42009-07-02 07:17:57 +0000533LLVMModuleRef LLVMModuleCreateWithNameInContext(const char *ModuleID,
534 LLVMContextRef C);
Tom Stellard0a4e9a32014-10-01 17:14:57 +0000535/**
536 * Return an exact copy of the specified module.
537 */
538LLVMModuleRef LLVMCloneModule(LLVMModuleRef M);
Gordon Henriksena49d4352008-03-07 19:13:06 +0000539
Gregory Szorc34c863a2012-03-21 03:54:29 +0000540/**
541 * Destroy a module instance.
542 *
543 * This must be called for every created module or memory will be
544 * leaked.
545 */
Gordon Henriksen76a03742007-09-18 03:18:57 +0000546void LLVMDisposeModule(LLVMModuleRef M);
547
Gregory Szorc34c863a2012-03-21 03:54:29 +0000548/**
Peter Zotov0a2fa0a2016-04-05 13:56:59 +0000549 * Obtain the identifier of a module.
550 *
551 * @param M Module to obtain identifier of
552 * @param Len Out parameter which holds the length of the returned string.
553 * @return The identifier of M.
554 * @see Module::getModuleIdentifier()
555 */
556const char *LLVMGetModuleIdentifier(LLVMModuleRef M, size_t *Len);
557
558/**
559 * Set the identifier of a module to a string Ident with length Len.
560 *
561 * @param M The module to set identifier
562 * @param Ident The string to set M's identifier to
563 * @param Len Length of Ident
564 * @see Module::setModuleIdentifier()
565 */
566void LLVMSetModuleIdentifier(LLVMModuleRef M, const char *Ident, size_t Len);
567
568/**
Gregory Szorc34c863a2012-03-21 03:54:29 +0000569 * Obtain the data layout for a module.
570 *
Amaury Sechetf3549c42016-02-16 00:23:52 +0000571 * @see Module::getDataLayoutStr()
572 *
573 * LLVMGetDataLayout is DEPRECATED, as the name is not only incorrect,
574 * but match the name of another method on the module. Prefer the use
575 * of LLVMGetDataLayoutStr, which is not ambiguous.
Gregory Szorc34c863a2012-03-21 03:54:29 +0000576 */
Amaury Sechetf3549c42016-02-16 00:23:52 +0000577const char *LLVMGetDataLayoutStr(LLVMModuleRef M);
Gordon Henriksen05568bb2007-12-27 20:13:47 +0000578const char *LLVMGetDataLayout(LLVMModuleRef M);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000579
580/**
581 * Set the data layout for a module.
582 *
583 * @see Module::setDataLayout()
584 */
Amaury Sechet6ada31c2016-02-15 23:40:06 +0000585void LLVMSetDataLayout(LLVMModuleRef M, const char *DataLayoutStr);
Gordon Henriksen05568bb2007-12-27 20:13:47 +0000586
Gregory Szorc34c863a2012-03-21 03:54:29 +0000587/**
588 * Obtain the target triple for a module.
589 *
590 * @see Module::getTargetTriple()
591 */
Gordon Henriksen05568bb2007-12-27 20:13:47 +0000592const char *LLVMGetTarget(LLVMModuleRef M);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000593
594/**
595 * Set the target triple for a module.
596 *
597 * @see Module::setTargetTriple()
598 */
Gordon Henriksen05568bb2007-12-27 20:13:47 +0000599void LLVMSetTarget(LLVMModuleRef M, const char *Triple);
600
Gregory Szorc34c863a2012-03-21 03:54:29 +0000601/**
602 * Dump a representation of a module to stderr.
603 *
604 * @see Module::dump()
605 */
Gordon Henriksen6c6075e2008-03-14 23:58:56 +0000606void LLVMDumpModule(LLVMModuleRef M);
607
Gregory Szorc34c863a2012-03-21 03:54:29 +0000608/**
Hans Wennborgb7ef2fe2012-05-09 16:54:17 +0000609 * Print a representation of a module to a file. The ErrorMessage needs to be
610 * disposed with LLVMDisposeMessage. Returns 0 on success, 1 otherwise.
611 *
612 * @see Module::print()
613 */
614LLVMBool LLVMPrintModuleToFile(LLVMModuleRef M, const char *Filename,
615 char **ErrorMessage);
616
617/**
Anders Waldenborg84355db2013-10-16 18:00:54 +0000618 * Return a string representation of the module. Use
619 * LLVMDisposeMessage to free the string.
620 *
621 * @see Module::print()
622 */
623char *LLVMPrintModuleToString(LLVMModuleRef M);
624
625/**
Gregory Szorc34c863a2012-03-21 03:54:29 +0000626 * Set inline assembly for a module.
627 *
628 * @see Module::setModuleInlineAsm()
629 */
Chris Lattner26941452010-04-10 17:52:58 +0000630void LLVMSetModuleInlineAsm(LLVMModuleRef M, const char *Asm);
Gordon Henriksen76a03742007-09-18 03:18:57 +0000631
Gregory Szorc34c863a2012-03-21 03:54:29 +0000632/**
633 * Obtain the context to which this module is associated.
634 *
635 * @see Module::getContext()
636 */
Chris Lattnera7e04b02010-11-28 20:03:44 +0000637LLVMContextRef LLVMGetModuleContext(LLVMModuleRef M);
638
Gregory Szorc34c863a2012-03-21 03:54:29 +0000639/**
640 * Obtain a Type from a module by its registered name.
641 */
642LLVMTypeRef LLVMGetTypeByName(LLVMModuleRef M, const char *Name);
Gordon Henriksen76a03742007-09-18 03:18:57 +0000643
Gregory Szorc34c863a2012-03-21 03:54:29 +0000644/**
645 * Obtain the number of operands for named metadata in a module.
646 *
647 * @see llvm::Module::getNamedMetadata()
648 */
Amaury Sechetb130f432016-04-23 00:12:45 +0000649unsigned LLVMGetNamedMetadataNumOperands(LLVMModuleRef M, const char *Name);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000650
651/**
652 * Obtain the named metadata operands for a module.
653 *
654 * The passed LLVMValueRef pointer should refer to an array of
655 * LLVMValueRef at least LLVMGetNamedMetadataNumOperands long. This
656 * array will be populated with the LLVMValueRef instances. Each
657 * instance corresponds to a llvm::MDNode.
658 *
659 * @see llvm::Module::getNamedMetadata()
660 * @see llvm::MDNode::getOperand()
661 */
Amaury Sechetb130f432016-04-23 00:12:45 +0000662void LLVMGetNamedMetadataOperands(LLVMModuleRef M, const char *Name,
663 LLVMValueRef *Dest);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000664
665/**
666 * Add an operand to named metadata.
667 *
668 * @see llvm::Module::getNamedMetadata()
669 * @see llvm::MDNode::addOperand()
670 */
Amaury Sechetb130f432016-04-23 00:12:45 +0000671void LLVMAddNamedMetadataOperand(LLVMModuleRef M, const char *Name,
Gregory Szorc34c863a2012-03-21 03:54:29 +0000672 LLVMValueRef Val);
673
Gregory Szorc52d26602012-03-21 07:28:27 +0000674/**
675 * Add a function to a module under a specified name.
676 *
677 * @see llvm::Function::Create()
678 */
679LLVMValueRef LLVMAddFunction(LLVMModuleRef M, const char *Name,
680 LLVMTypeRef FunctionTy);
681
682/**
683 * Obtain a Function value from a Module by its name.
684 *
685 * The returned value corresponds to a llvm::Function value.
686 *
687 * @see llvm::Module::getFunction()
688 */
689LLVMValueRef LLVMGetNamedFunction(LLVMModuleRef M, const char *Name);
690
691/**
692 * Obtain an iterator to the first Function in a Module.
693 *
694 * @see llvm::Module::begin()
695 */
696LLVMValueRef LLVMGetFirstFunction(LLVMModuleRef M);
697
698/**
699 * Obtain an iterator to the last Function in a Module.
700 *
701 * @see llvm::Module::end()
702 */
703LLVMValueRef LLVMGetLastFunction(LLVMModuleRef M);
704
705/**
706 * Advance a Function iterator to the next Function.
707 *
708 * Returns NULL if the iterator was already at the end and there are no more
709 * functions.
710 */
711LLVMValueRef LLVMGetNextFunction(LLVMValueRef Fn);
712
713/**
714 * Decrement a Function iterator to the previous Function.
715 *
716 * Returns NULL if the iterator was already at the beginning and there are
717 * no previous functions.
718 */
719LLVMValueRef LLVMGetPreviousFunction(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000720
721/**
722 * @}
723 */
724
725/**
726 * @defgroup LLVMCCoreType Types
727 *
728 * Types represent the type of a value.
729 *
730 * Types are associated with a context instance. The context internally
731 * deduplicates types so there is only 1 instance of a specific type
732 * alive at a time. In other words, a unique type is shared among all
733 * consumers within a context.
734 *
735 * A Type in the C API corresponds to llvm::Type.
736 *
737 * Types have the following hierarchy:
738 *
Gordon Henriksen76a03742007-09-18 03:18:57 +0000739 * types:
740 * integer type
741 * real type
742 * function type
743 * sequence types:
744 * array type
745 * pointer type
746 * vector type
747 * void type
748 * label type
749 * opaque type
Gregory Szorc34c863a2012-03-21 03:54:29 +0000750 *
751 * @{
Gordon Henriksen76a03742007-09-18 03:18:57 +0000752 */
753
Gregory Szorc34c863a2012-03-21 03:54:29 +0000754/**
755 * Obtain the enumerated type of a Type instance.
756 *
757 * @see llvm::Type:getTypeID()
758 */
Gordon Henriksen76a03742007-09-18 03:18:57 +0000759LLVMTypeKind LLVMGetTypeKind(LLVMTypeRef Ty);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000760
761/**
762 * Whether the type has a known size.
763 *
764 * Things that don't have a size are abstract types, labels, and void.a
765 *
766 * @see llvm::Type::isSized()
767 */
Torok Edwin1cd9ade2011-10-06 12:13:28 +0000768LLVMBool LLVMTypeIsSized(LLVMTypeRef Ty);
Gordon Henriksena49d4352008-03-07 19:13:06 +0000769
Gregory Szorc34c863a2012-03-21 03:54:29 +0000770/**
771 * Obtain the context to which this type instance is associated.
772 *
773 * @see llvm::Type::getContext()
774 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +0000775LLVMContextRef LLVMGetTypeContext(LLVMTypeRef Ty);
776
Gregory Szorc34c863a2012-03-21 03:54:29 +0000777/**
Anders Waldenborgb822cff2013-10-16 21:30:25 +0000778 * Dump a representation of a type to stderr.
779 *
780 * @see llvm::Type::dump()
781 */
782void LLVMDumpType(LLVMTypeRef Val);
783
784/**
Anders Waldenborg47b3bd32013-10-22 06:58:34 +0000785 * Return a string representation of the type. Use
786 * LLVMDisposeMessage to free the string.
787 *
788 * @see llvm::Type::print()
789 */
790char *LLVMPrintTypeToString(LLVMTypeRef Val);
791
792/**
Gregory Szorc34c863a2012-03-21 03:54:29 +0000793 * @defgroup LLVMCCoreTypeInt Integer Types
794 *
795 * Functions in this section operate on integer types.
796 *
797 * @{
798 */
799
800/**
801 * Obtain an integer type from a context with specified bit width.
802 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +0000803LLVMTypeRef LLVMInt1TypeInContext(LLVMContextRef C);
804LLVMTypeRef LLVMInt8TypeInContext(LLVMContextRef C);
805LLVMTypeRef LLVMInt16TypeInContext(LLVMContextRef C);
806LLVMTypeRef LLVMInt32TypeInContext(LLVMContextRef C);
807LLVMTypeRef LLVMInt64TypeInContext(LLVMContextRef C);
Eugene Zelenkoffec81c2015-11-04 22:32:32 +0000808LLVMTypeRef LLVMInt128TypeInContext(LLVMContextRef C);
Erick Tryzelaar262332f2009-08-14 00:01:31 +0000809LLVMTypeRef LLVMIntTypeInContext(LLVMContextRef C, unsigned NumBits);
810
Gregory Szorc34c863a2012-03-21 03:54:29 +0000811/**
812 * Obtain an integer type from the global context with a specified bit
813 * width.
814 */
Gordon Henriksena735a9c2008-05-04 12:55:34 +0000815LLVMTypeRef LLVMInt1Type(void);
816LLVMTypeRef LLVMInt8Type(void);
817LLVMTypeRef LLVMInt16Type(void);
818LLVMTypeRef LLVMInt32Type(void);
819LLVMTypeRef LLVMInt64Type(void);
Eugene Zelenkoffec81c2015-11-04 22:32:32 +0000820LLVMTypeRef LLVMInt128Type(void);
Gordon Henriksened7beaa2007-10-06 16:05:20 +0000821LLVMTypeRef LLVMIntType(unsigned NumBits);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +0000822unsigned LLVMGetIntTypeWidth(LLVMTypeRef IntegerTy);
Gordon Henriksen76a03742007-09-18 03:18:57 +0000823
Gregory Szorc34c863a2012-03-21 03:54:29 +0000824/**
825 * @}
826 */
827
828/**
829 * @defgroup LLVMCCoreTypeFloat Floating Point Types
830 *
831 * @{
832 */
833
834/**
835 * Obtain a 16-bit floating point type from a context.
836 */
Dan Gohman518cda42011-12-17 00:04:22 +0000837LLVMTypeRef LLVMHalfTypeInContext(LLVMContextRef C);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000838
839/**
840 * Obtain a 32-bit floating point type from a context.
841 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +0000842LLVMTypeRef LLVMFloatTypeInContext(LLVMContextRef C);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000843
844/**
845 * Obtain a 64-bit floating point type from a context.
846 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +0000847LLVMTypeRef LLVMDoubleTypeInContext(LLVMContextRef C);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000848
849/**
850 * Obtain a 80-bit floating point type (X87) from a context.
851 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +0000852LLVMTypeRef LLVMX86FP80TypeInContext(LLVMContextRef C);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000853
854/**
855 * Obtain a 128-bit floating point type (112-bit mantissa) from a
856 * context.
857 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +0000858LLVMTypeRef LLVMFP128TypeInContext(LLVMContextRef C);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000859
860/**
861 * Obtain a 128-bit floating point type (two 64-bits) from a context.
862 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +0000863LLVMTypeRef LLVMPPCFP128TypeInContext(LLVMContextRef C);
864
Gregory Szorc34c863a2012-03-21 03:54:29 +0000865/**
866 * Obtain a floating point type from the global context.
867 *
868 * These map to the functions in this group of the same name.
869 */
Dan Gohman518cda42011-12-17 00:04:22 +0000870LLVMTypeRef LLVMHalfType(void);
Gordon Henriksena735a9c2008-05-04 12:55:34 +0000871LLVMTypeRef LLVMFloatType(void);
872LLVMTypeRef LLVMDoubleType(void);
873LLVMTypeRef LLVMX86FP80Type(void);
874LLVMTypeRef LLVMFP128Type(void);
875LLVMTypeRef LLVMPPCFP128Type(void);
Gordon Henriksen76a03742007-09-18 03:18:57 +0000876
Gregory Szorc34c863a2012-03-21 03:54:29 +0000877/**
878 * @}
879 */
880
881/**
882 * @defgroup LLVMCCoreTypeFunction Function Types
883 *
884 * @{
885 */
886
887/**
888 * Obtain a function type consisting of a specified signature.
889 *
890 * The function is defined as a tuple of a return Type, a list of
891 * parameter types, and whether the function is variadic.
892 */
Gordon Henriksened7beaa2007-10-06 16:05:20 +0000893LLVMTypeRef LLVMFunctionType(LLVMTypeRef ReturnType,
894 LLVMTypeRef *ParamTypes, unsigned ParamCount,
Chris Lattner25963c62010-01-09 22:27:07 +0000895 LLVMBool IsVarArg);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000896
897/**
898 * Returns whether a function type is variadic.
899 */
Chris Lattner25963c62010-01-09 22:27:07 +0000900LLVMBool LLVMIsFunctionVarArg(LLVMTypeRef FunctionTy);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000901
902/**
903 * Obtain the Type this function Type returns.
904 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +0000905LLVMTypeRef LLVMGetReturnType(LLVMTypeRef FunctionTy);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000906
907/**
908 * Obtain the number of parameters this function accepts.
909 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +0000910unsigned LLVMCountParamTypes(LLVMTypeRef FunctionTy);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000911
912/**
913 * Obtain the types of a function's parameters.
914 *
915 * The Dest parameter should point to a pre-allocated array of
916 * LLVMTypeRef at least LLVMCountParamTypes() large. On return, the
917 * first LLVMCountParamTypes() entries in the array will be populated
918 * with LLVMTypeRef instances.
919 *
920 * @param FunctionTy The function type to operate on.
921 * @param Dest Memory address of an array to be filled with result.
922 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +0000923void LLVMGetParamTypes(LLVMTypeRef FunctionTy, LLVMTypeRef *Dest);
Gordon Henriksen76a03742007-09-18 03:18:57 +0000924
Gregory Szorc34c863a2012-03-21 03:54:29 +0000925/**
926 * @}
927 */
928
929/**
930 * @defgroup LLVMCCoreTypeStruct Structure Types
931 *
932 * These functions relate to LLVMTypeRef instances.
933 *
934 * @see llvm::StructType
935 *
936 * @{
937 */
938
939/**
940 * Create a new structure type in a context.
941 *
942 * A structure is specified by a list of inner elements/types and
943 * whether these can be packed together.
944 *
945 * @see llvm::StructType::create()
946 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +0000947LLVMTypeRef LLVMStructTypeInContext(LLVMContextRef C, LLVMTypeRef *ElementTypes,
Chris Lattner25963c62010-01-09 22:27:07 +0000948 unsigned ElementCount, LLVMBool Packed);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000949
950/**
951 * Create a new structure type in the global context.
952 *
953 * @see llvm::StructType::create()
954 */
Gordon Henriksened7beaa2007-10-06 16:05:20 +0000955LLVMTypeRef LLVMStructType(LLVMTypeRef *ElementTypes, unsigned ElementCount,
Chris Lattner25963c62010-01-09 22:27:07 +0000956 LLVMBool Packed);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000957
958/**
959 * Create an empty structure in a context having a specified name.
960 *
961 * @see llvm::StructType::create()
962 */
Chris Lattnere71ccde2011-07-14 05:53:17 +0000963LLVMTypeRef LLVMStructCreateNamed(LLVMContextRef C, const char *Name);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000964
965/**
966 * Obtain the name of a structure.
967 *
968 * @see llvm::StructType::getName()
969 */
Torok Edwin0d5f6ae2011-10-06 12:12:50 +0000970const char *LLVMGetStructName(LLVMTypeRef Ty);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000971
972/**
973 * Set the contents of a structure type.
974 *
975 * @see llvm::StructType::setBody()
976 */
Chris Lattnere71ccde2011-07-14 05:53:17 +0000977void LLVMStructSetBody(LLVMTypeRef StructTy, LLVMTypeRef *ElementTypes,
978 unsigned ElementCount, LLVMBool Packed);
979
Gregory Szorc34c863a2012-03-21 03:54:29 +0000980/**
981 * Get the number of elements defined inside the structure.
982 *
983 * @see llvm::StructType::getNumElements()
984 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +0000985unsigned LLVMCountStructElementTypes(LLVMTypeRef StructTy);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000986
987/**
988 * Get the elements within a structure.
989 *
990 * The function is passed the address of a pre-allocated array of
991 * LLVMTypeRef at least LLVMCountStructElementTypes() long. After
992 * invocation, this array will be populated with the structure's
993 * elements. The objects in the destination array will have a lifetime
994 * of the structure type itself, which is the lifetime of the context it
995 * is contained in.
996 */
Gordon Henriksen76a03742007-09-18 03:18:57 +0000997void LLVMGetStructElementTypes(LLVMTypeRef StructTy, LLVMTypeRef *Dest);
Gregory Szorc34c863a2012-03-21 03:54:29 +0000998
999/**
Peter Zotovc164a3f2015-06-04 09:09:53 +00001000 * Get the type of the element at a given index in the structure.
1001 *
1002 * @see llvm::StructType::getTypeAtIndex()
1003 */
1004LLVMTypeRef LLVMStructGetTypeAtIndex(LLVMTypeRef StructTy, unsigned i);
1005
1006/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00001007 * Determine whether a structure is packed.
1008 *
1009 * @see llvm::StructType::isPacked()
1010 */
Chris Lattner25963c62010-01-09 22:27:07 +00001011LLVMBool LLVMIsPackedStruct(LLVMTypeRef StructTy);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001012
1013/**
1014 * Determine whether a structure is opaque.
1015 *
1016 * @see llvm::StructType::isOpaque()
1017 */
Chris Lattner17cf05b2011-07-14 16:20:28 +00001018LLVMBool LLVMIsOpaqueStruct(LLVMTypeRef StructTy);
1019
Gregory Szorc34c863a2012-03-21 03:54:29 +00001020/**
1021 * @}
1022 */
Gordon Henriksen76a03742007-09-18 03:18:57 +00001023
Gregory Szorc34c863a2012-03-21 03:54:29 +00001024/**
1025 * @defgroup LLVMCCoreTypeSequential Sequential Types
1026 *
1027 * Sequential types represents "arrays" of types. This is a super class
1028 * for array, vector, and pointer types.
1029 *
1030 * @{
1031 */
1032
1033/**
1034 * Obtain the type of elements within a sequential type.
1035 *
1036 * This works on array, vector, and pointer types.
1037 *
1038 * @see llvm::SequentialType::getElementType()
1039 */
1040LLVMTypeRef LLVMGetElementType(LLVMTypeRef Ty);
1041
1042/**
1043 * Create a fixed size array type that refers to a specific type.
1044 *
1045 * The created type will exist in the context that its element type
1046 * exists in.
1047 *
1048 * @see llvm::ArrayType::get()
1049 */
Gordon Henriksened7beaa2007-10-06 16:05:20 +00001050LLVMTypeRef LLVMArrayType(LLVMTypeRef ElementType, unsigned ElementCount);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001051
1052/**
1053 * Obtain the length of an array type.
1054 *
1055 * This only works on types that represent arrays.
1056 *
1057 * @see llvm::ArrayType::getNumElements()
1058 */
1059unsigned LLVMGetArrayLength(LLVMTypeRef ArrayTy);
1060
1061/**
1062 * Create a pointer type that points to a defined type.
1063 *
1064 * The created type will exist in the context that its pointee type
1065 * exists in.
1066 *
1067 * @see llvm::PointerType::get()
1068 */
Gordon Henriksen5a3fe032007-12-17 16:08:32 +00001069LLVMTypeRef LLVMPointerType(LLVMTypeRef ElementType, unsigned AddressSpace);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001070
1071/**
1072 * Obtain the address space of a pointer type.
1073 *
1074 * This only works on types that represent pointers.
1075 *
1076 * @see llvm::PointerType::getAddressSpace()
1077 */
1078unsigned LLVMGetPointerAddressSpace(LLVMTypeRef PointerTy);
1079
1080/**
1081 * Create a vector type that contains a defined type and has a specific
1082 * number of elements.
1083 *
1084 * The created type will exist in the context thats its element type
1085 * exists in.
1086 *
1087 * @see llvm::VectorType::get()
1088 */
Gordon Henriksened7beaa2007-10-06 16:05:20 +00001089LLVMTypeRef LLVMVectorType(LLVMTypeRef ElementType, unsigned ElementCount);
Gordon Henriksen76a03742007-09-18 03:18:57 +00001090
Gregory Szorc34c863a2012-03-21 03:54:29 +00001091/**
1092 * Obtain the number of elements in a vector type.
1093 *
1094 * This only works on types that represent vectors.
1095 *
1096 * @see llvm::VectorType::getNumElements()
1097 */
Gordon Henriksen76a03742007-09-18 03:18:57 +00001098unsigned LLVMGetVectorSize(LLVMTypeRef VectorTy);
1099
Gregory Szorc34c863a2012-03-21 03:54:29 +00001100/**
1101 * @}
1102 */
1103
1104/**
1105 * @defgroup LLVMCCoreTypeOther Other Types
1106 *
1107 * @{
1108 */
1109
1110/**
1111 * Create a void type in a context.
1112 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +00001113LLVMTypeRef LLVMVoidTypeInContext(LLVMContextRef C);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001114
1115/**
1116 * Create a label type in a context.
1117 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +00001118LLVMTypeRef LLVMLabelTypeInContext(LLVMContextRef C);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001119
1120/**
1121 * Create a X86 MMX type in a context.
1122 */
Dale Johannesen95b67af2010-09-10 21:58:02 +00001123LLVMTypeRef LLVMX86MMXTypeInContext(LLVMContextRef C);
Erick Tryzelaar262332f2009-08-14 00:01:31 +00001124
Gregory Szorc34c863a2012-03-21 03:54:29 +00001125/**
1126 * These are similar to the above functions except they operate on the
1127 * global context.
1128 */
Gordon Henriksena735a9c2008-05-04 12:55:34 +00001129LLVMTypeRef LLVMVoidType(void);
1130LLVMTypeRef LLVMLabelType(void);
Dale Johannesen95b67af2010-09-10 21:58:02 +00001131LLVMTypeRef LLVMX86MMXType(void);
Gordon Henriksen76a03742007-09-18 03:18:57 +00001132
Gregory Szorc34c863a2012-03-21 03:54:29 +00001133/**
1134 * @}
1135 */
Gordon Henriksen76a03742007-09-18 03:18:57 +00001136
Gregory Szorc34c863a2012-03-21 03:54:29 +00001137/**
1138 * @}
1139 */
1140
1141/**
1142 * @defgroup LLVMCCoreValues Values
1143 *
1144 * The bulk of LLVM's object model consists of values, which comprise a very
Gordon Henriksen76a03742007-09-18 03:18:57 +00001145 * rich type hierarchy.
Gregory Szorc34c863a2012-03-21 03:54:29 +00001146 *
1147 * LLVMValueRef essentially represents llvm::Value. There is a rich
1148 * hierarchy of classes within this type. Depending on the instance
Eli Benderskyc52863c2012-08-10 18:30:44 +00001149 * obtained, not all APIs are available.
Gregory Szorc34c863a2012-03-21 03:54:29 +00001150 *
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00001151 * Callers can determine the type of an LLVMValueRef by calling the
Gregory Szorc34c863a2012-03-21 03:54:29 +00001152 * LLVMIsA* family of functions (e.g. LLVMIsAArgument()). These
1153 * functions are defined by a macro, so it isn't obvious which are
1154 * available by looking at the Doxygen source code. Instead, look at the
1155 * source definition of LLVM_FOR_EACH_VALUE_SUBCLASS and note the list
1156 * of value names given. These value names also correspond to classes in
1157 * the llvm::Value hierarchy.
1158 *
1159 * @{
Gordon Henriksen76a03742007-09-18 03:18:57 +00001160 */
1161
Gordon Henriksen29e38942008-12-19 18:39:45 +00001162#define LLVM_FOR_EACH_VALUE_SUBCLASS(macro) \
1163 macro(Argument) \
1164 macro(BasicBlock) \
1165 macro(InlineAsm) \
1166 macro(User) \
1167 macro(Constant) \
Torok Edwind09b7572011-10-14 20:37:56 +00001168 macro(BlockAddress) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001169 macro(ConstantAggregateZero) \
1170 macro(ConstantArray) \
Peter Zotovae0344b2013-11-05 12:55:37 +00001171 macro(ConstantDataSequential) \
1172 macro(ConstantDataArray) \
1173 macro(ConstantDataVector) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001174 macro(ConstantExpr) \
1175 macro(ConstantFP) \
1176 macro(ConstantInt) \
1177 macro(ConstantPointerNull) \
1178 macro(ConstantStruct) \
David Majnemerf0f224d2015-11-11 21:57:16 +00001179 macro(ConstantTokenNone) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001180 macro(ConstantVector) \
1181 macro(GlobalValue) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001182 macro(GlobalAlias) \
Rafael Espindola99e05cf2014-05-13 18:45:48 +00001183 macro(GlobalObject) \
1184 macro(Function) \
1185 macro(GlobalVariable) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001186 macro(UndefValue) \
1187 macro(Instruction) \
1188 macro(BinaryOperator) \
1189 macro(CallInst) \
1190 macro(IntrinsicInst) \
1191 macro(DbgInfoIntrinsic) \
1192 macro(DbgDeclareInst) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001193 macro(MemIntrinsic) \
1194 macro(MemCpyInst) \
1195 macro(MemMoveInst) \
1196 macro(MemSetInst) \
1197 macro(CmpInst) \
Torok Edwind09b7572011-10-14 20:37:56 +00001198 macro(FCmpInst) \
1199 macro(ICmpInst) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001200 macro(ExtractElementInst) \
1201 macro(GetElementPtrInst) \
1202 macro(InsertElementInst) \
1203 macro(InsertValueInst) \
Bill Wendlingfae14752011-08-12 20:24:12 +00001204 macro(LandingPadInst) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001205 macro(PHINode) \
1206 macro(SelectInst) \
1207 macro(ShuffleVectorInst) \
1208 macro(StoreInst) \
1209 macro(TerminatorInst) \
1210 macro(BranchInst) \
Torok Edwind09b7572011-10-14 20:37:56 +00001211 macro(IndirectBrInst) \
Gordon Henriksen29e38942008-12-19 18:39:45 +00001212 macro(InvokeInst) \
1213 macro(ReturnInst) \
1214 macro(SwitchInst) \
1215 macro(UnreachableInst) \
Bill Wendlingf891bf82011-07-31 06:30:59 +00001216 macro(ResumeInst) \
David Majnemer654e1302015-07-31 17:58:14 +00001217 macro(CleanupReturnInst) \
1218 macro(CatchReturnInst) \
David Majnemer8a1c45d2015-12-12 05:38:55 +00001219 macro(FuncletPadInst) \
1220 macro(CatchPadInst) \
1221 macro(CleanupPadInst) \
Duncan Sands5e37e992013-05-06 08:55:45 +00001222 macro(UnaryInstruction) \
1223 macro(AllocaInst) \
1224 macro(CastInst) \
Matt Arsenaultb03bd4d2013-11-15 01:34:59 +00001225 macro(AddrSpaceCastInst) \
Duncan Sands5e37e992013-05-06 08:55:45 +00001226 macro(BitCastInst) \
1227 macro(FPExtInst) \
1228 macro(FPToSIInst) \
1229 macro(FPToUIInst) \
1230 macro(FPTruncInst) \
1231 macro(IntToPtrInst) \
1232 macro(PtrToIntInst) \
1233 macro(SExtInst) \
1234 macro(SIToFPInst) \
1235 macro(TruncInst) \
1236 macro(UIToFPInst) \
1237 macro(ZExtInst) \
1238 macro(ExtractValueInst) \
1239 macro(LoadInst) \
1240 macro(VAArgInst)
Gordon Henriksen29e38942008-12-19 18:39:45 +00001241
Gregory Szorc34c863a2012-03-21 03:54:29 +00001242/**
1243 * @defgroup LLVMCCoreValueGeneral General APIs
1244 *
1245 * Functions in this section work on all LLVMValueRef instances,
1246 * regardless of their sub-type. They correspond to functions available
1247 * on llvm::Value.
1248 *
1249 * @{
1250 */
Gordon Henriksen76a03742007-09-18 03:18:57 +00001251
Gregory Szorc34c863a2012-03-21 03:54:29 +00001252/**
1253 * Obtain the type of a value.
1254 *
1255 * @see llvm::Value::getType()
1256 */
1257LLVMTypeRef LLVMTypeOf(LLVMValueRef Val);
1258
1259/**
Peter Zotov3e4561c2016-04-06 22:21:29 +00001260 * Obtain the enumerated type of a Value instance.
1261 *
1262 * @see llvm::Value::getValueID()
1263 */
1264LLVMValueKind LLVMGetValueKind(LLVMValueRef Val);
1265
1266/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00001267 * Obtain the string name of a value.
1268 *
1269 * @see llvm::Value::getName()
1270 */
1271const char *LLVMGetValueName(LLVMValueRef Val);
1272
1273/**
1274 * Set the string name of a value.
1275 *
1276 * @see llvm::Value::setName()
1277 */
1278void LLVMSetValueName(LLVMValueRef Val, const char *Name);
1279
1280/**
1281 * Dump a representation of a value to stderr.
1282 *
1283 * @see llvm::Value::dump()
1284 */
1285void LLVMDumpValue(LLVMValueRef Val);
1286
1287/**
Peter Zotovcd93b372013-11-06 09:21:01 +00001288 * Return a string representation of the value. Use
1289 * LLVMDisposeMessage to free the string.
1290 *
1291 * @see llvm::Value::print()
1292 */
1293char *LLVMPrintValueToString(LLVMValueRef Val);
1294
1295/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00001296 * Replace all uses of a value with another one.
1297 *
1298 * @see llvm::Value::replaceAllUsesWith()
1299 */
1300void LLVMReplaceAllUsesWith(LLVMValueRef OldVal, LLVMValueRef NewVal);
1301
1302/**
Amaury Sechet1c395072016-01-18 01:06:52 +00001303 * Determine whether the specified value instance is constant.
Gregory Szorc34c863a2012-03-21 03:54:29 +00001304 */
1305LLVMBool LLVMIsConstant(LLVMValueRef Val);
1306
1307/**
1308 * Determine whether a value instance is undefined.
1309 */
1310LLVMBool LLVMIsUndef(LLVMValueRef Val);
1311
1312/**
1313 * Convert value instances between types.
1314 *
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00001315 * Internally, an LLVMValueRef is "pinned" to a specific type. This
Gregory Szorc34c863a2012-03-21 03:54:29 +00001316 * series of functions allows you to cast an instance to a specific
1317 * type.
1318 *
1319 * If the cast is not valid for the specified type, NULL is returned.
1320 *
1321 * @see llvm::dyn_cast_or_null<>
1322 */
Gordon Henriksen29e38942008-12-19 18:39:45 +00001323#define LLVM_DECLARE_VALUE_CAST(name) \
1324 LLVMValueRef LLVMIsA##name(LLVMValueRef Val);
1325LLVM_FOR_EACH_VALUE_SUBCLASS(LLVM_DECLARE_VALUE_CAST)
1326
Duncan P. N. Exon Smith5bf8fef2014-12-09 18:38:53 +00001327LLVMValueRef LLVMIsAMDNode(LLVMValueRef Val);
1328LLVMValueRef LLVMIsAMDString(LLVMValueRef Val);
1329
Gregory Szorc34c863a2012-03-21 03:54:29 +00001330/**
1331 * @}
1332 */
1333
1334/**
1335 * @defgroup LLVMCCoreValueUses Usage
1336 *
1337 * This module defines functions that allow you to inspect the uses of a
1338 * LLVMValueRef.
1339 *
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00001340 * It is possible to obtain an LLVMUseRef for any LLVMValueRef instance.
Gregory Szorc34c863a2012-03-21 03:54:29 +00001341 * Each LLVMUseRef (which corresponds to a llvm::Use instance) holds a
1342 * llvm::User and llvm::Value.
1343 *
1344 * @{
1345 */
1346
1347/**
1348 * Obtain the first use of a value.
1349 *
1350 * Uses are obtained in an iterator fashion. First, call this function
1351 * to obtain a reference to the first use. Then, call LLVMGetNextUse()
Eli Benderskyc52863c2012-08-10 18:30:44 +00001352 * on that instance and all subsequently obtained instances until
Gregory Szorc34c863a2012-03-21 03:54:29 +00001353 * LLVMGetNextUse() returns NULL.
1354 *
1355 * @see llvm::Value::use_begin()
1356 */
Erick Tryzelaar9f9857e2010-03-02 20:32:28 +00001357LLVMUseRef LLVMGetFirstUse(LLVMValueRef Val);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001358
1359/**
1360 * Obtain the next use of a value.
1361 *
1362 * This effectively advances the iterator. It returns NULL if you are on
1363 * the final use and no more are available.
1364 */
Erick Tryzelaar9f9857e2010-03-02 20:32:28 +00001365LLVMUseRef LLVMGetNextUse(LLVMUseRef U);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001366
1367/**
1368 * Obtain the user value for a user.
1369 *
1370 * The returned value corresponds to a llvm::User type.
1371 *
1372 * @see llvm::Use::getUser()
1373 */
Erick Tryzelaar9f9857e2010-03-02 20:32:28 +00001374LLVMValueRef LLVMGetUser(LLVMUseRef U);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001375
1376/**
1377 * Obtain the value this use corresponds to.
1378 *
1379 * @see llvm::Use::get().
1380 */
Erick Tryzelaar9f9857e2010-03-02 20:32:28 +00001381LLVMValueRef LLVMGetUsedValue(LLVMUseRef U);
Chris Lattner40cf28d2009-10-12 04:01:02 +00001382
Gregory Szorc34c863a2012-03-21 03:54:29 +00001383/**
1384 * @}
1385 */
1386
1387/**
Gregory Szorc52d26602012-03-21 07:28:27 +00001388 * @defgroup LLVMCCoreValueUser User value
Gregory Szorc34c863a2012-03-21 03:54:29 +00001389 *
1390 * Function in this group pertain to LLVMValueRef instances that descent
1391 * from llvm::User. This includes constants, instructions, and
1392 * operators.
1393 *
1394 * @{
1395 */
1396
1397/**
1398 * Obtain an operand at a specific index in a llvm::User value.
1399 *
1400 * @see llvm::User::getOperand()
1401 */
Chris Lattner40cf28d2009-10-12 04:01:02 +00001402LLVMValueRef LLVMGetOperand(LLVMValueRef Val, unsigned Index);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001403
1404/**
Peter Zotovb19f78f2014-08-12 02:55:40 +00001405 * Obtain the use of an operand at a specific index in a llvm::User value.
1406 *
1407 * @see llvm::User::getOperandUse()
1408 */
1409LLVMUseRef LLVMGetOperandUse(LLVMValueRef Val, unsigned Index);
1410
1411/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00001412 * Set an operand at a specific index in a llvm::User value.
1413 *
1414 * @see llvm::User::setOperand()
1415 */
Erick Tryzelaarb4d48702010-08-20 14:51:22 +00001416void LLVMSetOperand(LLVMValueRef User, unsigned Index, LLVMValueRef Val);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001417
1418/**
1419 * Obtain the number of operands in a llvm::User value.
1420 *
1421 * @see llvm::User::getNumOperands()
1422 */
Erick Tryzelaarb4d48702010-08-20 14:51:22 +00001423int LLVMGetNumOperands(LLVMValueRef Val);
Chris Lattner40cf28d2009-10-12 04:01:02 +00001424
Gregory Szorc34c863a2012-03-21 03:54:29 +00001425/**
1426 * @}
1427 */
1428
1429/**
Gregory Szorc52d26602012-03-21 07:28:27 +00001430 * @defgroup LLVMCCoreValueConstant Constants
Gregory Szorc34c863a2012-03-21 03:54:29 +00001431 *
1432 * This section contains APIs for interacting with LLVMValueRef that
1433 * correspond to llvm::Constant instances.
1434 *
1435 * These functions will work for any LLVMValueRef in the llvm::Constant
1436 * class hierarchy.
1437 *
1438 * @{
1439 */
1440
1441/**
1442 * Obtain a constant value referring to the null instance of a type.
1443 *
1444 * @see llvm::Constant::getNullValue()
1445 */
Gordon Henriksen1046c732007-10-06 15:11:06 +00001446LLVMValueRef LLVMConstNull(LLVMTypeRef Ty); /* all zeroes */
Gregory Szorc34c863a2012-03-21 03:54:29 +00001447
1448/**
1449 * Obtain a constant value referring to the instance of a type
1450 * consisting of all ones.
1451 *
1452 * This is only valid for integer types.
1453 *
1454 * @see llvm::Constant::getAllOnesValue()
1455 */
1456LLVMValueRef LLVMConstAllOnes(LLVMTypeRef Ty);
1457
1458/**
1459 * Obtain a constant value referring to an undefined value of a type.
1460 *
1461 * @see llvm::UndefValue::get()
1462 */
Gordon Henriksen76a03742007-09-18 03:18:57 +00001463LLVMValueRef LLVMGetUndef(LLVMTypeRef Ty);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001464
1465/**
1466 * Determine whether a value instance is null.
1467 *
1468 * @see llvm::Constant::isNullValue()
1469 */
Chris Lattner25963c62010-01-09 22:27:07 +00001470LLVMBool LLVMIsNull(LLVMValueRef Val);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001471
1472/**
1473 * Obtain a constant that is a constant pointer pointing to NULL for a
1474 * specified type.
1475 */
Chris Lattner7f318242009-07-06 17:29:59 +00001476LLVMValueRef LLVMConstPointerNull(LLVMTypeRef Ty);
Gordon Henriksen76a03742007-09-18 03:18:57 +00001477
Gregory Szorc34c863a2012-03-21 03:54:29 +00001478/**
1479 * @defgroup LLVMCCoreValueConstantScalar Scalar constants
1480 *
1481 * Functions in this group model LLVMValueRef instances that correspond
1482 * to constants referring to scalar types.
1483 *
1484 * For integer types, the LLVMTypeRef parameter should correspond to a
1485 * llvm::IntegerType instance and the returned LLVMValueRef will
1486 * correspond to a llvm::ConstantInt.
1487 *
1488 * For floating point types, the LLVMTypeRef returned corresponds to a
1489 * llvm::ConstantFP.
1490 *
1491 * @{
1492 */
Erick Tryzelaard8531fa2010-02-28 09:45:59 +00001493
Gregory Szorc34c863a2012-03-21 03:54:29 +00001494/**
1495 * Obtain a constant value for an integer type.
1496 *
1497 * The returned value corresponds to a llvm::ConstantInt.
1498 *
1499 * @see llvm::ConstantInt::get()
1500 *
1501 * @param IntTy Integer type to obtain value of.
1502 * @param N The value the returned instance should refer to.
1503 * @param SignExtend Whether to sign extend the produced value.
1504 */
Gordon Henriksen1046c732007-10-06 15:11:06 +00001505LLVMValueRef LLVMConstInt(LLVMTypeRef IntTy, unsigned long long N,
Chris Lattner25963c62010-01-09 22:27:07 +00001506 LLVMBool SignExtend);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001507
1508/**
1509 * Obtain a constant value for an integer of arbitrary precision.
1510 *
1511 * @see llvm::ConstantInt::get()
1512 */
Chris Lattner4329e072010-11-23 02:47:22 +00001513LLVMValueRef LLVMConstIntOfArbitraryPrecision(LLVMTypeRef IntTy,
1514 unsigned NumWords,
1515 const uint64_t Words[]);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001516
1517/**
1518 * Obtain a constant value for an integer parsed from a string.
1519 *
1520 * A similar API, LLVMConstIntOfStringAndSize is also available. If the
1521 * string's length is available, it is preferred to call that function
1522 * instead.
1523 *
1524 * @see llvm::ConstantInt::get()
1525 */
Erick Tryzelaardd991352009-08-16 23:36:46 +00001526LLVMValueRef LLVMConstIntOfString(LLVMTypeRef IntTy, const char *Text,
1527 uint8_t Radix);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001528
1529/**
1530 * Obtain a constant value for an integer parsed from a string with
1531 * specified length.
1532 *
1533 * @see llvm::ConstantInt::get()
1534 */
Erick Tryzelaardd991352009-08-16 23:36:46 +00001535LLVMValueRef LLVMConstIntOfStringAndSize(LLVMTypeRef IntTy, const char *Text,
1536 unsigned SLen, uint8_t Radix);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001537
1538/**
1539 * Obtain a constant value referring to a double floating point value.
1540 */
Gordon Henriksen1046c732007-10-06 15:11:06 +00001541LLVMValueRef LLVMConstReal(LLVMTypeRef RealTy, double N);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001542
1543/**
1544 * Obtain a constant for a floating point value parsed from a string.
1545 *
1546 * A similar API, LLVMConstRealOfStringAndSize is also available. It
1547 * should be used if the input string's length is known.
1548 */
Gordon Henriksen931e1212008-02-02 01:07:50 +00001549LLVMValueRef LLVMConstRealOfString(LLVMTypeRef RealTy, const char *Text);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001550
1551/**
1552 * Obtain a constant for a floating point value parsed from a string.
1553 */
Erick Tryzelaardd991352009-08-16 23:36:46 +00001554LLVMValueRef LLVMConstRealOfStringAndSize(LLVMTypeRef RealTy, const char *Text,
1555 unsigned SLen);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001556
1557/**
1558 * Obtain the zero extended value for an integer constant value.
1559 *
1560 * @see llvm::ConstantInt::getZExtValue()
1561 */
Chris Lattner40cf28d2009-10-12 04:01:02 +00001562unsigned long long LLVMConstIntGetZExtValue(LLVMValueRef ConstantVal);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001563
1564/**
1565 * Obtain the sign extended value for an integer constant value.
1566 *
1567 * @see llvm::ConstantInt::getSExtValue()
1568 */
Chris Lattner40cf28d2009-10-12 04:01:02 +00001569long long LLVMConstIntGetSExtValue(LLVMValueRef ConstantVal);
Erick Tryzelaardd991352009-08-16 23:36:46 +00001570
Gregory Szorc34c863a2012-03-21 03:54:29 +00001571/**
Peter Zotov1d98e6d2014-10-28 19:46:44 +00001572 * Obtain the double value for an floating point constant value.
1573 * losesInfo indicates if some precision was lost in the conversion.
1574 *
1575 * @see llvm::ConstantFP::getDoubleValue
1576 */
1577double LLVMConstRealGetDouble(LLVMValueRef ConstantVal, LLVMBool *losesInfo);
1578
1579/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00001580 * @}
1581 */
1582
1583/**
Gregory Szorc52d26602012-03-21 07:28:27 +00001584 * @defgroup LLVMCCoreValueConstantComposite Composite Constants
1585 *
1586 * Functions in this group operate on composite constants.
Gregory Szorc34c863a2012-03-21 03:54:29 +00001587 *
1588 * @{
1589 */
1590
1591/**
Gregory Szorc52d26602012-03-21 07:28:27 +00001592 * Create a ConstantDataSequential and initialize it with a string.
Gregory Szorc34c863a2012-03-21 03:54:29 +00001593 *
Gregory Szorc52d26602012-03-21 07:28:27 +00001594 * @see llvm::ConstantDataArray::getString()
Gregory Szorc34c863a2012-03-21 03:54:29 +00001595 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +00001596LLVMValueRef LLVMConstStringInContext(LLVMContextRef C, const char *Str,
Chris Lattner25963c62010-01-09 22:27:07 +00001597 unsigned Length, LLVMBool DontNullTerminate);
Gregory Szorc52d26602012-03-21 07:28:27 +00001598
1599/**
1600 * Create a ConstantDataSequential with string content in the global context.
1601 *
1602 * This is the same as LLVMConstStringInContext except it operates on the
1603 * global context.
1604 *
1605 * @see LLVMConstStringInContext()
1606 * @see llvm::ConstantDataArray::getString()
1607 */
1608LLVMValueRef LLVMConstString(const char *Str, unsigned Length,
1609 LLVMBool DontNullTerminate);
1610
1611/**
Peter Zotovf9aa8822014-08-03 23:54:16 +00001612 * Returns true if the specified constant is an array of i8.
1613 *
1614 * @see ConstantDataSequential::getAsString()
1615 */
1616LLVMBool LLVMIsConstantString(LLVMValueRef c);
1617
1618/**
1619 * Get the given constant data sequential as a string.
1620 *
1621 * @see ConstantDataSequential::getAsString()
1622 */
Amaury Sechet7c2883c2016-04-03 21:06:04 +00001623const char *LLVMGetAsString(LLVMValueRef c, size_t *Length);
Peter Zotovf9aa8822014-08-03 23:54:16 +00001624
1625/**
Gregory Szorc52d26602012-03-21 07:28:27 +00001626 * Create an anonymous ConstantStruct with the specified values.
1627 *
1628 * @see llvm::ConstantStruct::getAnon()
1629 */
1630LLVMValueRef LLVMConstStructInContext(LLVMContextRef C,
Erick Tryzelaar262332f2009-08-14 00:01:31 +00001631 LLVMValueRef *ConstantVals,
Chris Lattner25963c62010-01-09 22:27:07 +00001632 unsigned Count, LLVMBool Packed);
Erick Tryzelaar262332f2009-08-14 00:01:31 +00001633
Gregory Szorc52d26602012-03-21 07:28:27 +00001634/**
1635 * Create a ConstantStruct in the global Context.
1636 *
1637 * This is the same as LLVMConstStructInContext except it operates on the
1638 * global Context.
1639 *
1640 * @see LLVMConstStructInContext()
1641 */
Gordon Henriksen1046c732007-10-06 15:11:06 +00001642LLVMValueRef LLVMConstStruct(LLVMValueRef *ConstantVals, unsigned Count,
Chris Lattner25963c62010-01-09 22:27:07 +00001643 LLVMBool Packed);
Gregory Szorc52d26602012-03-21 07:28:27 +00001644
1645/**
1646 * Create a ConstantArray from values.
1647 *
1648 * @see llvm::ConstantArray::get()
1649 */
1650LLVMValueRef LLVMConstArray(LLVMTypeRef ElementTy,
1651 LLVMValueRef *ConstantVals, unsigned Length);
1652
1653/**
1654 * Create a non-anonymous ConstantStruct from values.
1655 *
1656 * @see llvm::ConstantStruct::get()
1657 */
Rafael Espindola784ad242011-07-14 19:09:08 +00001658LLVMValueRef LLVMConstNamedStruct(LLVMTypeRef StructTy,
1659 LLVMValueRef *ConstantVals,
1660 unsigned Count);
Gregory Szorc52d26602012-03-21 07:28:27 +00001661
1662/**
Peter Zotovf9aa8822014-08-03 23:54:16 +00001663 * Get an element at specified index as a constant.
1664 *
1665 * @see ConstantDataSequential::getElementAsConstant()
1666 */
Amaury Sechet006ce632016-03-13 00:54:40 +00001667LLVMValueRef LLVMGetElementAsConstant(LLVMValueRef C, unsigned idx);
Peter Zotovf9aa8822014-08-03 23:54:16 +00001668
1669/**
Gregory Szorc52d26602012-03-21 07:28:27 +00001670 * Create a ConstantVector from values.
1671 *
1672 * @see llvm::ConstantVector::get()
1673 */
Gordon Henriksen1046c732007-10-06 15:11:06 +00001674LLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals, unsigned Size);
Gordon Henriksen76a03742007-09-18 03:18:57 +00001675
Gregory Szorc52d26602012-03-21 07:28:27 +00001676/**
1677 * @}
1678 */
1679
1680/**
1681 * @defgroup LLVMCCoreValueConstantExpressions Constant Expressions
1682 *
1683 * Functions in this group correspond to APIs on llvm::ConstantExpr.
1684 *
1685 * @see llvm::ConstantExpr.
1686 *
1687 * @{
1688 */
Chris Lattner40cf28d2009-10-12 04:01:02 +00001689LLVMOpcode LLVMGetConstOpcode(LLVMValueRef ConstantVal);
Erick Tryzelaarfd529d72009-08-19 08:36:49 +00001690LLVMValueRef LLVMAlignOf(LLVMTypeRef Ty);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001691LLVMValueRef LLVMSizeOf(LLVMTypeRef Ty);
1692LLVMValueRef LLVMConstNeg(LLVMValueRef ConstantVal);
Erick Tryzelaar4c340c72010-02-28 05:51:43 +00001693LLVMValueRef LLVMConstNSWNeg(LLVMValueRef ConstantVal);
1694LLVMValueRef LLVMConstNUWNeg(LLVMValueRef ConstantVal);
Erick Tryzelaar4cc690c2009-08-16 02:20:12 +00001695LLVMValueRef LLVMConstFNeg(LLVMValueRef ConstantVal);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001696LLVMValueRef LLVMConstNot(LLVMValueRef ConstantVal);
1697LLVMValueRef LLVMConstAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Dan Gohmane4ca02d2009-09-03 23:34:49 +00001698LLVMValueRef LLVMConstNSWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Erick Tryzelaar4c340c72010-02-28 05:51:43 +00001699LLVMValueRef LLVMConstNUWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Erick Tryzelaar4cc690c2009-08-16 02:20:12 +00001700LLVMValueRef LLVMConstFAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001701LLVMValueRef LLVMConstSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Erick Tryzelaar4c340c72010-02-28 05:51:43 +00001702LLVMValueRef LLVMConstNSWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1703LLVMValueRef LLVMConstNUWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Erick Tryzelaar4cc690c2009-08-16 02:20:12 +00001704LLVMValueRef LLVMConstFSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001705LLVMValueRef LLVMConstMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Erick Tryzelaar4c340c72010-02-28 05:51:43 +00001706LLVMValueRef LLVMConstNSWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1707LLVMValueRef LLVMConstNUWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Erick Tryzelaar4cc690c2009-08-16 02:20:12 +00001708LLVMValueRef LLVMConstFMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001709LLVMValueRef LLVMConstUDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Manuel Jacob49fafb12016-10-04 23:32:42 +00001710LLVMValueRef LLVMConstExactUDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001711LLVMValueRef LLVMConstSDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Dan Gohmane4ca02d2009-09-03 23:34:49 +00001712LLVMValueRef LLVMConstExactSDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001713LLVMValueRef LLVMConstFDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1714LLVMValueRef LLVMConstURem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1715LLVMValueRef LLVMConstSRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1716LLVMValueRef LLVMConstFRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1717LLVMValueRef LLVMConstAnd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1718LLVMValueRef LLVMConstOr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1719LLVMValueRef LLVMConstXor(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1720LLVMValueRef LLVMConstICmp(LLVMIntPredicate Predicate,
1721 LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1722LLVMValueRef LLVMConstFCmp(LLVMRealPredicate Predicate,
1723 LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1724LLVMValueRef LLVMConstShl(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1725LLVMValueRef LLVMConstLShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1726LLVMValueRef LLVMConstAShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
1727LLVMValueRef LLVMConstGEP(LLVMValueRef ConstantVal,
1728 LLVMValueRef *ConstantIndices, unsigned NumIndices);
Dan Gohmane4ca02d2009-09-03 23:34:49 +00001729LLVMValueRef LLVMConstInBoundsGEP(LLVMValueRef ConstantVal,
1730 LLVMValueRef *ConstantIndices,
1731 unsigned NumIndices);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001732LLVMValueRef LLVMConstTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1733LLVMValueRef LLVMConstSExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1734LLVMValueRef LLVMConstZExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1735LLVMValueRef LLVMConstFPTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1736LLVMValueRef LLVMConstFPExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1737LLVMValueRef LLVMConstUIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1738LLVMValueRef LLVMConstSIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1739LLVMValueRef LLVMConstFPToUI(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1740LLVMValueRef LLVMConstFPToSI(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1741LLVMValueRef LLVMConstPtrToInt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1742LLVMValueRef LLVMConstIntToPtr(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
1743LLVMValueRef LLVMConstBitCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
Matt Arsenaultb03bd4d2013-11-15 01:34:59 +00001744LLVMValueRef LLVMConstAddrSpaceCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
Erick Tryzelaar4cc690c2009-08-16 02:20:12 +00001745LLVMValueRef LLVMConstZExtOrBitCast(LLVMValueRef ConstantVal,
1746 LLVMTypeRef ToType);
1747LLVMValueRef LLVMConstSExtOrBitCast(LLVMValueRef ConstantVal,
1748 LLVMTypeRef ToType);
1749LLVMValueRef LLVMConstTruncOrBitCast(LLVMValueRef ConstantVal,
1750 LLVMTypeRef ToType);
1751LLVMValueRef LLVMConstPointerCast(LLVMValueRef ConstantVal,
1752 LLVMTypeRef ToType);
1753LLVMValueRef LLVMConstIntCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType,
Chris Lattner25963c62010-01-09 22:27:07 +00001754 LLVMBool isSigned);
Erick Tryzelaar4cc690c2009-08-16 02:20:12 +00001755LLVMValueRef LLVMConstFPCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001756LLVMValueRef LLVMConstSelect(LLVMValueRef ConstantCondition,
1757 LLVMValueRef ConstantIfTrue,
1758 LLVMValueRef ConstantIfFalse);
1759LLVMValueRef LLVMConstExtractElement(LLVMValueRef VectorConstant,
1760 LLVMValueRef IndexConstant);
1761LLVMValueRef LLVMConstInsertElement(LLVMValueRef VectorConstant,
1762 LLVMValueRef ElementValueConstant,
1763 LLVMValueRef IndexConstant);
1764LLVMValueRef LLVMConstShuffleVector(LLVMValueRef VectorAConstant,
1765 LLVMValueRef VectorBConstant,
1766 LLVMValueRef MaskConstant);
Dan Gohmand5104a52008-11-03 22:55:43 +00001767LLVMValueRef LLVMConstExtractValue(LLVMValueRef AggConstant, unsigned *IdxList,
1768 unsigned NumIdx);
1769LLVMValueRef LLVMConstInsertValue(LLVMValueRef AggConstant,
1770 LLVMValueRef ElementValueConstant,
1771 unsigned *IdxList, unsigned NumIdx);
Chris Lattner25963c62010-01-09 22:27:07 +00001772LLVMValueRef LLVMConstInlineAsm(LLVMTypeRef Ty,
Chris Lattner3d1f5522008-12-17 21:39:50 +00001773 const char *AsmString, const char *Constraints,
Chris Lattner25963c62010-01-09 22:27:07 +00001774 LLVMBool HasSideEffects, LLVMBool IsAlignStack);
Erick Tryzelaar0fb26ef2010-02-28 09:46:06 +00001775LLVMValueRef LLVMBlockAddress(LLVMValueRef F, LLVMBasicBlockRef BB);
Gordon Henriksen7ce31762007-10-06 14:29:36 +00001776
Gregory Szorc52d26602012-03-21 07:28:27 +00001777/**
1778 * @}
1779 */
1780
1781/**
1782 * @defgroup LLVMCCoreValueConstantGlobals Global Values
1783 *
1784 * This group contains functions that operate on global values. Functions in
1785 * this group relate to functions in the llvm::GlobalValue class tree.
1786 *
1787 * @see llvm::GlobalValue
1788 *
1789 * @{
1790 */
1791
Gordon Henriksen265f7802008-03-19 01:11:35 +00001792LLVMModuleRef LLVMGetGlobalParent(LLVMValueRef Global);
Chris Lattner25963c62010-01-09 22:27:07 +00001793LLVMBool LLVMIsDeclaration(LLVMValueRef Global);
Gordon Henriksen76a03742007-09-18 03:18:57 +00001794LLVMLinkage LLVMGetLinkage(LLVMValueRef Global);
1795void LLVMSetLinkage(LLVMValueRef Global, LLVMLinkage Linkage);
1796const char *LLVMGetSection(LLVMValueRef Global);
1797void LLVMSetSection(LLVMValueRef Global, const char *Section);
1798LLVMVisibility LLVMGetVisibility(LLVMValueRef Global);
1799void LLVMSetVisibility(LLVMValueRef Global, LLVMVisibility Viz);
Reid Kleckner2fae26f2014-03-05 02:34:23 +00001800LLVMDLLStorageClass LLVMGetDLLStorageClass(LLVMValueRef Global);
1801void LLVMSetDLLStorageClass(LLVMValueRef Global, LLVMDLLStorageClass Class);
Tim Northoverad96d012014-03-10 19:24:35 +00001802LLVMBool LLVMHasUnnamedAddr(LLVMValueRef Global);
1803void LLVMSetUnnamedAddr(LLVMValueRef Global, LLVMBool HasUnnamedAddr);
Anders Waldenborg213a63f2013-10-29 09:02:02 +00001804
1805/**
1806 * @defgroup LLVMCCoreValueWithAlignment Values with alignment
1807 *
1808 * Functions in this group only apply to values with alignment, i.e.
1809 * global variables, load and store instructions.
1810 */
1811
1812/**
1813 * Obtain the preferred alignment of the value.
Peter Zotov9f584e62014-03-05 05:05:34 +00001814 * @see llvm::AllocaInst::getAlignment()
Anders Waldenborg213a63f2013-10-29 09:02:02 +00001815 * @see llvm::LoadInst::getAlignment()
1816 * @see llvm::StoreInst::getAlignment()
1817 * @see llvm::GlobalValue::getAlignment()
1818 */
1819unsigned LLVMGetAlignment(LLVMValueRef V);
1820
1821/**
1822 * Set the preferred alignment of the value.
Peter Zotov9f584e62014-03-05 05:05:34 +00001823 * @see llvm::AllocaInst::setAlignment()
Anders Waldenborg213a63f2013-10-29 09:02:02 +00001824 * @see llvm::LoadInst::setAlignment()
1825 * @see llvm::StoreInst::setAlignment()
1826 * @see llvm::GlobalValue::setAlignment()
1827 */
1828void LLVMSetAlignment(LLVMValueRef V, unsigned Bytes);
1829
1830/**
Amaury Sechet83550102016-02-14 08:58:49 +00001831 * @}
1832 */
Gordon Henriksen76a03742007-09-18 03:18:57 +00001833
Gregory Szorc52d26602012-03-21 07:28:27 +00001834/**
1835 * @defgroup LLVMCoreValueConstantGlobalVariable Global Variables
1836 *
1837 * This group contains functions that operate on global variable values.
1838 *
1839 * @see llvm::GlobalVariable
1840 *
1841 * @{
1842 */
Gordon Henriksen76a03742007-09-18 03:18:57 +00001843LLVMValueRef LLVMAddGlobal(LLVMModuleRef M, LLVMTypeRef Ty, const char *Name);
Erick Tryzelaar06894b32010-02-28 09:46:13 +00001844LLVMValueRef LLVMAddGlobalInAddressSpace(LLVMModuleRef M, LLVMTypeRef Ty,
1845 const char *Name,
1846 unsigned AddressSpace);
Gordon Henriksen783f7bb2007-10-08 03:45:09 +00001847LLVMValueRef LLVMGetNamedGlobal(LLVMModuleRef M, const char *Name);
Gordon Henriksen07a45f42008-03-23 22:21:29 +00001848LLVMValueRef LLVMGetFirstGlobal(LLVMModuleRef M);
1849LLVMValueRef LLVMGetLastGlobal(LLVMModuleRef M);
1850LLVMValueRef LLVMGetNextGlobal(LLVMValueRef GlobalVar);
1851LLVMValueRef LLVMGetPreviousGlobal(LLVMValueRef GlobalVar);
Gordon Henriksen76a03742007-09-18 03:18:57 +00001852void LLVMDeleteGlobal(LLVMValueRef GlobalVar);
Gordon Henriksen76a03742007-09-18 03:18:57 +00001853LLVMValueRef LLVMGetInitializer(LLVMValueRef GlobalVar);
1854void LLVMSetInitializer(LLVMValueRef GlobalVar, LLVMValueRef ConstantVal);
Chris Lattner25963c62010-01-09 22:27:07 +00001855LLVMBool LLVMIsThreadLocal(LLVMValueRef GlobalVar);
1856void LLVMSetThreadLocal(LLVMValueRef GlobalVar, LLVMBool IsThreadLocal);
1857LLVMBool LLVMIsGlobalConstant(LLVMValueRef GlobalVar);
1858void LLVMSetGlobalConstant(LLVMValueRef GlobalVar, LLVMBool IsConstant);
Hans Wennborg5ff71202013-04-16 08:58:59 +00001859LLVMThreadLocalMode LLVMGetThreadLocalMode(LLVMValueRef GlobalVar);
1860void LLVMSetThreadLocalMode(LLVMValueRef GlobalVar, LLVMThreadLocalMode Mode);
1861LLVMBool LLVMIsExternallyInitialized(LLVMValueRef GlobalVar);
1862void LLVMSetExternallyInitialized(LLVMValueRef GlobalVar, LLVMBool IsExtInit);
Gordon Henriksen76a03742007-09-18 03:18:57 +00001863
Gregory Szorc52d26602012-03-21 07:28:27 +00001864/**
1865 * @}
1866 */
1867
1868/**
1869 * @defgroup LLVMCoreValueConstantGlobalAlias Global Aliases
1870 *
1871 * This group contains function that operate on global alias values.
1872 *
1873 * @see llvm::GlobalAlias
1874 *
1875 * @{
1876 */
Chris Lattner3d1f5522008-12-17 21:39:50 +00001877LLVMValueRef LLVMAddAlias(LLVMModuleRef M, LLVMTypeRef Ty, LLVMValueRef Aliasee,
1878 const char *Name);
1879
Gregory Szorc34c863a2012-03-21 03:54:29 +00001880/**
1881 * @}
1882 */
1883
1884/**
1885 * @defgroup LLVMCCoreValueFunction Function values
1886 *
1887 * Functions in this group operate on LLVMValueRef instances that
1888 * correspond to llvm::Function instances.
1889 *
1890 * @see llvm::Function
1891 *
1892 * @{
1893 */
1894
1895/**
1896 * Remove a function from its containing module and deletes it.
1897 *
1898 * @see llvm::Function::eraseFromParent()
1899 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00001900void LLVMDeleteFunction(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001901
1902/**
Amaury Sechete39e8532016-02-18 20:38:32 +00001903 * Check whether the given function has a personality function.
1904 *
1905 * @see llvm::Function::hasPersonalityFn()
1906 */
1907LLVMBool LLVMHasPersonalityFn(LLVMValueRef Fn);
1908
1909/**
Andrew Wilkins3bdfc1c2015-07-14 01:23:06 +00001910 * Obtain the personality function attached to the function.
1911 *
1912 * @see llvm::Function::getPersonalityFn()
1913 */
1914LLVMValueRef LLVMGetPersonalityFn(LLVMValueRef Fn);
1915
1916/**
1917 * Set the personality function attached to the function.
1918 *
1919 * @see llvm::Function::setPersonalityFn()
1920 */
1921void LLVMSetPersonalityFn(LLVMValueRef Fn, LLVMValueRef PersonalityFn);
1922
1923/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00001924 * Obtain the ID number from a function instance.
1925 *
1926 * @see llvm::Function::getIntrinsicID()
1927 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00001928unsigned LLVMGetIntrinsicID(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001929
1930/**
1931 * Obtain the calling function of a function.
1932 *
1933 * The returned value corresponds to the LLVMCallConv enumeration.
1934 *
1935 * @see llvm::Function::getCallingConv()
1936 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00001937unsigned LLVMGetFunctionCallConv(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001938
1939/**
1940 * Set the calling convention of a function.
1941 *
1942 * @see llvm::Function::setCallingConv()
1943 *
1944 * @param Fn Function to operate on
1945 * @param CC LLVMCallConv to set calling convention to
1946 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00001947void LLVMSetFunctionCallConv(LLVMValueRef Fn, unsigned CC);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001948
1949/**
1950 * Obtain the name of the garbage collector to use during code
1951 * generation.
1952 *
1953 * @see llvm::Function::getGC()
1954 */
Gordon Henriksend930f912008-08-17 18:44:35 +00001955const char *LLVMGetGC(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001956
1957/**
1958 * Define the garbage collector to use during code generation.
1959 *
1960 * @see llvm::Function::setGC()
1961 */
Gordon Henriksend930f912008-08-17 18:44:35 +00001962void LLVMSetGC(LLVMValueRef Fn, const char *Name);
Gregory Szorc34c863a2012-03-21 03:54:29 +00001963
1964/**
1965 * Add an attribute to a function.
1966 *
1967 * @see llvm::Function::addAttribute()
1968 */
Amaury Sechet5db224e2016-06-12 06:17:24 +00001969void LLVMAddAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx,
1970 LLVMAttributeRef A);
Amaury Sechet17b67cd2016-07-21 04:25:06 +00001971unsigned LLVMGetAttributeCountAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx);
1972void LLVMGetAttributesAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx,
1973 LLVMAttributeRef *Attrs);
Amaury Sechet5db224e2016-06-12 06:17:24 +00001974LLVMAttributeRef LLVMGetEnumAttributeAtIndex(LLVMValueRef F,
1975 LLVMAttributeIndex Idx,
1976 unsigned KindID);
Amaury Sechet6100adf2016-06-15 17:50:39 +00001977LLVMAttributeRef LLVMGetStringAttributeAtIndex(LLVMValueRef F,
1978 LLVMAttributeIndex Idx,
1979 const char *K, unsigned KLen);
Amaury Sechet5db224e2016-06-12 06:17:24 +00001980void LLVMRemoveEnumAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx,
1981 unsigned KindID);
Amaury Sechet6100adf2016-06-15 17:50:39 +00001982void LLVMRemoveStringAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx,
1983 const char *K, unsigned KLen);
Amaury Sechet5db224e2016-06-12 06:17:24 +00001984
Gregory Szorc34c863a2012-03-21 03:54:29 +00001985/**
Nick Lewyckyc3890d22015-07-29 22:32:47 +00001986 * Add a target-dependent attribute to a function
Tom Stellarde8f35e12013-04-16 23:12:43 +00001987 * @see llvm::AttrBuilder::addAttribute()
1988 */
1989void LLVMAddTargetDependentFunctionAttr(LLVMValueRef Fn, const char *A,
1990 const char *V);
1991
1992/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00001993 * @defgroup LLVMCCoreValueFunctionParameters Function Parameters
1994 *
1995 * Functions in this group relate to arguments/parameters on functions.
1996 *
1997 * Functions in this group expect LLVMValueRef instances that correspond
1998 * to llvm::Function instances.
1999 *
2000 * @{
2001 */
2002
2003/**
2004 * Obtain the number of parameters in a function.
2005 *
2006 * @see llvm::Function::arg_size()
2007 */
Gordon Henriksen265f7802008-03-19 01:11:35 +00002008unsigned LLVMCountParams(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002009
2010/**
2011 * Obtain the parameters in a function.
2012 *
2013 * The takes a pointer to a pre-allocated array of LLVMValueRef that is
2014 * at least LLVMCountParams() long. This array will be filled with
2015 * LLVMValueRef instances which correspond to the parameters the
2016 * function receives. Each LLVMValueRef corresponds to a llvm::Argument
2017 * instance.
2018 *
2019 * @see llvm::Function::arg_begin()
2020 */
Gordon Henriksen265f7802008-03-19 01:11:35 +00002021void LLVMGetParams(LLVMValueRef Fn, LLVMValueRef *Params);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002022
2023/**
2024 * Obtain the parameter at the specified index.
2025 *
2026 * Parameters are indexed from 0.
2027 *
2028 * @see llvm::Function::arg_begin()
2029 */
Gordon Henriksen265f7802008-03-19 01:11:35 +00002030LLVMValueRef LLVMGetParam(LLVMValueRef Fn, unsigned Index);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002031
2032/**
2033 * Obtain the function to which this argument belongs.
2034 *
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00002035 * Unlike other functions in this group, this one takes an LLVMValueRef
Gregory Szorc34c863a2012-03-21 03:54:29 +00002036 * that corresponds to a llvm::Attribute.
2037 *
2038 * The returned LLVMValueRef is the llvm::Function to which this
2039 * argument belongs.
2040 */
Gordon Henriksen265f7802008-03-19 01:11:35 +00002041LLVMValueRef LLVMGetParamParent(LLVMValueRef Inst);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002042
2043/**
2044 * Obtain the first parameter to a function.
2045 *
2046 * @see llvm::Function::arg_begin()
2047 */
Gordon Henriksen07a45f42008-03-23 22:21:29 +00002048LLVMValueRef LLVMGetFirstParam(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002049
2050/**
2051 * Obtain the last parameter to a function.
2052 *
2053 * @see llvm::Function::arg_end()
2054 */
Gordon Henriksen07a45f42008-03-23 22:21:29 +00002055LLVMValueRef LLVMGetLastParam(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002056
2057/**
2058 * Obtain the next parameter to a function.
2059 *
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00002060 * This takes an LLVMValueRef obtained from LLVMGetFirstParam() (which is
Gregory Szorc34c863a2012-03-21 03:54:29 +00002061 * actually a wrapped iterator) and obtains the next parameter from the
2062 * underlying iterator.
2063 */
Gordon Henriksen07a45f42008-03-23 22:21:29 +00002064LLVMValueRef LLVMGetNextParam(LLVMValueRef Arg);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002065
2066/**
2067 * Obtain the previous parameter to a function.
2068 *
2069 * This is the opposite of LLVMGetNextParam().
2070 */
Gordon Henriksen07a45f42008-03-23 22:21:29 +00002071LLVMValueRef LLVMGetPreviousParam(LLVMValueRef Arg);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002072
2073/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002074 * Set the alignment for a function parameter.
2075 *
2076 * @see llvm::Argument::addAttr()
Bill Wendling50d27842012-10-15 20:35:56 +00002077 * @see llvm::AttrBuilder::addAlignmentAttr()
Gregory Szorc34c863a2012-03-21 03:54:29 +00002078 */
Amaury Sechet81243a72016-05-01 01:42:34 +00002079void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned Align);
Gordon Henriksen265f7802008-03-19 01:11:35 +00002080
Gregory Szorc34c863a2012-03-21 03:54:29 +00002081/**
2082 * @}
2083 */
2084
2085/**
2086 * @}
2087 */
2088
2089/**
Gregory Szorc52d26602012-03-21 07:28:27 +00002090 * @}
2091 */
2092
2093/**
2094 * @}
2095 */
2096
2097/**
2098 * @defgroup LLVMCCoreValueMetadata Metadata
2099 *
2100 * @{
2101 */
2102
2103/**
2104 * Obtain a MDString value from a context.
2105 *
2106 * The returned instance corresponds to the llvm::MDString class.
2107 *
2108 * The instance is specified by string data of a specified length. The
2109 * string content is copied, so the backing memory can be freed after
2110 * this function returns.
2111 */
2112LLVMValueRef LLVMMDStringInContext(LLVMContextRef C, const char *Str,
2113 unsigned SLen);
2114
2115/**
2116 * Obtain a MDString value from the global context.
2117 */
2118LLVMValueRef LLVMMDString(const char *Str, unsigned SLen);
2119
2120/**
2121 * Obtain a MDNode value from a context.
2122 *
2123 * The returned value corresponds to the llvm::MDNode class.
2124 */
2125LLVMValueRef LLVMMDNodeInContext(LLVMContextRef C, LLVMValueRef *Vals,
2126 unsigned Count);
2127
2128/**
2129 * Obtain a MDNode value from the global context.
2130 */
2131LLVMValueRef LLVMMDNode(LLVMValueRef *Vals, unsigned Count);
2132
2133/**
2134 * Obtain the underlying string from a MDString value.
2135 *
2136 * @param V Instance to obtain string from.
NAKAMURA Takumie4a77052016-04-04 11:54:48 +00002137 * @param Length Memory address which will hold length of returned string.
Gregory Szorc52d26602012-03-21 07:28:27 +00002138 * @return String data in MDString.
2139 */
Amaury Sechet7c2883c2016-04-03 21:06:04 +00002140const char *LLVMGetMDString(LLVMValueRef V, unsigned *Length);
Gregory Szorc52d26602012-03-21 07:28:27 +00002141
2142/**
Duncan Sands12ccbe72012-09-19 20:29:39 +00002143 * Obtain the number of operands from an MDNode value.
2144 *
2145 * @param V MDNode to get number of operands from.
2146 * @return Number of operands of the MDNode.
2147 */
2148unsigned LLVMGetMDNodeNumOperands(LLVMValueRef V);
2149
2150/**
2151 * Obtain the given MDNode's operands.
2152 *
2153 * The passed LLVMValueRef pointer should point to enough memory to hold all of
2154 * the operands of the given MDNode (see LLVMGetMDNodeNumOperands) as
2155 * LLVMValueRefs. This memory will be populated with the LLVMValueRefs of the
2156 * MDNode's operands.
2157 *
2158 * @param V MDNode to get the operands from.
2159 * @param Dest Destination array for operands.
2160 */
2161void LLVMGetMDNodeOperands(LLVMValueRef V, LLVMValueRef *Dest);
2162
2163/**
Gregory Szorc52d26602012-03-21 07:28:27 +00002164 * @}
2165 */
2166
2167/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002168 * @defgroup LLVMCCoreValueBasicBlock Basic Block
2169 *
2170 * A basic block represents a single entry single exit section of code.
2171 * Basic blocks contain a list of instructions which form the body of
2172 * the block.
2173 *
2174 * Basic blocks belong to functions. They have the type of label.
2175 *
2176 * Basic blocks are themselves values. However, the C API models them as
2177 * LLVMBasicBlockRef.
2178 *
2179 * @see llvm::BasicBlock
2180 *
2181 * @{
2182 */
2183
2184/**
2185 * Convert a basic block instance to a value type.
2186 */
Gordon Henriksen07a45f42008-03-23 22:21:29 +00002187LLVMValueRef LLVMBasicBlockAsValue(LLVMBasicBlockRef BB);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002188
2189/**
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00002190 * Determine whether an LLVMValueRef is itself a basic block.
Gregory Szorc34c863a2012-03-21 03:54:29 +00002191 */
Chris Lattner25963c62010-01-09 22:27:07 +00002192LLVMBool LLVMValueIsBasicBlock(LLVMValueRef Val);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002193
2194/**
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00002195 * Convert an LLVMValueRef to an LLVMBasicBlockRef instance.
Gregory Szorc34c863a2012-03-21 03:54:29 +00002196 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002197LLVMBasicBlockRef LLVMValueAsBasicBlock(LLVMValueRef Val);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002198
2199/**
Amaury Secheta82042e2016-02-09 22:36:41 +00002200 * Obtain the string name of a basic block.
2201 */
2202const char *LLVMGetBasicBlockName(LLVMBasicBlockRef BB);
2203
2204/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002205 * Obtain the function to which a basic block belongs.
2206 *
2207 * @see llvm::BasicBlock::getParent()
2208 */
Gordon Henriksen07a45f42008-03-23 22:21:29 +00002209LLVMValueRef LLVMGetBasicBlockParent(LLVMBasicBlockRef BB);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002210
2211/**
2212 * Obtain the terminator instruction for a basic block.
2213 *
2214 * If the basic block does not have a terminator (it is not well-formed
2215 * if it doesn't), then NULL is returned.
2216 *
2217 * The returned LLVMValueRef corresponds to a llvm::TerminatorInst.
2218 *
2219 * @see llvm::BasicBlock::getTerminator()
2220 */
Nate Begeman43c322b2011-08-23 20:27:46 +00002221LLVMValueRef LLVMGetBasicBlockTerminator(LLVMBasicBlockRef BB);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002222
2223/**
2224 * Obtain the number of basic blocks in a function.
2225 *
2226 * @param Fn Function value to operate on.
2227 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002228unsigned LLVMCountBasicBlocks(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002229
2230/**
2231 * Obtain all of the basic blocks in a function.
2232 *
2233 * This operates on a function value. The BasicBlocks parameter is a
2234 * pointer to a pre-allocated array of LLVMBasicBlockRef of at least
2235 * LLVMCountBasicBlocks() in length. This array is populated with
2236 * LLVMBasicBlockRef instances.
2237 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002238void LLVMGetBasicBlocks(LLVMValueRef Fn, LLVMBasicBlockRef *BasicBlocks);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002239
2240/**
2241 * Obtain the first basic block in a function.
2242 *
2243 * The returned basic block can be used as an iterator. You will likely
2244 * eventually call into LLVMGetNextBasicBlock() with it.
2245 *
2246 * @see llvm::Function::begin()
2247 */
Gordon Henriksen054817c2008-03-19 03:47:18 +00002248LLVMBasicBlockRef LLVMGetFirstBasicBlock(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002249
2250/**
2251 * Obtain the last basic block in a function.
2252 *
2253 * @see llvm::Function::end()
2254 */
Gordon Henriksen054817c2008-03-19 03:47:18 +00002255LLVMBasicBlockRef LLVMGetLastBasicBlock(LLVMValueRef Fn);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002256
2257/**
2258 * Advance a basic block iterator.
2259 */
Gordon Henriksen054817c2008-03-19 03:47:18 +00002260LLVMBasicBlockRef LLVMGetNextBasicBlock(LLVMBasicBlockRef BB);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002261
2262/**
2263 * Go backwards in a basic block iterator.
2264 */
Gordon Henriksen054817c2008-03-19 03:47:18 +00002265LLVMBasicBlockRef LLVMGetPreviousBasicBlock(LLVMBasicBlockRef BB);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002266
2267/**
2268 * Obtain the basic block that corresponds to the entry point of a
2269 * function.
2270 *
2271 * @see llvm::Function::getEntryBlock()
2272 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002273LLVMBasicBlockRef LLVMGetEntryBasicBlock(LLVMValueRef Fn);
Erick Tryzelaar262332f2009-08-14 00:01:31 +00002274
Gregory Szorc34c863a2012-03-21 03:54:29 +00002275/**
2276 * Append a basic block to the end of a function.
2277 *
2278 * @see llvm::BasicBlock::Create()
2279 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +00002280LLVMBasicBlockRef LLVMAppendBasicBlockInContext(LLVMContextRef C,
2281 LLVMValueRef Fn,
2282 const char *Name);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002283
2284/**
2285 * Append a basic block to the end of a function using the global
2286 * context.
2287 *
2288 * @see llvm::BasicBlock::Create()
2289 */
2290LLVMBasicBlockRef LLVMAppendBasicBlock(LLVMValueRef Fn, const char *Name);
2291
2292/**
2293 * Insert a basic block in a function before another basic block.
2294 *
2295 * The function to add to is determined by the function of the
2296 * passed basic block.
2297 *
2298 * @see llvm::BasicBlock::Create()
2299 */
Erick Tryzelaar262332f2009-08-14 00:01:31 +00002300LLVMBasicBlockRef LLVMInsertBasicBlockInContext(LLVMContextRef C,
2301 LLVMBasicBlockRef BB,
2302 const char *Name);
2303
Gregory Szorc34c863a2012-03-21 03:54:29 +00002304/**
2305 * Insert a basic block in a function using the global context.
2306 *
2307 * @see llvm::BasicBlock::Create()
2308 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002309LLVMBasicBlockRef LLVMInsertBasicBlock(LLVMBasicBlockRef InsertBeforeBB,
2310 const char *Name);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002311
2312/**
2313 * Remove a basic block from a function and delete it.
2314 *
2315 * This deletes the basic block from its containing function and deletes
2316 * the basic block itself.
2317 *
2318 * @see llvm::BasicBlock::eraseFromParent()
2319 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002320void LLVMDeleteBasicBlock(LLVMBasicBlockRef BB);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002321
2322/**
2323 * Remove a basic block from a function.
2324 *
2325 * This deletes the basic block from its containing function but keep
2326 * the basic block alive.
2327 *
2328 * @see llvm::BasicBlock::removeFromParent()
2329 */
Nate Begeman43c322b2011-08-23 20:27:46 +00002330void LLVMRemoveBasicBlockFromParent(LLVMBasicBlockRef BB);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002331
Gregory Szorc34c863a2012-03-21 03:54:29 +00002332/**
2333 * Move a basic block to before another one.
2334 *
2335 * @see llvm::BasicBlock::moveBefore()
2336 */
Duncan Sandsb1d61aa2010-07-19 15:31:07 +00002337void LLVMMoveBasicBlockBefore(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002338
2339/**
2340 * Move a basic block to after another one.
2341 *
2342 * @see llvm::BasicBlock::moveAfter()
2343 */
Duncan Sandsb1d61aa2010-07-19 15:31:07 +00002344void LLVMMoveBasicBlockAfter(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos);
2345
Gregory Szorc34c863a2012-03-21 03:54:29 +00002346/**
2347 * Obtain the first instruction in a basic block.
2348 *
2349 * The returned LLVMValueRef corresponds to a llvm::Instruction
2350 * instance.
2351 */
Gordon Henriksen054817c2008-03-19 03:47:18 +00002352LLVMValueRef LLVMGetFirstInstruction(LLVMBasicBlockRef BB);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002353
2354/**
2355 * Obtain the last instruction in a basic block.
2356 *
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00002357 * The returned LLVMValueRef corresponds to an LLVM:Instruction.
Gregory Szorc34c863a2012-03-21 03:54:29 +00002358 */
Gordon Henriksen054817c2008-03-19 03:47:18 +00002359LLVMValueRef LLVMGetLastInstruction(LLVMBasicBlockRef BB);
Nate Begeman43c322b2011-08-23 20:27:46 +00002360
Gregory Szorc34c863a2012-03-21 03:54:29 +00002361/**
2362 * @}
2363 */
2364
2365/**
2366 * @defgroup LLVMCCoreValueInstruction Instructions
2367 *
2368 * Functions in this group relate to the inspection and manipulation of
2369 * individual instructions.
2370 *
2371 * In the C++ API, an instruction is modeled by llvm::Instruction. This
2372 * class has a large number of descendents. llvm::Instruction is a
2373 * llvm::Value and in the C API, instructions are modeled by
2374 * LLVMValueRef.
2375 *
2376 * This group also contains sub-groups which operate on specific
2377 * llvm::Instruction types, e.g. llvm::CallInst.
2378 *
2379 * @{
2380 */
2381
2382/**
2383 * Determine whether an instruction has any metadata attached.
2384 */
2385int LLVMHasMetadata(LLVMValueRef Val);
2386
2387/**
2388 * Return metadata associated with an instruction value.
2389 */
2390LLVMValueRef LLVMGetMetadata(LLVMValueRef Val, unsigned KindID);
2391
2392/**
2393 * Set metadata associated with an instruction value.
2394 */
2395void LLVMSetMetadata(LLVMValueRef Val, unsigned KindID, LLVMValueRef Node);
2396
2397/**
2398 * Obtain the basic block to which an instruction belongs.
2399 *
2400 * @see llvm::Instruction::getParent()
2401 */
Nate Begeman43c322b2011-08-23 20:27:46 +00002402LLVMBasicBlockRef LLVMGetInstructionParent(LLVMValueRef Inst);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002403
2404/**
2405 * Obtain the instruction that occurs after the one specified.
2406 *
2407 * The next instruction will be from the same basic block.
2408 *
2409 * If this is the last instruction in a basic block, NULL will be
2410 * returned.
2411 */
Gordon Henriksen054817c2008-03-19 03:47:18 +00002412LLVMValueRef LLVMGetNextInstruction(LLVMValueRef Inst);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002413
2414/**
Benjamin Kramerbde91762012-06-02 10:20:22 +00002415 * Obtain the instruction that occurred before this one.
Gregory Szorc34c863a2012-03-21 03:54:29 +00002416 *
2417 * If the instruction is the first instruction in a basic block, NULL
2418 * will be returned.
2419 */
Gordon Henriksen054817c2008-03-19 03:47:18 +00002420LLVMValueRef LLVMGetPreviousInstruction(LLVMValueRef Inst);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002421
2422/**
2423 * Remove and delete an instruction.
2424 *
2425 * The instruction specified is removed from its containing building
Amaury Sechet2f432082016-02-11 21:37:54 +00002426 * block but is kept alive.
2427 *
2428 * @see llvm::Instruction::removeFromParent()
2429 */
2430void LLVMInstructionRemoveFromParent(LLVMValueRef Inst);
2431
2432/**
2433 * Remove and delete an instruction.
2434 *
2435 * The instruction specified is removed from its containing building
Gregory Szorc34c863a2012-03-21 03:54:29 +00002436 * block and then deleted.
2437 *
2438 * @see llvm::Instruction::eraseFromParent()
2439 */
Devang Pateldbebc6f2011-10-03 20:59:18 +00002440void LLVMInstructionEraseFromParent(LLVMValueRef Inst);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002441
2442/**
2443 * Obtain the code opcode for an individual instruction.
2444 *
2445 * @see llvm::Instruction::getOpCode()
2446 */
Eric Christophera6b96002015-12-18 01:46:52 +00002447LLVMOpcode LLVMGetInstructionOpcode(LLVMValueRef Inst);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002448
2449/**
2450 * Obtain the predicate of an instruction.
2451 *
2452 * This is only valid for instructions that correspond to llvm::ICmpInst
2453 * or llvm::ConstantExpr whose opcode is llvm::Instruction::ICmp.
2454 *
2455 * @see llvm::ICmpInst::getPredicate()
2456 */
Torok Edwin60c40de2011-10-06 12:13:20 +00002457LLVMIntPredicate LLVMGetICmpPredicate(LLVMValueRef Inst);
Gordon Henriksen265f7802008-03-19 01:11:35 +00002458
Gregory Szorc34c863a2012-03-21 03:54:29 +00002459/**
Peter Zotov1d98e6d2014-10-28 19:46:44 +00002460 * Obtain the float predicate of an instruction.
2461 *
2462 * This is only valid for instructions that correspond to llvm::FCmpInst
2463 * or llvm::ConstantExpr whose opcode is llvm::Instruction::FCmp.
2464 *
2465 * @see llvm::FCmpInst::getPredicate()
2466 */
2467LLVMRealPredicate LLVMGetFCmpPredicate(LLVMValueRef Inst);
2468
2469/**
Peter Zotovaff492c2014-10-17 01:02:34 +00002470 * Create a copy of 'this' instruction that is identical in all ways
2471 * except the following:
2472 * * The instruction has no parent
2473 * * The instruction has no name
2474 *
2475 * @see llvm::Instruction::clone()
2476 */
2477LLVMValueRef LLVMInstructionClone(LLVMValueRef Inst);
2478
2479/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002480 * @defgroup LLVMCCoreValueInstructionCall Call Sites and Invocations
2481 *
2482 * Functions in this group apply to instructions that refer to call
2483 * sites and invocations. These correspond to C++ types in the
2484 * llvm::CallInst class tree.
2485 *
2486 * @{
2487 */
2488
2489/**
Amaury Sechet5c7b3af2016-02-10 00:09:37 +00002490 * Obtain the argument count for a call instruction.
2491 *
2492 * This expects an LLVMValueRef that corresponds to a llvm::CallInst or
2493 * llvm::InvokeInst.
2494 *
2495 * @see llvm::CallInst::getNumArgOperands()
2496 * @see llvm::InvokeInst::getNumArgOperands()
2497 */
2498unsigned LLVMGetNumArgOperands(LLVMValueRef Instr);
2499
2500/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002501 * Set the calling convention for a call instruction.
2502 *
2503 * This expects an LLVMValueRef that corresponds to a llvm::CallInst or
2504 * llvm::InvokeInst.
2505 *
2506 * @see llvm::CallInst::setCallingConv()
2507 * @see llvm::InvokeInst::setCallingConv()
2508 */
Gordon Henriksen1158c532007-12-29 20:45:00 +00002509void LLVMSetInstructionCallConv(LLVMValueRef Instr, unsigned CC);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002510
2511/**
2512 * Obtain the calling convention for a call instruction.
2513 *
2514 * This is the opposite of LLVMSetInstructionCallConv(). Reads its
2515 * usage.
2516 *
2517 * @see LLVMSetInstructionCallConv()
2518 */
Gordon Henriksen1158c532007-12-29 20:45:00 +00002519unsigned LLVMGetInstructionCallConv(LLVMValueRef Instr);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002520
Gregory Szorc34c863a2012-03-21 03:54:29 +00002521void LLVMSetInstrParamAlignment(LLVMValueRef Instr, unsigned index,
Amaury Sechet81243a72016-05-01 01:42:34 +00002522 unsigned Align);
Gordon Henriksen1158c532007-12-29 20:45:00 +00002523
Amaury Secheta65a2372016-06-15 05:14:29 +00002524void LLVMAddCallSiteAttribute(LLVMValueRef C, LLVMAttributeIndex Idx,
2525 LLVMAttributeRef A);
Amaury Sechet17b67cd2016-07-21 04:25:06 +00002526unsigned LLVMGetCallSiteAttributeCount(LLVMValueRef C, LLVMAttributeIndex Idx);
2527void LLVMGetCallSiteAttributes(LLVMValueRef C, LLVMAttributeIndex Idx,
2528 LLVMAttributeRef *Attrs);
Amaury Secheta65a2372016-06-15 05:14:29 +00002529LLVMAttributeRef LLVMGetCallSiteEnumAttribute(LLVMValueRef C,
2530 LLVMAttributeIndex Idx,
2531 unsigned KindID);
Amaury Sechet6100adf2016-06-15 17:50:39 +00002532LLVMAttributeRef LLVMGetCallSiteStringAttribute(LLVMValueRef C,
2533 LLVMAttributeIndex Idx,
2534 const char *K, unsigned KLen);
Amaury Secheta65a2372016-06-15 05:14:29 +00002535void LLVMRemoveCallSiteEnumAttribute(LLVMValueRef C, LLVMAttributeIndex Idx,
2536 unsigned KindID);
Amaury Sechet6100adf2016-06-15 17:50:39 +00002537void LLVMRemoveCallSiteStringAttribute(LLVMValueRef C, LLVMAttributeIndex Idx,
2538 const char *K, unsigned KLen);
Amaury Secheta65a2372016-06-15 05:14:29 +00002539
Gregory Szorc34c863a2012-03-21 03:54:29 +00002540/**
Amaury Sechet5c7b3af2016-02-10 00:09:37 +00002541 * Obtain the pointer to the function invoked by this instruction.
2542 *
2543 * This expects an LLVMValueRef that corresponds to a llvm::CallInst or
2544 * llvm::InvokeInst.
2545 *
2546 * @see llvm::CallInst::getCalledValue()
2547 * @see llvm::InvokeInst::getCalledValue()
2548 */
2549LLVMValueRef LLVMGetCalledValue(LLVMValueRef Instr);
2550
2551/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002552 * Obtain whether a call instruction is a tail call.
2553 *
2554 * This only works on llvm::CallInst instructions.
2555 *
2556 * @see llvm::CallInst::isTailCall()
2557 */
Chris Lattner25963c62010-01-09 22:27:07 +00002558LLVMBool LLVMIsTailCall(LLVMValueRef CallInst);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002559
2560/**
2561 * Set whether a call instruction is a tail call.
2562 *
2563 * This only works on llvm::CallInst instructions.
2564 *
2565 * @see llvm::CallInst::setTailCall()
2566 */
Chris Lattner25963c62010-01-09 22:27:07 +00002567void LLVMSetTailCall(LLVMValueRef CallInst, LLVMBool IsTailCall);
Gordon Henrikseneeb65372008-08-30 16:34:54 +00002568
Gregory Szorc34c863a2012-03-21 03:54:29 +00002569/**
Amaury Sechete39e8532016-02-18 20:38:32 +00002570 * Return the normal destination basic block.
2571 *
2572 * This only works on llvm::InvokeInst instructions.
2573 *
2574 * @see llvm::InvokeInst::getNormalDest()
2575 */
2576LLVMBasicBlockRef LLVMGetNormalDest(LLVMValueRef InvokeInst);
2577
2578/**
2579 * Return the unwind destination basic block.
2580 *
2581 * This only works on llvm::InvokeInst instructions.
2582 *
2583 * @see llvm::InvokeInst::getUnwindDest()
2584 */
2585LLVMBasicBlockRef LLVMGetUnwindDest(LLVMValueRef InvokeInst);
2586
2587/**
2588 * Set the normal destination basic block.
2589 *
2590 * This only works on llvm::InvokeInst instructions.
2591 *
2592 * @see llvm::InvokeInst::setNormalDest()
2593 */
2594void LLVMSetNormalDest(LLVMValueRef InvokeInst, LLVMBasicBlockRef B);
2595
2596/**
2597 * Set the unwind destination basic block.
2598 *
2599 * This only works on llvm::InvokeInst instructions.
2600 *
2601 * @see llvm::InvokeInst::setUnwindDest()
2602 */
2603void LLVMSetUnwindDest(LLVMValueRef InvokeInst, LLVMBasicBlockRef B);
2604
2605/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002606 * @}
2607 */
2608
2609/**
Peter Zotov2481c752014-10-28 19:46:56 +00002610 * @defgroup LLVMCCoreValueInstructionTerminator Terminators
2611 *
2612 * Functions in this group only apply to instructions that map to
2613 * llvm::TerminatorInst instances.
2614 *
2615 * @{
2616 */
2617
2618/**
2619 * Return the number of successors that this terminator has.
2620 *
2621 * @see llvm::TerminatorInst::getNumSuccessors
2622 */
2623unsigned LLVMGetNumSuccessors(LLVMValueRef Term);
2624
2625/**
2626 * Return the specified successor.
2627 *
2628 * @see llvm::TerminatorInst::getSuccessor
2629 */
2630LLVMBasicBlockRef LLVMGetSuccessor(LLVMValueRef Term, unsigned i);
2631
2632/**
2633 * Update the specified successor to point at the provided block.
2634 *
2635 * @see llvm::TerminatorInst::setSuccessor
2636 */
2637void LLVMSetSuccessor(LLVMValueRef Term, unsigned i, LLVMBasicBlockRef block);
2638
2639/**
2640 * Return if a branch is conditional.
2641 *
2642 * This only works on llvm::BranchInst instructions.
2643 *
2644 * @see llvm::BranchInst::isConditional
2645 */
2646LLVMBool LLVMIsConditional(LLVMValueRef Branch);
2647
2648/**
2649 * Return the condition of a branch instruction.
2650 *
2651 * This only works on llvm::BranchInst instructions.
2652 *
2653 * @see llvm::BranchInst::getCondition
2654 */
2655LLVMValueRef LLVMGetCondition(LLVMValueRef Branch);
2656
2657/**
2658 * Set the condition of a branch instruction.
2659 *
2660 * This only works on llvm::BranchInst instructions.
2661 *
2662 * @see llvm::BranchInst::setCondition
2663 */
2664void LLVMSetCondition(LLVMValueRef Branch, LLVMValueRef Cond);
2665
2666/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002667 * Obtain the default destination basic block of a switch instruction.
2668 *
2669 * This only works on llvm::SwitchInst instructions.
2670 *
2671 * @see llvm::SwitchInst::getDefaultDest()
2672 */
Nate Begeman43c322b2011-08-23 20:27:46 +00002673LLVMBasicBlockRef LLVMGetSwitchDefaultDest(LLVMValueRef SwitchInstr);
2674
Gregory Szorc34c863a2012-03-21 03:54:29 +00002675/**
Peter Zotov2481c752014-10-28 19:46:56 +00002676 * @}
2677 */
2678
2679/**
Amaury Sechet1dcf5772016-02-09 22:50:53 +00002680 * @defgroup LLVMCCoreValueInstructionAlloca Allocas
2681 *
2682 * Functions in this group only apply to instructions that map to
2683 * llvm::AllocaInst instances.
2684 *
2685 * @{
2686 */
2687
2688/**
2689 * Obtain the type that is being allocated by the alloca instruction.
2690 */
2691LLVMTypeRef LLVMGetAllocatedType(LLVMValueRef Alloca);
2692
2693/**
2694 * @}
2695 */
2696
2697/**
Amaury Sechet053ac452016-02-17 22:51:03 +00002698 * @defgroup LLVMCCoreValueInstructionGetElementPointer GEPs
2699 *
2700 * Functions in this group only apply to instructions that map to
2701 * llvm::GetElementPtrInst instances.
2702 *
2703 * @{
2704 */
2705
2706/**
2707 * Check whether the given GEP instruction is inbounds.
2708 */
2709LLVMBool LLVMIsInBounds(LLVMValueRef GEP);
2710
2711/**
2712 * Set the given GEP instruction to be inbounds or not.
2713 */
Amaury Sechet8a367d42016-05-01 02:23:14 +00002714void LLVMSetIsInBounds(LLVMValueRef GEP, LLVMBool InBounds);
Amaury Sechet053ac452016-02-17 22:51:03 +00002715
2716/**
2717 * @}
2718 */
2719
2720/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002721 * @defgroup LLVMCCoreValueInstructionPHINode PHI Nodes
2722 *
2723 * Functions in this group only apply to instructions that map to
2724 * llvm::PHINode instances.
2725 *
2726 * @{
2727 */
2728
2729/**
2730 * Add an incoming value to the end of a PHI list.
2731 */
Gordon Henriksen44dd8fb2007-10-08 18:14:39 +00002732void LLVMAddIncoming(LLVMValueRef PhiNode, LLVMValueRef *IncomingValues,
2733 LLVMBasicBlockRef *IncomingBlocks, unsigned Count);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002734
2735/**
2736 * Obtain the number of incoming basic blocks to a PHI node.
2737 */
Gordon Henriksen44dd8fb2007-10-08 18:14:39 +00002738unsigned LLVMCountIncoming(LLVMValueRef PhiNode);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002739
2740/**
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00002741 * Obtain an incoming value to a PHI node as an LLVMValueRef.
Gregory Szorc34c863a2012-03-21 03:54:29 +00002742 */
Gordon Henriksen44dd8fb2007-10-08 18:14:39 +00002743LLVMValueRef LLVMGetIncomingValue(LLVMValueRef PhiNode, unsigned Index);
Gregory Szorc34c863a2012-03-21 03:54:29 +00002744
2745/**
Daniel Dunbar06b9f9e2013-08-16 23:30:19 +00002746 * Obtain an incoming value to a PHI node as an LLVMBasicBlockRef.
Gregory Szorc34c863a2012-03-21 03:54:29 +00002747 */
Gordon Henriksen44dd8fb2007-10-08 18:14:39 +00002748LLVMBasicBlockRef LLVMGetIncomingBlock(LLVMValueRef PhiNode, unsigned Index);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002749
Gregory Szorc34c863a2012-03-21 03:54:29 +00002750/**
2751 * @}
2752 */
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002753
Gregory Szorc34c863a2012-03-21 03:54:29 +00002754/**
Amaury Sechetaad93532016-02-10 00:38:50 +00002755 * @defgroup LLVMCCoreValueInstructionExtractValue ExtractValue
2756 * @defgroup LLVMCCoreValueInstructionInsertValue InsertValue
2757 *
2758 * Functions in this group only apply to instructions that map to
2759 * llvm::ExtractValue and llvm::InsertValue instances.
2760 *
2761 * @{
2762 */
2763
2764/**
2765 * Obtain the number of indices.
Amaury Sechet053ac452016-02-17 22:51:03 +00002766 * NB: This also works on GEP.
Amaury Sechetaad93532016-02-10 00:38:50 +00002767 */
2768unsigned LLVMGetNumIndices(LLVMValueRef Inst);
2769
2770/**
2771 * Obtain the indices as an array.
2772 */
2773const unsigned *LLVMGetIndices(LLVMValueRef Inst);
2774
2775/**
2776 * @}
2777 */
2778
2779/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00002780 * @}
2781 */
2782
2783/**
2784 * @}
2785 */
2786
2787/**
2788 * @defgroup LLVMCCoreInstructionBuilder Instruction Builders
2789 *
2790 * An instruction builder represents a point within a basic block and is
2791 * the exclusive means of building instructions using the C interface.
2792 *
2793 * @{
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002794 */
2795
Erick Tryzelaar262332f2009-08-14 00:01:31 +00002796LLVMBuilderRef LLVMCreateBuilderInContext(LLVMContextRef C);
Gordon Henriksena735a9c2008-05-04 12:55:34 +00002797LLVMBuilderRef LLVMCreateBuilder(void);
Gordon Henriksen054817c2008-03-19 03:47:18 +00002798void LLVMPositionBuilder(LLVMBuilderRef Builder, LLVMBasicBlockRef Block,
2799 LLVMValueRef Instr);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002800void LLVMPositionBuilderBefore(LLVMBuilderRef Builder, LLVMValueRef Instr);
2801void LLVMPositionBuilderAtEnd(LLVMBuilderRef Builder, LLVMBasicBlockRef Block);
Gordon Henriksen265f7802008-03-19 01:11:35 +00002802LLVMBasicBlockRef LLVMGetInsertBlock(LLVMBuilderRef Builder);
Chris Lattner3d1f5522008-12-17 21:39:50 +00002803void LLVMClearInsertionPosition(LLVMBuilderRef Builder);
2804void LLVMInsertIntoBuilder(LLVMBuilderRef Builder, LLVMValueRef Instr);
Erick Tryzelaar9813bea2009-08-16 02:20:57 +00002805void LLVMInsertIntoBuilderWithName(LLVMBuilderRef Builder, LLVMValueRef Instr,
2806 const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002807void LLVMDisposeBuilder(LLVMBuilderRef Builder);
2808
Erick Tryzelaard8531fa2010-02-28 09:45:59 +00002809/* Metadata */
2810void LLVMSetCurrentDebugLocation(LLVMBuilderRef Builder, LLVMValueRef L);
2811LLVMValueRef LLVMGetCurrentDebugLocation(LLVMBuilderRef Builder);
2812void LLVMSetInstDebugLocation(LLVMBuilderRef Builder, LLVMValueRef Inst);
2813
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002814/* Terminators */
2815LLVMValueRef LLVMBuildRetVoid(LLVMBuilderRef);
2816LLVMValueRef LLVMBuildRet(LLVMBuilderRef, LLVMValueRef V);
Erick Tryzelaarfd529d72009-08-19 08:36:49 +00002817LLVMValueRef LLVMBuildAggregateRet(LLVMBuilderRef, LLVMValueRef *RetVals,
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002818 unsigned N);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002819LLVMValueRef LLVMBuildBr(LLVMBuilderRef, LLVMBasicBlockRef Dest);
2820LLVMValueRef LLVMBuildCondBr(LLVMBuilderRef, LLVMValueRef If,
2821 LLVMBasicBlockRef Then, LLVMBasicBlockRef Else);
2822LLVMValueRef LLVMBuildSwitch(LLVMBuilderRef, LLVMValueRef V,
2823 LLVMBasicBlockRef Else, unsigned NumCases);
Erick Tryzelaar0fb26ef2010-02-28 09:46:06 +00002824LLVMValueRef LLVMBuildIndirectBr(LLVMBuilderRef B, LLVMValueRef Addr,
2825 unsigned NumDests);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002826LLVMValueRef LLVMBuildInvoke(LLVMBuilderRef, LLVMValueRef Fn,
2827 LLVMValueRef *Args, unsigned NumArgs,
2828 LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch,
2829 const char *Name);
Benjamin Kramer5a6568832011-08-19 01:36:54 +00002830LLVMValueRef LLVMBuildLandingPad(LLVMBuilderRef B, LLVMTypeRef Ty,
Reid Kleckneref9828f2015-07-16 01:16:39 +00002831 LLVMValueRef PersFn, unsigned NumClauses,
2832 const char *Name);
Bill Wendlingf891bf82011-07-31 06:30:59 +00002833LLVMValueRef LLVMBuildResume(LLVMBuilderRef B, LLVMValueRef Exn);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002834LLVMValueRef LLVMBuildUnreachable(LLVMBuilderRef);
2835
Gordon Henriksen097102c2008-01-01 05:50:53 +00002836/* Add a case to the switch instruction */
2837void LLVMAddCase(LLVMValueRef Switch, LLVMValueRef OnVal,
2838 LLVMBasicBlockRef Dest);
2839
Erick Tryzelaar0fb26ef2010-02-28 09:46:06 +00002840/* Add a destination to the indirectbr instruction */
2841void LLVMAddDestination(LLVMValueRef IndirectBr, LLVMBasicBlockRef Dest);
2842
Amaury Sechete39e8532016-02-18 20:38:32 +00002843/* Get the number of clauses on the landingpad instruction */
2844unsigned LLVMGetNumClauses(LLVMValueRef LandingPad);
2845
2846/* Get the value of the clause at idnex Idx on the landingpad instruction */
2847LLVMValueRef LLVMGetClause(LLVMValueRef LandingPad, unsigned Idx);
2848
Bill Wendlingfae14752011-08-12 20:24:12 +00002849/* Add a catch or filter clause to the landingpad instruction */
2850void LLVMAddClause(LLVMValueRef LandingPad, LLVMValueRef ClauseVal);
2851
Amaury Sechete39e8532016-02-18 20:38:32 +00002852/* Get the 'cleanup' flag in the landingpad instruction */
2853LLVMBool LLVMIsCleanup(LLVMValueRef LandingPad);
2854
Bill Wendlingfae14752011-08-12 20:24:12 +00002855/* Set the 'cleanup' flag in the landingpad instruction */
2856void LLVMSetCleanup(LLVMValueRef LandingPad, LLVMBool Val);
2857
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002858/* Arithmetic */
2859LLVMValueRef LLVMBuildAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2860 const char *Name);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002861LLVMValueRef LLVMBuildNSWAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2862 const char *Name);
Erick Tryzelaar4c340c72010-02-28 05:51:43 +00002863LLVMValueRef LLVMBuildNUWAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2864 const char *Name);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002865LLVMValueRef LLVMBuildFAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2866 const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002867LLVMValueRef LLVMBuildSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2868 const char *Name);
Erick Tryzelaar4c340c72010-02-28 05:51:43 +00002869LLVMValueRef LLVMBuildNSWSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2870 const char *Name);
2871LLVMValueRef LLVMBuildNUWSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2872 const char *Name);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002873LLVMValueRef LLVMBuildFSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2874 const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002875LLVMValueRef LLVMBuildMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2876 const char *Name);
Erick Tryzelaar4c340c72010-02-28 05:51:43 +00002877LLVMValueRef LLVMBuildNSWMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2878 const char *Name);
2879LLVMValueRef LLVMBuildNUWMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2880 const char *Name);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002881LLVMValueRef LLVMBuildFMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2882 const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002883LLVMValueRef LLVMBuildUDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2884 const char *Name);
Manuel Jacob49fafb12016-10-04 23:32:42 +00002885LLVMValueRef LLVMBuildExactUDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2886 const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002887LLVMValueRef LLVMBuildSDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2888 const char *Name);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002889LLVMValueRef LLVMBuildExactSDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2890 const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002891LLVMValueRef LLVMBuildFDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2892 const char *Name);
2893LLVMValueRef LLVMBuildURem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2894 const char *Name);
2895LLVMValueRef LLVMBuildSRem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2896 const char *Name);
2897LLVMValueRef LLVMBuildFRem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2898 const char *Name);
2899LLVMValueRef LLVMBuildShl(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2900 const char *Name);
2901LLVMValueRef LLVMBuildLShr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2902 const char *Name);
2903LLVMValueRef LLVMBuildAShr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2904 const char *Name);
2905LLVMValueRef LLVMBuildAnd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2906 const char *Name);
2907LLVMValueRef LLVMBuildOr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2908 const char *Name);
2909LLVMValueRef LLVMBuildXor(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
2910 const char *Name);
Erick Tryzelaar31831792010-02-28 05:51:27 +00002911LLVMValueRef LLVMBuildBinOp(LLVMBuilderRef B, LLVMOpcode Op,
2912 LLVMValueRef LHS, LLVMValueRef RHS,
2913 const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002914LLVMValueRef LLVMBuildNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name);
Erick Tryzelaar4c340c72010-02-28 05:51:43 +00002915LLVMValueRef LLVMBuildNSWNeg(LLVMBuilderRef B, LLVMValueRef V,
2916 const char *Name);
2917LLVMValueRef LLVMBuildNUWNeg(LLVMBuilderRef B, LLVMValueRef V,
2918 const char *Name);
Dan Gohmanf919bd62009-09-28 21:51:41 +00002919LLVMValueRef LLVMBuildFNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002920LLVMValueRef LLVMBuildNot(LLVMBuilderRef, LLVMValueRef V, const char *Name);
2921
2922/* Memory */
2923LLVMValueRef LLVMBuildMalloc(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
2924LLVMValueRef LLVMBuildArrayMalloc(LLVMBuilderRef, LLVMTypeRef Ty,
2925 LLVMValueRef Val, const char *Name);
2926LLVMValueRef LLVMBuildAlloca(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
2927LLVMValueRef LLVMBuildArrayAlloca(LLVMBuilderRef, LLVMTypeRef Ty,
2928 LLVMValueRef Val, const char *Name);
2929LLVMValueRef LLVMBuildFree(LLVMBuilderRef, LLVMValueRef PointerVal);
2930LLVMValueRef LLVMBuildLoad(LLVMBuilderRef, LLVMValueRef PointerVal,
2931 const char *Name);
2932LLVMValueRef LLVMBuildStore(LLVMBuilderRef, LLVMValueRef Val, LLVMValueRef Ptr);
2933LLVMValueRef LLVMBuildGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
2934 LLVMValueRef *Indices, unsigned NumIndices,
2935 const char *Name);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002936LLVMValueRef LLVMBuildInBoundsGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
2937 LLVMValueRef *Indices, unsigned NumIndices,
2938 const char *Name);
2939LLVMValueRef LLVMBuildStructGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
2940 unsigned Idx, const char *Name);
2941LLVMValueRef LLVMBuildGlobalString(LLVMBuilderRef B, const char *Str,
2942 const char *Name);
2943LLVMValueRef LLVMBuildGlobalStringPtr(LLVMBuilderRef B, const char *Str,
2944 const char *Name);
Chris Lattner2cc6f9d2012-03-22 03:54:15 +00002945LLVMBool LLVMGetVolatile(LLVMValueRef MemoryAccessInst);
2946void LLVMSetVolatile(LLVMValueRef MemoryAccessInst, LLVMBool IsVolatile);
Andrew Wilkinsb7362ce2015-08-02 12:16:57 +00002947LLVMAtomicOrdering LLVMGetOrdering(LLVMValueRef MemoryAccessInst);
2948void LLVMSetOrdering(LLVMValueRef MemoryAccessInst, LLVMAtomicOrdering Ordering);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002949
2950/* Casts */
2951LLVMValueRef LLVMBuildTrunc(LLVMBuilderRef, LLVMValueRef Val,
2952 LLVMTypeRef DestTy, const char *Name);
2953LLVMValueRef LLVMBuildZExt(LLVMBuilderRef, LLVMValueRef Val,
2954 LLVMTypeRef DestTy, const char *Name);
2955LLVMValueRef LLVMBuildSExt(LLVMBuilderRef, LLVMValueRef Val,
2956 LLVMTypeRef DestTy, const char *Name);
2957LLVMValueRef LLVMBuildFPToUI(LLVMBuilderRef, LLVMValueRef Val,
2958 LLVMTypeRef DestTy, const char *Name);
2959LLVMValueRef LLVMBuildFPToSI(LLVMBuilderRef, LLVMValueRef Val,
2960 LLVMTypeRef DestTy, const char *Name);
2961LLVMValueRef LLVMBuildUIToFP(LLVMBuilderRef, LLVMValueRef Val,
2962 LLVMTypeRef DestTy, const char *Name);
2963LLVMValueRef LLVMBuildSIToFP(LLVMBuilderRef, LLVMValueRef Val,
2964 LLVMTypeRef DestTy, const char *Name);
2965LLVMValueRef LLVMBuildFPTrunc(LLVMBuilderRef, LLVMValueRef Val,
2966 LLVMTypeRef DestTy, const char *Name);
2967LLVMValueRef LLVMBuildFPExt(LLVMBuilderRef, LLVMValueRef Val,
2968 LLVMTypeRef DestTy, const char *Name);
2969LLVMValueRef LLVMBuildPtrToInt(LLVMBuilderRef, LLVMValueRef Val,
2970 LLVMTypeRef DestTy, const char *Name);
2971LLVMValueRef LLVMBuildIntToPtr(LLVMBuilderRef, LLVMValueRef Val,
2972 LLVMTypeRef DestTy, const char *Name);
2973LLVMValueRef LLVMBuildBitCast(LLVMBuilderRef, LLVMValueRef Val,
2974 LLVMTypeRef DestTy, const char *Name);
Matt Arsenaultb03bd4d2013-11-15 01:34:59 +00002975LLVMValueRef LLVMBuildAddrSpaceCast(LLVMBuilderRef, LLVMValueRef Val,
2976 LLVMTypeRef DestTy, const char *Name);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002977LLVMValueRef LLVMBuildZExtOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
2978 LLVMTypeRef DestTy, const char *Name);
2979LLVMValueRef LLVMBuildSExtOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
2980 LLVMTypeRef DestTy, const char *Name);
2981LLVMValueRef LLVMBuildTruncOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
2982 LLVMTypeRef DestTy, const char *Name);
Erick Tryzelaar31831792010-02-28 05:51:27 +00002983LLVMValueRef LLVMBuildCast(LLVMBuilderRef B, LLVMOpcode Op, LLVMValueRef Val,
2984 LLVMTypeRef DestTy, const char *Name);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002985LLVMValueRef LLVMBuildPointerCast(LLVMBuilderRef, LLVMValueRef Val,
2986 LLVMTypeRef DestTy, const char *Name);
Duncan Sands9d786d72009-11-23 10:49:03 +00002987LLVMValueRef LLVMBuildIntCast(LLVMBuilderRef, LLVMValueRef Val, /*Signed cast!*/
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00002988 LLVMTypeRef DestTy, const char *Name);
2989LLVMValueRef LLVMBuildFPCast(LLVMBuilderRef, LLVMValueRef Val,
2990 LLVMTypeRef DestTy, const char *Name);
Gordon Henriksenc23b66c2007-09-26 20:56:12 +00002991
2992/* Comparisons */
2993LLVMValueRef LLVMBuildICmp(LLVMBuilderRef, LLVMIntPredicate Op,
2994 LLVMValueRef LHS, LLVMValueRef RHS,
2995 const char *Name);
2996LLVMValueRef LLVMBuildFCmp(LLVMBuilderRef, LLVMRealPredicate Op,
2997 LLVMValueRef LHS, LLVMValueRef RHS,
2998 const char *Name);
2999
3000/* Miscellaneous instructions */
3001LLVMValueRef LLVMBuildPhi(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
3002LLVMValueRef LLVMBuildCall(LLVMBuilderRef, LLVMValueRef Fn,
3003 LLVMValueRef *Args, unsigned NumArgs,
3004 const char *Name);
3005LLVMValueRef LLVMBuildSelect(LLVMBuilderRef, LLVMValueRef If,
3006 LLVMValueRef Then, LLVMValueRef Else,
3007 const char *Name);
3008LLVMValueRef LLVMBuildVAArg(LLVMBuilderRef, LLVMValueRef List, LLVMTypeRef Ty,
3009 const char *Name);
3010LLVMValueRef LLVMBuildExtractElement(LLVMBuilderRef, LLVMValueRef VecVal,
3011 LLVMValueRef Index, const char *Name);
3012LLVMValueRef LLVMBuildInsertElement(LLVMBuilderRef, LLVMValueRef VecVal,
3013 LLVMValueRef EltVal, LLVMValueRef Index,
3014 const char *Name);
3015LLVMValueRef LLVMBuildShuffleVector(LLVMBuilderRef, LLVMValueRef V1,
3016 LLVMValueRef V2, LLVMValueRef Mask,
3017 const char *Name);
Dan Gohmand5104a52008-11-03 22:55:43 +00003018LLVMValueRef LLVMBuildExtractValue(LLVMBuilderRef, LLVMValueRef AggVal,
3019 unsigned Index, const char *Name);
3020LLVMValueRef LLVMBuildInsertValue(LLVMBuilderRef, LLVMValueRef AggVal,
3021 LLVMValueRef EltVal, unsigned Index,
3022 const char *Name);
Gordon Henriksen76a03742007-09-18 03:18:57 +00003023
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00003024LLVMValueRef LLVMBuildIsNull(LLVMBuilderRef, LLVMValueRef Val,
3025 const char *Name);
3026LLVMValueRef LLVMBuildIsNotNull(LLVMBuilderRef, LLVMValueRef Val,
3027 const char *Name);
3028LLVMValueRef LLVMBuildPtrDiff(LLVMBuilderRef, LLVMValueRef LHS,
3029 LLVMValueRef RHS, const char *Name);
Filip Pizlo0d3f7ec2013-11-20 00:07:49 +00003030LLVMValueRef LLVMBuildFence(LLVMBuilderRef B, LLVMAtomicOrdering ordering,
3031 LLVMBool singleThread, const char *Name);
3032LLVMValueRef LLVMBuildAtomicRMW(LLVMBuilderRef B, LLVMAtomicRMWBinOp op,
NAKAMURA Takumia3a81352013-10-23 17:56:29 +00003033 LLVMValueRef PTR, LLVMValueRef Val,
3034 LLVMAtomicOrdering ordering,
Carlo Kok8c6719b2013-04-23 13:21:19 +00003035 LLVMBool singleThread);
Mehdi Amini43165d92016-03-19 21:28:28 +00003036LLVMValueRef LLVMBuildAtomicCmpXchg(LLVMBuilderRef B, LLVMValueRef Ptr,
3037 LLVMValueRef Cmp, LLVMValueRef New,
3038 LLVMAtomicOrdering SuccessOrdering,
3039 LLVMAtomicOrdering FailureOrdering,
3040 LLVMBool SingleThread);
3041
3042LLVMBool LLVMIsAtomicSingleThread(LLVMValueRef AtomicInst);
3043void LLVMSetAtomicSingleThread(LLVMValueRef AtomicInst, LLVMBool SingleThread);
3044
3045LLVMAtomicOrdering LLVMGetCmpXchgSuccessOrdering(LLVMValueRef CmpXchgInst);
3046void LLVMSetCmpXchgSuccessOrdering(LLVMValueRef CmpXchgInst,
3047 LLVMAtomicOrdering Ordering);
3048LLVMAtomicOrdering LLVMGetCmpXchgFailureOrdering(LLVMValueRef CmpXchgInst);
3049void LLVMSetCmpXchgFailureOrdering(LLVMValueRef CmpXchgInst,
3050 LLVMAtomicOrdering Ordering);
Erick Tryzelaar3045b8b2009-08-16 02:19:59 +00003051
Gregory Szorc34c863a2012-03-21 03:54:29 +00003052/**
3053 * @}
3054 */
Gordon Henriksen34eb6d82007-12-19 22:30:40 +00003055
Gregory Szorc34c863a2012-03-21 03:54:29 +00003056/**
3057 * @defgroup LLVMCCoreModuleProvider Module Providers
3058 *
3059 * @{
3060 */
Gordon Henriksen0a68fe22007-12-12 01:04:30 +00003061
Gregory Szorc34c863a2012-03-21 03:54:29 +00003062/**
3063 * Changes the type of M so it can be passed to FunctionPassManagers and the
Jeffrey Yasskin091217b2010-01-27 20:34:15 +00003064 * JIT. They take ModuleProviders for historical reasons.
Gordon Henriksen0a68fe22007-12-12 01:04:30 +00003065 */
3066LLVMModuleProviderRef
3067LLVMCreateModuleProviderForExistingModule(LLVMModuleRef M);
3068
Gregory Szorc34c863a2012-03-21 03:54:29 +00003069/**
3070 * Destroys the module M.
Gordon Henriksen0a68fe22007-12-12 01:04:30 +00003071 */
Jeffrey Yasskin091217b2010-01-27 20:34:15 +00003072void LLVMDisposeModuleProvider(LLVMModuleProviderRef M);
Gordon Henriksen0a68fe22007-12-12 01:04:30 +00003073
Gregory Szorc34c863a2012-03-21 03:54:29 +00003074/**
3075 * @}
3076 */
Gordon Henriksen34eb6d82007-12-19 22:30:40 +00003077
Gregory Szorc34c863a2012-03-21 03:54:29 +00003078/**
3079 * @defgroup LLVMCCoreMemoryBuffers Memory Buffers
3080 *
3081 * @{
3082 */
Gordon Henriksen34eb6d82007-12-19 22:30:40 +00003083
Chris Lattner25963c62010-01-09 22:27:07 +00003084LLVMBool LLVMCreateMemoryBufferWithContentsOfFile(const char *Path,
3085 LLVMMemoryBufferRef *OutMemBuf,
3086 char **OutMessage);
3087LLVMBool LLVMCreateMemoryBufferWithSTDIN(LLVMMemoryBufferRef *OutMemBuf,
3088 char **OutMessage);
Bill Wendling526276a2013-02-14 19:11:28 +00003089LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRange(const char *InputData,
3090 size_t InputDataLength,
3091 const char *BufferName,
Bill Wendlingc9baa962013-02-14 19:39:14 +00003092 LLVMBool RequiresNullTerminator);
Bill Wendling526276a2013-02-14 19:11:28 +00003093LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRangeCopy(const char *InputData,
3094 size_t InputDataLength,
3095 const char *BufferName);
Tom Stellard62c03202013-04-18 19:50:53 +00003096const char *LLVMGetBufferStart(LLVMMemoryBufferRef MemBuf);
Tom Stellardb7fb7242013-04-16 23:12:51 +00003097size_t LLVMGetBufferSize(LLVMMemoryBufferRef MemBuf);
Gordon Henriksen34eb6d82007-12-19 22:30:40 +00003098void LLVMDisposeMemoryBuffer(LLVMMemoryBufferRef MemBuf);
3099
Gregory Szorc34c863a2012-03-21 03:54:29 +00003100/**
3101 * @}
3102 */
3103
3104/**
3105 * @defgroup LLVMCCorePassRegistry Pass Registry
3106 *
3107 * @{
3108 */
Owen Anderson4698c5d2010-10-07 17:55:47 +00003109
3110/** Return the global pass registry, for use with initialization functions.
Gregory Szorc34c863a2012-03-21 03:54:29 +00003111 @see llvm::PassRegistry::getPassRegistry */
Owen Anderson4698c5d2010-10-07 17:55:47 +00003112LLVMPassRegistryRef LLVMGetGlobalPassRegistry(void);
Gordon Henriksen878114b2008-03-16 04:20:44 +00003113
Gregory Szorc34c863a2012-03-21 03:54:29 +00003114/**
3115 * @}
3116 */
3117
3118/**
3119 * @defgroup LLVMCCorePassManagers Pass Managers
3120 *
3121 * @{
3122 */
Gordon Henriksen878114b2008-03-16 04:20:44 +00003123
3124/** Constructs a new whole-module pass pipeline. This type of pipeline is
3125 suitable for link-time optimization and whole-module transformations.
Gregory Szorc34c863a2012-03-21 03:54:29 +00003126 @see llvm::PassManager::PassManager */
Gordon Henriksena735a9c2008-05-04 12:55:34 +00003127LLVMPassManagerRef LLVMCreatePassManager(void);
Gordon Henriksen878114b2008-03-16 04:20:44 +00003128
3129/** Constructs a new function-by-function pass pipeline over the module
3130 provider. It does not take ownership of the module provider. This type of
3131 pipeline is suitable for code generation and JIT compilation tasks.
Gregory Szorc34c863a2012-03-21 03:54:29 +00003132 @see llvm::FunctionPassManager::FunctionPassManager */
Erick Tryzelaarad0e0cb2010-03-02 23:58:54 +00003133LLVMPassManagerRef LLVMCreateFunctionPassManagerForModule(LLVMModuleRef M);
3134
3135/** Deprecated: Use LLVMCreateFunctionPassManagerForModule instead. */
Gordon Henriksen878114b2008-03-16 04:20:44 +00003136LLVMPassManagerRef LLVMCreateFunctionPassManager(LLVMModuleProviderRef MP);
3137
3138/** Initializes, executes on the provided module, and finalizes all of the
3139 passes scheduled in the pass manager. Returns 1 if any of the passes
Gregory Szorc34c863a2012-03-21 03:54:29 +00003140 modified the module, 0 otherwise.
3141 @see llvm::PassManager::run(Module&) */
Chris Lattner25963c62010-01-09 22:27:07 +00003142LLVMBool LLVMRunPassManager(LLVMPassManagerRef PM, LLVMModuleRef M);
Gordon Henriksen878114b2008-03-16 04:20:44 +00003143
3144/** Initializes all of the function passes scheduled in the function pass
3145 manager. Returns 1 if any of the passes modified the module, 0 otherwise.
Gregory Szorc34c863a2012-03-21 03:54:29 +00003146 @see llvm::FunctionPassManager::doInitialization */
Chris Lattner25963c62010-01-09 22:27:07 +00003147LLVMBool LLVMInitializeFunctionPassManager(LLVMPassManagerRef FPM);
Gordon Henriksen878114b2008-03-16 04:20:44 +00003148
3149/** Executes all of the function passes scheduled in the function pass manager
3150 on the provided function. Returns 1 if any of the passes modified the
3151 function, false otherwise.
Gregory Szorc34c863a2012-03-21 03:54:29 +00003152 @see llvm::FunctionPassManager::run(Function&) */
Chris Lattner25963c62010-01-09 22:27:07 +00003153LLVMBool LLVMRunFunctionPassManager(LLVMPassManagerRef FPM, LLVMValueRef F);
Gordon Henriksen878114b2008-03-16 04:20:44 +00003154
3155/** Finalizes all of the function passes scheduled in in the function pass
3156 manager. Returns 1 if any of the passes modified the module, 0 otherwise.
Gregory Szorc34c863a2012-03-21 03:54:29 +00003157 @see llvm::FunctionPassManager::doFinalization */
Chris Lattner25963c62010-01-09 22:27:07 +00003158LLVMBool LLVMFinalizeFunctionPassManager(LLVMPassManagerRef FPM);
Gordon Henriksen878114b2008-03-16 04:20:44 +00003159
3160/** Frees the memory of a pass pipeline. For function pipelines, does not free
3161 the module provider.
Gregory Szorc34c863a2012-03-21 03:54:29 +00003162 @see llvm::PassManagerBase::~PassManagerBase. */
Gordon Henriksen878114b2008-03-16 04:20:44 +00003163void LLVMDisposePassManager(LLVMPassManagerRef PM);
3164
Gregory Szorc34c863a2012-03-21 03:54:29 +00003165/**
3166 * @}
3167 */
3168
3169/**
Duncan Sands1cba0a82013-02-17 16:35:51 +00003170 * @defgroup LLVMCCoreThreading Threading
3171 *
3172 * Handle the structures needed to make LLVM safe for multithreading.
3173 *
3174 * @{
3175 */
3176
Chandler Carruth39cd2162014-06-27 15:13:01 +00003177/** Deprecated: Multi-threading can only be enabled/disabled with the compile
3178 time define LLVM_ENABLE_THREADS. This function always returns
3179 LLVMIsMultithreaded(). */
Benjamin Kramer325ec892013-10-23 16:57:34 +00003180LLVMBool LLVMStartMultithreaded(void);
Duncan Sands1cba0a82013-02-17 16:35:51 +00003181
Chandler Carruth39cd2162014-06-27 15:13:01 +00003182/** Deprecated: Multi-threading can only be enabled/disabled with the compile
3183 time define LLVM_ENABLE_THREADS. */
Benjamin Kramer325ec892013-10-23 16:57:34 +00003184void LLVMStopMultithreaded(void);
Duncan Sands1cba0a82013-02-17 16:35:51 +00003185
3186/** Check whether LLVM is executing in thread-safe mode or not.
3187 @see llvm::llvm_is_multithreaded */
Benjamin Kramer325ec892013-10-23 16:57:34 +00003188LLVMBool LLVMIsMultithreaded(void);
Duncan Sands1cba0a82013-02-17 16:35:51 +00003189
3190/**
3191 * @}
3192 */
3193
3194/**
Gregory Szorc34c863a2012-03-21 03:54:29 +00003195 * @}
3196 */
3197
3198/**
3199 * @}
3200 */
Gordon Henriksen878114b2008-03-16 04:20:44 +00003201
Gordon Henriksen76a03742007-09-18 03:18:57 +00003202#ifdef __cplusplus
3203}
Eugene Zelenkoffec81c2015-11-04 22:32:32 +00003204#endif
Gordon Henriksen7330acd2007-10-05 23:59:36 +00003205
Eugene Zelenkoffec81c2015-11-04 22:32:32 +00003206#endif /* LLVM_C_CORE_H */