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