Home | History | Annotate | Download | only in llvm-c
      1 /*===-- llvm-c/Core.h - Core Library C Interface ------------------*- C -*-===*\
      2 |*                                                                            *|
      3 |*                     The LLVM Compiler Infrastructure                       *|
      4 |*                                                                            *|
      5 |* This file is distributed under the University of Illinois Open Source      *|
      6 |* License. See LICENSE.TXT for details.                                      *|
      7 |*                                                                            *|
      8 |*===----------------------------------------------------------------------===*|
      9 |*                                                                            *|
     10 |* This header declares the C interface to libLLVMCore.a, which implements    *|
     11 |* the LLVM intermediate representation.                                      *|
     12 |*                                                                            *|
     13 \*===----------------------------------------------------------------------===*/
     14 
     15 #ifndef LLVM_C_CORE_H
     16 #define LLVM_C_CORE_H
     17 
     18 #include "llvm-c/Support.h"
     19 
     20 #ifdef __cplusplus
     21 extern "C" {
     22 #endif
     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  * LLVM uses a polymorphic type hierarchy which C cannot represent, therefore
     44  * parameters must be passed as base types. Despite the declared types, most
     45  * of the functions provided operate only on branches of the type hierarchy.
     46  * The declared parameter names are descriptive and specify which type is
     47  * required. Additionally, each type hierarchy is documented along with the
     48  * functions that operate upon it. For more detail, refer to LLVM's C++ code.
     49  * If in doubt, refer to Core.cpp, which performs parameter downcasts in the
     50  * form unwrap<RequiredType>(Param).
     51  *
     52  * Many exotic languages can interoperate with C code but have a harder time
     53  * with C++ due to name mangling. So in addition to C, this interface enables
     54  * tools written in such languages.
     55  *
     56  * @{
     57  */
     58 
     59 /**
     60  * @defgroup LLVMCCoreTypes Types and Enumerations
     61  *
     62  * @{
     63  */
     64 
     65 /* Opaque types. */
     66 
     67 /**
     68  * The top-level container for all LLVM global data. See the LLVMContext class.
     69  */
     70 typedef struct LLVMOpaqueContext *LLVMContextRef;
     71 
     72 /**
     73  * The top-level container for all other LLVM Intermediate Representation (IR)
     74  * objects.
     75  *
     76  * @see llvm::Module
     77  */
     78 typedef struct LLVMOpaqueModule *LLVMModuleRef;
     79 
     80 /**
     81  * Each value in the LLVM IR has a type, an LLVMTypeRef.
     82  *
     83  * @see llvm::Type
     84  */
     85 typedef struct LLVMOpaqueType *LLVMTypeRef;
     86 
     87 /**
     88  * Represents an individual value in LLVM IR.
     89  *
     90  * This models llvm::Value.
     91  */
     92 typedef struct LLVMOpaqueValue *LLVMValueRef;
     93 
     94 /**
     95  * Represents a basic block of instructions in LLVM IR.
     96  *
     97  * This models llvm::BasicBlock.
     98  */
     99 typedef struct LLVMOpaqueBasicBlock *LLVMBasicBlockRef;
    100 
    101 /**
    102  * Represents an LLVM basic block builder.
    103  *
    104  * This models llvm::IRBuilder.
    105  */
    106 typedef struct LLVMOpaqueBuilder *LLVMBuilderRef;
    107 
    108 /**
    109  * Interface used to provide a module to JIT or interpreter.
    110  * This is now just a synonym for llvm::Module, but we have to keep using the
    111  * different type to keep binary compatibility.
    112  */
    113 typedef struct LLVMOpaqueModuleProvider *LLVMModuleProviderRef;
    114 
    115 /** @see llvm::PassManagerBase */
    116 typedef struct LLVMOpaquePassManager *LLVMPassManagerRef;
    117 
    118 /** @see llvm::PassRegistry */
    119 typedef struct LLVMOpaquePassRegistry *LLVMPassRegistryRef;
    120 
    121 /**
    122  * Used to get the users and usees of a Value.
    123  *
    124  * @see llvm::Use */
    125 typedef struct LLVMOpaqueUse *LLVMUseRef;
    126 
    127 
    128 /**
    129  * @see llvm::DiagnosticInfo
    130  */
    131 typedef struct LLVMOpaqueDiagnosticInfo *LLVMDiagnosticInfoRef;
    132 
    133 typedef enum {
    134     LLVMZExtAttribute       = 1<<0,
    135     LLVMSExtAttribute       = 1<<1,
    136     LLVMNoReturnAttribute   = 1<<2,
    137     LLVMInRegAttribute      = 1<<3,
    138     LLVMStructRetAttribute  = 1<<4,
    139     LLVMNoUnwindAttribute   = 1<<5,
    140     LLVMNoAliasAttribute    = 1<<6,
    141     LLVMByValAttribute      = 1<<7,
    142     LLVMNestAttribute       = 1<<8,
    143     LLVMReadNoneAttribute   = 1<<9,
    144     LLVMReadOnlyAttribute   = 1<<10,
    145     LLVMNoInlineAttribute   = 1<<11,
    146     LLVMAlwaysInlineAttribute    = 1<<12,
    147     LLVMOptimizeForSizeAttribute = 1<<13,
    148     LLVMStackProtectAttribute    = 1<<14,
    149     LLVMStackProtectReqAttribute = 1<<15,
    150     LLVMAlignment = 31<<16,
    151     LLVMNoCaptureAttribute  = 1<<21,
    152     LLVMNoRedZoneAttribute  = 1<<22,
    153     LLVMNoImplicitFloatAttribute = 1<<23,
    154     LLVMNakedAttribute      = 1<<24,
    155     LLVMInlineHintAttribute = 1<<25,
    156     LLVMStackAlignment = 7<<26,
    157     LLVMReturnsTwice = 1 << 29,
    158     LLVMUWTable = 1 << 30,
    159     LLVMNonLazyBind = 1 << 31
    160 
    161     /* FIXME: These attributes are currently not included in the C API as
    162        a temporary measure until the API/ABI impact to the C API is understood
    163        and the path forward agreed upon.
    164     LLVMAddressSafety = 1ULL << 32,
    165     LLVMStackProtectStrongAttribute = 1ULL<<33,
    166     LLVMCold = 1ULL << 34,
    167     LLVMOptimizeNone = 1ULL << 35,
    168     LLVMInAllocaAttribute = 1ULL << 36,
    169     LLVMNonNullAttribute = 1ULL << 37,
    170     LLVMJumpTableAttribute = 1ULL << 38,
    171     LLVMDereferenceableAttribute = 1ULL << 39,
    172     LLVMDereferenceableOrNullAttribute = 1ULL << 40,
    173     */
    174 } LLVMAttribute;
    175 
    176 typedef enum {
    177   /* Terminator Instructions */
    178   LLVMRet            = 1,
    179   LLVMBr             = 2,
    180   LLVMSwitch         = 3,
    181   LLVMIndirectBr     = 4,
    182   LLVMInvoke         = 5,
    183   /* removed 6 due to API changes */
    184   LLVMUnreachable    = 7,
    185 
    186   /* Standard Binary Operators */
    187   LLVMAdd            = 8,
    188   LLVMFAdd           = 9,
    189   LLVMSub            = 10,
    190   LLVMFSub           = 11,
    191   LLVMMul            = 12,
    192   LLVMFMul           = 13,
    193   LLVMUDiv           = 14,
    194   LLVMSDiv           = 15,
    195   LLVMFDiv           = 16,
    196   LLVMURem           = 17,
    197   LLVMSRem           = 18,
    198   LLVMFRem           = 19,
    199 
    200   /* Logical Operators */
    201   LLVMShl            = 20,
    202   LLVMLShr           = 21,
    203   LLVMAShr           = 22,
    204   LLVMAnd            = 23,
    205   LLVMOr             = 24,
    206   LLVMXor            = 25,
    207 
    208   /* Memory Operators */
    209   LLVMAlloca         = 26,
    210   LLVMLoad           = 27,
    211   LLVMStore          = 28,
    212   LLVMGetElementPtr  = 29,
    213 
    214   /* Cast Operators */
    215   LLVMTrunc          = 30,
    216   LLVMZExt           = 31,
    217   LLVMSExt           = 32,
    218   LLVMFPToUI         = 33,
    219   LLVMFPToSI         = 34,
    220   LLVMUIToFP         = 35,
    221   LLVMSIToFP         = 36,
    222   LLVMFPTrunc        = 37,
    223   LLVMFPExt          = 38,
    224   LLVMPtrToInt       = 39,
    225   LLVMIntToPtr       = 40,
    226   LLVMBitCast        = 41,
    227   LLVMAddrSpaceCast  = 60,
    228 
    229   /* Other Operators */
    230   LLVMICmp           = 42,
    231   LLVMFCmp           = 43,
    232   LLVMPHI            = 44,
    233   LLVMCall           = 45,
    234   LLVMSelect         = 46,
    235   LLVMUserOp1        = 47,
    236   LLVMUserOp2        = 48,
    237   LLVMVAArg          = 49,
    238   LLVMExtractElement = 50,
    239   LLVMInsertElement  = 51,
    240   LLVMShuffleVector  = 52,
    241   LLVMExtractValue   = 53,
    242   LLVMInsertValue    = 54,
    243 
    244   /* Atomic operators */
    245   LLVMFence          = 55,
    246   LLVMAtomicCmpXchg  = 56,
    247   LLVMAtomicRMW      = 57,
    248 
    249   /* Exception Handling Operators */
    250   LLVMResume         = 58,
    251   LLVMLandingPad     = 59
    252 
    253 } LLVMOpcode;
    254 
    255 typedef enum {
    256   LLVMVoidTypeKind,        /**< type with no size */
    257   LLVMHalfTypeKind,        /**< 16 bit floating point type */
    258   LLVMFloatTypeKind,       /**< 32 bit floating point type */
    259   LLVMDoubleTypeKind,      /**< 64 bit floating point type */
    260   LLVMX86_FP80TypeKind,    /**< 80 bit floating point type (X87) */
    261   LLVMFP128TypeKind,       /**< 128 bit floating point type (112-bit mantissa)*/
    262   LLVMPPC_FP128TypeKind,   /**< 128 bit floating point type (two 64-bits) */
    263   LLVMLabelTypeKind,       /**< Labels */
    264   LLVMIntegerTypeKind,     /**< Arbitrary bit width integers */
    265   LLVMFunctionTypeKind,    /**< Functions */
    266   LLVMStructTypeKind,      /**< Structures */
    267   LLVMArrayTypeKind,       /**< Arrays */
    268   LLVMPointerTypeKind,     /**< Pointers */
    269   LLVMVectorTypeKind,      /**< SIMD 'packed' format, or other vector type */
    270   LLVMMetadataTypeKind,    /**< Metadata */
    271   LLVMX86_MMXTypeKind      /**< X86 MMX */
    272 } LLVMTypeKind;
    273 
    274 typedef enum {
    275   LLVMExternalLinkage,    /**< Externally visible function */
    276   LLVMAvailableExternallyLinkage,
    277   LLVMLinkOnceAnyLinkage, /**< Keep one copy of function when linking (inline)*/
    278   LLVMLinkOnceODRLinkage, /**< Same, but only replaced by something
    279                             equivalent. */
    280   LLVMLinkOnceODRAutoHideLinkage, /**< Obsolete */
    281   LLVMWeakAnyLinkage,     /**< Keep one copy of function when linking (weak) */
    282   LLVMWeakODRLinkage,     /**< Same, but only replaced by something
    283                             equivalent. */
    284   LLVMAppendingLinkage,   /**< Special purpose, only applies to global arrays */
    285   LLVMInternalLinkage,    /**< Rename collisions when linking (static
    286                                functions) */
    287   LLVMPrivateLinkage,     /**< Like Internal, but omit from symbol table */
    288   LLVMDLLImportLinkage,   /**< Obsolete */
    289   LLVMDLLExportLinkage,   /**< Obsolete */
    290   LLVMExternalWeakLinkage,/**< ExternalWeak linkage description */
    291   LLVMGhostLinkage,       /**< Obsolete */
    292   LLVMCommonLinkage,      /**< Tentative definitions */
    293   LLVMLinkerPrivateLinkage, /**< Like Private, but linker removes. */
    294   LLVMLinkerPrivateWeakLinkage /**< Like LinkerPrivate, but is weak. */
    295 } LLVMLinkage;
    296 
    297 typedef enum {
    298   LLVMDefaultVisibility,  /**< The GV is visible */
    299   LLVMHiddenVisibility,   /**< The GV is hidden */
    300   LLVMProtectedVisibility /**< The GV is protected */
    301 } LLVMVisibility;
    302 
    303 typedef enum {
    304   LLVMDefaultStorageClass   = 0,
    305   LLVMDLLImportStorageClass = 1, /**< Function to be imported from DLL. */
    306   LLVMDLLExportStorageClass = 2  /**< Function to be accessible from DLL. */
    307 } LLVMDLLStorageClass;
    308 
    309 typedef enum {
    310   LLVMCCallConv           = 0,
    311   LLVMFastCallConv        = 8,
    312   LLVMColdCallConv        = 9,
    313   LLVMWebKitJSCallConv    = 12,
    314   LLVMAnyRegCallConv      = 13,
    315   LLVMX86StdcallCallConv  = 64,
    316   LLVMX86FastcallCallConv = 65
    317 } LLVMCallConv;
    318 
    319 typedef enum {
    320   LLVMIntEQ = 32, /**< equal */
    321   LLVMIntNE,      /**< not equal */
    322   LLVMIntUGT,     /**< unsigned greater than */
    323   LLVMIntUGE,     /**< unsigned greater or equal */
    324   LLVMIntULT,     /**< unsigned less than */
    325   LLVMIntULE,     /**< unsigned less or equal */
    326   LLVMIntSGT,     /**< signed greater than */
    327   LLVMIntSGE,     /**< signed greater or equal */
    328   LLVMIntSLT,     /**< signed less than */
    329   LLVMIntSLE      /**< signed less or equal */
    330 } LLVMIntPredicate;
    331 
    332 typedef enum {
    333   LLVMRealPredicateFalse, /**< Always false (always folded) */
    334   LLVMRealOEQ,            /**< True if ordered and equal */
    335   LLVMRealOGT,            /**< True if ordered and greater than */
    336   LLVMRealOGE,            /**< True if ordered and greater than or equal */
    337   LLVMRealOLT,            /**< True if ordered and less than */
    338   LLVMRealOLE,            /**< True if ordered and less than or equal */
    339   LLVMRealONE,            /**< True if ordered and operands are unequal */
    340   LLVMRealORD,            /**< True if ordered (no nans) */
    341   LLVMRealUNO,            /**< True if unordered: isnan(X) | isnan(Y) */
    342   LLVMRealUEQ,            /**< True if unordered or equal */
    343   LLVMRealUGT,            /**< True if unordered or greater than */
    344   LLVMRealUGE,            /**< True if unordered, greater than, or equal */
    345   LLVMRealULT,            /**< True if unordered or less than */
    346   LLVMRealULE,            /**< True if unordered, less than, or equal */
    347   LLVMRealUNE,            /**< True if unordered or not equal */
    348   LLVMRealPredicateTrue   /**< Always true (always folded) */
    349 } LLVMRealPredicate;
    350 
    351 typedef enum {
    352   LLVMLandingPadCatch,    /**< A catch clause   */
    353   LLVMLandingPadFilter    /**< A filter clause  */
    354 } LLVMLandingPadClauseTy;
    355 
    356 typedef enum {
    357   LLVMNotThreadLocal = 0,
    358   LLVMGeneralDynamicTLSModel,
    359   LLVMLocalDynamicTLSModel,
    360   LLVMInitialExecTLSModel,
    361   LLVMLocalExecTLSModel
    362 } LLVMThreadLocalMode;
    363 
    364 typedef enum {
    365   LLVMAtomicOrderingNotAtomic = 0, /**< A load or store which is not atomic */
    366   LLVMAtomicOrderingUnordered = 1, /**< Lowest level of atomicity, guarantees
    367                                      somewhat sane results, lock free. */
    368   LLVMAtomicOrderingMonotonic = 2, /**< guarantees that if you take all the
    369                                      operations affecting a specific address,
    370                                      a consistent ordering exists */
    371   LLVMAtomicOrderingAcquire = 4, /**< Acquire provides a barrier of the sort
    372                                    necessary to acquire a lock to access other
    373                                    memory with normal loads and stores. */
    374   LLVMAtomicOrderingRelease = 5, /**< Release is similar to Acquire, but with
    375                                    a barrier of the sort necessary to release
    376                                    a lock. */
    377   LLVMAtomicOrderingAcquireRelease = 6, /**< provides both an Acquire and a
    378                                           Release barrier (for fences and
    379                                           operations which both read and write
    380                                            memory). */
    381   LLVMAtomicOrderingSequentiallyConsistent = 7 /**< provides Acquire semantics
    382                                                  for loads and Release
    383                                                  semantics for stores.
    384                                                  Additionally, it guarantees
    385                                                  that a total ordering exists
    386                                                  between all
    387                                                  SequentiallyConsistent
    388                                                  operations. */
    389 } LLVMAtomicOrdering;
    390 
    391 typedef enum {
    392     LLVMAtomicRMWBinOpXchg, /**< Set the new value and return the one old */
    393     LLVMAtomicRMWBinOpAdd, /**< Add a value and return the old one */
    394     LLVMAtomicRMWBinOpSub, /**< Subtract a value and return the old one */
    395     LLVMAtomicRMWBinOpAnd, /**< And a value and return the old one */
    396     LLVMAtomicRMWBinOpNand, /**< Not-And a value and return the old one */
    397     LLVMAtomicRMWBinOpOr, /**< OR a value and return the old one */
    398     LLVMAtomicRMWBinOpXor, /**< Xor a value and return the old one */
    399     LLVMAtomicRMWBinOpMax, /**< Sets the value if it's greater than the
    400                              original using a signed comparison and return
    401                              the old one */
    402     LLVMAtomicRMWBinOpMin, /**< Sets the value if it's Smaller than the
    403                              original using a signed comparison and return
    404                              the old one */
    405     LLVMAtomicRMWBinOpUMax, /**< Sets the value if it's greater than the
    406                              original using an unsigned comparison and return
    407                              the old one */
    408     LLVMAtomicRMWBinOpUMin /**< Sets the value if it's greater than the
    409                              original using an unsigned comparison  and return
    410                              the old one */
    411 } LLVMAtomicRMWBinOp;
    412 
    413 typedef enum {
    414     LLVMDSError,
    415     LLVMDSWarning,
    416     LLVMDSRemark,
    417     LLVMDSNote
    418 } LLVMDiagnosticSeverity;
    419 
    420 /**
    421  * @}
    422  */
    423 
    424 void LLVMInitializeCore(LLVMPassRegistryRef R);
    425 
    426 /** Deallocate and destroy all ManagedStatic variables.
    427     @see llvm::llvm_shutdown
    428     @see ManagedStatic */
    429 void LLVMShutdown(void);
    430 
    431 
    432 /*===-- Error handling ----------------------------------------------------===*/
    433 
    434 char *LLVMCreateMessage(const char *Message);
    435 void LLVMDisposeMessage(char *Message);
    436 
    437 typedef void (*LLVMFatalErrorHandler)(const char *Reason);
    438 
    439 /**
    440  * Install a fatal error handler. By default, if LLVM detects a fatal error, it
    441  * will call exit(1). This may not be appropriate in many contexts. For example,
    442  * doing exit(1) will bypass many crash reporting/tracing system tools. This
    443  * function allows you to install a callback that will be invoked prior to the
    444  * call to exit(1).
    445  */
    446 void LLVMInstallFatalErrorHandler(LLVMFatalErrorHandler Handler);
    447 
    448 /**
    449  * Reset the fatal error handler. This resets LLVM's fatal error handling
    450  * behavior to the default.
    451  */
    452 void LLVMResetFatalErrorHandler(void);
    453 
    454 /**
    455  * Enable LLVM's built-in stack trace code. This intercepts the OS's crash
    456  * signals and prints which component of LLVM you were in at the time if the
    457  * crash.
    458  */
    459 void LLVMEnablePrettyStackTrace(void);
    460 
    461 /**
    462  * @defgroup LLVMCCoreContext Contexts
    463  *
    464  * Contexts are execution states for the core LLVM IR system.
    465  *
    466  * Most types are tied to a context instance. Multiple contexts can
    467  * exist simultaneously. A single context is not thread safe. However,
    468  * different contexts can execute on different threads simultaneously.
    469  *
    470  * @{
    471  */
    472 
    473 typedef void (*LLVMDiagnosticHandler)(LLVMDiagnosticInfoRef, void *);
    474 typedef void (*LLVMYieldCallback)(LLVMContextRef, void *);
    475 
    476 /**
    477  * Create a new context.
    478  *
    479  * Every call to this function should be paired with a call to
    480  * LLVMContextDispose() or the context will leak memory.
    481  */
    482 LLVMContextRef LLVMContextCreate(void);
    483 
    484 /**
    485  * Obtain the global context instance.
    486  */
    487 LLVMContextRef LLVMGetGlobalContext(void);
    488 
    489 /**
    490  * Set the diagnostic handler for this context.
    491  */
    492 void LLVMContextSetDiagnosticHandler(LLVMContextRef C,
    493                                      LLVMDiagnosticHandler Handler,
    494                                      void *DiagnosticContext);
    495 
    496 /**
    497  * Set the yield callback function for this context.
    498  *
    499  * @see LLVMContext::setYieldCallback()
    500  */
    501 void LLVMContextSetYieldCallback(LLVMContextRef C, LLVMYieldCallback Callback,
    502                                  void *OpaqueHandle);
    503 
    504 /**
    505  * Destroy a context instance.
    506  *
    507  * This should be called for every call to LLVMContextCreate() or memory
    508  * will be leaked.
    509  */
    510 void LLVMContextDispose(LLVMContextRef C);
    511 
    512 /**
    513  * Return a string representation of the DiagnosticInfo. Use
    514  * LLVMDisposeMessage to free the string.
    515  *
    516  * @see DiagnosticInfo::print()
    517  */
    518 char *LLVMGetDiagInfoDescription(LLVMDiagnosticInfoRef DI);
    519 
    520 /**
    521  * Return an enum LLVMDiagnosticSeverity.
    522  *
    523  * @see DiagnosticInfo::getSeverity()
    524  */
    525 LLVMDiagnosticSeverity LLVMGetDiagInfoSeverity(LLVMDiagnosticInfoRef DI);
    526 
    527 unsigned LLVMGetMDKindIDInContext(LLVMContextRef C, const char* Name,
    528                                   unsigned SLen);
    529 unsigned LLVMGetMDKindID(const char* Name, unsigned SLen);
    530 
    531 /**
    532  * @}
    533  */
    534 
    535 /**
    536  * @defgroup LLVMCCoreModule Modules
    537  *
    538  * Modules represent the top-level structure in an LLVM program. An LLVM
    539  * module is effectively a translation unit or a collection of
    540  * translation units merged together.
    541  *
    542  * @{
    543  */
    544 
    545 /**
    546  * Create a new, empty module in the global context.
    547  *
    548  * This is equivalent to calling LLVMModuleCreateWithNameInContext with
    549  * LLVMGetGlobalContext() as the context parameter.
    550  *
    551  * Every invocation should be paired with LLVMDisposeModule() or memory
    552  * will be leaked.
    553  */
    554 LLVMModuleRef LLVMModuleCreateWithName(const char *ModuleID);
    555 
    556 /**
    557  * Create a new, empty module in a specific context.
    558  *
    559  * Every invocation should be paired with LLVMDisposeModule() or memory
    560  * will be leaked.
    561  */
    562 LLVMModuleRef LLVMModuleCreateWithNameInContext(const char *ModuleID,
    563                                                 LLVMContextRef C);
    564 /**
    565  * Return an exact copy of the specified module.
    566  */
    567 LLVMModuleRef LLVMCloneModule(LLVMModuleRef M);
    568 
    569 /**
    570  * Destroy a module instance.
    571  *
    572  * This must be called for every created module or memory will be
    573  * leaked.
    574  */
    575 void LLVMDisposeModule(LLVMModuleRef M);
    576 
    577 /**
    578  * Obtain the data layout for a module.
    579  *
    580  * @see Module::getDataLayout()
    581  */
    582 const char *LLVMGetDataLayout(LLVMModuleRef M);
    583 
    584 /**
    585  * Set the data layout for a module.
    586  *
    587  * @see Module::setDataLayout()
    588  */
    589 void LLVMSetDataLayout(LLVMModuleRef M, const char *Triple);
    590 
    591 /**
    592  * Obtain the target triple for a module.
    593  *
    594  * @see Module::getTargetTriple()
    595  */
    596 const char *LLVMGetTarget(LLVMModuleRef M);
    597 
    598 /**
    599  * Set the target triple for a module.
    600  *
    601  * @see Module::setTargetTriple()
    602  */
    603 void LLVMSetTarget(LLVMModuleRef M, const char *Triple);
    604 
    605 /**
    606  * Dump a representation of a module to stderr.
    607  *
    608  * @see Module::dump()
    609  */
    610 void LLVMDumpModule(LLVMModuleRef M);
    611 
    612 /**
    613  * Print a representation of a module to a file. The ErrorMessage needs to be
    614  * disposed with LLVMDisposeMessage. Returns 0 on success, 1 otherwise.
    615  *
    616  * @see Module::print()
    617  */
    618 LLVMBool LLVMPrintModuleToFile(LLVMModuleRef M, const char *Filename,
    619                                char **ErrorMessage);
    620 
    621 /**
    622  * Return a string representation of the module. Use
    623  * LLVMDisposeMessage to free the string.
    624  *
    625  * @see Module::print()
    626  */
    627 char *LLVMPrintModuleToString(LLVMModuleRef M);
    628 
    629 /**
    630  * Set inline assembly for a module.
    631  *
    632  * @see Module::setModuleInlineAsm()
    633  */
    634 void LLVMSetModuleInlineAsm(LLVMModuleRef M, const char *Asm);
    635 
    636 /**
    637  * Obtain the context to which this module is associated.
    638  *
    639  * @see Module::getContext()
    640  */
    641 LLVMContextRef LLVMGetModuleContext(LLVMModuleRef M);
    642 
    643 /**
    644  * Obtain a Type from a module by its registered name.
    645  */
    646 LLVMTypeRef LLVMGetTypeByName(LLVMModuleRef M, const char *Name);
    647 
    648 /**
    649  * Obtain the number of operands for named metadata in a module.
    650  *
    651  * @see llvm::Module::getNamedMetadata()
    652  */
    653 unsigned LLVMGetNamedMetadataNumOperands(LLVMModuleRef M, const char* name);
    654 
    655 /**
    656  * Obtain the named metadata operands for a module.
    657  *
    658  * The passed LLVMValueRef pointer should refer to an array of
    659  * LLVMValueRef at least LLVMGetNamedMetadataNumOperands long. This
    660  * array will be populated with the LLVMValueRef instances. Each
    661  * instance corresponds to a llvm::MDNode.
    662  *
    663  * @see llvm::Module::getNamedMetadata()
    664  * @see llvm::MDNode::getOperand()
    665  */
    666 void LLVMGetNamedMetadataOperands(LLVMModuleRef M, const char* name, LLVMValueRef *Dest);
    667 
    668 /**
    669  * Add an operand to named metadata.
    670  *
    671  * @see llvm::Module::getNamedMetadata()
    672  * @see llvm::MDNode::addOperand()
    673  */
    674 void LLVMAddNamedMetadataOperand(LLVMModuleRef M, const char* name,
    675                                  LLVMValueRef Val);
    676 
    677 /**
    678  * Add a function to a module under a specified name.
    679  *
    680  * @see llvm::Function::Create()
    681  */
    682 LLVMValueRef LLVMAddFunction(LLVMModuleRef M, const char *Name,
    683                              LLVMTypeRef FunctionTy);
    684 
    685 /**
    686  * Obtain a Function value from a Module by its name.
    687  *
    688  * The returned value corresponds to a llvm::Function value.
    689  *
    690  * @see llvm::Module::getFunction()
    691  */
    692 LLVMValueRef LLVMGetNamedFunction(LLVMModuleRef M, const char *Name);
    693 
    694 /**
    695  * Obtain an iterator to the first Function in a Module.
    696  *
    697  * @see llvm::Module::begin()
    698  */
    699 LLVMValueRef LLVMGetFirstFunction(LLVMModuleRef M);
    700 
    701 /**
    702  * Obtain an iterator to the last Function in a Module.
    703  *
    704  * @see llvm::Module::end()
    705  */
    706 LLVMValueRef LLVMGetLastFunction(LLVMModuleRef M);
    707 
    708 /**
    709  * Advance a Function iterator to the next Function.
    710  *
    711  * Returns NULL if the iterator was already at the end and there are no more
    712  * functions.
    713  */
    714 LLVMValueRef LLVMGetNextFunction(LLVMValueRef Fn);
    715 
    716 /**
    717  * Decrement a Function iterator to the previous Function.
    718  *
    719  * Returns NULL if the iterator was already at the beginning and there are
    720  * no previous functions.
    721  */
    722 LLVMValueRef LLVMGetPreviousFunction(LLVMValueRef Fn);
    723 
    724 /**
    725  * @}
    726  */
    727 
    728 /**
    729  * @defgroup LLVMCCoreType Types
    730  *
    731  * Types represent the type of a value.
    732  *
    733  * Types are associated with a context instance. The context internally
    734  * deduplicates types so there is only 1 instance of a specific type
    735  * alive at a time. In other words, a unique type is shared among all
    736  * consumers within a context.
    737  *
    738  * A Type in the C API corresponds to llvm::Type.
    739  *
    740  * Types have the following hierarchy:
    741  *
    742  *   types:
    743  *     integer type
    744  *     real type
    745  *     function type
    746  *     sequence types:
    747  *       array type
    748  *       pointer type
    749  *       vector type
    750  *     void type
    751  *     label type
    752  *     opaque type
    753  *
    754  * @{
    755  */
    756 
    757 /**
    758  * Obtain the enumerated type of a Type instance.
    759  *
    760  * @see llvm::Type:getTypeID()
    761  */
    762 LLVMTypeKind LLVMGetTypeKind(LLVMTypeRef Ty);
    763 
    764 /**
    765  * Whether the type has a known size.
    766  *
    767  * Things that don't have a size are abstract types, labels, and void.a
    768  *
    769  * @see llvm::Type::isSized()
    770  */
    771 LLVMBool LLVMTypeIsSized(LLVMTypeRef Ty);
    772 
    773 /**
    774  * Obtain the context to which this type instance is associated.
    775  *
    776  * @see llvm::Type::getContext()
    777  */
    778 LLVMContextRef LLVMGetTypeContext(LLVMTypeRef Ty);
    779 
    780 /**
    781  * Dump a representation of a type to stderr.
    782  *
    783  * @see llvm::Type::dump()
    784  */
    785 void LLVMDumpType(LLVMTypeRef Val);
    786 
    787 /**
    788  * Return a string representation of the type. Use
    789  * LLVMDisposeMessage to free the string.
    790  *
    791  * @see llvm::Type::print()
    792  */
    793 char *LLVMPrintTypeToString(LLVMTypeRef Val);
    794 
    795 /**
    796  * @defgroup LLVMCCoreTypeInt Integer Types
    797  *
    798  * Functions in this section operate on integer types.
    799  *
    800  * @{
    801  */
    802 
    803 /**
    804  * Obtain an integer type from a context with specified bit width.
    805  */
    806 LLVMTypeRef LLVMInt1TypeInContext(LLVMContextRef C);
    807 LLVMTypeRef LLVMInt8TypeInContext(LLVMContextRef C);
    808 LLVMTypeRef LLVMInt16TypeInContext(LLVMContextRef C);
    809 LLVMTypeRef LLVMInt32TypeInContext(LLVMContextRef C);
    810 LLVMTypeRef LLVMInt64TypeInContext(LLVMContextRef C);
    811 LLVMTypeRef LLVMIntTypeInContext(LLVMContextRef C, unsigned NumBits);
    812 
    813 /**
    814  * Obtain an integer type from the global context with a specified bit
    815  * width.
    816  */
    817 LLVMTypeRef LLVMInt1Type(void);
    818 LLVMTypeRef LLVMInt8Type(void);
    819 LLVMTypeRef LLVMInt16Type(void);
    820 LLVMTypeRef LLVMInt32Type(void);
    821 LLVMTypeRef LLVMInt64Type(void);
    822 LLVMTypeRef LLVMIntType(unsigned NumBits);
    823 unsigned LLVMGetIntTypeWidth(LLVMTypeRef IntegerTy);
    824 
    825 /**
    826  * @}
    827  */
    828 
    829 /**
    830  * @defgroup LLVMCCoreTypeFloat Floating Point Types
    831  *
    832  * @{
    833  */
    834 
    835 /**
    836  * Obtain a 16-bit floating point type from a context.
    837  */
    838 LLVMTypeRef LLVMHalfTypeInContext(LLVMContextRef C);
    839 
    840 /**
    841  * Obtain a 32-bit floating point type from a context.
    842  */
    843 LLVMTypeRef LLVMFloatTypeInContext(LLVMContextRef C);
    844 
    845 /**
    846  * Obtain a 64-bit floating point type from a context.
    847  */
    848 LLVMTypeRef LLVMDoubleTypeInContext(LLVMContextRef C);
    849 
    850 /**
    851  * Obtain a 80-bit floating point type (X87) from a context.
    852  */
    853 LLVMTypeRef LLVMX86FP80TypeInContext(LLVMContextRef C);
    854 
    855 /**
    856  * Obtain a 128-bit floating point type (112-bit mantissa) from a
    857  * context.
    858  */
    859 LLVMTypeRef LLVMFP128TypeInContext(LLVMContextRef C);
    860 
    861 /**
    862  * Obtain a 128-bit floating point type (two 64-bits) from a context.
    863  */
    864 LLVMTypeRef LLVMPPCFP128TypeInContext(LLVMContextRef C);
    865 
    866 /**
    867  * Obtain a floating point type from the global context.
    868  *
    869  * These map to the functions in this group of the same name.
    870  */
    871 LLVMTypeRef LLVMHalfType(void);
    872 LLVMTypeRef LLVMFloatType(void);
    873 LLVMTypeRef LLVMDoubleType(void);
    874 LLVMTypeRef LLVMX86FP80Type(void);
    875 LLVMTypeRef LLVMFP128Type(void);
    876 LLVMTypeRef LLVMPPCFP128Type(void);
    877 
    878 /**
    879  * @}
    880  */
    881 
    882 /**
    883  * @defgroup LLVMCCoreTypeFunction Function Types
    884  *
    885  * @{
    886  */
    887 
    888 /**
    889  * Obtain a function type consisting of a specified signature.
    890  *
    891  * The function is defined as a tuple of a return Type, a list of
    892  * parameter types, and whether the function is variadic.
    893  */
    894 LLVMTypeRef LLVMFunctionType(LLVMTypeRef ReturnType,
    895                              LLVMTypeRef *ParamTypes, unsigned ParamCount,
    896                              LLVMBool IsVarArg);
    897 
    898 /**
    899  * Returns whether a function type is variadic.
    900  */
    901 LLVMBool LLVMIsFunctionVarArg(LLVMTypeRef FunctionTy);
    902 
    903 /**
    904  * Obtain the Type this function Type returns.
    905  */
    906 LLVMTypeRef LLVMGetReturnType(LLVMTypeRef FunctionTy);
    907 
    908 /**
    909  * Obtain the number of parameters this function accepts.
    910  */
    911 unsigned LLVMCountParamTypes(LLVMTypeRef FunctionTy);
    912 
    913 /**
    914  * Obtain the types of a function's parameters.
    915  *
    916  * The Dest parameter should point to a pre-allocated array of
    917  * LLVMTypeRef at least LLVMCountParamTypes() large. On return, the
    918  * first LLVMCountParamTypes() entries in the array will be populated
    919  * with LLVMTypeRef instances.
    920  *
    921  * @param FunctionTy The function type to operate on.
    922  * @param Dest Memory address of an array to be filled with result.
    923  */
    924 void LLVMGetParamTypes(LLVMTypeRef FunctionTy, LLVMTypeRef *Dest);
    925 
    926 /**
    927  * @}
    928  */
    929 
    930 /**
    931  * @defgroup LLVMCCoreTypeStruct Structure Types
    932  *
    933  * These functions relate to LLVMTypeRef instances.
    934  *
    935  * @see llvm::StructType
    936  *
    937  * @{
    938  */
    939 
    940 /**
    941  * Create a new structure type in a context.
    942  *
    943  * A structure is specified by a list of inner elements/types and
    944  * whether these can be packed together.
    945  *
    946  * @see llvm::StructType::create()
    947  */
    948 LLVMTypeRef LLVMStructTypeInContext(LLVMContextRef C, LLVMTypeRef *ElementTypes,
    949                                     unsigned ElementCount, LLVMBool Packed);
    950 
    951 /**
    952  * Create a new structure type in the global context.
    953  *
    954  * @see llvm::StructType::create()
    955  */
    956 LLVMTypeRef LLVMStructType(LLVMTypeRef *ElementTypes, unsigned ElementCount,
    957                            LLVMBool Packed);
    958 
    959 /**
    960  * Create an empty structure in a context having a specified name.
    961  *
    962  * @see llvm::StructType::create()
    963  */
    964 LLVMTypeRef LLVMStructCreateNamed(LLVMContextRef C, const char *Name);
    965 
    966 /**
    967  * Obtain the name of a structure.
    968  *
    969  * @see llvm::StructType::getName()
    970  */
    971 const char *LLVMGetStructName(LLVMTypeRef Ty);
    972 
    973 /**
    974  * Set the contents of a structure type.
    975  *
    976  * @see llvm::StructType::setBody()
    977  */
    978 void LLVMStructSetBody(LLVMTypeRef StructTy, LLVMTypeRef *ElementTypes,
    979                        unsigned ElementCount, LLVMBool Packed);
    980 
    981 /**
    982  * Get the number of elements defined inside the structure.
    983  *
    984  * @see llvm::StructType::getNumElements()
    985  */
    986 unsigned LLVMCountStructElementTypes(LLVMTypeRef StructTy);
    987 
    988 /**
    989  * Get the elements within a structure.
    990  *
    991  * The function is passed the address of a pre-allocated array of
    992  * LLVMTypeRef at least LLVMCountStructElementTypes() long. After
    993  * invocation, this array will be populated with the structure's
    994  * elements. The objects in the destination array will have a lifetime
    995  * of the structure type itself, which is the lifetime of the context it
    996  * is contained in.
    997  */
    998 void LLVMGetStructElementTypes(LLVMTypeRef StructTy, LLVMTypeRef *Dest);
    999 
   1000 /**
   1001  * Determine whether a structure is packed.
   1002  *
   1003  * @see llvm::StructType::isPacked()
   1004  */
   1005 LLVMBool LLVMIsPackedStruct(LLVMTypeRef StructTy);
   1006 
   1007 /**
   1008  * Determine whether a structure is opaque.
   1009  *
   1010  * @see llvm::StructType::isOpaque()
   1011  */
   1012 LLVMBool LLVMIsOpaqueStruct(LLVMTypeRef StructTy);
   1013 
   1014 /**
   1015  * @}
   1016  */
   1017 
   1018 
   1019 /**
   1020  * @defgroup LLVMCCoreTypeSequential Sequential Types
   1021  *
   1022  * Sequential types represents "arrays" of types. This is a super class
   1023  * for array, vector, and pointer types.
   1024  *
   1025  * @{
   1026  */
   1027 
   1028 /**
   1029  * Obtain the type of elements within a sequential type.
   1030  *
   1031  * This works on array, vector, and pointer types.
   1032  *
   1033  * @see llvm::SequentialType::getElementType()
   1034  */
   1035 LLVMTypeRef LLVMGetElementType(LLVMTypeRef Ty);
   1036 
   1037 /**
   1038  * Create a fixed size array type that refers to a specific type.
   1039  *
   1040  * The created type will exist in the context that its element type
   1041  * exists in.
   1042  *
   1043  * @see llvm::ArrayType::get()
   1044  */
   1045 LLVMTypeRef LLVMArrayType(LLVMTypeRef ElementType, unsigned ElementCount);
   1046 
   1047 /**
   1048  * Obtain the length of an array type.
   1049  *
   1050  * This only works on types that represent arrays.
   1051  *
   1052  * @see llvm::ArrayType::getNumElements()
   1053  */
   1054 unsigned LLVMGetArrayLength(LLVMTypeRef ArrayTy);
   1055 
   1056 /**
   1057  * Create a pointer type that points to a defined type.
   1058  *
   1059  * The created type will exist in the context that its pointee type
   1060  * exists in.
   1061  *
   1062  * @see llvm::PointerType::get()
   1063  */
   1064 LLVMTypeRef LLVMPointerType(LLVMTypeRef ElementType, unsigned AddressSpace);
   1065 
   1066 /**
   1067  * Obtain the address space of a pointer type.
   1068  *
   1069  * This only works on types that represent pointers.
   1070  *
   1071  * @see llvm::PointerType::getAddressSpace()
   1072  */
   1073 unsigned LLVMGetPointerAddressSpace(LLVMTypeRef PointerTy);
   1074 
   1075 /**
   1076  * Create a vector type that contains a defined type and has a specific
   1077  * number of elements.
   1078  *
   1079  * The created type will exist in the context thats its element type
   1080  * exists in.
   1081  *
   1082  * @see llvm::VectorType::get()
   1083  */
   1084 LLVMTypeRef LLVMVectorType(LLVMTypeRef ElementType, unsigned ElementCount);
   1085 
   1086 /**
   1087  * Obtain the number of elements in a vector type.
   1088  *
   1089  * This only works on types that represent vectors.
   1090  *
   1091  * @see llvm::VectorType::getNumElements()
   1092  */
   1093 unsigned LLVMGetVectorSize(LLVMTypeRef VectorTy);
   1094 
   1095 /**
   1096  * @}
   1097  */
   1098 
   1099 /**
   1100  * @defgroup LLVMCCoreTypeOther Other Types
   1101  *
   1102  * @{
   1103  */
   1104 
   1105 /**
   1106  * Create a void type in a context.
   1107  */
   1108 LLVMTypeRef LLVMVoidTypeInContext(LLVMContextRef C);
   1109 
   1110 /**
   1111  * Create a label type in a context.
   1112  */
   1113 LLVMTypeRef LLVMLabelTypeInContext(LLVMContextRef C);
   1114 
   1115 /**
   1116  * Create a X86 MMX type in a context.
   1117  */
   1118 LLVMTypeRef LLVMX86MMXTypeInContext(LLVMContextRef C);
   1119 
   1120 /**
   1121  * These are similar to the above functions except they operate on the
   1122  * global context.
   1123  */
   1124 LLVMTypeRef LLVMVoidType(void);
   1125 LLVMTypeRef LLVMLabelType(void);
   1126 LLVMTypeRef LLVMX86MMXType(void);
   1127 
   1128 /**
   1129  * @}
   1130  */
   1131 
   1132 /**
   1133  * @}
   1134  */
   1135 
   1136 /**
   1137  * @defgroup LLVMCCoreValues Values
   1138  *
   1139  * The bulk of LLVM's object model consists of values, which comprise a very
   1140  * rich type hierarchy.
   1141  *
   1142  * LLVMValueRef essentially represents llvm::Value. There is a rich
   1143  * hierarchy of classes within this type. Depending on the instance
   1144  * obtained, not all APIs are available.
   1145  *
   1146  * Callers can determine the type of an LLVMValueRef by calling the
   1147  * LLVMIsA* family of functions (e.g. LLVMIsAArgument()). These
   1148  * functions are defined by a macro, so it isn't obvious which are
   1149  * available by looking at the Doxygen source code. Instead, look at the
   1150  * source definition of LLVM_FOR_EACH_VALUE_SUBCLASS and note the list
   1151  * of value names given. These value names also correspond to classes in
   1152  * the llvm::Value hierarchy.
   1153  *
   1154  * @{
   1155  */
   1156 
   1157 #define LLVM_FOR_EACH_VALUE_SUBCLASS(macro) \
   1158   macro(Argument)                           \
   1159   macro(BasicBlock)                         \
   1160   macro(InlineAsm)                          \
   1161   macro(User)                               \
   1162     macro(Constant)                         \
   1163       macro(BlockAddress)                   \
   1164       macro(ConstantAggregateZero)          \
   1165       macro(ConstantArray)                  \
   1166       macro(ConstantDataSequential)         \
   1167         macro(ConstantDataArray)            \
   1168         macro(ConstantDataVector)           \
   1169       macro(ConstantExpr)                   \
   1170       macro(ConstantFP)                     \
   1171       macro(ConstantInt)                    \
   1172       macro(ConstantPointerNull)            \
   1173       macro(ConstantStruct)                 \
   1174       macro(ConstantVector)                 \
   1175       macro(GlobalValue)                    \
   1176         macro(GlobalAlias)                  \
   1177         macro(GlobalObject)                 \
   1178           macro(Function)                   \
   1179           macro(GlobalVariable)             \
   1180       macro(UndefValue)                     \
   1181     macro(Instruction)                      \
   1182       macro(BinaryOperator)                 \
   1183       macro(CallInst)                       \
   1184         macro(IntrinsicInst)                \
   1185           macro(DbgInfoIntrinsic)           \
   1186             macro(DbgDeclareInst)           \
   1187           macro(MemIntrinsic)               \
   1188             macro(MemCpyInst)               \
   1189             macro(MemMoveInst)              \
   1190             macro(MemSetInst)               \
   1191       macro(CmpInst)                        \
   1192         macro(FCmpInst)                     \
   1193         macro(ICmpInst)                     \
   1194       macro(ExtractElementInst)             \
   1195       macro(GetElementPtrInst)              \
   1196       macro(InsertElementInst)              \
   1197       macro(InsertValueInst)                \
   1198       macro(LandingPadInst)                 \
   1199       macro(PHINode)                        \
   1200       macro(SelectInst)                     \
   1201       macro(ShuffleVectorInst)              \
   1202       macro(StoreInst)                      \
   1203       macro(TerminatorInst)                 \
   1204         macro(BranchInst)                   \
   1205         macro(IndirectBrInst)               \
   1206         macro(InvokeInst)                   \
   1207         macro(ReturnInst)                   \
   1208         macro(SwitchInst)                   \
   1209         macro(UnreachableInst)              \
   1210         macro(ResumeInst)                   \
   1211       macro(UnaryInstruction)               \
   1212         macro(AllocaInst)                   \
   1213         macro(CastInst)                     \
   1214           macro(AddrSpaceCastInst)          \
   1215           macro(BitCastInst)                \
   1216           macro(FPExtInst)                  \
   1217           macro(FPToSIInst)                 \
   1218           macro(FPToUIInst)                 \
   1219           macro(FPTruncInst)                \
   1220           macro(IntToPtrInst)               \
   1221           macro(PtrToIntInst)               \
   1222           macro(SExtInst)                   \
   1223           macro(SIToFPInst)                 \
   1224           macro(TruncInst)                  \
   1225           macro(UIToFPInst)                 \
   1226           macro(ZExtInst)                   \
   1227         macro(ExtractValueInst)             \
   1228         macro(LoadInst)                     \
   1229         macro(VAArgInst)
   1230 
   1231 /**
   1232  * @defgroup LLVMCCoreValueGeneral General APIs
   1233  *
   1234  * Functions in this section work on all LLVMValueRef instances,
   1235  * regardless of their sub-type. They correspond to functions available
   1236  * on llvm::Value.
   1237  *
   1238  * @{
   1239  */
   1240 
   1241 /**
   1242  * Obtain the type of a value.
   1243  *
   1244  * @see llvm::Value::getType()
   1245  */
   1246 LLVMTypeRef LLVMTypeOf(LLVMValueRef Val);
   1247 
   1248 /**
   1249  * Obtain the string name of a value.
   1250  *
   1251  * @see llvm::Value::getName()
   1252  */
   1253 const char *LLVMGetValueName(LLVMValueRef Val);
   1254 
   1255 /**
   1256  * Set the string name of a value.
   1257  *
   1258  * @see llvm::Value::setName()
   1259  */
   1260 void LLVMSetValueName(LLVMValueRef Val, const char *Name);
   1261 
   1262 /**
   1263  * Dump a representation of a value to stderr.
   1264  *
   1265  * @see llvm::Value::dump()
   1266  */
   1267 void LLVMDumpValue(LLVMValueRef Val);
   1268 
   1269 /**
   1270  * Return a string representation of the value. Use
   1271  * LLVMDisposeMessage to free the string.
   1272  *
   1273  * @see llvm::Value::print()
   1274  */
   1275 char *LLVMPrintValueToString(LLVMValueRef Val);
   1276 
   1277 /**
   1278  * Replace all uses of a value with another one.
   1279  *
   1280  * @see llvm::Value::replaceAllUsesWith()
   1281  */
   1282 void LLVMReplaceAllUsesWith(LLVMValueRef OldVal, LLVMValueRef NewVal);
   1283 
   1284 /**
   1285  * Determine whether the specified constant instance is constant.
   1286  */
   1287 LLVMBool LLVMIsConstant(LLVMValueRef Val);
   1288 
   1289 /**
   1290  * Determine whether a value instance is undefined.
   1291  */
   1292 LLVMBool LLVMIsUndef(LLVMValueRef Val);
   1293 
   1294 /**
   1295  * Convert value instances between types.
   1296  *
   1297  * Internally, an LLVMValueRef is "pinned" to a specific type. This
   1298  * series of functions allows you to cast an instance to a specific
   1299  * type.
   1300  *
   1301  * If the cast is not valid for the specified type, NULL is returned.
   1302  *
   1303  * @see llvm::dyn_cast_or_null<>
   1304  */
   1305 #define LLVM_DECLARE_VALUE_CAST(name) \
   1306   LLVMValueRef LLVMIsA##name(LLVMValueRef Val);
   1307 LLVM_FOR_EACH_VALUE_SUBCLASS(LLVM_DECLARE_VALUE_CAST)
   1308 
   1309 LLVMValueRef LLVMIsAMDNode(LLVMValueRef Val);
   1310 LLVMValueRef LLVMIsAMDString(LLVMValueRef Val);
   1311 
   1312 /**
   1313  * @}
   1314  */
   1315 
   1316 /**
   1317  * @defgroup LLVMCCoreValueUses Usage
   1318  *
   1319  * This module defines functions that allow you to inspect the uses of a
   1320  * LLVMValueRef.
   1321  *
   1322  * It is possible to obtain an LLVMUseRef for any LLVMValueRef instance.
   1323  * Each LLVMUseRef (which corresponds to a llvm::Use instance) holds a
   1324  * llvm::User and llvm::Value.
   1325  *
   1326  * @{
   1327  */
   1328 
   1329 /**
   1330  * Obtain the first use of a value.
   1331  *
   1332  * Uses are obtained in an iterator fashion. First, call this function
   1333  * to obtain a reference to the first use. Then, call LLVMGetNextUse()
   1334  * on that instance and all subsequently obtained instances until
   1335  * LLVMGetNextUse() returns NULL.
   1336  *
   1337  * @see llvm::Value::use_begin()
   1338  */
   1339 LLVMUseRef LLVMGetFirstUse(LLVMValueRef Val);
   1340 
   1341 /**
   1342  * Obtain the next use of a value.
   1343  *
   1344  * This effectively advances the iterator. It returns NULL if you are on
   1345  * the final use and no more are available.
   1346  */
   1347 LLVMUseRef LLVMGetNextUse(LLVMUseRef U);
   1348 
   1349 /**
   1350  * Obtain the user value for a user.
   1351  *
   1352  * The returned value corresponds to a llvm::User type.
   1353  *
   1354  * @see llvm::Use::getUser()
   1355  */
   1356 LLVMValueRef LLVMGetUser(LLVMUseRef U);
   1357 
   1358 /**
   1359  * Obtain the value this use corresponds to.
   1360  *
   1361  * @see llvm::Use::get().
   1362  */
   1363 LLVMValueRef LLVMGetUsedValue(LLVMUseRef U);
   1364 
   1365 /**
   1366  * @}
   1367  */
   1368 
   1369 /**
   1370  * @defgroup LLVMCCoreValueUser User value
   1371  *
   1372  * Function in this group pertain to LLVMValueRef instances that descent
   1373  * from llvm::User. This includes constants, instructions, and
   1374  * operators.
   1375  *
   1376  * @{
   1377  */
   1378 
   1379 /**
   1380  * Obtain an operand at a specific index in a llvm::User value.
   1381  *
   1382  * @see llvm::User::getOperand()
   1383  */
   1384 LLVMValueRef LLVMGetOperand(LLVMValueRef Val, unsigned Index);
   1385 
   1386 /**
   1387  * Obtain the use of an operand at a specific index in a llvm::User value.
   1388  *
   1389  * @see llvm::User::getOperandUse()
   1390  */
   1391 LLVMUseRef LLVMGetOperandUse(LLVMValueRef Val, unsigned Index);
   1392 
   1393 /**
   1394  * Set an operand at a specific index in a llvm::User value.
   1395  *
   1396  * @see llvm::User::setOperand()
   1397  */
   1398 void LLVMSetOperand(LLVMValueRef User, unsigned Index, LLVMValueRef Val);
   1399 
   1400 /**
   1401  * Obtain the number of operands in a llvm::User value.
   1402  *
   1403  * @see llvm::User::getNumOperands()
   1404  */
   1405 int LLVMGetNumOperands(LLVMValueRef Val);
   1406 
   1407 /**
   1408  * @}
   1409  */
   1410 
   1411 /**
   1412  * @defgroup LLVMCCoreValueConstant Constants
   1413  *
   1414  * This section contains APIs for interacting with LLVMValueRef that
   1415  * correspond to llvm::Constant instances.
   1416  *
   1417  * These functions will work for any LLVMValueRef in the llvm::Constant
   1418  * class hierarchy.
   1419  *
   1420  * @{
   1421  */
   1422 
   1423 /**
   1424  * Obtain a constant value referring to the null instance of a type.
   1425  *
   1426  * @see llvm::Constant::getNullValue()
   1427  */
   1428 LLVMValueRef LLVMConstNull(LLVMTypeRef Ty); /* all zeroes */
   1429 
   1430 /**
   1431  * Obtain a constant value referring to the instance of a type
   1432  * consisting of all ones.
   1433  *
   1434  * This is only valid for integer types.
   1435  *
   1436  * @see llvm::Constant::getAllOnesValue()
   1437  */
   1438 LLVMValueRef LLVMConstAllOnes(LLVMTypeRef Ty);
   1439 
   1440 /**
   1441  * Obtain a constant value referring to an undefined value of a type.
   1442  *
   1443  * @see llvm::UndefValue::get()
   1444  */
   1445 LLVMValueRef LLVMGetUndef(LLVMTypeRef Ty);
   1446 
   1447 /**
   1448  * Determine whether a value instance is null.
   1449  *
   1450  * @see llvm::Constant::isNullValue()
   1451  */
   1452 LLVMBool LLVMIsNull(LLVMValueRef Val);
   1453 
   1454 /**
   1455  * Obtain a constant that is a constant pointer pointing to NULL for a
   1456  * specified type.
   1457  */
   1458 LLVMValueRef LLVMConstPointerNull(LLVMTypeRef Ty);
   1459 
   1460 /**
   1461  * @defgroup LLVMCCoreValueConstantScalar Scalar constants
   1462  *
   1463  * Functions in this group model LLVMValueRef instances that correspond
   1464  * to constants referring to scalar types.
   1465  *
   1466  * For integer types, the LLVMTypeRef parameter should correspond to a
   1467  * llvm::IntegerType instance and the returned LLVMValueRef will
   1468  * correspond to a llvm::ConstantInt.
   1469  *
   1470  * For floating point types, the LLVMTypeRef returned corresponds to a
   1471  * llvm::ConstantFP.
   1472  *
   1473  * @{
   1474  */
   1475 
   1476 /**
   1477  * Obtain a constant value for an integer type.
   1478  *
   1479  * The returned value corresponds to a llvm::ConstantInt.
   1480  *
   1481  * @see llvm::ConstantInt::get()
   1482  *
   1483  * @param IntTy Integer type to obtain value of.
   1484  * @param N The value the returned instance should refer to.
   1485  * @param SignExtend Whether to sign extend the produced value.
   1486  */
   1487 LLVMValueRef LLVMConstInt(LLVMTypeRef IntTy, unsigned long long N,
   1488                           LLVMBool SignExtend);
   1489 
   1490 /**
   1491  * Obtain a constant value for an integer of arbitrary precision.
   1492  *
   1493  * @see llvm::ConstantInt::get()
   1494  */
   1495 LLVMValueRef LLVMConstIntOfArbitraryPrecision(LLVMTypeRef IntTy,
   1496                                               unsigned NumWords,
   1497                                               const uint64_t Words[]);
   1498 
   1499 /**
   1500  * Obtain a constant value for an integer parsed from a string.
   1501  *
   1502  * A similar API, LLVMConstIntOfStringAndSize is also available. If the
   1503  * string's length is available, it is preferred to call that function
   1504  * instead.
   1505  *
   1506  * @see llvm::ConstantInt::get()
   1507  */
   1508 LLVMValueRef LLVMConstIntOfString(LLVMTypeRef IntTy, const char *Text,
   1509                                   uint8_t Radix);
   1510 
   1511 /**
   1512  * Obtain a constant value for an integer parsed from a string with
   1513  * specified length.
   1514  *
   1515  * @see llvm::ConstantInt::get()
   1516  */
   1517 LLVMValueRef LLVMConstIntOfStringAndSize(LLVMTypeRef IntTy, const char *Text,
   1518                                          unsigned SLen, uint8_t Radix);
   1519 
   1520 /**
   1521  * Obtain a constant value referring to a double floating point value.
   1522  */
   1523 LLVMValueRef LLVMConstReal(LLVMTypeRef RealTy, double N);
   1524 
   1525 /**
   1526  * Obtain a constant for a floating point value parsed from a string.
   1527  *
   1528  * A similar API, LLVMConstRealOfStringAndSize is also available. It
   1529  * should be used if the input string's length is known.
   1530  */
   1531 LLVMValueRef LLVMConstRealOfString(LLVMTypeRef RealTy, const char *Text);
   1532 
   1533 /**
   1534  * Obtain a constant for a floating point value parsed from a string.
   1535  */
   1536 LLVMValueRef LLVMConstRealOfStringAndSize(LLVMTypeRef RealTy, const char *Text,
   1537                                           unsigned SLen);
   1538 
   1539 /**
   1540  * Obtain the zero extended value for an integer constant value.
   1541  *
   1542  * @see llvm::ConstantInt::getZExtValue()
   1543  */
   1544 unsigned long long LLVMConstIntGetZExtValue(LLVMValueRef ConstantVal);
   1545 
   1546 /**
   1547  * Obtain the sign extended value for an integer constant value.
   1548  *
   1549  * @see llvm::ConstantInt::getSExtValue()
   1550  */
   1551 long long LLVMConstIntGetSExtValue(LLVMValueRef ConstantVal);
   1552 
   1553 /**
   1554  * Obtain the double value for an floating point constant value.
   1555  * losesInfo indicates if some precision was lost in the conversion.
   1556  *
   1557  * @see llvm::ConstantFP::getDoubleValue
   1558  */
   1559 double LLVMConstRealGetDouble(LLVMValueRef ConstantVal, LLVMBool *losesInfo);
   1560 
   1561 /**
   1562  * @}
   1563  */
   1564 
   1565 /**
   1566  * @defgroup LLVMCCoreValueConstantComposite Composite Constants
   1567  *
   1568  * Functions in this group operate on composite constants.
   1569  *
   1570  * @{
   1571  */
   1572 
   1573 /**
   1574  * Create a ConstantDataSequential and initialize it with a string.
   1575  *
   1576  * @see llvm::ConstantDataArray::getString()
   1577  */
   1578 LLVMValueRef LLVMConstStringInContext(LLVMContextRef C, const char *Str,
   1579                                       unsigned Length, LLVMBool DontNullTerminate);
   1580 
   1581 /**
   1582  * Create a ConstantDataSequential with string content in the global context.
   1583  *
   1584  * This is the same as LLVMConstStringInContext except it operates on the
   1585  * global context.
   1586  *
   1587  * @see LLVMConstStringInContext()
   1588  * @see llvm::ConstantDataArray::getString()
   1589  */
   1590 LLVMValueRef LLVMConstString(const char *Str, unsigned Length,
   1591                              LLVMBool DontNullTerminate);
   1592 
   1593 /**
   1594  * Returns true if the specified constant is an array of i8.
   1595  *
   1596  * @see ConstantDataSequential::getAsString()
   1597  */
   1598 LLVMBool LLVMIsConstantString(LLVMValueRef c);
   1599 
   1600 /**
   1601  * Get the given constant data sequential as a string.
   1602  *
   1603  * @see ConstantDataSequential::getAsString()
   1604  */
   1605 const char *LLVMGetAsString(LLVMValueRef c, size_t* out);
   1606 
   1607 /**
   1608  * Create an anonymous ConstantStruct with the specified values.
   1609  *
   1610  * @see llvm::ConstantStruct::getAnon()
   1611  */
   1612 LLVMValueRef LLVMConstStructInContext(LLVMContextRef C,
   1613                                       LLVMValueRef *ConstantVals,
   1614                                       unsigned Count, LLVMBool Packed);
   1615 
   1616 /**
   1617  * Create a ConstantStruct in the global Context.
   1618  *
   1619  * This is the same as LLVMConstStructInContext except it operates on the
   1620  * global Context.
   1621  *
   1622  * @see LLVMConstStructInContext()
   1623  */
   1624 LLVMValueRef LLVMConstStruct(LLVMValueRef *ConstantVals, unsigned Count,
   1625                              LLVMBool Packed);
   1626 
   1627 /**
   1628  * Create a ConstantArray from values.
   1629  *
   1630  * @see llvm::ConstantArray::get()
   1631  */
   1632 LLVMValueRef LLVMConstArray(LLVMTypeRef ElementTy,
   1633                             LLVMValueRef *ConstantVals, unsigned Length);
   1634 
   1635 /**
   1636  * Create a non-anonymous ConstantStruct from values.
   1637  *
   1638  * @see llvm::ConstantStruct::get()
   1639  */
   1640 LLVMValueRef LLVMConstNamedStruct(LLVMTypeRef StructTy,
   1641                                   LLVMValueRef *ConstantVals,
   1642                                   unsigned Count);
   1643 
   1644 /**
   1645  * Get an element at specified index as a constant.
   1646  *
   1647  * @see ConstantDataSequential::getElementAsConstant()
   1648  */
   1649 LLVMValueRef LLVMGetElementAsConstant(LLVMValueRef c, unsigned idx);
   1650 
   1651 /**
   1652  * Create a ConstantVector from values.
   1653  *
   1654  * @see llvm::ConstantVector::get()
   1655  */
   1656 LLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals, unsigned Size);
   1657 
   1658 /**
   1659  * @}
   1660  */
   1661 
   1662 /**
   1663  * @defgroup LLVMCCoreValueConstantExpressions Constant Expressions
   1664  *
   1665  * Functions in this group correspond to APIs on llvm::ConstantExpr.
   1666  *
   1667  * @see llvm::ConstantExpr.
   1668  *
   1669  * @{
   1670  */
   1671 LLVMOpcode LLVMGetConstOpcode(LLVMValueRef ConstantVal);
   1672 LLVMValueRef LLVMAlignOf(LLVMTypeRef Ty);
   1673 LLVMValueRef LLVMSizeOf(LLVMTypeRef Ty);
   1674 LLVMValueRef LLVMConstNeg(LLVMValueRef ConstantVal);
   1675 LLVMValueRef LLVMConstNSWNeg(LLVMValueRef ConstantVal);
   1676 LLVMValueRef LLVMConstNUWNeg(LLVMValueRef ConstantVal);
   1677 LLVMValueRef LLVMConstFNeg(LLVMValueRef ConstantVal);
   1678 LLVMValueRef LLVMConstNot(LLVMValueRef ConstantVal);
   1679 LLVMValueRef LLVMConstAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
   1680 LLVMValueRef LLVMConstNSWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
   1681 LLVMValueRef LLVMConstNUWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
   1682 LLVMValueRef LLVMConstFAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
   1683 LLVMValueRef LLVMConstSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
   1684 LLVMValueRef LLVMConstNSWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
   1685 LLVMValueRef LLVMConstNUWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
   1686 LLVMValueRef LLVMConstFSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
   1687 LLVMValueRef LLVMConstMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
   1688 LLVMValueRef LLVMConstNSWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
   1689 LLVMValueRef LLVMConstNUWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
   1690 LLVMValueRef LLVMConstFMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
   1691 LLVMValueRef LLVMConstUDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
   1692 LLVMValueRef LLVMConstSDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
   1693 LLVMValueRef LLVMConstExactSDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
   1694 LLVMValueRef LLVMConstFDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
   1695 LLVMValueRef LLVMConstURem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
   1696 LLVMValueRef LLVMConstSRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
   1697 LLVMValueRef LLVMConstFRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
   1698 LLVMValueRef LLVMConstAnd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
   1699 LLVMValueRef LLVMConstOr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
   1700 LLVMValueRef LLVMConstXor(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
   1701 LLVMValueRef LLVMConstICmp(LLVMIntPredicate Predicate,
   1702                            LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
   1703 LLVMValueRef LLVMConstFCmp(LLVMRealPredicate Predicate,
   1704                            LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
   1705 LLVMValueRef LLVMConstShl(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
   1706 LLVMValueRef LLVMConstLShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
   1707 LLVMValueRef LLVMConstAShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
   1708 LLVMValueRef LLVMConstGEP(LLVMValueRef ConstantVal,
   1709                           LLVMValueRef *ConstantIndices, unsigned NumIndices);
   1710 LLVMValueRef LLVMConstInBoundsGEP(LLVMValueRef ConstantVal,
   1711                                   LLVMValueRef *ConstantIndices,
   1712                                   unsigned NumIndices);
   1713 LLVMValueRef LLVMConstTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
   1714 LLVMValueRef LLVMConstSExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
   1715 LLVMValueRef LLVMConstZExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
   1716 LLVMValueRef LLVMConstFPTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
   1717 LLVMValueRef LLVMConstFPExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
   1718 LLVMValueRef LLVMConstUIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
   1719 LLVMValueRef LLVMConstSIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
   1720 LLVMValueRef LLVMConstFPToUI(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
   1721 LLVMValueRef LLVMConstFPToSI(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
   1722 LLVMValueRef LLVMConstPtrToInt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
   1723 LLVMValueRef LLVMConstIntToPtr(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
   1724 LLVMValueRef LLVMConstBitCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
   1725 LLVMValueRef LLVMConstAddrSpaceCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
   1726 LLVMValueRef LLVMConstZExtOrBitCast(LLVMValueRef ConstantVal,
   1727                                     LLVMTypeRef ToType);
   1728 LLVMValueRef LLVMConstSExtOrBitCast(LLVMValueRef ConstantVal,
   1729                                     LLVMTypeRef ToType);
   1730 LLVMValueRef LLVMConstTruncOrBitCast(LLVMValueRef ConstantVal,
   1731                                      LLVMTypeRef ToType);
   1732 LLVMValueRef LLVMConstPointerCast(LLVMValueRef ConstantVal,
   1733                                   LLVMTypeRef ToType);
   1734 LLVMValueRef LLVMConstIntCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType,
   1735                               LLVMBool isSigned);
   1736 LLVMValueRef LLVMConstFPCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
   1737 LLVMValueRef LLVMConstSelect(LLVMValueRef ConstantCondition,
   1738                              LLVMValueRef ConstantIfTrue,
   1739                              LLVMValueRef ConstantIfFalse);
   1740 LLVMValueRef LLVMConstExtractElement(LLVMValueRef VectorConstant,
   1741                                      LLVMValueRef IndexConstant);
   1742 LLVMValueRef LLVMConstInsertElement(LLVMValueRef VectorConstant,
   1743                                     LLVMValueRef ElementValueConstant,
   1744                                     LLVMValueRef IndexConstant);
   1745 LLVMValueRef LLVMConstShuffleVector(LLVMValueRef VectorAConstant,
   1746                                     LLVMValueRef VectorBConstant,
   1747                                     LLVMValueRef MaskConstant);
   1748 LLVMValueRef LLVMConstExtractValue(LLVMValueRef AggConstant, unsigned *IdxList,
   1749                                    unsigned NumIdx);
   1750 LLVMValueRef LLVMConstInsertValue(LLVMValueRef AggConstant,
   1751                                   LLVMValueRef ElementValueConstant,
   1752                                   unsigned *IdxList, unsigned NumIdx);
   1753 LLVMValueRef LLVMConstInlineAsm(LLVMTypeRef Ty,
   1754                                 const char *AsmString, const char *Constraints,
   1755                                 LLVMBool HasSideEffects, LLVMBool IsAlignStack);
   1756 LLVMValueRef LLVMBlockAddress(LLVMValueRef F, LLVMBasicBlockRef BB);
   1757 
   1758 /**
   1759  * @}
   1760  */
   1761 
   1762 /**
   1763  * @defgroup LLVMCCoreValueConstantGlobals Global Values
   1764  *
   1765  * This group contains functions that operate on global values. Functions in
   1766  * this group relate to functions in the llvm::GlobalValue class tree.
   1767  *
   1768  * @see llvm::GlobalValue
   1769  *
   1770  * @{
   1771  */
   1772 
   1773 LLVMModuleRef LLVMGetGlobalParent(LLVMValueRef Global);
   1774 LLVMBool LLVMIsDeclaration(LLVMValueRef Global);
   1775 LLVMLinkage LLVMGetLinkage(LLVMValueRef Global);
   1776 void LLVMSetLinkage(LLVMValueRef Global, LLVMLinkage Linkage);
   1777 const char *LLVMGetSection(LLVMValueRef Global);
   1778 void LLVMSetSection(LLVMValueRef Global, const char *Section);
   1779 LLVMVisibility LLVMGetVisibility(LLVMValueRef Global);
   1780 void LLVMSetVisibility(LLVMValueRef Global, LLVMVisibility Viz);
   1781 LLVMDLLStorageClass LLVMGetDLLStorageClass(LLVMValueRef Global);
   1782 void LLVMSetDLLStorageClass(LLVMValueRef Global, LLVMDLLStorageClass Class);
   1783 LLVMBool LLVMHasUnnamedAddr(LLVMValueRef Global);
   1784 void LLVMSetUnnamedAddr(LLVMValueRef Global, LLVMBool HasUnnamedAddr);
   1785 
   1786 /**
   1787  * @defgroup LLVMCCoreValueWithAlignment Values with alignment
   1788  *
   1789  * Functions in this group only apply to values with alignment, i.e.
   1790  * global variables, load and store instructions.
   1791  */
   1792 
   1793 /**
   1794  * Obtain the preferred alignment of the value.
   1795  * @see llvm::AllocaInst::getAlignment()
   1796  * @see llvm::LoadInst::getAlignment()
   1797  * @see llvm::StoreInst::getAlignment()
   1798  * @see llvm::GlobalValue::getAlignment()
   1799  */
   1800 unsigned LLVMGetAlignment(LLVMValueRef V);
   1801 
   1802 /**
   1803  * Set the preferred alignment of the value.
   1804  * @see llvm::AllocaInst::setAlignment()
   1805  * @see llvm::LoadInst::setAlignment()
   1806  * @see llvm::StoreInst::setAlignment()
   1807  * @see llvm::GlobalValue::setAlignment()
   1808  */
   1809 void LLVMSetAlignment(LLVMValueRef V, unsigned Bytes);
   1810 
   1811 /**
   1812   * @}
   1813   */
   1814 
   1815 /**
   1816  * @defgroup LLVMCoreValueConstantGlobalVariable Global Variables
   1817  *
   1818  * This group contains functions that operate on global variable values.
   1819  *
   1820  * @see llvm::GlobalVariable
   1821  *
   1822  * @{
   1823  */
   1824 LLVMValueRef LLVMAddGlobal(LLVMModuleRef M, LLVMTypeRef Ty, const char *Name);
   1825 LLVMValueRef LLVMAddGlobalInAddressSpace(LLVMModuleRef M, LLVMTypeRef Ty,
   1826                                          const char *Name,
   1827                                          unsigned AddressSpace);
   1828 LLVMValueRef LLVMGetNamedGlobal(LLVMModuleRef M, const char *Name);
   1829 LLVMValueRef LLVMGetFirstGlobal(LLVMModuleRef M);
   1830 LLVMValueRef LLVMGetLastGlobal(LLVMModuleRef M);
   1831 LLVMValueRef LLVMGetNextGlobal(LLVMValueRef GlobalVar);
   1832 LLVMValueRef LLVMGetPreviousGlobal(LLVMValueRef GlobalVar);
   1833 void LLVMDeleteGlobal(LLVMValueRef GlobalVar);
   1834 LLVMValueRef LLVMGetInitializer(LLVMValueRef GlobalVar);
   1835 void LLVMSetInitializer(LLVMValueRef GlobalVar, LLVMValueRef ConstantVal);
   1836 LLVMBool LLVMIsThreadLocal(LLVMValueRef GlobalVar);
   1837 void LLVMSetThreadLocal(LLVMValueRef GlobalVar, LLVMBool IsThreadLocal);
   1838 LLVMBool LLVMIsGlobalConstant(LLVMValueRef GlobalVar);
   1839 void LLVMSetGlobalConstant(LLVMValueRef GlobalVar, LLVMBool IsConstant);
   1840 LLVMThreadLocalMode LLVMGetThreadLocalMode(LLVMValueRef GlobalVar);
   1841 void LLVMSetThreadLocalMode(LLVMValueRef GlobalVar, LLVMThreadLocalMode Mode);
   1842 LLVMBool LLVMIsExternallyInitialized(LLVMValueRef GlobalVar);
   1843 void LLVMSetExternallyInitialized(LLVMValueRef GlobalVar, LLVMBool IsExtInit);
   1844 
   1845 /**
   1846  * @}
   1847  */
   1848 
   1849 /**
   1850  * @defgroup LLVMCoreValueConstantGlobalAlias Global Aliases
   1851  *
   1852  * This group contains function that operate on global alias values.
   1853  *
   1854  * @see llvm::GlobalAlias
   1855  *
   1856  * @{
   1857  */
   1858 LLVMValueRef LLVMAddAlias(LLVMModuleRef M, LLVMTypeRef Ty, LLVMValueRef Aliasee,
   1859                           const char *Name);
   1860 
   1861 /**
   1862  * @}
   1863  */
   1864 
   1865 /**
   1866  * @defgroup LLVMCCoreValueFunction Function values
   1867  *
   1868  * Functions in this group operate on LLVMValueRef instances that
   1869  * correspond to llvm::Function instances.
   1870  *
   1871  * @see llvm::Function
   1872  *
   1873  * @{
   1874  */
   1875 
   1876 /**
   1877  * Remove a function from its containing module and deletes it.
   1878  *
   1879  * @see llvm::Function::eraseFromParent()
   1880  */
   1881 void LLVMDeleteFunction(LLVMValueRef Fn);
   1882 
   1883 /**
   1884  * Obtain the ID number from a function instance.
   1885  *
   1886  * @see llvm::Function::getIntrinsicID()
   1887  */
   1888 unsigned LLVMGetIntrinsicID(LLVMValueRef Fn);
   1889 
   1890 /**
   1891  * Obtain the calling function of a function.
   1892  *
   1893  * The returned value corresponds to the LLVMCallConv enumeration.
   1894  *
   1895  * @see llvm::Function::getCallingConv()
   1896  */
   1897 unsigned LLVMGetFunctionCallConv(LLVMValueRef Fn);
   1898 
   1899 /**
   1900  * Set the calling convention of a function.
   1901  *
   1902  * @see llvm::Function::setCallingConv()
   1903  *
   1904  * @param Fn Function to operate on
   1905  * @param CC LLVMCallConv to set calling convention to
   1906  */
   1907 void LLVMSetFunctionCallConv(LLVMValueRef Fn, unsigned CC);
   1908 
   1909 /**
   1910  * Obtain the name of the garbage collector to use during code
   1911  * generation.
   1912  *
   1913  * @see llvm::Function::getGC()
   1914  */
   1915 const char *LLVMGetGC(LLVMValueRef Fn);
   1916 
   1917 /**
   1918  * Define the garbage collector to use during code generation.
   1919  *
   1920  * @see llvm::Function::setGC()
   1921  */
   1922 void LLVMSetGC(LLVMValueRef Fn, const char *Name);
   1923 
   1924 /**
   1925  * Add an attribute to a function.
   1926  *
   1927  * @see llvm::Function::addAttribute()
   1928  */
   1929 void LLVMAddFunctionAttr(LLVMValueRef Fn, LLVMAttribute PA);
   1930 
   1931 /**
   1932  * Add a target-dependent attribute to a fuction
   1933  * @see llvm::AttrBuilder::addAttribute()
   1934  */
   1935 void LLVMAddTargetDependentFunctionAttr(LLVMValueRef Fn, const char *A,
   1936                                         const char *V);
   1937 
   1938 /**
   1939  * Obtain an attribute from a function.
   1940  *
   1941  * @see llvm::Function::getAttributes()
   1942  */
   1943 LLVMAttribute LLVMGetFunctionAttr(LLVMValueRef Fn);
   1944 
   1945 /**
   1946  * Remove an attribute from a function.
   1947  */
   1948 void LLVMRemoveFunctionAttr(LLVMValueRef Fn, LLVMAttribute PA);
   1949 
   1950 /**
   1951  * @defgroup LLVMCCoreValueFunctionParameters Function Parameters
   1952  *
   1953  * Functions in this group relate to arguments/parameters on functions.
   1954  *
   1955  * Functions in this group expect LLVMValueRef instances that correspond
   1956  * to llvm::Function instances.
   1957  *
   1958  * @{
   1959  */
   1960 
   1961 /**
   1962  * Obtain the number of parameters in a function.
   1963  *
   1964  * @see llvm::Function::arg_size()
   1965  */
   1966 unsigned LLVMCountParams(LLVMValueRef Fn);
   1967 
   1968 /**
   1969  * Obtain the parameters in a function.
   1970  *
   1971  * The takes a pointer to a pre-allocated array of LLVMValueRef that is
   1972  * at least LLVMCountParams() long. This array will be filled with
   1973  * LLVMValueRef instances which correspond to the parameters the
   1974  * function receives. Each LLVMValueRef corresponds to a llvm::Argument
   1975  * instance.
   1976  *
   1977  * @see llvm::Function::arg_begin()
   1978  */
   1979 void LLVMGetParams(LLVMValueRef Fn, LLVMValueRef *Params);
   1980 
   1981 /**
   1982  * Obtain the parameter at the specified index.
   1983  *
   1984  * Parameters are indexed from 0.
   1985  *
   1986  * @see llvm::Function::arg_begin()
   1987  */
   1988 LLVMValueRef LLVMGetParam(LLVMValueRef Fn, unsigned Index);
   1989 
   1990 /**
   1991  * Obtain the function to which this argument belongs.
   1992  *
   1993  * Unlike other functions in this group, this one takes an LLVMValueRef
   1994  * that corresponds to a llvm::Attribute.
   1995  *
   1996  * The returned LLVMValueRef is the llvm::Function to which this
   1997  * argument belongs.
   1998  */
   1999 LLVMValueRef LLVMGetParamParent(LLVMValueRef Inst);
   2000 
   2001 /**
   2002  * Obtain the first parameter to a function.
   2003  *
   2004  * @see llvm::Function::arg_begin()
   2005  */
   2006 LLVMValueRef LLVMGetFirstParam(LLVMValueRef Fn);
   2007 
   2008 /**
   2009  * Obtain the last parameter to a function.
   2010  *
   2011  * @see llvm::Function::arg_end()
   2012  */
   2013 LLVMValueRef LLVMGetLastParam(LLVMValueRef Fn);
   2014 
   2015 /**
   2016  * Obtain the next parameter to a function.
   2017  *
   2018  * This takes an LLVMValueRef obtained from LLVMGetFirstParam() (which is
   2019  * actually a wrapped iterator) and obtains the next parameter from the
   2020  * underlying iterator.
   2021  */
   2022 LLVMValueRef LLVMGetNextParam(LLVMValueRef Arg);
   2023 
   2024 /**
   2025  * Obtain the previous parameter to a function.
   2026  *
   2027  * This is the opposite of LLVMGetNextParam().
   2028  */
   2029 LLVMValueRef LLVMGetPreviousParam(LLVMValueRef Arg);
   2030 
   2031 /**
   2032  * Add an attribute to a function argument.
   2033  *
   2034  * @see llvm::Argument::addAttr()
   2035  */
   2036 void LLVMAddAttribute(LLVMValueRef Arg, LLVMAttribute PA);
   2037 
   2038 /**
   2039  * Remove an attribute from a function argument.
   2040  *
   2041  * @see llvm::Argument::removeAttr()
   2042  */
   2043 void LLVMRemoveAttribute(LLVMValueRef Arg, LLVMAttribute PA);
   2044 
   2045 /**
   2046  * Get an attribute from a function argument.
   2047  */
   2048 LLVMAttribute LLVMGetAttribute(LLVMValueRef Arg);
   2049 
   2050 /**
   2051  * Set the alignment for a function parameter.
   2052  *
   2053  * @see llvm::Argument::addAttr()
   2054  * @see llvm::AttrBuilder::addAlignmentAttr()
   2055  */
   2056 void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned align);
   2057 
   2058 /**
   2059  * @}
   2060  */
   2061 
   2062 /**
   2063  * @}
   2064  */
   2065 
   2066 /**
   2067  * @}
   2068  */
   2069 
   2070 /**
   2071  * @}
   2072  */
   2073 
   2074 /**
   2075  * @defgroup LLVMCCoreValueMetadata Metadata
   2076  *
   2077  * @{
   2078  */
   2079 
   2080 /**
   2081  * Obtain a MDString value from a context.
   2082  *
   2083  * The returned instance corresponds to the llvm::MDString class.
   2084  *
   2085  * The instance is specified by string data of a specified length. The
   2086  * string content is copied, so the backing memory can be freed after
   2087  * this function returns.
   2088  */
   2089 LLVMValueRef LLVMMDStringInContext(LLVMContextRef C, const char *Str,
   2090                                    unsigned SLen);
   2091 
   2092 /**
   2093  * Obtain a MDString value from the global context.
   2094  */
   2095 LLVMValueRef LLVMMDString(const char *Str, unsigned SLen);
   2096 
   2097 /**
   2098  * Obtain a MDNode value from a context.
   2099  *
   2100  * The returned value corresponds to the llvm::MDNode class.
   2101  */
   2102 LLVMValueRef LLVMMDNodeInContext(LLVMContextRef C, LLVMValueRef *Vals,
   2103                                  unsigned Count);
   2104 
   2105 /**
   2106  * Obtain a MDNode value from the global context.
   2107  */
   2108 LLVMValueRef LLVMMDNode(LLVMValueRef *Vals, unsigned Count);
   2109 
   2110 /**
   2111  * Obtain the underlying string from a MDString value.
   2112  *
   2113  * @param V Instance to obtain string from.
   2114  * @param Len Memory address which will hold length of returned string.
   2115  * @return String data in MDString.
   2116  */
   2117 const char  *LLVMGetMDString(LLVMValueRef V, unsigned* Len);
   2118 
   2119 /**
   2120  * Obtain the number of operands from an MDNode value.
   2121  *
   2122  * @param V MDNode to get number of operands from.
   2123  * @return Number of operands of the MDNode.
   2124  */
   2125 unsigned LLVMGetMDNodeNumOperands(LLVMValueRef V);
   2126 
   2127 /**
   2128  * Obtain the given MDNode's operands.
   2129  *
   2130  * The passed LLVMValueRef pointer should point to enough memory to hold all of
   2131  * the operands of the given MDNode (see LLVMGetMDNodeNumOperands) as
   2132  * LLVMValueRefs. This memory will be populated with the LLVMValueRefs of the
   2133  * MDNode's operands.
   2134  *
   2135  * @param V MDNode to get the operands from.
   2136  * @param Dest Destination array for operands.
   2137  */
   2138 void LLVMGetMDNodeOperands(LLVMValueRef V, LLVMValueRef *Dest);
   2139 
   2140 /**
   2141  * @}
   2142  */
   2143 
   2144 /**
   2145  * @defgroup LLVMCCoreValueBasicBlock Basic Block
   2146  *
   2147  * A basic block represents a single entry single exit section of code.
   2148  * Basic blocks contain a list of instructions which form the body of
   2149  * the block.
   2150  *
   2151  * Basic blocks belong to functions. They have the type of label.
   2152  *
   2153  * Basic blocks are themselves values. However, the C API models them as
   2154  * LLVMBasicBlockRef.
   2155  *
   2156  * @see llvm::BasicBlock
   2157  *
   2158  * @{
   2159  */
   2160 
   2161 /**
   2162  * Convert a basic block instance to a value type.
   2163  */
   2164 LLVMValueRef LLVMBasicBlockAsValue(LLVMBasicBlockRef BB);
   2165 
   2166 /**
   2167  * Determine whether an LLVMValueRef is itself a basic block.
   2168  */
   2169 LLVMBool LLVMValueIsBasicBlock(LLVMValueRef Val);
   2170 
   2171 /**
   2172  * Convert an LLVMValueRef to an LLVMBasicBlockRef instance.
   2173  */
   2174 LLVMBasicBlockRef LLVMValueAsBasicBlock(LLVMValueRef Val);
   2175 
   2176 /**
   2177  * Obtain the function to which a basic block belongs.
   2178  *
   2179  * @see llvm::BasicBlock::getParent()
   2180  */
   2181 LLVMValueRef LLVMGetBasicBlockParent(LLVMBasicBlockRef BB);
   2182 
   2183 /**
   2184  * Obtain the terminator instruction for a basic block.
   2185  *
   2186  * If the basic block does not have a terminator (it is not well-formed
   2187  * if it doesn't), then NULL is returned.
   2188  *
   2189  * The returned LLVMValueRef corresponds to a llvm::TerminatorInst.
   2190  *
   2191  * @see llvm::BasicBlock::getTerminator()
   2192  */
   2193 LLVMValueRef LLVMGetBasicBlockTerminator(LLVMBasicBlockRef BB);
   2194 
   2195 /**
   2196  * Obtain the number of basic blocks in a function.
   2197  *
   2198  * @param Fn Function value to operate on.
   2199  */
   2200 unsigned LLVMCountBasicBlocks(LLVMValueRef Fn);
   2201 
   2202 /**
   2203  * Obtain all of the basic blocks in a function.
   2204  *
   2205  * This operates on a function value. The BasicBlocks parameter is a
   2206  * pointer to a pre-allocated array of LLVMBasicBlockRef of at least
   2207  * LLVMCountBasicBlocks() in length. This array is populated with
   2208  * LLVMBasicBlockRef instances.
   2209  */
   2210 void LLVMGetBasicBlocks(LLVMValueRef Fn, LLVMBasicBlockRef *BasicBlocks);
   2211 
   2212 /**
   2213  * Obtain the first basic block in a function.
   2214  *
   2215  * The returned basic block can be used as an iterator. You will likely
   2216  * eventually call into LLVMGetNextBasicBlock() with it.
   2217  *
   2218  * @see llvm::Function::begin()
   2219  */
   2220 LLVMBasicBlockRef LLVMGetFirstBasicBlock(LLVMValueRef Fn);
   2221 
   2222 /**
   2223  * Obtain the last basic block in a function.
   2224  *
   2225  * @see llvm::Function::end()
   2226  */
   2227 LLVMBasicBlockRef LLVMGetLastBasicBlock(LLVMValueRef Fn);
   2228 
   2229 /**
   2230  * Advance a basic block iterator.
   2231  */
   2232 LLVMBasicBlockRef LLVMGetNextBasicBlock(LLVMBasicBlockRef BB);
   2233 
   2234 /**
   2235  * Go backwards in a basic block iterator.
   2236  */
   2237 LLVMBasicBlockRef LLVMGetPreviousBasicBlock(LLVMBasicBlockRef BB);
   2238 
   2239 /**
   2240  * Obtain the basic block that corresponds to the entry point of a
   2241  * function.
   2242  *
   2243  * @see llvm::Function::getEntryBlock()
   2244  */
   2245 LLVMBasicBlockRef LLVMGetEntryBasicBlock(LLVMValueRef Fn);
   2246 
   2247 /**
   2248  * Append a basic block to the end of a function.
   2249  *
   2250  * @see llvm::BasicBlock::Create()
   2251  */
   2252 LLVMBasicBlockRef LLVMAppendBasicBlockInContext(LLVMContextRef C,
   2253                                                 LLVMValueRef Fn,
   2254                                                 const char *Name);
   2255 
   2256 /**
   2257  * Append a basic block to the end of a function using the global
   2258  * context.
   2259  *
   2260  * @see llvm::BasicBlock::Create()
   2261  */
   2262 LLVMBasicBlockRef LLVMAppendBasicBlock(LLVMValueRef Fn, const char *Name);
   2263 
   2264 /**
   2265  * Insert a basic block in a function before another basic block.
   2266  *
   2267  * The function to add to is determined by the function of the
   2268  * passed basic block.
   2269  *
   2270  * @see llvm::BasicBlock::Create()
   2271  */
   2272 LLVMBasicBlockRef LLVMInsertBasicBlockInContext(LLVMContextRef C,
   2273                                                 LLVMBasicBlockRef BB,
   2274                                                 const char *Name);
   2275 
   2276 /**
   2277  * Insert a basic block in a function using the global context.
   2278  *
   2279  * @see llvm::BasicBlock::Create()
   2280  */
   2281 LLVMBasicBlockRef LLVMInsertBasicBlock(LLVMBasicBlockRef InsertBeforeBB,
   2282                                        const char *Name);
   2283 
   2284 /**
   2285  * Remove a basic block from a function and delete it.
   2286  *
   2287  * This deletes the basic block from its containing function and deletes
   2288  * the basic block itself.
   2289  *
   2290  * @see llvm::BasicBlock::eraseFromParent()
   2291  */
   2292 void LLVMDeleteBasicBlock(LLVMBasicBlockRef BB);
   2293 
   2294 /**
   2295  * Remove a basic block from a function.
   2296  *
   2297  * This deletes the basic block from its containing function but keep
   2298  * the basic block alive.
   2299  *
   2300  * @see llvm::BasicBlock::removeFromParent()
   2301  */
   2302 void LLVMRemoveBasicBlockFromParent(LLVMBasicBlockRef BB);
   2303 
   2304 /**
   2305  * Move a basic block to before another one.
   2306  *
   2307  * @see llvm::BasicBlock::moveBefore()
   2308  */
   2309 void LLVMMoveBasicBlockBefore(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos);
   2310 
   2311 /**
   2312  * Move a basic block to after another one.
   2313  *
   2314  * @see llvm::BasicBlock::moveAfter()
   2315  */
   2316 void LLVMMoveBasicBlockAfter(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos);
   2317 
   2318 /**
   2319  * Obtain the first instruction in a basic block.
   2320  *
   2321  * The returned LLVMValueRef corresponds to a llvm::Instruction
   2322  * instance.
   2323  */
   2324 LLVMValueRef LLVMGetFirstInstruction(LLVMBasicBlockRef BB);
   2325 
   2326 /**
   2327  * Obtain the last instruction in a basic block.
   2328  *
   2329  * The returned LLVMValueRef corresponds to an LLVM:Instruction.
   2330  */
   2331 LLVMValueRef LLVMGetLastInstruction(LLVMBasicBlockRef BB);
   2332 
   2333 /**
   2334  * @}
   2335  */
   2336 
   2337 /**
   2338  * @defgroup LLVMCCoreValueInstruction Instructions
   2339  *
   2340  * Functions in this group relate to the inspection and manipulation of
   2341  * individual instructions.
   2342  *
   2343  * In the C++ API, an instruction is modeled by llvm::Instruction. This
   2344  * class has a large number of descendents. llvm::Instruction is a
   2345  * llvm::Value and in the C API, instructions are modeled by
   2346  * LLVMValueRef.
   2347  *
   2348  * This group also contains sub-groups which operate on specific
   2349  * llvm::Instruction types, e.g. llvm::CallInst.
   2350  *
   2351  * @{
   2352  */
   2353 
   2354 /**
   2355  * Determine whether an instruction has any metadata attached.
   2356  */
   2357 int LLVMHasMetadata(LLVMValueRef Val);
   2358 
   2359 /**
   2360  * Return metadata associated with an instruction value.
   2361  */
   2362 LLVMValueRef LLVMGetMetadata(LLVMValueRef Val, unsigned KindID);
   2363 
   2364 /**
   2365  * Set metadata associated with an instruction value.
   2366  */
   2367 void LLVMSetMetadata(LLVMValueRef Val, unsigned KindID, LLVMValueRef Node);
   2368 
   2369 /**
   2370  * Obtain the basic block to which an instruction belongs.
   2371  *
   2372  * @see llvm::Instruction::getParent()
   2373  */
   2374 LLVMBasicBlockRef LLVMGetInstructionParent(LLVMValueRef Inst);
   2375 
   2376 /**
   2377  * Obtain the instruction that occurs after the one specified.
   2378  *
   2379  * The next instruction will be from the same basic block.
   2380  *
   2381  * If this is the last instruction in a basic block, NULL will be
   2382  * returned.
   2383  */
   2384 LLVMValueRef LLVMGetNextInstruction(LLVMValueRef Inst);
   2385 
   2386 /**
   2387  * Obtain the instruction that occurred before this one.
   2388  *
   2389  * If the instruction is the first instruction in a basic block, NULL
   2390  * will be returned.
   2391  */
   2392 LLVMValueRef LLVMGetPreviousInstruction(LLVMValueRef Inst);
   2393 
   2394 /**
   2395  * Remove and delete an instruction.
   2396  *
   2397  * The instruction specified is removed from its containing building
   2398  * block and then deleted.
   2399  *
   2400  * @see llvm::Instruction::eraseFromParent()
   2401  */
   2402 void LLVMInstructionEraseFromParent(LLVMValueRef Inst);
   2403 
   2404 /**
   2405  * Obtain the code opcode for an individual instruction.
   2406  *
   2407  * @see llvm::Instruction::getOpCode()
   2408  */
   2409 LLVMOpcode   LLVMGetInstructionOpcode(LLVMValueRef Inst);
   2410 
   2411 /**
   2412  * Obtain the predicate of an instruction.
   2413  *
   2414  * This is only valid for instructions that correspond to llvm::ICmpInst
   2415  * or llvm::ConstantExpr whose opcode is llvm::Instruction::ICmp.
   2416  *
   2417  * @see llvm::ICmpInst::getPredicate()
   2418  */
   2419 LLVMIntPredicate LLVMGetICmpPredicate(LLVMValueRef Inst);
   2420 
   2421 /**
   2422  * Obtain the float predicate of an instruction.
   2423  *
   2424  * This is only valid for instructions that correspond to llvm::FCmpInst
   2425  * or llvm::ConstantExpr whose opcode is llvm::Instruction::FCmp.
   2426  *
   2427  * @see llvm::FCmpInst::getPredicate()
   2428  */
   2429 LLVMRealPredicate LLVMGetFCmpPredicate(LLVMValueRef Inst);
   2430 
   2431 /**
   2432  * Create a copy of 'this' instruction that is identical in all ways
   2433  * except the following:
   2434  *   * The instruction has no parent
   2435  *   * The instruction has no name
   2436  *
   2437  * @see llvm::Instruction::clone()
   2438  */
   2439 LLVMValueRef LLVMInstructionClone(LLVMValueRef Inst);
   2440 
   2441 /**
   2442  * @defgroup LLVMCCoreValueInstructionCall Call Sites and Invocations
   2443  *
   2444  * Functions in this group apply to instructions that refer to call
   2445  * sites and invocations. These correspond to C++ types in the
   2446  * llvm::CallInst class tree.
   2447  *
   2448  * @{
   2449  */
   2450 
   2451 /**
   2452  * Set the calling convention for a call instruction.
   2453  *
   2454  * This expects an LLVMValueRef that corresponds to a llvm::CallInst or
   2455  * llvm::InvokeInst.
   2456  *
   2457  * @see llvm::CallInst::setCallingConv()
   2458  * @see llvm::InvokeInst::setCallingConv()
   2459  */
   2460 void LLVMSetInstructionCallConv(LLVMValueRef Instr, unsigned CC);
   2461 
   2462 /**
   2463  * Obtain the calling convention for a call instruction.
   2464  *
   2465  * This is the opposite of LLVMSetInstructionCallConv(). Reads its
   2466  * usage.
   2467  *
   2468  * @see LLVMSetInstructionCallConv()
   2469  */
   2470 unsigned LLVMGetInstructionCallConv(LLVMValueRef Instr);
   2471 
   2472 
   2473 void LLVMAddInstrAttribute(LLVMValueRef Instr, unsigned index, LLVMAttribute);
   2474 void LLVMRemoveInstrAttribute(LLVMValueRef Instr, unsigned index,
   2475                               LLVMAttribute);
   2476 void LLVMSetInstrParamAlignment(LLVMValueRef Instr, unsigned index,
   2477                                 unsigned align);
   2478 
   2479 /**
   2480  * Obtain whether a call instruction is a tail call.
   2481  *
   2482  * This only works on llvm::CallInst instructions.
   2483  *
   2484  * @see llvm::CallInst::isTailCall()
   2485  */
   2486 LLVMBool LLVMIsTailCall(LLVMValueRef CallInst);
   2487 
   2488 /**
   2489  * Set whether a call instruction is a tail call.
   2490  *
   2491  * This only works on llvm::CallInst instructions.
   2492  *
   2493  * @see llvm::CallInst::setTailCall()
   2494  */
   2495 void LLVMSetTailCall(LLVMValueRef CallInst, LLVMBool IsTailCall);
   2496 
   2497 /**
   2498  * @}
   2499  */
   2500 
   2501 /**
   2502  * @defgroup LLVMCCoreValueInstructionTerminator Terminators
   2503  *
   2504  * Functions in this group only apply to instructions that map to
   2505  * llvm::TerminatorInst instances.
   2506  *
   2507  * @{
   2508  */
   2509 
   2510 /**
   2511  * Return the number of successors that this terminator has.
   2512  *
   2513  * @see llvm::TerminatorInst::getNumSuccessors
   2514  */
   2515 unsigned LLVMGetNumSuccessors(LLVMValueRef Term);
   2516 
   2517 /**
   2518  * Return the specified successor.
   2519  *
   2520  * @see llvm::TerminatorInst::getSuccessor
   2521  */
   2522 LLVMBasicBlockRef LLVMGetSuccessor(LLVMValueRef Term, unsigned i);
   2523 
   2524 /**
   2525  * Update the specified successor to point at the provided block.
   2526  *
   2527  * @see llvm::TerminatorInst::setSuccessor
   2528  */
   2529 void LLVMSetSuccessor(LLVMValueRef Term, unsigned i, LLVMBasicBlockRef block);
   2530 
   2531 /**
   2532  * Return if a branch is conditional.
   2533  *
   2534  * This only works on llvm::BranchInst instructions.
   2535  *
   2536  * @see llvm::BranchInst::isConditional
   2537  */
   2538 LLVMBool LLVMIsConditional(LLVMValueRef Branch);
   2539 
   2540 /**
   2541  * Return the condition of a branch instruction.
   2542  *
   2543  * This only works on llvm::BranchInst instructions.
   2544  *
   2545  * @see llvm::BranchInst::getCondition
   2546  */
   2547 LLVMValueRef LLVMGetCondition(LLVMValueRef Branch);
   2548 
   2549 /**
   2550  * Set the condition of a branch instruction.
   2551  *
   2552  * This only works on llvm::BranchInst instructions.
   2553  *
   2554  * @see llvm::BranchInst::setCondition
   2555  */
   2556 void LLVMSetCondition(LLVMValueRef Branch, LLVMValueRef Cond);
   2557 
   2558 /**
   2559  * Obtain the default destination basic block of a switch instruction.
   2560  *
   2561  * This only works on llvm::SwitchInst instructions.
   2562  *
   2563  * @see llvm::SwitchInst::getDefaultDest()
   2564  */
   2565 LLVMBasicBlockRef LLVMGetSwitchDefaultDest(LLVMValueRef SwitchInstr);
   2566 
   2567 /**
   2568  * @}
   2569  */
   2570 
   2571 /**
   2572  * @defgroup LLVMCCoreValueInstructionPHINode PHI Nodes
   2573  *
   2574  * Functions in this group only apply to instructions that map to
   2575  * llvm::PHINode instances.
   2576  *
   2577  * @{
   2578  */
   2579 
   2580 /**
   2581  * Add an incoming value to the end of a PHI list.
   2582  */
   2583 void LLVMAddIncoming(LLVMValueRef PhiNode, LLVMValueRef *IncomingValues,
   2584                      LLVMBasicBlockRef *IncomingBlocks, unsigned Count);
   2585 
   2586 /**
   2587  * Obtain the number of incoming basic blocks to a PHI node.
   2588  */
   2589 unsigned LLVMCountIncoming(LLVMValueRef PhiNode);
   2590 
   2591 /**
   2592  * Obtain an incoming value to a PHI node as an LLVMValueRef.
   2593  */
   2594 LLVMValueRef LLVMGetIncomingValue(LLVMValueRef PhiNode, unsigned Index);
   2595 
   2596 /**
   2597  * Obtain an incoming value to a PHI node as an LLVMBasicBlockRef.
   2598  */
   2599 LLVMBasicBlockRef LLVMGetIncomingBlock(LLVMValueRef PhiNode, unsigned Index);
   2600 
   2601 /**
   2602  * @}
   2603  */
   2604 
   2605 /**
   2606  * @}
   2607  */
   2608 
   2609 /**
   2610  * @}
   2611  */
   2612 
   2613 /**
   2614  * @defgroup LLVMCCoreInstructionBuilder Instruction Builders
   2615  *
   2616  * An instruction builder represents a point within a basic block and is
   2617  * the exclusive means of building instructions using the C interface.
   2618  *
   2619  * @{
   2620  */
   2621 
   2622 LLVMBuilderRef LLVMCreateBuilderInContext(LLVMContextRef C);
   2623 LLVMBuilderRef LLVMCreateBuilder(void);
   2624 void LLVMPositionBuilder(LLVMBuilderRef Builder, LLVMBasicBlockRef Block,
   2625                          LLVMValueRef Instr);
   2626 void LLVMPositionBuilderBefore(LLVMBuilderRef Builder, LLVMValueRef Instr);
   2627 void LLVMPositionBuilderAtEnd(LLVMBuilderRef Builder, LLVMBasicBlockRef Block);
   2628 LLVMBasicBlockRef LLVMGetInsertBlock(LLVMBuilderRef Builder);
   2629 void LLVMClearInsertionPosition(LLVMBuilderRef Builder);
   2630 void LLVMInsertIntoBuilder(LLVMBuilderRef Builder, LLVMValueRef Instr);
   2631 void LLVMInsertIntoBuilderWithName(LLVMBuilderRef Builder, LLVMValueRef Instr,
   2632                                    const char *Name);
   2633 void LLVMDisposeBuilder(LLVMBuilderRef Builder);
   2634 
   2635 /* Metadata */
   2636 void LLVMSetCurrentDebugLocation(LLVMBuilderRef Builder, LLVMValueRef L);
   2637 LLVMValueRef LLVMGetCurrentDebugLocation(LLVMBuilderRef Builder);
   2638 void LLVMSetInstDebugLocation(LLVMBuilderRef Builder, LLVMValueRef Inst);
   2639 
   2640 /* Terminators */
   2641 LLVMValueRef LLVMBuildRetVoid(LLVMBuilderRef);
   2642 LLVMValueRef LLVMBuildRet(LLVMBuilderRef, LLVMValueRef V);
   2643 LLVMValueRef LLVMBuildAggregateRet(LLVMBuilderRef, LLVMValueRef *RetVals,
   2644                                    unsigned N);
   2645 LLVMValueRef LLVMBuildBr(LLVMBuilderRef, LLVMBasicBlockRef Dest);
   2646 LLVMValueRef LLVMBuildCondBr(LLVMBuilderRef, LLVMValueRef If,
   2647                              LLVMBasicBlockRef Then, LLVMBasicBlockRef Else);
   2648 LLVMValueRef LLVMBuildSwitch(LLVMBuilderRef, LLVMValueRef V,
   2649                              LLVMBasicBlockRef Else, unsigned NumCases);
   2650 LLVMValueRef LLVMBuildIndirectBr(LLVMBuilderRef B, LLVMValueRef Addr,
   2651                                  unsigned NumDests);
   2652 LLVMValueRef LLVMBuildInvoke(LLVMBuilderRef, LLVMValueRef Fn,
   2653                              LLVMValueRef *Args, unsigned NumArgs,
   2654                              LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch,
   2655                              const char *Name);
   2656 LLVMValueRef LLVMBuildLandingPad(LLVMBuilderRef B, LLVMTypeRef Ty,
   2657                                  LLVMValueRef PersFn, unsigned NumClauses,
   2658                                  const char *Name);
   2659 LLVMValueRef LLVMBuildResume(LLVMBuilderRef B, LLVMValueRef Exn);
   2660 LLVMValueRef LLVMBuildUnreachable(LLVMBuilderRef);
   2661 
   2662 /* Add a case to the switch instruction */
   2663 void LLVMAddCase(LLVMValueRef Switch, LLVMValueRef OnVal,
   2664                  LLVMBasicBlockRef Dest);
   2665 
   2666 /* Add a destination to the indirectbr instruction */
   2667 void LLVMAddDestination(LLVMValueRef IndirectBr, LLVMBasicBlockRef Dest);
   2668 
   2669 /* Add a catch or filter clause to the landingpad instruction */
   2670 void LLVMAddClause(LLVMValueRef LandingPad, LLVMValueRef ClauseVal);
   2671 
   2672 /* Set the 'cleanup' flag in the landingpad instruction */
   2673 void LLVMSetCleanup(LLVMValueRef LandingPad, LLVMBool Val);
   2674 
   2675 /* Arithmetic */
   2676 LLVMValueRef LLVMBuildAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
   2677                           const char *Name);
   2678 LLVMValueRef LLVMBuildNSWAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
   2679                              const char *Name);
   2680 LLVMValueRef LLVMBuildNUWAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
   2681                              const char *Name);
   2682 LLVMValueRef LLVMBuildFAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
   2683                            const char *Name);
   2684 LLVMValueRef LLVMBuildSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
   2685                           const char *Name);
   2686 LLVMValueRef LLVMBuildNSWSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
   2687                              const char *Name);
   2688 LLVMValueRef LLVMBuildNUWSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
   2689                              const char *Name);
   2690 LLVMValueRef LLVMBuildFSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
   2691                            const char *Name);
   2692 LLVMValueRef LLVMBuildMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
   2693                           const char *Name);
   2694 LLVMValueRef LLVMBuildNSWMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
   2695                              const char *Name);
   2696 LLVMValueRef LLVMBuildNUWMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
   2697                              const char *Name);
   2698 LLVMValueRef LLVMBuildFMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
   2699                            const char *Name);
   2700 LLVMValueRef LLVMBuildUDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
   2701                            const char *Name);
   2702 LLVMValueRef LLVMBuildSDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
   2703                            const char *Name);
   2704 LLVMValueRef LLVMBuildExactSDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
   2705                                 const char *Name);
   2706 LLVMValueRef LLVMBuildFDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
   2707                            const char *Name);
   2708 LLVMValueRef LLVMBuildURem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
   2709                            const char *Name);
   2710 LLVMValueRef LLVMBuildSRem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
   2711                            const char *Name);
   2712 LLVMValueRef LLVMBuildFRem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
   2713                            const char *Name);
   2714 LLVMValueRef LLVMBuildShl(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
   2715                            const char *Name);
   2716 LLVMValueRef LLVMBuildLShr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
   2717                            const char *Name);
   2718 LLVMValueRef LLVMBuildAShr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
   2719                            const char *Name);
   2720 LLVMValueRef LLVMBuildAnd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
   2721                           const char *Name);
   2722 LLVMValueRef LLVMBuildOr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
   2723                           const char *Name);
   2724 LLVMValueRef LLVMBuildXor(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
   2725                           const char *Name);
   2726 LLVMValueRef LLVMBuildBinOp(LLVMBuilderRef B, LLVMOpcode Op,
   2727                             LLVMValueRef LHS, LLVMValueRef RHS,
   2728                             const char *Name);
   2729 LLVMValueRef LLVMBuildNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name);
   2730 LLVMValueRef LLVMBuildNSWNeg(LLVMBuilderRef B, LLVMValueRef V,
   2731                              const char *Name);
   2732 LLVMValueRef LLVMBuildNUWNeg(LLVMBuilderRef B, LLVMValueRef V,
   2733                              const char *Name);
   2734 LLVMValueRef LLVMBuildFNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name);
   2735 LLVMValueRef LLVMBuildNot(LLVMBuilderRef, LLVMValueRef V, const char *Name);
   2736 
   2737 /* Memory */
   2738 LLVMValueRef LLVMBuildMalloc(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
   2739 LLVMValueRef LLVMBuildArrayMalloc(LLVMBuilderRef, LLVMTypeRef Ty,
   2740                                   LLVMValueRef Val, const char *Name);
   2741 LLVMValueRef LLVMBuildAlloca(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
   2742 LLVMValueRef LLVMBuildArrayAlloca(LLVMBuilderRef, LLVMTypeRef Ty,
   2743                                   LLVMValueRef Val, const char *Name);
   2744 LLVMValueRef LLVMBuildFree(LLVMBuilderRef, LLVMValueRef PointerVal);
   2745 LLVMValueRef LLVMBuildLoad(LLVMBuilderRef, LLVMValueRef PointerVal,
   2746                            const char *Name);
   2747 LLVMValueRef LLVMBuildStore(LLVMBuilderRef, LLVMValueRef Val, LLVMValueRef Ptr);
   2748 LLVMValueRef LLVMBuildGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
   2749                           LLVMValueRef *Indices, unsigned NumIndices,
   2750                           const char *Name);
   2751 LLVMValueRef LLVMBuildInBoundsGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
   2752                                   LLVMValueRef *Indices, unsigned NumIndices,
   2753                                   const char *Name);
   2754 LLVMValueRef LLVMBuildStructGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
   2755                                 unsigned Idx, const char *Name);
   2756 LLVMValueRef LLVMBuildGlobalString(LLVMBuilderRef B, const char *Str,
   2757                                    const char *Name);
   2758 LLVMValueRef LLVMBuildGlobalStringPtr(LLVMBuilderRef B, const char *Str,
   2759                                       const char *Name);
   2760 LLVMBool LLVMGetVolatile(LLVMValueRef MemoryAccessInst);
   2761 void LLVMSetVolatile(LLVMValueRef MemoryAccessInst, LLVMBool IsVolatile);
   2762 
   2763 /* Casts */
   2764 LLVMValueRef LLVMBuildTrunc(LLVMBuilderRef, LLVMValueRef Val,
   2765                             LLVMTypeRef DestTy, const char *Name);
   2766 LLVMValueRef LLVMBuildZExt(LLVMBuilderRef, LLVMValueRef Val,
   2767                            LLVMTypeRef DestTy, const char *Name);
   2768 LLVMValueRef LLVMBuildSExt(LLVMBuilderRef, LLVMValueRef Val,
   2769                            LLVMTypeRef DestTy, const char *Name);
   2770 LLVMValueRef LLVMBuildFPToUI(LLVMBuilderRef, LLVMValueRef Val,
   2771                              LLVMTypeRef DestTy, const char *Name);
   2772 LLVMValueRef LLVMBuildFPToSI(LLVMBuilderRef, LLVMValueRef Val,
   2773                              LLVMTypeRef DestTy, const char *Name);
   2774 LLVMValueRef LLVMBuildUIToFP(LLVMBuilderRef, LLVMValueRef Val,
   2775                              LLVMTypeRef DestTy, const char *Name);
   2776 LLVMValueRef LLVMBuildSIToFP(LLVMBuilderRef, LLVMValueRef Val,
   2777                              LLVMTypeRef DestTy, const char *Name);
   2778 LLVMValueRef LLVMBuildFPTrunc(LLVMBuilderRef, LLVMValueRef Val,
   2779                               LLVMTypeRef DestTy, const char *Name);
   2780 LLVMValueRef LLVMBuildFPExt(LLVMBuilderRef, LLVMValueRef Val,
   2781                             LLVMTypeRef DestTy, const char *Name);
   2782 LLVMValueRef LLVMBuildPtrToInt(LLVMBuilderRef, LLVMValueRef Val,
   2783                                LLVMTypeRef DestTy, const char *Name);
   2784 LLVMValueRef LLVMBuildIntToPtr(LLVMBuilderRef, LLVMValueRef Val,
   2785                                LLVMTypeRef DestTy, const char *Name);
   2786 LLVMValueRef LLVMBuildBitCast(LLVMBuilderRef, LLVMValueRef Val,
   2787                               LLVMTypeRef DestTy, const char *Name);
   2788 LLVMValueRef LLVMBuildAddrSpaceCast(LLVMBuilderRef, LLVMValueRef Val,
   2789                                     LLVMTypeRef DestTy, const char *Name);
   2790 LLVMValueRef LLVMBuildZExtOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
   2791                                     LLVMTypeRef DestTy, const char *Name);
   2792 LLVMValueRef LLVMBuildSExtOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
   2793                                     LLVMTypeRef DestTy, const char *Name);
   2794 LLVMValueRef LLVMBuildTruncOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
   2795                                      LLVMTypeRef DestTy, const char *Name);
   2796 LLVMValueRef LLVMBuildCast(LLVMBuilderRef B, LLVMOpcode Op, LLVMValueRef Val,
   2797                            LLVMTypeRef DestTy, const char *Name);
   2798 LLVMValueRef LLVMBuildPointerCast(LLVMBuilderRef, LLVMValueRef Val,
   2799                                   LLVMTypeRef DestTy, const char *Name);
   2800 LLVMValueRef LLVMBuildIntCast(LLVMBuilderRef, LLVMValueRef Val, /*Signed cast!*/
   2801                               LLVMTypeRef DestTy, const char *Name);
   2802 LLVMValueRef LLVMBuildFPCast(LLVMBuilderRef, LLVMValueRef Val,
   2803                              LLVMTypeRef DestTy, const char *Name);
   2804 
   2805 /* Comparisons */
   2806 LLVMValueRef LLVMBuildICmp(LLVMBuilderRef, LLVMIntPredicate Op,
   2807                            LLVMValueRef LHS, LLVMValueRef RHS,
   2808                            const char *Name);
   2809 LLVMValueRef LLVMBuildFCmp(LLVMBuilderRef, LLVMRealPredicate Op,
   2810                            LLVMValueRef LHS, LLVMValueRef RHS,
   2811                            const char *Name);
   2812 
   2813 /* Miscellaneous instructions */
   2814 LLVMValueRef LLVMBuildPhi(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
   2815 LLVMValueRef LLVMBuildCall(LLVMBuilderRef, LLVMValueRef Fn,
   2816                            LLVMValueRef *Args, unsigned NumArgs,
   2817                            const char *Name);
   2818 LLVMValueRef LLVMBuildSelect(LLVMBuilderRef, LLVMValueRef If,
   2819                              LLVMValueRef Then, LLVMValueRef Else,
   2820                              const char *Name);
   2821 LLVMValueRef LLVMBuildVAArg(LLVMBuilderRef, LLVMValueRef List, LLVMTypeRef Ty,
   2822                             const char *Name);
   2823 LLVMValueRef LLVMBuildExtractElement(LLVMBuilderRef, LLVMValueRef VecVal,
   2824                                      LLVMValueRef Index, const char *Name);
   2825 LLVMValueRef LLVMBuildInsertElement(LLVMBuilderRef, LLVMValueRef VecVal,
   2826                                     LLVMValueRef EltVal, LLVMValueRef Index,
   2827                                     const char *Name);
   2828 LLVMValueRef LLVMBuildShuffleVector(LLVMBuilderRef, LLVMValueRef V1,
   2829                                     LLVMValueRef V2, LLVMValueRef Mask,
   2830                                     const char *Name);
   2831 LLVMValueRef LLVMBuildExtractValue(LLVMBuilderRef, LLVMValueRef AggVal,
   2832                                    unsigned Index, const char *Name);
   2833 LLVMValueRef LLVMBuildInsertValue(LLVMBuilderRef, LLVMValueRef AggVal,
   2834                                   LLVMValueRef EltVal, unsigned Index,
   2835                                   const char *Name);
   2836 
   2837 LLVMValueRef LLVMBuildIsNull(LLVMBuilderRef, LLVMValueRef Val,
   2838                              const char *Name);
   2839 LLVMValueRef LLVMBuildIsNotNull(LLVMBuilderRef, LLVMValueRef Val,
   2840                                 const char *Name);
   2841 LLVMValueRef LLVMBuildPtrDiff(LLVMBuilderRef, LLVMValueRef LHS,
   2842                               LLVMValueRef RHS, const char *Name);
   2843 LLVMValueRef LLVMBuildFence(LLVMBuilderRef B, LLVMAtomicOrdering ordering,
   2844                             LLVMBool singleThread, const char *Name);
   2845 LLVMValueRef LLVMBuildAtomicRMW(LLVMBuilderRef B, LLVMAtomicRMWBinOp op,
   2846                                 LLVMValueRef PTR, LLVMValueRef Val,
   2847                                 LLVMAtomicOrdering ordering,
   2848                                 LLVMBool singleThread);
   2849 
   2850 /**
   2851  * @}
   2852  */
   2853 
   2854 /**
   2855  * @defgroup LLVMCCoreModuleProvider Module Providers
   2856  *
   2857  * @{
   2858  */
   2859 
   2860 /**
   2861  * Changes the type of M so it can be passed to FunctionPassManagers and the
   2862  * JIT.  They take ModuleProviders for historical reasons.
   2863  */
   2864 LLVMModuleProviderRef
   2865 LLVMCreateModuleProviderForExistingModule(LLVMModuleRef M);
   2866 
   2867 /**
   2868  * Destroys the module M.
   2869  */
   2870 void LLVMDisposeModuleProvider(LLVMModuleProviderRef M);
   2871 
   2872 /**
   2873  * @}
   2874  */
   2875 
   2876 /**
   2877  * @defgroup LLVMCCoreMemoryBuffers Memory Buffers
   2878  *
   2879  * @{
   2880  */
   2881 
   2882 LLVMBool LLVMCreateMemoryBufferWithContentsOfFile(const char *Path,
   2883                                                   LLVMMemoryBufferRef *OutMemBuf,
   2884                                                   char **OutMessage);
   2885 LLVMBool LLVMCreateMemoryBufferWithSTDIN(LLVMMemoryBufferRef *OutMemBuf,
   2886                                          char **OutMessage);
   2887 LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRange(const char *InputData,
   2888                                                           size_t InputDataLength,
   2889                                                           const char *BufferName,
   2890                                                           LLVMBool RequiresNullTerminator);
   2891 LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRangeCopy(const char *InputData,
   2892                                                               size_t InputDataLength,
   2893                                                               const char *BufferName);
   2894 const char *LLVMGetBufferStart(LLVMMemoryBufferRef MemBuf);
   2895 size_t LLVMGetBufferSize(LLVMMemoryBufferRef MemBuf);
   2896 void LLVMDisposeMemoryBuffer(LLVMMemoryBufferRef MemBuf);
   2897 
   2898 /**
   2899  * @}
   2900  */
   2901 
   2902 /**
   2903  * @defgroup LLVMCCorePassRegistry Pass Registry
   2904  *
   2905  * @{
   2906  */
   2907 
   2908 /** Return the global pass registry, for use with initialization functions.
   2909     @see llvm::PassRegistry::getPassRegistry */
   2910 LLVMPassRegistryRef LLVMGetGlobalPassRegistry(void);
   2911 
   2912 /**
   2913  * @}
   2914  */
   2915 
   2916 /**
   2917  * @defgroup LLVMCCorePassManagers Pass Managers
   2918  *
   2919  * @{
   2920  */
   2921 
   2922 /** Constructs a new whole-module pass pipeline. This type of pipeline is
   2923     suitable for link-time optimization and whole-module transformations.
   2924     @see llvm::PassManager::PassManager */
   2925 LLVMPassManagerRef LLVMCreatePassManager(void);
   2926 
   2927 /** Constructs a new function-by-function pass pipeline over the module
   2928     provider. It does not take ownership of the module provider. This type of
   2929     pipeline is suitable for code generation and JIT compilation tasks.
   2930     @see llvm::FunctionPassManager::FunctionPassManager */
   2931 LLVMPassManagerRef LLVMCreateFunctionPassManagerForModule(LLVMModuleRef M);
   2932 
   2933 /** Deprecated: Use LLVMCreateFunctionPassManagerForModule instead. */
   2934 LLVMPassManagerRef LLVMCreateFunctionPassManager(LLVMModuleProviderRef MP);
   2935 
   2936 /** Initializes, executes on the provided module, and finalizes all of the
   2937     passes scheduled in the pass manager. Returns 1 if any of the passes
   2938     modified the module, 0 otherwise.
   2939     @see llvm::PassManager::run(Module&) */
   2940 LLVMBool LLVMRunPassManager(LLVMPassManagerRef PM, LLVMModuleRef M);
   2941 
   2942 /** Initializes all of the function passes scheduled in the function pass
   2943     manager. Returns 1 if any of the passes modified the module, 0 otherwise.
   2944     @see llvm::FunctionPassManager::doInitialization */
   2945 LLVMBool LLVMInitializeFunctionPassManager(LLVMPassManagerRef FPM);
   2946 
   2947 /** Executes all of the function passes scheduled in the function pass manager
   2948     on the provided function. Returns 1 if any of the passes modified the
   2949     function, false otherwise.
   2950     @see llvm::FunctionPassManager::run(Function&) */
   2951 LLVMBool LLVMRunFunctionPassManager(LLVMPassManagerRef FPM, LLVMValueRef F);
   2952 
   2953 /** Finalizes all of the function passes scheduled in in the function pass
   2954     manager. Returns 1 if any of the passes modified the module, 0 otherwise.
   2955     @see llvm::FunctionPassManager::doFinalization */
   2956 LLVMBool LLVMFinalizeFunctionPassManager(LLVMPassManagerRef FPM);
   2957 
   2958 /** Frees the memory of a pass pipeline. For function pipelines, does not free
   2959     the module provider.
   2960     @see llvm::PassManagerBase::~PassManagerBase. */
   2961 void LLVMDisposePassManager(LLVMPassManagerRef PM);
   2962 
   2963 /**
   2964  * @}
   2965  */
   2966 
   2967 /**
   2968  * @defgroup LLVMCCoreThreading Threading
   2969  *
   2970  * Handle the structures needed to make LLVM safe for multithreading.
   2971  *
   2972  * @{
   2973  */
   2974 
   2975 /** Deprecated: Multi-threading can only be enabled/disabled with the compile
   2976     time define LLVM_ENABLE_THREADS.  This function always returns
   2977     LLVMIsMultithreaded(). */
   2978 LLVMBool LLVMStartMultithreaded(void);
   2979 
   2980 /** Deprecated: Multi-threading can only be enabled/disabled with the compile
   2981     time define LLVM_ENABLE_THREADS. */
   2982 void LLVMStopMultithreaded(void);
   2983 
   2984 /** Check whether LLVM is executing in thread-safe mode or not.
   2985     @see llvm::llvm_is_multithreaded */
   2986 LLVMBool LLVMIsMultithreaded(void);
   2987 
   2988 /**
   2989  * @}
   2990  */
   2991 
   2992 /**
   2993  * @}
   2994  */
   2995 
   2996 /**
   2997  * @}
   2998  */
   2999 
   3000 #ifdef __cplusplus
   3001 }
   3002 #endif /* !defined(__cplusplus) */
   3003 
   3004 #endif /* !defined(LLVM_C_CORE_H) */
   3005