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