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