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