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