xref: /freebsd/contrib/llvm-project/llvm/include/llvm-c/Core.h (revision 18054d0220cfc8df9c9568c437bd6fbb59d53c3c)
1 /*===-- llvm-c/Core.h - Core Library C Interface ------------------*- C -*-===*\
2 |*                                                                            *|
3 |* Part of the LLVM Project, under the Apache License v2.0 with LLVM          *|
4 |* Exceptions.                                                                *|
5 |* See https://llvm.org/LICENSE.txt for license information.                  *|
6 |* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception                    *|
7 |*                                                                            *|
8 |*===----------------------------------------------------------------------===*|
9 |*                                                                            *|
10 |* This header declares the C interface to libLLVMCore.a, which implements    *|
11 |* the LLVM intermediate representation.                                      *|
12 |*                                                                            *|
13 \*===----------------------------------------------------------------------===*/
14 
15 #ifndef LLVM_C_CORE_H
16 #define LLVM_C_CORE_H
17 
18 #include "llvm-c/Deprecated.h"
19 #include "llvm-c/ErrorHandling.h"
20 #include "llvm-c/ExternC.h"
21 
22 #include "llvm-c/Types.h"
23 
24 LLVM_C_EXTERN_C_BEGIN
25 
26 /**
27  * @defgroup LLVMC LLVM-C: C interface to LLVM
28  *
29  * This module exposes parts of the LLVM library as a C API.
30  *
31  * @{
32  */
33 
34 /**
35  * @defgroup LLVMCTransforms Transforms
36  */
37 
38 /**
39  * @defgroup LLVMCCore Core
40  *
41  * This modules provide an interface to libLLVMCore, which implements
42  * the LLVM intermediate representation as well as other related types
43  * and utilities.
44  *
45  * Many exotic languages can interoperate with C code but have a harder time
46  * with C++ due to name mangling. So in addition to C, this interface enables
47  * tools written in such languages.
48  *
49  * @{
50  */
51 
52 /**
53  * @defgroup LLVMCCoreTypes Types and Enumerations
54  *
55  * @{
56  */
57 
58 /// External users depend on the following values being stable. It is not safe
59 /// to reorder them.
60 typedef enum {
61   /* Terminator Instructions */
62   LLVMRet            = 1,
63   LLVMBr             = 2,
64   LLVMSwitch         = 3,
65   LLVMIndirectBr     = 4,
66   LLVMInvoke         = 5,
67   /* removed 6 due to API changes */
68   LLVMUnreachable    = 7,
69   LLVMCallBr         = 67,
70 
71   /* Standard Unary Operators */
72   LLVMFNeg           = 66,
73 
74   /* Standard Binary Operators */
75   LLVMAdd            = 8,
76   LLVMFAdd           = 9,
77   LLVMSub            = 10,
78   LLVMFSub           = 11,
79   LLVMMul            = 12,
80   LLVMFMul           = 13,
81   LLVMUDiv           = 14,
82   LLVMSDiv           = 15,
83   LLVMFDiv           = 16,
84   LLVMURem           = 17,
85   LLVMSRem           = 18,
86   LLVMFRem           = 19,
87 
88   /* Logical Operators */
89   LLVMShl            = 20,
90   LLVMLShr           = 21,
91   LLVMAShr           = 22,
92   LLVMAnd            = 23,
93   LLVMOr             = 24,
94   LLVMXor            = 25,
95 
96   /* Memory Operators */
97   LLVMAlloca         = 26,
98   LLVMLoad           = 27,
99   LLVMStore          = 28,
100   LLVMGetElementPtr  = 29,
101 
102   /* Cast Operators */
103   LLVMTrunc          = 30,
104   LLVMZExt           = 31,
105   LLVMSExt           = 32,
106   LLVMFPToUI         = 33,
107   LLVMFPToSI         = 34,
108   LLVMUIToFP         = 35,
109   LLVMSIToFP         = 36,
110   LLVMFPTrunc        = 37,
111   LLVMFPExt          = 38,
112   LLVMPtrToInt       = 39,
113   LLVMIntToPtr       = 40,
114   LLVMBitCast        = 41,
115   LLVMAddrSpaceCast  = 60,
116 
117   /* Other Operators */
118   LLVMICmp           = 42,
119   LLVMFCmp           = 43,
120   LLVMPHI            = 44,
121   LLVMCall           = 45,
122   LLVMSelect         = 46,
123   LLVMUserOp1        = 47,
124   LLVMUserOp2        = 48,
125   LLVMVAArg          = 49,
126   LLVMExtractElement = 50,
127   LLVMInsertElement  = 51,
128   LLVMShuffleVector  = 52,
129   LLVMExtractValue   = 53,
130   LLVMInsertValue    = 54,
131   LLVMFreeze         = 68,
132 
133   /* Atomic operators */
134   LLVMFence          = 55,
135   LLVMAtomicCmpXchg  = 56,
136   LLVMAtomicRMW      = 57,
137 
138   /* Exception Handling Operators */
139   LLVMResume         = 58,
140   LLVMLandingPad     = 59,
141   LLVMCleanupRet     = 61,
142   LLVMCatchRet       = 62,
143   LLVMCatchPad       = 63,
144   LLVMCleanupPad     = 64,
145   LLVMCatchSwitch    = 65
146 } LLVMOpcode;
147 
148 typedef enum {
149   LLVMVoidTypeKind,      /**< type with no size */
150   LLVMHalfTypeKind,      /**< 16 bit floating point type */
151   LLVMFloatTypeKind,     /**< 32 bit floating point type */
152   LLVMDoubleTypeKind,    /**< 64 bit floating point type */
153   LLVMX86_FP80TypeKind,  /**< 80 bit floating point type (X87) */
154   LLVMFP128TypeKind,     /**< 128 bit floating point type (112-bit mantissa)*/
155   LLVMPPC_FP128TypeKind, /**< 128 bit floating point type (two 64-bits) */
156   LLVMLabelTypeKind,     /**< Labels */
157   LLVMIntegerTypeKind,   /**< Arbitrary bit width integers */
158   LLVMFunctionTypeKind,  /**< Functions */
159   LLVMStructTypeKind,    /**< Structures */
160   LLVMArrayTypeKind,     /**< Arrays */
161   LLVMPointerTypeKind,   /**< Pointers */
162   LLVMVectorTypeKind,    /**< Fixed width SIMD vector type */
163   LLVMMetadataTypeKind,  /**< Metadata */
164   LLVMX86_MMXTypeKind,   /**< X86 MMX */
165   LLVMTokenTypeKind,     /**< Tokens */
166   LLVMScalableVectorTypeKind, /**< Scalable SIMD vector type */
167   LLVMBFloatTypeKind,    /**< 16 bit brain floating point type */
168   LLVMX86_AMXTypeKind    /**< X86 AMX */
169 } LLVMTypeKind;
170 
171 typedef enum {
172   LLVMExternalLinkage,    /**< Externally visible function */
173   LLVMAvailableExternallyLinkage,
174   LLVMLinkOnceAnyLinkage, /**< Keep one copy of function when linking (inline)*/
175   LLVMLinkOnceODRLinkage, /**< Same, but only replaced by something
176                             equivalent. */
177   LLVMLinkOnceODRAutoHideLinkage, /**< Obsolete */
178   LLVMWeakAnyLinkage,     /**< Keep one copy of function when linking (weak) */
179   LLVMWeakODRLinkage,     /**< Same, but only replaced by something
180                             equivalent. */
181   LLVMAppendingLinkage,   /**< Special purpose, only applies to global arrays */
182   LLVMInternalLinkage,    /**< Rename collisions when linking (static
183                                functions) */
184   LLVMPrivateLinkage,     /**< Like Internal, but omit from symbol table */
185   LLVMDLLImportLinkage,   /**< Obsolete */
186   LLVMDLLExportLinkage,   /**< Obsolete */
187   LLVMExternalWeakLinkage,/**< ExternalWeak linkage description */
188   LLVMGhostLinkage,       /**< Obsolete */
189   LLVMCommonLinkage,      /**< Tentative definitions */
190   LLVMLinkerPrivateLinkage, /**< Like Private, but linker removes. */
191   LLVMLinkerPrivateWeakLinkage /**< Like LinkerPrivate, but is weak. */
192 } LLVMLinkage;
193 
194 typedef enum {
195   LLVMDefaultVisibility,  /**< The GV is visible */
196   LLVMHiddenVisibility,   /**< The GV is hidden */
197   LLVMProtectedVisibility /**< The GV is protected */
198 } LLVMVisibility;
199 
200 typedef enum {
201   LLVMNoUnnamedAddr,    /**< Address of the GV is significant. */
202   LLVMLocalUnnamedAddr, /**< Address of the GV is locally insignificant. */
203   LLVMGlobalUnnamedAddr /**< Address of the GV is globally insignificant. */
204 } LLVMUnnamedAddr;
205 
206 typedef enum {
207   LLVMDefaultStorageClass   = 0,
208   LLVMDLLImportStorageClass = 1, /**< Function to be imported from DLL. */
209   LLVMDLLExportStorageClass = 2  /**< Function to be accessible from DLL. */
210 } LLVMDLLStorageClass;
211 
212 typedef enum {
213   LLVMCCallConv             = 0,
214   LLVMFastCallConv          = 8,
215   LLVMColdCallConv          = 9,
216   LLVMGHCCallConv           = 10,
217   LLVMHiPECallConv          = 11,
218   LLVMWebKitJSCallConv      = 12,
219   LLVMAnyRegCallConv        = 13,
220   LLVMPreserveMostCallConv  = 14,
221   LLVMPreserveAllCallConv   = 15,
222   LLVMSwiftCallConv         = 16,
223   LLVMCXXFASTTLSCallConv    = 17,
224   LLVMX86StdcallCallConv    = 64,
225   LLVMX86FastcallCallConv   = 65,
226   LLVMARMAPCSCallConv       = 66,
227   LLVMARMAAPCSCallConv      = 67,
228   LLVMARMAAPCSVFPCallConv   = 68,
229   LLVMMSP430INTRCallConv    = 69,
230   LLVMX86ThisCallCallConv   = 70,
231   LLVMPTXKernelCallConv     = 71,
232   LLVMPTXDeviceCallConv     = 72,
233   LLVMSPIRFUNCCallConv      = 75,
234   LLVMSPIRKERNELCallConv    = 76,
235   LLVMIntelOCLBICallConv    = 77,
236   LLVMX8664SysVCallConv     = 78,
237   LLVMWin64CallConv         = 79,
238   LLVMX86VectorCallCallConv = 80,
239   LLVMHHVMCallConv          = 81,
240   LLVMHHVMCCallConv         = 82,
241   LLVMX86INTRCallConv       = 83,
242   LLVMAVRINTRCallConv       = 84,
243   LLVMAVRSIGNALCallConv     = 85,
244   LLVMAVRBUILTINCallConv    = 86,
245   LLVMAMDGPUVSCallConv      = 87,
246   LLVMAMDGPUGSCallConv      = 88,
247   LLVMAMDGPUPSCallConv      = 89,
248   LLVMAMDGPUCSCallConv      = 90,
249   LLVMAMDGPUKERNELCallConv  = 91,
250   LLVMX86RegCallCallConv    = 92,
251   LLVMAMDGPUHSCallConv      = 93,
252   LLVMMSP430BUILTINCallConv = 94,
253   LLVMAMDGPULSCallConv      = 95,
254   LLVMAMDGPUESCallConv      = 96
255 } LLVMCallConv;
256 
257 typedef enum {
258   LLVMArgumentValueKind,
259   LLVMBasicBlockValueKind,
260   LLVMMemoryUseValueKind,
261   LLVMMemoryDefValueKind,
262   LLVMMemoryPhiValueKind,
263 
264   LLVMFunctionValueKind,
265   LLVMGlobalAliasValueKind,
266   LLVMGlobalIFuncValueKind,
267   LLVMGlobalVariableValueKind,
268   LLVMBlockAddressValueKind,
269   LLVMConstantExprValueKind,
270   LLVMConstantArrayValueKind,
271   LLVMConstantStructValueKind,
272   LLVMConstantVectorValueKind,
273 
274   LLVMUndefValueValueKind,
275   LLVMConstantAggregateZeroValueKind,
276   LLVMConstantDataArrayValueKind,
277   LLVMConstantDataVectorValueKind,
278   LLVMConstantIntValueKind,
279   LLVMConstantFPValueKind,
280   LLVMConstantPointerNullValueKind,
281   LLVMConstantTokenNoneValueKind,
282 
283   LLVMMetadataAsValueValueKind,
284   LLVMInlineAsmValueKind,
285 
286   LLVMInstructionValueKind,
287   LLVMPoisonValueValueKind
288 } LLVMValueKind;
289 
290 typedef enum {
291   LLVMIntEQ = 32, /**< equal */
292   LLVMIntNE,      /**< not equal */
293   LLVMIntUGT,     /**< unsigned greater than */
294   LLVMIntUGE,     /**< unsigned greater or equal */
295   LLVMIntULT,     /**< unsigned less than */
296   LLVMIntULE,     /**< unsigned less or equal */
297   LLVMIntSGT,     /**< signed greater than */
298   LLVMIntSGE,     /**< signed greater or equal */
299   LLVMIntSLT,     /**< signed less than */
300   LLVMIntSLE      /**< signed less or equal */
301 } LLVMIntPredicate;
302 
303 typedef enum {
304   LLVMRealPredicateFalse, /**< Always false (always folded) */
305   LLVMRealOEQ,            /**< True if ordered and equal */
306   LLVMRealOGT,            /**< True if ordered and greater than */
307   LLVMRealOGE,            /**< True if ordered and greater than or equal */
308   LLVMRealOLT,            /**< True if ordered and less than */
309   LLVMRealOLE,            /**< True if ordered and less than or equal */
310   LLVMRealONE,            /**< True if ordered and operands are unequal */
311   LLVMRealORD,            /**< True if ordered (no nans) */
312   LLVMRealUNO,            /**< True if unordered: isnan(X) | isnan(Y) */
313   LLVMRealUEQ,            /**< True if unordered or equal */
314   LLVMRealUGT,            /**< True if unordered or greater than */
315   LLVMRealUGE,            /**< True if unordered, greater than, or equal */
316   LLVMRealULT,            /**< True if unordered or less than */
317   LLVMRealULE,            /**< True if unordered, less than, or equal */
318   LLVMRealUNE,            /**< True if unordered or not equal */
319   LLVMRealPredicateTrue   /**< Always true (always folded) */
320 } LLVMRealPredicate;
321 
322 typedef enum {
323   LLVMLandingPadCatch,    /**< A catch clause   */
324   LLVMLandingPadFilter    /**< A filter clause  */
325 } LLVMLandingPadClauseTy;
326 
327 typedef enum {
328   LLVMNotThreadLocal = 0,
329   LLVMGeneralDynamicTLSModel,
330   LLVMLocalDynamicTLSModel,
331   LLVMInitialExecTLSModel,
332   LLVMLocalExecTLSModel
333 } LLVMThreadLocalMode;
334 
335 typedef enum {
336   LLVMAtomicOrderingNotAtomic = 0, /**< A load or store which is not atomic */
337   LLVMAtomicOrderingUnordered = 1, /**< Lowest level of atomicity, guarantees
338                                      somewhat sane results, lock free. */
339   LLVMAtomicOrderingMonotonic = 2, /**< guarantees that if you take all the
340                                      operations affecting a specific address,
341                                      a consistent ordering exists */
342   LLVMAtomicOrderingAcquire = 4, /**< Acquire provides a barrier of the sort
343                                    necessary to acquire a lock to access other
344                                    memory with normal loads and stores. */
345   LLVMAtomicOrderingRelease = 5, /**< Release is similar to Acquire, but with
346                                    a barrier of the sort necessary to release
347                                    a lock. */
348   LLVMAtomicOrderingAcquireRelease = 6, /**< provides both an Acquire and a
349                                           Release barrier (for fences and
350                                           operations which both read and write
351                                            memory). */
352   LLVMAtomicOrderingSequentiallyConsistent = 7 /**< provides Acquire semantics
353                                                  for loads and Release
354                                                  semantics for stores.
355                                                  Additionally, it guarantees
356                                                  that a total ordering exists
357                                                  between all
358                                                  SequentiallyConsistent
359                                                  operations. */
360 } LLVMAtomicOrdering;
361 
362 typedef enum {
363     LLVMAtomicRMWBinOpXchg, /**< Set the new value and return the one old */
364     LLVMAtomicRMWBinOpAdd, /**< Add a value and return the old one */
365     LLVMAtomicRMWBinOpSub, /**< Subtract a value and return the old one */
366     LLVMAtomicRMWBinOpAnd, /**< And a value and return the old one */
367     LLVMAtomicRMWBinOpNand, /**< Not-And a value and return the old one */
368     LLVMAtomicRMWBinOpOr, /**< OR a value and return the old one */
369     LLVMAtomicRMWBinOpXor, /**< Xor a value and return the old one */
370     LLVMAtomicRMWBinOpMax, /**< Sets the value if it's greater than the
371                              original using a signed comparison and return
372                              the old one */
373     LLVMAtomicRMWBinOpMin, /**< Sets the value if it's Smaller than the
374                              original using a signed comparison and return
375                              the old one */
376     LLVMAtomicRMWBinOpUMax, /**< Sets the value if it's greater than the
377                              original using an unsigned comparison and return
378                              the old one */
379     LLVMAtomicRMWBinOpUMin, /**< Sets the value if it's greater than the
380                               original using an unsigned comparison and return
381                               the old one */
382     LLVMAtomicRMWBinOpFAdd, /**< Add a floating point value and return the
383                               old one */
384     LLVMAtomicRMWBinOpFSub /**< Subtract a floating point value and return the
385                              old one */
386 } LLVMAtomicRMWBinOp;
387 
388 typedef enum {
389     LLVMDSError,
390     LLVMDSWarning,
391     LLVMDSRemark,
392     LLVMDSNote
393 } LLVMDiagnosticSeverity;
394 
395 typedef enum {
396   LLVMInlineAsmDialectATT,
397   LLVMInlineAsmDialectIntel
398 } LLVMInlineAsmDialect;
399 
400 typedef enum {
401   /**
402    * Emits an error if two values disagree, otherwise the resulting value is
403    * that of the operands.
404    *
405    * @see Module::ModFlagBehavior::Error
406    */
407   LLVMModuleFlagBehaviorError,
408   /**
409    * Emits a warning if two values disagree. The result value will be the
410    * operand for the flag from the first module being linked.
411    *
412    * @see Module::ModFlagBehavior::Warning
413    */
414   LLVMModuleFlagBehaviorWarning,
415   /**
416    * Adds a requirement that another module flag be present and have a
417    * specified value after linking is performed. The value must be a metadata
418    * pair, where the first element of the pair is the ID of the module flag
419    * to be restricted, and the second element of the pair is the value the
420    * module flag should be restricted to. This behavior can be used to
421    * restrict the allowable results (via triggering of an error) of linking
422    * IDs with the **Override** behavior.
423    *
424    * @see Module::ModFlagBehavior::Require
425    */
426   LLVMModuleFlagBehaviorRequire,
427   /**
428    * Uses the specified value, regardless of the behavior or value of the
429    * other module. If both modules specify **Override**, but the values
430    * differ, an error will be emitted.
431    *
432    * @see Module::ModFlagBehavior::Override
433    */
434   LLVMModuleFlagBehaviorOverride,
435   /**
436    * Appends the two values, which are required to be metadata nodes.
437    *
438    * @see Module::ModFlagBehavior::Append
439    */
440   LLVMModuleFlagBehaviorAppend,
441   /**
442    * Appends the two values, which are required to be metadata
443    * nodes. However, duplicate entries in the second list are dropped
444    * during the append operation.
445    *
446    * @see Module::ModFlagBehavior::AppendUnique
447    */
448   LLVMModuleFlagBehaviorAppendUnique,
449 } LLVMModuleFlagBehavior;
450 
451 /**
452  * Attribute index are either LLVMAttributeReturnIndex,
453  * LLVMAttributeFunctionIndex or a parameter number from 1 to N.
454  */
455 enum {
456   LLVMAttributeReturnIndex = 0U,
457   // ISO C restricts enumerator values to range of 'int'
458   // (4294967295 is too large)
459   // LLVMAttributeFunctionIndex = ~0U,
460   LLVMAttributeFunctionIndex = -1,
461 };
462 
463 typedef unsigned LLVMAttributeIndex;
464 
465 /**
466  * @}
467  */
468 
469 void LLVMInitializeCore(LLVMPassRegistryRef R);
470 
471 /** Deallocate and destroy all ManagedStatic variables.
472     @see llvm::llvm_shutdown
473     @see ManagedStatic */
474 void LLVMShutdown(void);
475 
476 /*===-- Error handling ----------------------------------------------------===*/
477 
478 char *LLVMCreateMessage(const char *Message);
479 void LLVMDisposeMessage(char *Message);
480 
481 /**
482  * @defgroup LLVMCCoreContext Contexts
483  *
484  * Contexts are execution states for the core LLVM IR system.
485  *
486  * Most types are tied to a context instance. Multiple contexts can
487  * exist simultaneously. A single context is not thread safe. However,
488  * different contexts can execute on different threads simultaneously.
489  *
490  * @{
491  */
492 
493 typedef void (*LLVMDiagnosticHandler)(LLVMDiagnosticInfoRef, void *);
494 typedef void (*LLVMYieldCallback)(LLVMContextRef, void *);
495 
496 /**
497  * Create a new context.
498  *
499  * Every call to this function should be paired with a call to
500  * LLVMContextDispose() or the context will leak memory.
501  */
502 LLVMContextRef LLVMContextCreate(void);
503 
504 /**
505  * Obtain the global context instance.
506  */
507 LLVMContextRef LLVMGetGlobalContext(void);
508 
509 /**
510  * Set the diagnostic handler for this context.
511  */
512 void LLVMContextSetDiagnosticHandler(LLVMContextRef C,
513                                      LLVMDiagnosticHandler Handler,
514                                      void *DiagnosticContext);
515 
516 /**
517  * Get the diagnostic handler of this context.
518  */
519 LLVMDiagnosticHandler LLVMContextGetDiagnosticHandler(LLVMContextRef C);
520 
521 /**
522  * Get the diagnostic context of this context.
523  */
524 void *LLVMContextGetDiagnosticContext(LLVMContextRef C);
525 
526 /**
527  * Set the yield callback function for this context.
528  *
529  * @see LLVMContext::setYieldCallback()
530  */
531 void LLVMContextSetYieldCallback(LLVMContextRef C, LLVMYieldCallback Callback,
532                                  void *OpaqueHandle);
533 
534 /**
535  * Retrieve whether the given context is set to discard all value names.
536  *
537  * @see LLVMContext::shouldDiscardValueNames()
538  */
539 LLVMBool LLVMContextShouldDiscardValueNames(LLVMContextRef C);
540 
541 /**
542  * Set whether the given context discards all value names.
543  *
544  * If true, only the names of GlobalValue objects will be available in the IR.
545  * This can be used to save memory and runtime, especially in release mode.
546  *
547  * @see LLVMContext::setDiscardValueNames()
548  */
549 void LLVMContextSetDiscardValueNames(LLVMContextRef C, LLVMBool Discard);
550 
551 /**
552  * Destroy a context instance.
553  *
554  * This should be called for every call to LLVMContextCreate() or memory
555  * will be leaked.
556  */
557 void LLVMContextDispose(LLVMContextRef C);
558 
559 /**
560  * Return a string representation of the DiagnosticInfo. Use
561  * LLVMDisposeMessage to free the string.
562  *
563  * @see DiagnosticInfo::print()
564  */
565 char *LLVMGetDiagInfoDescription(LLVMDiagnosticInfoRef DI);
566 
567 /**
568  * Return an enum LLVMDiagnosticSeverity.
569  *
570  * @see DiagnosticInfo::getSeverity()
571  */
572 LLVMDiagnosticSeverity LLVMGetDiagInfoSeverity(LLVMDiagnosticInfoRef DI);
573 
574 unsigned LLVMGetMDKindIDInContext(LLVMContextRef C, const char *Name,
575                                   unsigned SLen);
576 unsigned LLVMGetMDKindID(const char *Name, unsigned SLen);
577 
578 /**
579  * Return an unique id given the name of a enum attribute,
580  * or 0 if no attribute by that name exists.
581  *
582  * See http://llvm.org/docs/LangRef.html#parameter-attributes
583  * and http://llvm.org/docs/LangRef.html#function-attributes
584  * for the list of available attributes.
585  *
586  * NB: Attribute names and/or id are subject to change without
587  * going through the C API deprecation cycle.
588  */
589 unsigned LLVMGetEnumAttributeKindForName(const char *Name, size_t SLen);
590 unsigned LLVMGetLastEnumAttributeKind(void);
591 
592 /**
593  * Create an enum attribute.
594  */
595 LLVMAttributeRef LLVMCreateEnumAttribute(LLVMContextRef C, unsigned KindID,
596                                          uint64_t Val);
597 
598 /**
599  * Get the unique id corresponding to the enum attribute
600  * passed as argument.
601  */
602 unsigned LLVMGetEnumAttributeKind(LLVMAttributeRef A);
603 
604 /**
605  * Get the enum attribute's value. 0 is returned if none exists.
606  */
607 uint64_t LLVMGetEnumAttributeValue(LLVMAttributeRef A);
608 
609 /**
610  * Create a type attribute
611  */
612 LLVMAttributeRef LLVMCreateTypeAttribute(LLVMContextRef C, unsigned KindID,
613                                          LLVMTypeRef type_ref);
614 
615 /**
616  * Get the type attribute's value.
617  */
618 LLVMTypeRef LLVMGetTypeAttributeValue(LLVMAttributeRef A);
619 
620 /**
621  * Create a string attribute.
622  */
623 LLVMAttributeRef LLVMCreateStringAttribute(LLVMContextRef C,
624                                            const char *K, unsigned KLength,
625                                            const char *V, unsigned VLength);
626 
627 /**
628  * Get the string attribute's kind.
629  */
630 const char *LLVMGetStringAttributeKind(LLVMAttributeRef A, unsigned *Length);
631 
632 /**
633  * Get the string attribute's value.
634  */
635 const char *LLVMGetStringAttributeValue(LLVMAttributeRef A, unsigned *Length);
636 
637 /**
638  * Check for the different types of attributes.
639  */
640 LLVMBool LLVMIsEnumAttribute(LLVMAttributeRef A);
641 LLVMBool LLVMIsStringAttribute(LLVMAttributeRef A);
642 LLVMBool LLVMIsTypeAttribute(LLVMAttributeRef A);
643 
644 /**
645  * Obtain a Type from a context by its registered name.
646  */
647 LLVMTypeRef LLVMGetTypeByName2(LLVMContextRef C, const char *Name);
648 
649 /**
650  * @}
651  */
652 
653 /**
654  * @defgroup LLVMCCoreModule Modules
655  *
656  * Modules represent the top-level structure in an LLVM program. An LLVM
657  * module is effectively a translation unit or a collection of
658  * translation units merged together.
659  *
660  * @{
661  */
662 
663 /**
664  * Create a new, empty module in the global context.
665  *
666  * This is equivalent to calling LLVMModuleCreateWithNameInContext with
667  * LLVMGetGlobalContext() as the context parameter.
668  *
669  * Every invocation should be paired with LLVMDisposeModule() or memory
670  * will be leaked.
671  */
672 LLVMModuleRef LLVMModuleCreateWithName(const char *ModuleID);
673 
674 /**
675  * Create a new, empty module in a specific context.
676  *
677  * Every invocation should be paired with LLVMDisposeModule() or memory
678  * will be leaked.
679  */
680 LLVMModuleRef LLVMModuleCreateWithNameInContext(const char *ModuleID,
681                                                 LLVMContextRef C);
682 /**
683  * Return an exact copy of the specified module.
684  */
685 LLVMModuleRef LLVMCloneModule(LLVMModuleRef M);
686 
687 /**
688  * Destroy a module instance.
689  *
690  * This must be called for every created module or memory will be
691  * leaked.
692  */
693 void LLVMDisposeModule(LLVMModuleRef M);
694 
695 /**
696  * Obtain the identifier of a module.
697  *
698  * @param M Module to obtain identifier of
699  * @param Len Out parameter which holds the length of the returned string.
700  * @return The identifier of M.
701  * @see Module::getModuleIdentifier()
702  */
703 const char *LLVMGetModuleIdentifier(LLVMModuleRef M, size_t *Len);
704 
705 /**
706  * Set the identifier of a module to a string Ident with length Len.
707  *
708  * @param M The module to set identifier
709  * @param Ident The string to set M's identifier to
710  * @param Len Length of Ident
711  * @see Module::setModuleIdentifier()
712  */
713 void LLVMSetModuleIdentifier(LLVMModuleRef M, const char *Ident, size_t Len);
714 
715 /**
716  * Obtain the module's original source file name.
717  *
718  * @param M Module to obtain the name of
719  * @param Len Out parameter which holds the length of the returned string
720  * @return The original source file name of M
721  * @see Module::getSourceFileName()
722  */
723 const char *LLVMGetSourceFileName(LLVMModuleRef M, size_t *Len);
724 
725 /**
726  * Set the original source file name of a module to a string Name with length
727  * Len.
728  *
729  * @param M The module to set the source file name of
730  * @param Name The string to set M's source file name to
731  * @param Len Length of Name
732  * @see Module::setSourceFileName()
733  */
734 void LLVMSetSourceFileName(LLVMModuleRef M, const char *Name, size_t Len);
735 
736 /**
737  * Obtain the data layout for a module.
738  *
739  * @see Module::getDataLayoutStr()
740  *
741  * LLVMGetDataLayout is DEPRECATED, as the name is not only incorrect,
742  * but match the name of another method on the module. Prefer the use
743  * of LLVMGetDataLayoutStr, which is not ambiguous.
744  */
745 const char *LLVMGetDataLayoutStr(LLVMModuleRef M);
746 const char *LLVMGetDataLayout(LLVMModuleRef M);
747 
748 /**
749  * Set the data layout for a module.
750  *
751  * @see Module::setDataLayout()
752  */
753 void LLVMSetDataLayout(LLVMModuleRef M, const char *DataLayoutStr);
754 
755 /**
756  * Obtain the target triple for a module.
757  *
758  * @see Module::getTargetTriple()
759  */
760 const char *LLVMGetTarget(LLVMModuleRef M);
761 
762 /**
763  * Set the target triple for a module.
764  *
765  * @see Module::setTargetTriple()
766  */
767 void LLVMSetTarget(LLVMModuleRef M, const char *Triple);
768 
769 /**
770  * Returns the module flags as an array of flag-key-value triples.  The caller
771  * is responsible for freeing this array by calling
772  * \c LLVMDisposeModuleFlagsMetadata.
773  *
774  * @see Module::getModuleFlagsMetadata()
775  */
776 LLVMModuleFlagEntry *LLVMCopyModuleFlagsMetadata(LLVMModuleRef M, size_t *Len);
777 
778 /**
779  * Destroys module flags metadata entries.
780  */
781 void LLVMDisposeModuleFlagsMetadata(LLVMModuleFlagEntry *Entries);
782 
783 /**
784  * Returns the flag behavior for a module flag entry at a specific index.
785  *
786  * @see Module::ModuleFlagEntry::Behavior
787  */
788 LLVMModuleFlagBehavior
789 LLVMModuleFlagEntriesGetFlagBehavior(LLVMModuleFlagEntry *Entries,
790                                      unsigned Index);
791 
792 /**
793  * Returns the key for a module flag entry at a specific index.
794  *
795  * @see Module::ModuleFlagEntry::Key
796  */
797 const char *LLVMModuleFlagEntriesGetKey(LLVMModuleFlagEntry *Entries,
798                                         unsigned Index, size_t *Len);
799 
800 /**
801  * Returns the metadata for a module flag entry at a specific index.
802  *
803  * @see Module::ModuleFlagEntry::Val
804  */
805 LLVMMetadataRef LLVMModuleFlagEntriesGetMetadata(LLVMModuleFlagEntry *Entries,
806                                                  unsigned Index);
807 
808 /**
809  * Add a module-level flag to the module-level flags metadata if it doesn't
810  * already exist.
811  *
812  * @see Module::getModuleFlag()
813  */
814 LLVMMetadataRef LLVMGetModuleFlag(LLVMModuleRef M,
815                                   const char *Key, size_t KeyLen);
816 
817 /**
818  * Add a module-level flag to the module-level flags metadata if it doesn't
819  * already exist.
820  *
821  * @see Module::addModuleFlag()
822  */
823 void LLVMAddModuleFlag(LLVMModuleRef M, LLVMModuleFlagBehavior Behavior,
824                        const char *Key, size_t KeyLen,
825                        LLVMMetadataRef Val);
826 
827 /**
828  * Dump a representation of a module to stderr.
829  *
830  * @see Module::dump()
831  */
832 void LLVMDumpModule(LLVMModuleRef M);
833 
834 /**
835  * Print a representation of a module to a file. The ErrorMessage needs to be
836  * disposed with LLVMDisposeMessage. Returns 0 on success, 1 otherwise.
837  *
838  * @see Module::print()
839  */
840 LLVMBool LLVMPrintModuleToFile(LLVMModuleRef M, const char *Filename,
841                                char **ErrorMessage);
842 
843 /**
844  * Return a string representation of the module. Use
845  * LLVMDisposeMessage to free the string.
846  *
847  * @see Module::print()
848  */
849 char *LLVMPrintModuleToString(LLVMModuleRef M);
850 
851 /**
852  * Get inline assembly for a module.
853  *
854  * @see Module::getModuleInlineAsm()
855  */
856 const char *LLVMGetModuleInlineAsm(LLVMModuleRef M, size_t *Len);
857 
858 /**
859  * Set inline assembly for a module.
860  *
861  * @see Module::setModuleInlineAsm()
862  */
863 void LLVMSetModuleInlineAsm2(LLVMModuleRef M, const char *Asm, size_t Len);
864 
865 /**
866  * Append inline assembly to a module.
867  *
868  * @see Module::appendModuleInlineAsm()
869  */
870 void LLVMAppendModuleInlineAsm(LLVMModuleRef M, const char *Asm, size_t Len);
871 
872 /**
873  * Create the specified uniqued inline asm string.
874  *
875  * @see InlineAsm::get()
876  */
877 LLVMValueRef LLVMGetInlineAsm(LLVMTypeRef Ty, char *AsmString,
878                               size_t AsmStringSize, char *Constraints,
879                               size_t ConstraintsSize, LLVMBool HasSideEffects,
880                               LLVMBool IsAlignStack,
881                               LLVMInlineAsmDialect Dialect, LLVMBool CanThrow);
882 
883 /**
884  * Obtain the context to which this module is associated.
885  *
886  * @see Module::getContext()
887  */
888 LLVMContextRef LLVMGetModuleContext(LLVMModuleRef M);
889 
890 /** Deprecated: Use LLVMGetTypeByName2 instead. */
891 LLVMTypeRef LLVMGetTypeByName(LLVMModuleRef M, const char *Name);
892 
893 /**
894  * Obtain an iterator to the first NamedMDNode in a Module.
895  *
896  * @see llvm::Module::named_metadata_begin()
897  */
898 LLVMNamedMDNodeRef LLVMGetFirstNamedMetadata(LLVMModuleRef M);
899 
900 /**
901  * Obtain an iterator to the last NamedMDNode in a Module.
902  *
903  * @see llvm::Module::named_metadata_end()
904  */
905 LLVMNamedMDNodeRef LLVMGetLastNamedMetadata(LLVMModuleRef M);
906 
907 /**
908  * Advance a NamedMDNode iterator to the next NamedMDNode.
909  *
910  * Returns NULL if the iterator was already at the end and there are no more
911  * named metadata nodes.
912  */
913 LLVMNamedMDNodeRef LLVMGetNextNamedMetadata(LLVMNamedMDNodeRef NamedMDNode);
914 
915 /**
916  * Decrement a NamedMDNode iterator to the previous NamedMDNode.
917  *
918  * Returns NULL if the iterator was already at the beginning and there are
919  * no previous named metadata nodes.
920  */
921 LLVMNamedMDNodeRef LLVMGetPreviousNamedMetadata(LLVMNamedMDNodeRef NamedMDNode);
922 
923 /**
924  * Retrieve a NamedMDNode with the given name, returning NULL if no such
925  * node exists.
926  *
927  * @see llvm::Module::getNamedMetadata()
928  */
929 LLVMNamedMDNodeRef LLVMGetNamedMetadata(LLVMModuleRef M,
930                                         const char *Name, size_t NameLen);
931 
932 /**
933  * Retrieve a NamedMDNode with the given name, creating a new node if no such
934  * node exists.
935  *
936  * @see llvm::Module::getOrInsertNamedMetadata()
937  */
938 LLVMNamedMDNodeRef LLVMGetOrInsertNamedMetadata(LLVMModuleRef M,
939                                                 const char *Name,
940                                                 size_t NameLen);
941 
942 /**
943  * Retrieve the name of a NamedMDNode.
944  *
945  * @see llvm::NamedMDNode::getName()
946  */
947 const char *LLVMGetNamedMetadataName(LLVMNamedMDNodeRef NamedMD,
948                                      size_t *NameLen);
949 
950 /**
951  * Obtain the number of operands for named metadata in a module.
952  *
953  * @see llvm::Module::getNamedMetadata()
954  */
955 unsigned LLVMGetNamedMetadataNumOperands(LLVMModuleRef M, const char *Name);
956 
957 /**
958  * Obtain the named metadata operands for a module.
959  *
960  * The passed LLVMValueRef pointer should refer to an array of
961  * LLVMValueRef at least LLVMGetNamedMetadataNumOperands long. This
962  * array will be populated with the LLVMValueRef instances. Each
963  * instance corresponds to a llvm::MDNode.
964  *
965  * @see llvm::Module::getNamedMetadata()
966  * @see llvm::MDNode::getOperand()
967  */
968 void LLVMGetNamedMetadataOperands(LLVMModuleRef M, const char *Name,
969                                   LLVMValueRef *Dest);
970 
971 /**
972  * Add an operand to named metadata.
973  *
974  * @see llvm::Module::getNamedMetadata()
975  * @see llvm::MDNode::addOperand()
976  */
977 void LLVMAddNamedMetadataOperand(LLVMModuleRef M, const char *Name,
978                                  LLVMValueRef Val);
979 
980 /**
981  * Return the directory of the debug location for this value, which must be
982  * an llvm::Instruction, llvm::GlobalVariable, or llvm::Function.
983  *
984  * @see llvm::Instruction::getDebugLoc()
985  * @see llvm::GlobalVariable::getDebugInfo()
986  * @see llvm::Function::getSubprogram()
987  */
988 const char *LLVMGetDebugLocDirectory(LLVMValueRef Val, unsigned *Length);
989 
990 /**
991  * Return the filename of the debug location for this value, which must be
992  * an llvm::Instruction, llvm::GlobalVariable, or llvm::Function.
993  *
994  * @see llvm::Instruction::getDebugLoc()
995  * @see llvm::GlobalVariable::getDebugInfo()
996  * @see llvm::Function::getSubprogram()
997  */
998 const char *LLVMGetDebugLocFilename(LLVMValueRef Val, unsigned *Length);
999 
1000 /**
1001  * Return the line number of the debug location for this value, which must be
1002  * an llvm::Instruction, llvm::GlobalVariable, or llvm::Function.
1003  *
1004  * @see llvm::Instruction::getDebugLoc()
1005  * @see llvm::GlobalVariable::getDebugInfo()
1006  * @see llvm::Function::getSubprogram()
1007  */
1008 unsigned LLVMGetDebugLocLine(LLVMValueRef Val);
1009 
1010 /**
1011  * Return the column number of the debug location for this value, which must be
1012  * an llvm::Instruction.
1013  *
1014  * @see llvm::Instruction::getDebugLoc()
1015  */
1016 unsigned LLVMGetDebugLocColumn(LLVMValueRef Val);
1017 
1018 /**
1019  * Add a function to a module under a specified name.
1020  *
1021  * @see llvm::Function::Create()
1022  */
1023 LLVMValueRef LLVMAddFunction(LLVMModuleRef M, const char *Name,
1024                              LLVMTypeRef FunctionTy);
1025 
1026 /**
1027  * Obtain a Function value from a Module by its name.
1028  *
1029  * The returned value corresponds to a llvm::Function value.
1030  *
1031  * @see llvm::Module::getFunction()
1032  */
1033 LLVMValueRef LLVMGetNamedFunction(LLVMModuleRef M, const char *Name);
1034 
1035 /**
1036  * Obtain an iterator to the first Function in a Module.
1037  *
1038  * @see llvm::Module::begin()
1039  */
1040 LLVMValueRef LLVMGetFirstFunction(LLVMModuleRef M);
1041 
1042 /**
1043  * Obtain an iterator to the last Function in a Module.
1044  *
1045  * @see llvm::Module::end()
1046  */
1047 LLVMValueRef LLVMGetLastFunction(LLVMModuleRef M);
1048 
1049 /**
1050  * Advance a Function iterator to the next Function.
1051  *
1052  * Returns NULL if the iterator was already at the end and there are no more
1053  * functions.
1054  */
1055 LLVMValueRef LLVMGetNextFunction(LLVMValueRef Fn);
1056 
1057 /**
1058  * Decrement a Function iterator to the previous Function.
1059  *
1060  * Returns NULL if the iterator was already at the beginning and there are
1061  * no previous functions.
1062  */
1063 LLVMValueRef LLVMGetPreviousFunction(LLVMValueRef Fn);
1064 
1065 /** Deprecated: Use LLVMSetModuleInlineAsm2 instead. */
1066 void LLVMSetModuleInlineAsm(LLVMModuleRef M, const char *Asm);
1067 
1068 /**
1069  * @}
1070  */
1071 
1072 /**
1073  * @defgroup LLVMCCoreType Types
1074  *
1075  * Types represent the type of a value.
1076  *
1077  * Types are associated with a context instance. The context internally
1078  * deduplicates types so there is only 1 instance of a specific type
1079  * alive at a time. In other words, a unique type is shared among all
1080  * consumers within a context.
1081  *
1082  * A Type in the C API corresponds to llvm::Type.
1083  *
1084  * Types have the following hierarchy:
1085  *
1086  *   types:
1087  *     integer type
1088  *     real type
1089  *     function type
1090  *     sequence types:
1091  *       array type
1092  *       pointer type
1093  *       vector type
1094  *     void type
1095  *     label type
1096  *     opaque type
1097  *
1098  * @{
1099  */
1100 
1101 /**
1102  * Obtain the enumerated type of a Type instance.
1103  *
1104  * @see llvm::Type:getTypeID()
1105  */
1106 LLVMTypeKind LLVMGetTypeKind(LLVMTypeRef Ty);
1107 
1108 /**
1109  * Whether the type has a known size.
1110  *
1111  * Things that don't have a size are abstract types, labels, and void.a
1112  *
1113  * @see llvm::Type::isSized()
1114  */
1115 LLVMBool LLVMTypeIsSized(LLVMTypeRef Ty);
1116 
1117 /**
1118  * Obtain the context to which this type instance is associated.
1119  *
1120  * @see llvm::Type::getContext()
1121  */
1122 LLVMContextRef LLVMGetTypeContext(LLVMTypeRef Ty);
1123 
1124 /**
1125  * Dump a representation of a type to stderr.
1126  *
1127  * @see llvm::Type::dump()
1128  */
1129 void LLVMDumpType(LLVMTypeRef Val);
1130 
1131 /**
1132  * Return a string representation of the type. Use
1133  * LLVMDisposeMessage to free the string.
1134  *
1135  * @see llvm::Type::print()
1136  */
1137 char *LLVMPrintTypeToString(LLVMTypeRef Val);
1138 
1139 /**
1140  * @defgroup LLVMCCoreTypeInt Integer Types
1141  *
1142  * Functions in this section operate on integer types.
1143  *
1144  * @{
1145  */
1146 
1147 /**
1148  * Obtain an integer type from a context with specified bit width.
1149  */
1150 LLVMTypeRef LLVMInt1TypeInContext(LLVMContextRef C);
1151 LLVMTypeRef LLVMInt8TypeInContext(LLVMContextRef C);
1152 LLVMTypeRef LLVMInt16TypeInContext(LLVMContextRef C);
1153 LLVMTypeRef LLVMInt32TypeInContext(LLVMContextRef C);
1154 LLVMTypeRef LLVMInt64TypeInContext(LLVMContextRef C);
1155 LLVMTypeRef LLVMInt128TypeInContext(LLVMContextRef C);
1156 LLVMTypeRef LLVMIntTypeInContext(LLVMContextRef C, unsigned NumBits);
1157 
1158 /**
1159  * Obtain an integer type from the global context with a specified bit
1160  * width.
1161  */
1162 LLVMTypeRef LLVMInt1Type(void);
1163 LLVMTypeRef LLVMInt8Type(void);
1164 LLVMTypeRef LLVMInt16Type(void);
1165 LLVMTypeRef LLVMInt32Type(void);
1166 LLVMTypeRef LLVMInt64Type(void);
1167 LLVMTypeRef LLVMInt128Type(void);
1168 LLVMTypeRef LLVMIntType(unsigned NumBits);
1169 unsigned LLVMGetIntTypeWidth(LLVMTypeRef IntegerTy);
1170 
1171 /**
1172  * @}
1173  */
1174 
1175 /**
1176  * @defgroup LLVMCCoreTypeFloat Floating Point Types
1177  *
1178  * @{
1179  */
1180 
1181 /**
1182  * Obtain a 16-bit floating point type from a context.
1183  */
1184 LLVMTypeRef LLVMHalfTypeInContext(LLVMContextRef C);
1185 
1186 /**
1187  * Obtain a 16-bit brain floating point type from a context.
1188  */
1189 LLVMTypeRef LLVMBFloatTypeInContext(LLVMContextRef C);
1190 
1191 /**
1192  * Obtain a 32-bit floating point type from a context.
1193  */
1194 LLVMTypeRef LLVMFloatTypeInContext(LLVMContextRef C);
1195 
1196 /**
1197  * Obtain a 64-bit floating point type from a context.
1198  */
1199 LLVMTypeRef LLVMDoubleTypeInContext(LLVMContextRef C);
1200 
1201 /**
1202  * Obtain a 80-bit floating point type (X87) from a context.
1203  */
1204 LLVMTypeRef LLVMX86FP80TypeInContext(LLVMContextRef C);
1205 
1206 /**
1207  * Obtain a 128-bit floating point type (112-bit mantissa) from a
1208  * context.
1209  */
1210 LLVMTypeRef LLVMFP128TypeInContext(LLVMContextRef C);
1211 
1212 /**
1213  * Obtain a 128-bit floating point type (two 64-bits) from a context.
1214  */
1215 LLVMTypeRef LLVMPPCFP128TypeInContext(LLVMContextRef C);
1216 
1217 /**
1218  * Obtain a floating point type from the global context.
1219  *
1220  * These map to the functions in this group of the same name.
1221  */
1222 LLVMTypeRef LLVMHalfType(void);
1223 LLVMTypeRef LLVMBFloatType(void);
1224 LLVMTypeRef LLVMFloatType(void);
1225 LLVMTypeRef LLVMDoubleType(void);
1226 LLVMTypeRef LLVMX86FP80Type(void);
1227 LLVMTypeRef LLVMFP128Type(void);
1228 LLVMTypeRef LLVMPPCFP128Type(void);
1229 
1230 /**
1231  * @}
1232  */
1233 
1234 /**
1235  * @defgroup LLVMCCoreTypeFunction Function Types
1236  *
1237  * @{
1238  */
1239 
1240 /**
1241  * Obtain a function type consisting of a specified signature.
1242  *
1243  * The function is defined as a tuple of a return Type, a list of
1244  * parameter types, and whether the function is variadic.
1245  */
1246 LLVMTypeRef LLVMFunctionType(LLVMTypeRef ReturnType,
1247                              LLVMTypeRef *ParamTypes, unsigned ParamCount,
1248                              LLVMBool IsVarArg);
1249 
1250 /**
1251  * Returns whether a function type is variadic.
1252  */
1253 LLVMBool LLVMIsFunctionVarArg(LLVMTypeRef FunctionTy);
1254 
1255 /**
1256  * Obtain the Type this function Type returns.
1257  */
1258 LLVMTypeRef LLVMGetReturnType(LLVMTypeRef FunctionTy);
1259 
1260 /**
1261  * Obtain the number of parameters this function accepts.
1262  */
1263 unsigned LLVMCountParamTypes(LLVMTypeRef FunctionTy);
1264 
1265 /**
1266  * Obtain the types of a function's parameters.
1267  *
1268  * The Dest parameter should point to a pre-allocated array of
1269  * LLVMTypeRef at least LLVMCountParamTypes() large. On return, the
1270  * first LLVMCountParamTypes() entries in the array will be populated
1271  * with LLVMTypeRef instances.
1272  *
1273  * @param FunctionTy The function type to operate on.
1274  * @param Dest Memory address of an array to be filled with result.
1275  */
1276 void LLVMGetParamTypes(LLVMTypeRef FunctionTy, LLVMTypeRef *Dest);
1277 
1278 /**
1279  * @}
1280  */
1281 
1282 /**
1283  * @defgroup LLVMCCoreTypeStruct Structure Types
1284  *
1285  * These functions relate to LLVMTypeRef instances.
1286  *
1287  * @see llvm::StructType
1288  *
1289  * @{
1290  */
1291 
1292 /**
1293  * Create a new structure type in a context.
1294  *
1295  * A structure is specified by a list of inner elements/types and
1296  * whether these can be packed together.
1297  *
1298  * @see llvm::StructType::create()
1299  */
1300 LLVMTypeRef LLVMStructTypeInContext(LLVMContextRef C, LLVMTypeRef *ElementTypes,
1301                                     unsigned ElementCount, LLVMBool Packed);
1302 
1303 /**
1304  * Create a new structure type in the global context.
1305  *
1306  * @see llvm::StructType::create()
1307  */
1308 LLVMTypeRef LLVMStructType(LLVMTypeRef *ElementTypes, unsigned ElementCount,
1309                            LLVMBool Packed);
1310 
1311 /**
1312  * Create an empty structure in a context having a specified name.
1313  *
1314  * @see llvm::StructType::create()
1315  */
1316 LLVMTypeRef LLVMStructCreateNamed(LLVMContextRef C, const char *Name);
1317 
1318 /**
1319  * Obtain the name of a structure.
1320  *
1321  * @see llvm::StructType::getName()
1322  */
1323 const char *LLVMGetStructName(LLVMTypeRef Ty);
1324 
1325 /**
1326  * Set the contents of a structure type.
1327  *
1328  * @see llvm::StructType::setBody()
1329  */
1330 void LLVMStructSetBody(LLVMTypeRef StructTy, LLVMTypeRef *ElementTypes,
1331                        unsigned ElementCount, LLVMBool Packed);
1332 
1333 /**
1334  * Get the number of elements defined inside the structure.
1335  *
1336  * @see llvm::StructType::getNumElements()
1337  */
1338 unsigned LLVMCountStructElementTypes(LLVMTypeRef StructTy);
1339 
1340 /**
1341  * Get the elements within a structure.
1342  *
1343  * The function is passed the address of a pre-allocated array of
1344  * LLVMTypeRef at least LLVMCountStructElementTypes() long. After
1345  * invocation, this array will be populated with the structure's
1346  * elements. The objects in the destination array will have a lifetime
1347  * of the structure type itself, which is the lifetime of the context it
1348  * is contained in.
1349  */
1350 void LLVMGetStructElementTypes(LLVMTypeRef StructTy, LLVMTypeRef *Dest);
1351 
1352 /**
1353  * Get the type of the element at a given index in the structure.
1354  *
1355  * @see llvm::StructType::getTypeAtIndex()
1356  */
1357 LLVMTypeRef LLVMStructGetTypeAtIndex(LLVMTypeRef StructTy, unsigned i);
1358 
1359 /**
1360  * Determine whether a structure is packed.
1361  *
1362  * @see llvm::StructType::isPacked()
1363  */
1364 LLVMBool LLVMIsPackedStruct(LLVMTypeRef StructTy);
1365 
1366 /**
1367  * Determine whether a structure is opaque.
1368  *
1369  * @see llvm::StructType::isOpaque()
1370  */
1371 LLVMBool LLVMIsOpaqueStruct(LLVMTypeRef StructTy);
1372 
1373 /**
1374  * Determine whether a structure is literal.
1375  *
1376  * @see llvm::StructType::isLiteral()
1377  */
1378 LLVMBool LLVMIsLiteralStruct(LLVMTypeRef StructTy);
1379 
1380 /**
1381  * @}
1382  */
1383 
1384 /**
1385  * @defgroup LLVMCCoreTypeSequential Sequential Types
1386  *
1387  * Sequential types represents "arrays" of types. This is a super class
1388  * for array, vector, and pointer types.
1389  *
1390  * @{
1391  */
1392 
1393 /**
1394  * Obtain the type of elements within a sequential type.
1395  *
1396  * This works on array, vector, and pointer types.
1397  *
1398  * @see llvm::SequentialType::getElementType()
1399  */
1400 LLVMTypeRef LLVMGetElementType(LLVMTypeRef Ty);
1401 
1402 /**
1403  * Returns type's subtypes
1404  *
1405  * @see llvm::Type::subtypes()
1406  */
1407 void LLVMGetSubtypes(LLVMTypeRef Tp, LLVMTypeRef *Arr);
1408 
1409 /**
1410  *  Return the number of types in the derived type.
1411  *
1412  * @see llvm::Type::getNumContainedTypes()
1413  */
1414 unsigned LLVMGetNumContainedTypes(LLVMTypeRef Tp);
1415 
1416 /**
1417  * Create a fixed size array type that refers to a specific type.
1418  *
1419  * The created type will exist in the context that its element type
1420  * exists in.
1421  *
1422  * @see llvm::ArrayType::get()
1423  */
1424 LLVMTypeRef LLVMArrayType(LLVMTypeRef ElementType, unsigned ElementCount);
1425 
1426 /**
1427  * Obtain the length of an array type.
1428  *
1429  * This only works on types that represent arrays.
1430  *
1431  * @see llvm::ArrayType::getNumElements()
1432  */
1433 unsigned LLVMGetArrayLength(LLVMTypeRef ArrayTy);
1434 
1435 /**
1436  * Create a pointer type that points to a defined type.
1437  *
1438  * The created type will exist in the context that its pointee type
1439  * exists in.
1440  *
1441  * @see llvm::PointerType::get()
1442  */
1443 LLVMTypeRef LLVMPointerType(LLVMTypeRef ElementType, unsigned AddressSpace);
1444 
1445 /**
1446  * Obtain the address space of a pointer type.
1447  *
1448  * This only works on types that represent pointers.
1449  *
1450  * @see llvm::PointerType::getAddressSpace()
1451  */
1452 unsigned LLVMGetPointerAddressSpace(LLVMTypeRef PointerTy);
1453 
1454 /**
1455  * Create a vector type that contains a defined type and has a specific
1456  * number of elements.
1457  *
1458  * The created type will exist in the context thats its element type
1459  * exists in.
1460  *
1461  * @see llvm::VectorType::get()
1462  */
1463 LLVMTypeRef LLVMVectorType(LLVMTypeRef ElementType, unsigned ElementCount);
1464 
1465 /**
1466  * Create a vector type that contains a defined type and has a scalable
1467  * number of elements.
1468  *
1469  * The created type will exist in the context thats its element type
1470  * exists in.
1471  *
1472  * @see llvm::ScalableVectorType::get()
1473  */
1474 LLVMTypeRef LLVMScalableVectorType(LLVMTypeRef ElementType,
1475                                    unsigned ElementCount);
1476 
1477 /**
1478  * Obtain the (possibly scalable) number of elements in a vector type.
1479  *
1480  * This only works on types that represent vectors (fixed or scalable).
1481  *
1482  * @see llvm::VectorType::getNumElements()
1483  */
1484 unsigned LLVMGetVectorSize(LLVMTypeRef VectorTy);
1485 
1486 /**
1487  * @}
1488  */
1489 
1490 /**
1491  * @defgroup LLVMCCoreTypeOther Other Types
1492  *
1493  * @{
1494  */
1495 
1496 /**
1497  * Create a void type in a context.
1498  */
1499 LLVMTypeRef LLVMVoidTypeInContext(LLVMContextRef C);
1500 
1501 /**
1502  * Create a label type in a context.
1503  */
1504 LLVMTypeRef LLVMLabelTypeInContext(LLVMContextRef C);
1505 
1506 /**
1507  * Create a X86 MMX type in a context.
1508  */
1509 LLVMTypeRef LLVMX86MMXTypeInContext(LLVMContextRef C);
1510 
1511 /**
1512  * Create a X86 AMX type in a context.
1513  */
1514 LLVMTypeRef LLVMX86AMXTypeInContext(LLVMContextRef C);
1515 
1516 /**
1517  * Create a token type in a context.
1518  */
1519 LLVMTypeRef LLVMTokenTypeInContext(LLVMContextRef C);
1520 
1521 /**
1522  * Create a metadata type in a context.
1523  */
1524 LLVMTypeRef LLVMMetadataTypeInContext(LLVMContextRef C);
1525 
1526 /**
1527  * These are similar to the above functions except they operate on the
1528  * global context.
1529  */
1530 LLVMTypeRef LLVMVoidType(void);
1531 LLVMTypeRef LLVMLabelType(void);
1532 LLVMTypeRef LLVMX86MMXType(void);
1533 LLVMTypeRef LLVMX86AMXType(void);
1534 
1535 /**
1536  * @}
1537  */
1538 
1539 /**
1540  * @}
1541  */
1542 
1543 /**
1544  * @defgroup LLVMCCoreValues Values
1545  *
1546  * The bulk of LLVM's object model consists of values, which comprise a very
1547  * rich type hierarchy.
1548  *
1549  * LLVMValueRef essentially represents llvm::Value. There is a rich
1550  * hierarchy of classes within this type. Depending on the instance
1551  * obtained, not all APIs are available.
1552  *
1553  * Callers can determine the type of an LLVMValueRef by calling the
1554  * LLVMIsA* family of functions (e.g. LLVMIsAArgument()). These
1555  * functions are defined by a macro, so it isn't obvious which are
1556  * available by looking at the Doxygen source code. Instead, look at the
1557  * source definition of LLVM_FOR_EACH_VALUE_SUBCLASS and note the list
1558  * of value names given. These value names also correspond to classes in
1559  * the llvm::Value hierarchy.
1560  *
1561  * @{
1562  */
1563 
1564 #define LLVM_FOR_EACH_VALUE_SUBCLASS(macro) \
1565   macro(Argument)                           \
1566   macro(BasicBlock)                         \
1567   macro(InlineAsm)                          \
1568   macro(User)                               \
1569     macro(Constant)                         \
1570       macro(BlockAddress)                   \
1571       macro(ConstantAggregateZero)          \
1572       macro(ConstantArray)                  \
1573       macro(ConstantDataSequential)         \
1574         macro(ConstantDataArray)            \
1575         macro(ConstantDataVector)           \
1576       macro(ConstantExpr)                   \
1577       macro(ConstantFP)                     \
1578       macro(ConstantInt)                    \
1579       macro(ConstantPointerNull)            \
1580       macro(ConstantStruct)                 \
1581       macro(ConstantTokenNone)              \
1582       macro(ConstantVector)                 \
1583       macro(GlobalValue)                    \
1584         macro(GlobalAlias)                  \
1585         macro(GlobalObject)                 \
1586           macro(Function)                   \
1587           macro(GlobalVariable)             \
1588           macro(GlobalIFunc)                \
1589       macro(UndefValue)                     \
1590       macro(PoisonValue)                    \
1591     macro(Instruction)                      \
1592       macro(UnaryOperator)                  \
1593       macro(BinaryOperator)                 \
1594       macro(CallInst)                       \
1595         macro(IntrinsicInst)                \
1596           macro(DbgInfoIntrinsic)           \
1597             macro(DbgVariableIntrinsic)     \
1598               macro(DbgDeclareInst)         \
1599             macro(DbgLabelInst)             \
1600           macro(MemIntrinsic)               \
1601             macro(MemCpyInst)               \
1602             macro(MemMoveInst)              \
1603             macro(MemSetInst)               \
1604       macro(CmpInst)                        \
1605         macro(FCmpInst)                     \
1606         macro(ICmpInst)                     \
1607       macro(ExtractElementInst)             \
1608       macro(GetElementPtrInst)              \
1609       macro(InsertElementInst)              \
1610       macro(InsertValueInst)                \
1611       macro(LandingPadInst)                 \
1612       macro(PHINode)                        \
1613       macro(SelectInst)                     \
1614       macro(ShuffleVectorInst)              \
1615       macro(StoreInst)                      \
1616       macro(BranchInst)                     \
1617       macro(IndirectBrInst)                 \
1618       macro(InvokeInst)                     \
1619       macro(ReturnInst)                     \
1620       macro(SwitchInst)                     \
1621       macro(UnreachableInst)                \
1622       macro(ResumeInst)                     \
1623       macro(CleanupReturnInst)              \
1624       macro(CatchReturnInst)                \
1625       macro(CatchSwitchInst)                \
1626       macro(CallBrInst)                     \
1627       macro(FuncletPadInst)                 \
1628         macro(CatchPadInst)                 \
1629         macro(CleanupPadInst)               \
1630       macro(UnaryInstruction)               \
1631         macro(AllocaInst)                   \
1632         macro(CastInst)                     \
1633           macro(AddrSpaceCastInst)          \
1634           macro(BitCastInst)                \
1635           macro(FPExtInst)                  \
1636           macro(FPToSIInst)                 \
1637           macro(FPToUIInst)                 \
1638           macro(FPTruncInst)                \
1639           macro(IntToPtrInst)               \
1640           macro(PtrToIntInst)               \
1641           macro(SExtInst)                   \
1642           macro(SIToFPInst)                 \
1643           macro(TruncInst)                  \
1644           macro(UIToFPInst)                 \
1645           macro(ZExtInst)                   \
1646         macro(ExtractValueInst)             \
1647         macro(LoadInst)                     \
1648         macro(VAArgInst)                    \
1649         macro(FreezeInst)                   \
1650       macro(AtomicCmpXchgInst)              \
1651       macro(AtomicRMWInst)                  \
1652       macro(FenceInst)
1653 
1654 /**
1655  * @defgroup LLVMCCoreValueGeneral General APIs
1656  *
1657  * Functions in this section work on all LLVMValueRef instances,
1658  * regardless of their sub-type. They correspond to functions available
1659  * on llvm::Value.
1660  *
1661  * @{
1662  */
1663 
1664 /**
1665  * Obtain the type of a value.
1666  *
1667  * @see llvm::Value::getType()
1668  */
1669 LLVMTypeRef LLVMTypeOf(LLVMValueRef Val);
1670 
1671 /**
1672  * Obtain the enumerated type of a Value instance.
1673  *
1674  * @see llvm::Value::getValueID()
1675  */
1676 LLVMValueKind LLVMGetValueKind(LLVMValueRef Val);
1677 
1678 /**
1679  * Obtain the string name of a value.
1680  *
1681  * @see llvm::Value::getName()
1682  */
1683 const char *LLVMGetValueName2(LLVMValueRef Val, size_t *Length);
1684 
1685 /**
1686  * Set the string name of a value.
1687  *
1688  * @see llvm::Value::setName()
1689  */
1690 void LLVMSetValueName2(LLVMValueRef Val, const char *Name, size_t NameLen);
1691 
1692 /**
1693  * Dump a representation of a value to stderr.
1694  *
1695  * @see llvm::Value::dump()
1696  */
1697 void LLVMDumpValue(LLVMValueRef Val);
1698 
1699 /**
1700  * Return a string representation of the value. Use
1701  * LLVMDisposeMessage to free the string.
1702  *
1703  * @see llvm::Value::print()
1704  */
1705 char *LLVMPrintValueToString(LLVMValueRef Val);
1706 
1707 /**
1708  * Replace all uses of a value with another one.
1709  *
1710  * @see llvm::Value::replaceAllUsesWith()
1711  */
1712 void LLVMReplaceAllUsesWith(LLVMValueRef OldVal, LLVMValueRef NewVal);
1713 
1714 /**
1715  * Determine whether the specified value instance is constant.
1716  */
1717 LLVMBool LLVMIsConstant(LLVMValueRef Val);
1718 
1719 /**
1720  * Determine whether a value instance is undefined.
1721  */
1722 LLVMBool LLVMIsUndef(LLVMValueRef Val);
1723 
1724 /**
1725  * Determine whether a value instance is poisonous.
1726  */
1727 LLVMBool LLVMIsPoison(LLVMValueRef Val);
1728 
1729 /**
1730  * Convert value instances between types.
1731  *
1732  * Internally, an LLVMValueRef is "pinned" to a specific type. This
1733  * series of functions allows you to cast an instance to a specific
1734  * type.
1735  *
1736  * If the cast is not valid for the specified type, NULL is returned.
1737  *
1738  * @see llvm::dyn_cast_or_null<>
1739  */
1740 #define LLVM_DECLARE_VALUE_CAST(name) \
1741   LLVMValueRef LLVMIsA##name(LLVMValueRef Val);
1742 LLVM_FOR_EACH_VALUE_SUBCLASS(LLVM_DECLARE_VALUE_CAST)
1743 
1744 LLVMValueRef LLVMIsAMDNode(LLVMValueRef Val);
1745 LLVMValueRef LLVMIsAMDString(LLVMValueRef Val);
1746 
1747 /** Deprecated: Use LLVMGetValueName2 instead. */
1748 const char *LLVMGetValueName(LLVMValueRef Val);
1749 /** Deprecated: Use LLVMSetValueName2 instead. */
1750 void LLVMSetValueName(LLVMValueRef Val, const char *Name);
1751 
1752 /**
1753  * @}
1754  */
1755 
1756 /**
1757  * @defgroup LLVMCCoreValueUses Usage
1758  *
1759  * This module defines functions that allow you to inspect the uses of a
1760  * LLVMValueRef.
1761  *
1762  * It is possible to obtain an LLVMUseRef for any LLVMValueRef instance.
1763  * Each LLVMUseRef (which corresponds to a llvm::Use instance) holds a
1764  * llvm::User and llvm::Value.
1765  *
1766  * @{
1767  */
1768 
1769 /**
1770  * Obtain the first use of a value.
1771  *
1772  * Uses are obtained in an iterator fashion. First, call this function
1773  * to obtain a reference to the first use. Then, call LLVMGetNextUse()
1774  * on that instance and all subsequently obtained instances until
1775  * LLVMGetNextUse() returns NULL.
1776  *
1777  * @see llvm::Value::use_begin()
1778  */
1779 LLVMUseRef LLVMGetFirstUse(LLVMValueRef Val);
1780 
1781 /**
1782  * Obtain the next use of a value.
1783  *
1784  * This effectively advances the iterator. It returns NULL if you are on
1785  * the final use and no more are available.
1786  */
1787 LLVMUseRef LLVMGetNextUse(LLVMUseRef U);
1788 
1789 /**
1790  * Obtain the user value for a user.
1791  *
1792  * The returned value corresponds to a llvm::User type.
1793  *
1794  * @see llvm::Use::getUser()
1795  */
1796 LLVMValueRef LLVMGetUser(LLVMUseRef U);
1797 
1798 /**
1799  * Obtain the value this use corresponds to.
1800  *
1801  * @see llvm::Use::get().
1802  */
1803 LLVMValueRef LLVMGetUsedValue(LLVMUseRef U);
1804 
1805 /**
1806  * @}
1807  */
1808 
1809 /**
1810  * @defgroup LLVMCCoreValueUser User value
1811  *
1812  * Function in this group pertain to LLVMValueRef instances that descent
1813  * from llvm::User. This includes constants, instructions, and
1814  * operators.
1815  *
1816  * @{
1817  */
1818 
1819 /**
1820  * Obtain an operand at a specific index in a llvm::User value.
1821  *
1822  * @see llvm::User::getOperand()
1823  */
1824 LLVMValueRef LLVMGetOperand(LLVMValueRef Val, unsigned Index);
1825 
1826 /**
1827  * Obtain the use of an operand at a specific index in a llvm::User value.
1828  *
1829  * @see llvm::User::getOperandUse()
1830  */
1831 LLVMUseRef LLVMGetOperandUse(LLVMValueRef Val, unsigned Index);
1832 
1833 /**
1834  * Set an operand at a specific index in a llvm::User value.
1835  *
1836  * @see llvm::User::setOperand()
1837  */
1838 void LLVMSetOperand(LLVMValueRef User, unsigned Index, LLVMValueRef Val);
1839 
1840 /**
1841  * Obtain the number of operands in a llvm::User value.
1842  *
1843  * @see llvm::User::getNumOperands()
1844  */
1845 int LLVMGetNumOperands(LLVMValueRef Val);
1846 
1847 /**
1848  * @}
1849  */
1850 
1851 /**
1852  * @defgroup LLVMCCoreValueConstant Constants
1853  *
1854  * This section contains APIs for interacting with LLVMValueRef that
1855  * correspond to llvm::Constant instances.
1856  *
1857  * These functions will work for any LLVMValueRef in the llvm::Constant
1858  * class hierarchy.
1859  *
1860  * @{
1861  */
1862 
1863 /**
1864  * Obtain a constant value referring to the null instance of a type.
1865  *
1866  * @see llvm::Constant::getNullValue()
1867  */
1868 LLVMValueRef LLVMConstNull(LLVMTypeRef Ty); /* all zeroes */
1869 
1870 /**
1871  * Obtain a constant value referring to the instance of a type
1872  * consisting of all ones.
1873  *
1874  * This is only valid for integer types.
1875  *
1876  * @see llvm::Constant::getAllOnesValue()
1877  */
1878 LLVMValueRef LLVMConstAllOnes(LLVMTypeRef Ty);
1879 
1880 /**
1881  * Obtain a constant value referring to an undefined value of a type.
1882  *
1883  * @see llvm::UndefValue::get()
1884  */
1885 LLVMValueRef LLVMGetUndef(LLVMTypeRef Ty);
1886 
1887 /**
1888  * Obtain a constant value referring to a poison value of a type.
1889  *
1890  * @see llvm::PoisonValue::get()
1891  */
1892 LLVMValueRef LLVMGetPoison(LLVMTypeRef Ty);
1893 
1894 /**
1895  * Determine whether a value instance is null.
1896  *
1897  * @see llvm::Constant::isNullValue()
1898  */
1899 LLVMBool LLVMIsNull(LLVMValueRef Val);
1900 
1901 /**
1902  * Obtain a constant that is a constant pointer pointing to NULL for a
1903  * specified type.
1904  */
1905 LLVMValueRef LLVMConstPointerNull(LLVMTypeRef Ty);
1906 
1907 /**
1908  * @defgroup LLVMCCoreValueConstantScalar Scalar constants
1909  *
1910  * Functions in this group model LLVMValueRef instances that correspond
1911  * to constants referring to scalar types.
1912  *
1913  * For integer types, the LLVMTypeRef parameter should correspond to a
1914  * llvm::IntegerType instance and the returned LLVMValueRef will
1915  * correspond to a llvm::ConstantInt.
1916  *
1917  * For floating point types, the LLVMTypeRef returned corresponds to a
1918  * llvm::ConstantFP.
1919  *
1920  * @{
1921  */
1922 
1923 /**
1924  * Obtain a constant value for an integer type.
1925  *
1926  * The returned value corresponds to a llvm::ConstantInt.
1927  *
1928  * @see llvm::ConstantInt::get()
1929  *
1930  * @param IntTy Integer type to obtain value of.
1931  * @param N The value the returned instance should refer to.
1932  * @param SignExtend Whether to sign extend the produced value.
1933  */
1934 LLVMValueRef LLVMConstInt(LLVMTypeRef IntTy, unsigned long long N,
1935                           LLVMBool SignExtend);
1936 
1937 /**
1938  * Obtain a constant value for an integer of arbitrary precision.
1939  *
1940  * @see llvm::ConstantInt::get()
1941  */
1942 LLVMValueRef LLVMConstIntOfArbitraryPrecision(LLVMTypeRef IntTy,
1943                                               unsigned NumWords,
1944                                               const uint64_t Words[]);
1945 
1946 /**
1947  * Obtain a constant value for an integer parsed from a string.
1948  *
1949  * A similar API, LLVMConstIntOfStringAndSize is also available. If the
1950  * string's length is available, it is preferred to call that function
1951  * instead.
1952  *
1953  * @see llvm::ConstantInt::get()
1954  */
1955 LLVMValueRef LLVMConstIntOfString(LLVMTypeRef IntTy, const char *Text,
1956                                   uint8_t Radix);
1957 
1958 /**
1959  * Obtain a constant value for an integer parsed from a string with
1960  * specified length.
1961  *
1962  * @see llvm::ConstantInt::get()
1963  */
1964 LLVMValueRef LLVMConstIntOfStringAndSize(LLVMTypeRef IntTy, const char *Text,
1965                                          unsigned SLen, uint8_t Radix);
1966 
1967 /**
1968  * Obtain a constant value referring to a double floating point value.
1969  */
1970 LLVMValueRef LLVMConstReal(LLVMTypeRef RealTy, double N);
1971 
1972 /**
1973  * Obtain a constant for a floating point value parsed from a string.
1974  *
1975  * A similar API, LLVMConstRealOfStringAndSize is also available. It
1976  * should be used if the input string's length is known.
1977  */
1978 LLVMValueRef LLVMConstRealOfString(LLVMTypeRef RealTy, const char *Text);
1979 
1980 /**
1981  * Obtain a constant for a floating point value parsed from a string.
1982  */
1983 LLVMValueRef LLVMConstRealOfStringAndSize(LLVMTypeRef RealTy, const char *Text,
1984                                           unsigned SLen);
1985 
1986 /**
1987  * Obtain the zero extended value for an integer constant value.
1988  *
1989  * @see llvm::ConstantInt::getZExtValue()
1990  */
1991 unsigned long long LLVMConstIntGetZExtValue(LLVMValueRef ConstantVal);
1992 
1993 /**
1994  * Obtain the sign extended value for an integer constant value.
1995  *
1996  * @see llvm::ConstantInt::getSExtValue()
1997  */
1998 long long LLVMConstIntGetSExtValue(LLVMValueRef ConstantVal);
1999 
2000 /**
2001  * Obtain the double value for an floating point constant value.
2002  * losesInfo indicates if some precision was lost in the conversion.
2003  *
2004  * @see llvm::ConstantFP::getDoubleValue
2005  */
2006 double LLVMConstRealGetDouble(LLVMValueRef ConstantVal, LLVMBool *losesInfo);
2007 
2008 /**
2009  * @}
2010  */
2011 
2012 /**
2013  * @defgroup LLVMCCoreValueConstantComposite Composite Constants
2014  *
2015  * Functions in this group operate on composite constants.
2016  *
2017  * @{
2018  */
2019 
2020 /**
2021  * Create a ConstantDataSequential and initialize it with a string.
2022  *
2023  * @see llvm::ConstantDataArray::getString()
2024  */
2025 LLVMValueRef LLVMConstStringInContext(LLVMContextRef C, const char *Str,
2026                                       unsigned Length, LLVMBool DontNullTerminate);
2027 
2028 /**
2029  * Create a ConstantDataSequential with string content in the global context.
2030  *
2031  * This is the same as LLVMConstStringInContext except it operates on the
2032  * global context.
2033  *
2034  * @see LLVMConstStringInContext()
2035  * @see llvm::ConstantDataArray::getString()
2036  */
2037 LLVMValueRef LLVMConstString(const char *Str, unsigned Length,
2038                              LLVMBool DontNullTerminate);
2039 
2040 /**
2041  * Returns true if the specified constant is an array of i8.
2042  *
2043  * @see ConstantDataSequential::getAsString()
2044  */
2045 LLVMBool LLVMIsConstantString(LLVMValueRef c);
2046 
2047 /**
2048  * Get the given constant data sequential as a string.
2049  *
2050  * @see ConstantDataSequential::getAsString()
2051  */
2052 const char *LLVMGetAsString(LLVMValueRef c, size_t *Length);
2053 
2054 /**
2055  * Create an anonymous ConstantStruct with the specified values.
2056  *
2057  * @see llvm::ConstantStruct::getAnon()
2058  */
2059 LLVMValueRef LLVMConstStructInContext(LLVMContextRef C,
2060                                       LLVMValueRef *ConstantVals,
2061                                       unsigned Count, LLVMBool Packed);
2062 
2063 /**
2064  * Create a ConstantStruct in the global Context.
2065  *
2066  * This is the same as LLVMConstStructInContext except it operates on the
2067  * global Context.
2068  *
2069  * @see LLVMConstStructInContext()
2070  */
2071 LLVMValueRef LLVMConstStruct(LLVMValueRef *ConstantVals, unsigned Count,
2072                              LLVMBool Packed);
2073 
2074 /**
2075  * Create a ConstantArray from values.
2076  *
2077  * @see llvm::ConstantArray::get()
2078  */
2079 LLVMValueRef LLVMConstArray(LLVMTypeRef ElementTy,
2080                             LLVMValueRef *ConstantVals, unsigned Length);
2081 
2082 /**
2083  * Create a non-anonymous ConstantStruct from values.
2084  *
2085  * @see llvm::ConstantStruct::get()
2086  */
2087 LLVMValueRef LLVMConstNamedStruct(LLVMTypeRef StructTy,
2088                                   LLVMValueRef *ConstantVals,
2089                                   unsigned Count);
2090 
2091 /**
2092  * Get an element at specified index as a constant.
2093  *
2094  * @see ConstantDataSequential::getElementAsConstant()
2095  */
2096 LLVMValueRef LLVMGetElementAsConstant(LLVMValueRef C, unsigned idx);
2097 
2098 /**
2099  * Create a ConstantVector from values.
2100  *
2101  * @see llvm::ConstantVector::get()
2102  */
2103 LLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals, unsigned Size);
2104 
2105 /**
2106  * @}
2107  */
2108 
2109 /**
2110  * @defgroup LLVMCCoreValueConstantExpressions Constant Expressions
2111  *
2112  * Functions in this group correspond to APIs on llvm::ConstantExpr.
2113  *
2114  * @see llvm::ConstantExpr.
2115  *
2116  * @{
2117  */
2118 LLVMOpcode LLVMGetConstOpcode(LLVMValueRef ConstantVal);
2119 LLVMValueRef LLVMAlignOf(LLVMTypeRef Ty);
2120 LLVMValueRef LLVMSizeOf(LLVMTypeRef Ty);
2121 LLVMValueRef LLVMConstNeg(LLVMValueRef ConstantVal);
2122 LLVMValueRef LLVMConstNSWNeg(LLVMValueRef ConstantVal);
2123 LLVMValueRef LLVMConstNUWNeg(LLVMValueRef ConstantVal);
2124 LLVMValueRef LLVMConstFNeg(LLVMValueRef ConstantVal);
2125 LLVMValueRef LLVMConstNot(LLVMValueRef ConstantVal);
2126 LLVMValueRef LLVMConstAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2127 LLVMValueRef LLVMConstNSWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2128 LLVMValueRef LLVMConstNUWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2129 LLVMValueRef LLVMConstFAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2130 LLVMValueRef LLVMConstSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2131 LLVMValueRef LLVMConstNSWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2132 LLVMValueRef LLVMConstNUWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2133 LLVMValueRef LLVMConstFSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2134 LLVMValueRef LLVMConstMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2135 LLVMValueRef LLVMConstNSWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2136 LLVMValueRef LLVMConstNUWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2137 LLVMValueRef LLVMConstFMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2138 LLVMValueRef LLVMConstUDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2139 LLVMValueRef LLVMConstExactUDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2140 LLVMValueRef LLVMConstSDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2141 LLVMValueRef LLVMConstExactSDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2142 LLVMValueRef LLVMConstFDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2143 LLVMValueRef LLVMConstURem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2144 LLVMValueRef LLVMConstSRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2145 LLVMValueRef LLVMConstFRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2146 LLVMValueRef LLVMConstAnd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2147 LLVMValueRef LLVMConstOr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2148 LLVMValueRef LLVMConstXor(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2149 LLVMValueRef LLVMConstICmp(LLVMIntPredicate Predicate,
2150                            LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2151 LLVMValueRef LLVMConstFCmp(LLVMRealPredicate Predicate,
2152                            LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2153 LLVMValueRef LLVMConstShl(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2154 LLVMValueRef LLVMConstLShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2155 LLVMValueRef LLVMConstAShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2156 LLVM_ATTRIBUTE_C_DEPRECATED(
2157     LLVMValueRef LLVMConstGEP(LLVMValueRef ConstantVal,
2158                               LLVMValueRef *ConstantIndices,
2159                               unsigned NumIndices),
2160     "Use LLVMConstGEP2 instead to support opaque pointers");
2161 LLVMValueRef LLVMConstGEP2(LLVMTypeRef Ty, LLVMValueRef ConstantVal,
2162                            LLVMValueRef *ConstantIndices, unsigned NumIndices);
2163 LLVM_ATTRIBUTE_C_DEPRECATED(
2164     LLVMValueRef LLVMConstInBoundsGEP(LLVMValueRef ConstantVal,
2165                                       LLVMValueRef *ConstantIndices,
2166                                       unsigned NumIndices),
2167     "Use LLVMConstInBoundsGEP2 instead to support opaque pointers");
2168 LLVMValueRef LLVMConstInBoundsGEP2(LLVMTypeRef Ty, LLVMValueRef ConstantVal,
2169                                    LLVMValueRef *ConstantIndices,
2170                                    unsigned NumIndices);
2171 LLVMValueRef LLVMConstTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
2172 LLVMValueRef LLVMConstSExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
2173 LLVMValueRef LLVMConstZExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
2174 LLVMValueRef LLVMConstFPTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
2175 LLVMValueRef LLVMConstFPExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
2176 LLVMValueRef LLVMConstUIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
2177 LLVMValueRef LLVMConstSIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
2178 LLVMValueRef LLVMConstFPToUI(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
2179 LLVMValueRef LLVMConstFPToSI(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
2180 LLVMValueRef LLVMConstPtrToInt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
2181 LLVMValueRef LLVMConstIntToPtr(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
2182 LLVMValueRef LLVMConstBitCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
2183 LLVMValueRef LLVMConstAddrSpaceCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
2184 LLVMValueRef LLVMConstZExtOrBitCast(LLVMValueRef ConstantVal,
2185                                     LLVMTypeRef ToType);
2186 LLVMValueRef LLVMConstSExtOrBitCast(LLVMValueRef ConstantVal,
2187                                     LLVMTypeRef ToType);
2188 LLVMValueRef LLVMConstTruncOrBitCast(LLVMValueRef ConstantVal,
2189                                      LLVMTypeRef ToType);
2190 LLVMValueRef LLVMConstPointerCast(LLVMValueRef ConstantVal,
2191                                   LLVMTypeRef ToType);
2192 LLVMValueRef LLVMConstIntCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType,
2193                               LLVMBool isSigned);
2194 LLVMValueRef LLVMConstFPCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
2195 LLVMValueRef LLVMConstSelect(LLVMValueRef ConstantCondition,
2196                              LLVMValueRef ConstantIfTrue,
2197                              LLVMValueRef ConstantIfFalse);
2198 LLVMValueRef LLVMConstExtractElement(LLVMValueRef VectorConstant,
2199                                      LLVMValueRef IndexConstant);
2200 LLVMValueRef LLVMConstInsertElement(LLVMValueRef VectorConstant,
2201                                     LLVMValueRef ElementValueConstant,
2202                                     LLVMValueRef IndexConstant);
2203 LLVMValueRef LLVMConstShuffleVector(LLVMValueRef VectorAConstant,
2204                                     LLVMValueRef VectorBConstant,
2205                                     LLVMValueRef MaskConstant);
2206 LLVMValueRef LLVMConstExtractValue(LLVMValueRef AggConstant, unsigned *IdxList,
2207                                    unsigned NumIdx);
2208 LLVMValueRef LLVMConstInsertValue(LLVMValueRef AggConstant,
2209                                   LLVMValueRef ElementValueConstant,
2210                                   unsigned *IdxList, unsigned NumIdx);
2211 LLVMValueRef LLVMBlockAddress(LLVMValueRef F, LLVMBasicBlockRef BB);
2212 
2213 /** Deprecated: Use LLVMGetInlineAsm instead. */
2214 LLVMValueRef LLVMConstInlineAsm(LLVMTypeRef Ty,
2215                                 const char *AsmString, const char *Constraints,
2216                                 LLVMBool HasSideEffects, LLVMBool IsAlignStack);
2217 
2218 /**
2219  * @}
2220  */
2221 
2222 /**
2223  * @defgroup LLVMCCoreValueConstantGlobals Global Values
2224  *
2225  * This group contains functions that operate on global values. Functions in
2226  * this group relate to functions in the llvm::GlobalValue class tree.
2227  *
2228  * @see llvm::GlobalValue
2229  *
2230  * @{
2231  */
2232 
2233 LLVMModuleRef LLVMGetGlobalParent(LLVMValueRef Global);
2234 LLVMBool LLVMIsDeclaration(LLVMValueRef Global);
2235 LLVMLinkage LLVMGetLinkage(LLVMValueRef Global);
2236 void LLVMSetLinkage(LLVMValueRef Global, LLVMLinkage Linkage);
2237 const char *LLVMGetSection(LLVMValueRef Global);
2238 void LLVMSetSection(LLVMValueRef Global, const char *Section);
2239 LLVMVisibility LLVMGetVisibility(LLVMValueRef Global);
2240 void LLVMSetVisibility(LLVMValueRef Global, LLVMVisibility Viz);
2241 LLVMDLLStorageClass LLVMGetDLLStorageClass(LLVMValueRef Global);
2242 void LLVMSetDLLStorageClass(LLVMValueRef Global, LLVMDLLStorageClass Class);
2243 LLVMUnnamedAddr LLVMGetUnnamedAddress(LLVMValueRef Global);
2244 void LLVMSetUnnamedAddress(LLVMValueRef Global, LLVMUnnamedAddr UnnamedAddr);
2245 
2246 /**
2247  * Returns the "value type" of a global value.  This differs from the formal
2248  * type of a global value which is always a pointer type.
2249  *
2250  * @see llvm::GlobalValue::getValueType()
2251  */
2252 LLVMTypeRef LLVMGlobalGetValueType(LLVMValueRef Global);
2253 
2254 /** Deprecated: Use LLVMGetUnnamedAddress instead. */
2255 LLVMBool LLVMHasUnnamedAddr(LLVMValueRef Global);
2256 /** Deprecated: Use LLVMSetUnnamedAddress instead. */
2257 void LLVMSetUnnamedAddr(LLVMValueRef Global, LLVMBool HasUnnamedAddr);
2258 
2259 /**
2260  * @defgroup LLVMCCoreValueWithAlignment Values with alignment
2261  *
2262  * Functions in this group only apply to values with alignment, i.e.
2263  * global variables, load and store instructions.
2264  */
2265 
2266 /**
2267  * Obtain the preferred alignment of the value.
2268  * @see llvm::AllocaInst::getAlignment()
2269  * @see llvm::LoadInst::getAlignment()
2270  * @see llvm::StoreInst::getAlignment()
2271  * @see llvm::AtomicRMWInst::setAlignment()
2272  * @see llvm::AtomicCmpXchgInst::setAlignment()
2273  * @see llvm::GlobalValue::getAlignment()
2274  */
2275 unsigned LLVMGetAlignment(LLVMValueRef V);
2276 
2277 /**
2278  * Set the preferred alignment of the value.
2279  * @see llvm::AllocaInst::setAlignment()
2280  * @see llvm::LoadInst::setAlignment()
2281  * @see llvm::StoreInst::setAlignment()
2282  * @see llvm::AtomicRMWInst::setAlignment()
2283  * @see llvm::AtomicCmpXchgInst::setAlignment()
2284  * @see llvm::GlobalValue::setAlignment()
2285  */
2286 void LLVMSetAlignment(LLVMValueRef V, unsigned Bytes);
2287 
2288 /**
2289  * Sets a metadata attachment, erasing the existing metadata attachment if
2290  * it already exists for the given kind.
2291  *
2292  * @see llvm::GlobalObject::setMetadata()
2293  */
2294 void LLVMGlobalSetMetadata(LLVMValueRef Global, unsigned Kind,
2295                            LLVMMetadataRef MD);
2296 
2297 /**
2298  * Erases a metadata attachment of the given kind if it exists.
2299  *
2300  * @see llvm::GlobalObject::eraseMetadata()
2301  */
2302 void LLVMGlobalEraseMetadata(LLVMValueRef Global, unsigned Kind);
2303 
2304 /**
2305  * Removes all metadata attachments from this value.
2306  *
2307  * @see llvm::GlobalObject::clearMetadata()
2308  */
2309 void LLVMGlobalClearMetadata(LLVMValueRef Global);
2310 
2311 /**
2312  * Retrieves an array of metadata entries representing the metadata attached to
2313  * this value. The caller is responsible for freeing this array by calling
2314  * \c LLVMDisposeValueMetadataEntries.
2315  *
2316  * @see llvm::GlobalObject::getAllMetadata()
2317  */
2318 LLVMValueMetadataEntry *LLVMGlobalCopyAllMetadata(LLVMValueRef Value,
2319                                                   size_t *NumEntries);
2320 
2321 /**
2322  * Destroys value metadata entries.
2323  */
2324 void LLVMDisposeValueMetadataEntries(LLVMValueMetadataEntry *Entries);
2325 
2326 /**
2327  * Returns the kind of a value metadata entry at a specific index.
2328  */
2329 unsigned LLVMValueMetadataEntriesGetKind(LLVMValueMetadataEntry *Entries,
2330                                          unsigned Index);
2331 
2332 /**
2333  * Returns the underlying metadata node of a value metadata entry at a
2334  * specific index.
2335  */
2336 LLVMMetadataRef
2337 LLVMValueMetadataEntriesGetMetadata(LLVMValueMetadataEntry *Entries,
2338                                     unsigned Index);
2339 
2340 /**
2341  * @}
2342  */
2343 
2344 /**
2345  * @defgroup LLVMCoreValueConstantGlobalVariable Global Variables
2346  *
2347  * This group contains functions that operate on global variable values.
2348  *
2349  * @see llvm::GlobalVariable
2350  *
2351  * @{
2352  */
2353 LLVMValueRef LLVMAddGlobal(LLVMModuleRef M, LLVMTypeRef Ty, const char *Name);
2354 LLVMValueRef LLVMAddGlobalInAddressSpace(LLVMModuleRef M, LLVMTypeRef Ty,
2355                                          const char *Name,
2356                                          unsigned AddressSpace);
2357 LLVMValueRef LLVMGetNamedGlobal(LLVMModuleRef M, const char *Name);
2358 LLVMValueRef LLVMGetFirstGlobal(LLVMModuleRef M);
2359 LLVMValueRef LLVMGetLastGlobal(LLVMModuleRef M);
2360 LLVMValueRef LLVMGetNextGlobal(LLVMValueRef GlobalVar);
2361 LLVMValueRef LLVMGetPreviousGlobal(LLVMValueRef GlobalVar);
2362 void LLVMDeleteGlobal(LLVMValueRef GlobalVar);
2363 LLVMValueRef LLVMGetInitializer(LLVMValueRef GlobalVar);
2364 void LLVMSetInitializer(LLVMValueRef GlobalVar, LLVMValueRef ConstantVal);
2365 LLVMBool LLVMIsThreadLocal(LLVMValueRef GlobalVar);
2366 void LLVMSetThreadLocal(LLVMValueRef GlobalVar, LLVMBool IsThreadLocal);
2367 LLVMBool LLVMIsGlobalConstant(LLVMValueRef GlobalVar);
2368 void LLVMSetGlobalConstant(LLVMValueRef GlobalVar, LLVMBool IsConstant);
2369 LLVMThreadLocalMode LLVMGetThreadLocalMode(LLVMValueRef GlobalVar);
2370 void LLVMSetThreadLocalMode(LLVMValueRef GlobalVar, LLVMThreadLocalMode Mode);
2371 LLVMBool LLVMIsExternallyInitialized(LLVMValueRef GlobalVar);
2372 void LLVMSetExternallyInitialized(LLVMValueRef GlobalVar, LLVMBool IsExtInit);
2373 
2374 /**
2375  * @}
2376  */
2377 
2378 /**
2379  * @defgroup LLVMCoreValueConstantGlobalAlias Global Aliases
2380  *
2381  * This group contains function that operate on global alias values.
2382  *
2383  * @see llvm::GlobalAlias
2384  *
2385  * @{
2386  */
2387 
2388 LLVM_ATTRIBUTE_C_DEPRECATED(
2389     LLVMValueRef LLVMAddAlias(LLVMModuleRef M, LLVMTypeRef Ty,
2390                               LLVMValueRef Aliasee, const char *Name),
2391     "Use LLVMAddAlias2 instead to support opaque pointers");
2392 
2393 /**
2394  * Add a GlobalAlias with the given value type, address space and aliasee.
2395  *
2396  * @see llvm::GlobalAlias::create()
2397  */
2398 LLVMValueRef LLVMAddAlias2(LLVMModuleRef M, LLVMTypeRef ValueTy,
2399                            unsigned AddrSpace, LLVMValueRef Aliasee,
2400                            const char *Name);
2401 
2402 /**
2403  * Obtain a GlobalAlias value from a Module by its name.
2404  *
2405  * The returned value corresponds to a llvm::GlobalAlias value.
2406  *
2407  * @see llvm::Module::getNamedAlias()
2408  */
2409 LLVMValueRef LLVMGetNamedGlobalAlias(LLVMModuleRef M,
2410                                      const char *Name, size_t NameLen);
2411 
2412 /**
2413  * Obtain an iterator to the first GlobalAlias in a Module.
2414  *
2415  * @see llvm::Module::alias_begin()
2416  */
2417 LLVMValueRef LLVMGetFirstGlobalAlias(LLVMModuleRef M);
2418 
2419 /**
2420  * Obtain an iterator to the last GlobalAlias in a Module.
2421  *
2422  * @see llvm::Module::alias_end()
2423  */
2424 LLVMValueRef LLVMGetLastGlobalAlias(LLVMModuleRef M);
2425 
2426 /**
2427  * Advance a GlobalAlias iterator to the next GlobalAlias.
2428  *
2429  * Returns NULL if the iterator was already at the end and there are no more
2430  * global aliases.
2431  */
2432 LLVMValueRef LLVMGetNextGlobalAlias(LLVMValueRef GA);
2433 
2434 /**
2435  * Decrement a GlobalAlias iterator to the previous GlobalAlias.
2436  *
2437  * Returns NULL if the iterator was already at the beginning and there are
2438  * no previous global aliases.
2439  */
2440 LLVMValueRef LLVMGetPreviousGlobalAlias(LLVMValueRef GA);
2441 
2442 /**
2443  * Retrieve the target value of an alias.
2444  */
2445 LLVMValueRef LLVMAliasGetAliasee(LLVMValueRef Alias);
2446 
2447 /**
2448  * Set the target value of an alias.
2449  */
2450 void LLVMAliasSetAliasee(LLVMValueRef Alias, LLVMValueRef Aliasee);
2451 
2452 /**
2453  * @}
2454  */
2455 
2456 /**
2457  * @defgroup LLVMCCoreValueFunction Function values
2458  *
2459  * Functions in this group operate on LLVMValueRef instances that
2460  * correspond to llvm::Function instances.
2461  *
2462  * @see llvm::Function
2463  *
2464  * @{
2465  */
2466 
2467 /**
2468  * Remove a function from its containing module and deletes it.
2469  *
2470  * @see llvm::Function::eraseFromParent()
2471  */
2472 void LLVMDeleteFunction(LLVMValueRef Fn);
2473 
2474 /**
2475  * Check whether the given function has a personality function.
2476  *
2477  * @see llvm::Function::hasPersonalityFn()
2478  */
2479 LLVMBool LLVMHasPersonalityFn(LLVMValueRef Fn);
2480 
2481 /**
2482  * Obtain the personality function attached to the function.
2483  *
2484  * @see llvm::Function::getPersonalityFn()
2485  */
2486 LLVMValueRef LLVMGetPersonalityFn(LLVMValueRef Fn);
2487 
2488 /**
2489  * Set the personality function attached to the function.
2490  *
2491  * @see llvm::Function::setPersonalityFn()
2492  */
2493 void LLVMSetPersonalityFn(LLVMValueRef Fn, LLVMValueRef PersonalityFn);
2494 
2495 /**
2496  * Obtain the intrinsic ID number which matches the given function name.
2497  *
2498  * @see llvm::Function::lookupIntrinsicID()
2499  */
2500 unsigned LLVMLookupIntrinsicID(const char *Name, size_t NameLen);
2501 
2502 /**
2503  * Obtain the ID number from a function instance.
2504  *
2505  * @see llvm::Function::getIntrinsicID()
2506  */
2507 unsigned LLVMGetIntrinsicID(LLVMValueRef Fn);
2508 
2509 /**
2510  * Create or insert the declaration of an intrinsic.  For overloaded intrinsics,
2511  * parameter types must be provided to uniquely identify an overload.
2512  *
2513  * @see llvm::Intrinsic::getDeclaration()
2514  */
2515 LLVMValueRef LLVMGetIntrinsicDeclaration(LLVMModuleRef Mod,
2516                                          unsigned ID,
2517                                          LLVMTypeRef *ParamTypes,
2518                                          size_t ParamCount);
2519 
2520 /**
2521  * Retrieves the type of an intrinsic.  For overloaded intrinsics, parameter
2522  * types must be provided to uniquely identify an overload.
2523  *
2524  * @see llvm::Intrinsic::getType()
2525  */
2526 LLVMTypeRef LLVMIntrinsicGetType(LLVMContextRef Ctx, unsigned ID,
2527                                  LLVMTypeRef *ParamTypes, size_t ParamCount);
2528 
2529 /**
2530  * Retrieves the name of an intrinsic.
2531  *
2532  * @see llvm::Intrinsic::getName()
2533  */
2534 const char *LLVMIntrinsicGetName(unsigned ID, size_t *NameLength);
2535 
2536 /** Deprecated: Use LLVMIntrinsicCopyOverloadedName2 instead. */
2537 const char *LLVMIntrinsicCopyOverloadedName(unsigned ID,
2538                                             LLVMTypeRef *ParamTypes,
2539                                             size_t ParamCount,
2540                                             size_t *NameLength);
2541 
2542 /**
2543  * Copies the name of an overloaded intrinsic identified by a given list of
2544  * parameter types.
2545  *
2546  * Unlike LLVMIntrinsicGetName, the caller is responsible for freeing the
2547  * returned string.
2548  *
2549  * This version also supports unnamed types.
2550  *
2551  * @see llvm::Intrinsic::getName()
2552  */
2553 const char *LLVMIntrinsicCopyOverloadedName2(LLVMModuleRef Mod, unsigned ID,
2554                                              LLVMTypeRef *ParamTypes,
2555                                              size_t ParamCount,
2556                                              size_t *NameLength);
2557 
2558 /**
2559  * Obtain if the intrinsic identified by the given ID is overloaded.
2560  *
2561  * @see llvm::Intrinsic::isOverloaded()
2562  */
2563 LLVMBool LLVMIntrinsicIsOverloaded(unsigned ID);
2564 
2565 /**
2566  * Obtain the calling function of a function.
2567  *
2568  * The returned value corresponds to the LLVMCallConv enumeration.
2569  *
2570  * @see llvm::Function::getCallingConv()
2571  */
2572 unsigned LLVMGetFunctionCallConv(LLVMValueRef Fn);
2573 
2574 /**
2575  * Set the calling convention of a function.
2576  *
2577  * @see llvm::Function::setCallingConv()
2578  *
2579  * @param Fn Function to operate on
2580  * @param CC LLVMCallConv to set calling convention to
2581  */
2582 void LLVMSetFunctionCallConv(LLVMValueRef Fn, unsigned CC);
2583 
2584 /**
2585  * Obtain the name of the garbage collector to use during code
2586  * generation.
2587  *
2588  * @see llvm::Function::getGC()
2589  */
2590 const char *LLVMGetGC(LLVMValueRef Fn);
2591 
2592 /**
2593  * Define the garbage collector to use during code generation.
2594  *
2595  * @see llvm::Function::setGC()
2596  */
2597 void LLVMSetGC(LLVMValueRef Fn, const char *Name);
2598 
2599 /**
2600  * Add an attribute to a function.
2601  *
2602  * @see llvm::Function::addAttribute()
2603  */
2604 void LLVMAddAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx,
2605                              LLVMAttributeRef A);
2606 unsigned LLVMGetAttributeCountAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx);
2607 void LLVMGetAttributesAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx,
2608                               LLVMAttributeRef *Attrs);
2609 LLVMAttributeRef LLVMGetEnumAttributeAtIndex(LLVMValueRef F,
2610                                              LLVMAttributeIndex Idx,
2611                                              unsigned KindID);
2612 LLVMAttributeRef LLVMGetStringAttributeAtIndex(LLVMValueRef F,
2613                                                LLVMAttributeIndex Idx,
2614                                                const char *K, unsigned KLen);
2615 void LLVMRemoveEnumAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx,
2616                                     unsigned KindID);
2617 void LLVMRemoveStringAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx,
2618                                       const char *K, unsigned KLen);
2619 
2620 /**
2621  * Add a target-dependent attribute to a function
2622  * @see llvm::AttrBuilder::addAttribute()
2623  */
2624 void LLVMAddTargetDependentFunctionAttr(LLVMValueRef Fn, const char *A,
2625                                         const char *V);
2626 
2627 /**
2628  * @defgroup LLVMCCoreValueFunctionParameters Function Parameters
2629  *
2630  * Functions in this group relate to arguments/parameters on functions.
2631  *
2632  * Functions in this group expect LLVMValueRef instances that correspond
2633  * to llvm::Function instances.
2634  *
2635  * @{
2636  */
2637 
2638 /**
2639  * Obtain the number of parameters in a function.
2640  *
2641  * @see llvm::Function::arg_size()
2642  */
2643 unsigned LLVMCountParams(LLVMValueRef Fn);
2644 
2645 /**
2646  * Obtain the parameters in a function.
2647  *
2648  * The takes a pointer to a pre-allocated array of LLVMValueRef that is
2649  * at least LLVMCountParams() long. This array will be filled with
2650  * LLVMValueRef instances which correspond to the parameters the
2651  * function receives. Each LLVMValueRef corresponds to a llvm::Argument
2652  * instance.
2653  *
2654  * @see llvm::Function::arg_begin()
2655  */
2656 void LLVMGetParams(LLVMValueRef Fn, LLVMValueRef *Params);
2657 
2658 /**
2659  * Obtain the parameter at the specified index.
2660  *
2661  * Parameters are indexed from 0.
2662  *
2663  * @see llvm::Function::arg_begin()
2664  */
2665 LLVMValueRef LLVMGetParam(LLVMValueRef Fn, unsigned Index);
2666 
2667 /**
2668  * Obtain the function to which this argument belongs.
2669  *
2670  * Unlike other functions in this group, this one takes an LLVMValueRef
2671  * that corresponds to a llvm::Attribute.
2672  *
2673  * The returned LLVMValueRef is the llvm::Function to which this
2674  * argument belongs.
2675  */
2676 LLVMValueRef LLVMGetParamParent(LLVMValueRef Inst);
2677 
2678 /**
2679  * Obtain the first parameter to a function.
2680  *
2681  * @see llvm::Function::arg_begin()
2682  */
2683 LLVMValueRef LLVMGetFirstParam(LLVMValueRef Fn);
2684 
2685 /**
2686  * Obtain the last parameter to a function.
2687  *
2688  * @see llvm::Function::arg_end()
2689  */
2690 LLVMValueRef LLVMGetLastParam(LLVMValueRef Fn);
2691 
2692 /**
2693  * Obtain the next parameter to a function.
2694  *
2695  * This takes an LLVMValueRef obtained from LLVMGetFirstParam() (which is
2696  * actually a wrapped iterator) and obtains the next parameter from the
2697  * underlying iterator.
2698  */
2699 LLVMValueRef LLVMGetNextParam(LLVMValueRef Arg);
2700 
2701 /**
2702  * Obtain the previous parameter to a function.
2703  *
2704  * This is the opposite of LLVMGetNextParam().
2705  */
2706 LLVMValueRef LLVMGetPreviousParam(LLVMValueRef Arg);
2707 
2708 /**
2709  * Set the alignment for a function parameter.
2710  *
2711  * @see llvm::Argument::addAttr()
2712  * @see llvm::AttrBuilder::addAlignmentAttr()
2713  */
2714 void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned Align);
2715 
2716 /**
2717  * @}
2718  */
2719 
2720 /**
2721  * @defgroup LLVMCCoreValueGlobalIFunc IFuncs
2722  *
2723  * Functions in this group relate to indirect functions.
2724  *
2725  * Functions in this group expect LLVMValueRef instances that correspond
2726  * to llvm::GlobalIFunc instances.
2727  *
2728  * @{
2729  */
2730 
2731 /**
2732  * Add a global indirect function to a module under a specified name.
2733  *
2734  * @see llvm::GlobalIFunc::create()
2735  */
2736 LLVMValueRef LLVMAddGlobalIFunc(LLVMModuleRef M,
2737                                 const char *Name, size_t NameLen,
2738                                 LLVMTypeRef Ty, unsigned AddrSpace,
2739                                 LLVMValueRef Resolver);
2740 
2741 /**
2742  * Obtain a GlobalIFunc value from a Module by its name.
2743  *
2744  * The returned value corresponds to a llvm::GlobalIFunc value.
2745  *
2746  * @see llvm::Module::getNamedIFunc()
2747  */
2748 LLVMValueRef LLVMGetNamedGlobalIFunc(LLVMModuleRef M,
2749                                      const char *Name, size_t NameLen);
2750 
2751 /**
2752  * Obtain an iterator to the first GlobalIFunc in a Module.
2753  *
2754  * @see llvm::Module::ifunc_begin()
2755  */
2756 LLVMValueRef LLVMGetFirstGlobalIFunc(LLVMModuleRef M);
2757 
2758 /**
2759  * Obtain an iterator to the last GlobalIFunc in a Module.
2760  *
2761  * @see llvm::Module::ifunc_end()
2762  */
2763 LLVMValueRef LLVMGetLastGlobalIFunc(LLVMModuleRef M);
2764 
2765 /**
2766  * Advance a GlobalIFunc iterator to the next GlobalIFunc.
2767  *
2768  * Returns NULL if the iterator was already at the end and there are no more
2769  * global aliases.
2770  */
2771 LLVMValueRef LLVMGetNextGlobalIFunc(LLVMValueRef IFunc);
2772 
2773 /**
2774  * Decrement a GlobalIFunc iterator to the previous GlobalIFunc.
2775  *
2776  * Returns NULL if the iterator was already at the beginning and there are
2777  * no previous global aliases.
2778  */
2779 LLVMValueRef LLVMGetPreviousGlobalIFunc(LLVMValueRef IFunc);
2780 
2781 /**
2782  * Retrieves the resolver function associated with this indirect function, or
2783  * NULL if it doesn't not exist.
2784  *
2785  * @see llvm::GlobalIFunc::getResolver()
2786  */
2787 LLVMValueRef LLVMGetGlobalIFuncResolver(LLVMValueRef IFunc);
2788 
2789 /**
2790  * Sets the resolver function associated with this indirect function.
2791  *
2792  * @see llvm::GlobalIFunc::setResolver()
2793  */
2794 void LLVMSetGlobalIFuncResolver(LLVMValueRef IFunc, LLVMValueRef Resolver);
2795 
2796 /**
2797  * Remove a global indirect function from its parent module and delete it.
2798  *
2799  * @see llvm::GlobalIFunc::eraseFromParent()
2800  */
2801 void LLVMEraseGlobalIFunc(LLVMValueRef IFunc);
2802 
2803 /**
2804  * Remove a global indirect function from its parent module.
2805  *
2806  * This unlinks the global indirect function from its containing module but
2807  * keeps it alive.
2808  *
2809  * @see llvm::GlobalIFunc::removeFromParent()
2810  */
2811 void LLVMRemoveGlobalIFunc(LLVMValueRef IFunc);
2812 
2813 /**
2814  * @}
2815  */
2816 
2817 /**
2818  * @}
2819  */
2820 
2821 /**
2822  * @}
2823  */
2824 
2825 /**
2826  * @}
2827  */
2828 
2829 /**
2830  * @defgroup LLVMCCoreValueMetadata Metadata
2831  *
2832  * @{
2833  */
2834 
2835 /**
2836  * Create an MDString value from a given string value.
2837  *
2838  * The MDString value does not take ownership of the given string, it remains
2839  * the responsibility of the caller to free it.
2840  *
2841  * @see llvm::MDString::get()
2842  */
2843 LLVMMetadataRef LLVMMDStringInContext2(LLVMContextRef C, const char *Str,
2844                                        size_t SLen);
2845 
2846 /**
2847  * Create an MDNode value with the given array of operands.
2848  *
2849  * @see llvm::MDNode::get()
2850  */
2851 LLVMMetadataRef LLVMMDNodeInContext2(LLVMContextRef C, LLVMMetadataRef *MDs,
2852                                      size_t Count);
2853 
2854 /**
2855  * Obtain a Metadata as a Value.
2856  */
2857 LLVMValueRef LLVMMetadataAsValue(LLVMContextRef C, LLVMMetadataRef MD);
2858 
2859 /**
2860  * Obtain a Value as a Metadata.
2861  */
2862 LLVMMetadataRef LLVMValueAsMetadata(LLVMValueRef Val);
2863 
2864 /**
2865  * Obtain the underlying string from a MDString value.
2866  *
2867  * @param V Instance to obtain string from.
2868  * @param Length Memory address which will hold length of returned string.
2869  * @return String data in MDString.
2870  */
2871 const char *LLVMGetMDString(LLVMValueRef V, unsigned *Length);
2872 
2873 /**
2874  * Obtain the number of operands from an MDNode value.
2875  *
2876  * @param V MDNode to get number of operands from.
2877  * @return Number of operands of the MDNode.
2878  */
2879 unsigned LLVMGetMDNodeNumOperands(LLVMValueRef V);
2880 
2881 /**
2882  * Obtain the given MDNode's operands.
2883  *
2884  * The passed LLVMValueRef pointer should point to enough memory to hold all of
2885  * the operands of the given MDNode (see LLVMGetMDNodeNumOperands) as
2886  * LLVMValueRefs. This memory will be populated with the LLVMValueRefs of the
2887  * MDNode's operands.
2888  *
2889  * @param V MDNode to get the operands from.
2890  * @param Dest Destination array for operands.
2891  */
2892 void LLVMGetMDNodeOperands(LLVMValueRef V, LLVMValueRef *Dest);
2893 
2894 /** Deprecated: Use LLVMMDStringInContext2 instead. */
2895 LLVMValueRef LLVMMDStringInContext(LLVMContextRef C, const char *Str,
2896                                    unsigned SLen);
2897 /** Deprecated: Use LLVMMDStringInContext2 instead. */
2898 LLVMValueRef LLVMMDString(const char *Str, unsigned SLen);
2899 /** Deprecated: Use LLVMMDNodeInContext2 instead. */
2900 LLVMValueRef LLVMMDNodeInContext(LLVMContextRef C, LLVMValueRef *Vals,
2901                                  unsigned Count);
2902 /** Deprecated: Use LLVMMDNodeInContext2 instead. */
2903 LLVMValueRef LLVMMDNode(LLVMValueRef *Vals, unsigned Count);
2904 
2905 /**
2906  * @}
2907  */
2908 
2909 /**
2910  * @defgroup LLVMCCoreValueBasicBlock Basic Block
2911  *
2912  * A basic block represents a single entry single exit section of code.
2913  * Basic blocks contain a list of instructions which form the body of
2914  * the block.
2915  *
2916  * Basic blocks belong to functions. They have the type of label.
2917  *
2918  * Basic blocks are themselves values. However, the C API models them as
2919  * LLVMBasicBlockRef.
2920  *
2921  * @see llvm::BasicBlock
2922  *
2923  * @{
2924  */
2925 
2926 /**
2927  * Convert a basic block instance to a value type.
2928  */
2929 LLVMValueRef LLVMBasicBlockAsValue(LLVMBasicBlockRef BB);
2930 
2931 /**
2932  * Determine whether an LLVMValueRef is itself a basic block.
2933  */
2934 LLVMBool LLVMValueIsBasicBlock(LLVMValueRef Val);
2935 
2936 /**
2937  * Convert an LLVMValueRef to an LLVMBasicBlockRef instance.
2938  */
2939 LLVMBasicBlockRef LLVMValueAsBasicBlock(LLVMValueRef Val);
2940 
2941 /**
2942  * Obtain the string name of a basic block.
2943  */
2944 const char *LLVMGetBasicBlockName(LLVMBasicBlockRef BB);
2945 
2946 /**
2947  * Obtain the function to which a basic block belongs.
2948  *
2949  * @see llvm::BasicBlock::getParent()
2950  */
2951 LLVMValueRef LLVMGetBasicBlockParent(LLVMBasicBlockRef BB);
2952 
2953 /**
2954  * Obtain the terminator instruction for a basic block.
2955  *
2956  * If the basic block does not have a terminator (it is not well-formed
2957  * if it doesn't), then NULL is returned.
2958  *
2959  * The returned LLVMValueRef corresponds to an llvm::Instruction.
2960  *
2961  * @see llvm::BasicBlock::getTerminator()
2962  */
2963 LLVMValueRef LLVMGetBasicBlockTerminator(LLVMBasicBlockRef BB);
2964 
2965 /**
2966  * Obtain the number of basic blocks in a function.
2967  *
2968  * @param Fn Function value to operate on.
2969  */
2970 unsigned LLVMCountBasicBlocks(LLVMValueRef Fn);
2971 
2972 /**
2973  * Obtain all of the basic blocks in a function.
2974  *
2975  * This operates on a function value. The BasicBlocks parameter is a
2976  * pointer to a pre-allocated array of LLVMBasicBlockRef of at least
2977  * LLVMCountBasicBlocks() in length. This array is populated with
2978  * LLVMBasicBlockRef instances.
2979  */
2980 void LLVMGetBasicBlocks(LLVMValueRef Fn, LLVMBasicBlockRef *BasicBlocks);
2981 
2982 /**
2983  * Obtain the first basic block in a function.
2984  *
2985  * The returned basic block can be used as an iterator. You will likely
2986  * eventually call into LLVMGetNextBasicBlock() with it.
2987  *
2988  * @see llvm::Function::begin()
2989  */
2990 LLVMBasicBlockRef LLVMGetFirstBasicBlock(LLVMValueRef Fn);
2991 
2992 /**
2993  * Obtain the last basic block in a function.
2994  *
2995  * @see llvm::Function::end()
2996  */
2997 LLVMBasicBlockRef LLVMGetLastBasicBlock(LLVMValueRef Fn);
2998 
2999 /**
3000  * Advance a basic block iterator.
3001  */
3002 LLVMBasicBlockRef LLVMGetNextBasicBlock(LLVMBasicBlockRef BB);
3003 
3004 /**
3005  * Go backwards in a basic block iterator.
3006  */
3007 LLVMBasicBlockRef LLVMGetPreviousBasicBlock(LLVMBasicBlockRef BB);
3008 
3009 /**
3010  * Obtain the basic block that corresponds to the entry point of a
3011  * function.
3012  *
3013  * @see llvm::Function::getEntryBlock()
3014  */
3015 LLVMBasicBlockRef LLVMGetEntryBasicBlock(LLVMValueRef Fn);
3016 
3017 /**
3018  * Insert the given basic block after the insertion point of the given builder.
3019  *
3020  * The insertion point must be valid.
3021  *
3022  * @see llvm::Function::BasicBlockListType::insertAfter()
3023  */
3024 void LLVMInsertExistingBasicBlockAfterInsertBlock(LLVMBuilderRef Builder,
3025                                                   LLVMBasicBlockRef BB);
3026 
3027 /**
3028  * Append the given basic block to the basic block list of the given function.
3029  *
3030  * @see llvm::Function::BasicBlockListType::push_back()
3031  */
3032 void LLVMAppendExistingBasicBlock(LLVMValueRef Fn,
3033                                   LLVMBasicBlockRef BB);
3034 
3035 /**
3036  * Create a new basic block without inserting it into a function.
3037  *
3038  * @see llvm::BasicBlock::Create()
3039  */
3040 LLVMBasicBlockRef LLVMCreateBasicBlockInContext(LLVMContextRef C,
3041                                                 const char *Name);
3042 
3043 /**
3044  * Append a basic block to the end of a function.
3045  *
3046  * @see llvm::BasicBlock::Create()
3047  */
3048 LLVMBasicBlockRef LLVMAppendBasicBlockInContext(LLVMContextRef C,
3049                                                 LLVMValueRef Fn,
3050                                                 const char *Name);
3051 
3052 /**
3053  * Append a basic block to the end of a function using the global
3054  * context.
3055  *
3056  * @see llvm::BasicBlock::Create()
3057  */
3058 LLVMBasicBlockRef LLVMAppendBasicBlock(LLVMValueRef Fn, const char *Name);
3059 
3060 /**
3061  * Insert a basic block in a function before another basic block.
3062  *
3063  * The function to add to is determined by the function of the
3064  * passed basic block.
3065  *
3066  * @see llvm::BasicBlock::Create()
3067  */
3068 LLVMBasicBlockRef LLVMInsertBasicBlockInContext(LLVMContextRef C,
3069                                                 LLVMBasicBlockRef BB,
3070                                                 const char *Name);
3071 
3072 /**
3073  * Insert a basic block in a function using the global context.
3074  *
3075  * @see llvm::BasicBlock::Create()
3076  */
3077 LLVMBasicBlockRef LLVMInsertBasicBlock(LLVMBasicBlockRef InsertBeforeBB,
3078                                        const char *Name);
3079 
3080 /**
3081  * Remove a basic block from a function and delete it.
3082  *
3083  * This deletes the basic block from its containing function and deletes
3084  * the basic block itself.
3085  *
3086  * @see llvm::BasicBlock::eraseFromParent()
3087  */
3088 void LLVMDeleteBasicBlock(LLVMBasicBlockRef BB);
3089 
3090 /**
3091  * Remove a basic block from a function.
3092  *
3093  * This deletes the basic block from its containing function but keep
3094  * the basic block alive.
3095  *
3096  * @see llvm::BasicBlock::removeFromParent()
3097  */
3098 void LLVMRemoveBasicBlockFromParent(LLVMBasicBlockRef BB);
3099 
3100 /**
3101  * Move a basic block to before another one.
3102  *
3103  * @see llvm::BasicBlock::moveBefore()
3104  */
3105 void LLVMMoveBasicBlockBefore(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos);
3106 
3107 /**
3108  * Move a basic block to after another one.
3109  *
3110  * @see llvm::BasicBlock::moveAfter()
3111  */
3112 void LLVMMoveBasicBlockAfter(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos);
3113 
3114 /**
3115  * Obtain the first instruction in a basic block.
3116  *
3117  * The returned LLVMValueRef corresponds to a llvm::Instruction
3118  * instance.
3119  */
3120 LLVMValueRef LLVMGetFirstInstruction(LLVMBasicBlockRef BB);
3121 
3122 /**
3123  * Obtain the last instruction in a basic block.
3124  *
3125  * The returned LLVMValueRef corresponds to an LLVM:Instruction.
3126  */
3127 LLVMValueRef LLVMGetLastInstruction(LLVMBasicBlockRef BB);
3128 
3129 /**
3130  * @}
3131  */
3132 
3133 /**
3134  * @defgroup LLVMCCoreValueInstruction Instructions
3135  *
3136  * Functions in this group relate to the inspection and manipulation of
3137  * individual instructions.
3138  *
3139  * In the C++ API, an instruction is modeled by llvm::Instruction. This
3140  * class has a large number of descendents. llvm::Instruction is a
3141  * llvm::Value and in the C API, instructions are modeled by
3142  * LLVMValueRef.
3143  *
3144  * This group also contains sub-groups which operate on specific
3145  * llvm::Instruction types, e.g. llvm::CallInst.
3146  *
3147  * @{
3148  */
3149 
3150 /**
3151  * Determine whether an instruction has any metadata attached.
3152  */
3153 int LLVMHasMetadata(LLVMValueRef Val);
3154 
3155 /**
3156  * Return metadata associated with an instruction value.
3157  */
3158 LLVMValueRef LLVMGetMetadata(LLVMValueRef Val, unsigned KindID);
3159 
3160 /**
3161  * Set metadata associated with an instruction value.
3162  */
3163 void LLVMSetMetadata(LLVMValueRef Val, unsigned KindID, LLVMValueRef Node);
3164 
3165 /**
3166  * Returns the metadata associated with an instruction value, but filters out
3167  * all the debug locations.
3168  *
3169  * @see llvm::Instruction::getAllMetadataOtherThanDebugLoc()
3170  */
3171 LLVMValueMetadataEntry *
3172 LLVMInstructionGetAllMetadataOtherThanDebugLoc(LLVMValueRef Instr,
3173                                                size_t *NumEntries);
3174 
3175 /**
3176  * Obtain the basic block to which an instruction belongs.
3177  *
3178  * @see llvm::Instruction::getParent()
3179  */
3180 LLVMBasicBlockRef LLVMGetInstructionParent(LLVMValueRef Inst);
3181 
3182 /**
3183  * Obtain the instruction that occurs after the one specified.
3184  *
3185  * The next instruction will be from the same basic block.
3186  *
3187  * If this is the last instruction in a basic block, NULL will be
3188  * returned.
3189  */
3190 LLVMValueRef LLVMGetNextInstruction(LLVMValueRef Inst);
3191 
3192 /**
3193  * Obtain the instruction that occurred before this one.
3194  *
3195  * If the instruction is the first instruction in a basic block, NULL
3196  * will be returned.
3197  */
3198 LLVMValueRef LLVMGetPreviousInstruction(LLVMValueRef Inst);
3199 
3200 /**
3201  * Remove and delete an instruction.
3202  *
3203  * The instruction specified is removed from its containing building
3204  * block but is kept alive.
3205  *
3206  * @see llvm::Instruction::removeFromParent()
3207  */
3208 void LLVMInstructionRemoveFromParent(LLVMValueRef Inst);
3209 
3210 /**
3211  * Remove and delete an instruction.
3212  *
3213  * The instruction specified is removed from its containing building
3214  * block and then deleted.
3215  *
3216  * @see llvm::Instruction::eraseFromParent()
3217  */
3218 void LLVMInstructionEraseFromParent(LLVMValueRef Inst);
3219 
3220 /**
3221  * Obtain the code opcode for an individual instruction.
3222  *
3223  * @see llvm::Instruction::getOpCode()
3224  */
3225 LLVMOpcode LLVMGetInstructionOpcode(LLVMValueRef Inst);
3226 
3227 /**
3228  * Obtain the predicate of an instruction.
3229  *
3230  * This is only valid for instructions that correspond to llvm::ICmpInst
3231  * or llvm::ConstantExpr whose opcode is llvm::Instruction::ICmp.
3232  *
3233  * @see llvm::ICmpInst::getPredicate()
3234  */
3235 LLVMIntPredicate LLVMGetICmpPredicate(LLVMValueRef Inst);
3236 
3237 /**
3238  * Obtain the float predicate of an instruction.
3239  *
3240  * This is only valid for instructions that correspond to llvm::FCmpInst
3241  * or llvm::ConstantExpr whose opcode is llvm::Instruction::FCmp.
3242  *
3243  * @see llvm::FCmpInst::getPredicate()
3244  */
3245 LLVMRealPredicate LLVMGetFCmpPredicate(LLVMValueRef Inst);
3246 
3247 /**
3248  * Create a copy of 'this' instruction that is identical in all ways
3249  * except the following:
3250  *   * The instruction has no parent
3251  *   * The instruction has no name
3252  *
3253  * @see llvm::Instruction::clone()
3254  */
3255 LLVMValueRef LLVMInstructionClone(LLVMValueRef Inst);
3256 
3257 /**
3258  * Determine whether an instruction is a terminator. This routine is named to
3259  * be compatible with historical functions that did this by querying the
3260  * underlying C++ type.
3261  *
3262  * @see llvm::Instruction::isTerminator()
3263  */
3264 LLVMValueRef LLVMIsATerminatorInst(LLVMValueRef Inst);
3265 
3266 /**
3267  * @defgroup LLVMCCoreValueInstructionCall Call Sites and Invocations
3268  *
3269  * Functions in this group apply to instructions that refer to call
3270  * sites and invocations. These correspond to C++ types in the
3271  * llvm::CallInst class tree.
3272  *
3273  * @{
3274  */
3275 
3276 /**
3277  * Obtain the argument count for a call instruction.
3278  *
3279  * This expects an LLVMValueRef that corresponds to a llvm::CallInst,
3280  * llvm::InvokeInst, or llvm:FuncletPadInst.
3281  *
3282  * @see llvm::CallInst::getNumArgOperands()
3283  * @see llvm::InvokeInst::getNumArgOperands()
3284  * @see llvm::FuncletPadInst::getNumArgOperands()
3285  */
3286 unsigned LLVMGetNumArgOperands(LLVMValueRef Instr);
3287 
3288 /**
3289  * Set the calling convention for a call instruction.
3290  *
3291  * This expects an LLVMValueRef that corresponds to a llvm::CallInst or
3292  * llvm::InvokeInst.
3293  *
3294  * @see llvm::CallInst::setCallingConv()
3295  * @see llvm::InvokeInst::setCallingConv()
3296  */
3297 void LLVMSetInstructionCallConv(LLVMValueRef Instr, unsigned CC);
3298 
3299 /**
3300  * Obtain the calling convention for a call instruction.
3301  *
3302  * This is the opposite of LLVMSetInstructionCallConv(). Reads its
3303  * usage.
3304  *
3305  * @see LLVMSetInstructionCallConv()
3306  */
3307 unsigned LLVMGetInstructionCallConv(LLVMValueRef Instr);
3308 
3309 void LLVMSetInstrParamAlignment(LLVMValueRef Instr, LLVMAttributeIndex Idx,
3310                                 unsigned Align);
3311 
3312 void LLVMAddCallSiteAttribute(LLVMValueRef C, LLVMAttributeIndex Idx,
3313                               LLVMAttributeRef A);
3314 unsigned LLVMGetCallSiteAttributeCount(LLVMValueRef C, LLVMAttributeIndex Idx);
3315 void LLVMGetCallSiteAttributes(LLVMValueRef C, LLVMAttributeIndex Idx,
3316                                LLVMAttributeRef *Attrs);
3317 LLVMAttributeRef LLVMGetCallSiteEnumAttribute(LLVMValueRef C,
3318                                               LLVMAttributeIndex Idx,
3319                                               unsigned KindID);
3320 LLVMAttributeRef LLVMGetCallSiteStringAttribute(LLVMValueRef C,
3321                                                 LLVMAttributeIndex Idx,
3322                                                 const char *K, unsigned KLen);
3323 void LLVMRemoveCallSiteEnumAttribute(LLVMValueRef C, LLVMAttributeIndex Idx,
3324                                      unsigned KindID);
3325 void LLVMRemoveCallSiteStringAttribute(LLVMValueRef C, LLVMAttributeIndex Idx,
3326                                        const char *K, unsigned KLen);
3327 
3328 /**
3329  * Obtain the function type called by this instruction.
3330  *
3331  * @see llvm::CallBase::getFunctionType()
3332  */
3333 LLVMTypeRef LLVMGetCalledFunctionType(LLVMValueRef C);
3334 
3335 /**
3336  * Obtain the pointer to the function invoked by this instruction.
3337  *
3338  * This expects an LLVMValueRef that corresponds to a llvm::CallInst or
3339  * llvm::InvokeInst.
3340  *
3341  * @see llvm::CallInst::getCalledOperand()
3342  * @see llvm::InvokeInst::getCalledOperand()
3343  */
3344 LLVMValueRef LLVMGetCalledValue(LLVMValueRef Instr);
3345 
3346 /**
3347  * Obtain whether a call instruction is a tail call.
3348  *
3349  * This only works on llvm::CallInst instructions.
3350  *
3351  * @see llvm::CallInst::isTailCall()
3352  */
3353 LLVMBool LLVMIsTailCall(LLVMValueRef CallInst);
3354 
3355 /**
3356  * Set whether a call instruction is a tail call.
3357  *
3358  * This only works on llvm::CallInst instructions.
3359  *
3360  * @see llvm::CallInst::setTailCall()
3361  */
3362 void LLVMSetTailCall(LLVMValueRef CallInst, LLVMBool IsTailCall);
3363 
3364 /**
3365  * Return the normal destination basic block.
3366  *
3367  * This only works on llvm::InvokeInst instructions.
3368  *
3369  * @see llvm::InvokeInst::getNormalDest()
3370  */
3371 LLVMBasicBlockRef LLVMGetNormalDest(LLVMValueRef InvokeInst);
3372 
3373 /**
3374  * Return the unwind destination basic block.
3375  *
3376  * Works on llvm::InvokeInst, llvm::CleanupReturnInst, and
3377  * llvm::CatchSwitchInst instructions.
3378  *
3379  * @see llvm::InvokeInst::getUnwindDest()
3380  * @see llvm::CleanupReturnInst::getUnwindDest()
3381  * @see llvm::CatchSwitchInst::getUnwindDest()
3382  */
3383 LLVMBasicBlockRef LLVMGetUnwindDest(LLVMValueRef InvokeInst);
3384 
3385 /**
3386  * Set the normal destination basic block.
3387  *
3388  * This only works on llvm::InvokeInst instructions.
3389  *
3390  * @see llvm::InvokeInst::setNormalDest()
3391  */
3392 void LLVMSetNormalDest(LLVMValueRef InvokeInst, LLVMBasicBlockRef B);
3393 
3394 /**
3395  * Set the unwind destination basic block.
3396  *
3397  * Works on llvm::InvokeInst, llvm::CleanupReturnInst, and
3398  * llvm::CatchSwitchInst instructions.
3399  *
3400  * @see llvm::InvokeInst::setUnwindDest()
3401  * @see llvm::CleanupReturnInst::setUnwindDest()
3402  * @see llvm::CatchSwitchInst::setUnwindDest()
3403  */
3404 void LLVMSetUnwindDest(LLVMValueRef InvokeInst, LLVMBasicBlockRef B);
3405 
3406 /**
3407  * @}
3408  */
3409 
3410 /**
3411  * @defgroup LLVMCCoreValueInstructionTerminator Terminators
3412  *
3413  * Functions in this group only apply to instructions for which
3414  * LLVMIsATerminatorInst returns true.
3415  *
3416  * @{
3417  */
3418 
3419 /**
3420  * Return the number of successors that this terminator has.
3421  *
3422  * @see llvm::Instruction::getNumSuccessors
3423  */
3424 unsigned LLVMGetNumSuccessors(LLVMValueRef Term);
3425 
3426 /**
3427  * Return the specified successor.
3428  *
3429  * @see llvm::Instruction::getSuccessor
3430  */
3431 LLVMBasicBlockRef LLVMGetSuccessor(LLVMValueRef Term, unsigned i);
3432 
3433 /**
3434  * Update the specified successor to point at the provided block.
3435  *
3436  * @see llvm::Instruction::setSuccessor
3437  */
3438 void LLVMSetSuccessor(LLVMValueRef Term, unsigned i, LLVMBasicBlockRef block);
3439 
3440 /**
3441  * Return if a branch is conditional.
3442  *
3443  * This only works on llvm::BranchInst instructions.
3444  *
3445  * @see llvm::BranchInst::isConditional
3446  */
3447 LLVMBool LLVMIsConditional(LLVMValueRef Branch);
3448 
3449 /**
3450  * Return the condition of a branch instruction.
3451  *
3452  * This only works on llvm::BranchInst instructions.
3453  *
3454  * @see llvm::BranchInst::getCondition
3455  */
3456 LLVMValueRef LLVMGetCondition(LLVMValueRef Branch);
3457 
3458 /**
3459  * Set the condition of a branch instruction.
3460  *
3461  * This only works on llvm::BranchInst instructions.
3462  *
3463  * @see llvm::BranchInst::setCondition
3464  */
3465 void LLVMSetCondition(LLVMValueRef Branch, LLVMValueRef Cond);
3466 
3467 /**
3468  * Obtain the default destination basic block of a switch instruction.
3469  *
3470  * This only works on llvm::SwitchInst instructions.
3471  *
3472  * @see llvm::SwitchInst::getDefaultDest()
3473  */
3474 LLVMBasicBlockRef LLVMGetSwitchDefaultDest(LLVMValueRef SwitchInstr);
3475 
3476 /**
3477  * @}
3478  */
3479 
3480 /**
3481  * @defgroup LLVMCCoreValueInstructionAlloca Allocas
3482  *
3483  * Functions in this group only apply to instructions that map to
3484  * llvm::AllocaInst instances.
3485  *
3486  * @{
3487  */
3488 
3489 /**
3490  * Obtain the type that is being allocated by the alloca instruction.
3491  */
3492 LLVMTypeRef LLVMGetAllocatedType(LLVMValueRef Alloca);
3493 
3494 /**
3495  * @}
3496  */
3497 
3498 /**
3499  * @defgroup LLVMCCoreValueInstructionGetElementPointer GEPs
3500  *
3501  * Functions in this group only apply to instructions that map to
3502  * llvm::GetElementPtrInst instances.
3503  *
3504  * @{
3505  */
3506 
3507 /**
3508  * Check whether the given GEP operator is inbounds.
3509  */
3510 LLVMBool LLVMIsInBounds(LLVMValueRef GEP);
3511 
3512 /**
3513  * Set the given GEP instruction to be inbounds or not.
3514  */
3515 void LLVMSetIsInBounds(LLVMValueRef GEP, LLVMBool InBounds);
3516 
3517 /**
3518  * Get the source element type of the given GEP operator.
3519  */
3520 LLVMTypeRef LLVMGetGEPSourceElementType(LLVMValueRef GEP);
3521 
3522 /**
3523  * @}
3524  */
3525 
3526 /**
3527  * @defgroup LLVMCCoreValueInstructionPHINode PHI Nodes
3528  *
3529  * Functions in this group only apply to instructions that map to
3530  * llvm::PHINode instances.
3531  *
3532  * @{
3533  */
3534 
3535 /**
3536  * Add an incoming value to the end of a PHI list.
3537  */
3538 void LLVMAddIncoming(LLVMValueRef PhiNode, LLVMValueRef *IncomingValues,
3539                      LLVMBasicBlockRef *IncomingBlocks, unsigned Count);
3540 
3541 /**
3542  * Obtain the number of incoming basic blocks to a PHI node.
3543  */
3544 unsigned LLVMCountIncoming(LLVMValueRef PhiNode);
3545 
3546 /**
3547  * Obtain an incoming value to a PHI node as an LLVMValueRef.
3548  */
3549 LLVMValueRef LLVMGetIncomingValue(LLVMValueRef PhiNode, unsigned Index);
3550 
3551 /**
3552  * Obtain an incoming value to a PHI node as an LLVMBasicBlockRef.
3553  */
3554 LLVMBasicBlockRef LLVMGetIncomingBlock(LLVMValueRef PhiNode, unsigned Index);
3555 
3556 /**
3557  * @}
3558  */
3559 
3560 /**
3561  * @defgroup LLVMCCoreValueInstructionExtractValue ExtractValue
3562  * @defgroup LLVMCCoreValueInstructionInsertValue InsertValue
3563  *
3564  * Functions in this group only apply to instructions that map to
3565  * llvm::ExtractValue and llvm::InsertValue instances.
3566  *
3567  * @{
3568  */
3569 
3570 /**
3571  * Obtain the number of indices.
3572  * NB: This also works on GEP operators.
3573  */
3574 unsigned LLVMGetNumIndices(LLVMValueRef Inst);
3575 
3576 /**
3577  * Obtain the indices as an array.
3578  */
3579 const unsigned *LLVMGetIndices(LLVMValueRef Inst);
3580 
3581 /**
3582  * @}
3583  */
3584 
3585 /**
3586  * @}
3587  */
3588 
3589 /**
3590  * @}
3591  */
3592 
3593 /**
3594  * @defgroup LLVMCCoreInstructionBuilder Instruction Builders
3595  *
3596  * An instruction builder represents a point within a basic block and is
3597  * the exclusive means of building instructions using the C interface.
3598  *
3599  * @{
3600  */
3601 
3602 LLVMBuilderRef LLVMCreateBuilderInContext(LLVMContextRef C);
3603 LLVMBuilderRef LLVMCreateBuilder(void);
3604 void LLVMPositionBuilder(LLVMBuilderRef Builder, LLVMBasicBlockRef Block,
3605                          LLVMValueRef Instr);
3606 void LLVMPositionBuilderBefore(LLVMBuilderRef Builder, LLVMValueRef Instr);
3607 void LLVMPositionBuilderAtEnd(LLVMBuilderRef Builder, LLVMBasicBlockRef Block);
3608 LLVMBasicBlockRef LLVMGetInsertBlock(LLVMBuilderRef Builder);
3609 void LLVMClearInsertionPosition(LLVMBuilderRef Builder);
3610 void LLVMInsertIntoBuilder(LLVMBuilderRef Builder, LLVMValueRef Instr);
3611 void LLVMInsertIntoBuilderWithName(LLVMBuilderRef Builder, LLVMValueRef Instr,
3612                                    const char *Name);
3613 void LLVMDisposeBuilder(LLVMBuilderRef Builder);
3614 
3615 /* Metadata */
3616 
3617 /**
3618  * Get location information used by debugging information.
3619  *
3620  * @see llvm::IRBuilder::getCurrentDebugLocation()
3621  */
3622 LLVMMetadataRef LLVMGetCurrentDebugLocation2(LLVMBuilderRef Builder);
3623 
3624 /**
3625  * Set location information used by debugging information.
3626  *
3627  * To clear the location metadata of the given instruction, pass NULL to \p Loc.
3628  *
3629  * @see llvm::IRBuilder::SetCurrentDebugLocation()
3630  */
3631 void LLVMSetCurrentDebugLocation2(LLVMBuilderRef Builder, LLVMMetadataRef Loc);
3632 
3633 /**
3634  * Attempts to set the debug location for the given instruction using the
3635  * current debug location for the given builder.  If the builder has no current
3636  * debug location, this function is a no-op.
3637  *
3638  * @deprecated LLVMSetInstDebugLocation is deprecated in favor of the more general
3639  *             LLVMAddMetadataToInst.
3640  *
3641  * @see llvm::IRBuilder::SetInstDebugLocation()
3642  */
3643 void LLVMSetInstDebugLocation(LLVMBuilderRef Builder, LLVMValueRef Inst);
3644 
3645 /**
3646  * Adds the metadata registered with the given builder to the given instruction.
3647  *
3648  * @see llvm::IRBuilder::AddMetadataToInst()
3649  */
3650 void LLVMAddMetadataToInst(LLVMBuilderRef Builder, LLVMValueRef Inst);
3651 
3652 /**
3653  * Get the dafult floating-point math metadata for a given builder.
3654  *
3655  * @see llvm::IRBuilder::getDefaultFPMathTag()
3656  */
3657 LLVMMetadataRef LLVMBuilderGetDefaultFPMathTag(LLVMBuilderRef Builder);
3658 
3659 /**
3660  * Set the default floating-point math metadata for the given builder.
3661  *
3662  * To clear the metadata, pass NULL to \p FPMathTag.
3663  *
3664  * @see llvm::IRBuilder::setDefaultFPMathTag()
3665  */
3666 void LLVMBuilderSetDefaultFPMathTag(LLVMBuilderRef Builder,
3667                                     LLVMMetadataRef FPMathTag);
3668 
3669 /**
3670  * Deprecated: Passing the NULL location will crash.
3671  * Use LLVMGetCurrentDebugLocation2 instead.
3672  */
3673 void LLVMSetCurrentDebugLocation(LLVMBuilderRef Builder, LLVMValueRef L);
3674 /**
3675  * Deprecated: Returning the NULL location will crash.
3676  * Use LLVMGetCurrentDebugLocation2 instead.
3677  */
3678 LLVMValueRef LLVMGetCurrentDebugLocation(LLVMBuilderRef Builder);
3679 
3680 /* Terminators */
3681 LLVMValueRef LLVMBuildRetVoid(LLVMBuilderRef);
3682 LLVMValueRef LLVMBuildRet(LLVMBuilderRef, LLVMValueRef V);
3683 LLVMValueRef LLVMBuildAggregateRet(LLVMBuilderRef, LLVMValueRef *RetVals,
3684                                    unsigned N);
3685 LLVMValueRef LLVMBuildBr(LLVMBuilderRef, LLVMBasicBlockRef Dest);
3686 LLVMValueRef LLVMBuildCondBr(LLVMBuilderRef, LLVMValueRef If,
3687                              LLVMBasicBlockRef Then, LLVMBasicBlockRef Else);
3688 LLVMValueRef LLVMBuildSwitch(LLVMBuilderRef, LLVMValueRef V,
3689                              LLVMBasicBlockRef Else, unsigned NumCases);
3690 LLVMValueRef LLVMBuildIndirectBr(LLVMBuilderRef B, LLVMValueRef Addr,
3691                                  unsigned NumDests);
3692 LLVM_ATTRIBUTE_C_DEPRECATED(
3693     LLVMValueRef LLVMBuildInvoke(LLVMBuilderRef, LLVMValueRef Fn,
3694                                  LLVMValueRef *Args, unsigned NumArgs,
3695                                  LLVMBasicBlockRef Then,
3696                                  LLVMBasicBlockRef Catch, const char *Name),
3697     "Use LLVMBuildInvoke2 instead to support opaque pointers");
3698 LLVMValueRef LLVMBuildInvoke2(LLVMBuilderRef, LLVMTypeRef Ty, LLVMValueRef Fn,
3699                               LLVMValueRef *Args, unsigned NumArgs,
3700                               LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch,
3701                               const char *Name);
3702 LLVMValueRef LLVMBuildUnreachable(LLVMBuilderRef);
3703 
3704 /* Exception Handling */
3705 LLVMValueRef LLVMBuildResume(LLVMBuilderRef B, LLVMValueRef Exn);
3706 LLVMValueRef LLVMBuildLandingPad(LLVMBuilderRef B, LLVMTypeRef Ty,
3707                                  LLVMValueRef PersFn, unsigned NumClauses,
3708                                  const char *Name);
3709 LLVMValueRef LLVMBuildCleanupRet(LLVMBuilderRef B, LLVMValueRef CatchPad,
3710                                  LLVMBasicBlockRef BB);
3711 LLVMValueRef LLVMBuildCatchRet(LLVMBuilderRef B, LLVMValueRef CatchPad,
3712                                LLVMBasicBlockRef BB);
3713 LLVMValueRef LLVMBuildCatchPad(LLVMBuilderRef B, LLVMValueRef ParentPad,
3714                                LLVMValueRef *Args, unsigned NumArgs,
3715                                const char *Name);
3716 LLVMValueRef LLVMBuildCleanupPad(LLVMBuilderRef B, LLVMValueRef ParentPad,
3717                                  LLVMValueRef *Args, unsigned NumArgs,
3718                                  const char *Name);
3719 LLVMValueRef LLVMBuildCatchSwitch(LLVMBuilderRef B, LLVMValueRef ParentPad,
3720                                   LLVMBasicBlockRef UnwindBB,
3721                                   unsigned NumHandlers, const char *Name);
3722 
3723 /* Add a case to the switch instruction */
3724 void LLVMAddCase(LLVMValueRef Switch, LLVMValueRef OnVal,
3725                  LLVMBasicBlockRef Dest);
3726 
3727 /* Add a destination to the indirectbr instruction */
3728 void LLVMAddDestination(LLVMValueRef IndirectBr, LLVMBasicBlockRef Dest);
3729 
3730 /* Get the number of clauses on the landingpad instruction */
3731 unsigned LLVMGetNumClauses(LLVMValueRef LandingPad);
3732 
3733 /* Get the value of the clause at index Idx on the landingpad instruction */
3734 LLVMValueRef LLVMGetClause(LLVMValueRef LandingPad, unsigned Idx);
3735 
3736 /* Add a catch or filter clause to the landingpad instruction */
3737 void LLVMAddClause(LLVMValueRef LandingPad, LLVMValueRef ClauseVal);
3738 
3739 /* Get the 'cleanup' flag in the landingpad instruction */
3740 LLVMBool LLVMIsCleanup(LLVMValueRef LandingPad);
3741 
3742 /* Set the 'cleanup' flag in the landingpad instruction */
3743 void LLVMSetCleanup(LLVMValueRef LandingPad, LLVMBool Val);
3744 
3745 /* Add a destination to the catchswitch instruction */
3746 void LLVMAddHandler(LLVMValueRef CatchSwitch, LLVMBasicBlockRef Dest);
3747 
3748 /* Get the number of handlers on the catchswitch instruction */
3749 unsigned LLVMGetNumHandlers(LLVMValueRef CatchSwitch);
3750 
3751 /**
3752  * Obtain the basic blocks acting as handlers for a catchswitch instruction.
3753  *
3754  * The Handlers parameter should point to a pre-allocated array of
3755  * LLVMBasicBlockRefs at least LLVMGetNumHandlers() large. On return, the
3756  * first LLVMGetNumHandlers() entries in the array will be populated
3757  * with LLVMBasicBlockRef instances.
3758  *
3759  * @param CatchSwitch The catchswitch instruction to operate on.
3760  * @param Handlers Memory address of an array to be filled with basic blocks.
3761  */
3762 void LLVMGetHandlers(LLVMValueRef CatchSwitch, LLVMBasicBlockRef *Handlers);
3763 
3764 /* Funclets */
3765 
3766 /* Get the number of funcletpad arguments. */
3767 LLVMValueRef LLVMGetArgOperand(LLVMValueRef Funclet, unsigned i);
3768 
3769 /* Set a funcletpad argument at the given index. */
3770 void LLVMSetArgOperand(LLVMValueRef Funclet, unsigned i, LLVMValueRef value);
3771 
3772 /**
3773  * Get the parent catchswitch instruction of a catchpad instruction.
3774  *
3775  * This only works on llvm::CatchPadInst instructions.
3776  *
3777  * @see llvm::CatchPadInst::getCatchSwitch()
3778  */
3779 LLVMValueRef LLVMGetParentCatchSwitch(LLVMValueRef CatchPad);
3780 
3781 /**
3782  * Set the parent catchswitch instruction of a catchpad instruction.
3783  *
3784  * This only works on llvm::CatchPadInst instructions.
3785  *
3786  * @see llvm::CatchPadInst::setCatchSwitch()
3787  */
3788 void LLVMSetParentCatchSwitch(LLVMValueRef CatchPad, LLVMValueRef CatchSwitch);
3789 
3790 /* Arithmetic */
3791 LLVMValueRef LLVMBuildAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3792                           const char *Name);
3793 LLVMValueRef LLVMBuildNSWAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3794                              const char *Name);
3795 LLVMValueRef LLVMBuildNUWAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3796                              const char *Name);
3797 LLVMValueRef LLVMBuildFAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3798                            const char *Name);
3799 LLVMValueRef LLVMBuildSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3800                           const char *Name);
3801 LLVMValueRef LLVMBuildNSWSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3802                              const char *Name);
3803 LLVMValueRef LLVMBuildNUWSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3804                              const char *Name);
3805 LLVMValueRef LLVMBuildFSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3806                            const char *Name);
3807 LLVMValueRef LLVMBuildMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3808                           const char *Name);
3809 LLVMValueRef LLVMBuildNSWMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3810                              const char *Name);
3811 LLVMValueRef LLVMBuildNUWMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3812                              const char *Name);
3813 LLVMValueRef LLVMBuildFMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3814                            const char *Name);
3815 LLVMValueRef LLVMBuildUDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3816                            const char *Name);
3817 LLVMValueRef LLVMBuildExactUDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3818                                 const char *Name);
3819 LLVMValueRef LLVMBuildSDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3820                            const char *Name);
3821 LLVMValueRef LLVMBuildExactSDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3822                                 const char *Name);
3823 LLVMValueRef LLVMBuildFDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3824                            const char *Name);
3825 LLVMValueRef LLVMBuildURem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3826                            const char *Name);
3827 LLVMValueRef LLVMBuildSRem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3828                            const char *Name);
3829 LLVMValueRef LLVMBuildFRem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3830                            const char *Name);
3831 LLVMValueRef LLVMBuildShl(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3832                            const char *Name);
3833 LLVMValueRef LLVMBuildLShr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3834                            const char *Name);
3835 LLVMValueRef LLVMBuildAShr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3836                            const char *Name);
3837 LLVMValueRef LLVMBuildAnd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3838                           const char *Name);
3839 LLVMValueRef LLVMBuildOr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3840                           const char *Name);
3841 LLVMValueRef LLVMBuildXor(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
3842                           const char *Name);
3843 LLVMValueRef LLVMBuildBinOp(LLVMBuilderRef B, LLVMOpcode Op,
3844                             LLVMValueRef LHS, LLVMValueRef RHS,
3845                             const char *Name);
3846 LLVMValueRef LLVMBuildNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name);
3847 LLVMValueRef LLVMBuildNSWNeg(LLVMBuilderRef B, LLVMValueRef V,
3848                              const char *Name);
3849 LLVMValueRef LLVMBuildNUWNeg(LLVMBuilderRef B, LLVMValueRef V,
3850                              const char *Name);
3851 LLVMValueRef LLVMBuildFNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name);
3852 LLVMValueRef LLVMBuildNot(LLVMBuilderRef, LLVMValueRef V, const char *Name);
3853 
3854 /* Memory */
3855 LLVMValueRef LLVMBuildMalloc(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
3856 LLVMValueRef LLVMBuildArrayMalloc(LLVMBuilderRef, LLVMTypeRef Ty,
3857                                   LLVMValueRef Val, const char *Name);
3858 
3859 /**
3860  * Creates and inserts a memset to the specified pointer and the
3861  * specified value.
3862  *
3863  * @see llvm::IRRBuilder::CreateMemSet()
3864  */
3865 LLVMValueRef LLVMBuildMemSet(LLVMBuilderRef B, LLVMValueRef Ptr,
3866                              LLVMValueRef Val, LLVMValueRef Len,
3867                              unsigned Align);
3868 /**
3869  * Creates and inserts a memcpy between the specified pointers.
3870  *
3871  * @see llvm::IRRBuilder::CreateMemCpy()
3872  */
3873 LLVMValueRef LLVMBuildMemCpy(LLVMBuilderRef B,
3874                              LLVMValueRef Dst, unsigned DstAlign,
3875                              LLVMValueRef Src, unsigned SrcAlign,
3876                              LLVMValueRef Size);
3877 /**
3878  * Creates and inserts a memmove between the specified pointers.
3879  *
3880  * @see llvm::IRRBuilder::CreateMemMove()
3881  */
3882 LLVMValueRef LLVMBuildMemMove(LLVMBuilderRef B,
3883                               LLVMValueRef Dst, unsigned DstAlign,
3884                               LLVMValueRef Src, unsigned SrcAlign,
3885                               LLVMValueRef Size);
3886 
3887 LLVMValueRef LLVMBuildAlloca(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
3888 LLVMValueRef LLVMBuildArrayAlloca(LLVMBuilderRef, LLVMTypeRef Ty,
3889                                   LLVMValueRef Val, const char *Name);
3890 LLVMValueRef LLVMBuildFree(LLVMBuilderRef, LLVMValueRef PointerVal);
3891 LLVM_ATTRIBUTE_C_DEPRECATED(
3892     LLVMValueRef LLVMBuildLoad(LLVMBuilderRef, LLVMValueRef PointerVal,
3893                                const char *Name),
3894     "Use LLVMBuildLoad2 instead to support opaque pointers");
3895 LLVMValueRef LLVMBuildLoad2(LLVMBuilderRef, LLVMTypeRef Ty,
3896                             LLVMValueRef PointerVal, const char *Name);
3897 LLVMValueRef LLVMBuildStore(LLVMBuilderRef, LLVMValueRef Val, LLVMValueRef Ptr);
3898 LLVM_ATTRIBUTE_C_DEPRECATED(
3899     LLVMValueRef LLVMBuildGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
3900                               LLVMValueRef *Indices, unsigned NumIndices,
3901                               const char *Name),
3902     "Use LLVMBuildGEP2 instead to support opaque pointers");
3903 LLVM_ATTRIBUTE_C_DEPRECATED(
3904     LLVMValueRef LLVMBuildInBoundsGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
3905                                       LLVMValueRef *Indices,
3906                                       unsigned NumIndices, const char *Name),
3907     "Use LLVMBuildInBoundsGEP2 instead to support opaque pointers");
3908 LLVM_ATTRIBUTE_C_DEPRECATED(
3909     LLVMValueRef LLVMBuildStructGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
3910                                     unsigned Idx, const char *Name),
3911     "Use LLVMBuildStructGEP2 instead to support opaque pointers");
3912 LLVMValueRef LLVMBuildGEP2(LLVMBuilderRef B, LLVMTypeRef Ty,
3913                            LLVMValueRef Pointer, LLVMValueRef *Indices,
3914                            unsigned NumIndices, const char *Name);
3915 LLVMValueRef LLVMBuildInBoundsGEP2(LLVMBuilderRef B, LLVMTypeRef Ty,
3916                                    LLVMValueRef Pointer, LLVMValueRef *Indices,
3917                                    unsigned NumIndices, const char *Name);
3918 LLVMValueRef LLVMBuildStructGEP2(LLVMBuilderRef B, LLVMTypeRef Ty,
3919                                  LLVMValueRef Pointer, unsigned Idx,
3920                                  const char *Name);
3921 LLVMValueRef LLVMBuildGlobalString(LLVMBuilderRef B, const char *Str,
3922                                    const char *Name);
3923 LLVMValueRef LLVMBuildGlobalStringPtr(LLVMBuilderRef B, const char *Str,
3924                                       const char *Name);
3925 LLVMBool LLVMGetVolatile(LLVMValueRef MemoryAccessInst);
3926 void LLVMSetVolatile(LLVMValueRef MemoryAccessInst, LLVMBool IsVolatile);
3927 LLVMBool LLVMGetWeak(LLVMValueRef CmpXchgInst);
3928 void LLVMSetWeak(LLVMValueRef CmpXchgInst, LLVMBool IsWeak);
3929 LLVMAtomicOrdering LLVMGetOrdering(LLVMValueRef MemoryAccessInst);
3930 void LLVMSetOrdering(LLVMValueRef MemoryAccessInst, LLVMAtomicOrdering Ordering);
3931 LLVMAtomicRMWBinOp LLVMGetAtomicRMWBinOp(LLVMValueRef AtomicRMWInst);
3932 void LLVMSetAtomicRMWBinOp(LLVMValueRef AtomicRMWInst, LLVMAtomicRMWBinOp BinOp);
3933 
3934 /* Casts */
3935 LLVMValueRef LLVMBuildTrunc(LLVMBuilderRef, LLVMValueRef Val,
3936                             LLVMTypeRef DestTy, const char *Name);
3937 LLVMValueRef LLVMBuildZExt(LLVMBuilderRef, LLVMValueRef Val,
3938                            LLVMTypeRef DestTy, const char *Name);
3939 LLVMValueRef LLVMBuildSExt(LLVMBuilderRef, LLVMValueRef Val,
3940                            LLVMTypeRef DestTy, const char *Name);
3941 LLVMValueRef LLVMBuildFPToUI(LLVMBuilderRef, LLVMValueRef Val,
3942                              LLVMTypeRef DestTy, const char *Name);
3943 LLVMValueRef LLVMBuildFPToSI(LLVMBuilderRef, LLVMValueRef Val,
3944                              LLVMTypeRef DestTy, const char *Name);
3945 LLVMValueRef LLVMBuildUIToFP(LLVMBuilderRef, LLVMValueRef Val,
3946                              LLVMTypeRef DestTy, const char *Name);
3947 LLVMValueRef LLVMBuildSIToFP(LLVMBuilderRef, LLVMValueRef Val,
3948                              LLVMTypeRef DestTy, const char *Name);
3949 LLVMValueRef LLVMBuildFPTrunc(LLVMBuilderRef, LLVMValueRef Val,
3950                               LLVMTypeRef DestTy, const char *Name);
3951 LLVMValueRef LLVMBuildFPExt(LLVMBuilderRef, LLVMValueRef Val,
3952                             LLVMTypeRef DestTy, const char *Name);
3953 LLVMValueRef LLVMBuildPtrToInt(LLVMBuilderRef, LLVMValueRef Val,
3954                                LLVMTypeRef DestTy, const char *Name);
3955 LLVMValueRef LLVMBuildIntToPtr(LLVMBuilderRef, LLVMValueRef Val,
3956                                LLVMTypeRef DestTy, const char *Name);
3957 LLVMValueRef LLVMBuildBitCast(LLVMBuilderRef, LLVMValueRef Val,
3958                               LLVMTypeRef DestTy, const char *Name);
3959 LLVMValueRef LLVMBuildAddrSpaceCast(LLVMBuilderRef, LLVMValueRef Val,
3960                                     LLVMTypeRef DestTy, const char *Name);
3961 LLVMValueRef LLVMBuildZExtOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
3962                                     LLVMTypeRef DestTy, const char *Name);
3963 LLVMValueRef LLVMBuildSExtOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
3964                                     LLVMTypeRef DestTy, const char *Name);
3965 LLVMValueRef LLVMBuildTruncOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
3966                                      LLVMTypeRef DestTy, const char *Name);
3967 LLVMValueRef LLVMBuildCast(LLVMBuilderRef B, LLVMOpcode Op, LLVMValueRef Val,
3968                            LLVMTypeRef DestTy, const char *Name);
3969 LLVMValueRef LLVMBuildPointerCast(LLVMBuilderRef, LLVMValueRef Val,
3970                                   LLVMTypeRef DestTy, const char *Name);
3971 LLVMValueRef LLVMBuildIntCast2(LLVMBuilderRef, LLVMValueRef Val,
3972                                LLVMTypeRef DestTy, LLVMBool IsSigned,
3973                                const char *Name);
3974 LLVMValueRef LLVMBuildFPCast(LLVMBuilderRef, LLVMValueRef Val,
3975                              LLVMTypeRef DestTy, const char *Name);
3976 
3977 /** Deprecated: This cast is always signed. Use LLVMBuildIntCast2 instead. */
3978 LLVMValueRef LLVMBuildIntCast(LLVMBuilderRef, LLVMValueRef Val, /*Signed cast!*/
3979                               LLVMTypeRef DestTy, const char *Name);
3980 
3981 /* Comparisons */
3982 LLVMValueRef LLVMBuildICmp(LLVMBuilderRef, LLVMIntPredicate Op,
3983                            LLVMValueRef LHS, LLVMValueRef RHS,
3984                            const char *Name);
3985 LLVMValueRef LLVMBuildFCmp(LLVMBuilderRef, LLVMRealPredicate Op,
3986                            LLVMValueRef LHS, LLVMValueRef RHS,
3987                            const char *Name);
3988 
3989 /* Miscellaneous instructions */
3990 LLVMValueRef LLVMBuildPhi(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
3991 LLVM_ATTRIBUTE_C_DEPRECATED(
3992     LLVMValueRef LLVMBuildCall(LLVMBuilderRef, LLVMValueRef Fn,
3993                                LLVMValueRef *Args, unsigned NumArgs,
3994                                const char *Name),
3995     "Use LLVMBuildCall2 instead to support opaque pointers");
3996 LLVMValueRef LLVMBuildCall2(LLVMBuilderRef, LLVMTypeRef, LLVMValueRef Fn,
3997                             LLVMValueRef *Args, unsigned NumArgs,
3998                             const char *Name);
3999 LLVMValueRef LLVMBuildSelect(LLVMBuilderRef, LLVMValueRef If,
4000                              LLVMValueRef Then, LLVMValueRef Else,
4001                              const char *Name);
4002 LLVMValueRef LLVMBuildVAArg(LLVMBuilderRef, LLVMValueRef List, LLVMTypeRef Ty,
4003                             const char *Name);
4004 LLVMValueRef LLVMBuildExtractElement(LLVMBuilderRef, LLVMValueRef VecVal,
4005                                      LLVMValueRef Index, const char *Name);
4006 LLVMValueRef LLVMBuildInsertElement(LLVMBuilderRef, LLVMValueRef VecVal,
4007                                     LLVMValueRef EltVal, LLVMValueRef Index,
4008                                     const char *Name);
4009 LLVMValueRef LLVMBuildShuffleVector(LLVMBuilderRef, LLVMValueRef V1,
4010                                     LLVMValueRef V2, LLVMValueRef Mask,
4011                                     const char *Name);
4012 LLVMValueRef LLVMBuildExtractValue(LLVMBuilderRef, LLVMValueRef AggVal,
4013                                    unsigned Index, const char *Name);
4014 LLVMValueRef LLVMBuildInsertValue(LLVMBuilderRef, LLVMValueRef AggVal,
4015                                   LLVMValueRef EltVal, unsigned Index,
4016                                   const char *Name);
4017 LLVMValueRef LLVMBuildFreeze(LLVMBuilderRef, LLVMValueRef Val,
4018                              const char *Name);
4019 
4020 LLVMValueRef LLVMBuildIsNull(LLVMBuilderRef, LLVMValueRef Val,
4021                              const char *Name);
4022 LLVMValueRef LLVMBuildIsNotNull(LLVMBuilderRef, LLVMValueRef Val,
4023                                 const char *Name);
4024 LLVM_ATTRIBUTE_C_DEPRECATED(
4025     LLVMValueRef LLVMBuildPtrDiff(LLVMBuilderRef, LLVMValueRef LHS,
4026                                   LLVMValueRef RHS, const char *Name),
4027     "Use LLVMBuildPtrDiff2 instead to support opaque pointers");
4028 LLVMValueRef LLVMBuildPtrDiff2(LLVMBuilderRef, LLVMTypeRef ElemTy,
4029                                LLVMValueRef LHS, LLVMValueRef RHS,
4030                                const char *Name);
4031 LLVMValueRef LLVMBuildFence(LLVMBuilderRef B, LLVMAtomicOrdering ordering,
4032                             LLVMBool singleThread, const char *Name);
4033 LLVMValueRef LLVMBuildAtomicRMW(LLVMBuilderRef B, LLVMAtomicRMWBinOp op,
4034                                 LLVMValueRef PTR, LLVMValueRef Val,
4035                                 LLVMAtomicOrdering ordering,
4036                                 LLVMBool singleThread);
4037 LLVMValueRef LLVMBuildAtomicCmpXchg(LLVMBuilderRef B, LLVMValueRef Ptr,
4038                                     LLVMValueRef Cmp, LLVMValueRef New,
4039                                     LLVMAtomicOrdering SuccessOrdering,
4040                                     LLVMAtomicOrdering FailureOrdering,
4041                                     LLVMBool SingleThread);
4042 
4043 /**
4044  * Get the number of elements in the mask of a ShuffleVector instruction.
4045  */
4046 unsigned LLVMGetNumMaskElements(LLVMValueRef ShuffleVectorInst);
4047 
4048 /**
4049  * \returns a constant that specifies that the result of a \c ShuffleVectorInst
4050  * is undefined.
4051  */
4052 int LLVMGetUndefMaskElem(void);
4053 
4054 /**
4055  * Get the mask value at position Elt in the mask of a ShuffleVector
4056  * instruction.
4057  *
4058  * \Returns the result of \c LLVMGetUndefMaskElem() if the mask value is undef
4059  * at that position.
4060  */
4061 int LLVMGetMaskValue(LLVMValueRef ShuffleVectorInst, unsigned Elt);
4062 
4063 LLVMBool LLVMIsAtomicSingleThread(LLVMValueRef AtomicInst);
4064 void LLVMSetAtomicSingleThread(LLVMValueRef AtomicInst, LLVMBool SingleThread);
4065 
4066 LLVMAtomicOrdering LLVMGetCmpXchgSuccessOrdering(LLVMValueRef CmpXchgInst);
4067 void LLVMSetCmpXchgSuccessOrdering(LLVMValueRef CmpXchgInst,
4068                                    LLVMAtomicOrdering Ordering);
4069 LLVMAtomicOrdering LLVMGetCmpXchgFailureOrdering(LLVMValueRef CmpXchgInst);
4070 void LLVMSetCmpXchgFailureOrdering(LLVMValueRef CmpXchgInst,
4071                                    LLVMAtomicOrdering Ordering);
4072 
4073 /**
4074  * @}
4075  */
4076 
4077 /**
4078  * @defgroup LLVMCCoreModuleProvider Module Providers
4079  *
4080  * @{
4081  */
4082 
4083 /**
4084  * Changes the type of M so it can be passed to FunctionPassManagers and the
4085  * JIT.  They take ModuleProviders for historical reasons.
4086  */
4087 LLVMModuleProviderRef
4088 LLVMCreateModuleProviderForExistingModule(LLVMModuleRef M);
4089 
4090 /**
4091  * Destroys the module M.
4092  */
4093 void LLVMDisposeModuleProvider(LLVMModuleProviderRef M);
4094 
4095 /**
4096  * @}
4097  */
4098 
4099 /**
4100  * @defgroup LLVMCCoreMemoryBuffers Memory Buffers
4101  *
4102  * @{
4103  */
4104 
4105 LLVMBool LLVMCreateMemoryBufferWithContentsOfFile(const char *Path,
4106                                                   LLVMMemoryBufferRef *OutMemBuf,
4107                                                   char **OutMessage);
4108 LLVMBool LLVMCreateMemoryBufferWithSTDIN(LLVMMemoryBufferRef *OutMemBuf,
4109                                          char **OutMessage);
4110 LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRange(const char *InputData,
4111                                                           size_t InputDataLength,
4112                                                           const char *BufferName,
4113                                                           LLVMBool RequiresNullTerminator);
4114 LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRangeCopy(const char *InputData,
4115                                                               size_t InputDataLength,
4116                                                               const char *BufferName);
4117 const char *LLVMGetBufferStart(LLVMMemoryBufferRef MemBuf);
4118 size_t LLVMGetBufferSize(LLVMMemoryBufferRef MemBuf);
4119 void LLVMDisposeMemoryBuffer(LLVMMemoryBufferRef MemBuf);
4120 
4121 /**
4122  * @}
4123  */
4124 
4125 /**
4126  * @defgroup LLVMCCorePassRegistry Pass Registry
4127  * @ingroup LLVMCCore
4128  *
4129  * @{
4130  */
4131 
4132 /** Return the global pass registry, for use with initialization functions.
4133     @see llvm::PassRegistry::getPassRegistry */
4134 LLVMPassRegistryRef LLVMGetGlobalPassRegistry(void);
4135 
4136 /**
4137  * @}
4138  */
4139 
4140 /**
4141  * @defgroup LLVMCCorePassManagers Pass Managers
4142  * @ingroup LLVMCCore
4143  *
4144  * @{
4145  */
4146 
4147 /** Constructs a new whole-module pass pipeline. This type of pipeline is
4148     suitable for link-time optimization and whole-module transformations.
4149     @see llvm::PassManager::PassManager */
4150 LLVMPassManagerRef LLVMCreatePassManager(void);
4151 
4152 /** Constructs a new function-by-function pass pipeline over the module
4153     provider. It does not take ownership of the module provider. This type of
4154     pipeline is suitable for code generation and JIT compilation tasks.
4155     @see llvm::FunctionPassManager::FunctionPassManager */
4156 LLVMPassManagerRef LLVMCreateFunctionPassManagerForModule(LLVMModuleRef M);
4157 
4158 /** Deprecated: Use LLVMCreateFunctionPassManagerForModule instead. */
4159 LLVMPassManagerRef LLVMCreateFunctionPassManager(LLVMModuleProviderRef MP);
4160 
4161 /** Initializes, executes on the provided module, and finalizes all of the
4162     passes scheduled in the pass manager. Returns 1 if any of the passes
4163     modified the module, 0 otherwise.
4164     @see llvm::PassManager::run(Module&) */
4165 LLVMBool LLVMRunPassManager(LLVMPassManagerRef PM, LLVMModuleRef M);
4166 
4167 /** Initializes all of the function passes scheduled in the function pass
4168     manager. Returns 1 if any of the passes modified the module, 0 otherwise.
4169     @see llvm::FunctionPassManager::doInitialization */
4170 LLVMBool LLVMInitializeFunctionPassManager(LLVMPassManagerRef FPM);
4171 
4172 /** Executes all of the function passes scheduled in the function pass manager
4173     on the provided function. Returns 1 if any of the passes modified the
4174     function, false otherwise.
4175     @see llvm::FunctionPassManager::run(Function&) */
4176 LLVMBool LLVMRunFunctionPassManager(LLVMPassManagerRef FPM, LLVMValueRef F);
4177 
4178 /** Finalizes all of the function passes scheduled in the function pass
4179     manager. Returns 1 if any of the passes modified the module, 0 otherwise.
4180     @see llvm::FunctionPassManager::doFinalization */
4181 LLVMBool LLVMFinalizeFunctionPassManager(LLVMPassManagerRef FPM);
4182 
4183 /** Frees the memory of a pass pipeline. For function pipelines, does not free
4184     the module provider.
4185     @see llvm::PassManagerBase::~PassManagerBase. */
4186 void LLVMDisposePassManager(LLVMPassManagerRef PM);
4187 
4188 /**
4189  * @}
4190  */
4191 
4192 /**
4193  * @defgroup LLVMCCoreThreading Threading
4194  *
4195  * Handle the structures needed to make LLVM safe for multithreading.
4196  *
4197  * @{
4198  */
4199 
4200 /** Deprecated: Multi-threading can only be enabled/disabled with the compile
4201     time define LLVM_ENABLE_THREADS.  This function always returns
4202     LLVMIsMultithreaded(). */
4203 LLVMBool LLVMStartMultithreaded(void);
4204 
4205 /** Deprecated: Multi-threading can only be enabled/disabled with the compile
4206     time define LLVM_ENABLE_THREADS. */
4207 void LLVMStopMultithreaded(void);
4208 
4209 /** Check whether LLVM is executing in thread-safe mode or not.
4210     @see llvm::llvm_is_multithreaded */
4211 LLVMBool LLVMIsMultithreaded(void);
4212 
4213 /**
4214  * @}
4215  */
4216 
4217 /**
4218  * @}
4219  */
4220 
4221 /**
4222  * @}
4223  */
4224 
4225 LLVM_C_EXTERN_C_END
4226 
4227 #endif /* LLVM_C_CORE_H */
4228